a801eaa536f26347c14e78a23f7edad54c485942
[portal.git] / ecomp-portal-FE-common / client / app / services / userbar / userbar.update.service.js
1 /*-
2  * ============LICENSE_START==========================================
3  * ONAP Portal
4  * ===================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ===================================================================
7  *
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
12  *
13  *             http://www.apache.org/licenses/LICENSE-2.0
14  *
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.
20  *
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
25  *
26  *             https://creativecommons.org/licenses/by/4.0/
27  *
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.
33  *
34  * ============LICENSE_END============================================
35  *
36  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
37  */
38 'use strict';
39
40 (function () {
41     class userbarUpdateService {
42         constructor($q, $log, $http, conf, uuid) {
43             this.$q = $q;
44             this.$log = $log;
45             this.$http = $http;
46             this.conf = conf;
47             this.uuid = uuid;
48             this.refreshCount = 0;
49             this.maxCount = 0;
50         }
51     
52         getRefreshCount() {
53             return this.refreshCount;
54         }
55         setRefreshCount(count){
56             this.refreshCount = count;
57         }
58         setMaxRefreshCount(count){
59             this.maxCount = count;
60         }
61         decrementRefreshCount(){
62             this.refreshCount = this.refreshCount - 1;
63         }
64
65         getWidthThresholdLeftMenu() {
66             let deferred = this.$q.defer();
67             this.$log.info('userbarUpdateService::getWidthThresholdLeftMenu');
68             this.$http({
69                     url: this.conf.api.getWidthThresholdLeftMenu,
70                     method: 'GET',
71                     cache: false,
72                     headers: {
73                         'X-ECOMP-RequestID':this.uuid.generate()
74                     }
75                 }).then(res => {
76                     if (Object.keys(res.data).length == 0) {
77                         deferred.reject("userbarUpdateService::getWidthThresholdLeftMenu Failed");
78                     } else {
79                         deferred.resolve(res.data);
80                     }
81                 })
82                 .catch(status => {
83                     deferred.reject(status);
84                 });
85             return deferred.promise;
86         }
87         
88         getWidthThresholdRightMenu() {
89             let deferred = this.$q.defer();
90             this.$log.info('userbarUpdateService::getWidthThresholdRightMenu');
91             this.$http({
92                     url: this.conf.api.getWidthThresholdRightMenu,
93                     method: 'GET',
94                     cache: false,
95                     headers: {
96                         'X-ECOMP-RequestID':this.uuid.generate()
97                     }
98                 }).then(res => {
99                     if (Object.keys(res.data).length == 0) {
100                         deferred.reject("userbarUpdateService::getWidthThresholdRightMenu Failed");
101                     } else {
102                         deferred.resolve(res.data);
103                     }
104                 })
105                 .catch(status => {
106                     deferred.reject(status);
107                 });
108             return deferred.promise;
109         }
110
111
112     }
113     userbarUpdateService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4'];
114     angular.module('ecompApp').service('userbarUpdateService', userbarUpdateService)
115 })();