check in hello world xos dashboard
authorScott Baker <smbaker@gmail.com>
Tue, 15 Jul 2014 20:57:34 +0000 (13:57 -0700)
committerScott Baker <smbaker@gmail.com>
Tue, 15 Jul 2014 20:57:34 +0000 (13:57 -0700)
planetstack/core/xoslib/dashboards/helloworld.html [new file with mode: 0644]
planetstack/core/xoslib/static/js/helloworld.js [new file with mode: 0644]

diff --git a/planetstack/core/xoslib/dashboards/helloworld.html b/planetstack/core/xoslib/dashboards/helloworld.html
new file mode 100644 (file)
index 0000000..9b61487
--- /dev/null
@@ -0,0 +1,13 @@
+<!-- /opt/planetstack/templates/admin/dashboard/helloworld.html -->
+<div>Hello, {{ user.firstname }} {{ user.lastname }}.</div>
+<div>This is the hello world view. The value of foobar is {{ foobar }}.</div>
+<div id="dynamicTableOfInterestingThings"></div>
+<p>Type a new description for the the first slice in the collection:</p>
+<input type="text" name="newDescription" id="newDescription">
+<input type="button" name="submitNewDescription" value="submit new description"  id="submitNewDescription">
+
+<script src="{{ STATIC_URL }}/js/vendor/underscore-min.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.js"></script>
+<script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
+
+<script src="{{ STATIC_URL }}/js/helloworld.js"></script>
diff --git a/planetstack/core/xoslib/static/js/helloworld.js b/planetstack/core/xoslib/static/js/helloworld.js
new file mode 100644 (file)
index 0000000..1563094
--- /dev/null
@@ -0,0 +1,27 @@
+// helloworld.js
+function updateHelloWorldData() {
+    var html = "<table class='table table-bordered table-striped'>";
+    for (var slicekey in xos.slices.models) {
+        slice = xos.slices.models[slicekey]
+        html = html + "<tr><td>" + slice.get("name") + "</td><td>" + slice.get("description") + "</td></tr>";
+    }
+    html = html + "</table>";
+    $('#dynamicTableOfInterestingThings').html(html);
+}
+
+$(document).ready(function(){
+    xos.slices.on("change", function() { updateHelloWorldData(); });
+    xos.slices.on("remove", function() { updateHelloWorldData(); });
+    xos.slices.on("sort", function() { updateHelloWorldData();  });
+
+    xos.slices.startPolling();
+});
+
+// helloworld.js
+$(document).ready(function() {
+    $('#submitNewDescription').bind('click', function() {
+        newDescription = $("#newDescription").val();
+        xos.slices.models[0].set("description", newDescription);
+        xos.slices.models[0].save();
+    });
+});