From 75ab8a3d7630e1714e0df06cfbd15d3c63dd1492 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 31 Aug 2018 13:53:13 +0000 Subject: [PATCH] Add recheck / details and ignore button to the view --- src/js/yunohost/controllers/diagnosis.js | 12 +++++++++--- src/views/diagnosis/diagnosis_show.ms | 15 +++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/js/yunohost/controllers/diagnosis.js b/src/js/yunohost/controllers/diagnosis.js index 0cbb5e84..d757d52c 100644 --- a/src/js/yunohost/controllers/diagnosis.js +++ b/src/js/yunohost/controllers/diagnosis.js @@ -12,28 +12,34 @@ // Why this method ? c.api('/diagnosis/show', function(data) { - console.log(data); - c.view('diagnosis/diagnosis_show', data); for (var i = 0 ; i < data.reports.length ; i++) { + // Convert timestamp to datetime + data.reports[i].time = new Date(data.reports[i].timestamp*1000); for (var j = 0 ; j < data.reports[i].reports.length ; j++) { var type_ = data.reports[i].reports[j].report[0]; type_ = type_.toLowerCase(); var icon = ""; + var issue = false; + if (type_ == "success") { icon = "check-circle"; } else if (type_ == "warning") { icon = "warning"; + issue = true; } else if (type_ == "error") { icon = "times"; + issue = true; } data.reports[i].reports[j].report[0] = type_; - data.reports[i].reports[j].report.push(icon); + data.reports[i].reports[j].icon = icon; + data.reports[i].reports[j].issue = issue; }; }; + c.view('diagnosis/diagnosis_show', data); }, 'GET'); }); diff --git a/src/views/diagnosis/diagnosis_show.ms b/src/views/diagnosis/diagnosis_show.ms index 22325be1..9cb53b12 100644 --- a/src/views/diagnosis/diagnosis_show.ms +++ b/src/views/diagnosis/diagnosis_show.ms @@ -8,16 +8,23 @@ {{#reports}}
-

{{ description }}

+

{{ description }}

+ {{t 'recheck'}}
    +

    Last time ran : {{formatRelative time}}

    {{#reports}} -
  • - {{#if report.[2]}} - +
  • + {{#if icon}} + {{/if}} {{report.[1]}} + {{#if issue}} + {{t 'ignore'}} + {{t 'details'}} + {{/if}} +
  • {{/reports}}