215 lines
6.7 KiB
JavaScript
215 lines
6.7 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
/**
|
|
* MODULE DESCRIPTION:
|
|
*
|
|
* TODO: Write description here.
|
|
*/
|
|
angular.module('portal.dashboard', ['ui.router', 'portal.common.constants']).config(DashboardConfig)
|
|
.controller('DashboardCtrl', DashboardCtrlController);
|
|
|
|
function DashboardConfig($stateProvider, Constants) {
|
|
$stateProvider.state('dashboard', {
|
|
url: '/dashboard',
|
|
pageTitle: 'Dashboard',
|
|
templateUrl: 'main/dashboard.html',
|
|
resolve: {
|
|
authorize: ['authorize',
|
|
function (authorize) {
|
|
return authorize.validate({
|
|
authorities: {
|
|
permission: [
|
|
Constants.Permissions.VIEW_SCRIPT_TAB,
|
|
Constants.Permissions.VIEW_GIT_TAB,
|
|
Constants.Permissions.VIEW_USER_TAB,
|
|
Constants.Permissions.VIEW_CREDS_TAB,
|
|
Constants.Permissions.VIEW_LOG_TAB,
|
|
]
|
|
},
|
|
redirect: 'login'
|
|
});
|
|
}
|
|
]
|
|
}
|
|
}).state('dashboard.scripts', {
|
|
url: '/scripts',
|
|
pageTitle: 'Scripts',
|
|
templateUrl: 'main/script-bank/script-bank.html'
|
|
}).state('dashboard.repos', {
|
|
url: '/repos',
|
|
pageTitle: 'Git Repositories',
|
|
templateUrl: 'main/git-bank/git-bank.html'
|
|
}).state('dashboard.credentials', {
|
|
url: '/credentials',
|
|
pageTitle: 'Credentials',
|
|
templateUrl: 'main/cred-bank/cred-bank.html'
|
|
}).state('dashboard.emails', {
|
|
url: '/emails',
|
|
pageTitle: 'Emails',
|
|
templateUrl: 'main/email-bank/email-bank.html'
|
|
}).state('dashboard.users', {
|
|
url: '/users',
|
|
pageTitle: 'Users',
|
|
templateUrl: 'main/user-bank/user-bank.html'
|
|
}).state('dashboard.permissions', {
|
|
url: '/permissions',
|
|
pageTitle: 'Permissions',
|
|
templateUrl: 'main/permission-bank/permission-bank.html'
|
|
}).state('dashboard.envars', {
|
|
url: '/envars',
|
|
pageTitle: 'Environment Variables',
|
|
templateUrl: 'main/env-bank/env-bank.html'
|
|
}).state('dashboard.syslogs', {
|
|
url: '/syslogs',
|
|
pageTitle: 'System Logs',
|
|
templateUrl: 'main/log-bank/log-bank.html'
|
|
});
|
|
}
|
|
|
|
function DashboardCtrlController($state, $scope, cache, accountStores, accountProvider,
|
|
$window, $mdDialog, Constants) {
|
|
|
|
var originatorEv;
|
|
$scope.openMenu = function($mdMenu, ev) {
|
|
originatorEv = ev;
|
|
$mdMenu.open(ev);
|
|
};
|
|
|
|
$scope.Constants = Constants;
|
|
|
|
$scope.loadingBlock = false;
|
|
|
|
$scope.userRole = '';
|
|
$scope.tabs = [{
|
|
title: 'Scripts',
|
|
source: 'main/script-bank/script-bank.html',
|
|
state: 'dashboard.scripts',
|
|
leftItem: '<i class="material-icons">description</i>',
|
|
active: true,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_SCRIPT_TAB
|
|
},{
|
|
title: 'Git Repositories',
|
|
source: 'main/git-bank/git-bank.html',
|
|
state: 'dashboard.repos',
|
|
leftItem: '<i class="material-icons">computer</i>',
|
|
active: true,
|
|
default: true,
|
|
canView: Constants.Permissions.VIEW_GIT_TAB
|
|
},{
|
|
title: 'Credentials',
|
|
source: 'main/cred-bank/cred-bank.html',
|
|
state: 'dashboard.credentials',
|
|
leftItem: '<i class="material-icons">vpn_key</i>',
|
|
active: false,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_CREDS_TAB
|
|
},{
|
|
title: 'Email Templates',
|
|
source: 'main/email-bank/email-bank.html',
|
|
state: 'dashboard.emails',
|
|
leftItem: '<i class="material-icons">email</i>',
|
|
active: false,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_EMAIL_TAB
|
|
},{
|
|
title: 'Users',
|
|
source: 'main/user-bank/user-bank.html',
|
|
state: 'dashboard.users',
|
|
leftItem: '<i class="material-icons">people</i>',
|
|
active: false,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_USER_TAB
|
|
},{
|
|
title: 'Permissions',
|
|
source: 'main/permission-bank/permission-bank.html',
|
|
state: 'dashboard.permissions',
|
|
leftItem: '<i class="material-icons">lock_open</i>',
|
|
active: false,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_PERMISSION_TAB
|
|
},{
|
|
title: 'Environment Variables',
|
|
source: 'main/env-bank/env-bank.html',
|
|
state: 'dashboard.envars',
|
|
leftItem: '<i class="material-icons">storage</i>',
|
|
active: false,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_ENV_VARS_TAB
|
|
},{
|
|
title: 'System Logs',
|
|
source: 'main/log-bank/log-bank.html',
|
|
state: 'dashboard.syslogs',
|
|
leftItem: '<i class="material-icons">description</i>',
|
|
active: false,
|
|
default: false,
|
|
canView: Constants.Permissions.VIEW_LOG_TAB
|
|
}];
|
|
|
|
$scope.mCache = cache.request([new accountStores.Account()]).then(function(){
|
|
$scope.allowedTabs = [];
|
|
$.each($scope.tabs, function(i, tab){
|
|
if ($scope.mCache.account.data.hasPermission(tab.canView)) {
|
|
$scope.allowedTabs.push(tab);
|
|
}
|
|
});
|
|
$scope.$broadcast('tabsetDidChange', $scope.allowedTabs);
|
|
}).catch(function(err){ });
|
|
|
|
$scope.$on('$destroy', function () {
|
|
$scope.mCache.unlisten();
|
|
});
|
|
|
|
$scope.logout = function() {
|
|
accountProvider.logout().then(function (data) {
|
|
cache.flush();
|
|
$state.go('login');
|
|
$window.location.href = '#/login';
|
|
$window.location.reload();
|
|
}).catch(function (data) {
|
|
$state.go('login');
|
|
});
|
|
};
|
|
|
|
$scope.openConfiguration = function() {
|
|
$mdDialog.show({
|
|
controller: 'ConfigurationCtrl',
|
|
templateUrl: 'common/partials/configuration/configuration.html',
|
|
clickOutsideToClose: false,
|
|
escapeToClose: false,
|
|
locals: {
|
|
account: $scope.mCache.account
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.openSeed = function() {
|
|
$mdDialog.show({
|
|
controller: 'SeedInfoCtrl',
|
|
templateUrl: 'common/partials/seed-info/seed-info.html',
|
|
clickOutsideToClose: false,
|
|
escapeToClose: false,
|
|
});
|
|
};
|
|
|
|
$scope.openLogLevel = function() {
|
|
$mdDialog.show({
|
|
controller: 'LoggerInfoCtrl',
|
|
templateUrl: 'common/partials/logger-info/logger-info.html',
|
|
clickOutsideToClose: false,
|
|
escapeToClose: false,
|
|
});
|
|
};
|
|
|
|
$scope.openSMTPConfig = function() {
|
|
$mdDialog.show({
|
|
controller: 'SMTPInfoCtrl',
|
|
templateUrl: 'common/partials/smtp-info/smtp-info.html',
|
|
clickOutsideToClose: false,
|
|
escapeToClose: false,
|
|
});
|
|
};
|
|
|
|
} //end DashboardCtrlController function
|
|
|
|
})(); |