Skip to contentSkip to conversation

conga/luci/cluster form-chooser resource_form_ ...

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

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: conga
Changes by: jparsons at sourceware.org 2006-07-27 16:32:46

Modified files:
luci/cluster : form-chooser
Added files:
luci/cluster : resource_form_handlers.js resource-form-macros

Log message:
Support for cluster resources

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-chooser.diff?cvsroot=cluster&r1=1.3&r2=1.4

/cvs/cluster/conga/luci/cluster/resource_form_handlers.js,v --> standard output revision 1.1

- renamed from luci/cluster/resource_form_handlers.js +163 -0
@@ -0,0 +1,163 @@
+/*swap_div switches between types of forms
+ * based on a chooser within the document */
+function swap_div(container_id, element_id){
+  container_element = document.getElementById(container_id);
+  if (!container_element) {
+    alert('Can\'t find element with id = ' + container_id);
+    return (-1)
+      }
+  child_element = document.getElementById(element_id);
+  if (!child_element) {
+    alert('Can\'t find element with id = ' + element_id);
+    return (-1)
+      }
+  for(child in child_element.children){
+    alert(child);
+  }
+  temp = container_element.firstChild;
+  container_element.replaceChild(child_element, container_element.firstChild);
+  
+  invisible_div = document.getElementById('invisible');
+  if (!invisible_div) {
+    alert('No invisible div');
+    return (-1)
+      } 
+  
+  invisible_div.appendChild(temp);
+}
+
+/*In order to val a new resource type, 
+ *create a form within the resource-form-macros 
+ *with 'resource-name'_form as the 'name' 
+ *attribute, and use:
+ * onSubmit="valResource('resource-name'_form)"
+ *val handler functions here and further
+ *down within actual cluster code.*/
+
+function validate(form){
+  if(form.resourceName.value.length == 0){
+    alert("Please enter a name for this resource. \n");
+    return;
+  }
+  name = form.getAttribute("name");
+  /*Get the type of form from the first
+   *part of the name string*/
+  type = name.split("_")[0];
+  /*use eval to access proper resource
+   *valer function as defined below*/
+  eval("val"+(type.toUpperCase())+"(form);");
+  /*TODO: val error checking!!!*/
+}
+
+/*Val an IP Resource*/
+function valIP(form){
+  /*first, check to make sure all input 
+   *fields have values*/
+  if (isNaN(parseInt(form.ip1.value)) ||
+     isNaN(parseInt(form.ip2.value)) ||
+     isNaN(parseInt(form.ip3.value)) ||
+     isNaN(parseInt(form.ip4.value)) ) {
+    error = "The IP Address contains illegal characters. \n";
+    alert(error);
+  }
+  else{
+    form.submit();
+  }
+}
+
+/*Val an NFS Mount Resource*/
+function valNFSM(form){
+  error = ""
+  /*check to make sure all input
+   *fields have values*/
+  if(form.mountpoint.value == "")
+    error += "Please enter a mount point.\n";
+  if(form.host.value == "")
+    error += "Please enter a host.\n";
+  if(form.exportpath.value == "")
+    error += "Please enter an export path.\n";
+  if(error != "")
+    alert(error);
+  else
+    form.submit();
+}
+
+/*Validate an NFS Export Resource*/
+function valNFSX(form){
+  form.submit();
+}
+
+/*Validate an NFS Client Resource*/
+function valNFSC(form){
+  error = ""
+  /*check to make sure all input
+   *fields have values*/
+  if(form.target.value == "")
+    error += "Please enter a target.\n";
+  if(error != "")
+    alert(error);
+  else
+    form.submit();
+}
+
+/*Validate an FS Resource*/
+function valFS(form){
+  error = ""
+  /*check to make sure all input
+   *fields have values*/
+  if(form.fsTypeSelect.value == "")
+    error += "Please Select a file system type.\n";
+  if(form.mountpoint.value == "")
+    error += "Please enter a mount point.\n";
+  if(form.device.value == "")
+    error += "Please enter a device.\n";
+  if(form.fsid.value == "")
+    error += "Please enter a file system id.\n";
+  if(error != "")
+    alert(error);
+  else
+    form.submit(); 
+}
+
+/*Validate a GFS Resource*/
+function valGFS(form){
+  error = ""
+  /*check to make sure all input
+   *fields have values*/
+  if(form.mountpoint.value == "")
+    error += "Please enter a mount point.\n";
+  if(form.device.value == "")
+    error += "Please enter a device.\n";
+  if(form.fsid.value == "")
+    error += "Please enter a file system id.\n";
+  if(error != "")
+    alert(error);
+  else
+    form.submit(); 
+}
+
+/*Validate a Script Resource*/
+function valSCR(form){
+  error = ""
+  /*check to make sure all input
+   *fields have values*/
+  if(form.file.value == "")
+    error += "Please enter a filename.\n";
+  if(error != "")
+    alert(error);
+  else
+    form.submit(); 
+}
+
+/*Validate a Samba Resource*/
+function valSMB(form){
+  error = ""
+  /*check to make sure all input
+   *fields have values*/
+  if(form.workgroup.value == "")
+    error += "Please enter a workgroup.\n";
+  if(error != "")
+    alert(error);
+  else
+    form.submit();   
+}

/cvs/cluster/conga/luci/cluster/resource-form-macros,v --> standard output revision 1.1

- renamed from luci/cluster/resource-form-macros +647 -0

647 lines not on this page · raw message

luci/cluster/form-chooser +6 -6
@@ -84,22 +84,22 @@
      <div metal:use-macro="here/form-macros/macros/servicerestart"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '30'">
-     <div metal:use-macro="here/form-macros/macros/resources-form"/>
+     <div metal:use-macro="here/resource-form-macros/macros/resources-form"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '31'">
-     <div metal:use-macro="here/form-macros/macros/resourceadd-form"/>
+     <div metal:use-macro="here/resource-form-macros/macros/resourceadd-form"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '32'">
-     <div metal:use-macro="here/form-macros/macros/resourcelist-form"/>
+     <div metal:use-macro="here/resource-form-macros/macros/resourcelist-form"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '33'">
-     <div metal:use-macro="here/form-macros/macros/resourceconfig-form"/>
+     <div metal:use-macro="here/resource-form-macros/macros/resourceconfig-form"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '34'">
-     <div metal:use-macro="here/form-macros/macros/resource-form"/>
+     <div metal:use-macro="here/resource-form-macros/macros/resource-form"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '35'">
-     <div metal:use-macro="here/form-macros/macros/resourceprocess-form"/>
+     <div metal:use-macro="here/resource-form-macros/macros/resourceprocess-form"/>
     </span>
     <span tal:omit-tag="" tal:condition="python: ptype == '40'">
      <div metal:use-macro="here/form-macros/macros/fdoms-form"/>