From 392b5c3166cb82263427c822c317f9186dd6e63c Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 24 Jun 2019 16:14:47 +0530 Subject: [PATCH] ui: added action to update offering linked domain(s) and zone(s) Signed-off-by: Abhishek Kumar --- ui/css/cloudstack3.css | 8 + ui/l10n/en.js | 5 + ui/scripts/configuration.js | 762 ++++++++++++++++++++++++++++++++++++ 3 files changed, 775 insertions(+) diff --git a/ui/css/cloudstack3.css b/ui/css/cloudstack3.css index b6877cdaf29..9d27d325a21 100644 --- a/ui/css/cloudstack3.css +++ b/ui/css/cloudstack3.css @@ -12811,6 +12811,14 @@ div.ui-dialog div.autoscaler div.field-group div.form-container form div.form-it background-position: -197px -647px; } +.updateOfferingAccess .icon { + background-position: -165px -122px; +} + +.updateOfferingAccess:hover .icon { + background-position: -165px -704px; +} + .accounts-wizard table { width: 100%; margin: 0; diff --git a/ui/l10n/en.js b/ui/l10n/en.js index a49b0e3427a..01d211609d5 100644 --- a/ui/l10n/en.js +++ b/ui/l10n/en.js @@ -294,6 +294,7 @@ var dictionary = { "label.action.take.snapshot.processing":"Taking Snapshot....", "label.action.unmanage.cluster":"Unmanage Cluster", "label.action.unmanage.cluster.processing":"Unmanaging Cluster....", +"label.action.update.offering.access":"Update Offering Access", "label.action.update.OS.preference":"Update OS Preference", "label.action.update.OS.preference.processing":"Updating OS Preference....", "label.action.update.resource.count":"Update Resource Count", @@ -553,6 +554,7 @@ var dictionary = { "label.compute":"Compute", "label.compute.and.storage":"Compute and Storage", "label.compute.offering":"Compute offering", +"label.compute.offering.access":"Compute offering access", "label.compute.offering.type":"Compute offering type", "label.compute.offering.custom.constrained":"Custom Constrained", "label.compute.offering.custom.unconstrained":"Custom Unconstrained", @@ -684,6 +686,7 @@ var dictionary = { "label.disk.iops.allocated":"IOPS Allocated", "label.disk.iops.write.rate":"Disk Write Rate (IOPS)", "label.disk.offering":"Disk Offering", +"label.disk.offering.access":"Disk offering access", "label.disk.offering.details":"Disk offering details", "label.disk.newOffering": "New Disk Offering", "label.disk.newOffering.description": "New disk offering to be used by this volume after the migration.", @@ -1184,6 +1187,7 @@ var dictionary = { "label.network.limits":"Network limits", "label.network.name":"Network Name", "label.network.offering":"Network Offering", +"label.network.offering.access":"Network offering access", "label.network.offering.details":"Network offering details", "label.network.offering.display.text":"Network Offering Display Text", "label.network.offering.id":"Network Offering ID", @@ -1835,6 +1839,7 @@ var dictionary = { "label.vpc.distributedvpcrouter":"Distributed VPC Router", "label.vpc.id":"VPC ID", "label.vpc.offering":"VPC Offering", +"label.vpc.offering.access":"VPC offering access", "label.vpc.offering.details":"VPC offering details", "label.vpc.router.details":"VPC Router Details", "label.vpc.supportsregionlevelvpc":"Supports Region Level VPC", diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js index c393dc1aab1..bd6b2b43bff 100644 --- a/ui/scripts/configuration.js +++ b/ui/scripts/configuration.js @@ -991,6 +991,203 @@ args.complete(); } } + }, + + updateOfferingAccess: { + label: 'label.action.update.offering.access', + messages: { + notification: function(args) { + return 'label.action.update.offering.access'; + } + }, + createForm: { + title: 'label.compute.offering.access', + desc: '', + preFilter: function(args) { + if (isAdmin()) { + } else { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', false); + args.$form.find('.form-item[rel=isPublic]').hide(); + args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //shown + } + var formOffering = args.context.serviceOfferings[0]; + $.ajax({ + url: createURL('listServiceOfferings&isrecursive=true'), + data: { + id: args.context.serviceOfferings[0].id + }, + dataType: "json", + async: false, + success: function (json) { + var item = json.listserviceofferingsresponse.serviceoffering[0]; + formOffering = item; + args.response.success({ + data: item + }); + } + }); //end ajax + var offeringDomainIds = formOffering.domainid; + if (offeringDomainIds) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', false); + args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //shown + offeringDomainIds = offeringDomainIds.indexOf(",") != -1 ? offeringDomainIds.spit(",") : [offeringDomainIds]; + var options = args.$form.find('.form-item[rel=domainId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringDomainIds, function(domainIdIndex, domainId) { + domainId = domainId.toString().trim(); + if ($(option).val() === domainId) { + $(option).attr('selected','selected'); + } + }); + }); + } else { + if (isAdmin()) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', true); + } + } + var offeringZoneIds = formOffering.zoneid; + if (offeringZoneIds) { + offeringZoneIds = offeringZoneIds.indexOf(",") != -1 ? offeringZoneIds.spit(",") : [offeringZoneIds]; + var options = args.$form.find('.form-item[rel=zoneId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringZoneIds, function(zoneIdIndex, zoneId) { + zoneId = zoneId.toString().trim(); + if ($(option).val() === zoneId) { + $(option).attr('selected','selected'); + } + }); + }); + } + }, + fields: { + isPublic: { + label: 'label.public', + isBoolean: true, + isReverse: true, + isChecked: false, + docID: 'helpComputeOfferingPublic' + }, + domainId: { + label: 'label.domain', + docID: 'helpComputeOfferingDomain', + dependsOn: 'isPublic', + isMultiple: true, + isHidden: true, + validation: { + required: true + }, + select: function(args) { + $.ajax({ + url: createURL('listDomains'), + data: { + listAll: true, + details: 'min' + }, + dataType: "json", + async: false, + success: function(json) { + var items = []; + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + args.response.success({ + data: items + }); + var options = args.$form.find('.form-item[rel=domainId]').children('option'); + $.each(options, function() { + console.log($(this).val()); + }); + console.log("Hello! "+options); + } + }); + } + }, + zoneId: { + label: 'label.zone', + docID: 'helpComputeOfferingZone', + isMultiple: true, + validation: { + allzonesonly: true + }, + select: function(args) { + $.ajax({ + url: createURL("listZones"), + data: {available: 'true'}, + dataType: "json", + async: true, + success: function(json) { + var items = []; + var zoneObjs = json.listzonesresponse.zone; + $(zoneObjs).each(function() { + items.push({ + id: this.id, + description: this.name + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + items.unshift({ + id: -1, + description: "All Zones", + selected: true + }); + args.response.success({ + data: items + }); + } + }); + } + } + } + }, + action: function(args) { + var data = { + id: args.context.serviceOfferings[0].id + }; + if (args.data.isPublic != "on") { + var domainId = (args.data.domainId && Array.isArray(args.data.domainId)) ? args.data.domainId.join(',') : args.data.domainId; + if (domainId) { + $.extend(data, { + domainid: domainId + }); + } + } else { + $.extend(data, { + domainid: "public" + }); + } + var zoneId = (args.data.zone && Array.isArray(args.data.zoneId)) ? args.data.zoneId.join(',') : args.data.zoneId != -1 ? args.data.zoneId : "all"; + if (zoneId) { + $.extend(data, { + zoneid: zoneId + }); + } + $.ajax({ + url: createURL('updateServiceOffering'), + data: data, + dataType: "json", + async: false, + success: function (json) { + var item = json.updateserviceofferingresponse.serviceoffering; + args.response.success({ + data: item + }); + } + }); //end ajax + }, + notification: { + poll: function(args) { + args.complete(); + } + } } }, @@ -2411,6 +2608,197 @@ args.complete(); } } + }, + + updateOfferingAccess: { + label: 'label.action.update.offering.access', + messages: { + notification: function(args) { + return 'label.action.update.offering.access'; + } + }, + createForm: { + title: 'label.disk.offering.access', + desc: '', + preFilter: function(args) { + if (isAdmin()) { + } else { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', false); + args.$form.find('.form-item[rel=isPublic]').hide(); + args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //shown + } + var formOffering = args.context.diskOfferings[0]; + $.ajax({ + url: createURL('listDiskOfferings'), + data: { + id: args.context.diskOfferings[0].id + }, + dataType: "json", + async: false, + success: function (json) { + var item = json.listdiskofferingsresponse.diskoffering[0]; + formOffering = item; + args.response.success({ + data: item + }); + } + }); //end ajax + var offeringDomainIds = formOffering.domainid; + if (offeringDomainIds) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', false); + args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //shown + offeringDomainIds = offeringDomainIds.indexOf(",") != -1 ? offeringDomainIds.spit(",") : [offeringDomainIds]; + var options = args.$form.find('.form-item[rel=domainId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringDomainIds, function(domainIdIndex, domainId) { + domainId = domainId.toString().trim(); + if ($(option).val() === domainId) { + $(option).attr('selected','selected'); + } + }); + }); + } else { + if (isAdmin()) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', true); + } + } + var offeringZoneIds = formOffering.zoneid; + if (offeringZoneIds) { + offeringZoneIds = offeringZoneIds.indexOf(",") != -1 ? offeringZoneIds.spit(",") : [offeringZoneIds]; + var options = args.$form.find('.form-item[rel=zoneId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringZoneIds, function(zoneIdIndex, zoneId) { + zoneId = zoneId.toString().trim(); + if ($(option).val() === zoneId) { + $(option).attr('selected','selected'); + } + }); + }); + } + }, + fields: { + isPublic: { + label: 'label.public', + isBoolean: true, + isReverse: true, + isChecked: false, + docID: 'helpDiskOfferingPublic' + }, + domainId: { + label: 'label.domain', + docID: 'helpDiskOfferingDomain', + dependsOn: 'isPublic', + isMultiple: true, + validation: { + required: true + }, + select: function(args) { + $.ajax({ + url: createURL('listDomains'), + data: { + listAll: true, + details: 'min' + }, + dataType: "json", + async: false, + success: function(json) { + var items = []; + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + args.response.success({ + data: items + }); + } + }); + }, + isHidden: true + }, + zoneId: { + label: 'label.zone', + docID: 'helpDiskOfferingZone', + isMultiple: true, + validation: { + allzonesonly: true + }, + select: function(args) { + $.ajax({ + url: createURL("listZones"), + data: {available: 'true'}, + dataType: "json", + async: true, + success: function(json) { + var items = []; + var zoneObjs = json.listzonesresponse.zone; + $(zoneObjs).each(function() { + items.push({ + id: this.id, + description: this.name + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + items.unshift({ + id: -1, + description: "All Zones" + }); + args.response.success({ + data: items + }); + } + }); + } + } + } + }, + action: function(args) { + var data = { + id: args.context.diskOfferings[0].id + }; + if (args.data.isPublic != "on") { + var domainId = (args.data.domainId && Array.isArray(args.data.domainId)) ? args.data.domainId.join(',') : args.data.domainId; + if (domainId) { + $.extend(data, { + domainid: domainId + }); + } + } else { + $.extend(data, { + domainid: "public" + }); + } + var zoneId = (args.data.zone && Array.isArray(args.data.zoneId)) ? args.data.zoneId.join(',') : args.data.zoneId != -1 ? args.data.zoneId : "all"; + if (zoneId) { + $.extend(data, { + zoneid: zoneId + }); + } + $.ajax({ + url: createURL('updateDiskOffering'), + data: data, + dataType: "json", + async: false, + success: function (json) { + var item = json.updatediskofferingresponse.diskoffering; + args.response.success({ + data: item + }); + } + }); //end ajax + }, + notification: { + poll: function(args) { + args.complete(); + } + } } }, @@ -3959,6 +4347,191 @@ }); } } + }, + + updateOfferingAccess: { + label: 'label.action.update.offering.access', + messages: { + notification: function(args) { + return 'label.action.update.offering.access'; + } + }, + createForm: { + title: 'label.network.offering.access', + desc: '', + preFilter: function(args) { + var formOffering = args.context.networkOfferings[0]; + $.ajax({ + url: createURL('listNetworkOfferings'), + data: { + id: args.context.networkOfferings[0].id + }, + dataType: "json", + async: false, + success: function (json) { + var item = json.listnetworkofferingsresponse.networkoffering[0]; + formOffering = item; + args.response.success({ + data: item + }); + } + }); //end ajax + var offeringDomainIds = formOffering.domainid; + if (offeringDomainIds) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', false); + args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //shown + offeringDomainIds = offeringDomainIds.indexOf(",") != -1 ? offeringDomainIds.spit(",") : [offeringDomainIds]; + var options = args.$form.find('.form-item[rel=domainId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringDomainIds, function(domainIdIndex, domainId) { + domainId = domainId.toString().trim(); + if ($(option).val() === domainId) { + $(option).attr('selected','selected'); + } + }); + }); + } else { + if (isAdmin()) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', true); + } + } + var offeringZoneIds = formOffering.zoneid; + if (offeringZoneIds) { + offeringZoneIds = offeringZoneIds.indexOf(",") != -1 ? offeringZoneIds.spit(",") : [offeringZoneIds]; + var options = args.$form.find('.form-item[rel=zoneId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringZoneIds, function(zoneIdIndex, zoneId) { + zoneId = zoneId.toString().trim(); + if ($(option).val() === zoneId) { + $(option).attr('selected','selected'); + } + }); + }); + } + }, + fields: { + isPublic: { + label: 'label.public', + isBoolean: true, + isReverse: true, + isChecked: false, + docID: 'helpNetworkOfferingPublic' + }, + domainId: { + label: 'label.domain', + docID: 'helpNetworkOfferingDomain', + dependsOn: 'isPublic', + isMultiple: true, + validation: { + required: true + }, + select: function(args) { + $.ajax({ + url: createURL('listDomains'), + data: { + listAll: true, + details: 'min' + }, + dataType: "json", + async: false, + success: function(json) { + var items = []; + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + args.response.success({ + data: items + }); + } + }); + }, + isHidden: true + }, + zoneId: { + label: 'label.zone', + docID: 'helpNetworkOfferingZone', + isMultiple: true, + validation: { + allzonesonly: true + }, + select: function(args) { + $.ajax({ + url: createURL("listZones"), + data: {available: 'true'}, + dataType: "json", + async: true, + success: function(json) { + var items = []; + var zoneObjs = json.listzonesresponse.zone; + $(zoneObjs).each(function() { + items.push({ + id: this.id, + description: this.name + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + items.unshift({ + id: -1, + description: "All Zones" + }); + args.response.success({ + data: items + }); + } + }); + } + } + } + }, + action: function(args) { + var data = { + id: args.context.networkOfferings[0].id + }; + if (args.data.isPublic != "on") { + var domainId = (args.data.domainId && Array.isArray(args.data.domainId)) ? args.data.domainId.join(',') : args.data.domainId; + if (domainId) { + $.extend(data, { + domainid: domainId + }); + } + } else { + $.extend(data, { + domainid: "public" + }); + } + var zoneId = (args.data.zone && Array.isArray(args.data.zoneId)) ? args.data.zoneId.join(',') : args.data.zoneId != -1 ? args.data.zoneId : "all"; + if (zoneId) { + $.extend(data, { + zoneid: zoneId + }); + } + $.ajax({ + url: createURL('updateNetworkOffering'), + data: data, + dataType: "json", + async: false, + success: function (json) { + var item = json.updatenetworkofferingresponse.networkoffering; + args.response.success({ + data: item + }); + } + }); //end ajax + }, + notification: { + poll: function(args) { + args.complete(); + } + } } }, tabs: { @@ -4706,6 +5279,191 @@ }); } } + }, + + updateOfferingAccess: { + label: 'label.action.update.offering.access', + messages: { + notification: function(args) { + return 'label.action.update.offering.access'; + } + }, + createForm: { + title: 'label.vpc.offering.access', + desc: '', + preFilter: function(args) { + var formOffering = args.context.vpcOfferings[0]; + $.ajax({ + url: createURL('listVPCOfferings'), + data: { + id: args.context.vpcOfferings[0].id + }, + dataType: "json", + async: false, + success: function (json) { + var item = json.listvpcofferingsresponse.vpcoffering[0]; + formOffering = item; + args.response.success({ + data: item + }); + } + }); //end ajax + var offeringDomainIds = formOffering.domainid; + if (offeringDomainIds) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', false); + args.$form.find('.form-item[rel=domainId]').css('display', 'inline-block'); //shown + offeringDomainIds = offeringDomainIds.indexOf(",") != -1 ? offeringDomainIds.spit(",") : [offeringDomainIds]; + var options = args.$form.find('.form-item[rel=domainId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringDomainIds, function(domainIdIndex, domainId) { + domainId = domainId.toString().trim(); + if ($(option).val() === domainId) { + $(option).attr('selected','selected'); + } + }); + }); + } else { + if (isAdmin()) { + args.$form.find('.form-item[rel=isPublic]').find('input[name=isPublic]').prop('checked', true); + } + } + var offeringZoneIds = formOffering.zoneid; + if (offeringZoneIds) { + offeringZoneIds = offeringZoneIds.indexOf(",") != -1 ? offeringZoneIds.spit(",") : [offeringZoneIds]; + var options = args.$form.find('.form-item[rel=zoneId]').find('option'); + $.each(options, function(optionIndex, option) { + $.each(offeringZoneIds, function(zoneIdIndex, zoneId) { + zoneId = zoneId.toString().trim(); + if ($(option).val() === zoneId) { + $(option).attr('selected','selected'); + } + }); + }); + } + }, + fields: { + isPublic: { + label: 'label.public', + isBoolean: true, + isReverse: true, + isChecked: false, + docID: 'helpVpcOfferingPublic' + }, + domainId: { + label: 'label.domain', + docID: 'helpVpcOfferingDomain', + dependsOn: 'isPublic', + isMultiple: true, + validation: { + required: true + }, + select: function(args) { + $.ajax({ + url: createURL('listDomains'), + data: { + listAll: true, + details: 'min' + }, + dataType: "json", + async: false, + success: function(json) { + var items = []; + var domainObjs = json.listdomainsresponse.domain; + $(domainObjs).each(function() { + items.push({ + id: this.id, + description: this.path + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + args.response.success({ + data: items + }); + } + }); + }, + isHidden: true + }, + zoneId: { + label: 'label.zone', + docID: 'helpVpcOfferingZone', + isMultiple: true, + validation: { + allzonesonly: true + }, + select: function(args) { + $.ajax({ + url: createURL("listZones"), + data: {available: 'true'}, + dataType: "json", + async: true, + success: function(json) { + var items = []; + var zoneObjs = json.listzonesresponse.zone; + $(zoneObjs).each(function() { + items.push({ + id: this.id, + description: this.name + }); + }); + items.sort(function(a, b) { + return a.description.localeCompare(b.description); + }); + items.unshift({ + id: -1, + description: "All Zones" + }); + args.response.success({ + data: items + }); + } + }); + } + } + } + }, + action: function(args) { + var data = { + id: args.context.vpcOfferings[0].id + }; + if (args.data.isPublic != "on") { + var domainId = (args.data.domainId && Array.isArray(args.data.domainId)) ? args.data.domainId.join(',') : args.data.domainId; + if (domainId) { + $.extend(data, { + domainid: domainId + }); + } + } else { + $.extend(data, { + domainid: "public" + }); + } + var zoneId = (args.data.zone && Array.isArray(args.data.zoneId)) ? args.data.zoneId.join(',') : args.data.zoneId != -1 ? args.data.zoneId : "all"; + if (zoneId) { + $.extend(data, { + zoneid: zoneId + }); + } + $.ajax({ + url: createURL('updateVPCOffering'), + data: data, + dataType: "json", + async: false, + success: function (json) { + var item = json.updatevpcofferingresponse.vpcoffering; + args.response.success({ + data: item + }); + } + }); //end ajax + }, + notification: { + poll: function(args) { + args.complete(); + } + } } }, tabs: { @@ -4807,6 +5565,7 @@ var allowedActions = []; allowedActions.push("edit"); allowedActions.push("remove"); + allowedActions.push("updateOfferingAccess"); return allowedActions; }; @@ -4823,6 +5582,7 @@ var allowedActions = []; allowedActions.push("edit"); allowedActions.push("remove"); + allowedActions.push("updateOfferingAccess"); return allowedActions; }; @@ -4842,6 +5602,7 @@ if (jsonObj.isdefault == false) allowedActions.push("remove"); + allowedActions.push("updateOfferingAccess"); return allowedActions; }; @@ -4862,6 +5623,7 @@ if (jsonObj.isdefault == false) allowedActions.push("remove"); + allowedActions.push("updateOfferingAccess"); return allowedActions; };