Skip to content

Commit a4ad71c

Browse files
committed
Merge pull request #1342 from ustcweizhou/root-disk-size-ui
CLOUDSTACK-6181: Add 'root disk size' field in instance wizard for KVM templatesThis commit includes three changes: (1) Revert commit 13bf1ec to show the 'root disk size' field (2) Set the default value from '1' to empty. This also changes the default value of customized service offerings from '1' to empty. (3) show 'root disk size' field only when users choose a KVM template, as cloudstack supports deployvm with rootdisksize on KVM only. * pr/1342: CLOUDSTACK-6181: Add 'root disk size' field in instance wizard for KVM templates Signed-off-by: Remi Bergsma <[email protected]>
2 parents 451ae2b + 3822be5 commit a4ad71c

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

client/WEB-INF/classes/resources/messages.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ label.smb.domain=SMB Domain
3838
label.hypervisors=Hypervisors
3939
label.home=Home
4040
label.sockets=CPU Sockets
41-
label.root.disk.size=Root disk size
41+
label.root.disk.size=Root disk size (GB)
4242
label.s3.nfs.server=S3 NFS Server
4343
label.s3.nfs.path=S3 NFS Path
4444
label.delete.events=Delete events

ui/scripts/instanceWizard.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,6 @@
279279
hypervisors: hypervisorObjs
280280
},
281281
customHidden: function(args) {
282-
////
283-
return true; // Disabled -- not supported in backend right now
284-
////
285-
286282
if (selectedTemplateOrIso == 'select-template') {
287283
return false; //show Root Disk Size field
288284
} else { //selectedTemplateOrIso == 'select-iso'

ui/scripts/ui-custom/instanceWizard.js

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -419,22 +419,59 @@
419419
});
420420
});
421421

422-
originalValues(formData);
423-
424422
var custom = args.customHidden({
425423
context: context,
426424
data: args.data
427425
});
428426

429427
$step.find('.custom-size-label').remove();
430428

431-
if (!custom) {
432-
$step.find('.section.custom-size').show();
433-
$step.addClass('custom-disk-size');
434-
} else {
429+
if (custom) {
435430
$step.find('.section.custom-size').hide();
436431
$step.removeClass('custom-disk-size');
437432
}
433+
434+
$step.find('input[type=radio]').bind('change', function() {
435+
var $target = $(this);
436+
var val = $target.val();
437+
var item = null;
438+
if (item == null) {
439+
item = $.grep(args.data.templates.featuredtemplates, function(elem) {
440+
return elem.id == val;
441+
})[0];
442+
}
443+
if (item == null) {
444+
item = $.grep(args.data.templates.communitytemplates, function(elem) {
445+
return elem.id == val;
446+
})[0];
447+
}
448+
if (item == null) {
449+
item = $.grep(args.data.templates.mytemplates, function(elem) {
450+
return elem.id == val;
451+
})[0];
452+
}
453+
if (item == null) {
454+
item = $.grep(args.data.templates.sharedtemplates, function(elem) {
455+
return elem.id == val;
456+
})[0];
457+
}
458+
459+
if (!item) return true;
460+
461+
var hypervisor = item['hypervisor'];
462+
if (hypervisor == 'KVM') {
463+
$step.find('.section.custom-size').show();
464+
$step.addClass('custom-disk-size');
465+
} else {
466+
$step.find('.section.custom-size').hide();
467+
$step.removeClass('custom-disk-size');
468+
}
469+
470+
return true;
471+
});
472+
473+
originalValues(formData);
474+
438475
}
439476
}
440477
};
@@ -1271,9 +1308,9 @@
12711308
args.maxDiskOfferingSize() : 100;
12721309

12731310
// Setup tabs and slider
1274-
$wizard.find('.section.custom-size .size.min span').html(minCustomDiskSize);
1275-
$wizard.find('.section.custom-size input[type=text]').val(minCustomDiskSize);
1276-
$wizard.find('.section.custom-size .size.max span').html(maxCustomDiskSize);
1311+
$wizard.find('.section.custom-size.custom-disk-size .size.min span').html(minCustomDiskSize);
1312+
$wizard.find('.section.custom-size.custom-disk-size input[type=text]').val(minCustomDiskSize);
1313+
$wizard.find('.section.custom-size.custom-disk-size .size.max span').html(maxCustomDiskSize);
12771314
$wizard.find('.tab-view').tabs();
12781315
$wizard.find('.slider').each(function() {
12791316
var $slider = $(this);

0 commit comments

Comments
 (0)