el: '#app',
data: {
info: null,
- summaries: [],
+ summaries: null,
selectedSummary: null,
filterGreen: true,
filterDomain: null,
//filterDate: (new Date()).toISOString().substring(0, 7),
filterDate: null,
reverse: true,
+ anonymous: true,
},
created: async function () {
let that = this;
- try {
- this.info = await this.getInfo();
- this.summaries = this.info.summaries;
- } catch (error) {}
+ if ('anonymous' in localStorage) {
+ this.anonymous = JSON.parse(localStorage.anonymous);
+ }
+ this.fetchAll();
},
methods: {
+ fetchAll: async function() {
+ try {
+ this.info = await this.getInfo();
+ this.summaries = this.info.summaries;
+ } catch (error) {
+ this.info = null;
+ this.summaries = null;
+ }
+ },
+ toggleAnonymous: function() {
+ this.anonymous = !this.anonymous;
+ localStorage.anonymous = this.anonymous;
+ this.fetchAll();
+ },
filtered: function () {
let that = this;
let filtered = this.summaries.filter(function (summary) {
return mindate === this.filterDate || maxdate === this.filterDate;
},
printDate: function (date) {
- return (new Date(date)).toISOString();
+ return (new Date(date)).toISOString().replace("T", " ").replace(/\..*Z$/, " UTC");
},
getColor: function (element) {
if (element.dkimresult === "fail" && element.spfresult === "fail") {
}
},
getInfo: function (event) {
- return fetch('api.php').then(function (response) {
+ let anonymous = this.anonymous ? "anonymous=1" : "";
+ return fetch(`api.php?${anonymous}`).then(function (response) {
if (response.status != 200) { return; }
return response.text().then(function (body) {
return JSON.parse(body);
});
},
getDetails: function (serial) {
- return fetch(`api.php?serial=${serial}`).then(function (response) {
+ let anonymous = this.anonymous ? "&anonymous=1" : "";
+ return fetch(`api.php?serial=${serial}${anonymous}`).then(function (response) {
if (response.status != 200) { return; }
return response.text().then(function (body) {
return JSON.parse(body);