Update / fix JS and template following evolution of the API

This commit is contained in:
Alexandre Aubin 2019-07-31 19:02:14 +02:00
parent 2a41bee642
commit f5b3f392d1
2 changed files with 61 additions and 60 deletions

View file

@ -11,14 +11,14 @@
app.get('#/diagnosis', function (c) {
// Why this method ?
c.api('/diagnosis/show', function(data) {
c.api('/diagnosis/show?full', function(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++)
for (var j = 0 ; j < data.reports[i].items.length ; j++)
{
var type_ = data.reports[i].reports[j].report[0];
var type_ = data.reports[i].items[j].status;
type_ = type_.toLowerCase();
var icon = "";
var issue = false;
@ -35,9 +35,9 @@
icon = "times";
issue = true;
}
data.reports[i].reports[j].report[0] = type_;
data.reports[i].reports[j].icon = icon;
data.reports[i].reports[j].issue = issue;
data.reports[i].items[j].status = type_;
data.reports[i].items[j].icon = icon;
data.reports[i].items[j].issue = issue;
};
};
c.view('diagnosis/diagnosis_show', data, function() {

View file

@ -14,19 +14,20 @@
<div class="panel-body">
<ul class="list-group">
<p>Last time ran : {{formatRelative time}}</p>
{{#reports}}
<li class="list-group-item alert alert-{{report.[0]}} alert-{{report.[0]}}-yo clearfix">
{{#items}}
<li class="list-group-item alert alert-{{status}} alert-{{status}}-yo clearfix">
{{#if icon}}
<span class="fa-fw fa-{{icon}}"></span>
{{/if}}
{{report.[1]}}
{{summary}}
{{#if issue}}
<a href="#" role="button" class="btn btn-sm btn-warning pull-right" style="margin: -5px 5px"><span class="fa-fw fa-times"></span> {{t 'ignore'}}</a>
{{/if}}
{{#if details}}
<a href="#" role="button" class="btn btn-sm btn-default pull-right" style="margin: -5px 5px"><span class="fa-fw fa-level-down"></span>{{t 'details'}}</a>
{{/if}}
</li>
{{/reports}}
{{/items}}
</ul>
</div>
</div>