[enh] Add context in log paste feature

This commit is contained in:
ljf 2018-06-04 03:32:04 +02:00
parent 6a04b57ca6
commit 07d2e1c3bd
2 changed files with 12 additions and 19 deletions

View file

@ -395,7 +395,7 @@
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: 'https://paste.yunohost.org/documents', url: 'https://paste.yunohost.org/documents',
data: preElement[0].innerHTML, data: preElement.text(),
}) })
.success(function(data, textStatus, jqXHR) { .success(function(data, textStatus, jqXHR) {
window.open('https://paste.yunohost.org/' + data.key, '_blank'); window.open('https://paste.yunohost.org/' + data.key, '_blank');

View file

@ -6,7 +6,7 @@
</div> </div>
<div class="actions-group"> <div class="actions-group">
<a data-paste-content="#log" class="btn btn-success"> <a data-paste-content="#description, #metadata, #env, #log" class="btn btn-success">
<span class="fa-cloud-upload"></span> {{t 'upload'}} <span class="fa-cloud-upload"></span> {{t 'upload'}}
</a> </a>
</div> </div>
@ -16,19 +16,14 @@
{{#if log.metadata}} {{#if log.metadata}}
<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> {{ log.description }}</h2> <!-- PLEASE DON'T INDENT THIS CODE, IT IS PASTED ON YUNOPASTE -->
<h2 class="panel-title" id="description"><span class="fa-fw fa-info-circle"></span> {{ log.description }}</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<dl class="dl-horizontal"> <dl class="dl-horizontal" id="metadata">
<dt>{{t 'path'}}</dt> <dd>{{ log.log_path }}</dd> <dt>{{t 'path'}}</dt> <dd>{{ log.log_path }}</dd>
{{#if log.metadata.started_at}} {{#if log.metadata.started_at}}<dt>{{t 'started_at'}}</dt> <dd>{{formatTime log.metadata.started_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>
<dt>{{t 'started_at'}}</dt> {{/if}}{{#if log.metadata.ended_at}}<dt>{{t 'ended_at'}}</dt> <dd>{{formatTime log.metadata.ended_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>{{/if}}
<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 'ended_at'}}</dt>
<dd>{{formatTime log.metadata.ended_at day="numeric" month="long" year="numeric" hour="numeric" minute="numeric"}}</dd>
{{/if}}
</dl> </dl>
</div> </div>
</div> </div>
@ -43,11 +38,9 @@
</div> </div>
<div id="collapse-context" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-context"> <div id="collapse-context" class="panel-collapse collapse" role="tabpanel" aria-labelledby="heading-context">
<div class="panel-body"> <div class="panel-body">
<dl class="dl-horizontal"> <dl class="dl-horizontal" id="env">
{{#each log.metadata.env}} {{#each log.metadata.env}}<dt>{{@key}}</dt> <dd>{{.}}</dd>
<dt>{{@key}}</dt> {{/each}}
<dd>{{.}}</dd>
{{/each}}
</dl> </dl>
</div> </div>
</div> </div>
@ -63,8 +56,8 @@
{{#if log.metadata.error}} {{#if log.metadata.error}}
<div class="alert alert-warning" role="alert"><span class="fas fa-exclamation-triangle"></span> <strong>{{t 'Error'}}</strong>: {{log.metadata.error}}</div> <div class="alert alert-warning" role="alert"><span class="fas fa-exclamation-triangle"></span> <strong>{{t 'Error'}}</strong>: {{log.metadata.error}}</div>
{{/if}} {{/if}}
{{#if next_number}}<a href="#/tools/logs/{{#if log.name}}{{ log.name }}{{else}}{{ log.log_path }}{{/if}}?number={{ next_number }}">MORE</a>{{/if}}
<!-- no indent because pre is sensible to whitespaces --> <!-- no indent because pre is sensible to whitespaces -->
{{#if next_number}}<a href="#/tools/logs/{{ log.log_path }}?number={{ next_number }}">MORE</a>{{/if}}
<pre id="log" class="full-width">{{#log.logs}}{{.}} <pre id="log" class="full-width">{{#log.logs}}{{.}}
{{/log.logs}}</pre> {{/log.logs}}</pre>
</div> </div>