make refreshApp take appId

This commit is contained in:
Girish Ramakrishnan
2019-12-16 16:08:49 -08:00
parent 55ae8404cd
commit 866a7480bc
+20 -16
View File
@@ -117,7 +117,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
function done(error) {
if (error) Client.error(error);
refreshApp($scope.display.show);
refreshApp($scope.app.id, $scope.display.show);
$timeout(function () {
$scope.display.busy = false;
@@ -287,7 +287,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.locationForm.$setPristine();
$scope.location.busy = false;
refreshApp();
refreshApp($scope.app.id);
});
});
}
@@ -395,7 +395,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.resources.currentMemoryLimit = $scope.resources.memoryLimit;
$scope.resources.busy = false;
refreshApp();
refreshApp($scope.app.id);
});
},
@@ -414,7 +414,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.resourcesDataDirForm.$setPristine();
$scope.resources.busyDataDir = false;
refreshApp();
refreshApp($scope.app.id);
});
}
};
@@ -452,7 +452,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.email.busy = false;
refreshApp(function (error) {
refreshApp($scope.app.id, function (error) {
if (error) return;
// when the mailboxName is 'reset', this will fill it up with the default again
$scope.email.mailboxName = $scope.app.mailboxName || '';
@@ -546,7 +546,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
if (error) return Client.error(error);
$('#updateModal').modal('hide');
refreshApp();
refreshApp($scope.app.id);
});
}
};
@@ -575,7 +575,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
trackBackupTask: function () {
$scope.backups.busyCreate = true;
refreshApp(function (error) {
refreshApp($scope.app.id, function (error) {
if (error) Client.error(error);
$scope.backups.busyCreate = false;
@@ -673,7 +673,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.console.busyRunState = false;
if (error) return Client.error(error);
refreshApp();
refreshApp($scope.app.id);
});
}
};
@@ -703,7 +703,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$('#restoreModal').modal('hide');
refreshApp();
refreshApp($scope.app.id);
});
}
};
@@ -988,16 +988,13 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
});
}
function refreshApp(callback) {
function refreshApp(appId, callback) {
callback = callback || function () {};
Client.getApp($scope.app.id, function (error, app) {
Client.getApp(appId, function (error, app) {
if (error && error.statusCode === 404) return $location.path('/apps');
if (error) return callback(error);
// Immediately move to debug view on error
if (app.error && !($scope.view === 'debug' || $scope.view === 'uninstall')) $scope.setView('debug');
// ensure we have amended progress properties set before copy
app.taskProgress = $scope.app.taskProgress;
app.taskProgressMessage = $scope.app.taskProgressMessage;
@@ -1031,6 +1028,13 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$timeout(waitForAppTask.bind(null, callback), 2000); // not yet done
}
function switchView() {
// Immediately move to debug view on error
if ($scope.app.error && !($scope.view === 'debug' || $scope.view === 'uninstall')) $scope.setView('debug');
if (!$scope.view) $scope.setView($routeParams.view || 'display'); // first time
}
Client.onReady(function () {
Client.getApp(appId, function (error, app) {
if (error && error.statusCode === 404) return $location.path('/apps');
@@ -1038,7 +1042,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
$scope.app = app;
$scope.setView($routeParams.view || 'display');
switchView();
// track on page load backup if active
if (app.installationState === ISTATES.PENDING_BACKUP) $scope.backups.trackBackupTask();
@@ -1051,7 +1055,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location'
], function (error) {
if (error) return Client.error(error);
var refreshTimer = $interval(function () { refreshApp(); }, 2000); // call with inline function to avoid iteration argument passed see $interval docs
var refreshTimer = $interval(function () { refreshApp($scope.app.id, switchView); }, 2000); // call with inline function to avoid iteration argument passed see $interval docs
$scope.$on('$destroy', function () {
$interval.cancel(refreshTimer);
});