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 CatalogService {
25 constructor($q, $log, $http, conf, uuid) {
34 let deferred = this.$q.defer();
38 url: this.conf.api.appCatalog,
41 'X-ECOMP-RequestID':this.uuid.generate()
46 if (res == null || res.data == null) {
47 deferred.reject("CatalogService::getAppCatalog Failed");
49 deferred.resolve(res.data);
53 this.$log.error('CatalogService:getAppCatalog failed: ' + status);
54 deferred.reject(status);
56 return deferred.promise;
59 // Expects an object with fields matching model class AppCatalogSelection:
60 // appId (number), select (boolean), pending (boolean).
61 updateAppCatalog(appData) {
62 let deferred = this.$q.defer();
63 // Validate the request, maybe this is overkill
64 if (appData == null || appData.appId == null || appData.select == null) {
65 var msg = 'CatalogService::updateAppCatalog: field appId and/or select not found';
67 return deferred.reject(msg);
71 url: this.conf.api.appCatalog,
74 'X-ECOMP-RequestID':this.uuid.generate()
78 if (res == null || res.data == null) {
79 deferred.reject("CatalogService::updateAppCatalog Failed");
81 deferred.resolve(res.data);
85 this.$log.error('CatalogService:updateAppCatalog failed: ' + status);
86 deferred.reject(status);
88 return deferred.promise;
93 CatalogService.$inject = ['$q', '$log', '$http', 'conf','uuid4'];
94 angular.module('ecompApp').service('catalogService', CatalogService)