From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros homebase/homeba ...
Date: 17 Aug 2006 16:22:44 -0000 [thread overview]
Message-ID: <20060817162244.8352.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-08-17 16:22:41
Modified files:
luci/cluster : form-macros
luci/homebase : homebase_common.js
Added files:
luci/cluster : validate_config_fence.js
validate_config_multicast.js
validate_config_qdisk.js
Removed files:
luci/cluster : validate_qdisk.js
Log message:
more javascript form validation
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_fence.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_qdisk.js.diff?cvsroot=cluster&r1=1.2&r2=NONE
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.4&r2=1.5
/cvs/cluster/conga/luci/cluster/validate_config_fence.js,v --> standard output
revision 1.1
--- conga/luci/cluster/validate_config_fence.js
+++ - 2006-08-17 16:22:42.036280000 +0000
@@ -0,0 +1,23 @@
+function validate_form(form) {
+ var errors = new Array();
+
+ if (!form)
+ return (-1);
+
+ if (!form.post_fail_delay || str_is_blank(form.post_fail_delay.value))
+ errors.push('No post fail delay value was given.');
+ else if (!is_valid_int(form.post_fail_delay.value, 0, null))
+ errors.push('The post fail delay must be a non-negative integer value.');
+
+ if (!form.post_join_delay || str_is_blank(form.post_join_delay.value))
+ errors.push('No post join delay value was given.');
+ else if (!is_valid_int(form.post_join_delay.value, 0, null))
+ errors.push('The post join delay must be a non-negative integer value.');
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (confirm('Update cluster fence daemon properties?'))
+ form.submit();
+ return (0);
+}
/cvs/cluster/conga/luci/cluster/validate_config_multicast.js,v --> standard output
revision 1.1
--- conga/luci/cluster/validate_config_multicast.js
+++ - 2006-08-17 16:22:42.136456000 +0000
@@ -0,0 +1,56 @@
+var prev_mcast_str = '';
+
+function disable_mcast(addrId) {
+ addrObj = document.getElementById(addrId);
+ if (!addrObj || addrObj.disabled)
+ return;
+ addrObj.disabled = true;
+ prev_mcast_str = addrObj.value;
+ addrObj.value = '';
+}
+
+function enable_mcast(addrId) {
+ addrObj = document.getElementById(addrId);
+ if (!addrObj || !addrObj.disabled)
+ return;
+ addrObj.disabled = false;
+ addrObj.value = prev_mcast_str;
+}
+
+function validate_form(form) {
+ var errors = new Array();
+
+ if (!form.mcast) {
+ errors.push('You did not specify how the multicast address should be chosen.');
+ error_dialog(errors);
+ return (-1);
+ }
+
+ var mcast;
+ if (form.mcast.length > 0 && form.mcast[0].checked)
+ mcast = 0;
+ else if (form.mcast.length > 1 && form.mcast[1].checked)
+ mcast = 1;
+ else
+ errors.push('An invalid value was given while specifying how the multicast address should be chosen.');
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (mcast) {
+ if (!form.mcast_address || str_is_blank(form.mcast_address.value))
+ errors.push('No multicast address was given.');
+ else {
+ var err = isValidHost(form.mcast_address.value);
+ if (err)
+ errors.push(err);
+ }
+ }
+
+ if (error_dialog(errors))
+ return (-1);
+
+ if (confirm('Update cluster multicast properties?'))
+ form.submit();
+ return (0);
+}
/cvs/cluster/conga/luci/cluster/validate_config_qdisk.js,v --> standard output
revision 1.1
--- conga/luci/cluster/validate_config_qdisk.js
+++ - 2006-08-17 16:22:42.317675000 +0000
@@ -0,0 +1,246 @@
+function check_heuristic(hnum, form) {
+ var errors = new Array();
+
+ if (hnum < 0)
+ errors.push('An invalid heuristic number was given: ' + hnum);
+ else if (hnum > 9)
+ errors.push('A maximum of 10 heuristics is allowed.');
+
+ if (errors.length > 0)
+ return (errors);
+
+ hstr = 'heuristic' + hnum + ':';
+
+ hname = document.getElementById(hstr + 'hname');
+ if (!hname || str_is_blank(hname.value))
+ errors.push('No name was given for heuristic ' + (hnum + 1));
+ else
+ hname = hname.value;
+
+ hpath = document.getElementById(hstr + 'hpath');
+ if (!hpath || str_is_blank(hpath.value))
+ errors.push('No path was given for heuristic ' + (hnum + 1));
+ else
+ hpath = hpath.value;
+
+ hint = document.getElementById(hstr + 'hinterval');
+ if (!hint || str_is_blank(hint.value))
+ errors.push('No interval was given for heuristic ' + (hnum + 1));
+ else
+ hint = hint.value;
+
+ hscore = document.getElementById(hstr + 'hscore');
+ if (!hscore || str_is_blank(hscore.value))
+ errors.push('No score was given for heuristic ' + (hnum + 1));
+ else
+ hscore = hscore.value;
+
+ if (errors.length == 4) {
+ /* The entry is blank -- ignore it. */
+ return (null);
+ }
+
+ /* TODO: hname, hpath */
+ if (hint && !is_valid_int(hint, 1, null))
+ errors.push('Heuristic interval values must be integers greater than 0.');
+
+ if (hscore && !is_valid_int(hscore, null, null))
+ errors.push('Heuristic score values must be integers.');
+
+ if (errors.length > 0)
+ return (errors);
+
+ return (null);
+}
+
+function validate_form(form) {
+ var errors = new Array();
+ if (!form || !form.quorumd) {
+ errors.push('You did not specify whether or not to use a quorum partition.');
+ return (error_dialog(errors));
+ }
+
+ if (form.quorumd[0].checked)
+ qpart = 0
+ else if (form.quorumd[1].checked)
+ qpart = 1;
+ else {
+ errors.push('You submitted an invalid value while specifying whether or not to use a quorum partition: ' + qpart + '.');
+ return (error_dialog(errors));
+ }
+
+ if (qpart) {
+ if (!form.interval || str_is_blank(form.interval.value))
+ errors.push('No interval setting was given.');
+ else {
+ if (!is_valid_int(form.interval.value, 1, null))
+ errors.push('Interval values must be integers greater than 0.');
+ }
+
+ if (!form.votes || str_is_blank(form.votes.value))
+ errors.push('No votes setting was given.');
+ else {
+ if (!is_valid_int(form.votes.value, null, null))
+ errors.push('Votes values must be integers.');
+ }
+
+ if (!form.tko || str_is_blank(form.tko.value))
+ errors.push('No TKO setting was given.');
+ else {
+ if (!is_valid_int(form.tko.value, null, null))
+ errors.push('TKO values must be integers.');
+ }
+
+ if (!form.min_score || str_is_blank(form.min_score.value))
+ errors.push('No minimum score setting was given.');
+ else {
+ if (!is_valid_int(form.min_score.value, null, null))
+ errors.push('Minimum score values must be integers.');
+ }
+
+ if (!form.device || str_is_blank(form.device.value))
+ errors.push('No device setting was given.');
+ else {
+ /* TODO: check this */
+ device = form.device.value;
+ }
+
+ if (!form.label || str_is_blank(form.label.value))
+ errors.push('No label setting was given.');
+ else {
+ /* TODO: check this */
+ label = form.device.label;
+ }
+
+ hnum = document.getElementById('num_heuristics');
+ if (hnum) {
+ hnum = Number(hnum.value);
+ if (hnum == 0)
+ hnum++;
+ for (var i = 0 ; i < hnum ; i++) {
+ var err = check_heuristic(i, form);
+ if (err)
+ errors = errors.concat(err);
+ }
+ }
+
+ if (error_dialog(errors))
+ return (-1);
+ }
+
+ if (confirm('Update quorum partition properties?'))
+ form.submit()
+}
+
+var oldInput = null;
+
+function addHeuristic(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+ hnum = document.getElementById('num_heuristics');
+ if (!hnum)
+ return;
+
+ var cur_hnum = Number(hnum.value) + 1;
+ if (cur_hnum >= 10) {
+ alert('There is a maximum of 10 heuristics.');
+ return;
+ }
+ hstr = 'heuristic' + cur_hnum + ':';
+
+ name_td = document.createElement('td');
+ name_td.className = 'systemsTable';
+ name_input = document.createElement('input');
+ name_input.className = 'qdname qdisk';
+ name_input.setAttribute('name', hstr + 'hname');
+ name_input.setAttribute('id', hstr + 'hname');
+ name_input.setAttribute('type', 'text');
+ name_td.appendChild(name_input);
+
+ path_td = document.createElement('td');
+ path_td.className = 'systemsTable';
+ path_input = document.createElement('input');
+ path_input.className = 'qdpath qdisk';
+ path_input.setAttribute('name', hstr + 'hprog');
+ path_input.setAttribute('id', hstr + 'hprog');
+ path_input.setAttribute('type', 'text');
+ path_td.appendChild(path_input);
+
+ interval_td = document.createElement('td');
+ interval_td.className = 'systemsTable';
+ interval_input = document.createElement('input');
+ interval_input.className = 'qdint qdisk';
+ interval_input.setAttribute('name', hstr + 'hinterval');
+ interval_input.setAttribute('id', hstr + 'hinterval');
+ interval_input.setAttribute('type', 'text');
+ interval_td.appendChild(interval_input);
+
+ score_td = document.createElement('td');
+ score_td.className = 'systemsTable';
+ score_input = document.createElement('input');
+ score_input.className = 'qdscore qdisk';
+ score_input.setAttribute('name', hstr + 'hscore');
+ score_input.setAttribute('id', hstr + 'hscore');
+ score_input.setAttribute('type', 'input');
+ score_td.appendChild(score_input);
+
+ tr = document.createElement('tr');
+ tr.className = 'systemsTable';
+ tr.appendChild(name_td);
+ tr.appendChild(path_td);
+ tr.appendChild(interval_td);
+ tr.appendChild(score_td);
+ parent.appendChild(tr);
+ hnum.value++;
+}
+
+function disableChildrenInput(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+
+ inputElem = parent.getElementsByTagName('input');
+ if (!inputElem || inputElem.length < 1) {
+ oldInput = null;
+ return;
+ }
+ if (inputElem[0].disabled)
+ return;
+ oldInput = new Array(inputElem.length);
+ for (var i = 0 ; i < inputElem.length ; i++) {
+ e = inputElem[i];
+
+ e.disabled = true;
+ if (e.type == 'button')
+ continue;
+ oldInput[e.name] = e.value;
+ e.value = '';
+ }
+}
+
+function enableChildrenInput(parent_name) {
+ parent = document.getElementById(parent_name);
+ if (!parent)
+ return;
+
+ inputElem = parent.getElementsByTagName('input');
+ if (!inputElem || inputElem.length < 1) {
+ return;
+ }
+
+ if (!inputElem[0].disabled)
+ return;
+
+ for (var i = 0 ; i < inputElem.length ; i++) {
+ e = inputElem[i];
+ e.disabled = false;
+ if (e.type == 'button')
+ continue;
+ if (oldInput && oldInput[e.name])
+ e.value = oldInput[e.name];
+ else
+ e.value = '';
+ }
+ oldInput = null;
+}
--- conga/luci/cluster/form-macros 2006/08/16 23:40:03 1.49
+++ conga/luci/cluster/form-macros 2006/08/17 16:22:41 1.50
@@ -361,6 +361,8 @@
<div id="configTabContent" tal:condition="python: configTabNum == 2">
<form name="fencedaemon" action="" method="get" tal:attributes="action clusterinfo/fencedaemon_url">
+ <script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_fence.js"></script>
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="1">
@@ -389,7 +391,7 @@
<tr class="systemsTable">
<td class="systemsTable" colspan="2">
<div class="systemsTableEnd">
- <input type="submit" value="Apply"/>
+ <input type="button" value="Apply" onClick="validate_form(this.form);" />
</div>
</td>
</tr>
@@ -399,28 +401,10 @@
</div>
<div id="configTabContent" tal:condition="python: configTabNum == 3">
- <script type="text/javascript">
- var prev_mcast_str = '';
+ <script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_multicast.js"></script>
- function disable_mcast(addrId) {
- addrObj = document.getElementById(addrId);
- if (!addrObj || addrObj.disabled)
- return;
- addrObj.disabled = true;
- prev_mcast_str = addrObj.value;
- addrObj.value = '';
- }
-
- function enable_mcast(addrId) {
- addrObj = document.getElementById(addrId);
- if (!addrObj || !addrObj.disabled)
- return;
- addrObj.disabled = false;
- addrObj.value = prev_mcast_str;
- }
- </script>
-
- <form name="multicast" action="" method="get" tal:attributes="action clusterinfo/multicast_url">
+ <form name="multicast" action="" method="post">
<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
<thead class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="1">
@@ -466,7 +450,7 @@
<tfoot class="systemsTable">
<tr class="systemsTable"><td class="systemsTable" colspan="2">
<div class="systemsTableEnd">
- <input type="submit" value="Apply"/>
+ <input type="button" value="Apply" onClick="validate_form(this.form);"/>
</div>
</td></tr>
</tfoot>
@@ -476,7 +460,7 @@
<div id="configTabContent" tal:condition="python: configTabNum == 4">
<script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
- <script type="text/javascript" src="/luci/cluster/validate_qdisk.js"></script>
+ <script type="text/javascript" src="/luci/cluster/validate_config_qdisk.js"></script>
<form name="quorum_partition" action="" method="post">
<input type="hidden" name="pagetype"
tal:attributes="value request/pagetype | request/form/pagetype"
--- conga/luci/homebase/homebase_common.js 2006/08/16 22:59:09 1.4
+++ conga/luci/homebase/homebase_common.js 2006/08/17 16:22:41 1.5
@@ -1,8 +1,8 @@
function is_valid_int(str, min, max) {
- if (str.match(/[^0-9 ]/))
+ if (str.match(/[^0-9 -]/))
return (0);
var val = parseInt(str, 10);
- if (!val || isNaN(val))
+ if (isNaN(val))
return (0);
if (min != null && val < min)
return (0);
next reply other threads:[~2006-08-17 16:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-17 16:22 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-07-12 22:35 [Cluster-devel] conga/luci cluster/form-macros homebase/homeba rmccabe
2007-07-12 15:44 rmccabe
2006-08-16 19:08 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060817162244.8352.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.