[Kimchi-devel] [PATCH V2 2/2] Allow admin user change permission settings when VM is running
Wen Wang
wenwang at linux.vnet.ibm.com
Fri Aug 22 06:11:12 UTC 2014
V1 -> V2:
Have the "edit" button in interface tab deleted when VM is running
Functions changed:
1) Enable "Edit" whether VM is running or off
2) Disable edit function of "General", "Storage", "Interface" except
"replace" of the cdrom under "Storage".
Signed-off-by: Wen Wang <wenwang at linux.vnet.ibm.com>
---
ui/js/src/kimchi.guest_edit_main.js | 56 +++++++++++++++++++++++-----------
ui/js/src/kimchi.guest_main.js | 1 -
ui/pages/guest-edit.html.tmpl | 2 +-
3 files changed, 39 insertions(+), 20 deletions(-)
diff --git a/ui/js/src/kimchi.guest_edit_main.js b/ui/js/src/kimchi.guest_edit_main.js
index 01d8045..fdd7944 100644
--- a/ui/js/src/kimchi.guest_edit_main.js
+++ b/ui/js/src/kimchi.guest_edit_main.js
@@ -19,7 +19,12 @@ kimchi.guest_edit_main = function() {
var buttonContainer = $('#action-button-container');
$('#guest-edit-tabs').tabs({
beforeActivate: function(event, ui) {
- var display_list = ['form-guest-edit-general', 'form-guest-edit-permission']
+ var display_list = null;
+ if(kimchi.thisVMState === "running") {
+ display_list = ['form-guest-edit-permission'];
+ } else {
+ display_list = ['form-guest-edit-general', 'form-guest-edit-permission'];
+ }
$(buttonContainer).addClass('hidden');
var deactivated = ui['newPanel'];
if(display_list.indexOf($(deactivated).attr('id')) >= 0) {
@@ -52,12 +57,17 @@ kimchi.guest_edit_main = function() {
text: false
});
- $('.detach', container).button({
- icons: {
- primary: 'ui-icon-trash'
- },
- text: false
- });
+ if(kimchi.thisVMState != "running") {
+ $('.detach', container).button({
+ icons: {
+ primary: 'ui-icon-trash'
+ },
+ text: false
+ });
+
+ } else {
+ $('.detach', container).remove();
+ }
$('.save', container).button({
icons: {
@@ -170,6 +180,10 @@ kimchi.guest_edit_main = function() {
var itemNode = $.parseHTML(kimchi.substitute($('#interface-tmpl').html(),data));
$(".body", "#form-guest-edit-interface").append(itemNode);
$("select", itemNode).append(networkOptions);
+ if(kimchi.thisVMState === "running") {
+ $("#form-guest-edit-interface .delete").remove();
+ $("#form-guest-edit-interface .edit").remove();
+ }
if(data.network!==""){
$("select", itemNode).val(data.network);
}
@@ -340,18 +354,25 @@ kimchi.guest_edit_main = function() {
var initContent = function(guest) {
guest['icon'] = guest['icon'] || 'images/icon-vm.png';
$('#form-guest-edit-general').fillWithObject(guest);
+ kimchi.thisVMState = guest['state'];
refreshCDROMs();
-
- $('#guest-edit-attach-cdrom-button').button({
- icons: {
- primary: "ui-icon-plusthick"
- },
- text: false
- }).click(function(event) {
- event.preventDefault();
- kimchi.window.open("guest-storage-add.html");
- });
+ 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({
+ icons: {
+ primary: "ui-icon-plusthick"
+ },
+ text: false
+ }).click(function(event) {
+ event.preventDefault();
+ kimchi.window.open("guest-storage-add.html");
+ });
+ $("#action-button-container").removeClass("hidden");
+ }
var onAttached = function(params) {
refreshCDROMs();
@@ -364,7 +385,6 @@ kimchi.guest_edit_main = function() {
};
initStorageListeners();
-
setupInterface();
setupPermission();
diff --git a/ui/js/src/kimchi.guest_main.js b/ui/js/src/kimchi.guest_main.js
index 320847e..5cbdb40 100644
--- a/ui/js/src/kimchi.guest_main.js
+++ b/ui/js/src/kimchi.guest_main.js
@@ -253,7 +253,6 @@ kimchi.createGuestLi = function(vmObject, prevScreenImage, openMenu) {
//Setup the VM Actions
var guestActions=result.find("div[name=guest-actions]");
guestActions.find(".shutoff-disabled").prop('disabled', !vmRunningBool );
- guestActions.find(".running-disabled").prop('disabled', vmRunningBool );
if (vmRunningBool) {
guestActions.find(".running-hidden").hide();
diff --git a/ui/pages/guest-edit.html.tmpl b/ui/pages/guest-edit.html.tmpl
index ed7ddeb..47615be 100644
--- a/ui/pages/guest-edit.html.tmpl
+++ b/ui/pages/guest-edit.html.tmpl
@@ -145,7 +145,7 @@
</div>
</div>
<footer>
- <div id="action-button-container" class="btn-group">
+ <div id="action-button-container" class="btn-group hidden">
<button id="guest-edit-button-save" class="btn-normal">
<span class="text">$_("Save")</span>
</button>
--
1.7.1
More information about the Kimchi-devel
mailing list