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) {
|
app.get('#/diagnosis', function (c) {
|
||||||
|
|
||||||
// Why this method ?
|
// 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++)
|
for (var i = 0 ; i < data.reports.length ; i++)
|
||||||
{
|
{
|
||||||
// Convert timestamp to datetime
|
// Convert timestamp to datetime
|
||||||
data.reports[i].time = new Date(data.reports[i].timestamp*1000);
|
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();
|
type_ = type_.toLowerCase();
|
||||||
var icon = "";
|
var icon = "";
|
||||||
var issue = false;
|
var issue = false;
|
||||||
|
|
||||||
if (type_ == "success") {
|
if (type_ == "success") {
|
||||||
icon = "check-circle";
|
icon = "check-circle";
|
||||||
}
|
}
|
||||||
else if (type_ == "warning") {
|
else if (type_ == "warning") {
|
||||||
icon = "warning";
|
icon = "warning";
|
||||||
issue = true;
|
issue = true;
|
||||||
}
|
}
|
||||||
else if (type_ == "error") {
|
else if (type_ == "error") {
|
||||||
type_ = "danger";
|
type_ = "danger";
|
||||||
icon = "times";
|
icon = "times";
|
||||||
issue = true;
|
issue = true;
|
||||||
}
|
}
|
||||||
data.reports[i].reports[j].report[0] = type_;
|
data.reports[i].items[j].status = type_;
|
||||||
data.reports[i].reports[j].icon = icon;
|
data.reports[i].items[j].icon = icon;
|
||||||
data.reports[i].reports[j].issue = issue;
|
data.reports[i].items[j].issue = issue;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
c.view('diagnosis/diagnosis_show', data, function() {
|
c.view('diagnosis/diagnosis_show', data, function() {
|
||||||
$(".rerun-diagnosis").click(function() {
|
$(".rerun-diagnosis").click(function() {
|
||||||
var category = $(this).attr("category");
|
var category = $(this).attr("category");
|
||||||
c.api('/diagnosis/run?force', function(data) {
|
c.api('/diagnosis/run?force', function(data) {
|
||||||
// This is a copy-pasta of some of the
|
// This is a copy-pasta of some of the
|
||||||
// redirect/refresh code of sammy.js
|
// redirect/refresh code of sammy.js
|
||||||
// because for some reason calling the function did not work >.>
|
// because for some reason calling the function did not work >.>
|
||||||
var to = "#/diagnosis";
|
var to = "#/diagnosis";
|
||||||
c.trigger('redirect', {to: to});
|
c.trigger('redirect', {to: to});
|
||||||
c.app.last_location = c.path;
|
c.app.last_location = c.path;
|
||||||
c.app.setLocation(to);
|
c.app.setLocation(to);
|
||||||
c.app.trigger('location-changed');
|
c.app.trigger('location-changed');
|
||||||
}, 'POST', {"categories": [category]});
|
}, 'POST', {"categories": [category]});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 'GET');
|
}, 'GET');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,25 +9,26 @@
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h2 class="panel-title" style="display: inline-block">{{ description }}</h2>
|
<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>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<p>Last time ran : {{formatRelative time}}</p>
|
<p>Last time ran : {{formatRelative time}}</p>
|
||||||
{{#reports}}
|
{{#items}}
|
||||||
<li class="list-group-item alert alert-{{report.[0]}} alert-{{report.[0]}}-yo clearfix">
|
<li class="list-group-item alert alert-{{status}} alert-{{status}}-yo clearfix">
|
||||||
{{#if icon}}
|
{{#if icon}}
|
||||||
<span class="fa-fw fa-{{icon}}"></span>
|
<span class="fa-fw fa-{{icon}}"></span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{report.[1]}}
|
{{summary}}
|
||||||
{{#if issue}}
|
{{#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-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}}
|
||||||
{{/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>
|
||||||
</li>
|
{{/if}}
|
||||||
{{/reports}}
|
</li>
|
||||||
</ul>
|
{{/items}}
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/reports}}
|
{{/reports}}
|
||||||
|
|
Loading…
Add table
Reference in a new issue