Merge pull request #310 from YunoHost/log-view-cleanup-and-suboperations

Cleanup + handle suboperations in log views
This commit is contained in:
Alexandre Aubin 2020-09-05 18:44:47 +02:00 committed by GitHub
commit 0c325feabc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 77 deletions

View file

@ -91,38 +91,20 @@
// Display journals list // Display journals list
app.get('#/tools/logs', function (c) { app.get('#/tools/logs', function (c) {
c.api('GET', "/logs?limit=25&with_details", {}, function(categories) { c.api('GET', "/logs?limit=40&with_details", {}, function(operations) {
data = []; operations = operations["operation"];
category_icons = {
'operation': 'wrench',
'history': 'history',
'package': 'puzzle-piece',
'system': 'cogs',
'access': 'ban',
'service': 'cog',
'app': 'cubes'
}
success_icons = { success_icons = {
true: 'check text-success', true: 'check text-success',
false: 'close text-danger', false: 'close text-danger',
'?': 'question text-warning' '?': 'question text-warning'
} }
for (var category in categories) { for (var log in operations)
for (var log in categories[category])
{ {
categories[category][log].success_icon = success_icons[categories[category][log].success] operations[log].success_icon = success_icons[operations[log].success]
}
if (categories.hasOwnProperty(category)) {
data.push({
key:category,
icon:(category in category_icons)?category_icons[category]:'info-circle',
value:categories[category]
});
}
} }
c.view('tools/tools_logs', { c.view('tools/tools_logs', {
"data": data, "operations": operations,
"locale": y18n.locale "locale": y18n.locale
}); });
}); });
@ -131,16 +113,10 @@
// One journal // One journal
app.get(/\#\/tools\/logs\/(.*)(\?number=(\d+))?/, function (c) { app.get(/\#\/tools\/logs\/(.*)(\?number=(\d+))?/, function (c) {
var params = "?path=" + c.params["splat"][0]; var params = "?path=" + c.params["splat"][0];
var number = (c.params["number"])?c.params["number"]:50; var number = (c.params["number"])?c.params["number"]:25;
params += "&filter_irrelevant&number=" + number; params += "&filter_irrelevant&with_suboperations&number=" + number;
c.api('GET', "/logs/display" + params, {}, function(log) { c.api('GET', "/logs/display" + params, {}, function(log) {
if ('metadata' in log) {
if (!'env' in log.metadata && 'args' in log.metadata) {
log.metadata.env = log.metadata.args
}
}
c.view('tools/tools_log', { c.view('tools/tools_log', {
"log": log, "log": log,
"next_number": log.logs.length == number ? number * 10:false, "next_number": log.logs.length == number ? number * 10:false,

View file

@ -212,6 +212,7 @@
"passwords_too_short": "Password is too short", "passwords_too_short": "Password is too short",
"path": "Path", "path": "Path",
"logs": "Logs", "logs": "Logs",
"log_suboperations": "Sub-operations",
"logs_operation": "Operations made on system with YunoHost", "logs_operation": "Operations made on system with YunoHost",
"logs_history": "History of command run on system", "logs_history": "History of command run on system",
"logs_package": "Debian packages management history", "logs_package": "Debian packages management history",

View file

@ -23,6 +23,14 @@
{{#if log.metadata.started_at}}<dt>{{t 'logs_started_at'}}</dt> <dd>{{formatTime log.metadata.started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd> {{#if log.metadata.started_at}}<dt>{{t 'logs_started_at'}}</dt> <dd>{{formatTime log.metadata.started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>
{{/if}}{{#if log.metadata.ended_at}}<dt>{{t 'logs_ended_at'}}</dt> <dd>{{formatTime log.metadata.ended_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>{{/if}} {{/if}}{{#if log.metadata.ended_at}}<dt>{{t 'logs_ended_at'}}</dt> <dd>{{formatTime log.metadata.ended_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>{{/if}}
{{#if log.metadata.error}}<dt>{{t 'logs_error'}}</dt> <dd>{{log.metadata.error}}</dd>{{/if}} {{#if log.metadata.error}}<dt>{{t 'logs_error'}}</dt> <dd>{{log.metadata.error}}</dd>{{/if}}
{{#if log.metadata.suboperations}}
<dt>{{t 'log_suboperations'}}</dt>
{{#log.metadata.suboperations}}
<dd>{{#unless success }}<span class="fa-fw fa-close text-danger"></span>{{/unless}}
<a href="#/tools/logs/{{ name }}">{{ description }}</a></dd>
{{/log.metadata.suboperations}}
{{/if}}
</dl> </dl>
</div> </div>
</div> </div>
@ -33,28 +41,6 @@
</div> </div>
{{/unless}} {{/unless}}
<!--
{{#if log.metadata.env}}
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-context">
<h2 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-context" aria-expanded="true" aria-controls="collapse-context">
<span class="fa-fw fa-bug"></span>{{t 'logs_context'}}
</a>
</h2>
</div>
<div id="collapse-context" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-context">
<div class="panel-body">
<dl class="dl-horizontal" id="env">
{{#each log.metadata.env}}<dt>{{@key}}</dt> <dd>{{.}}</dd>
{{/each}}
</dl>
</div>
</div>
</div>
{{/if}}
-->
{{/if}} {{/if}}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading"> <div class="panel-heading">

View file

@ -7,29 +7,17 @@
<div class="separator"></div> <div class="separator"></div>
{{#intl locales=locale}} {{#intl locales=locale}}
{{#if data}}
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
{{#data}}
{{#if value}}
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-{{key}}"> <div class="panel-heading">
<h2 class="panel-title"> <h2 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapse-{{key}}" aria-expanded="true" aria-controls="collapse-{{key}}"> <span class="fa-fw fa-wrench"></span>{{t 'logs_operation'}}
<span class="fa-fw fa-{{icon}}"></span>{{t (concat 'logs_' key)}}
</a>
</h2> </h2>
</div> </div>
<div id="collapse-{{key}}" class="panel-collapse{{#if @first}}{{else}} collapse{{/if}}" role="tabpanel" aria-labelledby="heading-{{key}}">
<div class="list-group"> <div class="list-group">
{{#value}} {{#operations}}
<a href="#/tools/logs/{{ name }}" class="list-group-item slide" title='{{formatTime started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}'><small style="margin-right:20px;" >{{formatRelative started_at}}</small> <a href="#/tools/logs/{{ name }}" class="list-group-item slide" title='{{formatTime started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}'><small style="margin-right:20px;" >{{formatRelative started_at}}</small>
<span class="fa-fw fa-{{success_icon}}"></span> {{ description }}</a> <span class="fa-fw fa-{{success_icon}}"></span> {{ description }}</a>
{{/value}} {{/operations}}
</div> </div>
</div> </div>
</div>
{{/if}}
{{/data}}
</div>
{{/if}}
{{/intl}} {{/intl}}