mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
Reingrate log view directly at the bottom of the service status page, now that we have at least the journalctl as a meaninful log. + various cosmetic and button tweaks
This commit is contained in:
parent
e187e4b61a
commit
c6b1bfb1c2
2 changed files with 53 additions and 42 deletions
|
@ -40,15 +40,26 @@
|
||||||
// Status & actions for a service
|
// Status & actions for a service
|
||||||
app.get('#/services/:service', function (c) {
|
app.get('#/services/:service', function (c) {
|
||||||
c.api('GET', '/services/'+ c.params['service'], {}, function(data) {
|
c.api('GET', '/services/'+ c.params['service'], {}, function(data) {
|
||||||
|
c.api('GET', '/services/'+ c.params['service'] +'/log', {number: 50}, function(data_log) {
|
||||||
|
|
||||||
data.name = c.params['service'];
|
data.name = c.params['service'];
|
||||||
if (data.last_state_change == 'unknown')
|
if (data.last_state_change == 'unknown')
|
||||||
{
|
{
|
||||||
data.last_state_change = 0;
|
data.last_state_change = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.logs = [];
|
||||||
|
$.each(data_log, function(k, v) {
|
||||||
|
data.logs.push({filename: k, filecontent: v.join('\n')});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Sort logs by filename, put the journalctl/systemd log on top
|
||||||
|
data.logs.sort(function(a,b) { return a.filename === "journalctl" ? -1 : b.filename === "journalctl" ? 1 : a.filename < b.filename ? -1 : a.filename > b.filename ? 1 : 0; });
|
||||||
|
|
||||||
c.view('service/service_info', data, function() {
|
c.view('service/service_info', data, function() {
|
||||||
|
|
||||||
// Configure behavior for enable/disable and start/stop buttons
|
// Configure behavior for enable/disable and start/stop buttons
|
||||||
$('button[data-action]').on('click', function() {
|
$('button[data-action="start"], button[data-action="stop"]').on('click', function() {
|
||||||
|
|
||||||
var service = $(this).data('service');
|
var service = $(this).data('service');
|
||||||
var action = $(this).data('action');
|
var action = $(this).data('action');
|
||||||
|
@ -58,32 +69,35 @@
|
||||||
var method = null,
|
var method = null,
|
||||||
endurl = service;
|
endurl = service;
|
||||||
|
|
||||||
switch (action) {
|
method = action === "start" ? 'PUT' : 'DELETE';
|
||||||
case 'start':
|
|
||||||
method = 'PUT';
|
|
||||||
break;
|
|
||||||
case 'stop':
|
|
||||||
method = 'DELETE';
|
|
||||||
break;
|
|
||||||
case 'enable':
|
|
||||||
method = 'PUT';
|
|
||||||
endurl += '/enable';
|
|
||||||
break;
|
|
||||||
case 'disable':
|
|
||||||
method = 'DELETE';
|
|
||||||
endurl += '/enable';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
c.flash('fail', y18n.t('unknown_action', [action]));
|
|
||||||
c.refresh();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
c.api(method, '/services/'+ endurl, {}, function() { c.refresh(); });
|
c.api(method, '/services/'+ endurl, {}, function() { c.refresh(); });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Configure behavior for enable/disable and start/stop buttons
|
||||||
|
$('button[data-action="share"]').on('click', function() {
|
||||||
|
|
||||||
|
c.showLoader();
|
||||||
|
|
||||||
|
// Send to paste.yunohost.org
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: 'https://paste.yunohost.org/documents',
|
||||||
|
data: $("#logs").text(),
|
||||||
|
})
|
||||||
|
.success(function(data, textStatus, jqXHR) {
|
||||||
|
window.open('https://paste.yunohost.org/' + data.key, '_blank');
|
||||||
|
})
|
||||||
|
.fail(function() {
|
||||||
|
c.flash('fail', y18n.t('paste_error'));
|
||||||
|
})
|
||||||
|
.always(function(){
|
||||||
|
c.hideLoader();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Service log
|
// Service log
|
||||||
|
|
|
@ -9,14 +9,20 @@
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h2 class="panel-title"><span class="fa-fw fa-info-circle"></span> {{t 'infos'}}</h2>
|
<h2 class="panel-title" style="display: inline-block; margin-right: 10px;"><span class="fa-fw fa-info-circle"></span> {{t name}}</h2>
|
||||||
|
{{#if (eq status "running")}}
|
||||||
|
<button class="btn btn-sm btn-danger pull-right" data-service="{{name}}" data-action="stop">
|
||||||
|
<span class="fa-stop"></span> {{t 'stop'}}
|
||||||
|
</button>
|
||||||
|
{{else}}
|
||||||
|
<button class="btn btn-sm btn-success pull-right" data-service="{{name}}" data-action="start">
|
||||||
|
<span class="fa-play"></span> {{t 'start'}}
|
||||||
|
</button>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<dl class="dl-horizontal">
|
<dl class="dl-horizontal">
|
||||||
|
|
||||||
<dt>{{t 'name'}}</dt>
|
|
||||||
<dd>{{name}}</dd>
|
|
||||||
|
|
||||||
<dt>{{t 'description'}}</dt>
|
<dt>{{t 'description'}}</dt>
|
||||||
<dd>{{description}}</dd>
|
<dd>{{description}}</dd>
|
||||||
|
|
||||||
|
@ -55,24 +61,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h2 class="panel-title"><span class="fa-fw fa-wrench"></span> {{t 'operations'}}</h2>
|
<h2 class="panel-title" style="display: inline-block; margin-right: 10px;"><span class="fa-fw fa-book"></span> {{t 'logs'}}</h2>
|
||||||
|
<button class="btn btn-sm btn-success pull-right" data-action="share"><span class="fa-cloud-upload"></span> {{t 'logs_share_with_yunopaste'}}</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div id="logs" class="panel-body">
|
||||||
<dl class="dl-horizontal">
|
{{#logs}}
|
||||||
|
<h2>{{filename}}</h2>
|
||||||
{{#if (eq status "running")}}
|
<pre class="service-log">{{filecontent}}</pre>
|
||||||
<button class="btn btn-danger" data-service="{{name}}" data-action="stop">
|
{{/logs}}
|
||||||
<span class="fa-stop"></span> {{t 'stop'}}
|
|
||||||
</button>
|
|
||||||
{{else}}
|
|
||||||
<button class="btn btn-success" data-service="{{name}}" data-action="start">
|
|
||||||
<span class="fa-play"></span> {{t 'start'}}
|
|
||||||
</button>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
</dl>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue