forked from esphome/dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
esphome-main.ts
81 lines (70 loc) · 2.01 KB
/
esphome-main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import "./devices/devices-list";
import "./components/esphome-header-menu";
import "./components/esphome-fab";
import { LitElement, html, PropertyValues } from "lit";
import { customElement, property, state } from "lit/decorators.js";
@customElement("esphome-main")
class ESPHomeMainView extends LitElement {
@property() version = "unknown";
@property() docsLink = "";
@property() logoutUrl?: string;
@state() private editing?: string;
protected render() {
if (this.editing) {
return html`
<style>
esphome-editor {
display: flex;
flex-direction: column;
flex: 1 0 auto;
}
</style>
<esphome-editor
@close=${this._handleEditorClose}
fileName=${this.editing}
></esphome-editor>
`;
}
return html`
<header class="esphome-header">
<img src="static/images/logo-text.svg" alt="ESPHome Logo" />
<div class="flex"></div>
<esphome-header-menu .logoutUrl=${this.logoutUrl}></esphome-header-menu>
</header>
<main>
<esphome-devices-list></esphome-devices-list>
</main>
<esphome-fab></esphome-fab>
<footer class="page-footer">
<div>
ESPHome by Open Home Foundation |
<a href="https://esphome.io/guides/supporters.html" target="_blank"
>Fund development</a
>
|
<a href=${this.docsLink} target="_blank" rel="noreferrer"
>${this.version} Documentation</a
>
</div>
</footer>
`;
}
createRenderRoot() {
return this;
}
protected firstUpdated(changedProps: PropertyValues): void {
super.firstUpdated(changedProps);
document.body.addEventListener<any>("edit-file", (ev) => {
this.editing = ev.detail;
});
import("./editor/esphome-editor");
}
private _handleEditorClose() {
this.editing = undefined;
}
}
declare global {
interface HTMLElementTagNameMap {
"esphome-main": ESPHomeMainView;
}
}