Handle app states for opening apps

This commit is contained in:
Johannes Zellner
2022-09-11 17:40:59 +02:00
parent 313c871c50
commit 2d901b2e2b
3 changed files with 31 additions and 14 deletions

View File

@@ -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 = [];