diff --git a/src/data/hassio/supervisor.ts b/src/data/hassio/supervisor.ts index abdeb8a6a0dc..cc74a7fd70f8 100644 --- a/src/data/hassio/supervisor.ts +++ b/src/data/hassio/supervisor.ts @@ -236,7 +236,12 @@ export const getHassioLogDownloadUrl = (provider: string) => provider.includes("_") ? `addons/${provider}` : provider }/logs`; -export const getHassioLogDownloadLinesUrl = ( +export const getHassioLogDownloadLinesUrl = (provider: string, lines: number) => + `/api/hassio/${ + provider.includes("_") ? `addons/${provider}` : provider + }/logs?lines=${lines}`; + +export const getHassioLogBootDownloadLinesUrl = ( provider: string, lines: number, boot = 0 diff --git a/src/panels/config/logs/dialog-download-logs.ts b/src/panels/config/logs/dialog-download-logs.ts index fdd67e5a315b..72ae401846ca 100644 --- a/src/panels/config/logs/dialog-download-logs.ts +++ b/src/panels/config/logs/dialog-download-logs.ts @@ -14,7 +14,10 @@ import type { DownloadLogsDialogParams } from "./show-dialog-download-logs"; import "../../../components/ha-select"; import "../../../components/ha-list-item"; import { stopPropagation } from "../../../common/dom/stop_propagation"; -import { getHassioLogDownloadLinesUrl } from "../../../data/hassio/supervisor"; +import { + getHassioLogDownloadLinesUrl, + getHassioLogBootDownloadLinesUrl, +} from "../../../data/hassio/supervisor"; import { getSignedPath } from "../../../data/auth"; import { fileDownload } from "../../../util/file_download"; @@ -112,11 +115,7 @@ class DownloadLogsDialog extends LitElement { const boot = this._dialogParams!.boot; const timeString = new Date().toISOString().replace(/:/g, "-"); - const downloadUrl = getHassioLogDownloadLinesUrl( - provider, - this._lineCount, - boot - ); + const downloadUrl = this._getDownloadUrl()(provider, this._lineCount, boot); const logFileName = provider !== "core" ? `${provider}_${timeString}.log` @@ -126,6 +125,13 @@ class DownloadLogsDialog extends LitElement { this.closeDialog(); } + private _getDownloadUrl() { + if (this._dialogParams!.boot === 0) { + return getHassioLogDownloadLinesUrl; + } + return getHassioLogBootDownloadLinesUrl; + } + private _setNumberOfLogs(ev) { this._lineCount = Number(ev.target.value); }