[Cluster-devel] conga/luci/cluster form-macros validate_qdisk. ...

rmccabe at sourceware.org rmccabe at sourceware.org
Wed Aug 16 23:02:27 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-08-16 23:02:27

Modified files:
	luci/cluster   : form-macros validate_qdisk.js 
Added files:
	luci/cluster   : validate_config_general.js 

Log message:
	more javascript form validation

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_general.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.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_qdisk.js.diff?cvsroot=cluster&r1=1.1&r2=1.2

/cvs/cluster/conga/luci/cluster/validate_config_general.js,v  -->  standard output
revision 1.1
--- conga/luci/cluster/validate_config_general.js
+++ -	2006-08-16 23:02:27.256146000 +0000
@@ -0,0 +1,31 @@
+function validate_form(form) {
+	var errors = new Array();
+	var name = null;
+	var ver = null;
+
+	if (!form.cluname || str_is_blank(form.cluname.value))
+		errors.push('You did not specify a cluster name.');
+	else
+		name = form.cluname.value;
+
+	if (!form.cfgver || str_is_blank(form.cfgver.value))
+		errors.push('You did not specify a configuration version.');
+	else
+		ver = form.cfgver.value;
+
+	if (ver && !is_valid_int(ver, 0, null)) {
+		errors.push('The configuration version must be an integer greater than 0.');
+		/* TODO: further restrictions? */
+	}
+
+	if (name) {
+		/* TODO: check this. */;
+	}
+
+	if (error_dialog(errors))
+		return (-1);
+
+	if (confirm('Update general cluster properties?'))
+		form.submit();
+	return (null);
+}
--- conga/luci/cluster/form-macros	2006/08/16 21:48:38	1.47
+++ conga/luci/cluster/form-macros	2006/08/16 23:02:27	1.48
@@ -319,8 +319,9 @@
 	</ul>
 
 	<div id="configTabContent" tal:condition="python: configTabNum == 1">
-		<form name="basecluster" action="" method="get"
-			tal:attributes="action clusterinfo/basecluster_url">
+		<script type="text/javascript" src="/luci/homebase/homebase_common.js"></script>
+		<script type="text/javascript" src="/luci/cluster/validate_config_general.js"></script>
+		<form name="basecluster" action="" method="post">
 		<table id="systemsTable" class="systemsTable" border="0" cellspacing="0">
 			<thead class="systemsTable"> 
 				<tr class="systemsTable"><td class="systemsTable" colspan="1">
@@ -349,7 +350,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>
--- conga/luci/cluster/validate_qdisk.js	2006/08/16 21:33:49	1.1
+++ conga/luci/cluster/validate_qdisk.js	2006/08/16 23:02:27	1.2
@@ -41,10 +41,10 @@
 	}
 
 	/* TODO: hname, hpath */
-	if (hint && isNaN(parseInt(hint)))
-		errors.push('Heuristic interval values must be integers.');
+	if (hint && !is_valid_int(hint, 1, null))
+		errors.push('Heuristic interval values must be integers greater than 0.');
 
-	if (hscore && isNaN(parseInt(hscore)))
+	if (hscore && !is_valid_int(hscore, null, null))
 		errors.push('Heuristic score values must be integers.');
 
 	if (errors.length > 0)
@@ -73,28 +73,28 @@
 		if (!form.interval || str_is_blank(form.interval.value))
 			errors.push('No interval setting was given.');
 		else {
-			if (isNaN(parseInt(form.interval.value)))
-				errors.push('Interval values must be integers.');
+			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 (isNaN(parseInt(form.votes.value)))
+			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 (isNaN(parseInt(form.tko.value)))
+			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 (isNaN(parseInt(form.tko.value)))
+			if (!is_valid_int(form.min_score.value, null, null))
 				errors.push('Minimum score values must be integers.');
 		}
 




More information about the Cluster-devel mailing list