tenant view only shows sites the user should be able to see
[plstackapi.git] / planetstack / core / xoslib / static / js / xosTenant.js
index 286537d..0182f9f 100644 (file)
@@ -72,6 +72,7 @@ XOSTenantButtonView = Marionette.ItemView.extend({
                      "click button.btn-tenant-delete": "deleteClicked",
                      "click button.btn-tenant-add-user": "addUserClicked",
                      "click button.btn-tenant-save": "saveClicked",
+                     "click button.btn-tenant-download-ssh": "downloadClicked",
                      },
 
             createClicked: function(e) {
@@ -86,6 +87,10 @@ XOSTenantButtonView = Marionette.ItemView.extend({
                      XOSTenantApp.editUsers(this.options.linkedView.model);
                      },
 
+            downloadClicked: function(e) {
+                     XOSTenantApp.downloadSSH(this.options.linkedView.model);
+                     },
+
             saveClicked: function(e) {
                      model = this.options.linkedView.model;
                      model.tenantSiteCollection.putToSlice(model);
@@ -113,6 +118,7 @@ XOSTenantApp.addRegions({
     tenantButtons: "#tenantButtons",
     tenantAddSliceInterior: "#tenant-addslice-interior",
     tenantEditUsersInterior: "#tenant-edit-users-interior",
+    tenantSSHCommandsInterior: "#tenant-ssh-commands-interior",
 });
 
 XOSTenantApp.setDirty = function(dirty) {
@@ -131,6 +137,9 @@ 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
+                                                helpText: {"serviceClass": "Existing slivers will be re-instantiated if changed",\r
+                                                           "default_image": "Existing slivers will be re-instantiated if changed",\r
+                                                           "default_flavor": "Existing slivers will be re-instantiated if changed"},\r
 \r
                                                 onShow: function() {\r
                                                     // the slice selector is in a different table, so make every label cell the maximal width\r
@@ -169,6 +178,9 @@ XOSTenantApp.buildViews = function() {
          sliceChanged: function(id) {\r
              XOSTenantApp.navToSlice(id);\r
          },\r
+         filter: function(slice) {\r
+             return slice.attributes.current_user_can_see;\r
+         },\r
      });\r
 \r
      xos.sites.fetch();\r
@@ -269,6 +281,51 @@ XOSTenantApp.editUsers = function(model) {
     $("#tenant-edit-users-dialog").dialog("open");\r
 };\r
 \r
+XOSTenantApp.downloadSSHOld = function(model) {\r
+    sshCommands = "";\r
+    for (index in model.attributes.sliceInfo.sshCommands) {\r
+         sshCommand = model.attributes.sliceInfo.sshCommands[index];\r
+         sshCommands = sshCommands + sshCommand + "\n";\r
+    }\r
+\r
+    if (sshCommands.length == 0) {\r
+         alert("this slice has no instantiated slivers yet");\r
+         return;\r
+    }\r
+\r
+    var myWindow = window.open("", "ssh_command_list",""); // "width=640, height=480");\r
+    myWindow.document.write("<html><head><title>SSH Commands</title></head><body><pre>" + sshCommands + "</pre></body></html>");\r
+    myWindow.document.close();\r
+};\r
+\r
+XOSTenantApp.downloadSSH = function(model) {\r
+    sshCommands = "";\r
+    for (index in model.attributes.sliceInfo.sshCommands) {\r
+         sshCommand = model.attributes.sliceInfo.sshCommands[index];\r
+         sshCommands = sshCommands + sshCommand + "\n";\r
+    }\r
+\r
+    if (sshCommands.length == 0) {\r
+         alert("this slice has no instantiated slivers yet");\r
+         return;\r
+    }\r
+\r
+    var htmlView = new HTMLView({html: '<pre style="overflow: auto; word-wrap: normal; white-space: pre; word-wrap: normal;">' + sshCommands + '</pre>'});\r
+    XOSTenantApp.tenantSSHCommandsInterior.show(htmlView);\r
+\r
+    $("#tenant-ssh-commands-dialog").dialog({\r
+       autoOpen: false,
+       modal: true,
+       width: 640,
+       buttons : {
+            "Ok" : function() {
+              $(this).dialog("close");
+            },
+          }
+        });
+    $("#tenant-ssh-commands-dialog").dialog("open");\r
+};\r
+\r
 XOSTenantApp.deleteSlice = function(model) {\r
     var app=this;\r
     app.deleteDialog(model, function() { console.log("afterDelete"); app.viewSlice(undefined); });\r