Add a restart button in recovery section

This commit is contained in:
Girish Ramakrishnan
2019-12-20 11:18:48 -08:00
parent 3f3ec9ef9a
commit adc078a5cb
5 changed files with 47 additions and 38 deletions

View File

@@ -21,6 +21,7 @@ var ISTATES = {
PENDING_DEBUG: 'pending_debug',
PENDING_START: 'pending_start',
PENDING_STOP: 'pending_stop',
PENDING_RESTART: 'pending_restart',
ERROR: 'error',
INSTALLED: 'installed'
};
@@ -555,25 +556,11 @@ angular.module('Application').service('Client', ['$http', '$interval', '$timeout
};
Client.prototype.restartApp = function (id, callback) {
var that = this;
function waitUntilStopped(callback) {
that.getApp(id, function (error, result) {
if (error) return callback(error);
if (result.runState === 'stopped') return callback();
setTimeout(waitUntilStopped.bind(null, callback), 2000);
});
}
that.stopApp(id, function (error) {
post('/api/v1/apps/' + id + '/start', {}, null, function (error, data, status) {
if (error) return callback(error);
if (status !== 202) return callback(new ClientError(status, data));
waitUntilStopped(function (error) {
if (error) return callback(error);
that.startApp(id, callback);
});
callback(null, data);
});
};