Merge pull request #241 from YunoHost/improve-log-list

[enh] Improve log list
This commit is contained in:
Alexandre Aubin 2019-05-13 13:48:07 +02:00 committed by GitHub
commit 135aba64a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 4 deletions

View file

@ -97,9 +97,9 @@
// Display journals list // Display journals list
app.get('#/tools/logs', function (c) { app.get('#/tools/logs', function (c) {
c.api("/logs", function(categories) { c.api("/logs?limit=25&with_details", function(categories) {
data = []; data = [];
icons = { category_icons = {
'operation': 'wrench', 'operation': 'wrench',
'history': 'history', 'history': 'history',
'package': 'puzzle-piece', 'package': 'puzzle-piece',
@ -108,11 +108,20 @@
'service': 'cog', 'service': 'cog',
'app': 'cubes' 'app': 'cubes'
} }
success_icons = {
true: 'check text-success',
false: 'close text-danger',
'?': 'question text-warning'
}
for (var category in categories) { for (var category in categories) {
for (var log in categories[category])
{
categories[category][log].success_icon = success_icons[categories[category][log].success]
}
if (categories.hasOwnProperty(category)) { if (categories.hasOwnProperty(category)) {
data.push({ data.push({
key:category, key:category,
icon:(category in icons)?icons[category]:'info-circle', icon:(category in category_icons)?category_icons[category]:'info-circle',
value:categories[category] value:categories[category]
}); });
} }

View file

@ -2,7 +2,11 @@
<a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a> <a href="#/" ><i class="fa-home"></i><span class="sr-only">{{t 'home'}}</span></a>
<a href="#/tools">{{t 'tools'}}</a> <a href="#/tools">{{t 'tools'}}</a>
<a href="#/tools/logs">{{t 'logs'}}</a> <a href="#/tools/logs">{{t 'logs'}}</a>
{{#if log.name}}
<a href="#/tools/logs/{{ log.name }}">{{ log.name }}</a>
{{else}}
<a href="#/tools/logs/{{ log.log_path }}">{{ log.log_path }}</a> <a href="#/tools/logs/{{ log.log_path }}">{{ log.log_path }}</a>
{{/if}}
</div> </div>
<div class="actions-group"> <div class="actions-group">

View file

@ -22,7 +22,8 @@
<div id="collapse-{{key}}" class="panel-collapse{{#if @first}}{{else}} collapse{{/if}}" role="tabpanel" aria-labelledby="heading-{{key}}"> <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}} {{#value}}
<a href="#/tools/logs/{{ name }}" class="list-group-item" title='{{formatTime started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}'><small style="margin-right:20px;" >{{formatRelative started_at}}</small> {{ description }}</a> <a href="#/tools/logs/{{ name }}" class="list-group-item" 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>
{{/value}} {{/value}}
</div> </div>
</div> </div>