From 142facec09cccced808d00c28977e65f65392274 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 1 Aug 2019 15:10:36 +0200 Subject: [PATCH] Add a badge summarizing number of issues per category --- src/js/yunohost/controllers/diagnosis.js | 5 +++++ src/views/diagnosis/diagnosis_show.ms | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/yunohost/controllers/diagnosis.js b/src/js/yunohost/controllers/diagnosis.js index 6c583daf..94203674 100644 --- a/src/js/yunohost/controllers/diagnosis.js +++ b/src/js/yunohost/controllers/diagnosis.js @@ -16,6 +16,8 @@ { // Convert timestamp to datetime data.reports[i].time = new Date(data.reports[i].timestamp*1000); + data.reports[i].warnings = 0; + data.reports[i].errors = 0; for (var j = 0 ; j < data.reports[i].items.length ; j++) { var type_ = data.reports[i].items[j].status; @@ -29,16 +31,19 @@ else if (type_ == "warning") { icon = "warning"; issue = true; + data.reports[i].warnings++; } else if (type_ == "error") { type_ = "danger"; icon = "times"; issue = true; + data.reports[i].errors++; } data.reports[i].items[j].status = type_; data.reports[i].items[j].icon = icon; data.reports[i].items[j].issue = issue; }; + data.reports[i].noIssues = data.reports[i].warnings + data.reports[i].errors ? false : true; }; c.view('diagnosis/diagnosis_show', data, function() { $(".rerun-diagnosis").click(function() { diff --git a/src/views/diagnosis/diagnosis_show.ms b/src/views/diagnosis/diagnosis_show.ms index 6641006d..e5c40f91 100644 --- a/src/views/diagnosis/diagnosis_show.ms +++ b/src/views/diagnosis/diagnosis_show.ms @@ -8,8 +8,11 @@ {{#reports}}
-

{{ description }}

- {{t 'rerun_diagnosis'}} +

{{ description }}

+ {{#if noIssues}}Everything good!{{/if}} + {{#if errors}}{{ errors }} errors{{/if}} + {{#if warnings}}{{ warnings }} warnings{{/if}} + {{t 'rerun_diagnosis'}}