182 files
This commit is contained in:
@@ -4,7 +4,9 @@ import { LitElement, html, css, nothing } from "lit";
|
||||
import { property, state } from "lit/decorators.js";
|
||||
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
||||
import type { HomeAssistant, AdvancedFeatures, BudgetStatus, HAUser } from "../types";
|
||||
import { t } from "../styles";
|
||||
import { t, langOf } from "../styles";
|
||||
import { signApiPath } from "../helpers/document-url";
|
||||
import { downloadUrl } from "../helpers/download";
|
||||
import { UserService } from "../user-service";
|
||||
import { OBJECT_COLUMNS, sanitizeColumns } from "../helpers/object-columns";
|
||||
import { downloadTextFile } from "../helpers/download";
|
||||
@@ -160,7 +162,7 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
private _userService: UserService | null = null;
|
||||
|
||||
private get _lang(): string {
|
||||
return this.hass?.language || "en";
|
||||
return langOf(this.hass);
|
||||
}
|
||||
|
||||
updated(changedProps: Map<string, unknown>): void {
|
||||
@@ -1430,6 +1432,7 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
<button @click=${this._exportJson}>${t("settings_export_json", L)}</button>
|
||||
<button @click=${this._exportYaml}>${t("settings_export_yaml", L)}</button>
|
||||
<button @click=${this._exportCsv}>${t("settings_export_csv", L)}</button>
|
||||
<button @click=${this._exportSettings}>${t("settings_export_settings", L)}</button>
|
||||
</div>
|
||||
<div class="settings-actions docs-archive-block">
|
||||
<h4>${t("settings_docs_archive", L)}</h4>
|
||||
@@ -1510,6 +1513,22 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
}
|
||||
}
|
||||
|
||||
/** The SECOND export: the global entry's settings (groups, saved views,
|
||||
* vacation, notification/budget settings, feature toggles) — the objects
|
||||
* export deliberately excludes them. Re-import via the regular import. */
|
||||
private async _exportSettings(): Promise<void> {
|
||||
try {
|
||||
const result = await this.hass.connection.sendMessagePromise({
|
||||
type: "maintenance_supporter/settings/export",
|
||||
}) as { data: string };
|
||||
const ts = new Date().toISOString().slice(0, 10);
|
||||
this._downloadFile(result.data, `maintenance_settings_${ts}.json`, "application/json");
|
||||
this._showToast(t("settings_export_success", this._lang));
|
||||
} catch {
|
||||
this._showToast(t("action_error", this._lang));
|
||||
}
|
||||
}
|
||||
|
||||
private async _exportYaml(): Promise<void> {
|
||||
try {
|
||||
const ids = this._selectedEntryIds;
|
||||
@@ -1573,17 +1592,8 @@ export class MaintenanceSettingsView extends LitElement {
|
||||
try {
|
||||
const raw = this._selectedEntryIds;
|
||||
const q = raw ? `?entry_ids=${encodeURIComponent(raw.join(","))}` : "";
|
||||
const signed = await this.hass.connection.sendMessagePromise<{ path: string }>({
|
||||
type: "auth/sign_path",
|
||||
path: `/api/maintenance_supporter/documents/archive${q}`,
|
||||
expires: 300,
|
||||
});
|
||||
const a = document.createElement("a");
|
||||
a.href = signed.path;
|
||||
a.download = "maintenance-documents.zip";
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.remove();
|
||||
const signed = await signApiPath(this.hass, `/api/maintenance_supporter/documents/archive${q}`);
|
||||
downloadUrl(signed, "maintenance-documents.zip");
|
||||
} catch {
|
||||
this._showToast(t("action_error", this._lang));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user