Handle app states for opening apps
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
/* global angular:false */
|
||||
/* global $:false */
|
||||
/* global APP_TYPES */
|
||||
/* global HSTATES */
|
||||
/* global ISTATES */
|
||||
/* global RSTATES */
|
||||
|
||||
angular.module('Application').controller('AppsController', ['$scope', '$translate', '$interval', '$location', 'Client', function ($scope, $translate, $interval, $location, Client) {
|
||||
var ALL_DOMAINS_DOMAIN = { _alldomains: true, domain: 'All Domains' }; // dummy record for the single select filter
|
||||
@@ -71,6 +74,33 @@ angular.module('Application').controller('AppsController', ['$scope', '$translat
|
||||
else localStorage.selectedDomain = newVal.domain;
|
||||
});
|
||||
|
||||
// handles various states and triggers a href or configure/repair view
|
||||
$scope.onAppClick = function (app, $event) {
|
||||
function stopEvent() {
|
||||
$event.originalEvent.stopPropagation();
|
||||
$event.originalEvent.preventDefault();
|
||||
}
|
||||
|
||||
if (app.installationState === ISTATES.ERROR) {
|
||||
if ($scope.isOperator(app)) $scope.showAppConfigure(app, 'repair');
|
||||
|
||||
return stopEvent();
|
||||
} else if (app.installationState === ISTATES.INSTALLED) {
|
||||
// app.health can also be null to indicate insufficient data
|
||||
if (app.runState === RSTATES.STOPPED) return stopEvent();
|
||||
|
||||
if (app.health === HSTATES.UNHEALTHY || app.health === HSTATES.ERROR || app.health === HSTATES.DEAD) {
|
||||
if ($scope.isOperator(app)) $scope.showAppConfigure(app, 'repair');
|
||||
return stopEvent();
|
||||
}
|
||||
|
||||
if (app.pendingPostInstallConfirmation) {
|
||||
$scope.appPostInstallConfirm.show(app);
|
||||
return stopEvent();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.clearAllFilter = function () {
|
||||
$scope.selectedState = $scope.states[0];
|
||||
$scope.selectedTags = [];
|
||||
|
||||
Reference in New Issue
Block a user