mirror of
https://github.com/home-assistant/frontend.git
synced 2026-02-04 01:10:33 -06:00
Remove download file support checks and related code (#29124)
This commit is contained in:
parent
73a1ce90c3
commit
311cbad8fa
@ -341,7 +341,6 @@ export interface ExternalConfig {
|
||||
hasAssist?: boolean;
|
||||
hasBarCodeScanner?: number;
|
||||
canSetupImprov?: boolean;
|
||||
downloadFileSupported?: boolean;
|
||||
appVersion?: string;
|
||||
hasEntityAddTo?: boolean; // Supports "Add to" from more-info dialog, with action coming from external app
|
||||
}
|
||||
|
||||
@ -1,19 +1,16 @@
|
||||
import { mdiDotsVertical, mdiDownload } from "@mdi/js";
|
||||
import type { TemplateResult } from "lit";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { css, html, LitElement } from "lit";
|
||||
import { customElement, property } from "lit/decorators";
|
||||
import "../../../components/ha-dropdown";
|
||||
import "../../../components/ha-dropdown-item";
|
||||
import "../../../components/ha-icon-button";
|
||||
import "../../../components/ha-svg-icon";
|
||||
import { getSignedPath } from "../../../data/auth";
|
||||
import "../../../layouts/hass-subpage";
|
||||
import type { HomeAssistant, Route } from "../../../types";
|
||||
import { fileDownload } from "../../../util/file_download";
|
||||
import "./ha-config-analytics";
|
||||
import {
|
||||
downloadFileSupported,
|
||||
fileDownload,
|
||||
} from "../../../util/file_download";
|
||||
import "../../../components/ha-dropdown-item";
|
||||
import "../../../components/ha-dropdown";
|
||||
|
||||
@customElement("ha-config-section-analytics")
|
||||
class HaConfigSectionAnalytics extends LitElement {
|
||||
@ -31,23 +28,19 @@ class HaConfigSectionAnalytics extends LitElement {
|
||||
.narrow=${this.narrow}
|
||||
.header=${this.hass.localize("ui.panel.config.analytics.caption")}
|
||||
>
|
||||
${downloadFileSupported(this.hass)
|
||||
? html`
|
||||
<ha-dropdown
|
||||
@wa-select=${this._handleOverflowAction}
|
||||
slot="toolbar-icon"
|
||||
>
|
||||
<ha-icon-button slot="trigger" .path=${mdiDotsVertical}>
|
||||
</ha-icon-button>
|
||||
<ha-dropdown-item .value=${"download_device_info"}>
|
||||
<ha-svg-icon slot="icon" .path=${mdiDownload}></ha-svg-icon>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.analytics.download_device_info"
|
||||
)}
|
||||
</ha-dropdown-item>
|
||||
</ha-dropdown>
|
||||
`
|
||||
: nothing}
|
||||
<ha-dropdown
|
||||
@wa-select=${this._handleOverflowAction}
|
||||
slot="toolbar-icon"
|
||||
>
|
||||
<ha-icon-button slot="trigger" .path=${mdiDotsVertical}>
|
||||
</ha-icon-button>
|
||||
<ha-dropdown-item .value=${"download_device_info"}>
|
||||
<ha-svg-icon slot="icon" .path=${mdiDownload}></ha-svg-icon>
|
||||
${this.hass.localize(
|
||||
"ui.panel.config.analytics.download_device_info"
|
||||
)}
|
||||
</ha-dropdown-item>
|
||||
</ha-dropdown>
|
||||
<div class="content">
|
||||
<ha-config-analytics .hass=${this.hass}></ha-config-analytics>
|
||||
</div>
|
||||
|
||||
@ -56,14 +56,10 @@ import {
|
||||
fetchHassioLogsFollow,
|
||||
fetchHassioLogsFollowSkip,
|
||||
fetchHassioLogsLegacy,
|
||||
getHassioLogDownloadLinesUrl,
|
||||
getHassioLogDownloadUrl,
|
||||
} from "../../../data/hassio/supervisor";
|
||||
import type { HomeAssistant } from "../../../types";
|
||||
import {
|
||||
downloadFileSupported,
|
||||
fileDownload,
|
||||
} from "../../../util/file_download";
|
||||
import { fileDownload } from "../../../util/file_download";
|
||||
import { showDownloadLogsDialog } from "./show-dialog-download-logs";
|
||||
|
||||
const NUMBER_OF_LINES = 100;
|
||||
@ -130,10 +126,6 @@ class ErrorLogCard extends LitElement {
|
||||
|
||||
@state() private _wrapLines = true;
|
||||
|
||||
@state() private _downloadSupported?: boolean;
|
||||
|
||||
@state() private _logsFileLink?: string;
|
||||
|
||||
protected render(): TemplateResult {
|
||||
const streaming =
|
||||
this._streamSupported &&
|
||||
@ -207,30 +199,11 @@ class ErrorLogCard extends LitElement {
|
||||
</ha-md-menu>
|
||||
`
|
||||
: nothing}
|
||||
${this._downloadSupported
|
||||
? html`
|
||||
<ha-icon-button
|
||||
.path=${mdiDownload}
|
||||
@click=${this._downloadLogs}
|
||||
.label=${localize("ui.panel.config.logs.download_logs")}
|
||||
></ha-icon-button>
|
||||
`
|
||||
: this._logsFileLink
|
||||
? html`
|
||||
<a
|
||||
href=${this._logsFileLink}
|
||||
target="_blank"
|
||||
class="download-link"
|
||||
>
|
||||
<ha-icon-button
|
||||
.path=${mdiDownload}
|
||||
.label=${localize(
|
||||
"ui.panel.config.logs.download_logs"
|
||||
)}
|
||||
></ha-icon-button>
|
||||
</a>
|
||||
`
|
||||
: nothing}
|
||||
<ha-icon-button
|
||||
.path=${mdiDownload}
|
||||
@click=${this._downloadLogs}
|
||||
.label=${localize("ui.panel.config.logs.download_logs")}
|
||||
></ha-icon-button>
|
||||
<ha-icon-button
|
||||
.path=${this._wrapLines ? mdiWrapDisabled : mdiWrap}
|
||||
@click=${this._toggleLineWrap}
|
||||
@ -338,7 +311,6 @@ class ErrorLogCard extends LitElement {
|
||||
protected willUpdate(changedProps: PropertyValues) {
|
||||
super.willUpdate(changedProps);
|
||||
if (!this.hasUpdated) {
|
||||
this._downloadSupported = downloadFileSupported(this.hass);
|
||||
this._streamSupported =
|
||||
!__SUPERVISOR__ || atLeastVersion(this.hass.config.version, 2024, 11);
|
||||
|
||||
@ -540,17 +512,6 @@ class ErrorLogCard extends LitElement {
|
||||
this._newLogsIndicator = true;
|
||||
}
|
||||
|
||||
if (!this._downloadSupported) {
|
||||
const downloadUrl = getHassioLogDownloadLinesUrl(
|
||||
this.provider!,
|
||||
this._numberOfLines,
|
||||
this._boot
|
||||
);
|
||||
getSignedPath(this.hass, downloadUrl).then((signedUrl) => {
|
||||
this._logsFileLink = signedUrl.path;
|
||||
});
|
||||
}
|
||||
|
||||
// first chunk loads successfully, reset retry param
|
||||
retry = false;
|
||||
}
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
import type { HomeAssistant } from "../types";
|
||||
import { isIosApp } from "./is_ios";
|
||||
|
||||
export const fileDownload = (href: string, filename = ""): void => {
|
||||
const element = document.createElement("a");
|
||||
element.target = "_blank";
|
||||
@ -11,6 +8,3 @@ export const fileDownload = (href: string, filename = ""): void => {
|
||||
element.dispatchEvent(new MouseEvent("click"));
|
||||
document.body.removeChild(element);
|
||||
};
|
||||
|
||||
export const downloadFileSupported = (hass: HomeAssistant): boolean =>
|
||||
!isIosApp(hass) || !!hass.auth.external?.config.downloadFileSupported;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user