summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-cpp/trunk/modules/edit/dashboard.py8
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/edit/edit.html57
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/edit/index.html32
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/index.html6
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html100
-rw-r--r--sca-cpp/trunk/modules/edit/htdocs/main/index.html1
-rw-r--r--sca-cpp/trunk/modules/edit/workspaces/joe@localhost2
7 files changed, 144 insertions, 62 deletions
diff --git a/sca-cpp/trunk/modules/edit/dashboard.py b/sca-cpp/trunk/modules/edit/dashboard.py
index c93924b68e..990476a84e 100644
--- a/sca-cpp/trunk/modules/edit/dashboard.py
+++ b/sca-cpp/trunk/modules/edit/dashboard.py
@@ -34,7 +34,7 @@ def getworkspace(id, cache):
# Post a new app to the user's workspace
def post(collection, app, user, cache):
id = (str(uuid.uuid1()),)
- workspace = cons((car(app), id, caddr(app)), getworkspace(workspaceid(user), cache))
+ workspace = cons((car(app), car(id), caddr(app)), getworkspace(workspaceid(user), cache))
cache.put(workspaceid(user), workspace)
return id
@@ -56,13 +56,13 @@ def get(id, user, cache):
def findapp(id, workspace):
if isNil(workspace):
return None
- if id == cadr(car(workspace)):
+ if car(id) == cadr(car(workspace)):
return car(workspace)
return findapp(id, cdr(workspace))
if isNil(id):
return ("Your Apps", user.id()) + getworkspace(workspaceid(user), cache)
- return findapp(car(id), getworkspace(workspaceid(user), cache))
+ return findapp(id, getworkspace(workspaceid(user), cache))
# Delete apps from the user's workspace
def delete(id, user, cache):
@@ -72,7 +72,7 @@ def delete(id, user, cache):
def deleteapp(id, workspace):
if isNil(workspace):
return ()
- if id == cadr(car(workspace)):
+ if car(id) == cadr(car(workspace)):
return cdr(workspace)
return cons(car(workspace), deleteapp(id, cdr(workspace)))
diff --git a/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html b/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html
index 5e1e41bf5c..91910ab292 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html
@@ -35,34 +35,41 @@ var editWidget = sca.component("EditWidget");
var dashboard = sca.reference(editWidget, "dashboard");
var apps = sca.reference(editWidget, "apps");
-if (false) {
-dashboard.get('', function(doc) {
- var entries = cddr(atom.readATOMFeedDocument(doc));
- var entry = car(entries);
- var item = caddr(entry);
- var composite = cddr(item);
- var comps = scdl.components(composite);
-
- var g = graph.mkgraph();
- var shapes = graph.composite(composite);
- log(shapes);
- for (var s in shapes)
- g.appendChild(shapes[s]);
-});
+/**
+ * Return the current app name.
+ */
+function appname() {
+ var qs = window.location.toString().split('?');
+ if (isNil(cdr(qs)))
+ return null;
+ var p = cadr(qs).split('=');
+ if (isNil(p) || isNil(cdr(p)))
+ return null;
+ return cadr(p);
}
-apps.get('store', function(doc) {
- var entry = atom.readATOMEntryDocument(doc);
- var item = caddr(entry);
- var composite = cddr(item);
- var comps = scdl.components(composite);
+/**
+ * Get an app and display it.
+ */
+function getapp(name) {
+ if (name == null)
+ return;
+ apps.get(name, function(doc) {
+ var entry = atom.readATOMEntryDocument(doc);
+ var item = caddr(entry);
+ var composite = cddr(item);
+ var comps = scdl.components(composite);
+
+ var g = graph.mkgraph();
+ var shapes = graph.composite(composite);
+ log(shapes);
+ for (var s in shapes)
+ g.appendChild(shapes[s]);
+ });
+}
- var g = graph.mkgraph();
- var shapes = graph.composite(composite);
- log(shapes);
- for (var s in shapes)
- g.appendChild(shapes[s]);
-});
+// Display the current app
+getapp(appname());
</script>
</body>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/edit/index.html b/sca-cpp/trunk/modules/edit/htdocs/edit/index.html
index 7cdfcd81a4..d5df8bc678 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/edit/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/edit/index.html
@@ -24,9 +24,39 @@
<script type="text/javascript" src="/ui.js"></script>
</head>
<body>
-<iframe id="editFrame" src="edit.html" style="visibility: visible; height: 100%; width: 100%; border: 0px;" scrolling="no" frameborder="0"></iframe>
+<h1><span id="titleDiv"></span></h1>
+<div id="editDiv"></div>
<script type="text/javascript">
+/**
+ * Return the current app name.
+ */
+function appname() {
+ var qs = window.location.toString().split('?');
+ if (isNil(cdr(qs)))
+ return null;
+ var p = cadr(qs).split('=');
+ if (isNil(p) || isNil(cdr(p)))
+ return null;
+ return cadr(p);
+}
+
+/**
+ * Display the editor for an app.
+ */
+function editapp(name) {
+ if (name == null)
+ return;
+ $('titleDiv').innerHTML = 'Editing: ' + name;
+ $('editDiv').innerHTML =
+ '<iframe id="editFrame" style="visibility: visible; height: 100%; width: 100%; border: 0px;" scrolling="no" frameborder="0" src="edit.html?' +
+ 'app=' + name +
+ '"></iframe>';
+}
+
+// Display the editor for the current app
+editapp(appname());
+
</script>
</body>
</html>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/index.html b/sca-cpp/trunk/modules/edit/htdocs/index.html
index 3c18fdbd47..dffcf2d416 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/index.html
@@ -27,11 +27,11 @@
<h1>App Edit Tools</h1>
<p>This module implements simple tools to help you create Tuscany apps.</p>
-<h2>App Dashboard</h1>
+<h2>App Dashboard</h2>
<p>Try the <a href="main">App Dashboard</a> to manage your collection of apps.</p>
-<h2>App Editor</h1>
-<p>Try the <a href="edit">App Editor</a> to edit an app.</p>
+<h2>App Editor</h2>
+<p>Try the <a href="edit/?app=store">App Editor</a> to edit an app.</p>
</body>
</html>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html b/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html
index a5e5b12aef..b69c760c99 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html
@@ -45,8 +45,8 @@
<br>
<table>
-<tr><td>App name:</td><td><input type="text" name="appName" size="50"/></td></td><td>e.g. mycoolapp</td></tr>
-<tr><td>Title:</td><td><input type="text" name="appTitle" size="50"/></td></td><td>e.g. My really cool app</td></tr>
+<tr><td>App name:</td><td><input type="text" id="appName" size="50"/></td></td><td>e.g. mycoolapp</td></tr>
+<tr><td>Title:</td><td><input type="text" id="appTitle" size="50"/></td></td><td>e.g. My really cool app</td></tr>
</table>
<input id="addAppButton" type="button" value="Add"/>
</form>
@@ -55,50 +55,94 @@
</div>
<script type="text/javascript">
+// Install the widget
ui.installwidget();
+// Init service references
var editWidget = sca.component("EditWidget");
var dashboard = sca.reference(editWidget, "dashboard");
-// Get and display list of apps
-dashboard.get('', function(doc) {
- var apps = '';
- apps += '<table width="100%">';
- apps += '<tr><th>App</th><th>Title</th></tr>';
-
- var entries = cddr(atom.readATOMFeedDocument(doc));
- for (var i = 0; i < length(entries); i++) {
- var entry = entries[i];
- var item = caddr(entry);
- var composite = cddr(item);
- var comps = scdl.components(composite);
-
- name = cadr(entry);
- title = car(entry);
-
- apps += '<tr>';
- apps += '<td><input name="apps" type="checkbox" value="' + name + '">' + '<a href=\"' + '/edit/?app=' + name + '\">' + name + '</a></td>';
- apps += '<td class="tdw">' + title + '</td>';
- apps += '</tr>';
+/**
+ * Get and display list of apps.
+ */
+function getapps(sync) {
+ function display(doc) {
+ var apps = '';
+ apps += '<table width="100%">';
+ apps += '<tr><th>App</th><th>Title</th></tr>';
+
+ var entries = cddr(atom.readATOMFeedDocument(doc));
+ for (var i = 0; i < length(entries); i++) {
+ var entry = entries[i];
+ var item = caddr(entry);
+ var composite = cddr(item);
+ var comps = scdl.components(composite);
+
+ name = cadr(entry);
+ title = car(entry);
+
+ apps += '<tr>';
+ apps += '<td><input name="apps" type="checkbox" value="' + name + '">' + '<a href=\"' + '/edit/?app=' + name + '\">' + name + '</a></td>';
+ apps += '<td class="tdw">' + title + '</td>';
+ apps += '</tr>';
+ }
+ apps += '</table>';
+ $('apps').innerHTML = apps;
}
- apps += '</table>';
- $('apps').innerHTML = apps;
-});
+ if (sync) {
+ display(dashboard.get(''));
+ } else {
+ dashboard.get('', function(doc) {
+ display(doc);
+ });
+ }
+}
-// Toggle new app form
+/**
+ * Toggle new app form link event.
+ */
$('addAppLink').onclick = function() {
var div = $('newApp');
div.style.visibility = div.style.visibility == 'hidden'? 'visible' : 'hidden';
return false;
};
-// Add a new app
+/**
+ * Add a new app button event.
+ */
$('addAppButton').onclick = function() {
- alert('Add new app');
+ var name = $('appName').value;
+ var title = $('appTitle').value;
+ var app = mklist(title, name, mklist());
+ var entry = atom.writeATOMEntry(app);
+ dashboard.put(name, car(entry));
+ getapps();
return false;
};
+/**
+ * Delete apps event.
+ */
+$('deleteAppLink').onclick = function() {
+ var apps = $('appsForm').apps;
+ if (isNil(apps))
+ return false;
+ if (isNil(apps.length))
+ apps = mklist(apps);
+ for (var i = 0; i < length(apps); i++) {
+ if (apps[i].checked) {
+ var name = apps[i].value;
+ dashboard.del(name);
+ }
+ }
+ getapps();
+ return false;
+};
+
+// Get and display the list of apps
+getapps(true);
+
</script>
</body>
</html>
diff --git a/sca-cpp/trunk/modules/edit/htdocs/main/index.html b/sca-cpp/trunk/modules/edit/htdocs/main/index.html
index 13b2662645..6242309ab9 100644
--- a/sca-cpp/trunk/modules/edit/htdocs/main/index.html
+++ b/sca-cpp/trunk/modules/edit/htdocs/main/index.html
@@ -29,6 +29,7 @@
<iframe id="dashboardFrame" src="dashboard.html"></iframe>
<script type="text/javascript">
+// Display the dashboard widget
ui.bindwidget('dashboardFrame', 'dashboard');
</script>
</body>
diff --git a/sca-cpp/trunk/modules/edit/workspaces/joe@localhost b/sca-cpp/trunk/modules/edit/workspaces/joe@localhost
index d735651e40..7e36c9a5a1 100644
--- a/sca-cpp/trunk/modules/edit/workspaces/joe@localhost
+++ b/sca-cpp/trunk/modules/edit/workspaces/joe@localhost
@@ -1 +1 @@
-(("Sample Store App" "store" ((composite (@xmlns "http://docs.oasis-open.org/ns/opencsa/sca/200912") (@xmlns:t "http://tuscany.apache.org/xmlns/sca/1.1") (@targetNamespace "http://store") (@name "store") (component (((@name "Store") (@color "yellow") (t:implementation.python (@script "store.py")) (service (@name "Widget") (t:binding.http (@uri "store"))) (reference (((@name "catalog") (@target "Catalog")) ((@name "shoppingCart") (@target "ShoppingCart/Cart")) ((@name "shoppingTotal") (@target "ShoppingCart/Total"))))) ((@name "Catalog") (@color "green") (t:implementation.python (@script "fruits-catalog.py")) (property "USD") (service (@name "Catalog") (t:binding.jsonrpc (@uri "catalog"))) (reference (@name "currencyConverter") (@target "CurrencyConverter"))) ((@name "ShoppingCart") (@color "pink") (t:implementation.python (@script "shopping-cart.py")) (service (((@name "ShoppingCart") (t:binding.atom (@uri "shoppingCart"))) ((@name "Total") (t:binding.jsonrpc (@uri "total"))))) (reference (@name "cache") (@target "Cache") (@align "bottom"))) ((@name "CurrencyConverter") (@color "red") (t:implementation.python (@script "currency-converter.py")) (service (@name "CurrencyConverter") (t:binding.jsonrpc (@uri "currencyConverter")))) ((@name "Cache") (@color "blue") (implementation.cpp (@path "../../components/cache") (@library "libmemcache")) (service (@name "Cache") (@align "top") (t:binding.atom (@uri "cache"))) (property "localhost:11211")))))))("Another Store App" "store2" ((composite (@xmlns "http://docs.oasis-open.org/ns/opencsa/sca/200912") (@xmlns:t "http://tuscany.apache.org/xmlns/sca/1.1") (@targetNamespace "http://store") (@name "store") (component (((@name "Store") (@color "yellow") (t:implementation.python (@script "store.py")) (service (@name "Widget") (t:binding.http (@uri "store"))) (reference (((@name "catalog") (@target "Catalog")) ((@name "shoppingCart") (@target "ShoppingCart/Cart")) ((@name "shoppingTotal") (@target "ShoppingCart/Total"))))) ((@name "Catalog") (@color "green") (t:implementation.python (@script "fruits-catalog.py")) (property "USD") (service (@name "Catalog") (t:binding.jsonrpc (@uri "catalog"))) (reference (@name "currencyConverter") (@target "CurrencyConverter"))) ((@name "ShoppingCart") (@color "pink") (t:implementation.python (@script "shopping-cart.py")) (service (((@name "ShoppingCart") (t:binding.atom (@uri "shoppingCart"))) ((@name "Total") (t:binding.jsonrpc (@uri "total"))))) (reference (@name "cache") (@target "Cache") (@align "bottom"))) ((@name "CurrencyConverter") (@color "red") (t:implementation.python (@script "currency-converter.py")) (service (@name "CurrencyConverter") (t:binding.jsonrpc (@uri "currencyConverter")))) ((@name "Cache") (@color "blue") (implementation.cpp (@path "../../components/cache") (@library "libmemcache")) (service (@name "Cache") (@align "top") (t:binding.atom (@uri "cache"))) (property "localhost:11211"))))))))
+(("Sample Online Store App" "store" ()) ("Sample HTTP Relay App" "relay" ())) \ No newline at end of file