Skip to content
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { customElement, property, state } from "lit/decorators";
import memoizeOne from "memoize-one";
import { isComponentLoaded } from "../../../../../common/config/is_component_loaded";
import { stringCompare } from "../../../../../common/string/compare";
import { extractSearchParam } from "../../../../../common/url/search-params";
import "../../../../../components/ha-card";
import { getSignedPath } from "../../../../../data/auth";
import { getConfigEntryDiagnosticsDownloadUrl } from "../../../../../data/diagnostics";
import { getOTBRInfo } from "../../../../../data/otbr";
import {
listThreadDataSets,
Expand All @@ -20,6 +23,7 @@ import { SubscribeMixin } from "../../../../../mixins/subscribe-mixin";
import { haStyle } from "../../../../../resources/styles";
import { HomeAssistant } from "../../../../../types";
import { brandsUrl } from "../../../../../util/brands-url";
import { fileDownload } from "../../../../../util/file_download";

interface ThreadNetwork {
name: string;
Expand All @@ -33,6 +37,8 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {

@property({ type: Boolean }) public narrow!: boolean;

@state() private _configEntryId: string | null = null;

@state() private _routers: ThreadRouter[] = [];

@state() private _datasets: ThreadDataSet[] = [];
Expand All @@ -47,6 +53,19 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
.path=${mdiDotsVertical}
slot="trigger"
></ha-icon-button>
<a
href=${getConfigEntryDiagnosticsDownloadUrl(
this._configEntryId || ""
)}
target="_blank"
@click=${this._signUrl}
>
<mwc-list-item>
${this.hass.localize(
"ui.panel.config.integrations.config_entry.download_diagnostics"
)}
</mwc-list-item>
</a>
<mwc-list-item @click=${this._addOTBR}
>${this.hass.localize(
"ui.panel.config.thread.add_open_thread_border_router"
Expand Down Expand Up @@ -177,6 +196,8 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
super.firstUpdated(changedProps);

this._refresh();

this._configEntryId = extractSearchParam("config_entry");
}

private _groupRoutersByNetwork = memoizeOne(
Expand Down Expand Up @@ -226,6 +247,16 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
});
}

private async _signUrl(ev) {
const anchor = ev.target.closest("a");
ev.preventDefault();
const signedUrl = await getSignedPath(
this.hass,
anchor.getAttribute("href")
);
fileDownload(signedUrl.path);
}

private _addOTBR() {
showConfigFlowDialog(this, {
dialogClosedCallback: () => {
Expand All @@ -245,6 +276,9 @@ export class ThreadConfigPanel extends SubscribeMixin(LitElement) {
margin: 0 auto;
direction: ltr;
}
ha-button-menu a {
text-decoration: none;
}
.routers {
padding-bottom: 0;
}
Expand Down