2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
22 class PortalAdminsCtrl {
23 constructor($log, portalAdminsService, ngDialog, confirmBoxService) {
25 let updateTableData = () => {
26 this.isLoadingTable = true;
27 portalAdminsService.getPortalAdmins().then(result=> {
28 $log.debug('PortalAdminsCtrl::updateTableData: result: ' + JSON.stringify(result));
29 if (!result || !result.length) {
30 $log.info('PortalAdminsCtrl::updateTableData: no Portal Admins err handling');
31 this.portalAdminsTableData = [];
34 this.portalAdminsTableData = result;
36 $log.error('PortalAdminsCtrl::updateTableData error :',err);
38 this.isLoadingTable = false;
43 $log.info('portalAdminsService.getPortalAdmins::initializing...');
44 this.isLoadingTable = false;
46 this.searchString= '';
47 this.portalAdminsTableHeaders = ['First Name', 'Last Name', 'User ID', 'Delete'];
48 this.portalAdminsTableData = [];
54 this.removePortalAdmin = pAdmin => {
55 $log.debug('pAdmin = ' + JSON.stringify(pAdmin));
56 confirmBoxService.deleteItem(pAdmin.firstName + ' ' + pAdmin.lastName )
57 .then(isConfirmed => {
59 if(!pAdmin || !pAdmin.userId){
60 $log.error('PortalAdminsCtrl::removePortalAdmin No portal admin or ID... cannot delete');
63 portalAdminsService.removePortalAdmin(pAdmin.userId).then(() => {
64 $log.info("PortalAdminsCtrl::removePortalAdmin removed admin");
67 $log.error('PortalAdminsCtrl::removePortalAdmin.deleteItem error: '+ err);
71 $log.error('PortalAdminsCtrl::removePortalAdmin.deleteItem error: '+ err);
75 this.openAddNewPortalAdminModal = (user) => {
81 userId: user.orgUserId,
82 firstName: user.firstName,
83 lastName: user.lastName
88 templateUrl: 'app/views/portal-admin/new-portal-admin/new-portal-admin.modal.html',
89 controller: 'NewPortalAdminModalCtrl',
90 controllerAs: 'newPortalAdmin',
92 }).closePromise.then(needUpdate => {
93 if(needUpdate.value === true){
94 $log.debug('PortalAdminsCtrl::openAddNewPortalAdminModal: updating Portal Admin table data...');
100 this.openEditUserModal = (loginId) => {
103 updateRemoteApp : false,
104 appId : this.selectedApp!=null?this.selectedApp.id:''
106 var modalInstance = ngDialog.open({
107 templateUrl: 'app/views/header/user-edit/edit-user.tpl.html',
108 controller: 'editUserController',
111 message: function message() {
118 }).closePromise.then(needUpdate => {
125 PortalAdminsCtrl.$inject = ['$log', 'portalAdminsService', 'ngDialog', 'confirmBoxService'];
126 angular.module('ecompApp').controller('PortalAdminsCtrl', PortalAdminsCtrl);