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

@@ -127,27 +127,23 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
var appId = $scope.selected.value;
function waitUntilStopped(callback) {
function waitUntilRestarted(callback) {
refreshApp(appId, function (error, result) {
if (error) return callback(error);
if (result.installationState === ISTATES.INSTALLED && result.runState === RSTATES.STOPPED) return callback();
setTimeout(waitUntilStopped.bind(null, callback), 2000);
if (result.installationState === ISTATES.INSTALLED) return callback();
setTimeout(waitUntilRestarted.bind(null, callback), 2000);
});
}
Client.stopApp(appId, function (error) {
if (error) console.error('Failed to stop app.', error);
Client.restartApp(appId, function (error) {
if (error) console.error('Failed to restart app.', error);
waitUntilStopped(function (error) {
if (error) console.error('Failed to get app status.', error);
waitUntilRestarted(function (error) {
if (error) console.error('Failed wait for restart.', error);
Client.startApp(appId, function (error) {
if (error) console.error('Failed to start app.', error);
$scope.restartAppBusy = false;
$scope.appBusy = false;
});
$scope.restartAppBusy = false;
$scope.appBusy = false;
});
});
};