From 52b4623222dd0b4450ff9afde379b705f5ffe6cc Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 17 Oct 2019 00:06:23 +0200 Subject: [PATCH] Mooooar buttons (update view) --- src/js/yunohost/controllers/tools.js | 61 +++++++++++++++------------- src/views/update/update.ms | 6 +-- 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/js/yunohost/controllers/tools.js b/src/js/yunohost/controllers/tools.js index 6d40f4b5..03f6f1a7 100644 --- a/src/js/yunohost/controllers/tools.js +++ b/src/js/yunohost/controllers/tools.js @@ -47,37 +47,42 @@ // 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() { + + 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 app.get('#/tools/logs', function (c) { c.api('GET', "/logs?limit=25&with_details", {}, function(categories) { diff --git a/src/views/update/update.ms b/src/views/update/update.ms index 62a44b50..0be7740a 100644 --- a/src/views/update/update.ms +++ b/src/views/update/update.ms @@ -20,7 +20,7 @@ {{/system}} {{else}}
@@ -37,14 +37,14 @@
{{#apps}}
- {{t 'system_upgrade_btn'}} +

{{label}} {{id}}

{{t 'from_to' current_version new_version}}

{{/apps}}
{{else}}