mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Landing-page: ping supervisor before get network infos (#24330)
* Ping supervisor before get network infos * Rename supervisor proxy prefix
This commit is contained in:
parent
ba5c1133c6
commit
4d7634ac67
@ -17,6 +17,7 @@ import "../../../src/components/ha-alert";
|
|||||||
import {
|
import {
|
||||||
ALTERNATIVE_DNS_SERVERS,
|
ALTERNATIVE_DNS_SERVERS,
|
||||||
getSupervisorNetworkInfo,
|
getSupervisorNetworkInfo,
|
||||||
|
pingSupervisor,
|
||||||
setSupervisorNetworkDns,
|
setSupervisorNetworkDns,
|
||||||
} from "../data/supervisor";
|
} from "../data/supervisor";
|
||||||
import { fireEvent } from "../../../src/common/dom/fire_event";
|
import { fireEvent } from "../../../src/common/dom/fire_event";
|
||||||
@ -85,7 +86,28 @@ class LandingPageNetwork extends LitElement {
|
|||||||
|
|
||||||
protected firstUpdated(_changedProperties: PropertyValues): void {
|
protected firstUpdated(_changedProperties: PropertyValues): void {
|
||||||
super.firstUpdated(_changedProperties);
|
super.firstUpdated(_changedProperties);
|
||||||
this._fetchSupervisorInfo();
|
this._pingSupervisor();
|
||||||
|
}
|
||||||
|
|
||||||
|
private _schedulePingSupervisor() {
|
||||||
|
setTimeout(
|
||||||
|
() => this._pingSupervisor(),
|
||||||
|
SCHEDULE_FETCH_NETWORK_INFO_SECONDS * 1000
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async _pingSupervisor() {
|
||||||
|
try {
|
||||||
|
const response = await pingSupervisor();
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error("Failed to ping supervisor, assume update in progress");
|
||||||
|
}
|
||||||
|
this._fetchSupervisorInfo();
|
||||||
|
} catch (err) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error(err);
|
||||||
|
this._schedulePingSupervisor();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _scheduleFetchSupervisorInfo() {
|
private _scheduleFetchSupervisorInfo() {
|
||||||
|
@ -18,7 +18,7 @@ export const ALTERNATIVE_DNS_SERVERS: {
|
|||||||
];
|
];
|
||||||
|
|
||||||
export async function getSupervisorLogs(lines = 100) {
|
export async function getSupervisorLogs(lines = 100) {
|
||||||
return fetch(`/supervisor/supervisor/logs?lines=${lines}`, {
|
return fetch(`/supervisor-api/supervisor/logs?lines=${lines}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "text/plain",
|
Accept: "text/plain",
|
||||||
},
|
},
|
||||||
@ -26,22 +26,26 @@ export async function getSupervisorLogs(lines = 100) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getSupervisorLogsFollow(lines = 500) {
|
export async function getSupervisorLogsFollow(lines = 500) {
|
||||||
return fetch(`/supervisor/supervisor/logs/follow?lines=${lines}`, {
|
return fetch(`/supervisor-api/supervisor/logs/follow?lines=${lines}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Accept: "text/plain",
|
Accept: "text/plain",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function pingSupervisor() {
|
||||||
|
return fetch("/supervisor-api/supervisor/ping");
|
||||||
|
}
|
||||||
|
|
||||||
export async function getSupervisorNetworkInfo() {
|
export async function getSupervisorNetworkInfo() {
|
||||||
return fetch("/supervisor/network/info");
|
return fetch("/supervisor-api/network/info");
|
||||||
}
|
}
|
||||||
|
|
||||||
export const setSupervisorNetworkDns = async (
|
export const setSupervisorNetworkDns = async (
|
||||||
dnsServerIndex: number,
|
dnsServerIndex: number,
|
||||||
primaryInterface: string
|
primaryInterface: string
|
||||||
) =>
|
) =>
|
||||||
fetch(`/supervisor/network/interface/${primaryInterface}/update`, {
|
fetch(`/supervisor-api/network/interface/${primaryInterface}/update`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
ipv4: {
|
ipv4: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user