harbor/static/resources/js/layout/admin-option/admin-option.controller.js

80 lines
1.9 KiB
JavaScript
Raw Normal View History

(function() {
'use strict';
angular
.module('harbor.layout.admin.option')
.controller('AdminOptionController', AdminOptionController);
2016-07-02 12:20:31 +02:00
AdminOptionController.$inject = ['$scope', '$timeout', '$location'];
2016-07-02 12:20:31 +02:00
function AdminOptionController($scope, $timeout, $location) {
2016-06-25 21:12:17 +02:00
2016-06-26 06:56:58 +02:00
$scope.subsSubPane = 296;
var vm = this;
vm.toggle = false;
2016-07-02 12:20:31 +02:00
vm.target = 'users';
vm.toggleAdminOption = toggleAdminOption;
2016-07-02 12:20:31 +02:00
$scope.$on('$locationChangeSuccess', function(e) {
if($location.path() === '') {
vm.target = 'users';
vm.toggle = false;
}else{
vm.target = 'system_management';
vm.toggle = true;
}
});
//Message dialog handler for admin-options.
$scope.$on('modalTitle', function(e, val) {
vm.modalTitle = val;
});
2016-07-02 12:20:31 +02:00
$scope.$on('modalMessage', function(e, val) {
vm.modalMessage = val;
});
$scope.$on('raiseError', function(e, val) {
if(val) {
vm.action = function() {
$scope.$broadcast('showDialog', false);
};
vm.contentType = 'text/plain';
vm.confirmOnly = true;
$timeout(function() {
$scope.$broadcast('showDialog', true);
}, 350);
}
});
$scope.$on('raiseInfo', function(e, val) {
if(val) {
vm.action = function() {
val.action();
$scope.$broadcast('showDialog', false);
}
vm.contentType = val.contentType;
vm.confirmOnly = val.confirmOnly;
$scope.$broadcast('showDialog', true);
}
});
function toggleAdminOption(e) {
switch(e.target) {
case 'users':
vm.toggle = false;
2016-07-02 12:20:31 +02:00
break;
case 'system_management':
vm.toggle = true;
2016-07-02 12:20:31 +02:00
break;
}
2016-07-02 12:20:31 +02:00
vm.target = e.target;
}
}
})();