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
app.get('#/update', function (c) {
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
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');
});
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
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(
y18n.t('tools'),
y18n.t('confirm_update_specific_app', [c.params['app']]),
confirm_message,
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');
});
}
);
});
});
});
});
// Display journals list
app.get('#/tools/logs', function (c) {

View file

@ -20,7 +20,7 @@
{{/system}}
</div>
<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>
{{else}}
<div class="panel-body">
@ -37,14 +37,14 @@
<div class="list-group">
{{#apps}}
<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>
<p class="list-group-item-text">{{t 'from_to' current_version new_version}}</p>
</div>
{{/apps}}
</div>
<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>
{{else}}
<div class="panel-body">