I got distracted by the multiple interface system edit screen and decided to clean it up a bit. A patch and partial screenshot are attached. The javascript is a lot less complex. The screen looks a lot more useable for the common case now. The help text is hidden for interfaces > 0, which saves a ton of vertical space. Each interface is in its own fieldset element now, which groups it better IMO. Configured interfaces are displayed by default. I took out the image-based +/- for now, but it can go back if people really like it better. I only changed it to simplify things while hacking. Most of the stuff in cobbler.js can go away if this approach is taken instead. -Al
diff --git a/webui_templates/system_edit.tmpl b/webui_templates/system_edit.tmpl index 83d5908..baa584d 100644 --- a/webui_templates/system_edit.tmpl +++ b/webui_templates/system_edit.tmpl @@ -12,12 +12,47 @@ <script language="javascript"> +function toggle_vis(target, num, display) +{ + t = document.getElementById(target + num); + c = document.getElementById('control' + num); + next_num = num + 1; + next = document.getElementById('interface' + next_num); + + current = t.style.display; + + if ( display ) { + if ( display == 'none' ) { + current = 'block'; + } + if ( display == 'block' ) { + current = 'none'; + } + } + + if ( t.style.display == 'block' ) { + t.style.display = 'none'; + if ( c ) { + c.innerHTML="[+]"; + } + } + else if ( t.style.display == 'none' ) { + t.style.display = 'block'; + if ( c ) { + c.innerHTML="[-]"; + } + if ( next ) { + next.style.display = 'block'; + } + } +} + function delete_interface(num) { #for $field in $fields document.getElementById("${field}-intf" + num).value = ""; #end for - toggleRowVisibility("id" + num); + toggle_vis('form', num, 'none'); } #if $system @@ -208,12 +243,13 @@ function page_onload() { </td> </tr> - ## ====================================== start of looping through interfaces #set $counter = -1 + #set $have_add_control = None #for $interface in $all_interfaces - #set $counter = $counter+1 + #set $counter = $counter+1 + #set $display = 'none' ## ---------------------------------- ## load up initial variable values @@ -227,6 +263,7 @@ function page_onload() { #set $virtbridge = $system.interfaces[$interface]["virt_bridge"] #set $subnet = $system.interfaces[$interface]["subnet"] #set $gateway = $system.interfaces[$interface]["gateway"] + #set $display = 'block' #else #set $macaddress = "" #set $ipaddress = "" @@ -235,149 +272,148 @@ function page_onload() { #set $virtbridge = "" #set $subnet = "" #set $gateway = "" + #if $counter < 1: + #set display = 'block' + #else + #set display = 'none' + #end if #end if - ## ---------------------------------------- - ## render the toggle link to hide the interfaces not yet defined - ## ---------------------------------------- - - <tr class="listrow" id="1000${counter}"> - <td> - <hr width="100%"/> - </td> - <td> - <hr width="100%"/> - </td> - </tr> - -## -##<td><a onclick="toggleRowVisibility('id263');" style="cursor: pointer;"><img name="id263-image" src="/img/list-expand.gif" alt=""/></a><a href="/network/software/channels/details.pxt?cid=263">Red Hat Enterprise Linux (v. 5 for 32-bit x86)</a></td> -## - - <tr class="listrow" id="id${counter}"> - <td> - Interface $interface.replace("intf","") - </td> - <td> - <a onclick="toggleRowVisibility('id${counter}');" style="cursor: pointer;"><img name="id${counter}-image" src="/cobbler/webui/list-expand.png" alt=""/></A> - </td> - </tr> - - ## ---------------------------------------- - ## now show all of the interface fields which may or may not - ## be hidden but are always there - ## ---------------------------------------- - - <tr class="listrow" id="child-id${counter}-0"> - <td> - <label for="macaddress-$interface">MAC</label> - </td> - <td> - <input type="text" size="64" style="width: 150px;" name="macaddress-$interface" id="macaddress-$interface" - value="$macaddress" - /> - #if not $system - <a href="javascript: get_random_mac()" style="font-size: 0.8em;">random</a> - #end if - <p class="context-tip">Example: AA:BB:CC:DD:EE:FF</p> - </td> - </tr> - - <tr class="listrow" id="child-id${counter}-1"> - <td> - <label for="ipaddress-$interface">IP</label> - </td> - <td> - <input type="text" size="64" style="width: 150px;" name="ipaddress-$interface" id="ipaddress-$interface" - value="$ipaddress" - /> - <p class="context-tip">Example: 192.168.10.15</p> - </td> - </tr> - - <tr class="listrow" id="child-id${counter}-3"> - <td> - <label for="hostname-$interface">Hostname</label> - </td> - <td> - <input type="text" size="255" style="width: 150px;" name="hostname-$interface" id="hostname-$interface" - value="$hostname" - /> - <p class="context-tip">Example: vanhalen.example.org</p> - </td> - </tr> - - <tr class="listrow" id="child-id${counter}-4"> - <td> - <label for="dhcptag-$interface">DHCP Tag</label> - </td> - <td> - <input type="text" size="128" style="width: 150px;" name="dhcptag-$interface" id="dhcptag-$interface" - value="$dhcptag" - /> - <p class="context-tip">Selects alternative subnets, see manpage or leave blank</p> - </td> - </tr> - - ## FIXME: add virt_bridge editing (like above) - - <tr class="listrow" id="child-id${counter}-5"> - <td> - <label for="virtbridge-$interface">Virt Bridge</label> - </td> - <td> - <input type="text" size="20" style="width: 150px;" name="virtbridge-$interface" id="virtbridge-$interface" - value="$virtbridge" - /> - <p class="context-tip">Example: 'xenbr0' or 'virbr0'. Can be blank if set in profile or settings.</p> - </td> - </tr> - - ## FIXME: add subnet editing (like above) - - <tr class="listrow" id="child-id${counter}-6"> - <td> - <label for="subnet-$interface">Subnet</label> - </td> - <td> - <input type="text" size="64" style="width: 150px;" name="subnet-$interface" id="subnet-$interface" - value="$subnet" - /> - <p class="context-tip">Ex: "255.255.255.0". For use in kickstart templates for static IPs.</p> - </td> - </tr> - - ## FIXME: add gateway editing (like above) - - <tr class="listrow" id="child-id${counter}-7"> - <td> - <label for="gateway-$interface">Gateway</label> - </td> - <td> - <input type="text" size="64" style="width: 150px;" name="gateway-$interface" id="gateway-$interface" - value="$gateway" - /> - <p class="context-tip">Ex: "192.168.1.11". For use in kickstart templates for static IPs.</p> - </td> - </tr> - - #if $interface != "intf0" - <tr class="listrow" id="child-id${counter}-8"> + <tr class="listrow" id="tr${counter}"> <td> - <label for="enabled-$interface">Remove</label> + #if $counter == 0: + Interface $interface.replace("intf","") + #else + <span id="interface${counter}" + #if $have_add_control is None: + style="display: block;" + #set $have_add_control = 1 + #else if $display is 'block': + style="display: block;" + #else + style="display: none;" + #end if + > + Interface $interface.replace("intf","") + <a onclick="toggle_vis('form', ${counter});" id="control${counter}" style="cursor: pointer;">[+]</a> + </span> + #end if </td> - <td> - <input type="button" name="delete-$interface" value="remove" onclick="delete_interface($counter)"> - <p class="context-tip">Clicking this button removes the interface from the configuration.</p> - </td> - </tr> - #end if - - - ## FIXME: make the save function understand the new fieldname-$interface variables - ## only enable an interface for saving if one of it's fields is non-empty - ## FIXME: delete checkboxes and accompanying API method. No delete for intf0. + <td> + <div id="form${counter}" style="display: $display;"> + <br/> + <fieldset id="cform"> + + <!-- MAC --> + <label for="macaddress-$interface">MAC</label> + <input type="text" size="64" style="width: 150px;" name="macaddress-$interface" id="macaddress-$interface" + value="$macaddress" + /> + #if not $system + <a href="javascript: get_random_mac()" style="font-size: 0.8em;">random</a> + #end if + #if $counter == 0: + <p class="context-tip">Example: AA:BB:CC:DD:EE:FF</p> + #else: + <br/> + #end if + + <!-- IP --> + <label for="ipaddress-$interface">IP</label> + <input type="text" size="64" style="width: 150px;" + name="ipaddress-$interface" id="ipaddress-$interface" + value="$ipaddress"/> + #if $counter == 0: + <p class="context-tip">Example: 192.168.10.15</p> + #else: + <br/> + #end if + + <! -- hostname --> + <label for="hostname-$interface">Hostname</label> + <input type="text" size="255" style="width: 150px;" + name="hostname-$interface" id="hostname-$interface" + value="$hostname" + /> + #if $counter == 0: + <p class="context-tip">Example: vanhalen.example.org</p> + #else: + <br/> + #end if + + <!-- DHCP Tag --> + <label for="dhcptag-$interface">DHCP Tag</label> + <input type="text" size="128" style="width: 150px;" + name="dhcptag-$interface" id="dhcptag-$interface" + value="$dhcptag"/> + #if $counter == 0: + <p class="context-tip">Selects alternative subnets, see manpage or leave blank</p> + #else: + <br/> + #end if + + ## FIXME: add virt_bridge editing (like above) + + <!-- Virt Bridge --> + <label for="virtbridge-$interface">Virt Bridge</label> + <input type="text" size="20" style="width: 150px;" + name="virtbridge-$interface" id="virtbridge-$interface" + value="$virtbridge"/> + #if $counter == 0: + <p class="context-tip">Example: 'xenbr0' or 'virbr0'. Can be blank if set in profile or settings.</p> + #else: + <br/> + #end if + + ## FIXME: add subnet editing (like above) + + <!-- Gateway --> + <label for="subnet-$interface">Subnet</label> + <input type="text" size="64" style="width: 150px;" + name="subnet-$interface" id="subnet-$interface" + value="$subnet"/> + #if $counter == 0: + <p class="context-tip">Ex: "255.255.255.0". For use in kickstart templates for static IPs.</p> + #else: + <br/> + #end if + + ## FIXME: add gateway editing (like above) + + <!-- Gateway Interface --> + <label for="gateway-$interface">Gateway</label> + <input type="text" size="64" style="width: 150px;" + name="gateway-$interface" id="gateway-$interface" + value="$gateway"/> + #if $counter == 0: + <p class="context-tip">Ex: "192.168.1.11". For use in kickstart templates for static IPs.</p> + #else: + <br/> + #end if + + <!-- remove button --> + #if $interface != "intf0" + <label for="enabled-$interface">Remove</label> + <input type="button" name="delete-$interface" + value="remove" onclick="delete_interface($counter);"/> + #if $counter == 0: + <p class="context-tip">Clicking this button removes the interface from the configuration.</p> + #else: + <br/> + #end if + #end if + + + ## FIXME: make the save function understand the new + ## fieldname-$interface variables only enable an interface for + ## saving if one of it's fields is non-empty + ## FIXME: delete checkboxes and accompanying API method. No + ## delete for intf0. + </fieldset> + </div> + </td> + </tr> #end for ## ====================================== end of looping through interfaces
Attachment:
cobbler-system-interfaces-tobeya.jpg
Description: JPEG image
_______________________________________________ et-mgmt-tools mailing list et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools