Security/ Package Name changes
[portal.git] / ecomp-portal-FE-common / client / app / services / confirm-box / confirm-box.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 /**
39  * Created by nnaffar on 1/18/16.
40  */
41 'use strict';
42
43 (function () {
44     class ConfirmBoxService {
45         constructor($q, $log, ngDialog,$modal) {
46             this.$q = $q;
47             this.$log = $log;
48             this.ngDialog = ngDialog;
49             this.$modal = $modal;
50         }
51         reloadPageConfirm(msg){
52                 let deferred = this.$q.defer();
53                 var modalInstance = this.$modal.open({
54                   templateUrl: 'app/views/confirmation-box/reload-page-confirm.html',
55                   controller: 'ConfirmationBoxCtrl',
56                   sizeClass:'modal-small',
57                   resolve: {
58                       message: function message() {
59                           var message = {
60                               title:msg.title,
61                               content: msg.content
62                           };
63                           return message;
64                      }
65                   }
66               });
67                 modalInstance.result.then(function () {
68                         deferred.resolve();
69                 });  
70                 return deferred.promise;
71         }
72         showInformation(msg) {
73             let deferred = this.$q.defer();
74                 var modalInstance = this.$modal.open({
75                 templateUrl: 'app/views/confirmation-box/information-box.tpl.html',
76                 controller: 'ConfirmationBoxCtrl',
77                 sizeClass:'modal-small',
78                 resolve: {
79                     message: function message() {
80                         var message = {
81                             title:'',
82                             content: msg
83                         };
84                         return message;
85                     }
86                 }
87             });
88                 modalInstance.result.then(function () {
89                         deferred.resolve();
90                 });  
91                 return deferred.promise;
92         };
93         
94         editItem(msg) {
95                 let deferred = this.$q.defer();
96                 var modalInstance = this.$modal.open({
97                 templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html',
98                 controller: 'ConfirmationBoxCtrl',
99                 sizeClass:'modal-small',
100                 resolve: {
101                     message: function message() {
102                         var message = {
103                             title:'',
104                             content: msg
105                         };
106                         return message;
107                     }
108                 }
109             });
110             modalInstance.result.then(function (confirm) {
111                         if(confirm)
112                                 deferred.resolve(confirm);
113                         else
114                                 deferred.reject(confirm);
115                 });             
116                 return deferred.promise;
117         };
118        
119         
120         showDynamicInformation(msg, templatePath, controller) {
121                 let deferred = this.$q.defer();
122                 var modalInstance = this.$modal.open({
123                 templateUrl: templatePath,
124                 controller: controller,
125                 sizeClass:'modal-small',
126                 resolve: {
127                     message: function message() {
128                         var message = {
129                             title:'',
130                             content: msg
131                         };
132                         return message;
133                     }
134                 }
135             });
136                 modalInstance.result.then(function () {
137                         deferred.resolve();
138                 });  
139                 return deferred.promise;
140         };
141         
142         confirm(msg) {
143                 let deferred = this.$q.defer();
144                 var modalInstance = this.$modal.open({
145                 templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html',
146                 controller: 'ConfirmationBoxCtrl',
147                 sizeClass:'modal-small',
148                 resolve: {
149                     message: function message() {
150                         var message = {
151                             title:'',
152                             content: msg
153                         };
154                         return message;
155                     }
156                 }
157             });
158             modalInstance.result.then(function (confirm) {
159                         if(confirm)
160                                 deferred.resolve(confirm);
161                         else
162                                 deferred.reject(confirm);
163                 });             
164                 return deferred.promise;
165         };
166
167         deleteItem(item) {
168                 let deferred = this.$q.defer();
169                  var modalInstance = this.$modal.open({
170                 templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html',
171                 controller: 'ConfirmationBoxCtrl',
172                 sizeClass:'modal-small',
173                 resolve: {
174                     message: function message() {
175                         var message = {
176                                 item:'',                     
177                             title:'Confirmation',
178                             content: 'Are you sure you want to delete ' +item+ ' ?'
179                         };
180                         return message;
181                     }
182                 }
183             });          
184                 modalInstance.result.then(function (confirm) {
185                         if(confirm)
186                                 deferred.resolve(confirm);
187                         else
188                                 deferred.reject(confirm);
189                 });             
190                 return deferred.promise;
191         };
192
193         moveMenuItem(msg) {
194             let deferred = this.$q.defer();
195                 var modalInstance = this.$modal.open({
196                        templateUrl: 'app/views/confirmation-box/dragdrop-confirmation-box.tpl.html',
197                        controller: 'ConfirmationBoxCtrl',
198                        sizeClass:'modal-small',
199                        resolve: {
200                            message: function message() {
201                                var message = {
202                                 item:'',                     
203                                    title:'Functional Menu - Move',
204                                    content: msg
205                                };
206                                return message;
207                            }
208                        }
209                    });           
210                 modalInstance.result.then(function (confirm) {
211                         if(confirm)
212                                 deferred.resolve(confirm);
213                         else
214                                 deferred.reject(confirm);
215                 });             
216                 return deferred.promise;
217         };
218
219         makeAdminChanges(msg) {
220                 let deferred = this.$q.defer();
221                 var modalInstance = this.$modal.open({
222                        templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html',
223                        controller: 'ConfirmationBoxCtrl',
224                        sizeClass:'modal-small',
225                        resolve: {
226                            message: function message() {
227                                var message = {
228                                 item:'',                     
229                                    title:'Admin Update',
230                                    content: msg
231                                };
232                                return message;
233                            }
234                        }
235                    });           
236                 modalInstance.result.then(function (confirm) {
237                         if(confirm)
238                                 deferred.resolve(confirm);
239                         else
240                                 deferred.reject(confirm);
241                 });             
242                 return deferred.promise;
243         };
244         
245         
246         makeUserAppRoleCatalogChanges(msg) {
247                 let deferred = this.$q.defer();
248                 var modalInstance = this.$modal.open({
249                        templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html',
250                        controller: 'ConfirmationBoxCtrl',
251                        sizeClass:'modal-small',
252                        resolve: {
253                            message: function message() {
254                                var message = {
255                                 item:'',                     
256                                    title:'UserRoles Update',
257                                    content: msg
258                                };
259                                return message;
260                            }
261                        }
262                    });           
263                 modalInstance.result.then(function (confirm) {
264                         if(confirm)
265                                 deferred.resolve(confirm);
266                         else
267                                 deferred.reject(confirm);
268                 });             
269                 return deferred.promise;
270         };
271      
272         
273         webAnalyticsChanges(msg) {
274                 let deferred = this.$q.defer();
275                 var modalInstance = this.$modal.open({
276                        templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html',
277                        controller: 'ConfirmationBoxCtrl',
278                        sizeClass:'modal-small',
279                        resolve: {
280                            message: function message() {
281                                var message = {
282                                 item:'',                     
283                                    title:'Add WebAnalytics Source',
284                                    content: msg
285                                };
286                                return message;
287                            }
288                        }
289                    });           
290                 modalInstance.result.then(function (confirm) {
291                         if(confirm)
292                                 deferred.resolve(confirm);
293                         else
294                                 deferred.reject(confirm);
295                 });             
296                 return deferred.promise;
297         };
298
299         
300         updateWebAnalyticsReport(msg) {
301             let deferred = this.$q.defer();
302                 var modalInstance = this.$modal.open({
303                        templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html',
304                        controller: 'ConfirmationBoxCtrl',
305                        sizeClass:'modal-small',
306                        resolve: {
307                            message: function message() {
308                                var message = {
309                                 item:'',                     
310                                    title:'Update WebAnalytics Source',
311                                    content: msg
312                                };
313                                return message;
314                            }
315                        }
316                    });           
317                 modalInstance.result.then(function (confirm) {
318                         if(confirm)
319                                 deferred.resolve(confirm);
320                         else
321                                 deferred.reject(confirm);
322                 });             
323                 return deferred.promise;
324         };
325
326     }
327     ConfirmBoxService.$inject = ['$q', '$log', 'ngDialog','$modal'];
328     angular.module('ecompApp').service('confirmBoxService', ConfirmBoxService)
329 })();