]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
zoneconf.cgi: Add Javascript for new GUI elements
authorLeo-Andres Hofmann <hofmann@leo-andres.de>
Thu, 18 Feb 2021 14:30:14 +0000 (15:30 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Feb 2021 18:58:13 +0000 (18:58 +0000)
Signed-off-by: Leo-Andres Hofmann <hofmann@leo-andres.de>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
html/cgi-bin/zoneconf.cgi
html/html/include/zoneconf.js

index 1d30450ed518e2fda22ea1dd638ce3e1e112a086..eb6cd0e6666329d2a1a8119cb7417f7de2e9e3fc 100644 (file)
@@ -410,7 +410,7 @@ foreach (@zones) {
 
        print <<END
                <td class='heading bold $_'>$uc<br>
-                       <select name="MODE $uc">
+                       <select name="MODE $uc" data-zone="$uc" onchange="changeZoneMode(this)">
                                <option value="DEFAULT" $mode_selected{"DEFAULT"}>$Lang::tr{"zoneconf nicmode default"}</option>
                                <option value="BRIDGE" $mode_selected{"BRIDGE"}>$Lang::tr{"zoneconf nicmode bridge"}</option>
                                <option value="MACVTAP" $mode_selected{"MACVTAP"}>$Lang::tr{"zoneconf nicmode macvtap"}</option>
@@ -544,7 +544,7 @@ foreach (@zones) { # load settings and prepare form elements for each zone
        # enable checkbox HTML
        my $row_1 = <<END
                <td>
-                       <input type="checkbox" name="STP-$uc" $disabled $checked>
+                       <input type="checkbox" id="STP-$uc" name="STP-$uc" data-zone="$uc" onchange="changeEnableSTP(this)" $disabled $checked>
                </td>
 END
 ;
@@ -553,7 +553,7 @@ END
        # priority input box HTML
        my $row_2 = <<END
                <td>
-                       <input type="number" class="stp-priority" name="STP-PRIORITY-$uc" min="1" max="65535" value="$stp_priority" $disabled>
+                       <input type="number" class="stp-priority" id="STP-PRIORITY-$uc" name="STP-PRIORITY-$uc" min="1" max="65535" value="$stp_priority" $disabled>
                </td>
 END
 ;
index d76f0ab68ad645e676544255c1a02c03dc821349..d27a79bc8949dcc42e5c7f58987591fe6be9edf5 100644 (file)
@@ -54,3 +54,30 @@ function highlightAccess(selectObj) {
        //if interface is assigned, highlight table cell in zone color
        colorParentCell(selectObj, zoneColor, (selectObj.value !== 'NONE'));
 }
+
+//update zone mode
+function changeZoneMode(selectObj) {
+       if(!(selectObj && ('zone' in selectObj.dataset))) {
+               return; //required parameters are missing
+       }
+
+       // STP enable checkbox
+       let stpEnable = document.getElementById('STP-' + selectObj.dataset.zone);
+       if(stpEnable) {
+               stpEnable.disabled = (selectObj.value !== 'BRIDGE'); //STP is available if zone is in bridge mode
+               stpEnable.checked = stpEnable.checked && (! stpEnable.disabled); //un-check if disabled
+               stpEnable.dispatchEvent(new Event('change'));
+       }
+}
+
+//STP enable checkbox change toggles priority input
+function changeEnableSTP(inputObj) {
+       if(!(inputObj && ('zone' in inputObj.dataset))) {
+               return; //required parameters are missing
+       }
+
+       let priority = document.getElementById('STP-PRIORITY-' + inputObj.dataset.zone);
+       if(priority) {
+               priority.disabled = inputObj.disabled || (! inputObj.checked);
+       }
+}