Download core logs via supervisor (#26251)

Use supervisor download dialog for core downloads
This commit is contained in:
Wendelin 2025-07-22 13:55:11 +02:00 committed by GitHub
parent 77aca59dda
commit 13868478f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ import { mdiDotsVertical, mdiDownload, mdiRefresh, mdiText } from "@mdi/js";
import { css, html, LitElement, nothing } from "lit"; import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators"; import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one"; import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../../common/config/is_component_loaded";
import { fireEvent } from "../../../common/dom/fire_event"; import { fireEvent } from "../../../common/dom/fire_event";
import type { LocalizeFunc } from "../../../common/translations/localize"; import type { LocalizeFunc } from "../../../common/translations/localize";
import "../../../components/buttons/ha-call-service-button"; import "../../../components/buttons/ha-call-service-button";
@ -23,6 +24,7 @@ import {
} from "../../../data/system_log"; } from "../../../data/system_log";
import type { HomeAssistant } from "../../../types"; import type { HomeAssistant } from "../../../types";
import { fileDownload } from "../../../util/file_download"; import { fileDownload } from "../../../util/file_download";
import { showDownloadLogsDialog } from "./show-dialog-download-logs";
import { showSystemLogDetailDialog } from "./show-dialog-system-log-detail"; import { showSystemLogDetailDialog } from "./show-dialog-system-log-detail";
import { formatSystemLogTime } from "./util"; import { formatSystemLogTime } from "./util";
@ -228,6 +230,18 @@ export class SystemLogCard extends LitElement {
} }
private async _downloadLogs() { private async _downloadLogs() {
// download logs via supervisor
if (isComponentLoaded(this.hass, "hassio")) {
showDownloadLogsDialog(this, {
header: this.header,
provider: "core",
defaultLineCount: 100,
boot: 0,
});
return;
}
// download logs from core
const timeString = new Date().toISOString().replace(/:/g, "-"); const timeString = new Date().toISOString().replace(/:/g, "-");
const downloadUrl = getErrorLogDownloadUrl; const downloadUrl = getErrorLogDownloadUrl;
const logFileName = `home-assistant_${timeString}.log`; const logFileName = `home-assistant_${timeString}.log`;