nexus site path corrected
[portal.git] / ecomp-portal-FE / client / app / views / support / get-access / get-access.controller.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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  * ================================================================================
19  */
20 'use strict';
21 (function () {
22     class GetAccessCtrl {
23         constructor($log,  $stateParams, getAccessService,applicationsService, ngDialog) {
24                 // $log.debug('GetAccessCtrl: appService param is: ' + applicationsService.goGetAccessAppName);
25
26                 this.updateAppsList = () => {
27                 getAccessService.getListOfApp().then(res=> {
28                         var tableData=[];
29                         // $log.info('GetAccessCtrl::updateAppsList: getting res');
30                         var result = (typeof(res.data) != "undefined" && res.data!=null)?res.data:null;
31                         // $log.info('GetAccessCtrl::updateAppsList: result',result);
32                         // $log.info('GetAccessCtrl::updateAppsList: done');
33                         var source = result;
34                         // $log.info('GetAccessCtrl::updateAppsList source: ', source);
35                         for(var i=0;i<source.length; i++){
36                                 var dataArr = source[i];
37                         var dataTemp={
38                                 ecomp_function: dataArr.ecompFunction,
39                                 app_name:dataArr.appName,
40                                 role_name:dataArr.roleName
41                         }
42                         tableData.push(dataTemp);
43                         }               
44                         this.appTable=tableData;
45                         
46                         if( $stateParams.appName != null)
47                                 this.searchString = $stateParams.appName;
48                         else
49                                 this.searchString = applicationsService.goGetAccessAppName;
50                         // the parameter has been used; clear the value.
51                         applicationsService.goGetAccessAppName = '';
52                 }).catch(err=> {
53                     $log.error('GetAccessCtrl:error:: ', err);
54                 }).finally(() => {
55                     this.isLoadingTable = false;
56                 });
57             };
58                 let init = () => {
59                 // $log.info('GetAccessCtrl:: initializing...');
60                 this.searchString = '';
61                 this.getAccessTableHeaders = ['ECOMP Function', 'Application Name', 'Role Name'];
62                 this.appTable=[];
63                 this.updateAppsList();
64             };
65             init();
66         }
67     }
68     GetAccessCtrl.$inject = ['$log', '$stateParams', 'getAccessService', 'applicationsService', 'ngDialog'];
69     angular.module('ecompApp').controller('GetAccessCtrl', GetAccessCtrl);
70 })();