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
+1 -1
View File
@@ -230,7 +230,7 @@
<div class="grid-item-content" uib-tooltip="{{ app.fqdn }}">
<a ng-show="app.type !== APP_TYPES.LINK && isOperator(app)" ng-href="#/app/{{ app.id}}/display" class="btn btn-lg btn-default grid-item-action"><i class="fas fa-cog"></i></a>
<div ng-show="app.type === APP_TYPES.LINK && isOperator(app)" ng-click="applinksEdit.show(app)" class="btn btn-lg btn-default grid-item-action"><i class="fas fa-cog"></i></div>
<a ng-href="{{ app | applicationLink }}" ng-click="isOperator(app) && (((app | installError) === true || (app | installationActive) === true) && showAppConfigure(app, 'repair')) || ((app | appIsInstalledAndHealthy) && app.pendingPostInstallConfirmation && appPostInstallConfirm.show(app))" target="_blank" ng-class="{ 'hand': (app | appIsInstalledAndHealthy) || (app | installError) || (app | installationActive)}">
<a ng-href="{{ app | applicationLink }}" ng-click="onAppClick(app, $event)" target="_blank">
<div class="grid-item-top">
<div class="row">
<div class="col-xs-12 text-center" style="padding-left: 5px; padding-right: 5px;">
+30
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 = [];