441766d42c43eac5eb88a1e7613ec56a81f92a2b
[clamp.git] / src / main / resources / META-INF / resources / designer / partials / portfolios / refresh_asdc.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 <style>
25 #paramsWarnrefresh {
26     display: none;
27 }
28
29 </style>
30 <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
31 <div attribute-test="refreshasdc" id="configure-widgets">
32         <div attribute-test="refreshasdch" 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         <div class="modal-body" style="height: 280px">
38                 <div style="height: 10px"></div>
39                 <div class="alert alert-danger refreshASDC" role="alert" id='paramsWarnrefresh'> 
40                                                         <strong>Ooops!</strong> Unable to load properties for <span id='servName'>. Would you like to</span>
41                                                         <a href="javascript:void(0);" ng-click="paramsRetry();" class="btn-link"  id='paramsRetry'>Retry </a> /
42                                                         <a href="javascript:void(0);" ng-click="paramsCancel();" class="btn-link" id='paramsCancel'>Cancel</a>
43                                                 </div>
44                 <form id="saveProps" >
45                                 <div>                           
46                                         
47                                         <div class="form-group">
48                                                 <label for="services" class="col-sm-4 control-label" >Refresh ASDC services?</label>
49         
50                         
51                                         </div>
52                                         
53                                 </div>
54
55                 </form>
56         <i hidden id="ridinSpinners" class="fa fa-spinner fa-spin" style="display:none;width:100%;text-align:center;font-size:24px;color:black;"></i>
57
58         </div>
59         <div attribute-test="refreshasdcf" class="modal-footer">
60                 <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
61                 <button ng-click="refreshASDC()" class="btn btn-primary">refresh</button>
62                 <button ng-click="close(true)" id="close_button"
63                         class="btn btn-primary">Cancel</button>
64
65         </div>  
66         <script>
67 //              $.ajax({
68 //                      async:false,
69 //                  dataType: "json",
70 //                  url: '/restservices/clds/v1/clds/asdc/services/',
71 //                  success: function(data){
72 //                      vf_Services=data;
73 //                  },
74 //                  error:function(s,a,err){
75 //                      console.log(err)
76 //                      console.log(s)
77 //                      console.log(a)
78 //                  },
79 //                  timeout:100000
80 //              });
81 //              var services=vf_Services.service
82 //              console.log(elementMap["global"])
83 //              for(k in services){
84 //                      console.log("lol")
85 //                      $("#service").append("<option value="+k+">"+services[k]+"</option>")
86 //              }
87 //              loadSharedPropertyByService()
88 //              var el = elementMap["global"];
89 //              $("#status").val($("#activity_modeler").text())
90 //              if (el !== undefined) {
91 //                      for (var i = 0; i < el.length; i++) {
92 //                              $("#" + el[i].name).val(el[i].value);
93 //                      }
94 //              }
95                 var previous;
96                 (function () {      
97                 
98                     $("#service").on('focus', function () {
99                         // Store the current value on focus and on change
100                         previous = this.value;
101                         console.log("hello")
102                     }).change(function(){
103                                 $("#ridinSpinners").css("display","")
104                                 var bool=loadSharedPropertyByService($(this).val())
105                                 $("#ridinSpinners").css("display","none")
106                                 if(!bool)
107                                         $(this).val(previous)
108                         });
109
110                 })();
111 //              $("#service").on("change",function(){
112 //                      $("#ridinSpinners").css("display","")
113 //                      loadSharedPropertyByService($(this).val())
114 //                      $("#ridinSpinners").css("display","none")
115 //              })
116                 function noRepeats(form){
117                         var select={};
118                         for(var i=0;i<form.length;i++){
119                                 if(select[form[i].name]===undefined)
120                                         select[form[i].name]=[]
121                                 select[form[i].name].push(form[i].value);
122                         }
123                         var arr=[]
124                         for(s in select){
125                                 var f={}
126                                 f.name=s
127                                 f.value=select[s]
128                                 arr.push(f)
129                         }
130                         return arr
131                 }
132                 
133                 $("#saveProps").on('submit', function(event) {
134                         saveGlobalProperties(noRepeats($(this).serializeArray()))
135                         event.preventDefault();
136                         
137                         $("#close_button").click();
138
139                 })
140                 $("#savePropsBtn").click(function(event) {
141                         //alert($("#CProp_Target").val())
142                         $("#saveProps").submit();
143                 })
144         </script>
145 </div>
146