]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - tools/tools/dmarc_reports/app.js
10 //filterDate: (new Date()).toISOString().substring(0, 7),
15 created: async
function () {
18 if ('anonymous' in localStorage
) {
19 this.anonymous
= JSON
.parse(localStorage
.anonymous
);
24 fetchAll: async
function() {
26 this.info
= await
this.getInfo();
27 this.summaries
= this.info
.summaries
;
30 this.summaries
= null;
33 toggleAnonymous: function() {
34 this.anonymous
= !this.anonymous
;
35 localStorage
.anonymous
= this.anonymous
;
38 filtered: function () {
40 let filtered
= this.summaries
.filter(function (summary
) {
41 return (!that
.filterGreen
|| that
.getColor(summary
) !== "lime")
42 && (!that
.filterDomain
|| summary
.domain
=== that
.filterDomain
)
43 && (!that
.filterOrg
|| summary
.org
=== that
.filterOrg
)
44 && (!that
.filterDate
|| that
.inDates(summary
));
47 return filtered
.reverse();
52 toggle: async
function(summary
) {
53 if (this.selectedSummary
&& this.selectedSummary
.serial
=== summary
.serial
) {
54 this.selectedSummary
= null;
56 if (!summary
.details
) {
57 summary
.details
= await
this.getDetails(summary
.serial
);
59 this.selectedSummary
= summary
;
62 inDates: function(summary
) {
63 if (!this.filterDate
) { return true; }
65 let mindate
= (new Date(summary
.mindate
)).toISOString().substring(0, 7);
66 let maxdate
= (new Date(summary
.maxdate
)).toISOString().substring(0, 7);
68 return mindate
=== this.filterDate
|| maxdate
=== this.filterDate
;
70 printDate: function (date
) {
71 return (new Date(date
)).toISOString().replace("T", " ").replace(/\..*Z$/, " UTC");
73 getColor: function (element
) {
74 if (element
.dkimresult
=== "fail" && element
.spfresult
=== "fail") {
76 } else if (element
.dkimresult
=== "fail" || element
.spfresult
=== "fail") {
78 } else if (element
.dkimresult
=== "pass" && element
.spfresult
=== "pass") {
84 getInfo: function (event
) {
85 let anonymous
= this.anonymous
? "anonymous=1" : "";
86 return fetch(`api.php?${anonymous}`).then(function (response
) {
87 if (response
.status
!= 200) { return; }
88 return response
.text().then(function (body
) {
89 return JSON
.parse(body
);
93 getDetails: function (serial
) {
94 let anonymous
= this.anonymous
? "&anonymous=1" : "";
95 return fetch(`api.php?serial=${serial}${anonymous}`).then(function (response
) {
96 if (response
.status
!= 200) { return; }
97 return response
.text().then(function (body
) {
98 return JSON
.parse(body
);