Initial commit

This commit is contained in:
Isaac Parenteau committed 2018-07-07 20:43:51 -05:00
commit 880e39de2e
511 files changed
+38363

No files matched your search

@@ -0,0 +1,115 @@
(function () {
'use strict';
/**
* MODULE DESCRIPTION:
*
* TODO: Write description here.
*/
angular.module('portal.dashboard.credBank', ['ui.router'])
.controller('CredBankCtrl', credBankCtrlController);
function credBankCtrlController($scope, cache, credentialProvider, credentialStores, $mdDialog, uiGridConstants, portalUtils, Constants) {
$scope.Permissions = Constants.Permissions;
$scope.confirmQuestionBox = true;
$scope.mCache = cache.request([new credentialStores.Credentials()]).then(function(){
$scope.credentials = $scope.mCache.credentials.data.values;
});
$scope.credsGrid = {
data: 'credentials',
paginationPageSizes: [28, 56, 84, 102],
paginationPageSize: 28,
enableHorizontalScrollbar: uiGridConstants.scrollbars.NEVER,
toggleModifierKeysToMultiSelect : true,
enableRowHeaderSelection: true,
multiSelect: true,
noUnselect: false,
onRegisterApi: function (gridApi) {
gridApi.selection.setModifierKeysToMultiSelect(true);
$scope.credsGridApi = gridApi;
},
columnDefs: [
{field: 'name', displayName: 'Credential Name', width: '*'},
{field: 'useSSH', displayName: 'Credential Type', width: '*',
cellTemplate: '<div class="ui-grid-cell-contents">{{row.entity.credentialType === "SSH" ? "SSH Key" : "Username/Password"}}</div>'},
{field: 'uid', displayName: 'Actions', width: '100', enableColumnMenu: false, enableFiltering: false, enableHiding: false,
cellTemplate: 'main/cred-bank/cell-templates/cred-actions.html'}
],
};
$scope.$on('$destroy', function () {
$scope.mCache.unlisten();
});
$scope.toggleFiltering = function() {
$scope.credsGridApi.enableFiltering = !$scope.credsGridApi.enableFiltering;
$scope.credsGridApi.core.notifyDataChange( uiGridConstants.dataChange.COLUMN );
};
var originatorEv;
$scope.openMenu = function($mdOpenMenu, ev) {
originatorEv = ev;
$mdOpenMenu(ev);
};
$scope.delete = function(entity) {
if ($scope.confirmQuestionBox) {
portalUtils.confirmBox('deleteCreds', 'Delete Credentials', ['Are you sure you want to delete the credential', entity.name],
true, function(value) {
if (value.confirm) {
$scope.confirmQuestionBox = !value.checkbox;
$scope.deleteCreds(entity);
}
});
} else {
$scope.deleteCreds(entity);
}
};
$scope.deleteCreds = function(entity) {
credentialProvider.deleteCredentials(entity).then(function() {
portalUtils.toast('Credentials deleted successfully', ['top', 'left'], 2000);
new credentialStores.Credentials().refresh();
}).catch(function(err){
portalUtils.toast('Unable to delete credentials: ' + err.message, ['top', 'left'], 4000);
new credentialStores.Credentials().refresh();
});
};
$scope.edit = function(entity) {
$mdDialog.show({
templateUrl: 'common/partials/add-creds/add-creds.html',
controller: 'AddCredsCtrl',
escapeToClose: false,
locals: {
modalInstance: {
header: 'Edit Credentials',
credentials: entity
}
}
}).then(function(){
new credentialStores.Credentials().refresh();
});
};
$scope.addCredentials = function() {
$mdDialog.show({
templateUrl: 'common/partials/add-creds/add-creds.html',
controller: 'AddCredsCtrl',
escapeToClose: false,
locals: {
modalInstance: {
header: 'Add Credentials',
}
}
}).then(function(){
new credentialStores.Credentials().refresh();
});
};
} //end UserBankCtrlController function
})();