display 'no slices' when there are no slices
authorScott Baker <smbaker@gmail.com>
Tue, 13 Jan 2015 22:41:41 +0000 (14:41 -0800)
committerScott Baker <smbaker@gmail.com>
Tue, 13 Jan 2015 22:41:41 +0000 (14:41 -0800)
planetstack/core/xoslib/dashboards/xosTenant.html
planetstack/core/xoslib/static/js/xosTenant.js

index 16e60f0..01b354c 100644 (file)
   </div>
 </script>
 
+<script type="text/template" id="xos-tenant-buttons-noslice-template">
+  <div class="box save-box">
+    <button class="btn btn-high btn-tenant-create">Create New Slice</button>
+  </div>
+</script>
+
 <script type="text/template" id="xos-log-template">
   <tr id="<%= logMessageId %>" class="xos-log xos-<%= statusclass %>">
      <td><%= what %><br>
index fc510f3..4c70f70 100644 (file)
@@ -231,31 +231,40 @@ XOSTenantApp.viewSlice = function(model) {
         model = xos.slicesPlus.models[0];\r
     }\r
 \r
-    sliceSelector = new XOSTenantApp.tenantSliceSelectorView({collection: xos.slicesPlus,\r
-                                                              selectedID: model.id,\r
-                                                             } );\r
-    XOSTenantApp.sliceSelector = sliceSelector;\r
-    XOSTenantApp.tenantSliceSelector.show(sliceSelector);\r
+    if (model) {\r
+        sliceSelector = new XOSTenantApp.tenantSliceSelectorView({collection: xos.slicesPlus,\r
+                                                                  selectedID: model ? model.id : null,\r
+                                                                 } );\r
+        XOSTenantApp.sliceSelector = sliceSelector;\r
+        XOSTenantApp.tenantSliceSelector.show(sliceSelector);\r
 \r
-    tenantSummary = new XOSTenantApp.tenantSummaryView({model: model,\r
-                                                        choices: {mount_data_sets: make_choices(xos.tenant().public_volume_names, null),\r
-                                                                  serviceClass: make_choices(xos.tenant().blessed_service_class_names, xos.tenant().blessed_service_classes),\r
-                                                                  default_image: make_choices(xos.tenant().blessed_image_names, xos.tenant().blessed_images),\r
-                                                                  default_flavor: make_choices(xos.tenant().blessed_flavor_names, xos.tenant().blessed_flavors),},\r
-                                                       });\r
-    XOSTenantApp.tenantSummary.show(tenantSummary);\r
+        tenantSummary = new XOSTenantApp.tenantSummaryView({model: model,\r
+                                                            choices: {mount_data_sets: make_choices(xos.tenant().public_volume_names, null),\r
+                                                                      serviceClass: make_choices(xos.tenant().blessed_service_class_names, xos.tenant().blessed_service_classes),\r
+                                                                      default_image: make_choices(xos.tenant().blessed_image_names, xos.tenant().blessed_images),\r
+                                                                      default_flavor: make_choices(xos.tenant().blessed_flavor_names, xos.tenant().blessed_flavors),},\r
+                                                           });\r
+        XOSTenantApp.tenantSummary.show(tenantSummary);\r
 \r
-    tenantSites = new XOSTenantSiteCollection();\r
-    tenantSites.getFromSlice(model);\r
-    model.tenantSiteCollection = tenantSites;\r
-    XOSTenantApp.tenantSites = tenantSites;\r
+        tenantSites = new XOSTenantSiteCollection();\r
+        tenantSites.getFromSlice(model);\r
+        model.tenantSiteCollection = tenantSites;\r
+        XOSTenantApp.tenantSites = tenantSites;\r
 \r
-    tenantSiteList = new XOSTenantApp.tenantSiteListView({collection: tenantSites });\r
-    XOSTenantApp.tenantSiteList.show(tenantSiteList);\r
-    // on xos.slicePlus.sort, need to update xostenantapp.tenantSites\r
+        tenantSiteList = new XOSTenantApp.tenantSiteListView({collection: tenantSites });\r
+        XOSTenantApp.tenantSiteList.show(tenantSiteList);\r
+        // on xos.slicePlus.sort, need to update xostenantapp.tenantSites\r
 \r
-    XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { app: XOSTenantApp,\r
-                                                                linkedView: tenantSummary } ) );\r
+        XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { app: XOSTenantApp,\r
+                                                                    linkedView: tenantSummary } ) );\r
+    } else {\r
+        XOSTenantApp.tenantSliceSelector.show(new HTMLView({html: ""}));\r
+        XOSTenantApp.tenantSummary.show(new HTMLView({html: "You have no slices"}));\r
+        XOSTenantApp.tenantSiteList.show(new HTMLView({html: ""}));\r
+        XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { template: "#xos-tenant-buttons-noslice-template",\r
+                                                                    app: XOSTenantApp,\r
+                                                                    linkedView: tenantSummary } ) );\r
+    }\r
 };\r
 \r
 XOSTenantApp.sanityCheck = function() {\r