From: rmccabe@sourceware.org <rmccabe@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] conga/luci cluster/form-macros cluster/resourc ...
Date: 14 Sep 2006 21:24:25 -0000 [thread overview]
Message-ID: <20060914212425.1437.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: conga
Changes by: rmccabe at sourceware.org 2006-09-14 21:24:25
Modified files:
luci/cluster : form-macros resource-form-macros
resource_form_handlers.js
luci/homebase : homebase_common.js
luci/site/luci/Extensions: cluster_adapters.py
Log message:
the end of the service/resource frontend nastiness. i hope.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/form-macros.diff?cvsroot=cluster&r1=1.59&r2=1.60
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource-form-macros.diff?cvsroot=cluster&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/cluster/resource_form_handlers.js.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/homebase/homebase_common.js.diff?cvsroot=cluster&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.64&r2=1.65
--- conga/luci/cluster/form-macros 2006/09/13 17:50:22 1.59
+++ conga/luci/cluster/form-macros 2006/09/14 21:24:24 1.60
@@ -1148,15 +1148,9 @@
<div id="resskel" class="invisible">
<tal:block metal:use-macro="here/resource-form-macros/macros/resource-swap-form" />
- <p class="invisible expander">
- <img class="service_tree" name="arrow_down" alt="[-]"
- src="/luci/cluster/arrow_down.png"
- onClick="collapse_div(this)">
- <span class="service_tree expander">Hide Children</span>
- </p>
</div>
- <h2>Service Composition</h2>
+ <h2 onclick="forms_to_xml()">Service Composition</h2>
<div class="service_comp_list" tal:attributes="id sinfo/root_uuid">
@@ -1205,19 +1199,13 @@
<tal:block metal:use-macro="here/resource-form-macros/macros/scr_macro" />
</span>
- <p
- tal:attributes="
- class python: (res['max_depth'] == 0 and 'invisible' or ('rc_indent' + str(res['indent_ctr'] - 1))) + ' expander'">
- <img class="service_tree" name="arrow_down" alt="[-]"
- src="/luci/cluster/arrow_down.png"
- onClick="collapse_div(this)">
- <span class="service_tree expander">Hide Children</span>
- </p>
-
<tal:block
tal:replace="structure python: '</div>' * (res['indent_ctr'] - res['max_depth'])" />
</div>
</div>
+ <form name="master">
+ <input type="hidden" name="form_xml" />
+ </form>
</div>
<div metal:define-macro="service-form">
--- conga/luci/cluster/resource-form-macros 2006/09/13 17:50:22 1.10
+++ conga/luci/cluster/resource-form-macros 2006/09/14 21:24:24 1.11
@@ -4,6 +4,35 @@
</head>
<body>
+<div metal:define-macro="res_form_footer" tal:omit-tag="">
+ <p class="hbSubmit">
+ <input class="hbSubmit" type="button"
+ onClick="validate_form(this.form);"
+ tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
+
+ <tal:block tal:condition="sinfo">
+ <input class="hbSubmit" type="button" value="Add a child"
+ onClick="add_child_resource(this.form)" />
+ <input class="hbSubmit" type="button" value="Delete this resource"
+ onClick="delete_resource(this.form)" />
+ </tal:block>
+ </p>
+
+ <tal:block tal:condition="not:exists:res"
+ tal:define="global expclass string: invisible expander" />
+
+ <tal:block tal:condition="exists:res">
+ <tal:block tal:define="
+ global expclass python: ((res['max_depth'] == 0 and 'invisible ') + 'expander')" />
+ </tal:block>
+
+ <p tal:attributes="class expclass">
+ <img class="service_tree" name="arrow_down" alt="[-]"
+ src="/luci/cluster/arrow_down.png"
+ onClick="collapse_div(this)">
+ <span class="service_tree expander">Hide Children</span>
+ </p>
+</div>
<div metal:define-macro="resources-form">
<h2>Resources for <span tal:replace="request/clustername" /></h2>
@@ -64,30 +93,27 @@
</div>
<div metal:define-macro="resource-swap-form">
-<form>
<p class="reshdr">
<strong class="reshdr">Select a Resource Type</strong>
</p>
<p class="reshdr">
- <select onChange="swap_div_elem(this.form.parentNode.parentNode,
- 'invisible', 'container',
- this.options[this.selectedIndex].value);">
- <option name="blank" value="blank" checked>Select a Resource</option>
- <option name="IP" value="IP">IP address</option>
- <option name="FS" value="FS">File system</option>
- <option name="GFS" value="GFS">GFS file system</option>
- <option name="NFSM" value="NFSM">NFS mount</option>
- <option name="NFSC" value="NFSC">NFS client</option>
- <option name="NFSX" value="NFSX">NFS export</option>
- <option name="SCR" value="SCR">Script</option>
- <option name="SMB" value="SMB">Samba</option>
- </select>
+ <form>
+ <select onChange="swap_div_elem(this.form.parentNode,
+ this.options[this.selectedIndex].value);">
+ <option name="blank" value="blank" checked>Select a Resource</option>
+ <option name="IP" value="IP">IP address</option>
+ <option name="FS" value="FS">File system</option>
+ <option name="GFS" value="GFS">GFS file system</option>
+ <option name="NFSM" value="NFSM">NFS mount</option>
+ <option name="NFSC" value="NFSC">NFS client</option>
+ <option name="NFSX" value="NFSX">NFS export</option>
+ <option name="SCR" value="SCR">Script</option>
+ <option name="SMB" value="SMB">Samba</option>
+ </select>
+ </form>
</p>
- <div name="container" class="systemsTable">
- </div>
-
<div name="invisible" class="invisible">
<div name="blank"> </div>
<div metal:use-macro="here/resource-form-macros/macros/ip_macro" />
@@ -99,7 +125,6 @@
<div metal:use-macro="here/resource-form-macros/macros/smb_macro" />
<div metal:use-macro="here/resource-form-macros/macros/scr_macro" />
</div>
-</form>
</div>
<div metal:define-macro="resourceadd-form">
@@ -231,9 +256,12 @@
<p class="reshdr">IP Address Resource Configuration</p>
- <form name="ip_form" method="get"
- tal:attributes="action processURL">
- <input name="pagetype" type="hidden" value="35"/>
+ <form method="get"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
+ <input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
tal:attributes="value res/parent_uuid | nothing" />
@@ -274,19 +302,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -320,7 +336,11 @@
<p class="reshdr">File System Resource Configuration</p>
- <form name="fs_form" method="get" tal:attributes="action processURL">
+ <form method="get"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -427,18 +447,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -467,7 +476,11 @@
<p class="reshdr">GFS Resource Configuration</p>
- <form name="gfs_form" method="get" tal:attributes="action processURL">
+ <form method="get"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -543,19 +556,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -584,7 +585,11 @@
<p class="reshdr">NFS Mount Resource Configuration</p>
- <form name="nfsm_form" method="get" tal:attributes="action processURL">
+ <form method="get"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -673,19 +678,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -710,7 +703,11 @@
<p class="reshdr">NFS Client Resource Configuration</p>
- <form name="nfsc_form" method="post" tal:attributes="action processURL">
+ <form method="post"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -761,19 +758,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -794,7 +779,11 @@
<p class="reshdr">NFS Export Resource Configuration</p>
- <form name="nfsx_form" method="post" tal:attributes="action processURL">
+ <form method="post"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -829,19 +818,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -863,7 +840,11 @@
<p class="reshdr">Script Resource Configuration</p>
- <form name="scr_form" method="post" tal:attributes="action processURL">
+ <form method="post"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -906,19 +887,7 @@
</tr>
</table>
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
@@ -944,7 +913,11 @@
Samba Server Configuration
</p>
- <form name="smb_form" method="post" tal:attributes="action processURL">
+ <form method="post"
+ tal:attributes="
+ action processURL | nothing;
+ name res/parent_uuid | nothing">
+
<input name="pagetype" type="hidden" value="35" />
<input name="parent_uuid" type="hidden"
@@ -986,20 +959,7 @@
</td>
</tr>
</table>
-
- <p class="hbSubmit">
- <input class="hbSubmit" type="button"
- onClick="validate_form(this.form);"
- tal:attributes="value python: sinfo and 'Apply' or 'Submit'" />
-
- <tal:block tal:condition="sinfo">
- <input class="hbSubmit" type="button" value="Add a child"
- onClick="add_child_resource(this.form)" />
- <input class="hbSubmit" type="button" value="Delete this resource"
- onClick="delete_resource(this.form)" />
- </tal:block>
- </p>
-
+ <div metal:use-macro="here/resource-form-macros/macros/res_form_footer" />
</form>
</div>
--- conga/luci/cluster/resource_form_handlers.js 2006/09/13 17:50:22 1.7
+++ conga/luci/cluster/resource_form_handlers.js 2006/09/14 21:24:24 1.8
@@ -1,30 +1,64 @@
-function swap_div_elem(container, swap_out_cname, swap_in_cname, swap_in_name) {
- var divs = container.getElementsByTagName('div');
- if (!divs)
+function collapse_div(image) {
+ var span = null;
+ var pdiv = image.parentNode;
+ var spanc = pdiv.getElementsByTagName('span');
+ for (var i = 0 ; i < spanc.length ; i++) {
+ if (spanc[i].className.match(/expander/)) {
+ span = spanc[i];
+ break;
+ }
+ }
+ if (!span)
return (-1);
- var swap_out_cont = null;
- var swap_in_cont = null;
+ var div = pdiv.parentNode.parentNode;
+ while (div) {
+ if (div.tagName && div.tagName.match(/^DIV$/i) &&
+ div.className.match(/service_comp/))
+ {
+ break;
+ }
+ if (!div.nextSibling)
+ div = div.parentNode;
+ else
+ div = div.nextSibling;
+ }
+ if (!div)
+ return (-1);
+
+ var dclass = 'invisible expander service_comp';
+ if (div.className.match(/invisible/))
+ dclass = 'expander service_comp';
+ while (div) {
+ div.className = dclass;
+ div = div.nextSibling;
+ }
+
+ if (image.name == 'arrow_down') {
+ image.src = 'arrow_right.png';
+ image.name = 'arrow_right';
+ image.alt = '[-]';
+ span.innerHTML = 'Show Children';
+ } else {
+ image.src = 'arrow_down.png';
+ image.name = 'arrow_down';
+ image.alt = '[+]';
+ span.innerHTML = 'Hide Children';
+ }
+}
+
+function swap_div_elem(container, swap_in_name) {
var swap_in_elem = null;
- var i = 0;
- while ((!swap_out_cont || !swap_in_cont || !swap_in_elem) && i < divs.length)
- {
- if (!swap_in_cont && divs[i].getAttribute('name') == swap_in_cname)
- swap_in_cont = divs[i];
- else if (!swap_out_cont && divs[i].getAttribute('name') == swap_out_cname)
- swap_out_cont = divs[i];
- else if (!swap_in_elem && divs[i].getAttribute('name') == swap_in_name)
+ var divs = container.getElementsByTagName('div');
+
+ for (var i = 0 ; i < divs.length ; i++) {
+ if (!swap_in_elem && divs[i].getAttribute('name') == swap_in_name)
swap_in_elem = divs[i];
- i++;
}
-
- if (!swap_out_cont || !swap_in_cont || !swap_in_elem)
+ if (!swap_in_elem)
return (-1);
- if (swap_in_cont.id)
- swap_in_elem.id = swap_in_cont.id;
- var temp = swap_in_cont.parentNode.replaceChild(swap_in_elem, swap_in_cont);
- swap_out_cont.appendChild(temp);
+ container.parentNode.replaceChild(swap_in_elem, container);
}
function validate_ip(form) {
@@ -143,7 +177,16 @@
function delete_resource(form) {
if (!confirm('Are you sure you want to delete this resource?'))
return (-1);
- form.submit();
+ var div = document.getElementById(form.uuid.value);
+ if (!div)
+ return (-1);
+ var pdiv = document.getElementById(form.parent_uuid.value);
+ div.parentNode.removeChild(div);
+ var pelem = pdiv.getElementsByTagName('p');
+ for (var i = 0 ; i < pelem.length ; i++) {
+ if (pelem[i].className.match(/expander/))
+ pelem[i].className += ' invisible';
+ }
}
function add_child_resource(form) {
@@ -155,12 +198,12 @@
var ilevel = Number(form.tree_level.value) + 1;
var sdiv = document.getElementById('resskel');
- if (!sdiv)
+ if (!sdiv) {
return (-1);
+ }
var pdiv = document.getElementById(form.uuid.value);
if (!pdiv) {
- alert('failed to find ' + form.uuid.value);
return (-1);
}
@@ -179,8 +222,13 @@
node.id = null;
node.className = null;
ielem = node.getElementsByTagName('input');
- if (!ielem)
+ if (!ielem) {
return (-1);
+ }
+
+ forms = node.getElementsByTagName('form');
+ for (var i = 0 ; i < forms.length ; i++)
+ forms.name = form.uuid.value;
var new_uuid = uuid_list.pop();
for (var i = 0 ; i < ielem.length ; i++) {
@@ -198,7 +246,11 @@
}
if (!child_div) {
- /* enable parent collapse */
+ var pelem = pdiv.getElementsByTagName('p');
+ for (var i = 0 ; i < pelem.length ; i++) {
+ if (pelem[i].className.match(/expander/))
+ pelem[i].className = pelem[i].className.replace(/invisible/,'');
+ }
child_div = document.createElement('div');
} else {
wrap_div = document.createElement('div');
@@ -211,3 +263,29 @@
child_div.appendChild(node);
pdiv.appendChild(child_div);
}
+
+function forms_to_xml() {
+ var form = document.getElementsByTagName('form');
+ var master_form = null;
+ var form_xml = '';
+
+ for (var i = 0 ; i < form.length ; i++) {
+ if (form[i].name == 'master') {
+ master_form = form[i];
+ continue;
+ } else if (!form[i].uuid || !form[i].uuid.value)
+ continue;
+ var temp = form[i].innerHTML.match(/<input [^>]+>/ig).toString().replace(/>(,|$)/g, '/>');
+ if (!temp)
+ continue;
+ form_xml += '<form id="' + form[i].uuid.value + '" parent="' +
+ form[i].parent_uuid.value + '">' + temp + '</form>';
+ }
+
+ if (!master_form || !form_xml)
+ return (-1);
+
+ /* sort this out in the backend */
+ master_form.form_xml.value = form_xml;
+ master_form.submit();
+}
--- conga/luci/homebase/homebase_common.js 2006/09/13 17:50:22 1.9
+++ conga/luci/homebase/homebase_common.js 2006/09/14 21:24:25 1.10
@@ -1,45 +1,3 @@
-function collapse_div(image) {
- if (!image)
- return (-1);
-
- var span = null;
- var pdiv = image.parentNode;
- var spanc = pdiv.getElementsByTagName('span');
- if (!spanc)
- return (-1);
- for (var i = 0 ; i < spanc.length ; i++) {
- if (spanc[i].className.match(/expander/)) {
- span = spanc[i];
- break;
- }
- }
- if (!span)
- return (-1);
-
- var div = image.parentNode.parentNode.nextSibling;
- while (div) {
- if (div.tagName && div.tagName.match(/^DIV$/i) && div.className.match(/expander/))
- break;
- div = div.nextSibling;
- }
- if (!div)
- return (-1);
-
- if (image.name == 'arrow_down') {
- image.src = 'arrow_right.png';
- image.name = 'arrow_right';
- image.alt = '[-]';
- span.innerHTML = 'Show Children';
- div.className = 'invisible expander service_comp';
- } else {
- image.src = 'arrow_down.png';
- image.name = 'arrow_down';
- image.alt = '[+]';
- span.innerHTML = 'Hide Children';
- div.className = 'expander service_comp';
- }
-}
-
function is_valid_int(str, min, max) {
if (str.match(/[^0-9 -]/))
return (0);
--- conga/luci/site/luci/Extensions/cluster_adapters.py 2006/09/13 17:50:22 1.64
+++ conga/luci/site/luci/Extensions/cluster_adapters.py 2006/09/14 21:24:25 1.65
@@ -966,7 +966,7 @@
if svc != None:
indent_ctr = 0
children = svc.getChildren()
- root_uuid = make_uuid('resource')
+ root_uuid = 'toplevel';
for child in children:
recurse_resources(root_uuid, child, resource_list, indent_ctr)
next reply other threads:[~2006-09-14 21:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-14 21:24 rmccabe [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-05-30 5:54 [Cluster-devel] conga/luci cluster/form-macros cluster/resourc rmccabe
2007-02-16 2:12 rmccabe
2007-02-16 2:06 rmccabe
2007-02-08 16:00 rmccabe
2007-02-08 15:59 rmccabe
2007-02-08 5:05 rmccabe
2007-01-26 17:56 rmccabe
2007-01-20 4:50 rmccabe
2006-12-06 22:44 rmccabe
2006-12-05 23:32 rmccabe
2006-12-05 6:44 rmccabe
2006-09-23 4:04 rmccabe
2006-09-13 17:50 rmccabe
2006-09-11 22:22 rmccabe
2006-09-05 21:25 rmccabe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060914212425.1437.qmail@sourceware.org \
--to=rmccabe@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.