nexus site path corrected
[portal.git] / ecomp-portal-FE / client / app / services / support / getAccess / get-access.service.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
21 'use strict';
22
23 (function () {
24     class GetAccessService {
25         constructor($q, $log, $http, conf,uuid) {
26             this.$q = $q;
27             this.$log = $log;
28             this.$http = $http;
29             this.conf = conf;
30             this.uuid = uuid;
31         }
32         getListOfApp(searchStr) {
33             //this.$log.info('GetAccessService::getListOfApp: get all app list');
34             let deferred = this.$q.defer();
35             //this.$log.info('GetAccessService::getListOfApp: searchStr', searchStr);
36             //this.$log.info('GetAccessService::getListOfApp: ', this.conf.api.listOfApp);
37             this.$http({
38                 method: "GET",
39                 url: this.conf.api.listOfApp,
40                 params: {search:searchStr},
41                 cache: false
42             }).then( res => {
43                 // this.$log.info('GetAccessService::getListOfApp response: ', res);
44                 if (Object.keys(res).length == 0) {
45                     deferred.reject("GetAccessService::getListOfApp: Failed");
46                 } else {
47                     // this.$log.debug('GetAccessService::getListOfApp: query results: ', res);
48                     // this.$log.info('GetAccessService::getListOfApp Succeeded');
49                     deferred.resolve(res);
50                 }
51             }).catch( status => {
52                 this.$log.error('GetAccessService::getListOfApp: query error: ',status);
53                 deferred.reject(status);
54             });
55             return deferred.promise;           
56         }
57
58     }
59     GetAccessService.$inject = ['$q', '$log', '$http', 'conf','uuid4'];
60     angular.module('ecompApp').service('getAccessService', GetAccessService)
61 })();