Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / static / js / modalService.js
1 angular.module("modalServices",[]).service('modalService', ['$modal', function ($modal) {
2         
3                                                                                                                 
4                 this.showSuccess = function(heading, messageBody){
5                         var modalInstance = $modal.open({
6                         templateUrl: 'modal_informative.html',
7                         controller: 'modalpopupController',
8                         resolve: {
9                            message: function () {
10                                         $(".overlayed").css("display","none");
11                                         $(".loadingId").css("display","none");
12                                    var message = {
13                                                    title:    heading,
14                                         text:     messageBody
15                                 };
16                                   return message;
17                                         }
18                         }
19                       }); 
20                 };
21                 this.showFailure = function(heading, messageBody){
22                 var modalInstance = $modal.open({
23                         templateUrl: 'modal_warning.html',
24                         controller: 'modalpopupController',
25                         resolve: {
26                            message: function () {
27                                   var message = {
28                                  title:    heading,
29                                  text:     messageBody
30                                 };
31                                   return message;
32                                         }
33                         }
34                       }); 
35                 };
36                 
37                 this.showWarning = function(heading, messageBody){
38                 var modalInstance = $modal.open({
39                         templateUrl: 'modal_warning_message.html',
40                         controller: 'modalpopupController',
41                         resolve: {
42                            message: function () {
43                                   var message = {
44                                          title:    heading,
45                                          text:     messageBody
46                                         };
47                                           return message;
48                                                 }
49                         }
50                       }); 
51                 };
52                 
53                 this.popupConfirmWin = function(title, msgBody, callback,dismissCallback){
54                          var modalInstance = $modal.open({
55                         templateUrl: 'confirmation_informative.html',
56                         controller: 'modalpopupController',
57                         resolve: {
58                            message: function () {
59                                    var message = {
60                                                    title:    title,
61                                         text:    msgBody
62                                 };
63                                           return message;
64                                         }
65                         }
66                       }); 
67                          var args = Array.prototype.slice.call( arguments, 0 );
68                      args.splice( 0, 3); 
69                         modalInstance.result.then(function(){
70                                         callback.apply(null, args);
71                                 }, function() {
72                           })['finally'](function(){
73                            modalInstance = undefined;
74                           });
75                         
76                 };
77                 this.popupConfirmWinWithCancel = function(title, msgBody, callback,dismissCallback){
78                          var modalInstance = $modal.open({
79                         templateUrl: 'confirmation_informative.html',
80                         controller: 'modalpopupController',
81                         resolve: {
82                            message: function () {
83                                    var message = {
84                                                    title:    title,
85                                         text:    msgBody
86                                 };
87                                           return message;
88                                         }
89                         }
90                       }); 
91                          var args = Array.prototype.slice.call( arguments, 0 );
92                      args.splice( 0, 3); 
93                         modalInstance.result.then(function(){
94                                         callback.apply(null, args);
95                                 }, function() {
96                                   dismissCallback();
97                           })['finally'](function(){
98                            modalInstance = undefined;
99                           });
100                         
101                 };
102         this.popupDeleteConfirmWin = function(title, msgBody, callback, argForCallBack){
103                          var modalInstance = $modal.open({
104                         templateUrl: 'confirmation_for_delete.html',
105                         controller: 'modalpopupController',
106                         resolve: {
107                            message: function () {
108                                    var message = {
109                                                    title:    title,
110                                         text:    msgBody
111                                 };
112                                           return message;
113                                         }
114                         }
115                       }); 
116                          
117                         modalInstance.result.then(function(){
118                                         callback(argForCallBack);
119                                 }, function() {
120                           })['finally'](function(){
121                            modalInstance = undefined;
122                           });
123                         
124                 };              
125                 
126          this.popupSuccessRedirectWin = function(title, msgBody, redirectUrl){
127                 var modalInstance = $modal.open({
128                 templateUrl: 'modal_informative.html',
129                 controller: 'modalpopupController',
130                 resolve: {
131                    message: function () {
132                            var message = {
133                                            title:    title,
134                                text:    msgBody
135                         };
136                                   return message;
137                                 }
138                 }
139               }); 
140                 modalInstance.result.then(function() {
141                   }, function() {
142                           window.location.href=redirectUrl;
143                   })['finally'](function(){
144                    modalInstance = undefined;
145                   });   
146         };      
147         
148         this.popupWarningRedirectWin = function(title, msgBody, redirectUrl){
149                 var modalInstance = $modal.open({
150                         templateUrl: 'modal_warning_message.html',
151                 controller: 'modalpopupController',
152                 resolve: {
153                    message: function () {
154                            var message = {
155                                            title:    title,
156                                text:    msgBody
157                         };
158                                   return message;
159                                 }
160                 }
161               }); 
162                 modalInstance.result.then(function() {
163                   }, function() {
164                           window.location.href=redirectUrl;
165                   })['finally'](function(){
166                    modalInstance = undefined;
167                   });   
168         };      
169  }]);