Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Landing page #22598

Merged
merged 34 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0f542fc
Add landing-page project
wendevlin Oct 21, 2024
6ef7e79
Add landing-page-prepare
wendevlin Oct 21, 2024
3e8d7ef
Add landing-page-network
wendevlin Oct 22, 2024
5d12632
Add logs to landing-page
wendevlin Oct 23, 2024
a662728
Improve landing-page build
wendevlin Oct 23, 2024
677956e
Improve landing-page logs and detail dialogs
wendevlin Oct 24, 2024
f221ac0
Add es5 build for landing-page
wendevlin Oct 29, 2024
31905b7
Add download_full_logs at landing-page
wendevlin Oct 30, 2024
7ea448c
Change dev build for landing-page
wendevlin Oct 30, 2024
10997c7
Fix landing-page build, do it like hassio
wendevlin Nov 4, 2024
67cd512
Remove compress from landing-page build
wendevlin Nov 4, 2024
7776534
Migrate landing-page eslint config
wendevlin Nov 19, 2024
88457d1
Add landing-page project
wendevlin Oct 21, 2024
0963ec1
Add landing-page-prepare
wendevlin Oct 21, 2024
487bc8e
Add landing-page-network
wendevlin Oct 22, 2024
16a2ff3
Add logs to landing-page
wendevlin Oct 23, 2024
6f6d188
Improve landing-page build
wendevlin Oct 23, 2024
7d6986b
Improve landing-page logs and detail dialogs
wendevlin Oct 24, 2024
b86e7a4
Add download_full_logs at landing-page
wendevlin Oct 30, 2024
8081d47
Fix landing-page build, do it like hassio
wendevlin Nov 4, 2024
ba1abed
Remove compress from landing-page build
wendevlin Nov 4, 2024
bb1e86e
Remove .eslintrc from landing-page
wendevlin Nov 19, 2024
37f7b42
Merge branch 'dev' of github.com:home-assistant/frontend into landing…
wendevlin Nov 19, 2024
b4ed00e
Fix landing-page CI translation issue
wendevlin Nov 19, 2024
48886c6
Remove landing-page supervisor logs
wendevlin Nov 19, 2024
dc83b6b
Fix onboarding-welcome-links LocalizeFunc type
wendevlin Nov 19, 2024
51978f8
Add landing-page log streaming
wendevlin Nov 20, 2024
5c0dbaf
Fix landing-page-logs error-check regex - github-advanced-security
wendevlin Nov 20, 2024
3b3a32f
Add landing-page dns error alert, improve try catch
wendevlin Nov 20, 2024
9aef546
Fix landing-page keep show installer when _getNetworkInfoError
wendevlin Nov 20, 2024
87ad9fd
Fix landing-page download logs
wendevlin Nov 20, 2024
1989850
Use observer logs for download in landing-page
wendevlin Nov 20, 2024
8ad6873
Add error message to landing-page dns set fail
wendevlin Nov 20, 2024
9106d26
Remove unused _observerFallback
wendevlin Nov 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions landing-page/src/components/landing-page-logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,17 @@ import "../../../src/components/ha-svg-icon";
import "../../../src/components/ha-ansi-to-html";
import "../../../src/components/ha-alert";
import type { HaAnsiToHtml } from "../../../src/components/ha-ansi-to-html";
import { getObserverLogs } from "../data/observer";
import {
getObserverLogs,
downloadUrl as observerLogsDownloadUrl,
} from "../data/observer";
import { fireEvent } from "../../../src/common/dom/fire_event";
import { fileDownload } from "../../../src/util/file_download";
import { getSupervisorLogs, getSupervisorLogsFollow } from "../data/supervisor";
import {
getDownloadUrl,
getSupervisorLogs,
getSupervisorLogsFollow,
} from "../data/supervisor";

const ERROR_CHECK = /^[\d\s-:]+(ERROR|CRITICAL)(.*)/gm;
declare global {
Expand Down Expand Up @@ -54,7 +61,9 @@ class LandingPageLogs extends LitElement {

@state() private _newLogsIndicator?: boolean;

@state() private _observerLogs = "";
@state() private _logLinesCount = 0;

@state() private _observerFallback = false;

protected render() {
return html`
Expand All @@ -66,7 +75,7 @@ class LandingPageLogs extends LitElement {
? html`<ha-icon-button
.label=${this.localize("logs.download_logs")}
.path=${mdiDownload}
@click=${this._downloadFullLog}
@click=${this._downloadLogs}
></ha-icon-button>`
: nothing}
</div>
Expand Down Expand Up @@ -145,6 +154,7 @@ class LandingPageLogs extends LitElement {
private _displayLogs(logs: string, tempLogLine = "", clear = false): string {
if (clear) {
this._ansiToHtmlElement?.clear();
this._logLinesCount = 0;
}

const showError = ERROR_CHECK.test(logs);
Expand All @@ -163,6 +173,7 @@ class LandingPageLogs extends LitElement {

if (lines.length) {
this._ansiToHtmlElement?.parseLinesToColoredPre(lines);
this._logLinesCount += lines.length;
}

if (showError) {
Expand All @@ -180,6 +191,7 @@ class LandingPageLogs extends LitElement {
}

private async _startLogStream() {
this._observerFallback = false;
this._error = false;
this._newLogsIndicator = false;
this._ansiToHtmlElement?.clear();
Expand Down Expand Up @@ -212,6 +224,7 @@ class LandingPageLogs extends LitElement {
console.error(err);

// fallback to observerlogs if there is a problem with supervisor
this._observerFallback = true;
this._loadObserverLogs();
}
}
Expand Down Expand Up @@ -242,10 +255,7 @@ class LandingPageLogs extends LitElement {

const logs = await response.text();

if (this._observerLogs !== logs) {
this._observerLogs = logs;
this._displayLogs(logs, "", true);
}
this._displayLogs(logs, "", true);

this._scheduleObserverLogs();
} catch (err) {
Expand All @@ -255,9 +265,14 @@ class LandingPageLogs extends LitElement {
}
}

private async _downloadFullLog() {
private _downloadLogs() {
const timeString = new Date().toISOString().replace(/:/g, "-");
fileDownload("/observer/logs", `home-assistant_${timeString}.log`);
const downloadUrl = this._observerFallback
wendevlin marked this conversation as resolved.
Show resolved Hide resolved
? observerLogsDownloadUrl
: getDownloadUrl(this._logLinesCount);
const downloadName = `${this._observerFallback ? "observer" : "supervisor"}_${timeString}.log`;

fileDownload(downloadUrl, downloadName);
}

static styles = [
Expand Down
2 changes: 2 additions & 0 deletions landing-page/src/data/observer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export async function getObserverLogs() {
return fetch("/observer/logs");
}

export const downloadUrl = "/observer/logs";
4 changes: 4 additions & 0 deletions landing-page/src/data/supervisor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export const ALTERNATIVE_DNS_SERVERS: {
},
];

export function getDownloadUrl(lines = 500) {
return `/supervisor/supervisor/logs?lines=${lines}`;
}

export async function getSupervisorLogs(lines = 100) {
return fetch(`/supervisor/supervisor/logs?lines=${lines}`, {
headers: {
Expand Down
Loading