From 8ce133b9805597522ff5957d6a879f9b078787eb Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Sun, 25 Jan 2015 17:04:00 -0800 Subject: [PATCH] download button for ssh commands --- .../core/xoslib/static/js/xosTenant.js | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js index 79e093e..4225cac 100644 --- a/planetstack/core/xoslib/static/js/xosTenant.js +++ b/planetstack/core/xoslib/static/js/xosTenant.js @@ -297,25 +297,8 @@ XOSTenantApp.editUsers = function(model) { $("#tenant-edit-users-dialog").dialog("open"); }; -XOSTenantApp.downloadSSHOld = function(model) { - sshCommands = ""; - for (index in model.attributes.sliceInfo.sshCommands) { - sshCommand = model.attributes.sliceInfo.sshCommands[index]; - sshCommands = sshCommands + sshCommand + "\n"; - } - - if (sshCommands.length == 0) { - alert("this slice has no instantiated slivers yet"); - return; - } - - var myWindow = window.open("", "ssh_command_list",""); // "width=640, height=480"); - myWindow.document.write("SSH Commands
" + sshCommands + "
"); - myWindow.document.close(); -}; - XOSTenantApp.downloadSSH = function(model) { - sshCommands = ""; + var sshCommands = ""; for (index in model.attributes.sliceInfo.sshCommands) { sshCommand = model.attributes.sliceInfo.sshCommands[index]; sshCommands = sshCommands + sshCommand + "\n"; @@ -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"); }, } -- 2.43.0