Merge pull request #240 from YunoHost/propagate-tools-upgrade-rework

[wip] Propagate tools_update and tools_upgrade api changes
This commit is contained in:
Alexandre Aubin 2019-05-16 16:59:25 +02:00 committed by GitHub
commit 3ced7c5cd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 69 deletions

View file

@ -49,50 +49,49 @@
// System update & upgrade
app.get('#/update', function (c) {
c.api('/update', function(data) {
var packagesLength = data.packages.length;
for(var i = 0; i < packagesLength; i++) {
data.packages[i].delayed = false;
// Check for special packages that need delayed upgrade.
if (["moulinette", "yunohost", "yunohost-admin", "ssowat", "python"].indexOf(data.packages[i].name) != -1) {
c.flash('warning', y18n.t('system_delayed_upgrade_warning', [data.packages[i].name]));
data.packages[i].delayed = true;
}
}
c.view('update/update', data);
}, 'PUT');
});
// Upgrade apps or packages
app.get('#/upgrade/:type', function (c) {
if (c.params['type'] !== 'apps' && c.params['type'] !== 'packages') {
c.flash('fail', y18n.t('unknown_argument', [c.params['type']]));
store.clear('slide');
c.redirect('#/update');
}
else {
c.confirm(
y18n.t('tools'),
// confirm_update_apps and confirm_update_packages
y18n.t('confirm_update_' + c.params['type'].toLowerCase()),
function(){
var endurl = '';
if (c.params['type'] == 'packages') {endurl = 'ignore_apps';}
else if (c.params['type'] == 'apps') {endurl = 'ignore_packages';}
c.api('/upgrade?'+endurl, function(data) {
// 'log' is a reserved name, maybe in handlebars
data.logs = data.log;
c.view('upgrade/upgrade', data);
}, 'PUT');
c.api('/upgrade?'+c.params["type"],
function(data) {
store.clear('slide');
c.redirect('#/tools/logs');
},
'PUT');
},
function(){
store.clear('slide');
c.redirect('#/update');
}
);
});
// 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('/upgrade/apps?app='+c.params['app'].toLowerCase(),
function(data) {
store.clear('slide');
c.redirect('#/tools/logs');
},
'PUT');
},
function(){
store.clear('slide');
c.redirect('#/update');
}
);
});
// Display journals list
@ -154,26 +153,6 @@
});
});
// 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('/upgrade/apps?app='+c.params['app'].toLowerCase(),
function(data) {
// 'log' is a reserved name, maybe in handlebars
data.logs = data.log;
c.view('upgrade/upgrade', data);
}, 'PUT');
},
function(){
store.clear('slide');
c.redirect('#/update');
}
);
});
// Download SSL Certificate Authority
app.get('#/tools/ca', function (c) {

View file

@ -88,7 +88,7 @@
"confirm_service_disable": "Are you sure you want to disable %s?",
"confirm_uninstall": "Are you sure you want to uninstall %s?",
"confirm_update_apps": "Are you sure you want to update all applications?",
"confirm_update_packages": "Are you sure you want to update all packages?",
"confirm_update_system": "Are you sure you want to update all system packages?",
"confirm_update_specific_app": "Are you sure you want to update %s?",
"confirm_upnp_enable": "Are you sure you want to enable UPnP?",
"confirm_upnp_disable": "Are you sure you want to disable UPnP?",
@ -307,8 +307,6 @@
"system": "System",
"system_apps": "Apps",
"system_apps_nothing": "There are no apps to upgrade.",
"system_delayed_upgrade": "Delayed upgrade",
"system_delayed_upgrade_warning": "<b>%s</b> will be upgraded automatically within the next hour.",
"system_packages": "Packages",
"system_packages_nothing": "There are no packages to upgrade.",
"system_update": "System update",

View file

@ -9,23 +9,18 @@
<div class="panel-heading">
<h2 class="panel-title"><span class="fa-fw fa-cube"></span> {{t 'system'}}</h2>
</div>
{{#if packages}}
{{#if system}}
<div class="list-group">
{{#packages}}
{{#system}}
<div class="list-group-item">
{{#if delayed}}
<span class="text-warning pull-right">
<span class="fa-warning"></span> {{t 'system_delayed_upgrade'}}
</span>
{{/if}}
<h3 class="list-group-item-heading">
{{name}} <small>{{fullname}}</small>
</h3>
</div>
{{/packages}}
{{/system}}
</div>
<div class="panel-footer">
<a href="#/upgrade/packages" role="button" class="btn btn-success">{{t 'system_upgrade_all_packages_btn'}}</a>
<a href="#/upgrade/system" role="button" class="btn btn-success">{{t 'system_upgrade_all_packages_btn'}}</a>
</div>
{{else}}
<div class="panel-body">