diff --git a/src/dialogs/more-info/controls/more-info-script.js b/src/dialogs/more-info/controls/more-info-script.js deleted file mode 100644 index fec483e033..0000000000 --- a/src/dialogs/more-info/controls/more-info-script.js +++ /dev/null @@ -1,31 +0,0 @@ -import "@polymer/iron-flex-layout/iron-flex-layout-classes"; -import { html } from "@polymer/polymer/lib/utils/html-tag"; -import { PolymerElement } from "@polymer/polymer/polymer-element"; -import LocalizeMixin from "../../../mixins/localize-mixin"; - -class MoreInfoScript extends LocalizeMixin(PolymerElement) { - static get template() { - return html` - - -
-
-
- [[localize('ui.dialogs.more_info_control.script.last_action')]] -
-
[[stateObj.attributes.last_action]]
-
-
- `; - } - - static get properties() { - return { - stateObj: { - type: Object, - }, - }; - } -} - -customElements.define("more-info-script", MoreInfoScript); diff --git a/src/dialogs/more-info/controls/more-info-script.ts b/src/dialogs/more-info/controls/more-info-script.ts new file mode 100644 index 0000000000..512cac1c43 --- /dev/null +++ b/src/dialogs/more-info/controls/more-info-script.ts @@ -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` +
+ ${this.hass.localize( + "ui.dialogs.more_info_control.script.last_triggered" + )}: + ${this.stateObj.attributes.last_triggered + ? html` + + ` + : this.hass.localize("ui.components.relative_time.never")} +
+ `; + } +} + +declare global { + interface HTMLElementTagNameMap { + "more-info-script": MoreInfoScript; + } +} diff --git a/src/translations/en.json b/src/translations/en.json index 490639a65b..f4eb9acaf9 100755 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -574,7 +574,8 @@ "settings": "Entity settings", "edit": "Edit entity", "script": { - "last_action": "Last Action" + "last_action": "Last Action", + "last_triggered": "Last Triggered" }, "sun": { "elevation": "Elevation",