diff --git a/dashboard/src/js/index.js b/dashboard/src/js/index.js index a76d03937..ad530d4d0 100644 --- a/dashboard/src/js/index.js +++ b/dashboard/src/js/index.js @@ -1,7 +1,6 @@ 'use strict'; /* global angular:false */ -/* global window, localStorage, document */ /* global $:false */ /* global async */ /* global ERROR,ISTATES,HSTATES,RSTATES,APP_TYPES,NOTIFICATION_TYPES */ @@ -485,6 +484,36 @@ app.directive('ngClickSelect', function () { }; }); +// handles various states and triggers a href or configure/repair view +// used by attaching to controller $scope +// if $scope.appPostInstallConfirm.show(app); exists it will be called if not yet confirmed +function onAppClick(app, $event, isOperator, $scope) { + function stopEvent() { + $event.originalEvent.stopPropagation(); + $event.originalEvent.preventDefault(); + } + + if (app.installationState !== ISTATES.INSTALLED) { + if (app.installationState === ISTATES.ERROR && isOperator) $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 (isOperator) $scope.showAppConfigure(app, 'repair'); + return stopEvent(); + } + + if (app.pendingPostInstallConfirmation && $scope.appPostInstallConfirm) { + $scope.appPostInstallConfirm.show(app); + return stopEvent(); + } +} + app.directive('ngClickReveal', function () { return { restrict: 'A', diff --git a/dashboard/src/views/user-settings.js b/dashboard/src/views/user-settings.js index c59cb0ec3..c5e1add68 100644 --- a/dashboard/src/views/user-settings.js +++ b/dashboard/src/views/user-settings.js @@ -2,7 +2,6 @@ /* global angular */ /* global Clipboard */ -/* global window */ /* global $, TASK_TYPES */ angular.module('Application').controller('UserSettingsController', ['$scope', '$location', '$translate', '$timeout', 'Client', function ($scope, $location, $translate, $timeout, Client) {