Share complex app link opening code between views

This commit is contained in:
Johannes Zellner
2022-09-13 12:39:56 +02:00
parent 0f2f1e1475
commit be72bfdb9f
4 changed files with 39 additions and 36 deletions

View File

@@ -74,33 +74,7 @@ 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.INSTALLED) {
if (app.installationState === ISTATES.ERROR && $scope.isOperator(app)) $scope.showAppConfigure(app, 'repair');
return stopEvent();
}
// app.health can also be null to indicate insufficient data
if (!app.health) return stopEvent();
if (app.runState === RSTATES.STOPPED) return stopEvent();
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.onAppClick = function (app, $event) { onAppClick(app, $event, $scope.isOperator(app), $scope); };
$scope.clearAllFilter = function () {
$scope.selectedState = $scope.states[0];