[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/cluster clu_portlet_fetcher cluster ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-09-27 22:24:11

Modified files:
	luci/cluster   : clu_portlet_fetcher clusterportlet.css 
	                 form-chooser form-macros index_html 
	                 portlet_cluconfig portlet_cluconfig_macro 
	                 resource-form-macros resource_form_handlers.js 
	                 validate_config_fence.js 
	                 validate_config_general.js 
	                 validate_config_multicast.js 
	                 validate_config_qdisk.js 

Log message:
	better javascript form validation and other minor cleanups

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/clu_portlet_fetcher.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/clusterportlet.css.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-chooser.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.72&r2=1.73
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/index_html.diff?cvsroot=cluster&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/portlet_cluconfig.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/portlet_cluconfig_macro.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_fence.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_general.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_multicast.js.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/validate_config_qdisk.js.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- conga/luci/cluster/clu_portlet_fetcher	2006/06/30 17:00:02	1.1
+++ conga/luci/cluster/clu_portlet_fetcher	2006/09/27 22:24:11	1.2
@@ -7,7 +7,7 @@
 <!-- unchecked_clusystems are all clusters...the check_clusters call filters list through user permissions -->
 <span tal:define="global unchecked_clusystems root/luci/systems/cluster/objectItems"/>
 <span tal:define="global clusystems python:here.check_clusters(request,unchecked_clusystems)"/>
-<div tal:omit-tag="" metal:use-macro="here/portlet_cluconfig/macros/cluchooseportlet" /> 
+<div tal:omit-tag="" metal:use-macro="here/portlet_cluconfig/macros/cluchooseportlet" />
 <span tal:omit-tag="" tal:define="global hasclustername request/clustername |nothing"/>
 <span tal:omit-tag="" tal:condition="hasclustername">
 <div tal:omit-tag="" metal:use-macro="here/portlet_cluconfig/macros/cluconfigportlet" />
--- conga/luci/cluster/clusterportlet.css	2006/07/05 21:00:26	1.2
+++ conga/luci/cluster/clusterportlet.css	2006/09/27 22:24:11	1.3
@@ -11,29 +11,29 @@
     border-collapse: collapse;
     border-spacing: 0;
 }
-                                                                                
+
 #portal-column-one {
     vertical-align: top;
     width: 16em;
 }
-                                                                                
+
 #portal-column-content {
     vertical-align: top;
     margin: 0;
     padding: 0;
 }
-                                                                                
+
 #portal-column-two {
     vertical-align: top;
     width: 16em;
 }
-                                                                                
+
 /* Padding for the columns */
-                                                                                
+
 #portal-column-one .visualPadding {
     padding: 2em 0em 1em 2em;
 }
-                                                                                
+
 #portal-column-two .visualPadding {
     padding: 2em 2em 1em 0em;
 }
@@ -159,7 +159,8 @@
 * html li.cluConfigTreeCurrentItem a:hover {
     height: 1.6em;
 }
-.type-nodecfg, .type-nodes, .type-node, .type-nodelist, 
+
+.type-nodecfg, .type-nodes, .type-node, .type-nodelist,
 .type-nodegrid, .type-nodeadd {
 display: block;
 }
--- conga/luci/cluster/form-chooser	2006/08/16 22:23:46	1.7
+++ conga/luci/cluster/form-chooser	2006/09/27 22:24:11	1.8
@@ -3,14 +3,14 @@
     <title tal:content="template/title">The title</title>
   </head>
   <body>
- 
+
   <metal:choose-form metal:define-macro="main-form">
   <span tal:define="global waiting request/specialpagetype |nothing"/>
   <span tal:condition="busywaiting">
     <div metal:use-macro="here/form-macros/macros/busywaitpage"/>
   </span>
   <span tal:condition="not: busywaiting">
-    <span tal:omit-tag="" tal:define="global ptype request/pagetype |nothing"/>  
+    <span tal:omit-tag="" tal:define="global ptype request/pagetype |nothing"/>
     <span tal:omit-tag="" tal:condition="python: not ptype">
      <div metal:use-macro="here/form-macros/macros/entry-form"/>
     </span>
--- conga/luci/cluster/form-macros	2006/09/26 20:57:09	1.72
+++ conga/luci/cluster/form-macros	2006/09/27 22:24:11	1.73
@@ -738,7 +738,7 @@
 					<input name="password" type="password" autocomplete="off">
 				</td>
 			</tr>
-		</table> 
+		</table>
 		<input type="hidden" name="fence_type" value="wti" />
 	</div>
 
@@ -762,7 +762,7 @@
 					<input name="password" type="password" autocomplete="off">
 				</td>
 			</tr>
-		</table> 
+		</table>
 		<input type="hidden" name="fence_type" value="ilo" />
 	</div>
 
@@ -785,7 +785,7 @@
 				<td>
 					<input name="password" type="password" autocomplete="off">
 				</td>
-		</table> 
+		</table>
 		<input type="hidden" name="fence_type" value="drac" />
 	</div>
 
@@ -809,7 +809,7 @@
 					<input name="password" type="password" autocomplete="off">
 				</td>
 			</tr>
-		</table> 
+		</table>
 		<input type="hidden" name="fence_type" value="rsa" />
 	</div>
 
@@ -837,7 +837,7 @@
 				<td>Auth Type</td>
 				<td><input name="auth_type" type="text"></td>
 			</tr>
-		</table> 
+		</table>
 		<input type="hidden" name="fence_type" value="ipmilan" />
 	</div>
 </div>
@@ -1301,7 +1301,7 @@
 	<h2>Add a Service</h2>
 
 	<div id="resskel" class="invisible">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/service-compose-macro" /> 
+		<tal:block metal:use-macro="here/resource-form-macros/macros/service-compose-macro" />
 	</div>
 
 	<div class="service_comp_list">
@@ -1464,7 +1464,7 @@
 	<h2>Service Composition</h2>
 
 	<div id="resskel" class="invisible">
-		<tal:block metal:use-macro="here/resource-form-macros/macros/service-compose-macro" /> 
+		<tal:block metal:use-macro="here/resource-form-macros/macros/service-compose-macro" />
 	</div>
 
 	<div class="service_comp_list" tal:attributes="id sinfo/root_uuid">
--- conga/luci/cluster/index_html	2006/09/26 19:47:32	1.15
+++ conga/luci/cluster/index_html	2006/09/27 22:24:11	1.16
@@ -11,8 +11,8 @@
    <head metal:use-macro="here/header/macros/html_header">
 
 
-                    
-  
+
+
 
      <metal:fillbase fill-slot="base">
       <metal:baseslot define-slot="base">
@@ -39,12 +39,12 @@
       <span tal:define="global firsttime request/busyfirst |nothing"/>
       <span tal:condition="firsttime">
        <span tal:define="global busywaiting python:True"/>
-        <meta http-equiv="refresh" content="" tal:attributes="content isBusy/refreshurl"/> 
+        <meta http-equiv="refresh" content="" tal:attributes="content isBusy/refreshurl"/>
       </span>
       <span tal:define="global busy isBusy/busy |nothing"/>
        <span tal:condition="busy">
         <span tal:define="global busywaiting python:True"/>
-        <meta http-equiv="refresh" content="" tal:attributes="content isBusy/refreshurl"/> 
+        <meta http-equiv="refresh" content="" tal:attributes="content isBusy/refreshurl"/>
         <span tal:define="ri_agent python:here.getRicciAgent(request/clustername)">
         <span tal:define="resmap python:here.getClusterOS(ri_agent);
                           global isVirtualized resmap/isVirtualized;
@@ -59,7 +59,7 @@
 
     <metal:cssslot fill-slot="css_slot">
       <tal:comment replace="nothing"> A slot where you can insert CSS in the header from a template </tal:comment>
-    
+
   <style type="text/css"><!-- @import url(./clusterportlet.css); --></style>
   <style type="text/css"><!-- @import url(/luci/homebase/luci_homebase.css); --></style>
       <metal:cssslot define-slot="css_slot" />
@@ -101,7 +101,7 @@
 				alert('Can\'t find element with id = ' + container_id);
 				return (-1);
 			}
-                                                                                
+
 			var child_element = document.getElementById(element_id);
 			if (!child_element) {
 				alert('Can\'t find element with id = ' + element_id);
@@ -157,7 +157,7 @@
     <!-- <div tal:define="global hascluster request/clustername |nothing"/>  -->
     <span tal:condition="hascluster">
     <span tal:define="global ricci_agent python:here.getRicciAgentForCluster(request)"/>
-    <div tal:omit-tag="" tal:define="global modelb python:here.getmodelbuilder(ricci_agent)" />  
+    <div tal:omit-tag="" tal:define="global modelb python:here.getmodelbuilder(ricci_agent)" />
     </span>
       <table id="portal-columns">
         <tbody>
@@ -184,14 +184,14 @@
                 <div id="content"
                      metal:define-macro="content">
 
-  
+
 
                   <div class="documentContent" id="region-content">
 
                     <a name="documentContent"></a>
 
                     <metal:bodytext metal:define-slot="main" tal:content="nothing">
-                
+
                       Page body text
                     </metal:bodytext>
                 <span tal:omit-tag="" tal:define="global cname request/clustername |nothing"/>
@@ -202,7 +202,7 @@
 					<h1 tal:content="string:${cname}"></h1>
 				</span>
 
- 
+
              <metal:main-form-content use-macro="here/form-chooser/macros/main-form">
                 <h1>Future Site of Forms</h1>
              </metal:main-form-content>
--- conga/luci/cluster/portlet_cluconfig	2006/06/30 17:00:02	1.1
+++ conga/luci/cluster/portlet_cluconfig	2006/09/27 22:24:11	1.2
@@ -4,17 +4,17 @@
 <body>
 
 
-<div metal:define-macro="cluchooseportlet"   
+<div metal:define-macro="cluchooseportlet"
        tal:omit-tag=""
        tal:define="global data python:here.createCluChooser(request, clusystems)">
-       
+
 <dl class="portlet" id="portlet-cluconfig-tree">
     <dt class="portletHeader">
         <a href="#">
           Clusters
         </a>
     </dt>
-    
+
     <dd class="portletItemSingle">
         <ul class="portletCluConfigTree cluConfigTreeLevel0">
 
@@ -33,14 +33,14 @@
 <div metal:define-macro="cluconfigportlet"
        tal:omit-tag=""
        tal:define="global data python:here.createCluConfigTree(request, modelb)">
-       
+
 <dl class="portlet" id="portlet-cluconfig-tree">
     <dt class="portletHeader">
         <a href="#" tal:attributes="href python:here.getClusterURL(request,modelb)">
-          <div tal:omit-tag="" tal:content="python: here.getClusterAlias(modelb)" /> 
+          <div tal:omit-tag="" tal:content="python: here.getClusterAlias(modelb)" />
         </a>
     </dt>
-    
+
     <dd class="portletItemSingle">
         <ul class="portletCluConfigTree cluConfigTreeLevel0">
 
--- conga/luci/cluster/portlet_cluconfig_macro	2006/06/30 17:00:02	1.1
+++ conga/luci/cluster/portlet_cluconfig_macro	2006/09/27 22:24:11	1.2
@@ -8,7 +8,7 @@
                 cur_item item/currentItem;"
     tal:condition="python: (cur_item or parent_shows_children or children)">
 
-   <tal:level define="item_type_class python: 'type-' + item['cfg_type'];"> 
+   <tal:level define="item_type_class python: 'type-' + item['cfg_type'];">
     <div tal:attributes="class item_type_class">
         <a tal:condition="cur_item"
            tal:attributes="href item/absolute_url;
--- conga/luci/cluster/resource-form-macros	2006/09/23 04:04:08	1.16
+++ conga/luci/cluster/resource-form-macros	2006/09/27 22:24:11	1.17
@@ -43,7 +43,7 @@
 			global rescInf python: here.getResourcesInfo(modelb, request);
 			global msg python: here.appendModel(request, modelb)" />
 
-	<table class="systemsTable" border="0" cellspacing="0">
+	<table class="systemsTable">
 		<thead class="systemsTable">
 			<tr class="systemsTable">
 				<th class="systemsTable" width="100">Resource Name</th>
@@ -250,7 +250,7 @@
 		tal:define="
 			global msg python: here.appendModel(request, modelb);
 			global res python: here.getResourceInfo(modelb, request);
-			global type python: res['tag_name']">
+			global type python: 'tag_name' in res and res['tag_name'] or ''">
 
 		<h2>Configure <span tal:replace="python: res['name']" /></h2>
 
@@ -403,7 +403,7 @@
 		tal:attributes="
 			action processURL | nothing;
 			name res/parent_uuid | nothing">
-		
+
 	<input name="pagetype" type="hidden" value="35" />
 
 	<input name="global" type="hidden"
--- conga/luci/cluster/resource_form_handlers.js	2006/09/26 19:47:32	1.14
+++ conga/luci/cluster/resource_form_handlers.js	2006/09/27 22:24:11	1.15
@@ -81,27 +81,42 @@
 function validate_ip(form) {
 	var errors = new Array();
 
-	if (!form.ip_address || str_is_blank(form.ip_address.value))
-		errors.push('You did not give an IP address.');
-	return (errors);
+	if (!form.ip_address || str_is_blank(form.ip_address.value)) {
+		errors.push('No IP address was given.');
+		set_form_error(form.ip_address);
+		return (errors);
+	}
 
 	var ipstr =	form.ip_address.value;
-	if (!isValidHost(ipstr))
+	if (!isValidHost(ipstr)) {
 		errors.push('\"' + ipstr + '\" is an invalid IP address.');
+		set_form_error(form.ip_address);
+	} else
+		clr_form_error(form.ip_address);
+
 	return (errors);
 }
 
 function validate_nfs_mount(form) {
 	var errors = new Array();
 
-	if (!form.mountpoint || str_is_blank(form.mounpoint.value))
+	if (!form.mountpoint || str_is_blank(form.mounpoint.value)) {
 		errors.push('No mount point was given.');
+		set_form_error(form.mountpoint);
+	} else
+		clr_form_error(form.mountpoint);
 
 	if (!form.host || str_is_blank(form.host.value))
 		errors.push('No NFS server host was given.');
+		set_form_error(form.host);
+	} else
+		clr_form_error(form.host);
 
-	if (!form.exportpath || str_is_blank(form.exportpath.value))
+	if (!form.exportpath || str_is_blank(form.exportpath.value)) {
 		errors.push('No NFS export path was given.');
+		set_form_error(form.exportpath);
+	} else
+		clr_form_error(form.exportpath);
 	return (errors);
 }
 
@@ -113,55 +128,85 @@
 function validate_nfs_client(form) {
 	var errors = new Array();
 
-	if (!form.target || str_is_blank(form.target.value))
+	if (!form.target || str_is_blank(form.target.value)) {
 		errors.push('No NFS client target was given.');
+		set_form_err(form.target);
+	} else
+		clr_form_err(form.target);
 	return (errors);
 }
 
 function validate_filesystem(form) {
 	var errors = new Array();
 
-	if (!form.fsTypeSelect || str_is_blank(form.fsTypeSelect.value))
+	if (!form.fsTypeSelect || str_is_blank(form.fsTypeSelect.value)) {
 		errors.push('No file system type was given.');
+		set_form_err(form.fsTypeSelect);
+	} else
+		clr_form_err(form.fsTypeSelect);
 
-	if (!form.mountpoint || str_is_blank(form.mountpoint.value))
+	if (!form.mountpoint || str_is_blank(form.mountpoint.value)) {
 		errors.push('No file system mount point was given.');
+		set_form_err(form.mountpoint);
+	} else
+		clr_form_err(form.mountpoint);
 
-	if (!form.device || str_is_blank(form.device.value))
+	if (!form.device || str_is_blank(form.device.value)) {
 		errors.push('No device containing the file system was given.');
+		set_form_err(form.device);
+	} else
+		clr_form_err(form.device);
 
-	if (!form.fsid || str_is_blank(form.fsid.value))
+	if (!form.fsid || str_is_blank(form.fsid.value)) {
 		errors.push('No file system ID was given.');
+		set_form_err(form.fsid);
+	} else
+		clr_form_err(form.fsid);
 	return (errors);
 }
 
 function validate_gfs(form) {
 	var errors = new Array();
 
-	if (!form.mountpoint || str_is_blank(form.mountpoint.value))
+	if (!form.mountpoint || str_is_blank(form.mountpoint.value)) {
 		errors.push('No file system mount point was given.');
+		set_form_err(form.mountpoint);
+	} else
+		clr_form_err(form.mountpoint);
 
-	if (!form.device || str_is_blank(form.device.value))
+	if (!form.device || str_is_blank(form.device.value)) {
 		errors.push('No device containing file system was given.');
+		set_form_err(form.device);
+	} else
+		clr_form_err(form.device);
 
-	if (!form.fsid || str_is_blank(form.fsid.value))
+	if (!form.fsid || str_is_blank(form.fsid.value)) {
 		errors.push('No file system ID was given.');
+		set_form_err(form.fsid);
+	} else
+		clr_form_err(form.fsid);
 	return (errors);
 }
 
 function validate_script(form) {
 	var errors = new Array();
 
-	if (!form.file || str_is_blank(form.file.value))
+	if (!form.file || str_is_blank(form.file.value)) {
 		errors.push('No path to the script file was given.');
+		set_form_err(form.file);
+	} else
+		clr_form_err(form.file);
 	return (errors);
 }
 
 function validate_samba(form) {
 	var errors = new Array();
 
-	if (!form.workgroup || str_is_blank(form.workgroup.value))
+	if (!form.workgroup || str_is_blank(form.workgroup.value)) {
 		errors.push('No workgroup was given');
+		set_form_err(form.workgroup);
+	} else
+		clr_form_err(form.workgroup);
 	return (errors);
 }
 
@@ -182,8 +227,11 @@
 
 	var errors = valfn(form);
 	if (form.type.value != 'ip') {
-		if (!form.resourceName || str_is_blank(form.resourceName.value))
+		if (!form.resourceName || str_is_blank(form.resourceName.value)) {
 			errors.push('No resource name was given.')
+			set_form_err(form.resourceName);
+		} else
+			clr_form_err(form.resourceName);
 	}
 
 	if (error_dialog(errors))
@@ -239,7 +287,7 @@
 	var ielem = node.getElementsByTagName('input');
 	if (!ielem)
 		return (null);
-	
+
 	var new_uuid = null;
 	if (!uuid)
 		new_uuid = uuid_list.pop();
--- conga/luci/cluster/validate_config_fence.js	2006/08/17 16:22:41	1.1
+++ conga/luci/cluster/validate_config_fence.js	2006/09/27 22:24:11	1.2
@@ -3,16 +3,23 @@
 
 	if (!form)
 		return (-1);
-
-	if (!form.post_fail_delay || str_is_blank(form.post_fail_delay.value))
+	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))
+		set_form_err(form.post_fail_delay);
+	} 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.');
+		set_form_err(form.post_fail_delay);
+	} else
+		clr_form_err(form.post_fail_delay);
 
-	if (!form.post_join_delay || str_is_blank(form.post_join_delay.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))
+		set_form_err(form.post_join_delay);
+	} 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.');
+		set_form_err(form.post_join_delay);
+	} else
+		clr_form_err(form.post_join_delay);
 
 	if (error_dialog(errors))
 		return (-1);
--- conga/luci/cluster/validate_config_general.js	2006/08/16 23:02:27	1.1
+++ conga/luci/cluster/validate_config_general.js	2006/09/27 22:24:11	1.2
@@ -3,20 +3,26 @@
 	var name = null;
 	var ver = null;
 
-	if (!form.cluname || str_is_blank(form.cluname.value))
+	if (!form.cluname || str_is_blank(form.cluname.value)) {
 		errors.push('You did not specify a cluster name.');
-	else
+		set_form_err(form.cluname);
+	} else {
 		name = form.cluname.value;
+		clr_form_err(form.cluname);
+	}
 
-	if (!form.cfgver || str_is_blank(form.cfgver.value))
+	if (!form.cfgver || str_is_blank(form.cfgver.value)) {
 		errors.push('You did not specify a configuration version.');
+		set_form_err(form.cfgver);
 	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.');
+		set_form_err(form.cfgver);
 		/* TODO: further restrictions? */
-	}
+	} else
+		clr_form_err(form.cfgver);
 
 	if (name) {
 		/* TODO: check this. */;
@@ -27,5 +33,5 @@
 
 	if (confirm('Update general cluster properties?'))
 		form.submit();
-	return (null);
+	return (0);
 }
--- conga/luci/cluster/validate_config_multicast.js	2006/08/17 16:22:41	1.1
+++ conga/luci/cluster/validate_config_multicast.js	2006/09/27 22:24:11	1.2
@@ -22,28 +22,40 @@
 
 	if (!form.mcast) {
 		errors.push('You did not specify how the multicast address should be chosen.');
+		set_form_err(form.mcast[0]);
+		set_form_err(form.mcast[1]);
 		error_dialog(errors);
 		return (-1);
 	}
 
-	var mcast;
+	var mcast = null;
 	if (form.mcast.length > 0 && form.mcast[0].checked)
 		mcast = 0;
 	else if (form.mcast.length > 1 && form.mcast[1].checked)
 		mcast = 1;
-	else
+	else {
 		errors.push('An invalid value was given while specifying how the multicast address should be chosen.');
+		set_form_err(form.mcast[0]);
+		set_form_err(form.mcast[1]);
+	}
 
-	if (error_dialog(errors))
-		return (-1);
+	if (mcast != null) {
+		clr_form_err(form.mcast[0]);
+		clr_form_err(form.mcast[1]);
+		clr_form_err(form.mcast_address);
+	}
 
-	if (mcast) {
-		if (!form.mcast_address || str_is_blank(form.mcast_address.value))
+	if (mcast == 1) {
+		if (!form.mcast_address || str_is_blank(form.mcast_address.value)) {
 			errors.push('No multicast address was given.');
-		else {
+			set_form_err(form.mcast_address);
+		} else {
 			var err = isValidHost(form.mcast_address.value);
-			if (err)
+			if (err) {
 				errors.push(err);
+				set_form_err(form.mcast_address);
+			}
+			clr_form_err(form.mcast_address);
 		}
 	}
 
--- conga/luci/cluster/validate_config_qdisk.js	2006/09/06 22:13:33	1.2
+++ conga/luci/cluster/validate_config_qdisk.js	2006/09/27 22:24:11	1.3
@@ -71,6 +71,7 @@
 
 function check_heuristic(hnum, form) {
 	var errors = new Array();
+	var blank = 0;
 
 	if (hnum < 0)
 		errors.push('An invalid heuristic number was given: ' + hnum);
@@ -83,41 +84,64 @@
 	var hstr = 'heuristic' + hnum;
 
 	var hname = document.getElementById(hstr + ':hname');
-	if (!hname || str_is_blank(hname.value))
+	if (!hname || str_is_blank(hname.value)) {
+		++blank;
 		errors.push('No name was given for heuristic ' + (hnum + 1));
-	else
+		set_form_err(hname);
+	} else {
+		/* XXX sanity check the name */
 		hname = hname.value;
+		clr_form_err(hname);
+	}
 
 	var hpath = document.getElementById(hstr + ':hpath');
-	if (!hpath || str_is_blank(hpath.value))
+	if (!hpath || str_is_blank(hpath.value)) {
+		++blank;
 		errors.push('No path was given for heuristic ' + (hnum + 1));
-	else
+		set_form_err(hpath);
+	} else {
+		/* XXX sanity check the path */
 		hpath = hpath.value;
+		clr_form_err(hpath);
+	}
 
 	var hint = document.getElementById(hstr + ':hinterval');
-	if (!hint || str_is_blank(hint.value))
+	if (!hint || str_is_blank(hint.value)) {
+		++blank;
 		errors.push('No interval was given for heuristic ' + (hnum + 1));
-	else
+		set_form_err(hint);
+	} else {
 		hint = hint.value;
+		if (!is_valid_int(hint, 1, null)) {
+			errors.push('Heuristic interval values must be greater than 0.');
+			set_form_err(hint);
+		} else
+			clr_form_err(hint);
+	}
 
 	var hscore = document.getElementById(hstr + ':hscore');
-	if (!hscore || str_is_blank(hscore.value))
+	if (!hscore || str_is_blank(hscore.value)) {
+		++blank;
 		errors.push('No score was given for heuristic ' + (hnum + 1));
-	else
+		set_form_err(hscore);
+	} else {
 		hscore = hscore.value;
+		if (!is_valid_int(hscore, 0, null)) {
+			errors.push('Heuristic score values must be 0 or greater.');
+			set_form_err(hscore);
+		} else
+			clr_form_err(hscore);
+	}
 
-	if (errors.length == 4) {
+	if (blank == 4) {
 		/* The entry is blank -- ignore it. */
+		clr_form_err(hname);
+		clr_form_err(hpath);
+		clr_form_err(hint);
+		clr_form_err(hscore);
 		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);
 
@@ -126,7 +150,10 @@
 
 function validate_form(form) {
 	var errors = new Array();
+
 	if (!form || !form.quorumd) {
+		set_form_err(form.quorumd[0]);
+		set_form_err(form.quorumd[1]);
 		errors.push('You did not specify whether or not to use a quorum partition.');
 		return (error_dialog(errors));
 	}
@@ -138,50 +165,77 @@
 		qpart = 1;
 	else {
 		errors.push('You submitted an invalid value while specifying whether or not to use a quorum partition.');
+		set_form_err(form.quorumd[0]);
+		set_form_err(form.quorumd[1]);
 		return (error_dialog(errors));
 	}
 
+	if (qpart != null) {
+		clr_form_err(form.quorumd[0]);
+		clr_form_err(form.quorumd[1]);
+	}
+
 	if (qpart) {
-		if (!form.interval || str_is_blank(form.interval.value))
+		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))
+			set_form_err(form.interval);
+		} else {
+			if (!is_valid_int(form.interval.value, 1, null)) {
 				errors.push('Interval values must be integers greater than 0.');
+				set_form_err(form.interval);
+			} else
+				clr_form_err(form.interval);
 		}
 
-		if (!form.votes || str_is_blank(form.votes.value))
+		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.');
+			set_form_err(form.votes);
+		} else {
+			if (!is_valid_int(form.votes.value, 1, null)) {
+				errors.push('Votes values must be greater than 0.');
+				set_form_err(form.votes);
+			} else
+				clr_form_err(form.votes);
 		}
 
-		if (!form.tko || str_is_blank(form.tko.value))
+		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.');
+			set_form_err(form.tko);
+		} else {
+			if (!is_valid_int(form.tko.value, 1, null)) {
+				errors.push('TKO values must be greater than 0.');
+				set_form_err(form.tko);
+			} else
+				clr_form_err(form.tko);
 		}
 
-		if (!form.min_score || str_is_blank(form.min_score.value))
+		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.');
+			set_form_err(form.min_score);
+		} else {
+			if (!is_valid_int(form.min_score.value, 1, null)) {
+				errors.push('Minimum score values must be greater than 0.');
+				set_form_err(form.min_score);
+			} else
+				clr_form_err(form.min_score);
 		}
 
-		if (!form.device || str_is_blank(form.device.value))
+		if (!form.device || str_is_blank(form.device.value)) {
 			errors.push('No device setting was given.');
-		else {
+			set_form_err(form.device);
+		} else {
 			/* TODO: check this */
 			var device = form.device.value;
+			clr_form_err(form.device);
 		}
 
-		if (!form.label || str_is_blank(form.label.value))
+		if (!form.label || str_is_blank(form.label.value)) {
 			errors.push('No label setting was given.');
-		else {
+			set_form_err(form.label);
+		} else {
 			/* TODO: check this */
 			var label = form.device.label;
+			clr_form_err(form.label);
 		}
 
 		var hnum = document.getElementById('num_heuristics');
@@ -195,11 +249,10 @@
 					errors = errors.concat(err);
 			}
 		}
-
-		if (error_dialog(errors))
-			return (-1);
 	}
 
+	if (error_dialog(errors))
+		return (-1);
 	if (confirm('Update quorum partition properties?'))
 		form.submit()
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]