Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
authorTony Mack <tmack@tux.cs.princeton.edu>
Mon, 26 Jan 2015 02:59:58 +0000 (21:59 -0500)
committerTony Mack <tmack@tux.cs.princeton.edu>
Mon, 26 Jan 2015 02:59:58 +0000 (21:59 -0500)
planetstack/core/dashboard/views/download_ssh_commands.py [new file with mode: 0644]
planetstack/core/xoslib/static/js/xosTenant.js

diff --git a/planetstack/core/dashboard/views/download_ssh_commands.py b/planetstack/core/dashboard/views/download_ssh_commands.py
new file mode 100644 (file)
index 0000000..96d1393
--- /dev/null
@@ -0,0 +1,18 @@
+from view_common import *
+from core.xoslib.objects.sliceplus import SlicePlus
+
+# This was intended to serve as a download feature for the tenant view. Found
+# a better way to do it. This is deprecated.
+
+class DownloadSSHCommandsView(View):
+    url = r'^sshcommands/(?P<sliceid>\d+)/$'
+
+    def get(self, request, sliceid=None, **kwargs):
+        #slice = Slices.objects.get(id=sliceid);
+        #for sliver in slice.slivers.all():
+        #    if (sliver.instance_id && sliver.instance_name):
+
+        slice = SlicePlus.objects.get(id=sliceid)
+
+        return HttpResponse(slice.getSliceInfo()["sshCommands"], content_type='text/text')
+
index 79e093e..4225cac 100644 (file)
@@ -297,25 +297,8 @@ 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
+    var sshCommands = "";\r
     for (index in model.attributes.sliceInfo.sshCommands) {\r
          sshCommand = model.attributes.sliceInfo.sshCommands[index];\r
          sshCommands = sshCommands + sshCommand + "\n";\r
@@ -334,7 +317,15 @@ XOSTenantApp.downloadSSH = function(model) {
        modal: true,
        width: 640,
        buttons : {
-            "Ok" : function() {
+            "Download": function() {
+                var dlLink = document.createElement('a');
+                dlLink.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(sshCommands));
+                dlLink.setAttribute('download', 'sshcommands.txt');
+                dlLink.click();
+
+                //window.open('data:text/text,' + encodeURIComponent(sshCommands));
+            },
+            "Close" : function() {
               $(this).dialog("close");
             },
           }