Mooooar buttons (update view)

This commit is contained in:
Alexandre Aubin 2019-10-17 00:06:23 +02:00
parent eab2e2c368
commit 52b4623222
2 changed files with 36 additions and 31 deletions

View file

@ -47,37 +47,42 @@
// System update & upgrade // System update & upgrade
app.get('#/update', function (c) { app.get('#/update', function (c) {
c.api('PUT', '/update', {}, function(data) { c.api('PUT', '/update', {}, function(data) {
c.view('update/update', data); c.view('update/update', data, function() {
// Configure buttons behaviors
$("button[data-upgrade]").on("click", function() {
var what = $(this).data("upgrade").toLowerCase();
// Upgrade all apps or the system
if ((what == "system") || (what == "system"))
{
var confirm_message = y18n.t('confirm_update_' + what);
var api_url = '/upgrade?'+what;
}
// Upgrade a specific apps
else
{
var confirm_message = y18n.t('confirm_update_specific_app', [what]);
var api_url = '/upgrade/apps?app='+what;
}
c.confirm(
y18n.t('tools'),
confirm_message,
function(){
c.api('PUT', api_url, {}, function(data) {
c.redirect_to('#/tools/logs');
});
}
);
});
});
}); });
}); });
// Upgrade apps or packages
app.get('#/upgrade/:type', function (c) {
c.confirm(
y18n.t('tools'),
// confirm_update_apps and confirm_update_packages
y18n.t('confirm_update_' + c.params['type'].toLowerCase()),
function(){
c.api('PUT', '/upgrade?'+c.params["type"], {}, function(data) {
c.redirect_to('#/tools/logs');
});
}
);
});
// Upgrade a specific apps
app.get('#/upgrade/apps/:app', function (c) {
c.confirm(
y18n.t('tools'),
y18n.t('confirm_update_specific_app', [c.params['app']]),
function(){
c.api('PUT', '/upgrade/apps?app='+c.params['app'].toLowerCase(), {}, function(data) {
c.redirect_to('#/tools/logs');
});
}
);
});
// 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=25&with_details", {}, function(categories) {

View file

@ -20,7 +20,7 @@
{{/system}} {{/system}}
</div> </div>
<div class="panel-footer"> <div class="panel-footer">
<a href="#/upgrade/system" role="button" class="btn btn-success">{{t 'system_upgrade_all_packages_btn'}}</a> <button class="btn btn-success" data-upgrade="system">{{t 'system_upgrade_all_packages_btn'}}</button>
</div> </div>
{{else}} {{else}}
<div class="panel-body"> <div class="panel-body">
@ -37,14 +37,14 @@
<div class="list-group"> <div class="list-group">
{{#apps}} {{#apps}}
<div class="list-group-item clearfix"> <div class="list-group-item clearfix">
<a href="#/upgrade/apps/{{id}}" role="button" class="btn btn-success pull-right">{{t 'system_upgrade_btn'}}</a> <button class="btn btn-success pull-right" data-upgrade="{{id}}">{{t 'system_upgrade_btn'}}</button>
<h3 class="list-group-item-heading">{{label}} <small>{{id}}</small></h3> <h3 class="list-group-item-heading">{{label}} <small>{{id}}</small></h3>
<p class="list-group-item-text">{{t 'from_to' current_version new_version}}</p> <p class="list-group-item-text">{{t 'from_to' current_version new_version}}</p>
</div> </div>
{{/apps}} {{/apps}}
</div> </div>
<div class="panel-footer"> <div class="panel-footer">
<a role="button" href="#/upgrade/apps" class="btn btn-success">{{t 'system_upgrade_all_applications_btn'}}</a> <button class="btn btn-success" data-upgrade="apps">{{t 'system_upgrade_all_applications_btn'}}</button>
</div> </div>
{{else}} {{else}}
<div class="panel-body"> <div class="panel-body">