-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
267 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
modules/ui/app/scripts/controllers/AddSuperadminModalCtrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* global $:false */ | ||
|
||
'use strict'; | ||
|
||
angular.module('wasabi.controllers') | ||
.controller('AddSuperadminModalCtrl', | ||
['$scope', '$modalInstance', 'AuthFactory', 'UtilitiesFactory', '$rootScope', '$modal', 'AUTH_EVENTS', 'SuperadminsFactory', | ||
function ($scope, $modalInstance, AuthFactory, UtilitiesFactory, $rootScope, $modal, AUTH_EVENTS, SuperadminsFactory) { | ||
|
||
UtilitiesFactory.trackEvent('loadedDialog', | ||
{key: 'dialog_name', value: 'addSuperadmin'}); | ||
|
||
$scope.data = { | ||
superadminEmail: '' | ||
}; | ||
|
||
$scope.superadmin = null; | ||
$scope.superadminFormSubmitted = false; | ||
$scope.superadminValidated = false; | ||
$scope.validating = false; | ||
$scope.failedValidation = false; | ||
|
||
$scope.postSubmitError = null; | ||
$scope.modalInstance = (this._isTesting === true ? null : $modalInstance); | ||
$scope.verifyFormNoValueError = false; | ||
|
||
// This is called when we are in Add Superadmin and they enter a superadmin ID and hit Verify. We need to | ||
// verify that the superadmin ID is valid and retrieve information about the superadmin, such as apps they | ||
// have roles for. | ||
$scope.verifySuperadmin = function() { | ||
if ($scope.data.superadminEmail.length === 0) { | ||
$scope.verifyFormNoValueError = true; | ||
return; | ||
} | ||
$scope.verifyFormNoValueError = false; | ||
// Hit API to validate that the ID is a valid Corp superadmin. | ||
$scope.validating = true; | ||
$scope.superadminValidated = false; | ||
$scope.failedValidation = false; | ||
AuthFactory.checkValidUser({ | ||
email: $scope.data.superadminEmail | ||
}).$promise.then(function (results) { | ||
$scope.validating = false; | ||
if (results) { | ||
$scope.superadmin = {}; | ||
$scope.superadmin.superadminID = (results.superadminname ? results.superadminname : ''); | ||
$scope.superadmin.firstName = (results.firstName ? results.firstName : ''); | ||
$scope.superadmin.lastName = (results.lastName ? results.lastName : ''); | ||
$scope.superadmin.email = (results.email ? results.email : ''); | ||
$scope.superadminValidated = true; | ||
} | ||
}, function(/*response*/) { | ||
$scope.failedValidation = true; | ||
}); | ||
}; | ||
|
||
$scope.addSuperadmin = function() { | ||
/* | ||
SuperadminsFactory.create({ | ||
username: $scope.superadmin.username, | ||
firstName: $scope.superadmin.firstName, | ||
lastName: $scope.superadmin.lastName, | ||
email: $scope.superadmin.email | ||
}).$promise.then(function () { | ||
UtilitiesFactory.trackEvent('createItemSuccess', | ||
{key: 'dialog_name', value: 'createSuperadmin'}, | ||
{key: 'experiment_id', value: $scope.superadmin.username}, | ||
{key: 'item_id', value: $scope.superadmin.username}); | ||
$scope.closeDialog(); | ||
}, | ||
function(response) { | ||
UtilitiesFactory.handleGlobalError(response, 'Attempting to remove a superadmin resulted in error.'); | ||
}); | ||
*/ | ||
$scope.closeDialog(); | ||
}; | ||
|
||
$scope.closeDialog = function () { | ||
$modalInstance.close(); | ||
}; | ||
|
||
}]); |
82 changes: 82 additions & 0 deletions
82
modules/ui/app/scripts/controllers/SuperadminsTableCtrl.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*jshint devel:true */ | ||
|
||
'use strict'; | ||
|
||
angular.module('wasabi.controllers'). | ||
controller('SuperadminsTableCtrl', ['$scope', '$filter', '$http', 'SuperadminsFactory', '$modal', 'UtilitiesFactory', 'DialogsFactory', 'AUTH_EVENTS', | ||
function ($scope, $filter, $http, SuperadminsFactory, $modal, UtilitiesFactory, DialogsFactory, AUTH_EVENTS) { | ||
|
||
$scope.superadmins = []; | ||
|
||
// load superadmins from server | ||
$scope.loadSuperadmins = function () { | ||
//$scope.superadmins = SuperadminsFactory.query(); | ||
$scope.superadmins = [ | ||
{ | ||
username: 'scressler', | ||
firstName: 'Scott', | ||
lastName: 'Cressler', | ||
email: 'scott_cressler@intuit.com' | ||
}, | ||
{ | ||
username: 'cma', | ||
firstName: 'Calvin', | ||
lastName: 'Ma', | ||
email: 'calvin_ma@intuit.com' | ||
} | ||
]; | ||
}; | ||
|
||
UtilitiesFactory.hideHeading(false); | ||
UtilitiesFactory.selectTopLevelTab('Tools'); | ||
|
||
$scope.capitalizeFirstLetter = function(string) { | ||
return UtilitiesFactory.capitalizeFirstLetter(string); | ||
}; | ||
|
||
$scope.removeSuperadmin = function(user) { | ||
DialogsFactory.confirmDialog('Remove superadmin privileges for user, ' + user.username + '?', 'Remove Superadmin', function() { | ||
/* | ||
SuperadminsFactory.delete({ | ||
id: user.username | ||
}).$promise.then(function () { | ||
UtilitiesFactory.trackEvent('deleteItemSuccess', | ||
{key: 'dialog_name', value: 'deleteSuperadmin'}, | ||
{key: 'experiment_id', value: user.username}, | ||
{key: 'item_id', value: user.username}); | ||
$scope.loadSuperadmins(); | ||
}, | ||
function(response) { | ||
UtilitiesFactory.handleGlobalError(response, 'Attempting to remove a superadmin resulted in error.'); | ||
}); | ||
*/ | ||
}); | ||
}; | ||
|
||
// init controller | ||
$scope.loadSuperadmins(); | ||
|
||
$scope.openAddSuperadminModal = function (superadmin) { | ||
var modalInstance = $modal.open({ | ||
templateUrl: 'views/AddSuperadminModal.html', | ||
controller: 'AddSuperadminModalCtrl', | ||
windowClass: 'xxx-dialog', | ||
backdrop: 'static' | ||
}); | ||
|
||
// This will cause the dialog to be closed and we get redirected to the Sign In page if | ||
// the login token has expired. | ||
UtilitiesFactory.failIfTokenExpired(modalInstance); | ||
|
||
// This handles closing the dialog if one of the child dialogs has encountered an expired token. | ||
$scope.$on(AUTH_EVENTS.notAuthenticated, function() { | ||
modalInstance.close(); | ||
}); | ||
|
||
modalInstance.result.then(function () { | ||
$scope.loadSuperadmins(); | ||
}); | ||
}; | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
angular.module('wasabi.services').factory('SuperadminsFactory', ['$resource', 'ConfigFactory', | ||
function ($resource, ConfigFactory) { | ||
return $resource(ConfigFactory.baseUrl() + '/authorization/role/superadmin/:id', {}, { | ||
'create': { method: 'POST', | ||
transformRequest: function (data) { | ||
return typeof(data) === 'string' ? data : JSON.stringify(data); | ||
} | ||
}, | ||
'query': { method: 'GET', | ||
transformResponse: function (data) { | ||
var parsedData = $.parseJSON(data); | ||
|
||
return parsedData; | ||
}, | ||
isArray: true | ||
}, | ||
'delete': { method: 'DELETE', | ||
params: {id: '@id'} | ||
} | ||
}); | ||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<div id="addSuperadmin" class="modalDialog"> | ||
<h1>Add Superadmin</h1> | ||
|
||
<form name="superadminForm" novalidate ng-submit="addSuperadmin()"> | ||
<div class="dialogContent"> | ||
<div ng-show="!superadmin.superadminID" class="enterCorpId"> | ||
<div class="verifyField"> | ||
<input id="email" type="text" class="text" placeholder="Email Address" auto-focus ng-model="data.superadminEmail" /> | ||
<div class="verify" ng-class="{pass: superadminValidated, verifying: validating, fail: failedValidation}"></div> | ||
</div> | ||
<button class="blue verifySuperadminId" type="button" ng-click="verifySuperadmin()">Verify</button> | ||
<div class="hint">Email Address must be entered exactly.</div> | ||
<div class="error" | ||
ng-show="verifyFormNoValueError"> | ||
<small class="fieldError" | ||
ng-show="verifyFormNoValueError"> | ||
Email Address required. | ||
</small> | ||
</div> | ||
</div> | ||
<div class="buttonBar"> | ||
<button type="submit" id="btnAddSuperadmin" class="blue" ng-class="{disabled: !superadminValidated}" ng-disabled="!superadminValidated">Make Superadmin</button> | ||
<button class="cancel" ng-click="closeDialog()">Close</button> | ||
</div> | ||
</div> | ||
|
||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<div ng-controller="SuperadminsTableCtrl"> | ||
<div class="toolbar"> | ||
<button id="btnNewSuperadmin" class="blue" ng-click="openAddSuperadminModal()">Add Superadmin</button> | ||
</div> | ||
|
||
<div id="usersList"> | ||
<div class="tableContainer"> | ||
<table col-resizeable> | ||
<tr> | ||
<th style="width:13%" class="_username"><span class="colLabel">ID</span></th> | ||
<th style="width:16%" class="_score"><span class="colLabel">First Name</span></th> | ||
<th style="width:18%" class="_comments"><span class="colLabel">Last Name</span></th> | ||
<th style="width:20%" class="_email"><span class="colLabel">Email</span></th> | ||
<th style="width:8%" class="icon">Actions</th> | ||
</tr> | ||
<tr ng-repeat="superadmin in superadmins | orderBy:orderByField:reverseSort"> | ||
<td> | ||
{{superadmin.username}} | ||
</td> | ||
<td> | ||
{{superadmin.firstName}} | ||
</td> | ||
<td> | ||
{{superadmin.lastName}} | ||
</td> | ||
<td> | ||
{{superadmin.email}} | ||
</td> | ||
<td class="icon"> | ||
<a class="command delete" href="#" title="Remove Superadmin" onclick="return false;" ng-click="removeSuperadmin(superadmin)"> | ||
Delete | ||
</a> | ||
</td> | ||
</tr> | ||
</table> | ||
</div> | ||
</div> | ||
</div> |