Fix terminal restart and other state issues
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
/* global angular */
|
||||
/* global $ */
|
||||
/* global Terminal */
|
||||
/* global RSTATES */
|
||||
/* global RSTATES,ISTATES */
|
||||
|
||||
// create main application module
|
||||
var app = angular.module('Application', ['angular-md5', 'ui-notification']);
|
||||
@@ -123,13 +123,15 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
||||
|
||||
$scope.restartApp = function () {
|
||||
$scope.restartAppBusy = true;
|
||||
$scope.appBusy = true;
|
||||
|
||||
var appId = $scope.selected.value;
|
||||
|
||||
function waitUntilStopped(callback) {
|
||||
refreshApp(appId, function (error, result) {
|
||||
if (error) return callback(error);
|
||||
|
||||
if (result.runState === RSTATES.STOPPED) return callback();
|
||||
if (result.installationState === ISTATES.INSTALLED && result.runState === RSTATES.STOPPED) return callback();
|
||||
setTimeout(waitUntilStopped.bind(null, callback), 2000);
|
||||
});
|
||||
}
|
||||
@@ -138,12 +140,13 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
||||
if (error) console.error('Failed to stop app.', error);
|
||||
|
||||
waitUntilStopped(function (error) {
|
||||
if (error) return console.error('Failed to get app status.', error);
|
||||
if (error) console.error('Failed to get app status.', error);
|
||||
|
||||
Client.startApp(appId, function (error) {
|
||||
if (error) console.error('Failed to start app.', error);
|
||||
|
||||
$scope.restartAppBusy = false;
|
||||
$scope.appBusy = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -234,13 +237,6 @@ app.controller('TerminalController', ['$scope', '$timeout', '$location', 'Client
|
||||
|
||||
var result = $scope.selectedAppInfo;
|
||||
|
||||
// we expect this to be called _after_ a reconfigure was issued
|
||||
if (result.installationState === 'installed') {
|
||||
$scope.appBusy = false;
|
||||
} else if (result.installationState !== 'error') {
|
||||
$scope.appBusy = true;
|
||||
}
|
||||
|
||||
$scope.schedulerTasks = result.manifest.addons.scheduler ? Object.keys(result.manifest.addons.scheduler).map(function (k) { return { name: k, command: result.manifest.addons.scheduler[k].command }; }) : [];
|
||||
|
||||
$scope.terminal = new Terminal();
|
||||
|
||||
Reference in New Issue
Block a user