00a56246fec3eefa7167f19ae6b18a58e1bb073d
[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 .fileUpload {
27         position: relative;
28         overflow: hidden;
29         margin: 10px;
30 }
31
32 .fileUpload input.upload {
33         position: absolute;
34         top: 0;
35         right: 0;
36         margin: 0;
37         padding: 0;
38         font-size: 20px;
39         cursor: pointer;
40         opacity: 0;
41         filter: alpha(opacity = 0);
42         float: left;
43 }
44
45 .fileDisplay {
46         display: inline-block;
47         overflow: hidden;
48         float: right;
49         margin-left: 0px;
50         z-index: initial;
51         text-align: center;
52         margin-top: 17px;
53 }
54
55 #paramsWarn {
56         display: none;
57 }
58 </style>
59 <link rel="stylesheet"
60         href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
61 <script type="text/javascript">
62         function disablefile() {
63             document.getElementById("fileUpload").disabled = true;
64     }
65     function disableSVN() {
66             document.getElementById("schemaLocation").disabled = true;
67             document.getElementById("userID").disabled = true;
68             document.getElementById("password").disabled = true;
69     }
70 </script>
71
72
73 <div id="configure-widgets">
74         <div class="modal-header">
75                 <button type="button" class="close" ng-click="close(false)"
76                         aria-hidden="true" style="margin-top: -3px">&times;</button>
77                 <h4>Model Properties</h4>
78         </div>
79
80         <div class="modal-body" style="height: 280px">
81                 <i hidden id="ridinSpinners" class="fa fa-spinner fa-spin"
82                         style="display: none; margin-bottom: 10px; width: 100%; text-align: center; font-size: 24px; color: black;"></i>
83                 <form id="saveProps">
84                         <div class="alert alert-danger" role="alert" id='paramsWarn'>
85                                 <strong>Ooops!</strong> Unable to load properties for <span
86                                         id='servName'>. Would you like to</span> <a
87                                         href="javascript:void(0);" class="btn-link" id='paramsRetry'>Retry
88                                 </a> / <a href="javascript:void(0);" class="btn-link" id='paramsCancel'>Cancel</a>
89                         </div>
90                         <div>
91
92                                 <div class="form-group clearfix">
93                                         <label for="services" class="col-sm-4 control-label">Services</label>
94
95                                         <div class="col-sm-8">
96                                                 <select class="form-control" name="service" id="service"
97                                                         onchange="propChangeAlert(this);">
98                                                         <!--                                                             <option ng-repeat="(key, value) in services" value="{{key}}">{{value}}</option>  -->
99                                                 </select>
100                                         </div>
101                                 </div>
102                                 <div class="form-group clearfix">
103                                         <label for="vf" class="col-sm-4 control-label"> Resource-VF</label>
104
105                                         <div class="col-sm-8">
106                                                 <select class="form-control" id="vf" name="vf"
107                                                         onchange="propChangeAlert(this);">
108
109                                                 </select>
110
111                                         </div>
112                                 </div>
113
114                                 <div class="form-group clearfix">
115                                         <label for="actionSet" class="col-sm-4 control-label">
116                                                 Action Set</label>
117
118                                         <div class="col-sm-8">
119                                                 <select class="form-control" id="actionSet" name="actionSet"
120                                                         onchange="propChangeAlert(this);">
121                                                 </select>
122
123                                         </div>
124                                 </div>
125
126                                 <div class="form-group clearfix">
127                                         <label for="location" class="col-sm-4 control-label">
128                                                 Location</label>
129
130                                         <div class="col-sm-8">
131                                                 <select class="form-control" id="location" name="location"
132                                                         multiple size=2>
133
134                                                 </select>
135
136                                         </div>
137                                 </div>
138
139
140
141                         </div>
142
143                 </form>
144                 <div class="alert alert-warning propChangeWarn" style="display: none;">
145                         <strong>Warning!</strong> Changing these properties will reset all
146                         associated GUI fields.
147                 </div>
148
149         </div>
150         <div class="modal-footer">
151                 <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
152                 <button id="savePropsBtn" class="btn btn-primary">Save</button>
153                 <button ng-click="close(true)" id="close_button"
154                         class="btn btn-primary">Cancel</button>
155
156         </div>
157
158
159         <script>
160                 //display message only if global was previously saved
161         serDiff = false;
162         vfDiff = false;
163         asDiff = false;
164         (function() {
165                 $("#paramsWarn").hide();
166                 /*Below service method is called for checking the service is being loaded or not*/
167                 var intialize = intializeService;
168                 function intializeService() {
169                         $("#service").off('focus').off('change');
170                         $("#service").on('change', function() {
171                                 var chosen = $(this).val();
172                                 (function(spinner) {
173                                         $("#ridinSpinners").show();
174                                         setTimeout(spinner, 1);
175                                 })(function() {
176                                         loadSharedPropertyByService(chosen, null, intialize);
177                                         if (elementMap["global"]) {
178                                                 if ($("#vf").val() == oldVf) {
179                                                         vfDiff = false;
180                                                         if ((!vfDiff) && (!asDiff) && (!serDiff)) {
181                                                                 $(".propChangeWarn").hide();
182                                                         }
183                                                         ;
184                                                 } else {
185                                                         vfDiff = true;
186                                                         $(".propChangeWarn").show();
187                                                 }
188                                         }
189                                         $("#ridinSpinners").hide();
190                                 });
191                         });
192                 }
193                 loadSharedPropertyByService(undefined, null, intialize);
194                 intializeService();
195                 $("#paramsRetry").on('click', function() {
196                         //$("#paramsWarn").hide();
197                         var currentValue = $("#service").val();
198                         $("#ridinSpinners").css("display", "")
199                         var bool = loadSharedPropertyByService(currentValue);
200                         $("#ridinSpinners").css("display", "none")
201                 });
202                 $("#paramsCancel").on('click', function() {
203                         loadSharedPropertyByServiceProperties();
204                         $("#paramsWarn").hide();
205                 });
206         })();
207         function noRepeats(form) {
208                 var select = {};
209                 for (var i = 0; i < form.length; i++) {
210                         if (form[i].hasOwnProperty("name")) {
211                                 if (select[form[i].name] === undefined)
212                                         select[form[i].name] = []
213                                 select[form[i].name].push(form[i].value);
214                         }
215                 }
216                 var arr = []
217                 for (s in select) {
218                         var f = {}
219                         f.name = s
220                         f.value = select[s]
221                         if (!(s == "service" && f.value == "")) {
222                                 arr.push(f)
223                         }
224                 }
225                 return arr
226         }
227         $(function() {
228                 if (elementMap["global"]) {
229                         for (var i = 0; i < elementMap["global"].length; i++) {
230                                 if (elementMap["global"][i]["name"] == "vf") {
231                                         oldVf = elementMap["global"][i]["value"];
232                                 }
233                         }
234                 } else {
235                         oldVf = "";
236                 }
237         });
238         function propChangeAlert(actionset) {
239                 //throw warnings only if options were previously chosen
240                 if (elementMap["global"]) {
241                         loop1: for (var i = 0; i < elementMap["global"].length; i++) {
242                                 if (elementMap["global"][i]["name"] == actionset.id) {
243                                         //user did not change properties                                                
244                                         if (elementMap["global"][i]["value"][0] == actionset.value) {
245                                                 if (elementMap["global"][i]["name"] == "actionSet") {
246                                                         asDiff = false;
247                                                 } else if (elementMap["global"][i]["name"] == "service") {
248                                                         serDiff = false;
249                                                 } else if (elementMap["global"][i]["name"] == "vf") {
250                                                         vfDiff = false;
251                                                 }
252                                                 if ((!vfDiff) && (!asDiff) && (!serDiff)) {
253                                                         $(".propChangeWarn").hide();
254                                                 }
255                                                 ;
256                                                 //user changed properties
257                                         } else {
258                                                 if (elementMap["global"][i]["name"] == "actionSet") {
259                                                         asDiff = true;
260                                                 } else if (elementMap["global"][i]["name"] == "service") {
261                                                         serDiff = true;
262                                                 } else if (elementMap["global"][i]["name"] == "vf") {
263                                                         vfDiff = true;
264                                                 }
265                                                 ;
266                                                 $(".propChangeWarn").show();
267                                         }
268                                         break loop1;
269                                 }
270                         }
271                 }
272         }
273         $("#saveProps").on('submit', function(event) {
274                 saveGlobalProperties(noRepeats($(this).serializeArray()))
275                 event.preventDefault();
276                 //module reset, based on property updates
277                 if (elementMap["global"]) {
278                         $.each(Object.keys(elementMap), function(i, v) {
279                                 if ((v.match(/^Policy/)) && asDiff) {
280                                         elementMap[v] = {};
281                                 }
282                                 if ((v.match(/^TCA/)) && (vfDiff || serDiff)) {
283                                         elementMap[v] = {};
284                                 }
285                         });
286                 }
287                 ;
288                 $("#close_button").click();
289         })
290         $("#savePropsBtn").click(function(event) {
291                 //alert($("#CProp_Target").val())
292                 $("#saveProps").submit();
293         })
294         </script>
295 </div>