mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-09 19:09:48 +00:00
♻️ convert more-info-script to LitElement/TypeScript (#4545)
* ♻️ convert more-info-script to Lit/TypeScript * ♻️ convert more-info-script to LitElement/TypeScript * 👌 use relative time
This commit is contained in:
committed by
Bram Kragten
parent
49611e285f
commit
8a9e149d33
46
src/dialogs/more-info/controls/more-info-script.ts
Normal file
46
src/dialogs/more-info/controls/more-info-script.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
LitElement,
|
||||
html,
|
||||
TemplateResult,
|
||||
property,
|
||||
customElement,
|
||||
} from "lit-element";
|
||||
import { HassEntity } from "home-assistant-js-websocket";
|
||||
|
||||
import { HomeAssistant } from "../../../types";
|
||||
|
||||
import "../../../components/ha-relative-time";
|
||||
|
||||
@customElement("more-info-script")
|
||||
class MoreInfoScript extends LitElement {
|
||||
@property() public hass!: HomeAssistant;
|
||||
@property() public stateObj?: HassEntity;
|
||||
|
||||
protected render(): TemplateResult | void {
|
||||
if (!this.hass || !this.stateObj) {
|
||||
return html``;
|
||||
}
|
||||
|
||||
return html`
|
||||
<div>
|
||||
${this.hass.localize(
|
||||
"ui.dialogs.more_info_control.script.last_triggered"
|
||||
)}:
|
||||
${this.stateObj.attributes.last_triggered
|
||||
? html`
|
||||
<ha-relative-time
|
||||
.hass=${this.hass}
|
||||
.datetime=${this.stateObj.attributes.last_triggered}
|
||||
></ha-relative-time>
|
||||
`
|
||||
: this.hass.localize("ui.components.relative_time.never")}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
"more-info-script": MoreInfoScript;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user