Add recheck / details and ignore button to the view

This commit is contained in:
Alexandre Aubin 2018-08-31 13:53:13 +00:00
parent 948872b727
commit 75ab8a3d76
2 changed files with 20 additions and 7 deletions

View file

@ -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');
});

View file

@ -8,16 +8,23 @@
{{#reports}}
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="panel-title">{{ description }}</h2>
<h2 class="panel-title" style="display: inline-block">{{ description }}</h2>
<a href="#" role="button" class="btn btn-sm btn-info pull-right"><span class="fa-fw fa-refresh"></span> {{t 'recheck'}}</a>
</div>
<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">
{{#if report.[2]}}
<span class="fa-fw fa-{{report.[2]}}"></span>
<li class="list-group-item alert alert-{{report.[0]}} alert-{{report.[0]}}-yo clearfix">
{{#if icon}}
<span class="fa-fw fa-{{icon}}"></span>
{{/if}}
{{report.[1]}}
{{#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>
<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}}
</ul>