diff --git a/client/controllers/instance/controllerInstance.js b/client/controllers/instance/controllerInstance.js index 2f2d33339..3932480eb 100644 --- a/client/controllers/instance/controllerInstance.js +++ b/client/controllers/instance/controllerInstance.js @@ -75,18 +75,14 @@ function ControllerInstance( // watch for deployed/started/stopped instance // all watches necessary, updateDisplayedTabs expectst to be invoked // after fetching instance, fetching container, and cointainer start - var containerWatch; - $scope.$watch('dataInstance.data.instance', handleInstance); - function handleInstance (instance) { - if (!instance) { return; } // instance still being fetched - containerWatch = $scope.$watch('dataInstance.data.instance.containers.models[0]', handleContainer); - } + var containerWatch = + $scope.$watch('dataInstance.data.instance.containers.models[0]', handleContainer); + function handleContainer (container) { if (!container) { buildLogsOnly(); } else { // handles both container.error and container.dockerContainer states - containerWatch(); // once, got container $scope.$watch('dataInstance.data.instance.containers.models[0].attrs.inspect.State.Running', displayTabsForContainerState); // once } } @@ -140,6 +136,10 @@ function ControllerInstance( displayTabsForContainerState(keypather.get(container, 'running()')); } + $scope.$on('$destroy', function () { + containerWatch(); + }); + function buildLogsOnly () { data.openItems.reset([]); // Set to true if we see the instance in an undeployed state diff --git a/client/services/serviceHelperInstanceActionsModal.js b/client/services/serviceHelperInstanceActionsModal.js index 8a9a817de..5bdde2860 100644 --- a/client/services/serviceHelperInstanceActionsModal.js +++ b/client/services/serviceHelperInstanceActionsModal.js @@ -11,6 +11,7 @@ function HelperInstanceActionsModal( $timeout, async, keypather, + errs, updateEnvName, $localStorage ) { @@ -73,12 +74,15 @@ function HelperInstanceActionsModal( $rootScope.dataApp.data.loading = true; if (!opts.env) { return; } $scope.instance.update(opts, function (err) { - $rootScope.safeApply(); if (err) { throw err; } - $rootScope.dataApp.data.loading = false; + $rootScope.safeApply(); // update instances collection to update // viewInstanceList - $state.go('instance.instance', $stateParams); + $scope.instance.redeploy(function(err) { + $rootScope.dataApp.data.loading = false; + errs.handler(err); + $state.go('instance.instance', $stateParams, {reload: true}); + }); }); if (cb) { cb(); diff --git a/package.json b/package.json index e0e8d1ab0..923386bec 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "ngStorage": "git+https://github.com/cflynn07/ngStorage.git#v0.4.0", "primus": "^2.3.0", "regexp-quote": "0.0.0", - "runnable": "git+ssh://git@github.com:CodeNow/runnable-api-client#v0.38.4", + "runnable": "git+ssh://git@github.com:CodeNow/runnable-api-client#v0.38.6", "term.js": "git://github.com/Runnable/term.js.git#6a1d4ec38aa26c61fb6a4f0a20ba5cb207e66f2d", "uuid": "^2.0.1" },