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,36 +47,41 @@
// 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() {
// Upgrade apps or packages var what = $(this).data("upgrade").toLowerCase();
app.get('#/upgrade/:type', function (c) {
c.confirm( // Upgrade all apps or the system
y18n.t('tools'),
// confirm_update_apps and confirm_update_packages if ((what == "system") || (what == "system"))
y18n.t('confirm_update_' + c.params['type'].toLowerCase()), {
function(){ var confirm_message = y18n.t('confirm_update_' + what);
c.api('PUT', '/upgrade?'+c.params["type"], {}, function(data) { var api_url = '/upgrade?'+what;
c.redirect_to('#/tools/logs');
});
} }
);
});
// Upgrade a specific apps // Upgrade a specific apps
app.get('#/upgrade/apps/:app', function (c) {
else
{
var confirm_message = y18n.t('confirm_update_specific_app', [what]);
var api_url = '/upgrade/apps?app='+what;
}
c.confirm( c.confirm(
y18n.t('tools'), y18n.t('tools'),
y18n.t('confirm_update_specific_app', [c.params['app']]), confirm_message,
function(){ function(){
c.api('PUT', '/upgrade/apps?app='+c.params['app'].toLowerCase(), {}, function(data) { c.api('PUT', api_url, {}, function(data) {
c.redirect_to('#/tools/logs'); c.redirect_to('#/tools/logs');
}); });
} }
); );
}); });
});
});
});
// Display journals list // Display journals list
app.get('#/tools/logs', function (c) { app.get('#/tools/logs', function (c) {

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">