summaryrefslogtreecommitdiffstats
path: root/sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html
diff options
context:
space:
mode:
authornash <nash@13f79535-47bb-0310-9956-ffa450edef68>2010-08-24 11:26:41 +0000
committernash <nash@13f79535-47bb-0310-9956-ffa450edef68>2010-08-24 11:26:41 +0000
commitd1f056a0126252f101d108ad2952ac0eebb78cb0 (patch)
tree6d284afe78fb3af0cd721e9d7a6fe4d79818d91e /sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html
parentde5a3e20aa493e9bfad8ea32deb2f3bd7e4ff2be (diff)
Copy 1.6 release to new 1.6.1 branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@988487 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html')
-rw-r--r--sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html408
1 files changed, 408 insertions, 0 deletions
diff --git a/sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html b/sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html
new file mode 100644
index 0000000000..1936f9896c
--- /dev/null
+++ b/sca-java-1.x/branches/sca-java-1.6.1/modules/domain-manager/src/main/resources/cloud-gadget.html
@@ -0,0 +1,408 @@
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html>
+<head>
+<title>SCA Domain - Cloud</title>
+
+<script type="text/javascript" src="../cloud-gadget/cloud-gadget.js"></script>
+<script type="text/javascript" src="utils.js"></script>
+
+<link rel="stylesheet" type="text/css" href="manager.css">
+</head>
+
+<body>
+ <div id="cloudComposite">
+
+ <form id="cloudCompositeForm">
+ <div id="composites" ></div>
+ <br>
+ &gt;<a href="" id="addNodeLink">Add</a>
+ &nbsp;<a href="" id="deleteNodeLink">Delete</a>
+ &nbsp;&nbsp;
+ <a href="" id="startNodeLink">Start</a>
+ &nbsp;<a href="" id="stopNodeLink">Stop</a>
+ </form>
+
+ <div id="newNode" style="visibility: hidden;">
+ <form id="newNodeForm">
+ <table width="100%">
+ <tr><th>Add a Node</th></tr>
+ <tr><td>Add a node to the cloud. The node will run the SCA components declared in the specified composite.</td></tr>
+ </table>
+ <br>
+ <table>
+ <tr><td>Node name:</td><td><input type="text" name="nodeName" size="50"/></td><td>e.g. YourNode</td></tr>
+ <tr><td>Node URI:</td><td><input type="text" name="nodeURI" size="50"/></td></td><td>e.g. http://yourhost:8080</td></tr>
+ <tr><td>Composite namespace:</td><td><input type="text" name="compositeNamespace" size="50"/></td></td><td>e.g. http://your/namespace</td></tr>
+ <tr><td>Composite name:</td><td><input type="text" name="compositeName" size="50"/></td></td><td>e.g. yourcomposite</td></tr>
+ <tr><td>Contribution URI:</td><td><input type="text" name="contributionURI" size="50"/></td></td><td>e.g. yourcontrib, http://yourcontrib</td></tr>
+ </table>
+ <input id="addNodeButton" type="button" value="Add" />
+ </form>
+ </div>
+
+ </div>
+</body>
+
+<script type="text/javascript">
+
+ //@Reference
+ var cloudComposite = new tuscany.sca.Reference("cloudComposite");
+
+ //@Reference
+ var domainComposite = new tuscany.sca.Reference("domainComposite");
+
+ //@Reference
+ var processCollection = new tuscany.sca.Reference("processCollection");
+
+ var gadget = gadget(window, document);
+ if (gadget.showStatus == null) {
+ gadget.showStatus = true;
+ }
+ if (gadget.showConfigurations == null) {
+ gadget.showConfigurations = true;
+ }
+
+ var cloudCompositeForm = elementByID(gadget, 'cloudCompositeForm');
+ var compositesElement = elementByID(gadget, 'composites');
+ var newNodeElement = elementByID(gadget, 'newNode');
+ var newNodeForm = elementByID(gadget, 'newNodeForm');
+
+ var nodeNames;
+ var deployedComposites = new Array();
+
+ function getNodes() {
+ cloudComposite.get("", getNodesResponse);
+ }
+
+ function contributionURI(id) {
+ var i = id.indexOf(';');
+ return id.substring(10, i);
+ }
+
+ function compositeName(id) {
+ var i = id.indexOf(';');
+ return id.substring(i + 1);
+ }
+
+ function compositeLocalName(id) {
+ name = compositeName(id);
+ var i = name.indexOf(';');
+ return name.substring(i + 1);
+ }
+
+ function getNodesResponse(feed) {
+ nodeNames = new Array();
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ var composites = "";
+ composites += '<table width="100%">';
+ composites += '<tr><th>Node</th>';
+ if (gadget.showStatus) {
+ composites += '<th>Status</th>';
+ }
+ if (gadget.showComposites) {
+ composites += '<th>Composite</th>';
+ }
+ if (gadget.showContributions) {
+ composites += '<th>Contribution</th>';
+ }
+ if (gadget.showConfigurations) {
+ composites += '<th>Node Config</th>';
+ }
+ composites += '</tr>';
+
+ for (var i=0; i<entries.length; i++) {
+ var nodeId = entries[i].getElementsByTagName("id")[0].firstChild.nodeValue;
+ var links = entries[i].getElementsByTagName("link");
+ var nodeLink = undefined;
+ var compositeLink = undefined;
+ var compositeId = "composite:undefined;undefined;undefined";
+ var uri = '<span style="color: red">unknown</span>';
+ var qname = undefined;
+ for (var l = 0; l < links.length; l++) {
+ var a = links[l].getAttribute('rel');
+ if (a == undefined) {
+ nodeLink = links[l].getAttribute('href');
+ } else if (a == 'related') {
+ compositeLink = links[l].getAttribute('href');
+ var c = compositeLink.indexOf('composite:');
+ compositeId = compositeLink.substring(c);
+ uri = contributionURI(compositeId);
+ qname = compositeName(compositeId);
+ }
+ }
+
+ var nodeName = compositeLocalName(nodeId);
+ nodeNames[i] = nodeName;
+
+ var content = "";
+ if (entries[i].getElementsByTagName("content")[0].firstChild != null) {
+ content = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
+ }
+
+ composites += '<tr>'
+ if (content.indexOf('<span id="problem"') != -1) {
+ composites += '<td><input name="composites" type="checkbox" value="' + nodeId + '">' +
+ '<a href=\"' + nodeLink + '\">' + nodeName + '</a></td>';
+ if (gadget.showStatus) {
+ composites += '<td><span id="status_' + nodeName + '">unknown</span></td>';
+ }
+ if (gadget.showComposites) {
+ composites += '<td>' + content + '</td>';
+ }
+ if (gadget.showContributions) {
+ composites += '<td>' + uri + '</td>';
+ }
+ } else {
+ composites += '<td><input name="composites" type="checkbox" value="' + nodeId + '">' +
+ '<a href=\"' + nodeLink + '\">' + nodeName + '</a></td>';
+ if (gadget.showStatus) {
+ composites += '<td><span id="status_' + nodeName + '">unknown</span></td>';
+ }
+ if (gadget.showComposites) {
+ composites += '<td><a href=\"' + compositeLink + '\">' + qname + '</a></td>';
+ }
+ if (gadget.showContributions) {
+ composites += '<td><a href="/contribution/' + uri + '">' + uri + '</a></td>';
+ }
+ }
+ if (gadget.showConfigurations) {
+ composites += '<td><a href="/node-config/' + nodeName + '"><img src="icons/feed-icon.png" border="0"></a></td>';
+ }
+ composites += '</tr>';
+ }
+ composites += '</table>';
+ compositesElement.innerHTML = composites;
+
+ processCollection.get("", getProcessesResponse);
+ }
+ }
+
+ function getProcessesResponse(feed) {
+ if (feed != null) {
+ var nodeStatus = new Array();
+
+ var entries = feed.getElementsByTagName("entry");
+ for (var i=0; i<entries.length; i++) {
+ var nodeName = entries[i].getElementsByTagName("id")[0].firstChild.nodeValue;
+ nodeStatus[nodeName] = 'started';
+ }
+
+ if (gadget.showStatus) {
+ for (var i = 0; i < nodeNames.length; i++) {
+ var element = elementByID(gadget, 'status_' + nodeNames[i]);
+ var nodeName = nodeNames[i];
+ if (nodeStatus[nodeName] == null) {
+ element.innerHTML = '<span>stopped</span>';
+ } else {
+ element.innerHTML = '<span><a style="color: green" href="/processes/?node=' + nodeName + '">started</a></span>';
+ }
+ }
+ }
+ }
+ }
+
+ function deleteNode() {
+ var composites = array(cloudCompositeForm.composites);
+ for (var i = 0; i < composites.length; i++) {
+ if (composites[i].checked) {
+ var id = composites[i].value;
+ cloudComposite.del(id, deleteNodeResponse);
+ }
+ }
+ return false;
+ }
+
+ function deleteNodeResponse() {
+ getNodes();
+ }
+
+ function addNode() {
+ var nodeName = newNodeForm.nodeName.value;
+ var nodeURI = newNodeForm.nodeURI.value;
+ var compositeNamespace = newNodeForm.compositeNamespace.value;
+ var compositeName = newNodeForm.compositeName.value;
+ var contributionURI = newNodeForm.contributionURI.value;
+ var id = 'composite:' +
+ 'http://tuscany.apache.org/cloud' + ';' +
+ 'http://tuscany.apache.org/cloud' + ';' +
+ nodeName;
+
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom">\n' +
+ '<id>' + id + '</id>\n' +
+ '<content type="text/xml">\n' +
+ '<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"\n' +
+ ' xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"\n' +
+ ' targetNamespace="http://tuscany.apache.org/cloud"\n' +
+ ' xmlns:c="' + compositeNamespace + '"\n' +
+ ' name="' + nodeName + '">\n' +
+ '\n' +
+ ' <component name="' + nodeName + '">\n' +
+ ' <t:implementation.node uri="' + contributionURI + '" composite="c:' + compositeName + '"/>\n' +
+ ' <service name="Node">\n' +
+ ' <binding.ws uri="' + nodeURI + '"/>\n' +
+ ' <t:binding.http uri="' + nodeURI + '"/>\n' +
+ ' <t:binding.jsonrpc uri="' + nodeURI + '"/>\n' +
+ ' <t:binding.atom uri="' + nodeURI + '"/>\n' +
+ ' </service>\n' +
+ ' </component>\n' +
+ '</composite>' +
+ '</content>' +
+ '</entry>';
+ cloudComposite.post(entry, addNodeResponse);
+ }
+
+ function addNodeResponse() {
+ newNodeForm.nodeName.value = "";
+ newNodeForm.nodeURI.value = "";
+ newNodeForm.compositeNamespace.value = "";
+ newNodeForm.compositeName.value = "";
+ newNodeForm.contributionURI.value = "";
+ getNodes();
+ }
+
+ function startNode() {
+ var composites = array(cloudCompositeForm.composites);
+ for (var i = 0; i < composites.length; i++) {
+ if (composites[i].checked) {
+ var id = nodeNames[i];
+
+ var entry = '<entry xmlns="http://www.w3.org/2005/Atom">' +
+ '<id>' + id + '</id>' +
+ '</entry>';
+ processCollection.post(entry, startNodeResponse);
+ }
+ }
+ return false;
+ }
+
+ function startNodeResponse() {
+ processCollection.get("", getProcessesResponse);
+
+ var composites = array(cloudCompositeForm.composites);
+ for (var i = 0; i < composites.length; i++) {
+ if (composites[i].checked) {
+ composites[i].checked = false;
+ }
+ }
+ }
+
+ function stopNode() {
+ var composites = array(cloudCompositeForm.composites);
+ for (var i = 0; i < composites.length; i++) {
+ if (composites[i].checked) {
+ var id = nodeNames[i];
+ processCollection.del(id, stopNodeResponse);
+ }
+ }
+ return false;
+ }
+
+ function stopNodeResponse() {
+ processCollection.get("", getProcessesResponse);
+
+ var composites = array(cloudCompositeForm.composites);
+ for (var i = 0; i < composites.length; i++) {
+ if (composites[i].checked) {
+ composites[i].checked = false;
+ }
+ }
+ }
+
+ function getComposites() {
+ domainComposite.get("", getCompositesResponse);
+ }
+
+ function getCompositesResponse(feed) {
+ if (feed != null) {
+ var entries = feed.getElementsByTagName("entry");
+ for (var i=0; i<entries.length; i++) {
+ var id = entries[i].getElementsByTagName("id")[0].firstChild.nodeValue;
+ deployedComposites[id] = id;
+ }
+ }
+ }
+
+ function suggestCompositeNamespaces() {
+ var namespaces = new Array();
+ for (var uri in deployedComposites) {
+ var qname = compositeName(uri);
+ var ns = qname.substring(0, qname.indexOf(';'));
+ namespaces[ns] = ns;
+ }
+ return array(namespaces);
+ }
+
+ function suggestCompositeNames() {
+ var inputns = newNodeForm.compositeNamespace.value;
+ var names = new Array();
+ for (var uri in deployedComposites) {
+ var qname = compositeName(uri);
+ var sc = qname.indexOf(';');
+ var ns = qname.substring(0, sc);
+ var name = qname.substring(sc + 1);
+ if (ns == inputns || inputns == "") {
+ names[name] = name;
+ }
+ }
+ return array(names);
+ }
+
+ function suggestContributionURIs() {
+ var inputns = newNodeForm.compositeNamespace.value;
+ var inputname = newNodeForm.compositeName.value;
+ var uris = new Array();
+ for (var uri in deployedComposites) {
+ var qname = compositeName(uri);
+ var sc = qname.indexOf(';');
+ var ns = qname.substring(0, sc);
+ var name = qname.substring(sc + 1);
+ if ((ns == inputns || inputns == "") && (name == inputname || inputname == "")) {
+ var curi = contributionURI(uri);
+ uris[curi] = curi;
+ }
+ }
+ return array(uris);
+ }
+
+ function toggleNewNode() {
+ var visibility = newNodeElement.style.visibility;
+ if (visibility == 'hidden') {
+ newNodeElement.style.visibility = 'visible';
+ } else {
+ newNodeElement.style.visibility = 'hidden';
+ }
+ return false;
+ }
+
+ elementByID(gadget, 'deleteNodeLink').onclick = deleteNode;
+ elementByID(gadget, 'addNodeLink').onclick = toggleNewNode;
+ elementByID(gadget, 'startNodeLink').onclick = startNode;
+ elementByID(gadget, 'stopNodeLink').onclick = stopNode;
+ elementByID(gadget, 'addNodeButton').onclick = addNode;
+
+ getNodes();
+ getComposites();
+ suggest(newNodeForm.compositeNamespace, suggestCompositeNamespaces);
+ suggest(newNodeForm.compositeName, suggestCompositeNames);
+ suggest(newNodeForm.contributionURI, suggestContributionURIs);
+
+</script>
+</html>