nexus site path corrected
[portal.git] / ecomp-portal-FE / client / app / services / confirm-box / confirm-box.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
21 'use strict';
22
23 (function () {
24     class ConfirmBoxService {
25         constructor($q, $log, ngDialog) {
26             this.$q = $q;
27             this.$log = $log;
28             this.ngDialog = ngDialog;
29         }
30
31         showInformation(message) {
32             let deferred = this.$q.defer();
33             this.ngDialog.open({
34                 templateUrl: 'app/views/confirmation-box/information-box.tpl.html',
35                 controller: 'ConfirmationBoxCtrl',
36                 controllerAs: 'confirmBox',
37                 className: 'confirm-box ngdialog-theme-default',
38                 showClose: false,
39                 data: {
40                     message: message
41                 }
42             }).closePromise.then(confirmed => {
43                 deferred.resolve(confirmed.value);
44             }).catch(err => {
45                 deferred.reject(err);
46             });
47             return deferred.promise;
48         };
49
50         confirm(message) {
51             let deferred = this.$q.defer();
52             this.ngDialog.open({
53                 templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html',
54                 controller: 'ConfirmationBoxCtrl',
55                 controllerAs: 'confirmBox',
56                 className: 'confirm-box ngdialog-theme-default',
57                 showClose: false,
58                 data: {
59                     message: message
60                 }
61             }).closePromise.then(confirmed => {
62                 deferred.resolve(confirmed.value);
63             }).catch(err => {
64                 deferred.reject(err);
65             });
66             return deferred.promise;
67         };
68         
69         
70         showDynamicInformation(message, templatePath, controller) {
71             let deferred = this.$q.defer();
72             this.ngDialog.open({
73                 templateUrl: templatePath,
74                 controller: controller,
75                 controllerAs: 'confirmBox',
76                 className: 'confirm-box ngdialog-theme-default',
77                 showClose: false,
78                 data: {
79                     message: message
80                 }
81             }).closePromise.then(confirmed => {
82                 deferred.resolve(confirmed.value);
83             }).catch(err => {
84                 deferred.reject(err);
85             });
86             return deferred.promise;
87         };
88
89         deleteItem(item) {
90             let deferred = this.$q.defer();
91             this.ngDialog.open({
92                 templateUrl: 'app/views/confirmation-box/confirmation-box.tpl.html',
93                 controller: 'ConfirmationBoxCtrl',
94                 controllerAs: 'confirmBox',
95                 className: 'confirm-box ngdialog-theme-default',
96                 showClose: false,
97                 data: {
98                     item: item,
99                     title: 'Functional Menu - Delete'
100                 }
101             }).closePromise.then(confirmed => {
102                 deferred.resolve(confirmed.value);
103             }).catch(err => {
104                 deferred.reject(err);
105             });
106             return deferred.promise;
107         };
108
109         moveMenuItem(message) {
110             let deferred = this.$q.defer();
111             this.ngDialog.open({
112                 templateUrl: 'app/views/confirmation-box/dragdrop-confirmation-box.tpl.html',
113                 controller: 'ConfirmationBoxCtrl',
114                 controllerAs: 'confirmBox',
115                 className: 'confirm-box ngdialog-theme-default',
116                 showClose: false,
117                 data: {
118                     message: message,
119                     title:'Functional Menu - Move'
120                 }
121             }).closePromise.then(confirmed => {
122                 deferred.resolve(confirmed.value);
123             }).catch(err => {
124                 deferred.reject(err);
125             });
126             return deferred.promise;
127         };
128
129         makeAdminChanges(message) {
130             let deferred = this.$q.defer();
131             this.ngDialog.open({
132                 templateUrl: 'app/views/confirmation-box/admin-confirmation-box.tpl.html',
133                 controller: 'ConfirmationBoxCtrl',
134                 controllerAs: 'confirmBox',
135                 className: 'confirm-box ngdialog-theme-default',
136                 showClose: false,
137                 data: {
138                     message: message,
139                     title: 'Admin Update'
140                 }
141             }).closePromise.then(confirmed => {
142                 deferred.resolve(confirmed.value);
143             }).catch(err => {
144                 deferred.reject(err);
145             });
146             return deferred.promise;
147         };
148
149
150     }
151     ConfirmBoxService.$inject = ['$q', '$log', 'ngDialog'];
152     angular.module('ecompApp').service('confirmBoxService', ConfirmBoxService)
153 })();