mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
[fix] Indicate to users server is rebooting/shutting down
This commit is contained in:
parent
d4e86accce
commit
802b189faa
3 changed files with 106 additions and 68 deletions
|
@ -172,8 +172,34 @@
|
||||||
y18n.t('confirm_reboot_action_' + action),
|
y18n.t('confirm_reboot_action_' + action),
|
||||||
function(){
|
function(){
|
||||||
c.api('/'+action+'?force', function(data) {
|
c.api('/'+action+'?force', function(data) {
|
||||||
|
// This code is not executed due to 502 response (reboot or shutdown)
|
||||||
c.redirect('#/logout');
|
c.redirect('#/logout');
|
||||||
}, 'PUT');
|
}, 'PUT', {}, false, function (xhr) {
|
||||||
|
c.flash('success', y18n.t('tools_' + action + '_done'))
|
||||||
|
// Disconnect from the webadmin
|
||||||
|
store.clear('url');
|
||||||
|
store.clear('connected');
|
||||||
|
store.set('path', '#/');
|
||||||
|
|
||||||
|
// Rename the page to allow refresh without ask for rebooting
|
||||||
|
window.location.href = window.location.href.split('#')[0] + '#/';
|
||||||
|
// Display reboot or shutdown info
|
||||||
|
// We can't use template because now the webserver is off
|
||||||
|
if (action == 'reboot') {
|
||||||
|
$('#main').replaceWith('<div id="main"><div class="alert alert-warning"><i class="fa-refresh"></i> ' + y18n.t('tools_rebooting') + '</div></div>');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('#main').replaceWith('<div id="main"><div class="alert alert-warning"><i class="fa-power-off"></i> ' + y18n.t('tools_shuttingdown') + '</div></div>');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove loader if any
|
||||||
|
$('div.loader').remove();
|
||||||
|
|
||||||
|
// Force scrollTop on page load
|
||||||
|
$('html, body').scrollTop(0);
|
||||||
|
store.clear('slide');
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
function(){
|
function(){
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
|
@ -187,6 +213,11 @@
|
||||||
c.redirect('#/tools/reboot');
|
c.redirect('#/tools/reboot');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
app.get('#/tools/reboot/:action/done', function (c) {
|
||||||
|
var action = c.params['action'].toLowerCase();
|
||||||
|
if (action == 'reboot' || action == 'shutdown') {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Diagnosis
|
// Diagnosis
|
||||||
app.get('#/tools/diagnosis(/:private)?', function (c) {
|
app.get('#/tools/diagnosis(/:private)?', function (c) {
|
||||||
|
|
|
@ -62,10 +62,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
// API call
|
// API call
|
||||||
api: function(uri, callback, method, data, websocket) {
|
api: function(uri, callback, method, data, websocket, callbackOnFailure) {
|
||||||
c = this;
|
c = this;
|
||||||
|
|
||||||
call = function(uri, callback, method, data) {
|
call = function(uri, callback, method, data, callbackOnFailure) {
|
||||||
method = typeof method !== 'undefined' ? method : 'GET';
|
method = typeof method !== 'undefined' ? method : 'GET';
|
||||||
data = typeof data !== 'undefined' ? data : {};
|
data = typeof data !== 'undefined' ? data : {};
|
||||||
if (window.navigator && window.navigator.language && (typeof data.locale === 'undefined')) {
|
if (window.navigator && window.navigator.language && (typeof data.locale === 'undefined')) {
|
||||||
|
@ -84,22 +84,8 @@
|
||||||
if ($('div.loader').length === 0) {
|
if ($('div.loader').length === 0) {
|
||||||
$('#main').append('<div class="loader loader-content"></div>');
|
$('#main').append('<div class="loader loader-content"></div>');
|
||||||
}
|
}
|
||||||
|
if (typeof callbackOnFailure !== 'function') {
|
||||||
jQuery.ajax({
|
callbackOnFailure = function(xhr) {
|
||||||
url: 'https://' + store.get('url') + uri,
|
|
||||||
type: method,
|
|
||||||
crossdomain: true,
|
|
||||||
data: data,
|
|
||||||
traditional: true,
|
|
||||||
dataType: 'json'
|
|
||||||
})
|
|
||||||
.always(function(xhr, ts, error) {
|
|
||||||
})
|
|
||||||
.done(function(data) {
|
|
||||||
data = data || {};
|
|
||||||
callback(data);
|
|
||||||
})
|
|
||||||
.fail(function(xhr) {
|
|
||||||
// Postinstall is a custom case, we have to wait that
|
// Postinstall is a custom case, we have to wait that
|
||||||
// operation is done before doing anything
|
// operation is done before doing anything
|
||||||
if (uri === '/postinstall') {
|
if (uri === '/postinstall') {
|
||||||
|
@ -161,7 +147,24 @@
|
||||||
$('html, body').scrollTop(0);
|
$('html, body').scrollTop(0);
|
||||||
store.clear('slide');
|
store.clear('slide');
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.ajax({
|
||||||
|
url: 'https://' + store.get('url') + uri,
|
||||||
|
type: method,
|
||||||
|
crossdomain: true,
|
||||||
|
data: data,
|
||||||
|
traditional: true,
|
||||||
|
dataType: 'json'
|
||||||
|
})
|
||||||
|
.always(function(xhr, ts, error) {
|
||||||
|
})
|
||||||
|
.done(function(data) {
|
||||||
|
data = data || {};
|
||||||
|
callback(data);
|
||||||
|
})
|
||||||
|
.fail(callbackOnFailure);
|
||||||
};
|
};
|
||||||
|
|
||||||
websocket = typeof websocket !== 'undefined' ? websocket : true;
|
websocket = typeof websocket !== 'undefined' ? websocket : true;
|
||||||
|
@ -181,9 +184,9 @@
|
||||||
|
|
||||||
ws.onclose = function() {};
|
ws.onclose = function() {};
|
||||||
|
|
||||||
ws.onopen = call(uri, callback, method, data);
|
ws.onopen = call(uri, callback, method, data, callbackOnFailure);
|
||||||
} else {
|
} else {
|
||||||
call(uri, callback, method, data);
|
call(uri, callback, method, data, callbackOnFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -273,8 +273,12 @@
|
||||||
"tools_security_feed_view_items": "View all security notifications",
|
"tools_security_feed_view_items": "View all security notifications",
|
||||||
"tools_reboot": "Reboot your server",
|
"tools_reboot": "Reboot your server",
|
||||||
"tools_reboot_btn": "Reboot",
|
"tools_reboot_btn": "Reboot",
|
||||||
|
"tools_reboot_done": "Rebooting...",
|
||||||
|
"tools_rebooting": "Your server is rebooting. To return on the web administration interface you need to wait your server to be up. You can check that by refreshing regularly this page (F5).",
|
||||||
"tools_shutdown": "Shutdown your server",
|
"tools_shutdown": "Shutdown your server",
|
||||||
"tools_shutdown_btn": "Shutdown",
|
"tools_shutdown_btn": "Shutdown",
|
||||||
|
"tools_shutdown_done": "Shutting down...",
|
||||||
|
"tools_shuttingdown": "Your server is powerring off. As long as your server is off, you won't be able to use the web administration.",
|
||||||
"tools_shutdown_reboot": "Shutdown/Reboot",
|
"tools_shutdown_reboot": "Shutdown/Reboot",
|
||||||
"total": "Total",
|
"total": "Total",
|
||||||
"transmission": "Transmission",
|
"transmission": "Transmission",
|
||||||
|
|
Loading…
Add table
Reference in a new issue