Author: tyrell
Date: Fri Dec  7 10:52:38 2007
New Revision: 10714

Log:

Integrating Service Start/Stop functionality.

Modified:
   trunk/mashup/java/modules/www/org/js/mashup-editor.js
   trunk/mashup/java/modules/www/org/js/mashup-utils.js
   trunk/mashup/java/modules/www/org/js/services.js
   trunk/mashup/java/modules/www/org/mashup.jsp

Modified: trunk/mashup/java/modules/www/org/js/mashup-editor.js
==============================================================================
--- trunk/mashup/java/modules/www/org/js/mashup-editor.js       (original)
+++ trunk/mashup/java/modules/www/org/js/mashup-editor.js       Fri Dec  7 
10:52:38 2007
@@ -416,7 +416,7 @@
 
             //Generating the Service Path
             var serviceUrl = self.location.protocol + "//" + 
self.location.hostname + ":" +
-                             self.location.port + "/" + SERVICE_PATH
+                             self.location.port + "/" + SERVICE_PATH;
 
             //Make sure the XMLHttpRequest object was instantiated
             if (xmlHttpRequest)

Modified: trunk/mashup/java/modules/www/org/js/mashup-utils.js
==============================================================================
--- trunk/mashup/java/modules/www/org/js/mashup-utils.js        (original)
+++ trunk/mashup/java/modules/www/org/js/mashup-utils.js        Fri Dec  7 
10:52:38 2007
@@ -837,3 +837,15 @@
     }
     else return false;
 };
+
+/**
+ * @description Handles the change to a service status. Updates the mashup 
list model, which propagates to the view.
+ * @method handleServiceStartStop
+ */
+WSO2.MashupUtils.handleServiceStartStop = function(serviceName, serviceState, 
callback) {
+    var params = new Array();
+    params[0] = serviceName;
+    params[1] = serviceState;
+
+    wso2.mashup.services.activationOfService(serviceName, serviceState, 
callback, params);
+};

Modified: trunk/mashup/java/modules/www/org/js/services.js
==============================================================================
--- trunk/mashup/java/modules/www/org/js/services.js    (original)
+++ trunk/mashup/java/modules/www/org/js/services.js    Fri Dec  7 10:52:38 2007
@@ -16,6 +16,8 @@
 
 var GLOBAL_SERVICE_STRING = "GlobalAdmin"
 var SERVICE_GROUP_ADMIN_STRING = "ServiceGroupAdmin"
+var serverURL = self.location.protocol + "//" + self.location.hostname + ":" +
+                self.location.port + "/" + SERVICE_PATH;
 
 if (typeof wso2 == "undefined") {
     /**

Modified: trunk/mashup/java/modules/www/org/mashup.jsp
==============================================================================
--- trunk/mashup/java/modules/www/org/mashup.jsp        (original)
+++ trunk/mashup/java/modules/www/org/mashup.jsp        Fri Dec  7 10:52:38 2007
@@ -475,14 +475,55 @@
                     <!--Will be available only to users with Admin priviledges 
OR who are Authors of the current Mashup-->
                     <% if ((RegistryUtils.isAdminRole(registry)) ||
                             
(author.equalsIgnoreCase(RegistryUtils.getCurrentUser(registry)))) { %>
-                    <li>
-                        <a href="#">Start|Stop this service</a>
+                    <li id="service-status">
+                        Service status not available
                     </li>
-                    <li>
-                        <a href="#"
-                           
onclick="wso2.mashup.services.getServiceDataForEditor('<%=mashup%>', 
wso2.mashup.populateServiceEditor);">Edit
-                            this service</a>
+                    <li id="edit-service">
+                        Service editing is not available
                     </li>
+
+                    <script type="text/javascript">
+                        //Getting the Current status of the service
+                        function handleServiceStartStopCallback() {
+                            var params = this.params;
+                            var serviceState = params[1];
+
+                            if (serviceState) {
+                                
document.getElementById("service-status").innerHTML =
+                                "Service started. [<a href='#' 
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", false, 
handleServiceStartStopCallback)'>Stop</a>]"
+                                //Enabling service editing
+                                
document.getElementById("edit-service").innerHTML =
+                                '<a href="#" 
onclick="wso2.mashup.services.getServiceDataForEditor(\'<%=mashup%>\', 
wso2.mashup.populateServiceEditor);">Edit this service</a>'
+                            } else {
+                                
document.getElementById("service-status").innerHTML =
+                                "Service stopped. [<a href='#' 
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", true, 
handleServiceStartStopCallback)'>Start</a>]"
+                                //Disabling service editing
+                                
document.getElementById("edit-service").innerHTML =
+                                "Service editing is not available"
+                            }
+                        }
+
+                        function listServiceDataCallback() {
+                            var xmlBodyContent = 
this.req.responseXML.getElementsByTagName("return")[0];
+                            var serviceMashupObject = 
WSO2.MashupUtils.generateMashupFromXml(xmlBodyContent);
+
+                            if (serviceMashupObject.getServiceStatus() == 
"true") {
+                                
document.getElementById("service-status").innerHTML =
+                                "Service started. [<a href='#' 
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", false, 
handleServiceStartStopCallback)'>Stop</a>]"
+                                //Enabling service editing
+                                
document.getElementById("edit-service").innerHTML =
+                                '<a href="#" 
onclick="wso2.mashup.services.getServiceDataForEditor(\'<%=mashup%>\', 
wso2.mashup.populateServiceEditor);">Edit this service</a>'
+                            } else {
+                                
document.getElementById("service-status").innerHTML =
+                                "Service stopped. [<a href='#' 
onclick='WSO2.MashupUtils.handleServiceStartStop(\"<%=mashup%>\", true, 
handleServiceStartStopCallback)'>Start</a>]"
+                                //Disabling service editing
+                                
document.getElementById("edit-service").innerHTML =
+                                "Service editing is not available"
+                            }
+                        }
+
+                        wso2.mashup.services.listServiceData('<%=mashup%>', 
listServiceDataCallback);
+                    </script>
                     <%}%>
                     <li>
                         <a href="#" 
onclick="WSO2.MashupUtils.showCreateMashupDialog();">Create a

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

Reply via email to