From 815adf95622e0d2a31383e9dc7469108db03597f Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Thu, 30 Dec 2010 08:52:56 +0000 Subject: Add logic to list, add, remove apps and link to the edit page. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1053825 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/edit/dashboard.py | 8 +- sca-cpp/trunk/modules/edit/htdocs/edit/edit.html | 57 ++++++------ sca-cpp/trunk/modules/edit/htdocs/edit/index.html | 32 ++++++- sca-cpp/trunk/modules/edit/htdocs/index.html | 6 +- .../trunk/modules/edit/htdocs/main/dashboard.html | 100 +++++++++++++++------ sca-cpp/trunk/modules/edit/htdocs/main/index.html | 1 + .../trunk/modules/edit/workspaces/joe@localhost | 2 +- 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()); 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 @@ - +

+
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 @@

App Edit Tools

This module implements simple tools to help you create Tuscany apps.

-

App Dashboard

+

App Dashboard

Try the App Dashboard to manage your collection of apps.

-

App Editor

-

Try the App Editor to edit an app.

+

App Editor

+

Try the App Editor to edit an app.

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 @@
- - + +
App name:e.g. mycoolapp
Title:e.g. My really cool app
App name:e.g. mycoolapp
Title:e.g. My really cool app
@@ -55,50 +55,94 @@ 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 @@ 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 -- cgit v1.2.3