From: Wen Wang <wenwang(a)linux.vnet.ibm.com>
V3 -> v4:
Disable CDROM hotplug due to back-end limitatiions
V2 -> V3:
Minor changes according to JQuery rules.
V1 -> V2:
Enable CDROM hot plug including detaching.
Enable users add and detach disk when vm is running.
Signed-off-by: Wen Wang <wenwang(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_edit_main.js | 30 ++++++++++++---------------
ui/js/src/kimchi.guest_storage_add.main.js | 18 +++++++++++++---
2 files changed, 27 insertions(+), 21 deletions(-)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index ed8c689..9d87a73 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -57,16 +57,14 @@ kimchi.guest_edit_main = function() {
text: false
});
- if(kimchi.thisVMState != "running") {
- $('.detach', container).button({
- icons: {
- primary: 'ui-icon-trash'
- },
- text: false
- });
-
- } else {
- $('.detach', container).remove();
+ $('.detach', container).button({
+ icons: {
+ primary: 'ui-icon-trash'
+ },
+ text: false
+ });
+ if (kimchi.thisVMState === 'running') {
+ $('.detach[data-type="cdrom"]', container).remove();
}
$('.save', container).button({
@@ -467,14 +465,8 @@ kimchi.guest_edit_main = function() {
guest['icon'] = guest['icon'] || 'images/icon-vm.png';
$('#form-guest-edit-general').fillWithObject(guest);
kimchi.thisVMState = guest['state'];
-
refreshCDROMs();
- if(kimchi.thisVMState === "running") {
- $("#form-guest-edit-general input").prop("disabled",
"disabled");
- $("#guest-edit-attach-cdrom-button").remove();
- $("#form-guest-edit-interface .header button").remove();
- } else {
- $('#guest-edit-attach-cdrom-button').button({
+ $('#guest-edit-attach-cdrom-button').button({
icons: {
primary: "ui-icon-plusthick"
},
@@ -483,6 +475,10 @@ kimchi.guest_edit_main = function() {
event.preventDefault();
kimchi.window.open("guest-storage-add.html");
});
+ if(kimchi.thisVMState === "running") {
+ $("#form-guest-edit-general input").prop("disabled",
true);
+ $("#form-guest-edit-interface .header button").remove();
+ } else {
$("#action-button-container").removeClass("hidden");
}
diff --git a/ui/js/src/kimchi.guest_storage_add.main.js
b/ui/js/src/kimchi.guest_storage_add.main.js
index 57eed6a..5df5625 100644
--- a/ui/js/src/kimchi.guest_storage_add.main.js
+++ b/ui/js/src/kimchi.guest_storage_add.main.js
@@ -24,7 +24,10 @@ kimchi.guest_storage_add_main = function() {
label: 'disk',
value: 'disk',
}];
- kimchi.select('guest-storage-type-list', types);
+ var typesRunning = [{
+ label: 'disk',
+ value: 'disk'
+ }];
var storageAddForm = $('#form-guest-storage-add');
var submitButton = $('#guest-storage-button-add');
@@ -32,10 +35,8 @@ kimchi.guest_storage_add_main = function() {
var pathTextbox = $('input[name="path"]', storageAddForm);
var poolTextbox = $('input[name="pool"]', storageAddForm);
var volTextbox = $('input[name="vol"]', storageAddForm);
- var selectType = $(typeTextbox).val();
typeTextbox.change(function() {
- $('#guest-storage-bus').selectMenu();
var pathObject = {'cdrom': ".path-section", 'disk':
'.volume-section'}
selectType = $(this).val();
$.each(pathObject, function(type, value) {
@@ -84,7 +85,7 @@ kimchi.guest_storage_add_main = function() {
options.push({
label: value.name,
value: value.name
- });
+ });
}
});
if (options.length) {
@@ -109,6 +110,15 @@ kimchi.guest_storage_add_main = function() {
});
});
+ if (kimchi.thisVMState === 'running') {
+ types =typesRunning;
+ $(typeTextbox).val('disk');
+ typeTextbox.change();
+ poolTextbox.change();
+ }
+ var selectType = $(typeTextbox).val();
+ kimchi.select('guest-storage-type-list', types);
+
var validateCDROM = function(settings) {
if (/^((https|http|ftp|ftps|tftp|\/).*)+$/.test(settings['path']))
return true;
--
1.7.1