summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-common/client/app/views/admins
diff options
context:
space:
mode:
authorChristopher Lott (Christopher) (cl778h) <clott@vm-ep-dev2.client.research.att.com>2017-06-12 09:49:00 -0400
committerChristopher Lott (cl778h) <clott@research.att.com>2017-06-12 13:42:43 -0400
commit627badaf69987c01811c477219fd943757a635f5 (patch)
tree97df9449a411d1ecf830cc76d8afd6f9b5677bda /ecomp-portal-FE-common/client/app/views/admins
parentba838f2e13f1e8050c75e68bd3733d56d8f416d5 (diff)
[PORTAL-16 PORTAL-18] Widget ms; staging
Remove staging repositories from poms. Add widget microservice code base. Add portal unit tests. Repair defects. Normalize line endings. Change-Id: Ia5e48da2a3141b352439ecd548cddf918f4df585 Signed-off-by: Christopher Lott (cl778h) <clott@research.att.com>
Diffstat (limited to 'ecomp-portal-FE-common/client/app/views/admins')
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.js505
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js268
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.html25
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.less6
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/admins.controller.spec.js38
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/admins.less57
-rw-r--r--ecomp-portal-FE-common/client/app/views/admins/admins.tpl.html132
7 files changed, 522 insertions, 509 deletions
diff --git a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.js b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.js
index 5a164e1a..9aec9b4f 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.js
+++ b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.js
@@ -1,252 +1,253 @@
-/*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-
-'use strict';
-(function () {
- class NewAdminModalCtrl {
- constructor($log, adminsService, $scope, confirmBoxService, utilsService, $location) {
-
- let init = () => {
- this.isSaving = false;
- this.originalApps = [];
- /* istanbul ignore if */
- if ($scope.ngDialogData && $scope.ngDialogData.selectedUser && $scope.ngDialogData.dialogState) {
- this.selectedUser = $scope.ngDialogData.selectedUser;
- this.dialogState = $scope.ngDialogData.dialogState;
- this.isShowBack = false;
- if (this.dialogState === 2) {
- this.getAdminAppsRoles();
- }
- } else {
- this.isShowBack = true;
- this.selectedUser = null;
- this.dialogState = 1;
- }
-
- //this.searchUsersInProgress = false;
- //this.showNewAdminAppDropdown = false;
- $log.info('NewAdminModalCtrl::initiated');
- this.appsOrder = [];
- };
-
- let orderList = (apps) => {
- this.appsOrder = [];
- for (var i = 0; i < apps.length; i++) {
- if (apps[i].isAdmin) {
- this.appsOrder.push(apps[i].id);
- }
- }
- };
-
- this.orderFilter = app => {
- if (!app || !app.id || !this.appsOrder.length) {
- return;
- }
- return this.appsOrder.indexOf(app.id);
- };
-
- /**
- * this function get the selected admin apps roles
- */
- this.getAdminAppsRoles = () => {
- if (!this.selectedUser || !this.selectedUser.orgUserId) {
- $log.error('No user is selected / searchUsers is InProgress');
- this.dialogState = 1;
- return;
- }
- adminsService.getAdminAppsRoles(this.selectedUser.orgUserId).then(roles => {
- $log.debug('apps roles res: ', JSON.stringify(roles));
- if (!roles.appsRoles) {
- return;
- }
-
- this.adminAppsRoles = [];
- for (var i = 0; i < roles.appsRoles.length; i++) {
- if (!roles.appsRoles[i].restrictedApp) {
- $log.debug('pushing: {id: ', roles.appsRoles[i].id,
- 'name: ', roles.appsRoles[i].appName,
- 'restrictedApp: ', roles.appsRoles[i].restrictedApp,
- 'isAdmin: ', roles.appsRoles[i].isAdmin, '}');
- this.adminAppsRoles.push({
- id: roles.appsRoles[i].id,
- appName: roles.appsRoles[i].appName,
- isAdmin: roles.appsRoles[i].isAdmin,
- restrictedApp: roles.appsRoles[i].restrictedApp
- });
- }
- }
- this.dialogState = 2;
- this.adminAppsRoles = this.adminAppsRoles.sort(getSortOrder("appName"));
-
- orderList(roles.appsRoles);
- if (this.appsOrder != null) {
- for (var j = 0; j < this.appsOrder.length; j++) {
- this.originalApps.push(this.appsOrder[j]);
- }
- }
- }).catch(err => {
- $log.error(err);
- });
- };
-
- // Refactor this into a directive
- let getSortOrder = (prop) => {
- return function (a, b) {
- if (a[prop].toLowerCase() > b[prop].toLowerCase()) {
- return 1;
- } else if (a[prop].toLowerCase() < b[prop].toLowerCase()) {
- return -1;
- }
- return 0;
- }
- }
-
- /**
- * this function set the selected user
- * @param user: selected user object
- */
- this.setSelectedUser = (user) => {
- $log.debug('selected user: ', user);
- this.selectedUser = user;
- };
-
- /**
- * Mark the user as not admin of the selected app
- * @param app: selected app object
- */
- this.unadminApp = (app) => {
- confirmBoxService.deleteItem(app.appName).then(confirmed => {
- if (confirmed === true) {
- app.isAdmin = false;
- this.appsOrder.splice(this.appsOrder.indexOf(app.id), 1);
- }
- }).catch(err => {
- $log(err);
- });
- };
-
- /**
- * update the selected admin app with the new roles
- */
- this.updateAdminAppsRoles = () => {
- if (!this.selectedUser || !this.selectedUser.orgUserId || !this.adminAppsRoles) {
- return;
- }
- this.isSaving = true;
- $log.debug('going to update user: ' + this.selectedUser.orgUserId + ' with app roles: ' + JSON.stringify(this.adminAppsRoles));
- confirmBoxService.makeAdminChanges('Are you sure you want to make these admin changes?')
- .then(confirmed => {
- if(confirmed === true){
- adminsService.updateAdminAppsRoles({
- orgUserId: this.selectedUser.orgUserId,
- appsRoles: this.adminAppsRoles
- })
- .then(res => {
- $log.debug('Admin apps roles updated successfully!', res);
- //close and resolve dialog promise with true (to update the table)
- this.remindToAddUserIfNecessary();
- $scope.closeThisDialog(true);
- }).catch(err => {
- $log.error('NewAdminModalCtrl.updateAdminAppsRoles:: Failed - ' + err);
- }).finally(()=> {
- this.isSaving = false;
- })
- }else{
- this.isSaving = false;
- }
- });
- };
-
- /**
- * Navigate between dialog screens using step number: 1,2,...
- */
- this.navigateBack = () => {
- if (this.dialogState === 1) {
- //back from 1st screen?
- }
- if (this.dialogState === 2) {
- this.dialogState = 1;
- }
- };
-
- init();
-
- /**
- * each time new app is selected in the drop down,
- * add it to the user administrated apps list
- */
- $scope.$watch('newAdmin.selectedNewApp', (newVal) => {
- if (!newVal || newVal.isAdmin === undefined) {
- return;
- }
- //newVal.isAdmin = true; - track by ruined this, here is the workaround:
- let app = _.find(this.adminAppsRoles, {id: newVal.id});
- if (app) {
- app.isAdmin = true;
- this.appsOrder.push(app.id);
- }
- this.selectedNewApp = null;
- //this.showNewAdminAppDropdown = false;
- });
-
- $scope.$on('$stateChangeStart', e => {
- //Disable navigation when modal is opened
- //**Nabil - note: this will cause the history back state to be replaced with current state
- e.preventDefault();
- });
-
- /**
- * If an Admin was added for an application remind the portal admin to add the admin as a user
- */
- this.remindToAddUserIfNecessary = () => {
-
- var adminAddedToNewApp = false;
- if ((this.originalApps != null) && (this.originalApps.length > 0)) {
- for (var i = 0; i < this.appsOrder.length; i++) {
- var foundApp = false;
- for (var j = 0; j < this.originalApps.length; j++) {
- if (this.originalApps[j] === this.appsOrder[i]) {
- foundApp = true;
- }
- }
- if (foundApp === false) {
- adminAddedToNewApp = true;
- break;
- }
- }
- } else {
- adminAddedToNewApp = true;
- }
-
- if (adminAddedToNewApp === true) {
- confirmBoxService.confirm('Add this person as an application user? This allows them to access the application from ECOMP Portal. Press OK to go to the Add Users page.')
- .then(confirmed => {
- if (confirmed === true) {
- $location.path('/users');
- }
- });
- }
- }
-
- }
- }
- NewAdminModalCtrl.$inject = ['$log', 'adminsService', '$scope', 'confirmBoxService', 'utilsService', '$location'];
- angular.module('ecompApp').controller('NewAdminModalCtrl', NewAdminModalCtrl);
-})();
+/*-
+ * ================================================================================
+ * ECOMP Portal
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+
+'use strict';
+(function () {
+ class NewAdminModalCtrl {
+ constructor($log, adminsService, $scope, confirmBoxService, utilsService, $location) {
+
+ let init = () => {
+ this.isSaving = false;
+ this.originalApps = [];
+ /* istanbul ignore if */
+ if ($scope.ngDialogData && $scope.ngDialogData.selectedUser && $scope.ngDialogData.dialogState) {
+ this.selectedUser = $scope.ngDialogData.selectedUser;
+ this.dialogState = $scope.ngDialogData.dialogState;
+ this.isShowBack = false;
+ if (this.dialogState === 2) {
+ this.getAdminAppsRoles();
+ }
+ } else {
+ this.isShowBack = true;
+ this.selectedUser = null;
+ this.dialogState = 1;
+ }
+
+ //this.searchUsersInProgress = false;
+ //this.showNewAdminAppDropdown = false;
+ $log.info('NewAdminModalCtrl::initiated');
+ this.appsOrder = [];
+ };
+
+ let orderList = (apps) => {
+ this.appsOrder = [];
+ for (var i = 0; i < apps.length; i++) {
+ if (apps[i].isAdmin) {
+ this.appsOrder.push(apps[i].id);
+ }
+ }
+ };
+
+ this.orderFilter = app => {
+ if (!app || !app.id || !this.appsOrder.length) {
+ return;
+ }
+ return this.appsOrder.indexOf(app.id);
+ };
+
+ /**
+ * this function get the selected admin apps roles
+ */
+ this.getAdminAppsRoles = () => {
+ if (!this.selectedUser || !this.selectedUser.orgUserId) {
+ $log.error('No user is selected / searchUsers is InProgress');
+ this.dialogState = 1;
+ return;
+ }
+ adminsService.getAdminAppsRoles(this.selectedUser.orgUserId).then(roles => {
+ $log.debug('apps roles res: ', JSON.stringify(roles));
+ if (!roles.appsRoles) {
+ return;
+ }
+
+ this.adminAppsRoles = [];
+ for (var i = 0; i < roles.appsRoles.length; i++) {
+ if (!roles.appsRoles[i].restrictedApp) {
+ $log.debug('pushing: {id: ', roles.appsRoles[i].id,
+ 'name: ', roles.appsRoles[i].appName,
+ 'restrictedApp: ', roles.appsRoles[i].restrictedApp,
+ 'isAdmin: ', roles.appsRoles[i].isAdmin, '}');
+ this.adminAppsRoles.push({
+ id: roles.appsRoles[i].id,
+ appName: roles.appsRoles[i].appName,
+ isAdmin: roles.appsRoles[i].isAdmin,
+ restrictedApp: roles.appsRoles[i].restrictedApp
+ });
+ }
+ }
+ this.dialogState = 2;
+ this.adminAppsRoles = this.adminAppsRoles.sort(getSortOrder("appName"));
+
+ orderList(roles.appsRoles);
+ if (this.appsOrder != null) {
+ for (var j = 0; j < this.appsOrder.length; j++) {
+ this.originalApps.push(this.appsOrder[j]);
+ }
+ }
+ }).catch(err => {
+ $log.error(err);
+ });
+ };
+
+ // Refactor this into a directive
+ let getSortOrder = (prop) => {
+ return function (a, b) {
+ if (a[prop].toLowerCase() > b[prop].toLowerCase()) {
+ return 1;
+ } else if (a[prop].toLowerCase() < b[prop].toLowerCase()) {
+ return -1;
+ }
+ return 0;
+ }
+ }
+
+ /**
+ * this function set the selected user
+ * @param user: selected user object
+ */
+ this.setSelectedUser = (user) => {
+ $log.debug('selected user: ', user);
+ this.selectedUser = user;
+ };
+
+ /**
+ * Mark the user as not admin of the selected app
+ * @param app: selected app object
+ */
+ this.unadminApp = (app) => {
+ confirmBoxService.deleteItem(app.appName).then(confirmed => {
+ if (confirmed === true) {
+ app.isAdmin = false;
+ this.appsOrder.splice(this.appsOrder.indexOf(app.id), 1);
+ }
+ }).catch(err => {
+ $log(err);
+ });
+ };
+
+ /**
+ * update the selected admin app with the new roles
+ */
+ this.updateAdminAppsRoles = () => {
+ if (!this.selectedUser || !this.selectedUser.orgUserId || !this.adminAppsRoles) {
+ return;
+ }
+ this.isSaving = true;
+ $log.debug('going to update user: ' + this.selectedUser.orgUserId + ' with app roles: ' + JSON.stringify(this.adminAppsRoles));
+ confirmBoxService.makeAdminChanges('Are you sure you want to make these admin changes?')
+ .then(confirmed => {
+ if(confirmed === true){
+ adminsService.updateAdminAppsRoles({
+ orgUserId: this.selectedUser.orgUserId,
+ appsRoles: this.adminAppsRoles
+ })
+ .then(res => {
+ $log.debug('Admin apps roles updated successfully!', res);
+ //close and resolve dialog promise with true (to update the table)
+ this.remindToAddUserIfNecessary();
+ $scope.closeThisDialog(true);
+ }).catch(err => {
+ $log.error('NewAdminModalCtrl.updateAdminAppsRoles:: Failed - ' + err);
+ }).finally(()=> {
+ this.isSaving = false;
+ })
+ }else{
+ this.isSaving = false;
+ }
+ });
+ };
+
+ /**
+ * Navigate between dialog screens using step number: 1,2,...
+ */
+ this.navigateBack = () => {
+ if (this.dialogState === 1) {
+ //back from 1st screen?
+ }
+ if (this.dialogState === 2) {
+ this.dialogState = 1;
+ }
+ };
+
+ init();
+
+ /**
+ * each time new app is selected in the drop down,
+ * add it to the user administrated apps list
+ */
+ $scope.$watch('newAdmin.selectedNewApp.value', (newVal) => {
+ var newVal= JSON.parse(newVal);
+ if (!newVal || newVal.isAdmin === undefined) {
+ return;
+ }
+ //newVal.isAdmin = true; - track by ruined this, here is the workaround:
+ let app = _.find(this.adminAppsRoles, {id: newVal.id});
+ if (app) {
+ app.isAdmin = true;
+ this.appsOrder.push(app.id);
+ }
+ this.selectedNewApp = null;
+ //this.showNewAdminAppDropdown = false;
+ });
+
+ $scope.$on('$stateChangeStart', e => {
+ //Disable navigation when modal is opened
+ //**Nabil - note: this will cause the history back state to be replaced with current state
+ e.preventDefault();
+ });
+
+ /**
+ * If an Admin was added for an application remind the portal admin to add the admin as a user
+ */
+ this.remindToAddUserIfNecessary = () => {
+
+ var adminAddedToNewApp = false;
+ if ((this.originalApps != null) && (this.originalApps.length > 0)) {
+ for (var i = 0; i < this.appsOrder.length; i++) {
+ var foundApp = false;
+ for (var j = 0; j < this.originalApps.length; j++) {
+ if (this.originalApps[j] === this.appsOrder[i]) {
+ foundApp = true;
+ }
+ }
+ if (foundApp === false) {
+ adminAddedToNewApp = true;
+ break;
+ }
+ }
+ } else {
+ adminAddedToNewApp = true;
+ }
+
+ if (adminAddedToNewApp === true) {
+ confirmBoxService.confirm('Add this person as an application user? This allows them to access the application from ECOMP Portal. Press OK to go to the Add Users page.')
+ .then(confirmed => {
+ if (confirmed === true) {
+ $location.path('/users');
+ }
+ });
+ }
+ }
+
+ }
+ }
+ NewAdminModalCtrl.$inject = ['$log', 'adminsService', '$scope', 'confirmBoxService', 'utilsService', '$location'];
+ angular.module('ecompApp').controller('NewAdminModalCtrl', NewAdminModalCtrl);
+})();
diff --git a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js
index 540459ed..c6011d18 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js
+++ b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.controller.spec.js
@@ -1,134 +1,134 @@
-/*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
-/**
- * Created by nnaffar on 12/8/15.
- */
-'use strict';
-
-describe('Controller: NewAdminCtrl ', () => {
- beforeEach(module('ecompApp'));
-
- //destroy $http default cache before starting to prevent the error 'default cache already exists'
- beforeEach(inject((_CacheFactory_)=> {
- _CacheFactory_.destroyAll();
- }));
-
-
- let newCtrl, $controller, $q, $rootScope, $log;
-
- beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
- [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
- }));
-
- let deferredAdminAppsRoles, deferredUpdateRolesRes;
- let adminsServiceMock;
- beforeEach(()=> {
- [deferredAdminAppsRoles, deferredUpdateRolesRes] = [$q.defer(), $q.defer()];
-
- adminsServiceMock = jasmine.createSpyObj('adminsServiceMock', ['getAdminAppsRoles', 'updateAdminAppsRoles']);
-
- adminsServiceMock.getAdminAppsRoles.and.returnValue(deferredAdminAppsRoles.promise);
- adminsServiceMock.updateAdminAppsRoles.and.returnValue(deferredUpdateRolesRes.promise);
-
- newCtrl = $controller('NewAdminModalCtrl', {
- $log: $log,
- adminsService: adminsServiceMock,
- $scope: $rootScope
- });
- });
-
- it('should init default values when loading the controller', ()=> {
- expect(newCtrl.dialogState).toBe(1);
- expect(newCtrl.selectedUser).toBe(null);
- });
-
- it('should populate admin apps roles and move to the next screen when adminsService.getAdminAppsRoles succeeded', ()=> {
- let userApps = {appsRoles: [{id: 1, isAdmin: false}, {id: 2, isAdmin: true}]};
- deferredAdminAppsRoles.resolve(userApps);
-
- newCtrl.selectedUser = {orgUserId: 'orgUserId'};
-
- newCtrl.getAdminAppsRoles();
- $rootScope.$apply();
-
- expect(adminsServiceMock.getAdminAppsRoles).toHaveBeenCalledWith(newCtrl.selectedUser.orgUserId);
- expect(newCtrl.adminAppsRoles).toEqual(userApps.appsRoles);
- expect(newCtrl.dialogState).toBe(2);
- });
-
- it('should log the error when adminsService.getAdminAppsRoles fails', ()=> {
- spyOn($log, 'error');
- deferredAdminAppsRoles.reject('some error');
-
- newCtrl.searchUsersInProgress = false;
- newCtrl.selectedUser = {orgUserId: 'orgUserId'};
-
- newCtrl.getAdminAppsRoles();
- $rootScope.$apply();
-
- expect($log.error).toHaveBeenCalled();
- });
- it('should log the error when trying to getAdminAppsRoles without selecting user ', ()=> {
- spyOn($log, 'error');
-
- newCtrl.searchUsersInProgress = false;
- newCtrl.selectedUser = null;
-
- newCtrl.getAdminAppsRoles();
- $rootScope.$apply();
-
- expect($log.error).toHaveBeenCalled();
- });
-
- it('should set isAdmin as true when adding app via the dropdown menu', ()=> {
- newCtrl.adminAppsRoles = [{id: 1, isAdmin: false},{id: 2, isAdmin: true}];
- //simulate UI change
- $rootScope.$apply('newAdmin.selectedNewApp = null');
- $rootScope.$apply('newAdmin.selectedNewApp = {id: 1, isAdmin: true}');
-
- expect(newCtrl.adminAppsRoles[0].isAdmin).toBe(true);
- expect(newCtrl.selectedNewApp).toBe(null);
- });
-
- it('should close the modal when updating apps roles succeeded', ()=> {
- $rootScope.closeThisDialog = () => {};
- spyOn($rootScope,'closeThisDialog');
-
- newCtrl.selectedUser = {orgUserId: 'orgUserId'};
- newCtrl.adminAppsRoles = [{id: 1}];
-
- deferredUpdateRolesRes.resolve();
- newCtrl.updateAdminAppsRoles();
- $rootScope.$apply();
-
- expect(adminsServiceMock.updateAdminAppsRoles).toHaveBeenCalledWith({orgUserId: newCtrl.selectedUser.orgUserId, appsRoles: newCtrl.adminAppsRoles});
- expect($rootScope.closeThisDialog).toHaveBeenCalled();
- });
- it('should log the error when updating apps roles fails', ()=> {
- newCtrl.selectedUser = {orgUserId: 'orgUserId'};
- newCtrl.adminAppsRoles = [{id: 1}];
-
- spyOn($log,'error');
- deferredUpdateRolesRes.reject();
- newCtrl.updateAdminAppsRoles();
- $rootScope.$apply();
- expect($log.error).toHaveBeenCalled();
- });
-});
+/*-
+ * ================================================================================
+ * ECOMP Portal
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
+/**
+ * Created by nnaffar on 12/8/15.
+ */
+'use strict';
+
+describe('Controller: NewAdminCtrl ', () => {
+ beforeEach(module('ecompApp'));
+
+ //destroy $http default cache before starting to prevent the error 'default cache already exists'
+ beforeEach(inject((_CacheFactory_)=> {
+ _CacheFactory_.destroyAll();
+ }));
+
+
+ let newCtrl, $controller, $q, $rootScope, $log;
+
+ beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
+ [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
+ }));
+
+ let deferredAdminAppsRoles, deferredUpdateRolesRes;
+ let adminsServiceMock;
+ beforeEach(()=> {
+ [deferredAdminAppsRoles, deferredUpdateRolesRes] = [$q.defer(), $q.defer()];
+
+ adminsServiceMock = jasmine.createSpyObj('adminsServiceMock', ['getAdminAppsRoles', 'updateAdminAppsRoles']);
+
+ adminsServiceMock.getAdminAppsRoles.and.returnValue(deferredAdminAppsRoles.promise);
+ adminsServiceMock.updateAdminAppsRoles.and.returnValue(deferredUpdateRolesRes.promise);
+
+ newCtrl = $controller('NewAdminModalCtrl', {
+ $log: $log,
+ adminsService: adminsServiceMock,
+ $scope: $rootScope
+ });
+ });
+
+ it('should init default values when loading the controller', ()=> {
+ expect(newCtrl.dialogState).toBe(1);
+ expect(newCtrl.selectedUser).toBe(null);
+ });
+
+ it('should populate admin apps roles and move to the next screen when adminsService.getAdminAppsRoles succeeded', ()=> {
+ let userApps = {appsRoles: [{id: 1, isAdmin: false}, {id: 2, isAdmin: true}]};
+ deferredAdminAppsRoles.resolve(userApps);
+
+ newCtrl.selectedUser = {orgUserId: 'orgUserId'};
+
+ newCtrl.getAdminAppsRoles();
+ $rootScope.$apply();
+
+ expect(adminsServiceMock.getAdminAppsRoles).toHaveBeenCalledWith(newCtrl.selectedUser.orgUserId);
+ expect(newCtrl.adminAppsRoles).toEqual(userApps.appsRoles);
+ expect(newCtrl.dialogState).toBe(2);
+ });
+
+ it('should log the error when adminsService.getAdminAppsRoles fails', ()=> {
+ spyOn($log, 'error');
+ deferredAdminAppsRoles.reject('some error');
+
+ newCtrl.searchUsersInProgress = false;
+ newCtrl.selectedUser = {orgUserId: 'orgUserId'};
+
+ newCtrl.getAdminAppsRoles();
+ $rootScope.$apply();
+
+ expect($log.error).toHaveBeenCalled();
+ });
+ it('should log the error when trying to getAdminAppsRoles without selecting user ', ()=> {
+ spyOn($log, 'error');
+
+ newCtrl.searchUsersInProgress = false;
+ newCtrl.selectedUser = null;
+
+ newCtrl.getAdminAppsRoles();
+ $rootScope.$apply();
+
+ expect($log.error).toHaveBeenCalled();
+ });
+
+ it('should set isAdmin as true when adding app via the dropdown menu', ()=> {
+ newCtrl.adminAppsRoles = [{id: 1, isAdmin: false},{id: 2, isAdmin: true}];
+ //simulate UI change
+ $rootScope.$apply('newAdmin.selectedNewApp = null');
+ $rootScope.$apply('newAdmin.selectedNewApp = {id: 1, isAdmin: true}');
+
+ expect(newCtrl.adminAppsRoles[0].isAdmin).toBe(true);
+ expect(newCtrl.selectedNewApp).toBe(null);
+ });
+
+ it('should close the modal when updating apps roles succeeded', ()=> {
+ $rootScope.closeThisDialog = () => {};
+ spyOn($rootScope,'closeThisDialog');
+
+ newCtrl.selectedUser = {orgUserId: 'orgUserId'};
+ newCtrl.adminAppsRoles = [{id: 1}];
+
+ deferredUpdateRolesRes.resolve();
+ newCtrl.updateAdminAppsRoles();
+ $rootScope.$apply();
+
+ expect(adminsServiceMock.updateAdminAppsRoles).toHaveBeenCalledWith({orgUserId: newCtrl.selectedUser.orgUserId, appsRoles: newCtrl.adminAppsRoles});
+ expect($rootScope.closeThisDialog).toHaveBeenCalled();
+ });
+ it('should log the error when updating apps roles fails', ()=> {
+ newCtrl.selectedUser = {orgUserId: 'orgUserId'};
+ newCtrl.adminAppsRoles = [{id: 1}];
+
+ spyOn($log,'error');
+ deferredUpdateRolesRes.reject();
+ newCtrl.updateAdminAppsRoles();
+ $rootScope.$apply();
+ expect($log.error).toHaveBeenCalled();
+ });
+});
diff --git a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.html b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.html
index 1b1b9de8..a18b8f60 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.html
+++ b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.html
@@ -31,8 +31,7 @@
<button id="search-users-button-cancel" class="btn btn-alt btn-small" ng-click="closeThisDialog()">Cancel</button>
</div>
</div>
-
-
+ <br>
<div id="div-admin-app-roles" class="admin-app-roles" ng-show="newAdmin.dialogState===2">
<div class="title" id="title"
ng-bind="newAdmin.selectedUser.firstName + ' ' + newAdmin.selectedUser.lastName + ' (' + newAdmin.selectedUser.orgUserId + ')'"></div>
@@ -43,16 +42,14 @@
</div>
- <div class="select-input custom-select-wrap">
- <select class="new-administrated-app" id="dropdown-select-app"
- ui-select2 ng-model="newAdmin.selectedNewApp"
- data-placeholder="Select application"
- ng-options="app as app.appName for app in (filteredApps = (newAdmin.adminAppsRoles | filter:{isAdmin:'false'})) track by app.id "
- ng-disabled="!filteredApps.length">
- <option id="option-select-app" value="" disabled style="display: none;">Select application</option>
- </select>
+ <div class="adminAppsRoles_dropdown">
+ <select id="dropdown1" name="dropdown1" b2b-dropdown
+ placeholder-text="Select application"
+ ng-model="newAdmin.selectedNewApp.value">
+ <option b2b-dropdown-list option-repeat="app in (filteredApps = (newAdmin.adminAppsRoles | filter:{isAdmin:'false'})) track by app.id " ng-disabled="!filteredApps.length" value="{{app}}">{{app.appName}}</option>
+ </select>
</div>
-
+ <br>
<div class="admin-roles-list">
<div ng-repeat="app in (newAdmin.adminAppsRoles | orderBy:newAdmin.orderFilter) track by app.id" ng-show="app.isAdmin">
@@ -75,3 +72,9 @@
</div>
</div>
+
+<script>
+$(document).ready(function(){
+ $(".ngdialog-close").attr('id','dialog-close');
+});
+</script>
diff --git a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.less b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.less
index 8b304b43..f7c1111d 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.less
+++ b/ecomp-portal-FE-common/client/app/views/admins/add-admin-dialogs/new-admin.modal.less
@@ -47,7 +47,7 @@
}
.admin-roles-list {
- height: 240px;
+ height: 185px;
overflow-y: auto;
}
@@ -73,6 +73,10 @@
color: transparent;
margin-left: 8px;
}
+
+ .awd-select-list {
+ max-height: 205px;
+ }
}
diff --git a/ecomp-portal-FE-common/client/app/views/admins/admins.controller.spec.js b/ecomp-portal-FE-common/client/app/views/admins/admins.controller.spec.js
index 3841a2b3..32cc3a1f 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/admins.controller.spec.js
+++ b/ecomp-portal-FE-common/client/app/views/admins/admins.controller.spec.js
@@ -1,19 +1,19 @@
-/*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ================================================================================
- */
+/*-
+ * ================================================================================
+ * ECOMP Portal
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ================================================================================
+ */
diff --git a/ecomp-portal-FE-common/client/app/views/admins/admins.less b/ecomp-portal-FE-common/client/app/views/admins/admins.less
index 729ef693..38760ca3 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/admins.less
+++ b/ecomp-portal-FE-common/client/app/views/admins/admins.less
@@ -1,6 +1,7 @@
.w-ecomp-admins-page-main {
+
.bg_portalWhite;//white for 1702
- position: @page-main-position;
+ position: @page-main-position;
top: @page-main-top;
left: @page-main-left;
right: @page-main-right;
@@ -8,38 +9,42 @@
padding-top: @padding-top;
overflow-y: @page-main-overflow-y;
padding-left: @padding-left-side;
-#input-table-search::-webkit-input-placeholder,
-{
-font-style: italic;
- color: #D7D7D7;
-
-}
+ #input-table-search::-webkit-input-placeholder,
+ {
+ font-style: italic;
+ color: #D7D7D7;
+
+ }
.ecomp-spinner{
top: 255px;
}
+ .table-admins-div{
+ width:15px;
+ font-size:23px;
+ cursor: pointer;
+ }
.admins-home-container {
- position: relative;
- padding-right: 0;
- padding-left: 0;
- padding-bottom: @container-bottom;
+ position: relative;
+ padding-right: 0;
+ padding-left: 0;
+ padding-bottom: @container-bottom;
- .admins-table {
- width: @table-width;
- //margin-left: @table-margin-left;
- margin: 0 auto;
+ .admins-table {
+ width: @table-width;
+ //margin-left: @table-margin-left;
+ margin: 0 auto;
- .table-control {
- .table-dropdown-filter {
- width: @table-dropdown-filter-width;
- display: @table-dropdown-filter-display;
- }
- }
+ .table-control {
+ .table-dropdown-filter {
+ width: @table-dropdown-filter-width;
+ display: @table-dropdown-filter-display;
+ }
+ }
- .table-body {
- cursor: pointer;
- }
- }
+ .table-body {
+ cursor: pointer;
+ }
+ }
}
}
-
diff --git a/ecomp-portal-FE-common/client/app/views/admins/admins.tpl.html b/ecomp-portal-FE-common/client/app/views/admins/admins.tpl.html
index 907bf323..f9ea3ff9 100644
--- a/ecomp-portal-FE-common/client/app/views/admins/admins.tpl.html
+++ b/ecomp-portal-FE-common/client/app/views/admins/admins.tpl.html
@@ -1,66 +1,66 @@
-<!--
- ================================================================================
- ECOMP Portal
- ================================================================================
- Copyright (C) 2017 AT&T Intellectual Property
- ================================================================================
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- ================================================================================
- -->
-<div class="w-ecomp-admins-page-main">
- <div class="admins-home-container" id="page-content">
- <div id="title" class="w-ecomp-main-view-title">
- <h1 class="heading-page" >Admins</h1>
- </div>
- <div class="admins-table">
- <div class="table-control">
- <div class="table-control-fields">
- <div class="table-dropdown">
- <select id="dropdown1" name="dropdown1" b2b-dropdown placeholder-text="All application" ng-model="admins.filterByApp.value">
- <option b2b-dropdown-list option-repeat="d in admins.availableApps" value="{{d.value}}">{{d.title}}</option>
- </select>
- </div>
- <div >
- <input id="input-table-search" placeholder="Search in entire table" class="table-search-field" type="text" data-ng-model="admins.searchString">
- </div>
- <button class="btn btn-alt btn-small" ng-click="admins.openAddNewAdminModal()"><i class="icon-people-userbookmark" aria-hidden="true"></i>&nbsp;Add Admin</button>
- </div>
- </div>
- <span class="ecomp-spinner" ng-show="admins.isLoadingTable"></span>
- <div b2b-table table-data="admins.adminsTableData" ng-hide="admins.isLoadingTable" search-string="admins.searchString" class="b2b-table-div">
- <table>
- <thead b2b-table-row type="header">
- <tr >
- <th b2b-table-header key="firstName" sortable="true" id="col1">First Name</th>
- <th b2b-table-header key="lastName" sortable="true" id="col2">Last Name</th>
- <th b2b-table-header key="orgUserId" sortable="true" id="col3">User ID</th>
- <th b2b-table-header key="" sortable="falses" id="col4">Applications</th>
- </tr>
- </thead>
- <tbody b2b-table-row type="body" row-repeat="rowData in admins.adminsTableData | filter: admins.portalsRowFilter">
- <tr ng-click="admins.openAddNewAdminModal(rowData)">
- <td b2b-table-body id="rowheader_t1_{{$index}}" headers="col1" ng-bind="rowData.firstName"></td>
- <td b2b-table-body headers="rowheader_t1_{{$index}} col2" ng-bind="rowData.lastName"></td>
- <td b2b-table-body headers="rowheader_t1_{{$index}} col3" ng-bind="rowData.orgUserId"></td>
- <td b2b-table-body headers="rowheader_t1_{{$index}} col4">
- <div class="ecomp-table-repeat" ng-repeat="app in rowData.apps" ng-bind="app.appName"></div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </div>
- </div>
-
-</div>
+<!--
+ ================================================================================
+ ECOMP Portal
+ ================================================================================
+ Copyright (C) 2017 AT&T Intellectual Property
+ ================================================================================
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ ================================================================================
+ -->
+<div class="w-ecomp-admins-page-main">
+ <div class="admins-home-container" id="page-content">
+ <div id="title" class="w-ecomp-main-view-title">
+ <h1 class="heading-page" >Admins</h1>
+ </div>
+ <div class="admins-table">
+ <div class="table-control">
+ <div class="table-control-fields">
+ <div class="table-dropdown">
+ <select id="dropdown1" name="dropdown1" b2b-dropdown placeholder-text="All application" ng-model="admins.filterByApp.value">
+ <option b2b-dropdown-list option-repeat="d in admins.availableApps" value="{{d.value}}">{{d.title}}</option>
+ </select>
+ </div>
+ <div >
+ <input id="input-table-search" placeholder="Search in entire table" class="table-search-field" type="text" data-ng-model="admins.searchString">
+ </div>
+ <button class="btn btn-alt btn-small" ng-click="admins.openAddNewAdminModal()"><i class="icon-people-userbookmark" aria-hidden="true"></i>&nbsp;Add Admin</button>
+ </div>
+ </div>
+ <span class="ecomp-spinner" ng-show="admins.isLoadingTable"></span>
+ <div b2b-table table-data="admins.adminsTableData" ng-hide="admins.isLoadingTable" search-string="admins.searchString" class="b2b-table-div">
+ <table>
+ <thead b2b-table-row type="header">
+ <tr >
+ <th b2b-table-header key="firstName" sortable="true" id="col1" default-sort="a">First Name</th>
+ <th b2b-table-header key="lastName" sortable="true" id="col2">Last Name</th>
+ <th b2b-table-header key="orgUserId" sortable="true" id="col3">User ID</th>
+ <th b2b-table-header key="" sortable="falses" id="col4">Applications</th>
+ </tr>
+ </thead>
+ <tbody b2b-table-row type="body" row-repeat="rowData in admins.adminsTableData | filter: admins.portalsRowFilter" class="table-admins-div">
+ <tr ng-click="admins.openAddNewAdminModal(rowData)" >
+ <td b2b-table-body id="rowheader_t1_{{$index}}" headers="col1" ng-bind="rowData.firstName"></td>
+ <td b2b-table-body headers="rowheader_t1_{{$index}} col2" ng-bind="rowData.lastName"></td>
+ <td b2b-table-body headers="rowheader_t1_{{$index}} col3" ng-bind="rowData.orgUserId"></td>
+ <td b2b-table-body headers="rowheader_t1_{{$index}} col4">
+ <div class="ecomp-table-repeat" ng-repeat="app in rowData.apps" ng-bind="app.appName"></div>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ </div>
+ </div>
+
+</div>