mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
[migrateVolume API method] Filter disk offerings based on storage pool selected (#2612)
After using the feature introduced by #2486 in production, we felt the need for an improvement in the UI. It is interesting to filter the displayed disk offerings according to the type of storage selected (local/shared) to migrate the volume to.
This commit is contained in:
parent
67c67f516a
commit
883b313b9d
@ -414,27 +414,20 @@
|
||||
isHidden: true,
|
||||
dependsOn: 'isAdvanced',
|
||||
select: function(args) {
|
||||
$.ajax({
|
||||
url: createURL("listDiskOfferings&listAll=true"),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function(json) {
|
||||
var diskofferings = json.listdiskofferingsresponse.diskoffering;
|
||||
var items = [];
|
||||
items.push({
|
||||
id: "",
|
||||
description: ""
|
||||
});
|
||||
$(diskofferings).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.name
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
var diskOfferings = cloudStack.listDiskOfferings({listAll: true});
|
||||
var items = [];
|
||||
items.push({
|
||||
id: "",
|
||||
description: ""
|
||||
});
|
||||
$(diskOfferings).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.name
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@ -1683,19 +1683,16 @@
|
||||
dataProvider: function(args) {
|
||||
var data = {};
|
||||
listViewDataProvider(args, data);
|
||||
|
||||
$.ajax({
|
||||
url: createURL('listDiskOfferings&isrecursive=true'),
|
||||
var listDiskOfferingsOptions = {
|
||||
isRecursive: true,
|
||||
data: data,
|
||||
success: function(json) {
|
||||
var items = json.listdiskofferingsresponse.diskoffering;
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
},
|
||||
error: function(data) {
|
||||
args.response.error(parseXMLHttpResponse(data));
|
||||
}
|
||||
};
|
||||
var diskOfferings = cloudStack.listDiskOfferings(listDiskOfferingsOptions);
|
||||
args.response.success({
|
||||
data: diskOfferings
|
||||
});
|
||||
},
|
||||
|
||||
@ -2297,16 +2294,14 @@
|
||||
var data = {
|
||||
id: args.context.diskOfferings[0].id
|
||||
};
|
||||
$.ajax({
|
||||
url: createURL('listDiskOfferings&isrecursive=true'),
|
||||
data: data,
|
||||
success: function(json) {
|
||||
var item = json.listdiskofferingsresponse.diskoffering[0];
|
||||
args.response.success({
|
||||
actionFilter: diskOfferingActionfilter,
|
||||
data: item
|
||||
});
|
||||
}
|
||||
var listDiskOfferingsOptions = {
|
||||
isRecursive: true,
|
||||
data: data
|
||||
};
|
||||
var diskOfferings = cloudStack.listDiskOfferings(listDiskOfferingsOptions);
|
||||
args.response.success({
|
||||
actionFilter: diskOfferingActionfilter,
|
||||
data: diskOfferings[0]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -2851,3 +2851,34 @@ cloudStack.createArrayOfParametersForCreatePodCommand = function (zoneId, data){
|
||||
cloudStack.addParameterToCommandUrlParameterArrayIfValueIsNotEmpty(array, "endIp", data.podEndIp);
|
||||
return array;
|
||||
}
|
||||
|
||||
cloudStack.listDiskOfferings = function(options){
|
||||
var defaultOptions = {
|
||||
listAll: false,
|
||||
isRecursive: false,
|
||||
error: function(data) {
|
||||
args.response.error(data);
|
||||
}
|
||||
};
|
||||
var mergedOptions = $.extend({}, defaultOptions, options);
|
||||
|
||||
var listDiskOfferingsUrl = "listDiskOfferings";
|
||||
if(mergedOptions.listAll){
|
||||
listDiskOfferingsUrl = listDiskOfferingsUrl + "&listall=true";
|
||||
}
|
||||
if(mergedOptions.isRecursive){
|
||||
listDiskOfferingsUrl = listDiskOfferingsUrl + "&isrecursive=true";
|
||||
}
|
||||
var diskOfferings = undefined;
|
||||
$.ajax({
|
||||
url: createURL(listDiskOfferingsUrl),
|
||||
data: mergedOptions.data,
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
diskOfferings = json.listdiskofferingsresponse.diskoffering;
|
||||
},
|
||||
error: mergedOptions.error
|
||||
});
|
||||
return diskOfferings;
|
||||
};
|
||||
@ -77,6 +77,7 @@
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
var diskOfferings = cloudStack.listDiskOfferings({listAll: true});
|
||||
$('select[name=storagePool]').change(function(){
|
||||
var uuidOfStoragePoolSelected = $(this).val();
|
||||
var storagePoolSelected = mapStoragePoolsByUuid.get(uuidOfStoragePoolSelected);
|
||||
@ -86,6 +87,20 @@
|
||||
}else{
|
||||
$('div[rel=newDiskOffering],div[rel=useNewDiskOffering]').show();
|
||||
}
|
||||
var storageType = 'shared';
|
||||
if(storagePoolSelected.scope == 'HOST'){
|
||||
storageType = 'local';
|
||||
}
|
||||
$(diskOfferings).each(function(){
|
||||
var diskOfferingOption = $('option[value=' + this.id + ']');
|
||||
if(this.storagetype == storageType){
|
||||
diskOfferingOption.show();
|
||||
}else{
|
||||
diskOfferingOption.hide();
|
||||
}
|
||||
});
|
||||
var firstAvailableDiskOfferingForStorageType = $('select#label_disk_newOffering').children('option:visible').first().attr('value');
|
||||
$('select#label_disk_newOffering').attr('value', firstAvailableDiskOfferingForStorageType);
|
||||
});
|
||||
var functionHideShowNewDiskOfferint = function(){
|
||||
if($('div[rel=useNewDiskOffering] input[type=checkbox]').is(':checked')){
|
||||
@ -119,23 +134,16 @@
|
||||
required: false
|
||||
},
|
||||
select: function(args){
|
||||
$.ajax({
|
||||
url: createURL("listDiskOfferings&listall=true"),
|
||||
dataType: "json",
|
||||
async: true,
|
||||
success: function(json){
|
||||
var diskOfferings = json.listdiskofferingsresponse.diskoffering;
|
||||
var items = [];
|
||||
$(diskOfferings).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.name
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
var diskOfferings = cloudStack.listDiskOfferings({listAll: true});
|
||||
var items = [];
|
||||
$(diskOfferings).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.name
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -165,7 +173,7 @@
|
||||
});
|
||||
}
|
||||
|
||||
var diskofferingObjs, selectedDiskOfferingObj;
|
||||
var selectedDiskOfferingObj = null;
|
||||
|
||||
cloudStack.sections.storage = {
|
||||
title: 'label.storage',
|
||||
@ -277,36 +285,28 @@
|
||||
label: 'label.disk.offering',
|
||||
docID: 'helpVolumeDiskOffering',
|
||||
select: function(args) {
|
||||
$.ajax({
|
||||
url: createURL("listDiskOfferings"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
diskofferingObjs = json.listdiskofferingsresponse.diskoffering;
|
||||
var items = [];
|
||||
$(diskofferingObjs).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
var diskOfferings = cloudStack.listDiskOfferings({});
|
||||
var items = [];
|
||||
$(diskOfferings).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
|
||||
args.$select.change(function() {
|
||||
var diskOfferingId = $(this).val();
|
||||
$(diskofferingObjs).each(function() {
|
||||
$(diskOfferings).each(function() {
|
||||
if (this.id == diskOfferingId) {
|
||||
selectedDiskOfferingObj = this;
|
||||
return false; //break the $.each() loop
|
||||
}
|
||||
});
|
||||
if (selectedDiskOfferingObj == null)
|
||||
if (selectedDiskOfferingObj == null){
|
||||
return;
|
||||
|
||||
}
|
||||
var $form = $(this).closest('form');
|
||||
var $diskSize = $form.find('.form-item[rel=diskSize]');
|
||||
if (selectedDiskOfferingObj.iscustomized == true) {
|
||||
@ -510,60 +510,44 @@
|
||||
label: 'label.custom.disk.offering',
|
||||
docID: 'helpVolumeDiskOffering',
|
||||
select: function(args) {
|
||||
var diskofferingObjs;
|
||||
$.ajax({
|
||||
url: createURL("listDiskOfferings"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
diskofferingObjs = json.listdiskofferingsresponse.diskoffering;
|
||||
var items = [{
|
||||
id: '',
|
||||
description: ''
|
||||
}];
|
||||
$(diskofferingObjs).each(function() {
|
||||
if (this.iscustomized == true) {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
}
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
var diskOfferings = cloudStack.listDiskOfferings({});
|
||||
var items = [{
|
||||
id: '',
|
||||
description: ''
|
||||
}];
|
||||
$(diskOfferings).each(function() {
|
||||
if (this.iscustomized == true) {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
}
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
},
|
||||
diskOffering: {
|
||||
label: 'label.custom.disk.offering',
|
||||
docID: 'helpVolumeDiskOffering',
|
||||
select: function(args) {
|
||||
var diskofferingObjs;
|
||||
$.ajax({
|
||||
url: createURL("listDiskOfferings"),
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function(json) {
|
||||
diskofferingObjs = json.listdiskofferingsresponse.diskoffering;
|
||||
var items = [{
|
||||
id: '',
|
||||
description: ''
|
||||
}];
|
||||
$(diskofferingObjs).each(function() {
|
||||
if (this.iscustomized == true) {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
}
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
var diskOfferings = cloudStack.listDiskOfferings({});
|
||||
var items = [{
|
||||
id: '',
|
||||
description: ''
|
||||
}];
|
||||
$(diskOfferings).each(function() {
|
||||
if (this.iscustomized == true) {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
}
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
},
|
||||
checksum: {
|
||||
@ -1480,25 +1464,18 @@
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: createURL("listDiskOfferings"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
diskofferingObjs = json.listdiskofferingsresponse.diskoffering;
|
||||
var items = [];
|
||||
$(diskofferingObjs).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
});
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
}
|
||||
var diskOfferings = cloudStack.listDiskOfferings({});
|
||||
var items = [];
|
||||
$(diskOfferings).each(function() {
|
||||
items.push({
|
||||
id: this.id,
|
||||
description: this.displaytext
|
||||
});
|
||||
});
|
||||
|
||||
args.response.success({
|
||||
data: items
|
||||
});
|
||||
|
||||
args.$select.change(function() {
|
||||
if(args.context.volumes[0].type == "ROOT") {
|
||||
selectedDiskOfferingObj = null;
|
||||
@ -1506,15 +1483,15 @@
|
||||
}
|
||||
|
||||
var diskOfferingId = $(this).val();
|
||||
$(diskofferingObjs).each(function() {
|
||||
$(diskOfferings).each(function() {
|
||||
if (this.id == diskOfferingId) {
|
||||
selectedDiskOfferingObj = this;
|
||||
return false; //break the $.each() loop
|
||||
}
|
||||
});
|
||||
if (selectedDiskOfferingObj == null)
|
||||
if (selectedDiskOfferingObj == null){
|
||||
return;
|
||||
|
||||
}
|
||||
var $form = $(this).closest('form');
|
||||
|
||||
var $shrinkok = $form.find('.form-item[rel=shrinkok]');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user