[PORTAL-7] Rebase
[portal.git] / ecomp-portal-FE-common / client / app / services / userbar / userbar.update.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 'use strict';
21
22 (function () {
23     class userbarUpdateService {
24         constructor($q, $log, $http, conf, uuid) {
25             this.$q = $q;
26             this.$log = $log;
27             this.$http = $http;
28             this.conf = conf;
29             this.uuid = uuid;
30             this.refreshCount = 0;
31             this.maxCount = 0;
32         }
33     
34         getRefreshCount() {
35             return this.refreshCount;
36         }
37         setRefreshCount(count){
38             this.refreshCount = count;
39         }
40         setMaxRefreshCount(count){
41             this.maxCount = count;
42         }
43         decrementRefreshCount(){
44             this.refreshCount = this.refreshCount - 1;
45         }
46
47         getWidthThresholdLeftMenu() {
48             let deferred = this.$q.defer();
49             this.$log.info('userbarUpdateService::getWidthThresholdLeftMenu');
50             this.$http({
51                     url: this.conf.api.getWidthThresholdLeftMenu,
52                     method: 'GET',
53                     cache: false,
54                     headers: {
55                         'X-ECOMP-RequestID':this.uuid.generate()
56                     }
57                 }).then(res => {
58                     if (Object.keys(res.data).length == 0) {
59                         deferred.reject("userbarUpdateService::getWidthThresholdLeftMenu Failed");
60                     } else {
61                         deferred.resolve(res.data);
62                     }
63                 })
64                 .catch(status => {
65                     deferred.reject(status);
66                 });
67             return deferred.promise;
68         }
69         
70         getWidthThresholdRightMenu() {
71             let deferred = this.$q.defer();
72             this.$log.info('userbarUpdateService::getWidthThresholdRightMenu');
73             this.$http({
74                     url: this.conf.api.getWidthThresholdRightMenu,
75                     method: 'GET',
76                     cache: false,
77                     headers: {
78                         'X-ECOMP-RequestID':this.uuid.generate()
79                     }
80                 }).then(res => {
81                     if (Object.keys(res.data).length == 0) {
82                         deferred.reject("userbarUpdateService::getWidthThresholdRightMenu Failed");
83                     } else {
84                         deferred.resolve(res.data);
85                     }
86                 })
87                 .catch(status => {
88                     deferred.reject(status);
89                 });
90             return deferred.promise;
91         }
92
93
94     }
95     userbarUpdateService.$inject = ['$q', '$log', '$http', 'conf', 'uuid4'];
96     angular.module('ecompApp').service('userbarUpdateService', userbarUpdateService)
97 })();