Remove ECOMP in headers
[clamp.git] / src / main / resources / META-INF / resources / designer / partials / portfolios / global_properties.html
index e6f20e0..babdeb6 100644 (file)
   limitations under the License.
   ============LICENSE_END============================================
   ===================================================================
-  ECOMP is a trademark and service mark of AT&T Intellectual Property.
+  
   -->
 
+
 <style>
 .fileUpload {
        position: relative;
@@ -79,8 +80,9 @@
                        aria-hidden="true" style="margin-top: -3px">&times;</button>
                <h4>Model Properties</h4>
        </div>
+       
        <div class="modal-body" style="height: 280px">
-               <div style="height: 10px"></div>
+               <i hidden id="ridinSpinners" class="fa fa-spinner fa-spin" style="display:none;margin-bottom:10px;width:100%;text-align:center;font-size:24px;color:black;"></i>
                <form id="saveProps" >
                                <div class="alert alert-danger" role="alert" id='paramsWarn'> 
                                                        <strong>Ooops!</strong> Unable to load properties for <span id='servName'>. Would you like to</span>
        
                                                <div class="col-sm-8">
                                                        <select  class="form-control" 
-                                                               name="service" id="service" >
+                                                               name="service" id="service" onchange="propChangeAlert(this);">
 <!--                                                            <option ng-repeat="(key, value) in services" value="{{key}}">{{value}}</option>  -->
                                                        </select>
                                                </div>
                                        </div>
-                                       <div class="form-group">
+                                       <div class="form-group clearfix">
                                                <label for="vf" class="col-sm-4 control-label">
                                                        Resource-VF</label>
 
                                                <div class="col-sm-8">
-                                                       <select class="form-control" id="vf" name="vf" >
+                                                       <select class="form-control" id="vf" name="vf" onchange="propChangeAlert(this);">
+
+                                                       </select>
+
+                                               </div>
+                                       </div>
+                                       
+                                       <div class="form-group clearfix">
+                                               <label for="actionSet" class="col-sm-4 control-label">
+                                                       Action Set</label>
 
+                                               <div class="col-sm-8">
+                                                       <select class="form-control" id="actionSet" name="actionSet" onchange="propChangeAlert(this);">
                                                        </select>
 
                                                </div>
                                        </div>
-                                       <div class="form-group">
+                                       
+                                       <div class="form-group clearfix">
                                                <label for="location" class="col-sm-4 control-label">
                                                        Location</label>
 
 
                                                </div>
                                        </div>
+                                       
+                                       
+                                       
                                </div>
 
                </form>
-       <i hidden id="ridinSpinners" class="fa fa-spinner fa-spin" style="display:none;width:100%;text-align:center;font-size:24px;color:black;"></i>
+               <div class="alert alert-warning propChangeWarn" style="display:none;">
+                       <strong>Warning!</strong> Changing these properties will reset all associated GUI fields.
+               </div>
 
        </div>
        <div class="modal-footer">
                <!--<button ng-click="reset()" class="btn btn-primary" style="float:left">Reset</button>-->
-               <button id="savePropsBtn" class="btn btn-primary">Close</button>
+               <button id="savePropsBtn" class="btn btn-primary">Save</button>
                <button ng-click="close(true)" id="close_button"
                        class="btn btn-primary">Cancel</button>
 
 //             $.ajax({
 //                     async:false,
 //                 dataType: "json",
-//                 url: '/restservices/clds/v1/jaxrsClds/clds/asdc/services/',
+//                 url: '/restservices/clds/v1/clds/asdc/services/',
 //                 success: function(data){
 //                     vf_Services=data;
 //                 },
 //                             $("#" + el[i].name).val(el[i].value);
 //                     }
 //             }   
-
-
-      
-
-         (function () {
+               
+               //display message only if global was previously saved
+               serDiff = false;
+               vfDiff = false;
+               asDiff = false;
                        
-                   var previous;
+         (function () {
                    $("#paramsWarn").hide();
                    /*Below service method is called for checking the service is being loaded or not*/
-                       loadSharedPropertyByService();
 
-                   $("#service").on('focus', function () {
-                       // Store the current value on focus and on change
-                       previous = this.value;
-                       
-                   }).change(function(){
-                               $("#ridinSpinners").css("display","")
-                               var bool=loadSharedPropertyByService($(this).val())
-                               $("#ridinSpinners").css("display","none")
-                               if(!bool)
-                                       $(this).val(previous)
-                   });
+                       var intialize = intializeService;
+
+                       function intializeService() {
+                               $("#service").off('focus').off('change');
+
+                               $("#service").on('change', function(){
+                                       var chosen = $(this).val();
+                                       (function(spinner){
+                                               $("#ridinSpinners").show();
+                                               setTimeout(spinner, 1);
+                                       })(function(){
+                                               loadSharedPropertyByService(chosen, null, intialize);
+                                               if (elementMap["global"]){
+                                                       if ($("#vf").val() == oldVf){
+                                                               vfDiff = false;
+                                                               if ((!vfDiff)&&(!asDiff)&&(!serDiff)){
+                                                                       $(".propChangeWarn").hide();
+                                                               };
+                                                       } else {
+                                                               vfDiff = true;
+                                                               $(".propChangeWarn").show();
+                                                       }
+                                               }
+                                               $("#ridinSpinners").hide();
+                                       });
+                               });
+                       }
+                       
+                       loadSharedPropertyByService(undefined, null, intialize);
+                       intializeService();
+                   
                        $("#paramsRetry").on('click', function () {
                                //$("#paramsWarn").hide();
-                               var currentValue = $("#service").val() == null ? previous : $("#service").val();
+                               var currentValue = $("#service").val();
                                $("#ridinSpinners").css("display","")
                                var bool=loadSharedPropertyByService(currentValue);
                                $("#ridinSpinners").css("display","none")
                                $("#paramsWarn").hide();
                                
                        });
+                       
                })();
-//             $("#service").on("change",function(){
-//                     $("#ridinSpinners").css("display","")
-//                     loadSharedPropertyByService($(this).val())
-//                     $("#ridinSpinners").css("display","none")
-//             })
+               
                function noRepeats(form){
                        var select={};
                        for(var i=0;i<form.length;i++){
                                var f={}
                                f.name=s
                                f.value=select[s]
-                               arr.push(f)
+                               if (!(s=="service" && f.value=="")){
+                                       arr.push(f)
+                               }
                        }
                        return arr
                }
+           
+               $(function(){
+                       if (elementMap["global"]){
+                               for (var i=0; i< elementMap["global"].length; i++){
+                                       if (elementMap["global"][i]["name"]=="vf"){
+                                               oldVf = elementMap["global"][i]["value"];
+                                       }
+                               }
+                       } else {
+                               oldVf = "";
+                       }
+               });
+                       
+               function propChangeAlert(actionset){
+                       //throw warnings only if options were previously chosen
+                       if (elementMap["global"]){
+                               loop1: 
+                               for (var i=0; i< elementMap["global"].length; i++){
+                                       if (elementMap["global"][i]["name"] == actionset.id){
+                                               //user did not change properties                                                
+                                               if (elementMap["global"][i]["value"][0] == actionset.value){
+                                                       if (elementMap["global"][i]["name"] == "actionSet"){
+                                                               asDiff = false;
+                                                       } else if (elementMap["global"][i]["name"] == "service"){
+                                                               serDiff = false;
+                                                       }  else if (elementMap["global"][i]["name"] == "vf"){
+                                                               vfDiff = false;
+                                                       }
+                                                       if ((!vfDiff)&&(!asDiff)&&(!serDiff)){
+                                                               $(".propChangeWarn").hide();
+                                                       };
+                                               //user changed properties
+                                               } else { 
+                                                       if (elementMap["global"][i]["name"] == "actionSet"){
+                                                               asDiff = true;
+                                                       } else if (elementMap["global"][i]["name"] == "service"){
+                                                               serDiff = true;
+                                                       } else if (elementMap["global"][i]["name"] == "vf"){
+                                                               vfDiff = true;
+                                                       };
+                                                       $(".propChangeWarn").show();
+                                               }
+                                               break loop1;
+                                       }
+                               }
+                       }
+               }
                
                $("#saveProps").on('submit', function(event) {
                        saveGlobalProperties(noRepeats($(this).serializeArray()))
                        event.preventDefault();
                        
+                       //module reset, based on property updates
+                       if (elementMap["global"]){
+                               $.each(Object.keys(elementMap), function(i,v){
+                                       if ((v.match(/^Policy/)) && asDiff){
+                                               elementMap[v]={};
+                                       }
+                                       if ((v.match(/^TCA/)) && (vfDiff || serDiff)){
+                                               elementMap[v]={};
+                                       }
+                               });
+                       };
+                       
                        $("#close_button").click();
-
                })
+               
                $("#savePropsBtn").click(function(event) {
                        //alert($("#CProp_Target").val())
                        $("#saveProps").submit();
 
        </script>
 </div>
-