We don't need all that custom madness for the postinstall ...

This commit is contained in:
Alexandre Aubin 2019-10-19 04:20:41 +02:00
parent 1347589eec
commit 79fc66558c
2 changed files with 54 additions and 82 deletions

View file

@ -101,6 +101,7 @@
store.set('url', window.location.hostname +'/yunohost/api'); store.set('url', window.location.hostname +'/yunohost/api');
store.set('user', 'admin'); store.set('user', 'admin');
c.api('POST', '/postinstall', {domain: domain, password: password}, function() { c.api('POST', '/postinstall', {domain: domain, password: password}, function() {
c.flash('success', y18n.t('installation_complete'));
c.redirect_to('#/login'); c.redirect_to('#/login');
}); });
} }

View file

@ -144,37 +144,9 @@
call = function(uri, callback, method, data, callbackOnFailure) { call = function(uri, callback, method, data, callbackOnFailure) {
var args = data; // Define default callback for failures
// TODO: change this code
if (uri === '/postinstall') {
var post_installing = false;
setInterval(function () {
post_installing = true;
}, 1500);
}
if (typeof callbackOnFailure !== 'function') { if (typeof callbackOnFailure !== 'function') {
callbackOnFailure = function(xhr) { callbackOnFailure = function(xhr) {
// Postinstall is a custom case, we have to wait that
// operation is done before doing anything
//
// TODO / FIXME : maybe we should add this as a
// callbackonfailure during the actual api call instead
// of hard-coding it here...
if ((uri === '/postinstall') && (post_installing)) {
interval = window.location.hostname === args.domain ? 20000 : 5000;
checkInstall = setInterval(function () {
c.checkInstall(function(isInstalled) {
if (isInstalled || typeof isInstalled === 'undefined') {
c.flash('success', y18n.t('installation_complete'));
clearInterval(checkInstall);
window.location.href = 'https://'+ window.location.hostname +'/yunohost/admin/';
}
});
}, interval);
}
// Regular errors
else {
if (xhr.status == 200) { if (xhr.status == 200) {
// Fail with 200, WTF // Fail with 200, WTF
callback({}); callback({});
@ -230,7 +202,6 @@
// Force scrollTop on page load // Force scrollTop on page load
$('html, body').scrollTop(0); $('html, body').scrollTop(0);
store.clear('slide'); store.clear('slide');
}
}; };
} }