117 lines
3.6 KiB
JavaScript
117 lines
3.6 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
/**
|
|
* MODULE DESCRIPTION:
|
|
*
|
|
* TODO: Write description here.
|
|
*/
|
|
angular.module('portal.dashboard.envBank', ['ui.router'])
|
|
.controller('EnvBankCtrl', EnvBankCtrlController);
|
|
|
|
function EnvBankCtrlController($scope, cache, systemStores, systemProvider, uiGridConstants, $timeout, $mdDialog, portalUtils, Constants) {
|
|
|
|
$scope.envars = [];
|
|
$scope.Constants = Constants;
|
|
$scope.mCache = cache.request([new systemStores.EnvironmentVariables()]).then(function(){
|
|
$scope.envars = $scope.mCache.envvars.data.values;
|
|
});
|
|
|
|
$scope.envarGrid = {
|
|
data: 'envars',
|
|
paginationPageSizes: [25, 50, 75, 100, 125, 150, 175, 200],
|
|
paginationPageSize: 25,
|
|
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
|
|
toggleModifierKeysToMultiSelect : true,
|
|
enableRowHeaderSelection: true,
|
|
enableColumnMenus: true,
|
|
enableGridMenu: true,
|
|
multiSelect: true,
|
|
noUnselect: false,
|
|
onRegisterApi: function (gridApi) {
|
|
gridApi.selection.setModifierKeysToMultiSelect(true);
|
|
$scope.envGridApi = gridApi;
|
|
},
|
|
columnDefs: [
|
|
{field: 'name', displayName: 'Environment Name'},
|
|
{field: 'value', displayName: 'Environment Value'},
|
|
],
|
|
};
|
|
|
|
$scope.$on('$destroy', function () {
|
|
$scope.mCache.unlisten();
|
|
});
|
|
|
|
$scope.toggleFiltering = function() {
|
|
$scope.envGridApi.enableFiltering = !$scope.envGridApi.enableFiltering;
|
|
$scope.envGridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
|
|
};
|
|
|
|
var originatorEv;
|
|
$scope.openMenu = function($mdOpenMenu, ev) {
|
|
originatorEv = ev;
|
|
$mdOpenMenu(ev);
|
|
};
|
|
|
|
$scope.delete = function() {
|
|
var messages = ['Are you sure you want to delete the following environment variables?'];
|
|
|
|
var selectedEnvVars = $scope.envGridApi.selection.getSelectedRows();
|
|
for (var i = 0; i < selectedEnvVars.length; i++) {
|
|
messages.push(selectedEnvVars[i].name);
|
|
}
|
|
|
|
portalUtils.confirmBox('deleteEnVars', 'Delete Environment Variables', messages, false, function(value) {
|
|
if (value.confirm) {
|
|
$scope.deleteEnvVars(selectedEnvVars);
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.deleteEnvVars = function(selectedEnvVars) {
|
|
systemProvider.deleteEnvVar(selectedEnvVars).then(function() {
|
|
portalUtils.toast('Environment Variables deleted successfully', ['top', 'left'], 2000);
|
|
}).catch(function(err){
|
|
portalUtils.toast('Unable to delete environment variables: ' + err.message, ['top', 'left'], 4000);
|
|
});
|
|
};
|
|
|
|
$scope.edit = function() {
|
|
$mdDialog.show({
|
|
templateUrl: 'common/partials/add-env/add-env.html',
|
|
controller: 'AddEnvVarCtrl',
|
|
escapeToClose: false,
|
|
locals: {
|
|
modalInstance: {
|
|
header: 'Edit Environment Variables',
|
|
envVars: $scope.envGridApi.selection.getSelectedRows()
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.addEnvVar = function() {
|
|
$mdDialog.show({
|
|
templateUrl: 'common/partials/add-env/add-env.html',
|
|
controller: 'AddEnvVarCtrl',
|
|
escapeToClose: false,
|
|
locals: {
|
|
modalInstance: {
|
|
header: 'Add New Environment Variables',
|
|
envVars: []
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
$scope.selectedCount = function() {
|
|
try {
|
|
return $scope.envGridApi.selection.getSelectedRows().length;
|
|
} catch(err) {
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
} //end EnvBankCtrlController function
|
|
|
|
})(); |