Remove unused vars and methods
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / service / modalService.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
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  * ============LICENSE_END=========================================================
19  */
20 angular.module("modalServices",[]).service('modalService', ['$modal', function ($modal) {
21         
22                                                                                                                 
23                 this.showSuccess = function(heading, messageBody){
24                         $modal.open({
25                         templateUrl: 'modal_informative.html',
26                         controller: 'modalpopupController',
27                         resolve: {
28                            message: function () {
29                                         $(".overlayed").css("display","none");
30                                         $(".loadingId").css("display","none");
31                                    var message = {
32                                                    title:    heading,
33                                         text:     messageBody
34                                 };
35                                   return message;
36                                         }
37                         }
38                       }); 
39                 };
40                 this.showFailure = function(heading, messageBody){
41                         $modal.open({
42                         templateUrl: 'modal_warning.html',
43                         controller: 'modalpopupController',
44                         resolve: {
45                            message: function () {
46                                   var message = {
47                                  title:    heading,
48                                  text:     messageBody
49                                 };
50                                   return message;
51                                         }
52                         }
53                       }); 
54                 };
55                 
56                 this.showMessage = function(heading, messageBody){
57                 $modal.open({
58                         templateUrl: 'modal_message.html',
59                         controller: 'modalpopupController',
60                         resolve: {
61                            message: function () {
62                                   var message = {
63                                          title:    heading,
64                                          text:     messageBody
65                                         };
66                                           return message;
67                                                 }
68                         }
69                       }); 
70                 };
71                 
72                 this.showWarning = function(heading, messageBody){
73                 $modal.open({
74                         templateUrl: 'modal_warning_message.html',
75                         controller: 'modalpopupController',
76                         resolve: {
77                            message: function () {
78                                   var message = {
79                                          title:    heading,
80                                          text:     messageBody
81                                         };
82                                           return message;
83                                                 }
84                         }
85                       }); 
86                 };
87                 
88                 this.popupConfirmWin = function(title, msgBody, callback){
89                          var modalInstance = $modal.open({
90                         templateUrl: 'confirmation_informative.html',
91                         controller: 'modalpopupController',
92                         resolve: {
93                            message: function () {
94                                    var message = {
95                                                    title:    title,
96                                         text:    msgBody
97                                 };
98                                           return message;
99                                         }
100                         }
101                       }); 
102                          var args = Array.prototype.slice.call( arguments, 0 );
103                      args.splice( 0, 3); 
104                         modalInstance.result.then(function(){
105                                         callback.apply(null, args);
106                                 }, function() {
107                           })['finally'](function(){
108                            modalInstance = undefined;
109                           });
110                         
111                 };
112                 this.popupConfirmWinWithCancel = function(title, msgBody, callback,dismissCallback){
113                          var modalInstance = $modal.open({
114                         templateUrl: 'confirmation_informative.html',
115                         controller: 'modalpopupController',
116                         resolve: {
117                            message: function () {
118                                    var message = {
119                                                    title:    title,
120                                         text:    msgBody
121                                 };
122                                           return message;
123                                         }
124                         }
125                       }); 
126                          var args = Array.prototype.slice.call( arguments, 0 );
127                      args.splice( 0, 3); 
128                         modalInstance.result.then(function(){
129                                         callback.apply(null, args);
130                                 }, function() {
131                                   dismissCallback();
132                           })['finally'](function(){
133                            modalInstance = undefined;
134                           });
135                         
136                 };
137         this.popupDeleteConfirmWin = function(title, msgBody, callback, argForCallBack){
138                          var modalInstance = $modal.open({
139                         templateUrl: 'confirmation_for_delete.html',
140                         controller: 'modalpopupController',
141                         resolve: {
142                            message: function () {
143                                    var message = {
144                                                    title:    title,
145                                         text:    msgBody
146                                 };
147                                           return message;
148                                         }
149                         }
150                       }); 
151                          
152                         modalInstance.result.then(function(){
153                                         callback(argForCallBack);
154                                 }, function() {
155                           })['finally'](function(){
156                            modalInstance = undefined;
157                           });
158                         
159                 };              
160                 
161          this.popupSuccessRedirectWin = function(title, msgBody, redirectUrl){
162                 var modalInstance = $modal.open({
163                 templateUrl: 'modal_informative.html',
164                 controller: 'modalpopupController',
165                 resolve: {
166                    message: function () {
167                            var message = {
168                                            title:    title,
169                                text:    msgBody
170                         };
171                                   return message;
172                                 }
173                 }
174               }); 
175                 modalInstance.result.then(function() {
176                   }, function() {
177                           window.location.href=redirectUrl;
178                   })['finally'](function(){
179                    modalInstance = undefined;
180                   });   
181         };      
182         
183         this.popupWarningRedirectWin = function(title, msgBody, redirectUrl){
184                 var modalInstance = $modal.open({
185                         templateUrl: 'modal_warning_message.html',
186                 controller: 'modalpopupController',
187                 resolve: {
188                    message: function () {
189                            var message = {
190                                            title:    title,
191                                text:    msgBody
192                         };
193                                   return message;
194                                 }
195                 }
196               }); 
197                 modalInstance.result.then(function() {
198                   }, function() {
199                           window.location.href=redirectUrl;
200                   })['finally'](function(){
201                    modalInstance = undefined;
202                   });   
203         };      
204  }]);