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 * ================================================================================
23 class PortalAdminsService {
24 constructor($q, $log, $http, conf, uuid, utilsService) {
30 this.utilsService = utilsService;
34 let deferred = this.$q.defer();
35 this.$log.info('PortalAdminsService::get all portal admins list');
37 url: this.conf.api.portalAdmins,
41 'X-ECOMP-RequestID':this.uuid.generate()
44 // If response comes back as a redirected HTML page which IS NOT a success
45 if (this.utilsService.isValidJSON(res)== false) {
46 deferred.reject('PortalAdminsService::getPortalAdmins Failed');
48 deferred.resolve(res.data);
52 deferred.reject(status);
54 return deferred.promise;
57 addPortalAdmin(userData) {
58 let deferred = this.$q.defer();
59 this.$log.info('PortalAdminsService::addPortalAdmin: ' + JSON.stringify(userData));
61 url: this.conf.api.portalAdmin,
65 'X-ECOMP-RequestID':this.uuid.generate()
69 // If response comes back as a redirected HTML page which IS NOT a success
70 this.$log.debug('PortalAdminsService:: this.conf.api.portalAdmin: ' + JSON.stringify(res));
71 if (this.utilsService.isValidJSON(res)== false) {
72 deferred.reject('PortalAdminsService::addPortalAdmin Failed');
74 deferred.resolve(res.data);
78 this.$log.debug('PortalAdminsService:: this.conf.api.portalAdmin: ' + JSON.stringify(errRes));
79 deferred.reject(errRes);
81 return deferred.promise;
84 removePortalAdmin(userId,orUserId) {
85 let deferred = this.$q.defer();
86 let userInfo = userId+"-"+orUserId;
87 let url = this.conf.api.portalAdmin + '/' + userInfo;
88 this.$log.info('PortalAdminsService:: remove Portal Admin');
94 'X-ECOMP-RequestID':this.uuid.generate()
97 // If response comes back as a redirected HTML page which IS NOT a success
98 if (this.utilsService.isValidJSON(res)== false) {
99 deferred.reject('PortalAdminsService::removePortalAdmin Failed');
101 deferred.resolve(res.data);
104 deferred.reject(errRes);
107 return deferred.promise;
110 PortalAdminsService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4', 'utilsService'];
111 angular.module('ecompApp').service('portalAdminsService', PortalAdminsService)