Skip to content

Commit f37833f

Browse files
authored
Backport tailscale network status changes (#1895)
Resolves #1894 This change adjusts network status related changes on [Tailscale change on Network Status dialog](tiny-pilot/tinypilot-pro#1549) to support tailnet status. <a data-ca-tag href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1895"><img src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review on CodeApprove" /></a>
1 parent 0a37d81 commit f37833f

File tree

2 files changed

+30
-17
lines changed

2 files changed

+30
-17
lines changed

app/templates/custom-elements/network-status-dialog.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ <h3>Network Status</h3>
117117
}
118118

119119
async _update() {
120+
// Check Ethernet/WiFi status.
120121
let networkStatus;
121122
try {
122123
networkStatus = await getNetworkStatus();
@@ -129,11 +130,14 @@ <h3>Network Status</h3>
129130
);
130131
return;
131132
}
132-
this._elements.statusEthernet.update(
133+
this._elements.statusEthernet.setEthernetWifi(
133134
"Ethernet",
134135
networkStatus.ethernet
135136
);
136-
this._elements.statusWifi.update("Wi-Fi", networkStatus.wifi);
137+
this._elements.statusWifi.setEthernetWifi(
138+
"Wi-Fi",
139+
networkStatus.wifi
140+
);
137141
}
138142
}
139143
);

app/templates/custom-elements/network-status-interface.html

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,19 @@
3939
display: inline-block;
4040
}
4141

42-
:host([is-connected=""]) .status-dot {
42+
:host([ethernet-wifi-status="CONNECTED"]) .status-dot {
4343
background-color: var(--brand-green-bright);
4444
}
4545

46-
:host(:not([is-connected])) .status-dot {
46+
:host([ethernet-wifi-status="DISCONNECTED"]) .status-dot {
4747
background-color: var(--brand-red-bright);
4848
}
4949

50-
.label-connected,
51-
.label-disconnected {
50+
:host(:not([network-status-type="ETHERNET_WIFI"])) .ip-address-container,
51+
:host(:not([network-status-type="ETHERNET_WIFI"])) .mac-address-container {
5252
display: none;
5353
}
5454

55-
:host([is-connected=""]) .label-connected,
56-
:host(:not([is-connected])) .label-disconnected {
57-
display: inline;
58-
}
59-
6055
#ip-address,
6156
#mac-address {
6257
margin-left: 0.3em;
@@ -67,16 +62,15 @@
6762
<div id="data">
6863
<div class="connection-indicator">
6964
<span class="status-dot status-dot-connected"></span>
70-
<span class="label-connected">Connected</span>
71-
<span class="label-disconnected">Disconnected</span>
65+
<span id="label-status"><!-- Filled programmatically --></span>
7266
</div>
73-
<div>
67+
<div class="ip-address-container">
7468
IP Address:
7569
<span id="ip-address" class="monospace"
7670
><!-- Filled programmatically --></span
7771
>
7872
</div>
79-
<div>
73+
<div class="mac-address-container">
8074
MAC Address:
8175
<span id="mac-address" class="monospace"
8276
><!-- Filled programmatically --></span
@@ -102,6 +96,10 @@
10296
name: this.shadowRoot.querySelector("#name"),
10397
ipAddress: this.shadowRoot.querySelector("#ip-address"),
10498
macAddress: this.shadowRoot.querySelector("#mac-address"),
99+
labelStatus: this.shadowRoot.querySelector("#label-status"),
100+
};
101+
this._networkStatusType = {
102+
ETHERNET_WIFI: "ETHERNET_WIFI",
105103
};
106104
}
107105

@@ -112,9 +110,20 @@
112110
* @param {string} [status.ipAddress]
113111
* @param {string} [status.macAddress]
114112
*/
115-
update(name, status) {
113+
setEthernetWifi(name, status) {
114+
this.setAttribute(
115+
"network-status-type",
116+
this._networkStatusType.ETHERNET_WIFI
117+
);
116118
this._elements.name.innerText = name;
117-
this.toggleAttribute("is-connected", status.isConnected);
119+
const networkStatus = status.isConnected
120+
? "Connected"
121+
: "Disconnected";
122+
this._elements.labelStatus.innerText = networkStatus;
123+
this.setAttribute(
124+
"ethernet-wifi-status",
125+
networkStatus.toUpperCase()
126+
);
118127
this._elements.ipAddress.innerText = status.ipAddress || "n/a";
119128
this._elements.macAddress.innerText = status.macAddress || "n/a";
120129
}

0 commit comments

Comments
 (0)