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,91 @@
<md-dialog flex="40">
<form name="credForm" ng-submit="credForm.$valid && ok()">
<md-toolbar>
<div class="md-toolbar-tools md-portal">
<span>{{header}}</span>
<span flex></span>
<md-button class="md-icon-button" ng-click="cancel()">
<md-icon aria-label="Close dialog">close</md-icon>
</md-button>
</div>
</md-toolbar>
<md-dialog-content layout-padding flex>
<div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Credential Name</label>
<input ng-model="credentials.name" name="credName" id="credName" required>
<div ng-messages="credForm.credName.$error" ng-show="credForm.credName.$invalid && submitted || credForm.credName.$touched">
<div ng-message="required">Credentials name is required</div>
</div>
</md-input-container>
</div>
<div layout-gt-xs="row">
<md-input-container class="md-block" flex-gt-xs>
<label>Credential Type</label>
<md-select ng-model="credentials.credentialType" required name="type" id="type">
<md-option ng-repeat="cred in credentialTypes" ng-value="cred.name">{{cred.value}}</md-option>
</md-select>
<div ng-messages="credForm.type.$error" ng-show="credForm.type.$invalid && submitted || credForm.type.$touched">
<div ng-message="required">Credential type is required</div>
</div>
</md-input-container>
</div>
</div>
<div layout-gt-xs="row" layout-align="start center" ng-if="credentials.credentialType === 'PASSWD'">
<md-input-container class="md-block" flex-gt-sm>
<label>User Name</label>
<input ng-model="credentials.username" required name="username" id="username">
<div ng-messages="credForm.username.$error" ng-show="credForm.username.$invalid && submitted || credForm.username.$touched">
<div ng-message="required">Username is required</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex-gt-xs>
<label>Password</label>
<input ng-model="credentials.password" type="{{passwordType}}" name="password" id="password" ng-required="requirePassword">
<div ng-messages="credForm.password.$error" ng-show="credForm.password.$invalid && submitted || credForm.password.$touched">
<div ng-message="required">Password is required</div>
</div>
</md-input-container>
<md-button class="md-icon-button" style="margin-bottom: 25px;" ng-mousedown="passwordType='text'" ng-mouseup="passwordType='password'">
<md-icon>remove_red_eye</md-icon>
<md-tooltip>View password</md-tooltip>
</md-button>
</div>
<div layout="column" ng-if="credentials.credentialType === 'SSH'" flex>
<md-input-container class="md-block" flex-gt-sm>
<label>User Identity</label>
<input ng-model="credentials.username" required name="username" id="username">
<div ng-messages="credForm.username.$error" ng-show="credForm.username.$invalid && submitted || credForm.username.$touched">
<md-tooltip md-delay="500" class="mediaTileToolTip" md-direction="bottom">Username on the remote system the ssh key belongs to</md-tooltip>
<div ng-message="required">User identity is required</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex>
<label>SSH Private Key</label>
<textarea ng-model="credentials.key" name="sshKey" id="sshKey" required rows="3" cols="50"></textarea>
<div ng-messages="credForm.sshKey.$error" ng-show="credForm.sshKey.$invalid && submitted || credForm.sshKey.$touched">
<div ng-message="required">SSH Key is required</div>
</div>
</md-input-container>
<md-input-container class="md-block" flex>
<label>Passphrase</label>
<input ng-model="credentials.passphrase" name="passphrase" id="passphrase">
</md-input-container>
</div>
<div ng-show="loadingBlock" class="loadingFade"></div>
<div class="loadingModal" ng-show="loadingBlock">
<md-progress-circular md-mode="indeterminate" md-diameter="80" class="md-hue-2"></md-progress-circular>
</div>
</md-dialog-content>
<md-dialog-actions layout="row" class="modal-footer">
<div class="text-danger">{{error}}</div>
<md-button id="okButton" type="submit" class="md-raised md-primary" >OK</md-button>
<md-button id="cancelButton" class="md-raised md-warn" ng-click="cancel()">Cancel</md-button>
</md-dialog-actions>
</form>
</md-dialog>
@@ -0,0 +1,60 @@
(function () {
'use strict';
/**
* MODULE DESCRIPTION:
*
* TODO: Write description here.
*/
angular.module('portal.common.partials.addCreds', ['ui.router']).controller('AddCredsCtrl', AddUserCtrlController);
function AddUserCtrlController($scope, modalInstance, $state, cache, $mdDialog, Account, Credentials, credentialStores, credentialProvider, portalUtils) {
$scope.header = modalInstance.header;
$scope.passwordType = 'password';
$scope.submitted = false;
$scope.loadingBlock = false;
$scope.isNew = modalInstance.credentials === undefined ? true : false;
$scope.credentials = $scope.isNew ? new Credentials() : modalInstance.credentials;
$scope.valid = false;
$scope.mCache = cache.request([new credentialStores.CredentialTypes()]).then(function(){
$scope.credentialTypes = $scope.mCache.credentialTypes.data.values;
});
/**
* OK button handler
* @returns {undefined}
*/
$scope.ok = function () {
$scope.loadingBlock = true;
var status = $scope.isNew ? 'added': 'edited';
$scope.submitted = true;
credentialProvider.addCredentials($scope.credentials).then(function(data){
$scope.loadingBlock = false;
portalUtils.toast('Credentials ' + status + ' successfully', ['top', 'left'], 2000);
$mdDialog.hide();
}).catch(function(err){
$scope.loadingBlock = false;
$scope.error = err.message;
});
};
/**
* Cancel button handler.
* @returns {undefined}
*/
$scope.cancel = function () {
//Dismiss the modal
$mdDialog.cancel();
};
} //end AddUserCtrlController function
})();