mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-29 11:09:26 +00:00
Compare commits
1 Commits
dev-tools-
...
Change-con
Author | SHA1 | Date | |
---|---|---|---|
![]() |
df9d2303dc |
@@ -1,138 +0,0 @@
|
|||||||
import { mdiClose } from "@mdi/js";
|
|
||||||
import "@polymer/paper-tabs";
|
|
||||||
import {
|
|
||||||
css,
|
|
||||||
CSSResultGroup,
|
|
||||||
html,
|
|
||||||
LitElement,
|
|
||||||
PropertyValues,
|
|
||||||
TemplateResult,
|
|
||||||
} from "lit";
|
|
||||||
import { customElement, property, state, query } from "lit/decorators";
|
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
|
||||||
import { haStyleDialog } from "../../resources/styles";
|
|
||||||
import type { HomeAssistant, Route } from "../../types";
|
|
||||||
import "../../components/ha-dialog";
|
|
||||||
import "../../components/ha-tabs";
|
|
||||||
import "../../components/ha-icon-button";
|
|
||||||
import "../../panels/developer-tools/developer-tools-router";
|
|
||||||
import type { HaDialog } from "../../components/ha-dialog";
|
|
||||||
import "@material/mwc-button/mwc-button";
|
|
||||||
|
|
||||||
@customElement("ha-developer-tools-dialog")
|
|
||||||
export class HaDeveloperToolsDialog extends LitElement {
|
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
|
||||||
|
|
||||||
@state() private _opened = false;
|
|
||||||
|
|
||||||
@state() private _route: Route = {
|
|
||||||
prefix: "/developer-tools",
|
|
||||||
path: "/state",
|
|
||||||
};
|
|
||||||
|
|
||||||
@query("ha-dialog", true) private _dialog!: HaDialog;
|
|
||||||
|
|
||||||
public async showDialog(): Promise<void> {
|
|
||||||
this._opened = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async closeDialog(): Promise<void> {
|
|
||||||
this._opened = false;
|
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
|
||||||
if (!this._opened) {
|
|
||||||
return html``;
|
|
||||||
}
|
|
||||||
return html`
|
|
||||||
<ha-dialog open @closed=${this.closeDialog}>
|
|
||||||
<div class="header">
|
|
||||||
<ha-tabs
|
|
||||||
scrollable
|
|
||||||
attr-for-selected="page-name"
|
|
||||||
.selected=${this._route.path.substr(1)}
|
|
||||||
@iron-activate=${this.handlePageSelected}
|
|
||||||
>
|
|
||||||
<paper-tab page-name="state">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.developer-tools.tabs.states.title"
|
|
||||||
)}
|
|
||||||
</paper-tab>
|
|
||||||
<paper-tab page-name="service">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.developer-tools.tabs.services.title"
|
|
||||||
)}
|
|
||||||
</paper-tab>
|
|
||||||
<paper-tab page-name="template">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.developer-tools.tabs.templates.title"
|
|
||||||
)}
|
|
||||||
</paper-tab>
|
|
||||||
<paper-tab page-name="event">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.developer-tools.tabs.events.title"
|
|
||||||
)}
|
|
||||||
</paper-tab>
|
|
||||||
<paper-tab page-name="statistics">
|
|
||||||
${this.hass.localize(
|
|
||||||
"ui.panel.developer-tools.tabs.statistics.title"
|
|
||||||
)}
|
|
||||||
</paper-tab>
|
|
||||||
</ha-tabs>
|
|
||||||
<ha-icon-button
|
|
||||||
.path=${mdiClose}
|
|
||||||
@click=${this.closeDialog}
|
|
||||||
></ha-icon-button>
|
|
||||||
</div>
|
|
||||||
<developer-tools-router
|
|
||||||
.route=${this._route}
|
|
||||||
.narrow=${document.body.clientWidth < 600}
|
|
||||||
.hass=${this.hass}
|
|
||||||
></developer-tools-router>
|
|
||||||
</ha-dialog>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
|
||||||
super.updated(changedProps);
|
|
||||||
this.hass.loadBackendTranslation("title");
|
|
||||||
this.hass.loadFragmentTranslation("developer-tools");
|
|
||||||
}
|
|
||||||
|
|
||||||
private handlePageSelected(ev) {
|
|
||||||
const newPage = ev.detail.item.getAttribute("page-name");
|
|
||||||
if (newPage !== this._route.path.substr(1)) {
|
|
||||||
this._route = {
|
|
||||||
prefix: "/developer-tools",
|
|
||||||
path: `/${newPage}`,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// scrollTo(0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
|
||||||
return [
|
|
||||||
haStyleDialog,
|
|
||||||
css`
|
|
||||||
ha-dialog {
|
|
||||||
--mdc-dialog-min-width: 100vw;
|
|
||||||
--mdc-dialog-min-height: 100vh;
|
|
||||||
}
|
|
||||||
.header {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
ha-tabs {
|
|
||||||
flex: 1;
|
|
||||||
}
|
|
||||||
`,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
interface HTMLElementTagNameMap {
|
|
||||||
"ha-developer-tools-dialog": HaDeveloperToolsDialog;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,12 +0,0 @@
|
|||||||
import { fireEvent } from "../../common/dom/fire_event";
|
|
||||||
|
|
||||||
export const loadDeveloperToolDialog = () =>
|
|
||||||
import("./ha-developer-tools-dialog");
|
|
||||||
|
|
||||||
export const showDeveloperToolDialog = (element: HTMLElement): void => {
|
|
||||||
fireEvent(element, "show-dialog", {
|
|
||||||
dialogTag: "ha-developer-tools-dialog",
|
|
||||||
dialogImport: loadDeveloperToolDialog,
|
|
||||||
dialogParams: {},
|
|
||||||
});
|
|
||||||
};
|
|
@@ -224,7 +224,7 @@ class HaBlueprintOverview extends LitElement {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
back-path="/config"
|
back-path="/config"
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.automations}
|
.tabs=${configSections.blueprints}
|
||||||
.columns=${this._columns(this.narrow, this.hass.language)}
|
.columns=${this._columns(this.narrow, this.hass.language)}
|
||||||
.data=${this._processedBlueprints(this.blueprints)}
|
.data=${this._processedBlueprints(this.blueprints)}
|
||||||
id="entity_id"
|
id="entity_id"
|
||||||
|
@@ -57,22 +57,22 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
{
|
{
|
||||||
path: "/config/automation",
|
path: "/config/automation",
|
||||||
name: "Automations & Scenes",
|
name: "Automations & Scenes",
|
||||||
description: "Automations, blueprints, scenes and scripts",
|
description: "Automations, helpers, scenes and scripts",
|
||||||
iconPath: mdiRobot,
|
iconPath: mdiRobot,
|
||||||
iconColor: "#518C43",
|
iconColor: "#518C43",
|
||||||
components: ["automation", "blueprint", "scene", "script"],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/config/helpers",
|
|
||||||
name: "Automation Helpers",
|
|
||||||
description: "Elements that help build automations",
|
|
||||||
iconPath: mdiTools,
|
|
||||||
iconColor: "#4D2EA4",
|
|
||||||
core: true,
|
core: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "/config/blueprint",
|
||||||
|
name: "Blueprints",
|
||||||
|
description: "Manage blueprints",
|
||||||
|
iconPath: mdiPaletteSwatch,
|
||||||
|
iconColor: "#4D2EA4",
|
||||||
|
component: "blueprint",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/hassio",
|
path: "/hassio",
|
||||||
name: "Add-ons & Backups (Supervisor)",
|
name: "Add-ons, Backups & Supervisor",
|
||||||
description: "Create backups, check logs or reboot your system",
|
description: "Create backups, check logs or reboot your system",
|
||||||
iconPath: mdiHomeAssistant,
|
iconPath: mdiHomeAssistant,
|
||||||
iconColor: "#4084CD",
|
iconColor: "#4084CD",
|
||||||
@@ -155,13 +155,6 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
automations: [
|
automations: [
|
||||||
{
|
|
||||||
component: "blueprint",
|
|
||||||
path: "/config/blueprint",
|
|
||||||
translationKey: "ui.panel.config.blueprint.caption",
|
|
||||||
iconPath: mdiPaletteSwatch,
|
|
||||||
iconColor: "#518C43",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
component: "automation",
|
component: "automation",
|
||||||
path: "/config/automation",
|
path: "/config/automation",
|
||||||
@@ -169,6 +162,14 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
iconPath: mdiRobot,
|
iconPath: mdiRobot,
|
||||||
iconColor: "#518C43",
|
iconColor: "#518C43",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
component: "helpers",
|
||||||
|
path: "/config/helpers",
|
||||||
|
translationKey: "ui.panel.config.helpers.caption",
|
||||||
|
iconPath: mdiTools,
|
||||||
|
iconColor: "#4D2EA4",
|
||||||
|
core: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
component: "scene",
|
component: "scene",
|
||||||
path: "/config/scene",
|
path: "/config/scene",
|
||||||
@@ -184,14 +185,13 @@ export const configSections: { [name: string]: PageNavigation[] } = {
|
|||||||
iconColor: "#518C43",
|
iconColor: "#518C43",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
helpers: [
|
blueprints: [
|
||||||
{
|
{
|
||||||
component: "helpers",
|
component: "blueprint",
|
||||||
path: "/config/helpers",
|
path: "/config/blueprint",
|
||||||
translationKey: "ui.panel.config.helpers.caption",
|
translationKey: "ui.panel.config.blueprint.caption",
|
||||||
iconPath: mdiTools,
|
iconPath: mdiPaletteSwatch,
|
||||||
iconColor: "#4D2EA4",
|
iconColor: "#518C43",
|
||||||
core: true,
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
tags: [
|
tags: [
|
||||||
|
@@ -132,7 +132,7 @@ export class HaConfigHelpers extends LitElement {
|
|||||||
.narrow=${this.narrow}
|
.narrow=${this.narrow}
|
||||||
back-path="/config"
|
back-path="/config"
|
||||||
.route=${this.route}
|
.route=${this.route}
|
||||||
.tabs=${configSections.helpers}
|
.tabs=${configSections.automations}
|
||||||
.columns=${this._columns(this.narrow, this.hass.language)}
|
.columns=${this._columns(this.narrow, this.hass.language)}
|
||||||
.data=${this._getItems(this._stateItems)}
|
.data=${this._getItems(this._stateItems)}
|
||||||
@row-click=${this._openEditDialog}
|
@row-click=${this._openEditDialog}
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
import type { PropertyValues } from "lit";
|
import type { PropertyValues } from "lit";
|
||||||
import tinykeys from "tinykeys";
|
import tinykeys from "tinykeys";
|
||||||
import { showDeveloperToolDialog } from "../dialogs/developert-tools/show-dialog-developer-tools";
|
|
||||||
import {
|
import {
|
||||||
QuickBarParams,
|
QuickBarParams,
|
||||||
showQuickBar,
|
showQuickBar,
|
||||||
@@ -33,7 +32,6 @@ export default <T extends Constructor<HassElement>>(superClass: T) =>
|
|||||||
tinykeys(window, {
|
tinykeys(window, {
|
||||||
e: (ev) => this._showQuickBar(ev),
|
e: (ev) => this._showQuickBar(ev),
|
||||||
c: (ev) => this._showQuickBar(ev, true),
|
c: (ev) => this._showQuickBar(ev, true),
|
||||||
d: () => showDeveloperToolDialog(this),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user