[mashup-dev] svn commit r3479 - in trunk/mashup/java/modules/www:
js/wso2 xslt
svn at wso2.org
svn at wso2.org
Mon Jun 4 01:30:55 PDT 2007
Author: tyrell
Date: Mon Jun 4 01:30:30 2007
New Revision: 3479
Modified:
trunk/mashup/java/modules/www/js/wso2/mashup-widget-helper.js
trunk/mashup/java/modules/www/js/wso2/mashup.js
trunk/mashup/java/modules/www/js/wso2/services.js
trunk/mashup/java/modules/www/xslt/MashupServiceList.xsl
Log:
Completing functionality of the MashupList in the UI.
Modified: trunk/mashup/java/modules/www/js/wso2/mashup-widget-helper.js
==============================================================================
--- trunk/mashup/java/modules/www/js/wso2/mashup-widget-helper.js (original)
+++ trunk/mashup/java/modules/www/js/wso2/mashup-widget-helper.js Mon Jun 4 01:30:30 2007
@@ -156,16 +156,40 @@
*/
WSO2.MashupUtils.createListItem = function(xmlBodyContent) {
- var mashupsListITem = new wso2.mashup.MashupListItem('mashupListItem_' + WSO2.MashupUtils.listItemCount++, {visible:true,draggable:true});
+ var mashupsListItem = new wso2.mashup.MashupListItem('mashupListItem_' + WSO2.MashupUtils.listItemCount++, {visible:true,draggable:true});
var mashupActionHolder = document.createElement("div");
mashupActionHolder.id = 'serviceActionsDiv_' + WSO2.MashupUtils.listItemCount;
- mashupsListITem.setHeader(mashupActionHolder);
- mashupsListITem.render("mashuplist-box");
+ mashupsListItem.setHeader(mashupActionHolder);
+ mashupsListItem.render("mashuplist-box");
processXML(xmlBodyContent, URL + "/xslt/MashupServiceList.xsl", document.getElementById(mashupActionHolder.id), true);
};
+WSO2.MashupUtils.clearMashupList = function() {
+
+ //clear existing list, if applicable
+ var mashupListParent = document.getElementById("mashups_list");
+ mashupListParent.removeChild(document.getElementById("mashuplist-box"));
+
+ //re-creating the div
+ var mashupListBox = document.createElement("div");
+ mashupListBox.id = 'mashuplist-box';
+ mashupListBox.className = 'wso2-mashuplisBox';
+ mashupListParent.appendChild(mashupListBox);
+
+ //Attaching the title
+ var mashupTitle = document.createElement("div");
+ mashupTitle.className = "wso2-mashuplisBoxTitle";
+ var titleText = document.createTextNode("Available Services");
+ mashupTitle.appendChild(titleText);
+ mashupListBox.appendChild(mashupTitle);
+
+ //re-setting the list item count
+ WSO2.MashupUtils.listItemCount = 0;
+
+};
+
/**
* @description Display the service editor.
* @method showServiceEditor
@@ -176,15 +200,15 @@
var serviceEditor = new wso2.mashup.MashupEditor("mashupEditor_1", {
width: "60em",
monitorresize:true,
- /*effect:{effect:YAHOO.widget.ContainerEffect.FADE,
- duration:0.25},*/
+ /*effect:{effect:YAHOO.widget.ContainerEffect.FADE,
+ duration:0.25},*/
fixedcenter:true,
modal:true,
- draggable:true
+ draggable:true
});
serviceEditor.render("content");
- serviceEditor.Draw(xmlBodyContent);
+ serviceEditor.Draw(xmlBodyContent);
};
@@ -240,89 +264,5 @@
};
-/**
- * @description Add Wiget contain details about mashup to the container.
- * @method createWidget
- * @param {String} el The element ID representing the List Item <em>OR</em>
- * @param {HTMLElement} el The element representing the List Item
- * @param {String} bodyContent The HTML used to set the body of the List Item <em>OR</em>
- * @param {HTMLElement} bodyContent The HTMLElement to append to the body
- */
-
-WSO2.MashupUtils.prototype.getListOfServices = function(mashupsArray) {
- var body_xml = '<ns1:listServiceGroups xmlns:ns1="http://org.apache.axis2/xsd">\n' +
- ' </ns1:listServiceGroups>\n';
-
- //var callURL = serverURL + "/" + SERVICE_GROUP_ADMIN_STRING + "/" + "listServiceGroups";
-
- var callURL = "https://10.100.1.170:9443/services" + "/" + SERVICE_GROUP_ADMIN_STRING + "/" + "listServiceGroups";
- WSO2.JSCommons.asyncSOAPRequest("listServiceGroups", callURL, this.listServiceCallBack, body_xml);
-
-};
-
-WSO2.MashupUtils.prototype.listServiceCallBack = function() {
- if (this.readyState == 4) {
-
- var resDOM = this.responseXML;
- var titles = resDOM.getElementsByTagName('services');
-
- for (var i = 0; i < titles.length; i++) {
- //alert(titles[i]);
- WSO2.MashupUtils.createListItem('mashuplist-box', titles[i].firstChild.nodeValue, "");
- WSO2.MashupUtils.getServiceData(titles[i].firstChild.nodeValue);
- }
-
- }
-
-};
-
-WSO2.MashupUtils.getServiceData = function(serviceName) {
- var body_xml = '<req:getServiceDataRequest xmlns:req="http://org.apache.axis2/xsd">\n' +
- ' <req:serviceName>' + serviceName + '</req:serviceName>\n' +
- ' </req:getServiceDataRequest>\n';
- var callURL = "https://10.100.1.170:9443/services" + "/" + "ServiceAdmin" + "/" ;
-
- //var callURL = serverURL + "/" + "ServiceAdmin" + "/" ;
-
- //send("getServiceData", body_xml, "", callURL, "", false, this.listServiceDataCallback);
- WSO2.JSCommons.asyncSOAPRequest("getServiceData", callURL, this.listServiceDataCallback, body_xml);
-};
-
-WSO2.MashupUtils.prototype.listServiceDataCallback = function(xhRe) {
- var resDOM = xhRe.responseXML;
-
- var wID = "wdgt_" + this._countW;
- var nameSvc = resDOM.getElementsByTagName('name')[0].firstChild.nodeValue;
- var eprs = resDOM.getElementsByTagName('eprs');
- var mas = new WSO2.Mashup(wID, nameSvc, null, eprs);
-
- WSO2.MashupUtils.createMashupWidget(mas);
-
-};
-
-
-/**@description This function get the real scope of the object and apply the function with real scope.
- *
- * @param {function} fn
- * @return {function} New function with real scope applied.
- */
-function getRealScope(fn) {
- var scope = window;
- if (fn._cscope) scope = fn._cscope;
- return function() {
- return fn.apply(scope, arguments);
- };
-}
-
-/**@description Bind the passed function to the object.
- *
- * @param {function} fn
- * @param {Object} obj
- * @return {function} new function with corrected scope.
- */
-function bind(fn, obj) {
- fn._cscope = obj;
- return getRealScope(fn);
-}
Modified: trunk/mashup/java/modules/www/js/wso2/mashup.js
==============================================================================
--- trunk/mashup/java/modules/www/js/wso2/mashup.js (original)
+++ trunk/mashup/java/modules/www/js/wso2/mashup.js Mon Jun 4 01:30:30 2007
@@ -114,27 +114,48 @@
wso2.mashup.showSimpleDialog("Login failed. Please recheck the user name and password and try again.", "warnicon");
},
- handleListServiceGroups : function() {
+ populateMashupsList : function() {
+
+ WSO2.MashupUtils.clearMashupList();
var serviceGroups = this.req.responseXML.getElementsByTagName("return");
for (var i = 0; i < serviceGroups.length; i++)
{
- WSO2.MashupUtils.createListItem(serviceGroups[i]);
+ // Extracting the service name
+ var nodes = serviceGroups[i].childNodes;
+ for (var j = 0; j < nodes.length; j++) {
+ if (nodes[j].nodeName == "services")
+ {
+ wso2.mashup.services.listServiceData(nodes[j].firstChild.nodeValue, wso2.mashup.buildListItem);
+ }
+ }
+
}
},
- handleListServiceData : function() {
+ buildListItem : function () {
+ var serviceDataXML = this.req.responseXML.getElementsByTagName("return")[0];
+ WSO2.MashupUtils.createListItem(serviceDataXML);
+ },
+
+
+ populateServiceEditor : function() {
var serviceData = this.req.responseXML.getElementsByTagName("return")[0];
WSO2.MashupUtils.showServiceEditor(serviceData);
},
+ handleServiceStart : function() {
+
+
+ },
+
createUI : function() {
- wso2.mashup.services.listServiceGroups(wso2.mashup.handleListServiceGroups);
+ wso2.mashup.services.listServiceGroups(wso2.mashup.populateMashupsList);
var panel = new wso2.mashup.MashupWidget("panel", {visible:true, draggable:true, close:true, minimize:true});
panel.setHeader("Hello World");
Modified: trunk/mashup/java/modules/www/js/wso2/services.js
==============================================================================
--- trunk/mashup/java/modules/www/js/wso2/services.js (original)
+++ trunk/mashup/java/modules/www/js/wso2/services.js Mon Jun 4 01:30:30 2007
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-wso2.mashup.services = {}
-
var GLOBAL_SERVICE_STRING = "GlobalAdmin"
var SERVICE_GROUP_ADMIN_STRING = "ServiceGroupAdmin"
+wso2.mashup.services = {}
+
/**
* @description Method used handle login operation to the admin console.
* @method login
@@ -100,6 +100,45 @@
var callURL = serverURL + "/" + "ServiceAdmin" + "/" ;
new wso2.wsf.WSRequest(callURL, "getServiceData", body_xml, callback);
+};
+
+
+/**
+ * @description Method used to activate/de-activate a service
+ * @method activationOfService
+ * @public
+ * @static
+ * @param {String} serviceName Name of the service to retrieve operations
+ * @param {boolean} serviceStatus The desired status of
+ * @param {callback} callBack User-defined callback function or object
+ */
+
+wso2.mashup.services.activationOfService = function (serviceName, serviceStatus, callback) {
+ var body_xml = '';
+ var callURL = serverURL + "/" + "ServiceAdmin" ;
+ var soapAction = "";
+
+ if (serviceStatus) {
+ body_xml = '<req:startServiceRequest xmlns:req="http://org.apache.axis2/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n' +
+ ' </req:startServiceRequest>\n';
+ soapAction = "startService";
+ }
+ if (!serviceStatus) {
+ body_xml = '<req:stopServiceRequest xmlns:req="http://org.apache.axis2/xsd">\n' +
+ ' <req:serviceName>' + serviceName + '</req:serviceName>\n' +
+ ' </req:stopServiceRequest>\n';
+ soapAction = "stopService";
+
+ }
+ new wso2.wsf.WSRequest(callURL, soapAction, body_xml, callback);
+};
+
+wso2.mashup.services.defaultErrHandler = function () {
+
+ // do nothing :)
+
+ // TODO: Add logging here
};
Modified: trunk/mashup/java/modules/www/xslt/MashupServiceList.xsl
==============================================================================
--- trunk/mashup/java/modules/www/xslt/MashupServiceList.xsl (original)
+++ trunk/mashup/java/modules/www/xslt/MashupServiceList.xsl Mon Jun 4 01:30:30 2007
@@ -2,22 +2,62 @@
<xsl:template match="*">
+ <xsl:variable name="active">
+ <xsl:value-of select="active"/>
+ </xsl:variable>
+ <xsl:variable name="serviceDescription">
+ <xsl:value-of select="description"/>
+ </xsl:variable>
+ <xsl:variable name="serviceName">
+ <xsl:value-of select="name"/>
+ </xsl:variable>
+
<div>
<div class="wso2-mashuplistServiceTitle">
- <xsl:value-of select="services"/>
+ <xsl:value-of select="$serviceDescription"/>
</div>
<div class="wso2-mashuplisBody">
- <div style="dispaly:inline; float:left">Service started</div>
+ <xsl:if test="$active='true'">
+ <div style="dispaly:inline; float:left; color:green">Service started</div>
+ </xsl:if>
+ <xsl:if test="$active='false'">
+ <div style="dispaly:inline; float:left; color:red">Service stopped</div>
+ </xsl:if>
+
<div style="dispaly:inline; float:right">
<xsl:element name="img">
<xsl:attribute name="src">images/application_edit.gif</xsl:attribute>
- <xsl:attribute name="onclick">javascript:wso2.mashup.services.listServiceData('<xsl:value-of select="services"/>', wso2.mashup.handleListServiceData);
+ <xsl:attribute name="onclick">javascript:wso2.mashup.services.listServiceData('
+ <xsl:value-of select="$serviceName"/>
+ ', wso2.mashup.populateServiceEditor);
</xsl:attribute>
<xsl:attribute name="style">cursor:pointer;</xsl:attribute>
<xsl:attribute name="title">Edit Service</xsl:attribute>
</xsl:element>
- <img src="images/blank.gif" width="2" /><img src="images/control_play_blue.gif" title="Start Service" style="cursor:pointer;"/>
- <img src="images/blank.gif" width="2" /><img src="images/stop.gif" title="Stop Service" style="cursor:pointer;"/>
+ <img src="images/blank.gif" width="2"/>
+ <xsl:element name="img">
+ <xsl:attribute name="src">images/control_play_blue.gif</xsl:attribute>
+ <xsl:attribute name="title">Start Service</xsl:attribute>
+ <xsl:attribute name="style">cursor:pointer;</xsl:attribute>
+ <xsl:attribute name="onclick">
+ javascript:wso2.mashup.services.activationOfService('
+ <xsl:value-of select="$serviceName"/>
+ ',true);
+ javascript:wso2.mashup.services.listServiceGroups(wso2.mashup.populateMashupsList);
+ </xsl:attribute>
+ </xsl:element>
+ <img src="images/blank.gif" width="2"/>
+ <xsl:element name="img">
+ <xsl:attribute name="src">images/stop.gif</xsl:attribute>
+ <xsl:attribute name="title">Stop Service</xsl:attribute>
+ <xsl:attribute name="style">cursor:pointer;</xsl:attribute>
+ <xsl:attribute name="onclick">
+ javascript:wso2.mashup.services.activationOfService('
+ <xsl:value-of select="$serviceName"/>
+ ',false);
+ javascript:wso2.mashup.services.listServiceGroups(wso2.mashup.populateMashupsList);
+ </xsl:attribute>
+ </xsl:element>
</div>
</div>
More information about the Mashup-dev
mailing list