2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
41 constructor($log, $scope, $stateParams, filterFilter, getAccessService, userProfileService, ExternalRequestAccessService, applicationsService, ngDialog) {
42 // $log.debug('GetAccessCtrl: appService param is: ' + applicationsService.goGetAccessAppName);
43 var resultAccessValue = null;
45 $scope.openAppRoleModal = (itemData) => {
46 if(resultAccessValue){
51 orgUserId: $scope.orgUserId,
52 firstName: $scope.firstName,
53 lastName: $scope.lastName,
54 headerText: itemData.app_name,
58 templateUrl: 'app/views/catalog/request-access-catalog-dialogs/request-access-catalog.modal.html',
59 controller: 'ExternalRequestAccessCtrl',
60 controllerAs: 'userInfo',
66 $scope.$watch('access.searchString', function (searchKey) {
67 var search = searchKey;
68 this.totalPage = filterFilter($scope.access.appTable, search);
69 var resultLen = this.totalPage.length;
70 $scope.access.totalPage = Math.ceil(resultLen/$scope.access.viewPerPage);
71 $scope.access.currentPage = 1;
74 userProfileService.getUserProfile().then(
76 $scope.orgUserId = profile.orgUserId;
77 $scope.firstName = profile.firstName;
78 $scope.lastName = profile.lastName;
81 this.updateAppsList = () => {
82 ExternalRequestAccessService.getExternalRequestAccessServiceInfo().then(
84 resultAccessValue = property.accessValue;
86 $log.error('GetAccessCtrl: failed getExternalRequestAccessServiceInfo: ' + JSON.Stringify(err));
88 getAccessService.getListOfApp().then(res=> {
90 // $log.info('GetAccessCtrl::updateAppsList: getting res');
91 var result = (typeof(res.data) != "undefined" && res.data!=null)?res.data:null;
92 // $log.info('GetAccessCtrl::updateAppsList: result',result);
93 // $log.info('GetAccessCtrl::updateAppsList: done');
95 // $log.info('GetAccessCtrl::updateAppsList source: ', source);
96 for(var i=0;i<source.length; i++){
97 var dataArr = source[i];
98 var checkEcompFuncAvail = 'Function Not Available' ;
99 var reqStatus = 'Pending';
100 dataArr.ecompFunction = (dataArr.ecompFunction === null) ? checkEcompFuncAvail : dataArr.ecompFunction;
101 dataArr.reqType = (dataArr.reqType === 'P') ? reqStatus : dataArr.reqType;
103 ecomp_function: dataArr.ecompFunction,
104 app_name:dataArr.appName,
105 role_name:dataArr.roleName,
106 current_role:dataArr.roleActive,
107 request_type:dataArr.reqType
109 tableData.push(dataTemp);
111 this.appTable=tableData;
113 var len = tableData.length;
114 this.totalPage = Math.ceil(len/this.viewPerPage);
116 if( $stateParams.appName != null)
117 this.searchString = $stateParams.appName;
119 this.searchString = applicationsService.goGetAccessAppName;
120 // the parameter has been used; clear the value.
121 applicationsService.goGetAccessAppName = '';
123 $log.error('GetAccessCtrl:error:: ', err);
125 this.isLoadingTable = false;
129 this.updateTable = (num) => {
130 this.startIndex=this.viewPerPage*(num-1);
131 this.currentPage = num;
134 // $log.info('GetAccessCtrl:: initializing...');
135 this.searchString = '';
136 this.getAccessTableHeaders = ['Function', 'Application Name', 'Role Name', 'Current Role', 'Request Status'];
138 this.updateAppsList();
141 this.currentPage = 1;
147 GetAccessCtrl.$inject = ['$log', '$scope', '$stateParams', 'filterFilter', 'getAccessService', 'userProfileService', 'ExternalRequestAccessService','applicationsService', 'ngDialog'];
148 angular.module('ecompApp').controller('GetAccessCtrl', GetAccessCtrl);