many changes to xoslib test
authorScott Baker <smbaker@gmail.com>
Thu, 30 Oct 2014 07:06:16 +0000 (00:06 -0700)
committerScott Baker <smbaker@gmail.com>
Thu, 30 Oct 2014 07:06:16 +0000 (00:06 -0700)
planetstack/core/xoslib/dashboards/test.html
planetstack/core/xoslib/static/css/test.css
planetstack/core/xoslib/static/js/test.js

index 5326b76..cc539ce 100644 (file)
 
 <p>This shows all of the things you can see using xosLib</p>
 
-<h3>Deployments</h3>
 <div id="deploymentList">
 </div>
 
-<h3>Images</h3>
 <div id="imageList">
 </div>
 
-<h3>Network Templates</h3>
 <div id="networkTemplateList">
 </div>
 
-<h3>Networks</h3>
 <div id="networkList">
 </div>
 
-<h3>Nodes</h3>
 <div id="nodeList">
 </div>
 
-<h3>Services</h3>
 <div id="serviceList">
 </div>
 
-<h3>Sites</h3>
 <div id="siteList">
 </div>
 
-<h3>Slices</h3>
 <div id="sliceList">
 </div>
 
-<h3>Slivers</h3>
 <div id="sliverList">
 </div>
 
-<h3>Users</h3>
 <div id="userList">
 </div>
 
@@ -63,6 +53,8 @@
 <div id="detail"></div>\r
 <div id="linkedObjs1"></div>
 <div id="linkedObjs2"></div>
+<div id="linkedObjs3"></div>
+<div id="linkedObjs4"></div>
 </div>
 </div>
 
@@ -87,6 +79,7 @@
 <!-- Deployment -->
 
 <script type="text/template" id="test-deployment-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 
 
 <script type="text/template" id="test-deployment-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= backend_type %></td>
   <td><%= admin_tenant %></td>
   <td><%= sites.length %></td>
 <!-- Image -->
 
 <script type="text/template" id="test-image-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 </script>
 
 <script type="text/template" id="test-image-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= disk_format %></td>
   <td><%= container_format %></td>
   <td><%= path %></td>
 <!-- NetworkTemplate -->
 
 <script type="text/template" id="test-networkTemplate-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 
 
 <script type="text/template" id="test-networkTemplate-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= description %></td>
   <td><%= visibility %></td>
   <td><%= translation %></td>
 <!-- Network -->
 
 <script type="text/template" id="test-network-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
   </table>
 </script>
 
-
 <script type="text/template" id="test-network-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= template %></td>
   <td><%= ports %></td>
   <td><%= labels %></td>
-  <td><%= owner %></td>
+  <td><%= idToName(owner,"slivers","name") %></td>
 </script>
 
 <script type="text/template" id="test-network-detail-template">
   </form>\r
 </script>
 
+<!-- NetworkSliver -->
+
+<script type="text/template" id="test-networkSliver-list-template">
+  <h3><%= title %></h3>
+  <table class="test-table">
+  <thead><tr>
+     <th>id</th>
+     <th>network</th>
+     <th>sliver</th>
+     <th>ip</th>
+     <th>port_id</th>
+  </tr></thead>
+  <tbody></tbody>
+  </table>
+</script>
+
+<script type="text/template" id="test-networkSliver-listitem-template">
+  <td class="objectLink"><%= id %></td>
+  <td><%= idToName(network,"networks","name") %></td>
+  <td><%= idToName(sliver,"slivers","name") %></td>
+  <td><%= ip %></td>
+  <td><%= port_id %></td>
+</script>
+
+<script type="text/template" id="test-networkSliver-detail-template">
+  <h3>Detail View: Network</h3>
+  <form>\r
+  <table>\r
+  <tr><td>Network:</td><td><input type="text" name="network" value="<%= network %>"></td></tr>\r
+  <tr><td>Sliver:</td><td><input type="text" name="sliver" value="<%= sliver %>"></td></tr>\r
+  <tr><td>Ip:</td><td><input type="text" name="ip" value="<%= ip %>"></td></tr>\r
+  <tr><td>Port_id:</td><td><input type="text" name="port_id" value="<%= port_id %>"></td></tr>\r
+  <tr><td colspan=2><button class="btn js-submit">Save</button></td></tr>\r
+  </table>\r
+  </form>\r
+</script>
+
 <!-- Node -->
 
 <script type="text/template" id="test-node-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 
 
 <script type="text/template" id="test-node-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
-  <td><%= site %></td>
-  <td><%= deployment %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
+  <td><%= idToName(site,"sites","name") %></td>
+  <td><%= idToName(deployment,"deployments","name") %></td>
 </script>
 
 <script type="text/template" id="test-node-detail-template">
   </form>\r
 </script>
 
+<!-- SliceRole -->
+
+<script type="text/template" id="test-sliceRole-list-template">
+  <h3><%= title %></h3>
+  <table class="test-table">
+  <thead><tr>
+     <th>id</th>
+     <th>role</th>
+  </tr></thead>
+  <tbody></tbody>
+  </table>
+</script>
+
+
+<script type="text/template" id="test-sliceRole-listitem-template">
+  <td class="objectLink"><%= id %></td>
+  <td><%= role %></td>
+</script>
+
+<script type="text/template" id="test-sliceRole-detail-template">
+  <h3>Detail View: Service</h3>
+  <form>\r
+  <table>\r
+  <tr><td>Role:</td><td><input type="text" name="role" value="<%= role %>"></td></tr>\r
+  <tr><td colspan=2><button class="btn js-submit">Save</button></td></tr>\r
+  </table>\r
+  </form>\r
+</script>
+
 <!-- Service -->
 
 <script type="text/template" id="test-service-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 
 
 <script type="text/template" id="test-service-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= description %></td>
   <td><%= enabled %></td>
   <td><%= versionNumber %></td>
 <!-- Site -->
 
 <script type="text/template" id="test-site-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
   </table>
 </script>
 
-
 <script type="text/template" id="test-site-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= site_url %></td>
   <td><%= enabled %></td>
   <td><%= login_base %></td>
 <!-- Slice -->
 
 <script type="text/template" id="test-slice-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 </script>
 
 <script type="text/template" id="test-slice-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= enabled %></td>
   <td><%= omf_friendly %></td>
   <td><%= description %></td>
   <td><%= slice_url %></td>
-  <td><%= site %></td>
+  <td><%= idToName(site,"sites","name") %></td>
   <td><%= max_slivers %></td>
-  <td><%= service %></td>
+  <td><%= idToName(service,"services","name") %></td>
 </script>
 
 <script type="text/template" id="test-slice-detail-template">
   </form>\r
 </script>
 
+<!-- SlicDeployment -->
+
+<script type="text/template" id="test-sliceDeployment-list-template">
+  <h3><%= title %></h3>
+  <table class="test-table">
+  <thead><tr>
+     <th>id</th>
+     <th>slice</th>
+     <th>deployment</th>
+     <th>tenant_id</th>
+  </tr></thead>
+  <tbody></tbody>
+  </table>
+</script>
+
+<script type="text/template" id="test-sliceDeployment-listitem-template">
+  <td class="objectLink"><%= id %></td>
+  <td><%= idToName(slice,"slices","name") %></td>
+  <td><%= idToName(deployment,"deployments","name") %></td>
+  <td><%= tenant_id %></td>
+</script>
+
+<script type="text/template" id="test-sliceDeployment-detail-template">
+  <h3>Detail View: Slice Deployment</h3>
+  <form>\r
+  <table>\r
+  <tr><td>Slice:</td><td><input type="text" name="slice" value="<%= slice %>"></td></tr>\r
+  <tr><td>Deployment:</td><td><input type="text" name="deployment" value="<%= deployment %>"></td></tr>\r
+  <tr><td>Tenant Id:</td><td><input type="text" name="tenant_id" value="<%= tenant_id %>"></td></tr>\r
+  <tr><td colspan=2><button class="btn js-submit">Save</button></td></tr>\r
+  </table>\r
+  </form>\r
+</script>
+
+<!-- SlicePrivilege -->
+
+<script type="text/template" id="test-slicePrivilege-list-template">
+  <h3><%= title %></h3>
+  <table class="test-table">
+  <thead><tr>
+     <th>id</th>
+     <th>user</th>
+     <th>slice</th>
+     <th>role</th>
+  </tr></thead>
+  <tbody></tbody>
+  </table>
+</script>
+
+<script type="text/template" id="test-slicePrivilege-listitem-template">
+  <td class="objectLink"><%= id %></td>
+  <td><%= idToName(user,"users","username") %></td>
+  <td><%= idToName(slice,"slices","name") %></td>
+  <td><%= idToName(role,"sliceRoles","role") %></td>
+</script>
+
+<script type="text/template" id="test-slicePrivilege-detail-template">
+  <h3>Detail View: Slice Privilege</h3>
+  <form>\r
+  <table>\r
+  <tr><td>User:</td><td><input type="text" name="user" value="<%= user %>"></td></tr>\r
+  <tr><td>Slice:</td><td><input type="text" name="slice" value="<%= slice %>"></td></tr>\r
+  <tr><td>Role:</td><td><input type="text" name="role" value="<%= role %>"></td></tr>\r
+  <tr><td colspan=2><button class="btn js-submit">Save</button></td></tr>\r
+  </table>\r
+  </form>\r
+</script>
+
 <!-- Sliver -->
 
 <script type="text/template" id="test-sliver-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 
 
 <script type="text/template" id="test-sliver-listitem-template">
-  <td><%= id %></td>
-  <td><%= name %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= name %></td>
   <td><%= instance_id %></td>
   <td><%= instance_name %></td>
-  <td><%= image %></td>
-  <td><%= creator %></td>
-  <td><%= slice %></td>
-  <td><%= node %></td>
-  <td><%= deploymentNetwork %></td>
+  <td><%= idToName(image,"images","name") %></td>
+  <td><%= idToName(creator,"users","name") %></td>
+  <td><%= idToName(slice,"slices","name") %></td>
+  <td><%= idToName(node,"nodes","name") %></td>
+  <td><%= idToName(deploymentNetwork,"deployments","name") %></td>
   <td><%= flavor %></td>
   <td><%= userData %></td>
 </script>
 <!-- User -->
 
 <script type="text/template" id="test-user-list-template">
+  <h3><%= title %></h3>
   <table class="test-table">
   <thead><tr>
      <th>id</th>
 
 
 <script type="text/template" id="test-user-listitem-template">
-  <td><%= id %></td>
-  <td><%= username %></td>
+  <td class="objectLink"><%= id %></td>
+  <td class="objectLink"><%= username %></td>
   <td><%= firstname %></td>
   <td><%= lastname %></td>
   <td><%= phone %></td>
index e5b1b80..dee32d8 100644 (file)
@@ -6,6 +6,7 @@
     position: fixed;
     top: 1em;
     right: 1em;
+    width: 450px;
 }
 
 #detailBox {
@@ -14,6 +15,8 @@
     background-color: #f0f0f0;
     margin-bottom:30px;
     display:none;
+    overflow:auto;
+    max-height:80vh;
 }
 
 #errorBox {
@@ -32,3 +35,9 @@
     display:none;
 }
 
+.objectLink {
+    cursor:pointer;
+    color:blue;
+    text-decoration:underline;
+}
+
index ff681e8..86de742 100644 (file)
@@ -11,25 +11,11 @@ TestApp.addRegions({
     sliceList: "#sliceList",
     sliverList: "#sliverList",
     userList: "#userList",
-    detail: "#detail"
-});
-
-// ---- Deployment ----
-
-TestApp.DeploymentListItemView = Marionette.ItemView.extend({
-    template: '#test-deployment-listitem-template',
-    tagName: 'tr',
-    className: 'test-tablerow',
-});
-
-TestApp.DeploymentListView = Marionette.CompositeView.extend({
-    childView: TestApp.DeploymentListItemView,
-    childViewContainer: 'tbody',
-    template: '#test-deployment-list-template',
-
-    initialize: function() {
-        this.listenTo(this.collection, 'change', this._renderChildren)
-    },
+    detail: "#detail",
+    linkedObjs1: "#linkedObjs1",
+    linkedObjs2: "#linkedObjs2",
+    linkedObjs3: "#linkedObjs3",
+    linkedObjs4: "#linkedObjs4"
 });
 
 TestApp.hideError = function(result) {
@@ -53,8 +39,17 @@ TestApp.showError = function(result) {
      });
 };
 
+idToName = function(id, collectionName, fieldName) {
+    linkedObject = xos[collectionName].get(id);
+    if (linkedObject == undefined) {
+        return "#" + id;
+    } else {
+        return linkedObject.attributes[fieldName];
+    }
+};
+
 TestApp.on("start", function() {
-     var objs = ['deployment', 'image', 'networkTemplate', 'network', 'node', 'service', 'site', 'slice', 'sliver', 'user'];
+     var objs = ['deployment', 'image', 'networkTemplate', 'network', 'networkSliver', 'node', 'service', 'site', 'slice', 'sliceDeployment', 'slicePrivilege', 'sliver', 'user', 'sliceRole'];
 
      for (var index in objs) {
          name = objs[index];
@@ -112,6 +107,20 @@ TestApp.on("start", function() {
                     e.preventDefault();\r
                     e.stopPropagation();\r
 \r
+                    index=0;\r
+                    for (relatedName in this.model.collection.relatedCollections) {\r
+                        relatedField = this.model.collection.relatedCollections[relatedName];\r
+\r
+                        relatedListViewClass = TestApp[relatedName + "ListView"].extend({collection: xos[relatedName].filterBy(relatedField,this.model.id)});\r
+                        TestApp["linkedObjs" + (index+1)].show(new relatedListViewClass());\r
+                        index = index + 1;\r
+                    }\r
+\r
+                    while (index<4) {\r
+                        TestApp["linkedObjs" + (index+1)].empty();\r
+                        index = index + 1;\r
+                    }\r
+\r
                     var detailView = new this.detailClass({\r
                         model: this.model,\r
                     });\r
@@ -125,15 +134,32 @@ TestApp.on("start", function() {
              childViewContainer: 'tbody',
              template: table_template,
              collection: xos[collection_name],
+             title: name + "s",
 
              initialize: function() {
                  this.listenTo(this.collection, 'change', this._renderChildren)
+
+                 // Because many of the templates use idToName(), we need to
+                 // listen to the collections that hold the names for the ids
+                 // that we want to display.
+                 for (i in this.collection.foreignCollections) {
+                     foreignName = this.collection.foreignCollections[i];
+                     this.listenTo(xos[foreignName], 'change', this._renderChildren);
+                     this.listenTo(xos[foreignName], 'sort', this._renderChildren);
+                 }
+             },
+
+             templateHelpers: function() {
+                return { title: this.title };
              },
          });
+         TestApp[collection_name + "ListView"] = listViewClass;
 
          var listView = new listViewClass();
 
-         TestApp[region_name].show(listView);
+         if (region_name in TestApp.getRegions()) {
+             TestApp[region_name].show(listView);
+         }
          xos[collection_name].fetch(); //startPolling();
      }