X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fxoslib%2Fstatic%2Fjs%2FxosTenant.js;h=ae6f955eeda30063cd3acdaee29e13fe865e8b6a;hb=e5eeb46dd6b896101cf680bcf4d1d3083960afdf;hp=10e70e62907f3c7403f41ddd2ca331f64c6ec951;hpb=fe290f49559b1e19b9251b83877862f70679bf86;p=plstackapi.git diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js index 10e70e6..ae6f955 100644 --- a/planetstack/core/xoslib/static/js/xosTenant.js +++ b/planetstack/core/xoslib/static/js/xosTenant.js @@ -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); @@ -102,6 +107,7 @@ XOSTenantApp = new XOSApplication({ logTableId: "#logTable", statusMsgId: "#statusMsg", hideTabsByDefault: true, + dirty: false, varName: "XOSTenantApp", }); @@ -112,9 +118,11 @@ XOSTenantApp.addRegions({ tenantButtons: "#tenantButtons", tenantAddSliceInterior: "#tenant-addslice-interior", tenantEditUsersInterior: "#tenant-edit-users-interior", + tenantSSHCommandsInterior: "#tenant-ssh-commands-interior", }); XOSTenantApp.setDirty = function(dirty) { + XOSTenantApp.dirty = dirty; if (dirty) { $("button.btn-tenant-save").addClass("btn-success"); } else { @@ -129,6 +137,9 @@ XOSTenantApp.buildViews = function() { app: XOSTenantApp, detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports", "mount_data_sets"], fieldDisplayNames: {serviceClass: "Service Level", "default_flavor": "Flavor", "default_image": "Image", "mount_data_sets": "Data Sets"}, + helpText: {"serviceClass": "Existing slivers will be re-instantiated if changed", + "default_image": "Existing slivers will be re-instantiated if changed", + "default_flavor": "Existing slivers will be re-instantiated if changed"}, onShow: function() { // the slice selector is in a different table, so make every label cell the maximal width @@ -253,6 +264,9 @@ XOSTenantApp.editUsers = function(model) { var editDialog = this; user_ids = all_options($("#tenant-edit-users-dialog").find(".select-picker-to")); user_ids = user_ids.map( function(x) { return parseInt(x,10); } ); + if (!array_same_elements(user_ids, model.usersBuffer)) { + XOSTenantApp.setDirty(true); + } model.usersBuffer = user_ids; $(editDialog).dialog("close"); }, @@ -264,12 +278,66 @@ 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 = ""; + 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 htmlView = new HTMLView({html: '
' + sshCommands + '
'}); + XOSTenantApp.tenantSSHCommandsInterior.show(htmlView); + + $("#tenant-ssh-commands-dialog").dialog({ + autoOpen: false, + modal: true, + width: 640, + buttons : { + "Ok" : function() { + $(this).dialog("close"); + }, + } + }); + $("#tenant-ssh-commands-dialog").dialog("open"); +}; + XOSTenantApp.deleteSlice = function(model) { var app=this; app.deleteDialog(model, function() { console.log("afterDelete"); app.viewSlice(undefined); }); }; XOSTenantApp.viewSlice = function(model) { + if (XOSTenantApp.dirty) { + if (!confirm("The current sliver has unsaved data -- view new sliver anyway ?")) { + $("#tenantSliceSelector select").val(XOSTenantApp.currentSlice.id); + return; + } + } + + XOSTenantApp.setDirty(false); + if (!model && xos.slicesPlus.models.length > 0) { model = xos.slicesPlus.models[0]; } @@ -303,6 +371,8 @@ XOSTenantApp.viewSlice = function(model) { XOSTenantApp.tenantButtons.show( new XOSTenantButtonView( { app: XOSTenantApp, linkedView: tenantSummary } ) ); + + XOSTenantApp.currentSlice = model; } else { XOSTenantApp.tenantSliceSelector.show(new HTMLView({html: ""})); XOSTenantApp.tenantSummary.show(new HTMLView({html: "You have no slices"}));