mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
Use numeric prefix for IPv6 mask
This commit is contained in:
parent
5a34560381
commit
1f4b973968
@ -120,7 +120,7 @@ export const parseAddress = (address: string) => {
|
||||
const [ip, cidr] = address.split("/");
|
||||
const isIPv6 = ip.includes(":");
|
||||
const mask = cidr ? cidrToNetmask(cidr, isIPv6) : null;
|
||||
return { ip, mask };
|
||||
return { ip, mask, prefix: cidr };
|
||||
};
|
||||
|
||||
export const formatAddress = (ip: string, mask: string) =>
|
||||
|
@ -380,7 +380,7 @@ export class HassioNetwork extends LitElement {
|
||||
? html`
|
||||
${this._interface![version].address.map(
|
||||
(address: string, index: number) => {
|
||||
const { ip, mask } = parseAddress(address);
|
||||
const { ip, mask, prefix } = parseAddress(address);
|
||||
return html`
|
||||
<div class="address-row">
|
||||
<ha-textfield
|
||||
@ -395,18 +395,35 @@ export class HassioNetwork extends LitElement {
|
||||
.disabled=${disableInputs}
|
||||
>
|
||||
</ha-textfield>
|
||||
<ha-textfield
|
||||
id="netmask"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.network.supervisor.netmask"
|
||||
)}
|
||||
.version=${version}
|
||||
.value=${mask}
|
||||
.index=${index}
|
||||
@change=${this._handleInputValueChanged}
|
||||
.disabled=${disableInputs}
|
||||
>
|
||||
</ha-textfield>
|
||||
${version === "ipv6"
|
||||
? html`
|
||||
<ha-textfield
|
||||
id="prefix"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.network.supervisor.prefix"
|
||||
)}
|
||||
.version=${version}
|
||||
.value=${prefix || ""}
|
||||
.index=${index}
|
||||
@change=${this._handleInputValueChanged}
|
||||
.disabled=${disableInputs}
|
||||
>
|
||||
</ha-textfield>
|
||||
`
|
||||
: html`
|
||||
<ha-textfield
|
||||
id="netmask"
|
||||
.label=${this.hass.localize(
|
||||
"ui.panel.config.network.supervisor.netmask"
|
||||
)}
|
||||
.version=${version}
|
||||
.value=${mask || ""}
|
||||
.index=${index}
|
||||
@change=${this._handleInputValueChanged}
|
||||
.disabled=${disableInputs}
|
||||
>
|
||||
</ha-textfield>
|
||||
`}
|
||||
${this._interface![version].address.length > 1 &&
|
||||
!disableInputs
|
||||
? html`
|
||||
@ -667,6 +684,11 @@ export class HassioNetwork extends LitElement {
|
||||
const { ip } = parseAddress(this._interface![version]!.address![index]);
|
||||
this._interface[version]!.address![index] = formatAddress(ip, value);
|
||||
this.requestUpdate("_interface");
|
||||
} else if (id === "prefix") {
|
||||
const index = (ev.target as any).index as number;
|
||||
const { ip } = parseAddress(this._interface![version]!.address![index]);
|
||||
this._interface[version]!.address![index] = `${ip}/${value}`;
|
||||
this.requestUpdate("_interface");
|
||||
} else if (id === "nameserver") {
|
||||
const index = (ev.target as any).index as number;
|
||||
this._interface[version]!.nameservers![index] = value;
|
||||
|
@ -6319,6 +6319,7 @@
|
||||
"disabled": "Disabled",
|
||||
"ip": "IP address",
|
||||
"netmask": "Netmask",
|
||||
"prefix": "Subnet prefix",
|
||||
"add_address": "Add address",
|
||||
"gateway": "Gateway address",
|
||||
"dns_server": "DNS Server",
|
||||
|
Loading…
x
Reference in New Issue
Block a user