Add a restart button in recovery section
This commit is contained in:
@@ -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);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user