Skip to contentSkip to conversation

conga/luci/cluster clu_portlet_fetcher cluster ...

Cluster-devel [email protected] 1 participant 1 message Sep 27, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at 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

luci/cluster/clu_portlet_fetcher +1 -1
@@ -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" />
luci/cluster/clusterportlet.css +8 -7
@@ -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;
 }
luci/cluster/form-chooser +2 -2
@@ -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>
luci/cluster/form-macros +7 -7
@@ -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">
luci/cluster/index_html +10 -10
@@ -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>
luci/cluster/portlet_cluconfig +6 -6
@@ -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">
 
luci/cluster/portlet_cluconfig_macro +1 -1
@@ -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;
luci/cluster/resource-form-macros +3 -3
@@ -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"
luci/cluster/resource_form_handlers.js +66 -18

163 lines not on this page · raw message

luci/cluster/validate_config_fence.js +12 -5
@@ -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);
luci/cluster/validate_config_general.js +11 -5
@@ -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);
 }
luci/cluster/validate_config_multicast.js +20 -8
@@ -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);
 		}
 	}
 
luci/cluster/validate_config_qdisk.js +91 -38

206 lines not on this page · raw message