811f6b7166bd55e5f7e2e0c991bf7b06fec81158
[clamp.git] / src / main / resources / META-INF / resources / designer / partials / portfolios / global_properties.html
1 <!--
2   ============LICENSE_START=======================================================
3   ONAP CLAMP
4   ================================================================================
5   Copyright (C) 2017 AT&T Intellectual Property. All rights
6                               reserved.
7   ================================================================================
8   Licensed under the Apache License, Version 2.0 (the "License"); 
9   you may not use this file except in compliance with the License. 
10   You may obtain a copy of the License at
11   
12   http://www.apache.org/licenses/LICENSE-2.0
13   
14   Unless required by applicable law or agreed to in writing, software 
15   distributed under the License is distributed on an "AS IS" BASIS, 
16   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
17   See the License for the specific language governing permissions and 
18   limitations under the License.
19   ============LICENSE_END============================================
20   ===================================================================
21   
22   -->
23
24
25 <style>
26 #paramsWarn {
27         display: none;
28 }
29 </style>
30
31 <div id="configure-widgets">
32         <div class="modal-header">
33                 <button type="button" class="close" ng-click="close(false)"
34                         aria-hidden="true" style="margin-top: -3px">&times;</button>
35                 <h4>Model Properties</h4>
36         </div>
37
38         <div class="modal-body" style="height: 280px">
39                 <i hidden id="ridinSpinners" class="fa fa-spinner fa-spin"
40                         style="display: none; margin-bottom: 10px; width: 100%; text-align: center; font-size: 24px; color: black;"></i>
41                 <form id="saveProps">
42                         <div class="alert alert-danger" role="alert" id='paramsWarn'>
43                                 <strong>Ooops!</strong> Unable to load properties for <span
44                                         id='servName'>. Would you like to</span> <a
45                                         href="javascript:void(0);" class="btn-link" id='paramsRetry'>Retry
46                                 </a> / <a href="javascript:void(0);" class="btn-link" id='paramsCancel'>Cancel</a>
47                         </div>
48                         <div>
49
50                                 <div class="form-group clearfix">
51                                         <label for="services" class="col-sm-4 control-label">Services</label>
52
53                                         <div class="col-sm-8">
54                                                 <select class="form-control" name="service" id="service"
55                                                         onchange="propChangeAlert(this);">
56                                                         <!--                                                             <option ng-repeat="(key, value) in services" value="{{key}}">{{value}}</option>  -->
57                                                 </select>
58                                         </div>
59                                 </div>
60                                 <div class="form-group clearfix">
61                                         <label for="vf" class="col-sm-4 control-label"> Resource-VF</label>
62
63                                         <div class="col-sm-8">
64                                                 <select class="form-control" id="vf" name="vf"
65                                                         onchange="propChangeAlert(this);">
66
67                                                 </select>
68
69                                         </div>
70                                 </div>
71
72                                 <div class="form-group clearfix">
73                                         <label for="actionSet" class="col-sm-4 control-label">
74                                                 Action Set</label>
75
76                                         <div class="col-sm-8">
77                                                 <select class="form-control" id="actionSet" name="actionSet"
78                                                         onchange="propChangeAlert(this);">
79                                                 </select>
80
81                                         </div>
82                                 </div>
83
84                                 <div class="form-group clearfix">
85                                         <label for="location" class="col-sm-4 control-label">
86                                                 Location</label>
87
88                                         <div class="col-sm-8">
89                                                 <select class="form-control" id="location" name="location"
90                                                         multiple size=2>
91
92                                                 </select>
93
94                                         </div>
95                                 </div>
96                                 <div class="form-group clearfix">
97                                         <label for="deployParameters" class="col-sm-4 control-label">
98                                                 Deploy Parameters</label>
99
100                                         <div class="col-sm-8">
101                                                 <textarea class="form-control" id="deployParameters"
102                                                         name="deployParameters" rows="3">
103                                                 </textarea>
104
105                                         </div>
106                                 </div>
107
108
109                         </div>
110
111                 </form>
112                 <div class="alert alert-warning propChangeWarn" style="display: none;">
113                         <strong>Warning!</strong> Changing these properties will reset all
114                         associated GUI fields.
115                 </div>
116
117         </div>
118         <div class="modal-footer">
119                 <button id="savePropsBtn" class="btn btn-primary" ng-click="submitForm()">Save</button>
120                 <button ng-click="close(true)" id="close_button"
121                         class="btn btn-primary">Cancel</button>
122
123         </div>
124
125
126         <script>
127                 //display message only if global was previously saved
128         serDiff = false;
129         vfDiff = false;
130         asDiff = false;
131         (function() {
132                 $("#paramsWarn").hide();
133                 /*Below service method is called for checking the service is being loaded or not*/
134                 var intialize = intializeService;
135                 function intializeService() {
136                         $("#service").off('focus').off('change');
137                         $("#service").on('change', function() {
138                                 var chosen = $(this).val();
139                                 (function(spinner) {
140                                         $("#ridinSpinners").show();
141                                         setTimeout(spinner, 1);
142                                 })(function() {
143                                         loadSharedPropertyByService(chosen, null, intialize);
144                                         if (elementMap["global"]) {
145                                                 if ($("#vf").val() == oldVf) {
146                                                         vfDiff = false;
147                                                         if ((!vfDiff) && (!asDiff) && (!serDiff)) {
148                                                                 $(".propChangeWarn").hide();
149                                                         }
150                                                         ;
151                                                 } else {
152                                                         vfDiff = true;
153                                                         $(".propChangeWarn").show();
154                                                 }
155                                         }
156                                         $("#ridinSpinners").hide();
157                                 });
158                         });
159                 }
160                 loadSharedPropertyByService(undefined, null, intialize);
161                 intializeService();
162                 $("#paramsRetry").on('click', function() {
163                         //$("#paramsWarn").hide();
164                         var currentValue = $("#service").val();
165                         $("#ridinSpinners").css("display", "")
166                         var bool = loadSharedPropertyByService(currentValue);
167                         $("#ridinSpinners").css("display", "none")
168                 });
169                 $("#paramsCancel").on('click', function() {
170                         loadSharedPropertyByServiceProperties();
171                         $("#paramsWarn").hide();
172                 });
173         })();
174         $(function() {
175                 if (elementMap["global"]) {
176                         for (var i = 0; i < elementMap["global"].length; i++) {
177                                 if (elementMap["global"][i]["name"] == "vf") {
178                                         oldVf = elementMap["global"][i]["value"];
179                                 }
180                         }
181                 } else {
182                         oldVf = "";
183                 }
184         });
185         function propChangeAlert(actionset) {
186                 //throw warnings only if options were previously chosen
187                 if (elementMap["global"]) {
188                         loop1: for (var i = 0; i < elementMap["global"].length; i++) {
189                                 if (elementMap["global"][i]["name"] == actionset.id) {
190                                         //user did not change properties                                                
191                                         if (elementMap["global"][i]["value"][0] == actionset.value) {
192                                                 if (elementMap["global"][i]["name"] == "actionSet") {
193                                                         asDiff = false;
194                                                 } else if (elementMap["global"][i]["name"] == "service") {
195                                                         serDiff = false;
196                                                 } else if (elementMap["global"][i]["name"] == "vf") {
197                                                         vfDiff = false;
198                                                 }
199                                                 if ((!vfDiff) && (!asDiff) && (!serDiff)) {
200                                                         $(".propChangeWarn").hide();
201                                                 }
202                                                 ;
203                                                 //user changed properties
204                                         } else {
205                                                 if (elementMap["global"][i]["name"] == "actionSet") {
206                                                         asDiff = true;
207                                                 } else if (elementMap["global"][i]["name"] == "service") {
208                                                         serDiff = true;
209                                                 } else if (elementMap["global"][i]["name"] == "vf") {
210                                                         vfDiff = true;
211                                                 }
212                                                 ;
213                                                 $(".propChangeWarn").show();
214                                         }
215                                         break loop1;
216                                 }
217                         }
218                 }
219         }
220         </script>
221 </div>