X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fprivate%2Fwebsites%2Ftools%2Ftools%2Fdmarc_reports%2Fapp.js;h=8e8a6c47a57105c39cd007facab3b7f624bab4f2;hb=9c08c3bc093d3d4547214daf057051e7384581e9;hp=7fe67d01d1345dee47792dadd2c0ab20bcf0a16f;hpb=7df5e532c1ce2ab9e8527615c08c1178990870e6;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/modules/private/websites/tools/tools/dmarc_reports/app.js b/modules/private/websites/tools/tools/dmarc_reports/app.js index 7fe67d0..8e8a6c4 100644 --- a/modules/private/websites/tools/tools/dmarc_reports/app.js +++ b/modules/private/websites/tools/tools/dmarc_reports/app.js @@ -2,7 +2,7 @@ const app = new Vue({ el: '#app', data: { info: null, - summaries: [], + summaries: null, selectedSummary: null, filterGreen: true, filterDomain: null, @@ -10,16 +10,31 @@ const app = new Vue({ //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) { @@ -53,7 +68,7 @@ const app = new Vue({ 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") { @@ -67,7 +82,8 @@ const app = new Vue({ } }, 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); @@ -75,7 +91,8 @@ const app = new Vue({ }); }, 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);