tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1053825 - in /tuscany/sca-cpp/trunk/modules/edit: dashboard.py htdocs/edit/edit.html htdocs/edit/index.html htdocs/index.html htdocs/main/dashboard.html htdocs/main/index.html workspaces/joe@localhost
Date Thu, 30 Dec 2010 08:52:57 GMT
Author: jsdelfino
Date: Thu Dec 30 08:52:56 2010
New Revision: 1053825

URL: http://svn.apache.org/viewvc?rev=1053825&view=rev
Log:
Add logic to list, add, remove apps and link to the edit page.

Modified:
    tuscany/sca-cpp/trunk/modules/edit/dashboard.py
    tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html
    tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/index.html
    tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html
    tuscany/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html
    tuscany/sca-cpp/trunk/modules/edit/htdocs/main/index.html
    tuscany/sca-cpp/trunk/modules/edit/workspaces/joe@localhost

Modified: tuscany/sca-cpp/trunk/modules/edit/dashboard.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/dashboard.py?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/dashboard.py (original)
+++ tuscany/sca-cpp/trunk/modules/edit/dashboard.py Thu Dec 30 08:52:56 2010
@@ -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)))
 

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/edit.html Thu Dec 30 08:52:56 2010
@@ -35,34 +35,41 @@ var editWidget = sca.component("EditWidg
 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>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/index.html?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/edit/index.html Thu Dec 30 08:52:56 2010
@@ -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>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/index.html Thu Dec 30 08:52:56 2010
@@ -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>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/main/dashboard.html Thu Dec 30 08:52:56 2010
@@ -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>

Modified: tuscany/sca-cpp/trunk/modules/edit/htdocs/main/index.html
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/htdocs/main/index.html?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/htdocs/main/index.html (original)
+++ tuscany/sca-cpp/trunk/modules/edit/htdocs/main/index.html Thu Dec 30 08:52:56 2010
@@ -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>

Modified: tuscany/sca-cpp/trunk/modules/edit/workspaces/joe@localhost
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/edit/workspaces/joe%40localhost?rev=1053825&r1=1053824&r2=1053825&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/edit/workspaces/joe@localhost (original)
+++ tuscany/sca-cpp/trunk/modules/edit/workspaces/joe@localhost Thu Dec 30 08:52:56 2010
@@ -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 "ShoppingCar
 t/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



Mime
View raw message