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