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,102 @@
<md-dialog flex="40">
<form name="userForm" ng-submit="userForm.$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>Email Address <small>(This will be their user name)</small></label>
<input ng-model="account.email" name="email" id="email" required ng-pattern="/^.+@.+\..+$/">
<div ng-messages="userForm.email.$error" ng-show="userForm.email.$invalid && submitted || userForm.email.$touched">
<div ng-message="required">Email is required</div>
<div ng-message="pattern">Email is not in correct format</div>
</div>
</md-input-container>
</div>
<div layout-gt-xs="row" layout-align="start center">
<md-input-container class="md-block" flex-gt-xs>
<label>Password</label>
<input ng-model="account.password" type="{{passwordType}}" name="password" id="password" ng-required="requirePassword">
<div ng-messages="userForm.password.$error" ng-show="userForm.password.$invalid && submitted || userForm.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>
<md-input-container class="md-block" flex-gt-xs>
<label>Confirm Password</label>
<input ng-model="account.confPassword" type="{{confPasswordType}}" name="confPassword" id="confPassword"
ng-required="requirePassword" compare-to="account.password">
<div ng-messages="userForm.confPassword.$error" ng-show="userForm.confPassword.$invalid && submitted || userForm.confPassword.$touched">
<div ng-message="compareTo">Passwords do not match</div>
<div ng-message="required">Must confirm password</div>
</div>
</md-input-container>
<md-button class="md-icon-button" style="margin-bottom: 25px;" ng-mousedown="confPasswordType='text'" ng-mouseup="confPasswordType='password'">
<md-icon>remove_red_eye</md-icon>
<md-tooltip>View password</md-tooltip>
</md-button>
</div>
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>
<label>First name</label>
<input ng-model="account.firstName">
</md-input-container>
<md-input-container class="md-block" flex-gt-sm>
<label>Last Name</label>
<input ng-model="account.lastName">
</md-input-container>
</div>
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>
<label>Role</label>
<md-select ng-model="account.role" id="role" name="role" required>
<md-option value="USER">User</md-option>
<md-option value="ADMIN">Administrator</md-option>
</md-select>
<div ng-messages="userForm.role.$error" ng-show="userForm.role.$invalid && submitted || userForm.role.$touched">
<div ng-message="required">Role is required</div>
</div>
</md-input-container>
</div>
<div layout-gt-sm="row">
<md-input-container class="md-block" flex-gt-sm>
<label>Effective Date</label>
<md-datepicker ng-model="account.effectiveDate"></md-datepicker>
</md-input-container>
<md-input-container class="md-block" flex-gt-sm>
<label>Expiration Date</label>
<md-datepicker ng-model="account.expirationDate"></md-datepicker>
</md-input-container>
</div>
</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,85 @@
(function () {
'use strict';
/**
* MODULE DESCRIPTION:
*
* TODO: Write description here.
*/
angular.module('portal.common.partials.addUser', ['ui.router']).controller('AddUserCtrl', AddUserCtrlController);
function AddUserCtrlController($scope, modalInstance, $state, cache, $mdDialog, Account, accountProvider, portalUtils,
permissionStores, configStores, Triggers) {
$scope.header = modalInstance.header;
$scope.passwordType = 'password';
$scope.confPasswordType = 'password';
$scope.requirePassword = modalInstance.requirePassword;
$scope.submitted = false;
$scope.loadingBlock = false;
$scope.isNew = modalInstance.account === undefined ? true : false;
$scope.account = $scope.isNew ? new Account() : modalInstance.account;
$scope.valid = false;
$scope.mCache = cache.request([new configStores.Config('userExpirationDays'),
new permissionStores.AllPermissionGroups()]).then(function(){
$scope.expirationDays = parseInt($scope.mCache.config.data.userExpirationDays);
$scope.permissionGroups = $scope.mCache.allPermissionGroups.data.values;
}).catch(function(err){
portalUtils.toast('Unable to get expiration days: ' + err.message, ['top', 'left'], 4000);
});
if ($scope.isNew) {
$scope.account.effectiveDate = new Date();
} else {
$scope.account.effectiveDate = moment($scope.account.effectiveDate);
$scope.account.expirationDate = moment($scope.account.expirationDate);
}
$scope.$watch('expirationDays', function(value){
if ($scope.isNew) {
$scope.account.expirationDate = moment().add($scope.expirationDays, 'days');
}
});
/**
* OK button handler
* @returns {undefined}
*/
$scope.ok = function () {
$scope.loadingBlock = true;
var status = $scope.isNew ? 'added': 'edited';
$scope.submitted = true;
accountProvider.addUser($scope.account).then(function(data){
$scope.loadingBlock = false;
portalUtils.toast('User ' + 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();
};
Triggers.listen([Triggers.PERMISSIONS_ADDED, Triggers.PERMISSIONS_DELETED], function(trigger, payload){
new permissionStores.AllPermissionGroups().refresh();
});
} //end AddUserCtrlController function
})();