Buttons are healthier than <a>, in particular here to avoid ugly js in the middle of the template

This commit is contained in:
Alexandre Aubin 2019-10-16 22:45:44 +02:00
parent e054675230
commit e5ce0ac19d
2 changed files with 13 additions and 4 deletions

View file

@ -122,7 +122,7 @@
var params = "?path=" + c.params["splat"][0];
var number = (c.params["number"])?c.params["number"]:50;
params += "&number=" + number;
c.api('GET', "/logs/display" + params, {}, function(log) {
if ('metadata' in log) {
if (!'env' in log.metadata && 'args' in log.metadata) {
@ -133,10 +133,19 @@
"log": log,
"next_number": log.logs.length == number ? number * 10:false,
"locale": y18n.locale
}, function() {
// Configure behavior for the button to share log on Yunohost (it calls display --share)
$("#share-with-yunopaste").on("click", function() {
c.api('GET', '/logs/display?path='+$(this).data('log-id')+'&share', {},
function(data) {
$('div.loader').remove();
window.open(data.url, '_blank');
});
});
});
});
});
// Download SSL Certificate Authority
app.get('#/tools/ca', function (c) {

View file

@ -10,9 +10,9 @@
</div>
<div class="actions-group">
<a href="javascript:void(null);" onclick="c.api('GET', '/logs/display?path={{#if log.name}}{{ log.name }}{{else}}{{ log.log_path }}{{/if}}&share', {}, function(data) { $('div.loader').remove(); window.open(data.url, '_blank'); });" class="btn btn-success">
<button id="share-with-yunopaste" class="btn btn-success" data-log-id="{{#if log.name}}{{ log.name }}{{else}}{{ log.log_path }}{{/if}}">
<span class="fa-cloud-upload"></span> {{t 'logs_share_with_yunopaste'}}
</a>
</button>
</div>
<div class="separator"></div>