[conga-luci-1stgen] RHEL5-active: luci: Usability improvements for nfsrestart (69af4c6)
by rmccabe@fedorahosted.org
Repository : http://git.fedorahosted.org/git/?p=conga-luci-1stgen.git
On branch : RHEL5-active
>---------------------------------------------------------------
commit 69af4c6c1fe88c36bd5b78f32c4f7edacae4acd9
Author: Ryan McCabe <rmccabe(a)redhat.com>
Date: Tue Aug 14 17:17:35 2012 -0400
luci: Usability improvements for nfsrestart
Don't allow nfsrestart to be set unless force_unmount has
also been set. Disable the checkbox for nfsrestart if
force_unmount's checkbox is unchecked.
Resolves: rhbz#822633
Signed-off-by: Ryan McCabe <rmccabe(a)redhat.com>
>---------------------------------------------------------------
luci/cluster/resource-form-macros | 21 +++++++++------------
luci/cluster/resource_form_handlers.js | 14 ++++++++++++++
luci/site/luci/Extensions/ResourceHandler.py | 8 ++++++++
3 files changed, 31 insertions(+), 12 deletions(-)
diff --git a/luci/cluster/resource-form-macros b/luci/cluster/resource-form-macros
index 6c2a7cb..d00224f 100644
--- a/luci/cluster/resource-form-macros
+++ b/luci/cluster/resource-form-macros
@@ -459,7 +459,8 @@
<form method="post"
tal:attributes="name res/parent_uuid | nothing"
- tal:define="editDisabled resourceIsRef | nothing">
+ tal:define="editDisabled resourceIsRef | nothing;
+ force_unmount res/attrs/force_unmount | nothing">
<input name="immutable" type="hidden" value="true"
tal:condition="editDisabled" />
@@ -568,14 +569,11 @@
<tr class="systemsTable">
<td class="systemsTable">Force unmount</td>
<td class="systemsTable">
- <tal:block tal:define="
- force_unmount res/attrs/force_unmount | nothing">
-
<input type="checkbox" name="forceunmount"
+ onchange="forceunmount_update(this.form)"
tal:attributes="
disabled python: editDisabled;
checked python:(force_unmount and force_unmount.lower() == 'true' or force_unmount == '1') and 'checked' or ''" />
- </tal:block>
</td>
</tr>
@@ -612,7 +610,7 @@
tal:define="nfsrestart res/attrs/nfsrestart | nothing">
<input type="checkbox" name="nfsrestart"
tal:attributes="
- disabled python: editDisabled;
+ disabled python: (editDisabled or not force_unmount or not (force_unmount.lower() == 'true' or force_unmount == '1'));
checked python:(nfsrestart and nfsrestart.lower() == 'true' or nfsrestart == '1') and 'checked' or ''" />
</tal:block>
</td>
@@ -630,7 +628,8 @@
<form method="post"
tal:attributes="name res/parent_uuid | nothing"
- tal:define="editDisabled resourceIsRef | nothing">
+ tal:define="editDisabled resourceIsRef | nothing;
+ force_unmount res/attrs/force_unmount | nothing">
<input name="immutable" type="hidden" value="true"
tal:condition="editDisabled" />
@@ -729,14 +728,11 @@
<tr class="systemsTable">
<td class="systemsTable">Force unmount</td>
<td class="systemsTable">
- <tal:block tal:define="
- force_unmount res/attrs/force_unmount | nothing">
-
<input type="checkbox" name="forceunmount"
+ onchange="forceunmount_update(this.form)"
tal:attributes="
disabled python: editDisabled;
checked python:(force_unmount and force_unmount.lower() == 'true' or force_unmount == '1') and 'checked' or ''" />
- </tal:block>
</td>
</tr>
@@ -760,7 +756,7 @@
tal:define="nfsrestart res/attrs/nfsrestart | nothing">
<input type="checkbox" name="nfsrestart"
tal:attributes="
- disabled python: editDisabled;
+ disabled python: (editDisabled or not force_unmount or not (force_unmount.lower() == 'true' or force_unmount == '1'));
checked python:(nfsrestart and nfsrestart.lower() == 'true' or nfsrestart == '1') and 'checked' or ''" />
</tal:block>
</td>
@@ -884,6 +880,7 @@
force_unmount res/attrs/force_unmount | nothing">
<input type="checkbox" name="forceunmount"
+ onchange="forceunmount_update(this.form)"
tal:attributes="
disabled python: editDisabled;
checked python:(force_unmount and force_unmount.lower() == 'true' or force_unmount == '1') and 'checked' or ''" />
diff --git a/luci/cluster/resource_form_handlers.js b/luci/cluster/resource_form_handlers.js
index db9a33d..caefed1 100644
--- a/luci/cluster/resource_form_handlers.js
+++ b/luci/cluster/resource_form_handlers.js
@@ -484,6 +484,20 @@ function set_recovery_type(form) {
}
}
+function forceunmount_update(form) {
+ var nfsrestart_cb = form.nfsrestart;
+ if (!nfsrestart_cb) {
+ return;
+ }
+
+ if (form.forceunmount.checked) {
+ nfsrestart_cb.disabled = false;
+ } else {
+ nfsrestart_cb.checked = false;
+ nfsrestart_cb.disabled = true;
+ }
+}
+
function forms_to_xml(submit_button, master_form) {
var errors = new Array();
var form_xml = '';
diff --git a/luci/site/luci/Extensions/ResourceHandler.py b/luci/site/luci/Extensions/ResourceHandler.py
index ed55580..22f15f5 100644
--- a/luci/site/luci/Extensions/ResourceHandler.py
+++ b/luci/site/luci/Extensions/ResourceHandler.py
@@ -178,7 +178,9 @@ def addFs(res, rname, form, model):
fsid = str(generate_fsid(model, rname))
res.addAttribute('fsid', fsid)
+ has_forceunmount = False
if form.has_key('forceunmount'):
+ has_forceunmount = True
res.addAttribute('force_unmount', '1')
else:
res.addAttribute('force_unmount', '0')
@@ -194,6 +196,8 @@ def addFs(res, rname, form, model):
res.addAttribute('force_fsck', '0')
if form.has_key('nfsrestart'):
+ if not has_forceunmount:
+ raise Exception, 'nfsrestart requires force_unmount'
res.addAttribute('nfsrestart', '1')
else:
res.removeAttribute('nfsrestart')
@@ -265,7 +269,9 @@ def addClusterfs(res, rname, form, model):
fsid = str(generate_fsid(model, rname))
res.addAttribute('fsid', fsid)
+ has_forceunmount = False
if form.has_key('forceunmount'):
+ has_forceunmount = True
res.addAttribute('force_unmount', '1')
else:
res.addAttribute('force_unmount', '0')
@@ -276,6 +282,8 @@ def addClusterfs(res, rname, form, model):
res.addAttribute('self_fence', '0')
if form.has_key('nfsrestart'):
+ if not has_forceunmount:
+ raise Exception, 'nfsrestart requires force_unmount'
res.addAttribute('nfsrestart', '1')
else:
res.removeAttribute('nfsrestart')