Xlink 1port (#1396)

* Fix support for 1 port devices with xlink

* Fix button height
This commit is contained in:
Tim Wilkinson 2024-08-25 14:34:24 -07:00 committed by GitHub
parent 967ea8f548
commit 1f793f1e0a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 3 deletions

View File

@ -69,11 +69,16 @@ if (request.env.REQUEST_METHOD === "PUT") {
for (let i = 0; i < length(xs); i++) {
xlinks[xs[i].name] = xs[i];
}
let defport = "eth0";
const ports = hardware.getEthernetPorts();
if (length(ports) > 0) {
defport = ports[0].k;
}
uciMesh.foreach("xlink", "interface", x => {
const ux = xlinks[x[".name"]];
if (ux) {
uciMesh.set("xlink", `${ux.name}bridge`, "vlan", ux.vlan);
uciMesh.set("xlink", `${ux.name}bridge`, "ports", [ `${ux.port}:t` ]);
uciMesh.set("xlink", `${ux.name}bridge`, "ports", [ `${ux.port || defport}:t` ]);
uciMesh.commit("xlink");
uciMesh.set("xlink", ux.name, "ifname", `br0.${ux.vlan}`);
@ -109,7 +114,7 @@ if (request.env.REQUEST_METHOD === "PUT") {
uciMesh.set("xlink", `${ux.name}bridge`, "bridge-vlan");
uciMesh.set("xlink", `${ux.name}bridge`, "device", "br0");
uciMesh.set("xlink", `${ux.name}bridge`, "vlan", ux.vlan);
uciMesh.set("xlink", `${ux.name}bridge`, "ports", [ `${ux.port}:t` ]);
uciMesh.set("xlink", `${ux.name}bridge`, "ports", [ `${ux.port || defport}:t` ]);
uciMesh.commit("xlink");
uciMesh.set("xlink", name, "interface");

View File

@ -202,7 +202,7 @@
{
margin-top: 4px;
min-width: 24px;
min-height: 24px;
height: calc(var(--font-base-size) * 2 - 8px);
border-radius: 4px;
color: var(--ctrl-modal-textbox-border-color);
background-color: var(--ctrl-modal-textbox-bg-color);

View File

@ -425,6 +425,7 @@ export function supportsXLink()
switch (getBoard().model.id) {
case "mikrotik,hap-ac2":
case "mikrotik,hap-ac3":
case "mikrotik,sxtsq-5-ac":
case "glinet,gl-b1300":
case "qemu":
case "vmware":
@ -434,6 +435,7 @@ export function supportsXLink()
}
};
const default1PortLayout = [ { k: "lan", d: "lan" } ];
const default5PortLayout = [ { k: "wan", d: "port1" }, { k: "lan1", d: "port2" }, { k: "lan2", d: "port3" }, { k: "lan3", d: "port4" }, { k: "lan4", d: "port5" } ];
const default3PortLayout = [ { k: "lan2", d: "port1" }, { k: "lan1", d: "port2" }, { k: "wan", d: "port3" } ];
const defaultNPortLayout = [];
@ -446,6 +448,8 @@ export function getEthernetPorts()
return default5PortLayout;
case "glinet,gl-b1300":
return default3PortLayout;
case "mikrotik,sxtsq-5-ac":
return default1PortLayout;
case "qemu":
case "vmware":
if (length(defaultNPortLayout) === 0) {