airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hes...@apache.org
Subject svn commit: r1405840 - /airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_json.js
Date Mon, 05 Nov 2012 15:37:59 GMT
Author: heshan
Date: Mon Nov  5 15:37:59 2012
New Revision: 1405840

URL: http://svn.apache.org/viewvc?rev=1405840&view=rev
Log:
Adding the js.

Added:
    airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_json.js

Added: airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_json.js
URL: http://svn.apache.org/viewvc/airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_json.js?rev=1405840&view=auto
==============================================================================
--- airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_json.js (added)
+++ airavata/sandbox/client-api-demo/src/main/webapp/x_host_descriptor_save_json.js Mon Nov
 5 15:37:59 2012
@@ -0,0 +1,99 @@
+function xmlToString(xml) {
+    var xmlData = $(xml);
+    var xmlString;
+    if (window.ActiveXObject) {
+        xmlString = xmlData.xml;
+    } else {
+        var oSerializer = new XMLSerializer();
+        xmlString = oSerializer.serializeToString(xmlData[0]);
+    }
+    console.log(xmlString);
+    return xmlString;
+}
+
+$(document).ready(function(){
+    $(window).load(function () {
+        $("div").hide();
+    });
+
+    $("select[name='drop1']").change(function() {
+        //alert($(this).val());
+        if("Local" == $(this).val()) {
+            $("div").hide();
+        } else {
+            $("div").show();
+        }
+    });
+
+    $('[name="saveHostButton"]').click(function(){
+        //alert($(this).val());
+        var hostName = $("#hostName1").val();
+        var hostAddress = $("#hostAddress1").val();
+        var hostEndpoint = $("#hostEndpoint1").val();
+        alert(hostEndpoint);
+        alert(hostEndpoint);
+        alert("hostEndpoint null  :" + hostEndpoint == null);
+        alert("hostEndpoint empty :" + hostEndpoint == "");
+        var gatekeeperEndpoint = $("#gatekeeperEndpoint1").val();
+        var xml = $('<type:hostDescription xmlns:type="http://schemas.airavata.apache.org/gfac/type"><type:hostName>'
+ hostName + '</type:hostName><type:hostAddress>' + hostAddress + '</type:hostAddress></type:hostDescription>');
+
+        var xmlData= $(xml);
+        var xmlString;
+        if (window.ActiveXObject){
+            xmlString = xmlData.xml;
+        } else {
+            var oSerializer = new XMLSerializer();
+            xmlString = oSerializer.serializeToString(xmlData[0]);
+        }
+        console.log(xmlString);
+
+        alert(hostName);
+        alert(hostAddress);
+        alert(xmlString);
+
+        if (("" == hostEndpoint) || ("" == gatekeeperEndpoint)) {
+            alert("if Case");
+            $.ajax({
+
+                beforeSend: function(x) {
+                    if (x && x.overrideMimeType) {
+                        x.overrideMimeType("application/j-son;charset=UTF-8");
+                    }
+                },
+
+                type: "POST",
+                dataType: "json",
+                contentType: "application/json;charset=utf-8",
+                url: "http://localhost:7080/airavata-registry-rest-services/registry/api/hostdescriptor/save",
+                data: JSON.stringify({
+                    "hostname": hostName,
+                    "hostAddress": hostAddress
+                })
+            }).done(function( msg ) {
+                    alert( "Data Saved: " + msg );
+                });
+        } else {
+            alert("end Case");
+            $.ajax({
+                beforeSend: function(x) {
+                    if (x && x.overrideMimeType) {
+                        x.overrideMimeType("application/j-son;charset=UTF-8");
+                    }
+                },
+                type: "POST",
+                dataType: "json",
+                contentType: "application/json;charset=utf-8",
+                url: "http://localhost:7080/airavata-registry-rest-services/registry/api/hostdescriptor/save",
+                data: JSON.stringify({
+                    "hostname": hostName,
+                    "hostAddress": hostAddress,
+                    "hostEndpoint" : hostEndpoint,
+                    "gatekeeperEndpoint" : gatekeeperEndpoint
+                })
+            }).done(function( msg ) {
+                    alert( "Data Saved: " + msg );
+                });
+        }
+
+    });
+});
\ No newline at end of file



Mime
View raw message