Author: tyrell
Date: Fri Jan 11 01:39:12 2008
New Revision: 12143

Log:

Adding the mashup download dialog.

Modified:
   trunk/mashup/java/modules/www/css/mashup-main.css
   trunk/mashup/java/modules/www/js/mashup-utils.js
   trunk/mashup/java/modules/www/mashup.jsp

Modified: trunk/mashup/java/modules/www/css/mashup-main.css
==============================================================================
--- trunk/mashup/java/modules/www/css/mashup-main.css   (original)
+++ trunk/mashup/java/modules/www/css/mashup-main.css   Fri Jan 11 01:39:12 2008
@@ -100,4 +100,27 @@
 pre {
     white-space: -moz-pre-wrap !important; /* Mozilla */
     word-wrap: break-word; /* IE 5.5+ */
-}
\ No newline at end of file
+}
+
+.diaLogTitle{
+       font-family: Arial, Helvetica, sans-serif;
+       font-size:10pt;
+       color:#FFFFFF;
+       font-weight:bold;
+       background-image:url(../images/w_top_bg.gif);
+
+}
+
+#d_Body{
+       border-right-width: 2px;
+       border-bottom-width: 2px;
+       border-left-width: 1px;
+       border-right-style: solid;
+       border-bottom-style: solid;
+       border-left-style: solid;
+       border-right-color: #96A64B;
+       border-bottom-color: #96A64B;
+       border-left-color: #96A64B;
+       padding: 5px;
+       background-color: #E7F3AF;
+}

Modified: trunk/mashup/java/modules/www/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/js/mashup-utils.js    (original)
+++ trunk/mashup/java/modules/www/js/mashup-utils.js    Fri Jan 11 01:39:12 2008
@@ -149,59 +149,59 @@
     var parent = document.createElement("div");
     parent.setAttribute("id", "MashupSharingDialog");
 
-  var strFrmService = '<br><table align="center" border="0">'+
-       '<tr><td width="170">Destination Server Address</td><td><input 
name="txtDestAddress" type="text" id="txtDestAddress" 
value="http://mashups.wso2.org"; size="50"/></td></tr>'+
-       '<tr><td>Destination Server Username</td><td><input 
name="txtDestUsername" type="text" id="txtDestUsername" size="50"/></td></tr>'+
-       '<tr><td>Destination Server Password</td><td><input 
name="txtDestPassword" type="password" id="txtDestPassword" 
size="50"/></td></tr>'+
-       '<tr><td><label id="lblStatus"></label></td></tr>'+
-       '</table>';
-       
-/*
-    var lblDestAddress = document.createElement("label");
-    lblDestAddress.appendChild(document.createTextNode("Destination Server 
Address   "));
-    parent.appendChild(lblDestAddress);
-
-    var txtDestServerAddress = document.createElement("input");
-    txtDestServerAddress.setAttribute("type", "text");
-    txtDestServerAddress.setAttribute("id", "txtDestAddress");
-    txtDestServerAddress.setAttribute("value", "http://mashups.wso2.org";);
-    txtDestServerAddress.setAttribute("size", "50");
-    parent.appendChild(txtDestServerAddress);
-
-    parent.appendChild(document.createElement("br"));
-    parent.appendChild(document.createElement("br"));
-
-    var lblUsername = document.createElement("label");
-    lblUsername.appendChild(document.createTextNode("Destination Server 
Username   "));
-    parent.appendChild(lblUsername);
-
-    var txtDestServerUsername = document.createElement("input");
-    txtDestServerUsername.setAttribute("type", "text");
-    txtDestServerUsername.setAttribute("id", "txtDestUsername");
-    txtDestServerUsername.setAttribute("size", "50");
-    parent.appendChild(txtDestServerUsername);
-
-    parent.appendChild(document.createElement("br"));
-    parent.appendChild(document.createElement("br"));
-
-    var lblPassword = document.createElement("label");
-    lblPassword.appendChild(document.createTextNode("Destination Server 
Password   "));
-    parent.appendChild(lblPassword);
-
-
-    var txtDestServerPassword = document.createElement("input");
-    txtDestServerPassword.setAttribute("type", "password");
-    txtDestServerPassword.setAttribute("id", "txtDestPassword");
-    txtDestServerPassword.setAttribute("size", "50");
-    parent.appendChild(txtDestServerPassword);
-
-    parent.appendChild(document.createElement("br"));
-    parent.appendChild(document.createElement("br"));
-
-    var lblStatusMessages = document.createElement("label");
-    lblStatusMessages.setAttribute("id", "lblStatus");
-    parent.appendChild(lblStatusMessages);
-*/
+    var strFrmService = '<br><table align="center" border="0">' +
+                        '<tr><td width="170">Destination Server 
Address</td><td><input name="txtDestAddress" type="text" id="txtDestAddress" 
value="http://mashups.wso2.org"; size="50"/></td></tr>' +
+                        '<tr><td>Destination Server Username</td><td><input 
name="txtDestUsername" type="text" id="txtDestUsername" size="50"/></td></tr>' +
+                        '<tr><td>Destination Server Password</td><td><input 
name="txtDestPassword" type="password" id="txtDestPassword" 
size="50"/></td></tr>' +
+                        '<tr><td><label id="lblStatus"></label></td></tr>' +
+                        '</table>';
+
+    /*
+        var lblDestAddress = document.createElement("label");
+        lblDestAddress.appendChild(document.createTextNode("Destination Server 
Address   "));
+        parent.appendChild(lblDestAddress);
+
+        var txtDestServerAddress = document.createElement("input");
+        txtDestServerAddress.setAttribute("type", "text");
+        txtDestServerAddress.setAttribute("id", "txtDestAddress");
+        txtDestServerAddress.setAttribute("value", "http://mashups.wso2.org";);
+        txtDestServerAddress.setAttribute("size", "50");
+        parent.appendChild(txtDestServerAddress);
+
+        parent.appendChild(document.createElement("br"));
+        parent.appendChild(document.createElement("br"));
+
+        var lblUsername = document.createElement("label");
+        lblUsername.appendChild(document.createTextNode("Destination Server 
Username   "));
+        parent.appendChild(lblUsername);
+
+        var txtDestServerUsername = document.createElement("input");
+        txtDestServerUsername.setAttribute("type", "text");
+        txtDestServerUsername.setAttribute("id", "txtDestUsername");
+        txtDestServerUsername.setAttribute("size", "50");
+        parent.appendChild(txtDestServerUsername);
+
+        parent.appendChild(document.createElement("br"));
+        parent.appendChild(document.createElement("br"));
+
+        var lblPassword = document.createElement("label");
+        lblPassword.appendChild(document.createTextNode("Destination Server 
Password   "));
+        parent.appendChild(lblPassword);
+
+
+        var txtDestServerPassword = document.createElement("input");
+        txtDestServerPassword.setAttribute("type", "password");
+        txtDestServerPassword.setAttribute("id", "txtDestPassword");
+        txtDestServerPassword.setAttribute("size", "50");
+        parent.appendChild(txtDestServerPassword);
+
+        parent.appendChild(document.createElement("br"));
+        parent.appendChild(document.createElement("br"));
+
+        var lblStatusMessages = document.createElement("label");
+        lblStatusMessages.setAttribute("id", "lblStatus");
+        parent.appendChild(lblStatusMessages);
+    */
 
     YAHOO.util.Event.onContentReady('doc3', function() {
         // Instantiate the Dialog
@@ -671,151 +671,43 @@
  */
 WSO2.MashupUtils.showMashupDownloadingDialog = function (serviceName) {
 
-    //Creating the content div
-    var parent = document.createElement("div");
-    parent.setAttribute("id", "MashupDownloadDialog");
-
-    parent.appendChild(document.createElement("br"));
-
-    var lblIpAddress = document.createElement("label");
-    lblIpAddress.appendChild(document.createTextNode("Enter your mashup 
server's address "));
-    parent.appendChild(lblIpAddress);
-
-    parent.appendChild(document.createElement("br"));
-
-    var txtIpAddress = document.createElement("input");
-    txtIpAddress.setAttribute("type", "text");
-    txtIpAddress.setAttribute("id", "txtIpAddress");
-    txtIpAddress.setAttribute("size", "50");
-    parent.appendChild(txtIpAddress);
-
-    parent.appendChild(document.createElement("br"));
-    parent.appendChild(document.createElement("br"));
-
-    var lblStatusMessages = document.createElement("label");
-    lblStatusMessages.setAttribute("id", "lblStatus");
-    parent.appendChild(lblStatusMessages);
-
-
-    YAHOO.util.Event.onContentReady('doc3', function() {
-        // Instantiate the Dialog
-        var browser = WSRequest.util._getBrowser();
-        var serviceSharingDialog = "";
-
-        if (browser == "ie" || browser == "ie7") {
-            serviceSharingDialog = new 
YAHOO.widget.Dialog("MashupDownloadDialog",
-            {
-                width : "500px",
-                x:YAHOO.util.Dom.getViewportWidth() /
-                  8, //Manual fix for getting rubbish viewport dimensions in IE
-                y:100,
-                draggable:true,
-                visible : false,
-                modal:true,
-                close:false,
-                buttons : [ { text:"Submit", handler:handleSubmit, 
isDefault:true },
-                { text:"Close", handler:handleCancel } ]
-            });
-        } else {
-            serviceSharingDialog = new 
YAHOO.widget.Dialog("MashupDownloadDialog",
-            { width : "500px",
-                fixedcenter : true,
-                draggable:true,
-                visible : false,
-                constraintoviewport : true,
-                modal:true,
-                close:false,
-                buttons : [ { text:"Submit", handler:handleSubmit, 
isDefault:true },
-                { text:"Close", handler:handleCancel } ]
-            });
-        }
-
-        serviceSharingDialog.setHeader("Download Mashup [" + serviceName + 
"]");
-        serviceSharingDialog.setBody(parent);
-        serviceSharingDialog.render("content");
-        serviceSharingDialog.show();
-
-        // Event handlers for the Dialog
-        function handleSubmit() {
-            //get the remote host
-            var remoteServer = document.getElementById("txtIpAddress").value;
-
-            var labelElement = document.getElementById("lblStatus");
-
-            if ((WSO2.MashupUtils.trim(serviceName) != "") &&
-                (WSO2.MashupUtils.trim(remoteServer) != "")) {
-                labelElement.innerHTML = "";
-                labelElement.appendChild(document.createTextNode("Contacting 
backend services. Please wait..."));
-                wso2.mashup.services.downloadService(serviceName, 
remoteServer, submitServiceCallback, labelElement, submitServiceError);
-            }
-            else {
-                labelElement.innerHTML = "";
-                labelElement.appendChild(document.createTextNode("Please enter 
valid details ..."));
-            }
-
-        }
+    //Creating the form content
+    var downloadForm = '<form method="post" id="downloadForm" 
name="downloadForm" action="services/ServiceSharingHelper/downloadService">' +
+                       '<input id="txtRemoteServer" name="remoteServer" 
type="hidden">' +
+                       '<input size="10" id="txtServiceName" 
name="serviceName" type="hidden" value="' +
+                       serviceName + '">' +
+                       '<b><label>Your Mashup Server Admin User Name: 
</label></b><input size="40" name="username" type="text"> <br>' +
+                       '<b><label>Your Mashup Server Admin Password: 
&nbsp;&nbsp;</label></b><input size="40" name="password" type="password"> <br>' 
+
+                       '<b><label>Your Mashup Server Address: 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label></b><input
 size="40" name="name" type="text" value="https://localhost:7443/";> <br>' +
+                       '<br><br><input type="button" value="Download" 
onclick="WSO2.MashupUtils.makeMashupDownloadRequest();"/>' +
+                       '</form>';
 
-        function submitServiceCallback() {
-
-            var response ;
+    WSO2.MashupUtils.dialog("Download " + serviceName, downloadForm, 100, 100);
 
-            var browser = WSRequest.util._getBrowser();
-            if (browser == "ie" || browser == "ie7") {
-                response =
-                
this.req.responseXML.getElementsByTagName("ns:return")[0].firstChild.nodeValue;
-            } else {
-                response =
-                
this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue;
-            }
-
-            if (response == "true") {
-                this.params.innerHTML = "";
-                this.params.appendChild(document.createTextNode("The service 
was successfully downloaded. You can safely close this window."));
-
-            } else {
-                this.params.innerHTML = "";
-                this.params.appendChild(document.createTextNode("Failed to 
download the service. Please verify the destination address."));
-            }
-        }
+};
 
-        function submitServiceError() {
 
-            var error = this.req.error;
-            if (!error) {
-                this.params.innerHTML = "";
-                this.params.appendChild(document.createTextNode("Failed to 
download the service. Please refer to system admin for more details."));
-            }
+WSO2.MashupUtils.makeMashupDownloadRequest = function() {
+    function handleSuccess(o) {
+        WSO2.MashupUtils.dialog("Done", "The mashup was downloaded 
successfully.", 100, 100);
+    }
 
-            else if (error.reason.indexOf("Access Denied. Please login first") 
> -1) {
-                wso2.wsf.Util.alertMessage("Your session has expired.");
-                //Envoking force logout
-                wso2.mashup.services.logout(wso2.mashup.handleLogout);
-            }
+    function handleFailure(o) {
+        WSO2.MashupUtils.dialog("Error", "Failed to download the 
mashup.<br><br>" +
+                                         o.responseText, 100, 100);
+    }
 
-            else if (error.detail.indexOf("UnknownHostException") > -1) {
-                this.params.innerHTML = "";
-                this.params.appendChild(document.createTextNode("Failed to 
download the service. Unknown Host : '" +
-                                                                error.reason + 
"'"));
-            } else {
-                this.params.innerHTML = "";
-                this.params.appendChild(document.createTextNode("Failed to 
download the service. " +
-                                                                error.reason));
-            }
-        }
+    var callback =
+    {
+        success:handleSuccess,
+        failure:handleFailure
+    };
 
-        function handleCancel() {
-            this.cancel();
-            clearDom();
-        }
+    YAHOO.util.Connect.setForm("downloadForm");
+    YAHOO.util.Connect.asyncRequest('POST', 
'services/ServiceSharingHelper/downloadService', callback, null);
 
-        function clearDom() {
-            var dialogMask = 
document.getElementById("MashupDownloadDialog_mask");
-            dialogMask.parentNode.removeChild(dialogMask);
-            var dialogResedue = 
document.getElementById("MashupDownloadDialog_c");
-            dialogResedue.parentNode.removeChild(dialogResedue);
-        }
-    });
-};
+    WSO2.MashupUtils.dialog.close();
+}
 
 
 /**
@@ -884,3 +776,43 @@
 
     wso2.mashup.services.activationOfService(serviceName, serviceState, 
callback, params);
 };
+
+WSO2.MashupUtils.dialog = function(strTitle, strBody, width, height) {
+    if (document.getElementById('lyrDialog') == null) {
+
+        var x = (document.body.clientWidth - width) / 2;
+        var y = (document.body.clientHeight - height) / 2;
+        x = (x > 0) ? x : 0;
+        y = (y > 0) ? y : 0;
+                
+        document.body.innerHTML +=
+        '<div id="lyrDialog" style="position:absolute; left:' + x + 'px; top:' 
+ y +
+        'px; width:' + width + 'px; z-index:1">' +
+        '<table width="100%"  border="0" height="' + height +
+        '" cellspacing="0" cellpadding="0">' +
+        '<tr height="24">' +
+        '<td height="24" ><table width="100%" height="24" border="0" 
cellspacing="0" cellpadding="0">' +
+        '<tr height="24">' +
+        '<td width="18" height="24"><img 
src="images/w_small_top_left_edit.gif" width="18" height="24"></td>' +
+        '<td class="diaLogTitle" height="24">' + strTitle + '</td>' +
+        '<td width="17" height="24" class="diaLogTitle"><img 
src="images/w_top_close.gif" style="cursor: pointer;" 
onclick="WSO2.MashupUtils.dialog.close()" width="17" height="16"></td>' +
+        '<td width="9" height="24"><img src="images/w_top_right_edit.gif" 
width="9" height="24"></td>' +
+        '</tr>' +
+        '</table></td>' +
+        '</tr>' +
+        '<tr>' +
+        '<td id="d_Body" height="100%" valign="top">' + strBody + '</td>' +
+        '</tr>' +
+
+        '</table>' +
+        '</div>';
+
+    } else {
+        document.getElementById('lyrDialog').style.display = "block";
+    }
+};
+
+WSO2.MashupUtils.dialog.close = function() {
+    
document.getElementById('lyrDialog').parentNode.removeChild(document.getElementById('lyrDialog'));
+
+}
\ No newline at end of file

Modified: trunk/mashup/java/modules/www/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/mashup.jsp    (original)
+++ trunk/mashup/java/modules/www/mashup.jsp    Fri Jan 11 01:39:12 2008
@@ -100,6 +100,8 @@
 <script type="text/javascript" src="js/yui/tabview/tabview.js"></script>
 <script type="text/javascript" 
src="js/yui/yahoo-dom-event/yahoo-dom-event.js"></script>
 <script type="text/javascript" src="js/yui/utilities/utilities.js"></script>
+<script language="javascript" src="js/yui/connection/connection.js" 
type="text/javascript"></script>
+
 <!--YUI-EXT Dependencies-->
 <script type="text/javascript" src="js/yui-ext/yui-utilities.js"></script>
 <script type="text/javascript" src="js/yui-ext/ext-yui-adapter.js"></script>
@@ -432,6 +434,11 @@
         the scraping assistant</a>
 </li>
 <li>
+    <a href="#"
+       
onclick="WSO2.MashupUtils.showMashupDownloadingDialog('<%=mashupServiceName%>');">Download
+        this mashup</a>
+</li>
+<li>
     <a href="stub_gen.jsp" target="_blank">Use the Java Script Stub 
Generator</a>
 </li>
 <%}%>

_______________________________________________
Mashup-dev mailing list
[email protected]
http://www.wso2.org/cgi-bin/mailman/listinfo/mashup-dev

Reply via email to