xosAdminSite, WIP
diff --git a/planetstack/core/xoslib/dashboards/xosAdminSite.html b/planetstack/core/xoslib/dashboards/xosAdminSite.html
new file mode 100644
index 0000000..5288d87
--- /dev/null
+++ b/planetstack/core/xoslib/dashboards/xosAdminSite.html
@@ -0,0 +1,45 @@
+<script src="{{ STATIC_URL }}/js/vendor/underscore-min.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.syphon.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.wreqr.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.babysitter.js"></script>
+<script src="{{ STATIC_URL }}/js/vendor/backbone.marionette.js"></script>
+
+<link rel="stylesheet" type="text/css" href="{% static 'css/xosAdminSite.css' %}" media="all" >
+
+<script src="{{ STATIC_URL }}/js/xoslib/xos-backbone.js"></script>
+<script src="{{ STATIC_URL }}/js/xoslib/xosHelper.js"></script>
+<script src="{{ STATIC_URL }}/js/xosAdminSite.js"></script>
+
+<div id="headerPanel">
+header
+</div>
+
+<div id="navigationPanel">
+nav
+</div>
+
+<div id="contentPanel">
+content
+
+<div id="detailBox">
+<div id="detail"></div>
+<div id="linkedObjs1"></div>
+<div id="linkedObjs2"></div>
+<div id="linkedObjs3"></div>
+<div id="linkedObjs4"></div>
+</div>
+
+</div>
+
+<div id="logPanel">
+log
+
+<div id="successBox">
+</div>
+<div id="errorBox">
+</div>
+
+</div>
+
+{% include 'xosAdmin.html' %}
diff --git a/planetstack/core/xoslib/static/css/xosAdminSite.css b/planetstack/core/xoslib/static/css/xosAdminSite.css
new file mode 100644
index 0000000..e73a51f
--- /dev/null
+++ b/planetstack/core/xoslib/static/css/xosAdminSite.css
@@ -0,0 +1,55 @@
+.test-table td, th {
+    border: 1px solid black;
+}
+.objectLink {
+    cursor:pointer;
+    color:blue;
+    text-decoration:underline;
+}
+
+#navigationPanel {
+  position: absolute;
+  top: 100px;
+  left: 0;
+  width: 130px;
+  bottom: 0;
+  overflow: hidden;
+  background-color: #F0F0F0;
+}
+
+#headerPanel {
+  position: absolute;
+  top: 0;
+  left: 0;
+  right: 0;
+  width: auto;
+  height: 100px;
+  overflow: hidden;
+  background-color: #F0E0E0;
+}
+
+#logPanel {
+  position: absolute;
+  top: auto;
+  left: 130px;
+  right: 0;
+  bottom: 0;
+  width: auto;
+  height: 100px;
+  overflow: hidden;
+  background-color: #F0E0E0;
+}
+
+#contentPanel {
+    position: fixed;
+    top: 100px;
+    bottom: 100px;
+    left: 130px;
+    right: 0;
+    overflow: auto;
+    background: #f0F0E0;
+}
+
+.btn-xosnav {
+    width: 120px;
+}
diff --git a/planetstack/core/xoslib/static/js/xosAdminSite.js b/planetstack/core/xoslib/static/js/xosAdminSite.js
new file mode 100644
index 0000000..e3457eb
--- /dev/null
+++ b/planetstack/core/xoslib/static/js/xosAdminSite.js
@@ -0,0 +1,144 @@
+OBJS = ['deployment', 'image', 'networkTemplate', 'network', 'networkSliver', 'networkDeployment', 'node', 'service', 'site', 'slice', 'sliceDeployment', 'slicePrivilege', 'sliver', 'user', 'sliceRole', 'userDeployment'];
+NAV_OBJS = ['deployment', 'site', 'slice', 'user'];
+
+function assert(outcome, description) {
+    if (!outcome) {
+        console.log(description);
+    }
+}
+
+XOSAdminApp = new XOSApplication();
+
+XOSAdminApp.addRegions({
+    navigation: "#navigationPanel",
+
+    detail: "#detail",
+    linkedObjs1: "#linkedObjs1",
+    linkedObjs2: "#linkedObjs2",
+    linkedObjs3: "#linkedObjs3",
+    linkedObjs4: "#linkedObjs4"
+});
+
+XOSAdminApp.navigateToModel = function(app, detailClass, detailNavLink, model) {
+     XOSAdminApp.Router.navigate(detailNavLink + "/" + model.id, {trigger: true});
+};

+

+XOSAdminApp.updateNavigationPanel = function() {

+    buttonTemplate=$("#xos-navbutton").html();

+    assert(buttonTemplate != undefined, "buttonTemplate is undefined");

+    html=""

+    for (var index in NAV_OBJS) {

+        name = NAV_OBJS[index];

+        collection_name = name+"s";

+        nav_url = "/" + collection_name;

+        id = "nav-"+name;

+

+        html = html + _.template(buttonTemplate, {name: collection_name, router: "XOSAdminApp.Router", routeUrl: nav_url});

+    }

+

+    $("#navigationPanel").html(html);

+};

+

+XOSAdminApp.buildViews = function() {

+     for (var index in OBJS) {

+         name = OBJS[index];
+         tr_template = '#xosAdmin-' + name + '-listitem-template';
+         table_template = '#xosAdmin-' + name + '-list-template';
+         detail_template = '#xosAdmin-' + name + '-detail-template';
+         collection_name = name + "s";
+         region_name = name + "List";
+         detailNavLink = collection_name;
+
+         detailClass = XOSDetailView.extend({
+            template: detail_template,

+            app: XOSAdminApp,

+         });

+         XOSAdminApp[collection_name + "DetailView"] = detailClass;

+
+         itemViewClass = XOSItemView.extend({
+             detailClass: detailClass,
+             template: tr_template,
+             app: XOSAdminApp,
+             detailNavLink: detailNavLink,
+         });
+
+         listViewClass = XOSListView.extend({
+             childView: itemViewClass,
+             template: table_template,
+             collection: xos[collection_name],
+             title: name + "s",
+             app: XOSAdminApp,
+         });
+
+         XOSAdminApp[collection_name + "ListView"] = listViewClass;
+
+         xos[collection_name].fetch(); //startPolling();
+     }

+};

+

+XOSAdminApp.initRouter = function() {

+    router = Marionette.AppRouter.extend({

+    });

+

+    var api = {};

+    var routes = {};

+

+    function listViewShower(listViewName) {

+        return function() {

+            XOSAdminApp.detail.show(new XOSAdminApp[listViewName]);

+        }

+    };

+

+    function detailShower(detailName, collection_name) {

+        shower = function(model_id) {

+            model = xos[collection_name].get(model_id);

+            if (model == undefined) {

+                $("#detail").html("not ready yet");

+                return;

+            }

+            detailViewClass = XOSAdminApp[detailName];

+            detailView = new detailViewClass({model: model});

+            XOSAdminApp.detail.show(detailView);

+            detailView.showLinkedItems();

+        }

+        return shower;

+    };

+

+    for (var index in OBJS) {

+        name = OBJS[index];

+        collection_name = name + "s";

+        nav_url = collection_name;

+        api_command = "list" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1);

+        listViewName = collection_name + "ListView";

+        detailViewName = collection_name + "DetailView";

+

+        api[api_command] = listViewShower(listViewName);

+        routes[nav_url] = api_command;

+

+        nav_url = collection_name + "/:id";

+        api_command = "detail" + collection_name.charAt(0).toUpperCase() + collection_name.slice(1);

+

+        api[api_command] = detailShower(detailViewName, collection_name);

+        routes[nav_url] = api_command;

+    };

+

+    XOSAdminApp.Router = new router({ appRoutes: routes, controller: api });

+}

+

+XOSAdminApp.on("start", function() {

+     XOSAdminApp.buildViews();
+
+     XOSAdminApp.initRouter();
+
+     XOSAdminApp.updateNavigationPanel();
+
+     if (Backbone.history) {
+         console.log("history start");
+         Backbone.history.start();
+     }
+});
+
+$(document).ready(function(){
+    XOSAdminApp.start();
+});
+