]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/tools/tools/dmarc_reports/app.js
10 //filterDate: (new Date()).toISOString().substring(0, 7),
14 created: async
function () {
18 this.info
= await
this.getInfo();
19 this.summaries
= this.info
.summaries
;
23 filtered: function () {
25 let filtered
= this.summaries
.filter(function (summary
) {
26 return (!that
.filterGreen
|| that
.getColor(summary
) !== "lime")
27 && (!that
.filterDomain
|| summary
.domain
=== that
.filterDomain
)
28 && (!that
.filterOrg
|| summary
.org
=== that
.filterOrg
)
29 && (!that
.filterDate
|| that
.inDates(summary
));
32 return filtered
.reverse();
37 toggle: async
function(summary
) {
38 if (this.selectedSummary
&& this.selectedSummary
.serial
=== summary
.serial
) {
39 this.selectedSummary
= null;
41 if (!summary
.details
) {
42 summary
.details
= await
this.getDetails(summary
.serial
);
44 this.selectedSummary
= summary
;
47 inDates: function(summary
) {
48 if (!this.filterDate
) { return true; }
50 let mindate
= (new Date(summary
.mindate
)).toISOString().substring(0, 7);
51 let maxdate
= (new Date(summary
.maxdate
)).toISOString().substring(0, 7);
53 return mindate
=== this.filterDate
|| maxdate
=== this.filterDate
;
55 printDate: function (date
) {
56 return (new Date(date
)).toISOString();
58 getColor: function (element
) {
59 if (element
.dkimresult
=== "fail" && element
.spfresult
=== "fail") {
61 } else if (element
.dkimresult
=== "fail" || element
.spfresult
=== "fail") {
63 } else if (element
.dkimresult
=== "pass" && element
.spfresult
=== "pass") {
69 getInfo: function (event
) {
70 return fetch('api.php').then(function (response
) {
71 if (response
.status
!= 200) { return; }
72 return response
.text().then(function (body
) {
73 return JSON
.parse(body
);
77 getDetails: function (serial
) {
78 return fetch(`api.php?serial=${serial}`).then(function (response
) {
79 if (response
.status
!= 200) { return; }
80 return response
.text().then(function (body
) {
81 return JSON
.parse(body
);