mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Update / fix JS and template following evolution of the API
This commit is contained in:
parent
2a41bee642
commit
f5b3f392d1
2 changed files with 61 additions and 60 deletions
|
@ -11,50 +11,50 @@
|
|||
app.get('#/diagnosis', function (c) {
|
||||
|
||||
// Why this method ?
|
||||
c.api('/diagnosis/show', 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++)
|
||||
{
|
||||
var type_ = data.reports[i].reports[j].report[0];
|
||||
type_ = type_.toLowerCase();
|
||||
var icon = "";
|
||||
var issue = false;
|
||||
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].items.length ; j++)
|
||||
{
|
||||
var type_ = data.reports[i].items[j].status;
|
||||
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") {
|
||||
type_ = "danger";
|
||||
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;
|
||||
};
|
||||
};
|
||||
c.view('diagnosis/diagnosis_show', data, function() {
|
||||
$(".rerun-diagnosis").click(function() {
|
||||
var category = $(this).attr("category");
|
||||
c.api('/diagnosis/run?force', function(data) {
|
||||
// This is a copy-pasta of some of the
|
||||
// redirect/refresh code of sammy.js
|
||||
// because for some reason calling the function did not work >.>
|
||||
var to = "#/diagnosis";
|
||||
c.trigger('redirect', {to: to});
|
||||
c.app.last_location = c.path;
|
||||
c.app.setLocation(to);
|
||||
c.app.trigger('location-changed');
|
||||
}, 'POST', {"categories": [category]});
|
||||
});
|
||||
});
|
||||
if (type_ == "success") {
|
||||
icon = "check-circle";
|
||||
}
|
||||
else if (type_ == "warning") {
|
||||
icon = "warning";
|
||||
issue = true;
|
||||
}
|
||||
else if (type_ == "error") {
|
||||
type_ = "danger";
|
||||
icon = "times";
|
||||
issue = true;
|
||||
}
|
||||
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() {
|
||||
$(".rerun-diagnosis").click(function() {
|
||||
var category = $(this).attr("category");
|
||||
c.api('/diagnosis/run?force', function(data) {
|
||||
// This is a copy-pasta of some of the
|
||||
// redirect/refresh code of sammy.js
|
||||
// because for some reason calling the function did not work >.>
|
||||
var to = "#/diagnosis";
|
||||
c.trigger('redirect', {to: to});
|
||||
c.app.last_location = c.path;
|
||||
c.app.setLocation(to);
|
||||
c.app.trigger('location-changed');
|
||||
}, 'POST', {"categories": [category]});
|
||||
});
|
||||
});
|
||||
}, 'GET');
|
||||
|
||||
});
|
||||
|
|
|
@ -9,25 +9,26 @@
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h2 class="panel-title" style="display: inline-block">{{ description }}</h2>
|
||||
<a role="button" category="{{ id }}" class="btn btn-sm btn-info pull-right rerun-diagnosis"><span class="fa-fw fa-refresh"></span> {{t 'rerun_diagnosis'}}</a>
|
||||
<a role="button" category="{{ id }}" class="btn btn-sm btn-info pull-right rerun-diagnosis"><span class="fa-fw fa-refresh"></span> {{t 'rerun_diagnosis'}}</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 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>
|
||||
<ul class="list-group">
|
||||
<p>Last time ran : {{formatRelative time}}</p>
|
||||
{{#items}}
|
||||
<li class="list-group-item alert alert-{{status}} alert-{{status}}-yo clearfix">
|
||||
{{#if icon}}
|
||||
<span class="fa-fw fa-{{icon}}"></span>
|
||||
{{/if}}
|
||||
{{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>
|
||||
{{/items}}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{{/reports}}
|
||||
|
|
Loading…
Add table
Reference in a new issue