make tenantview method reslient of users with no site, catch users with no site in...
[plstackapi.git] / planetstack / core / xoslib / static / js / xosTenant.js
index 268b8ca..9c45460 100644 (file)
@@ -103,6 +103,11 @@ XOSTenantApp.buildViews = function() {
                                                 app: XOSTenantApp,\r
                                                 detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports", "mount_data_sets"],\r
                                                 fieldDisplayNames: {serviceClass: "Service Level", "default_flavor": "Flavor", "default_image": "Image", "mount_data_sets": "Data Sets"},\r
+\r
+                                                onShow: function() {\r
+                                                    // the slice selector is in a different table, so make every label cell the maximal width\r
+                                                    make_same_width("#xos-tenant-view-panel", ".xos-label-cell");\r
+                                                },\r
                                                 });\r
 \r
      XOSTenantApp.tenantSummaryView = tenantSummaryClass;\r
@@ -127,6 +132,7 @@ XOSTenantApp.buildViews = function() {
                                                noDeleteColumn: true,\r
                                                disablePaginate: true,\r
                                                disableFilter: true,\r
+                                               fieldDisplayNames: {"name": "Site"},\r
                                                });\r
 \r
      XOSTenantApp.tenantSiteListView = tenantSiteListClass;\r
@@ -170,6 +176,12 @@ XOSTenantApp.adjustCollectionField = function(collectionName, id, fieldName, amo
 \r
 XOSTenantApp.addSlice = function() {\r
     var app=this;\r
+\r
+    if (!xos.tenant().current_user_can_create_slice) {\r
+        window.alert("You do not have sufficient rights to create a slice on your site");\r
+        return;\r
+    }\r
+\r
     model = new xos.slicesPlus.model({site: xos.tenant().current_user_site_id,\r
                                       name: xos.tenant().current_user_login_base + "_"});\r
     console.log(model);\r
@@ -252,6 +264,8 @@ XOSTenantApp.viewSlice = function(model) {
         tenantSites = new XOSTenantSiteCollection();\r
         tenantSites.getFromSlice(model);\r
         model.usersBuffer = model.attributes.users; /* save a copy of 'users' that we can edit. This prevents another view (developer) from overwriting our copy with a fetch from the server */\r
+        model.usersOrig = model.attributes.users;   /* save an immutable copy that we'll use for username lookups */\r
+        model.user_namesOrig = model.attributes.user_names;\r
         model.tenantSiteCollection = tenantSites;\r
         XOSTenantApp.tenantSites = tenantSites;\r
 \r
@@ -285,6 +299,9 @@ XOSTenantApp.sanityCheck = function() {
     if (xos.tenant().blessed_sites.length == 0) {\r
         errors.push("no blessed sites");\r
     }\r
+    if (xos.tenant().current_user_site_id == null) {\r
+        errors.push("current user does not have a site");\r
+    }\r
 \r
     if (errors.length > 0) {\r
          $("#tenantSummary").html("Tenant view sanity check failed<br>" + errors.join("<br>"));\r