X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fcore%2Fxoslib%2Fstatic%2Fjs%2FxosTenant.js;h=4225caccbc54bf9e311c96361ba755d8d26d8348;hb=8ce133b9805597522ff5957d6a879f9b078787eb;hp=c0d9ab9beb570e32df2965226ca7f9fb6bab642d;hpb=753a13edfd39603fbdc59747c4d7c2b59a2d06b9;p=plstackapi.git diff --git a/planetstack/core/xoslib/static/js/xosTenant.js b/planetstack/core/xoslib/static/js/xosTenant.js index c0d9ab9..4225cac 100644 --- a/planetstack/core/xoslib/static/js/xosTenant.js +++ b/planetstack/core/xoslib/static/js/xosTenant.js @@ -5,7 +5,7 @@ XOSTenantSite = XOSModel.extend( { }); XOSTenantSiteCollection = XOSCollection.extend( { - listFields: ["name", "allocated"], + listFields: ["name", "allocated", "ready"], modelName: "tenantSite", collectionName: "tenantSites", @@ -14,17 +14,33 @@ XOSTenantSiteCollection = XOSCollection.extend( { var id = 0; for (siteName in slice.attributes.site_allocation) { allocated = slice.attributes.site_allocation[siteName]; - tenantSites.push(new XOSTenantSite( { name: siteName, allocated: allocated, id: id} )); + ready = slice.attributes.site_ready[siteName] || 0; + tenantSites.push(new XOSTenantSite( { name: siteName, allocated: allocated, ready: ready, id: id} )); id = id + 1; } for (index in xos.tenantview.models[0].attributes.blessed_site_names) { siteName = xos.tenantview.models[0].attributes.blessed_site_names[index]; if (! (siteName in slice.attributes.site_allocation)) { - tenantSites.push(new XOSTenantSite( { name: siteName, allocated: 0, id: id} )); + tenantSites.push(new XOSTenantSite( { name: siteName, allocated: 0, ready: 0, id: id} )); id = id + 1; } } this.set(tenantSites); + + var that=this; + this.listenTo(slice, 'change', function() { that.getReadyFromSlice(slice); }) + }, + + getReadyFromSlice: function(slice) { + for (siteName in slice.attributes.site_ready) { + ready = slice.attributes.site_ready[siteName]; + for (index in this.models) { + tenantSite = this.models[index]; + if (tenantSite.attributes.name == siteName) { + tenantSite.set("ready", ready); + } + } + } }, putToSlice: function(slice) { @@ -135,9 +151,10 @@ XOSTenantApp.buildViews = function() { tenantSummaryClass = XOSTenantSummaryView.extend({template: "#xos-detail-template", app: XOSTenantApp, - detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports", "mount_data_sets"], + detailFields: ["serviceClass", "default_image", "default_flavor", "network_ports"], fieldDisplayNames: {serviceClass: "Service Level", "default_flavor": "Flavor", "default_image": "Image", "mount_data_sets": "Data Sets"}, - helpText: {"default_image": "Existing slivers will be re-instantiated if changed", + 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() { @@ -177,6 +194,9 @@ XOSTenantApp.buildViews = function() { sliceChanged: function(id) { XOSTenantApp.navToSlice(id); }, + filter: function(slice) { + return slice.attributes.current_user_can_see; + }, }); xos.sites.fetch(); @@ -277,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"; @@ -314,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"); }, }