From mboxrd@z Thu Jan 1 00:00:00 1970 From: rmccabe@sourceware.org Date: 30 Jun 2006 18:06:11 -0000 Subject: [Cluster-devel] conga/luci/homebase form-macros index_html val ... Message-ID: <20060630180611.26487.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: rmccabe at sourceware.org 2006-06-30 18:06:10 Modified files: luci/homebase : form-macros index_html Added files: luci/homebase : validate_cluster_add.js validate_perm.js validate_sys_add.js validate_sys_remove.js validate_user_add.js validate_user_del.js Log message: move javascript validate functions into their own files Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_cluster_add.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_perm.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_sys_add.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_sys_remove.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_user_add.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/validate_user_del.js.diff?cvsroot=cluster&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/form-macros.diff?cvsroot=cluster&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/index_html.diff?cvsroot=cluster&r1=1.9&r2=1.10 /cvs/cluster/conga/luci/homebase/validate_cluster_add.js,v --> standard output revision 1.1 --- conga/luci/homebase/validate_cluster_add.js +++ - 2006-06-30 18:06:11.143347000 +0000 @@ -0,0 +1,23 @@ +function validateForm(form) { + var errors = new Array(); + + if (!form || !form.clusterName || + str_is_blank(form.clusterName.value)) + { + errors.push('No cluster name was given.'); + } else { + var invalid_chars = str_is_valid(form.clusterName.value, '/[0-9A-Za-z_. -]/g'); + if (invalid_chars) + errors.push('The cluster name you gave contains the following invalid characters: "' + invalid_chars + '".'); + } + + var added_storage = validate_systems(form, errors); + + if (error_dialog(errors)) + return (-1); + + if (confirm("Submit form?")) + form.submit(); + + return (0); +} /cvs/cluster/conga/luci/homebase/validate_perm.js,v --> standard output revision 1.1 --- conga/luci/homebase/validate_perm.js +++ - 2006-06-30 18:06:11.243925000 +0000 @@ -0,0 +1,45 @@ +function validateForm(form) { + var errors = new Array(); + + if (!form || !form.userList) + return (-1); + + var userIdx = form.userList.selectedIndex; + if (userIdx < 0 || !form.userList.options[userIdx].value) + errors.push('You have not selected a valid user.'); + + if (error_dialog(errors)) + return (-1); + + var selected_clusters = new Array(); + var selected_storage = new Array(); + + if (!form) + return (-1); + + var num_clusters = document.getElementById('numClusters').value; + for (var i = 0 ; i < num_clusters ; i++) { + var element = document.getElementById('__CLUSTER' + i); + if (!element || !element.value || !element.checked) + continue; + selected_clusters.push(element.value); + } + + var num_storage = document.getElementById('numStorage').value; + for (var i = 0 ; i < num_storage ; i++) { + var element = document.getElementById('__SYSTEM' + i); + if (!element || !element.value || !element.checked) + continue; + selected_storage.push(element.value); + } + + if (selected_clusters.length + selected_storage.length < 1) + return (0); + + if (error_dialog(errors)) + return (-1); + + if (confirm('Modify permissions for ' + form.userList.options[userIdx].value + '?')) + form.submit(); + return (0); +} /cvs/cluster/conga/luci/homebase/validate_sys_add.js,v --> standard output revision 1.1 --- conga/luci/homebase/validate_sys_add.js +++ - 2006-06-30 18:06:11.326319000 +0000 @@ -0,0 +1,18 @@ +function validateForm(form) { + var errors = new Array(); + + if (!form) + return (-1); + + var added_storage = validate_systems(form, errors); + if (error_dialog(errors)) + return (-1); + + if (added_storage.length > 0 && + confirm("Do you really want to add the following Storage Systems:\n" + added_storage.join('\n'))) + { + form.submit(); + } + + return (0); +} /cvs/cluster/conga/luci/homebase/validate_sys_remove.js,v --> standard output revision 1.1 --- conga/luci/homebase/validate_sys_remove.js +++ - 2006-06-30 18:06:11.406255000 +0000 @@ -0,0 +1,45 @@ +function validateForm(form) { + var errors = new Array(); + var selected_clusters = new Array(); + var selected_storage = new Array(); + + if (!form) + return (-1); + + var num_clusters = document.getElementById('numClusters').value; + for (var i = 0 ; i < num_clusters ; i++) { + var element = document.getElementById('__CLUSTER' + i); + if (!element || !element.value || !element.checked) + continue; + selected_clusters.push(element.value); + } + + var num_storage = document.getElementById('numStorage').value; + for (var i = 0 ; i < num_storage ; i++) { + var element = document.getElementById('__SYSTEM' + i); + if (!element || !element.value || !element.checked) + continue; + selected_storage.push(element.value); + } + + if (selected_clusters.length + selected_storage.length < 1) + return (0); + + if (error_dialog(errors)) + return (-1); + + var confirm_str = 'Do you really want to remove the following managed systems:'; + if (selected_clusters.length > 0) + confirm_str += '\nClusters:\n-' + selected_clusters.join('\n-'); + + if (selected_storage.length > 0) { + if (selected_clusters.length > 0) + confirm_str += '\n'; + + confirm_str += '\nStorage Systems:\n-' + selected_storage.join('\n-'); + } + + if (confirm(confirm_str)) + form.submit(); + return (0); +} /cvs/cluster/conga/luci/homebase/validate_user_add.js,v --> standard output revision 1.1 --- conga/luci/homebase/validate_user_add.js +++ - 2006-06-30 18:06:11.485000000 +0000 @@ -0,0 +1,31 @@ +function validateForm(form) { + var errors = new Array() + + if (!form) + return (-1); + + if (!form.newUserName || !form.newUserName.value) + errors.push('You did not enter a user name.'); + if (!form.newPassword || !form.newPassword.value) + errors.push('You did not enter a password.'); + if (error_dialog(errors)) + return (-1); + + var invalid = str_is_valid(form.newUserName.value, '/[0-9A-Za-z_]/g'); + if (invalid) + errors.push('The user name you specified contains the following invalid characters: "' + invalid + '"'); + + if (str_is_blank(form.newPassword.value)) + errors.push('Passwords may not be blank.'); + else if (form.newPassword.value.length < 5) + errors.push('Passwords must be@least five characters long.'); + else if (form.newPassword.value != form.newPasswordConfirm.value) + errors.push('The passwords you entered do not match.'); + + if (error_dialog(errors)) + return (-1); + + if (confirm('Do you really want to add the user \"' + form.newUserName.value + '\"?')) + form.submit(); + return (0); +} /cvs/cluster/conga/luci/homebase/validate_user_del.js,v --> standard output revision 1.1 --- conga/luci/homebase/validate_user_del.js +++ - 2006-06-30 18:06:11.572831000 +0000 @@ -0,0 +1,26 @@ +function validateForm(form) { + var errors = new Array(); + + if (!form || !form.deluserId) + return (-1); + + var userIdx = form.deluserId.selectedIndex; + if (userIdx <= 0 || + !form.deluserId.options[userIdx] || + !form.deluserId.options[userIdx].value) + { + errors.push('You have not selected a valid user.'); + return (-1); + } + + if (error_dialog(errors)) + return (-1); + + if (confirm('Do you really want to remove the user \"' + + form.deluserId.options[userIdx].value + '\"?')) + { + form.submit(); + } + + return (0); +} --- conga/luci/homebase/form-macros 2006/06/22 03:49:54 1.24 +++ conga/luci/homebase/form-macros 2006/06/30 18:06:10 1.25 @@ -1,7 +1,7 @@ - $Id: form-macros,v 1.24 2006/06/22 03:49:54 rmccabe Exp $ + $Id: form-macros,v 1.25 2006/06/30 18:06:10 rmccabe Exp $ @@ -41,33 +41,7 @@ - selected index is valid - -
@@ -216,52 +159,7 @@ - The rest is checked by the python form submit validator. - if yes, confirm again, showing list - - @@ -650,30 +485,7 @@ - At least one node name/password are given and are valid - --- conga/luci/homebase/index_html 2006/06/30 17:45:20 1.9 +++ conga/luci/homebase/index_html 2006/06/30 18:06:10 1.10 @@ -15,7 +15,7 @@ xml:lang language"> - $Id: index_html,v 1.9 2006/06/30 17:45:20 rmccabe Exp $ + $Id: index_html,v 1.10 2006/06/30 18:06:10 rmccabe Exp $ @@ -55,13 +55,16 @@ + A slot where you can insert javascript in the header from a template -