mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
more-info dialog for counter (#4038)
* more-info dialog for counter * address comments
This commit is contained in:
parent
0005c75091
commit
be4d431dc3
@ -35,6 +35,7 @@ export const DOMAINS_WITH_MORE_INFO = [
|
|||||||
"camera",
|
"camera",
|
||||||
"climate",
|
"climate",
|
||||||
"configurator",
|
"configurator",
|
||||||
|
"counter",
|
||||||
"cover",
|
"cover",
|
||||||
"fan",
|
"fan",
|
||||||
"group",
|
"group",
|
||||||
|
@ -14,6 +14,7 @@ const fixedIcons = {
|
|||||||
climate: "hass:thermostat",
|
climate: "hass:thermostat",
|
||||||
configurator: "hass:settings",
|
configurator: "hass:settings",
|
||||||
conversation: "hass:text-to-speech",
|
conversation: "hass:text-to-speech",
|
||||||
|
counter: "hass:counter",
|
||||||
device_tracker: "hass:account",
|
device_tracker: "hass:account",
|
||||||
fan: "hass:fan",
|
fan: "hass:fan",
|
||||||
google_assistant: "hass:google-assistant",
|
google_assistant: "hass:google-assistant",
|
||||||
|
@ -10,6 +10,7 @@ import "./more-info-automation";
|
|||||||
import "./more-info-camera";
|
import "./more-info-camera";
|
||||||
import "./more-info-climate";
|
import "./more-info-climate";
|
||||||
import "./more-info-configurator";
|
import "./more-info-configurator";
|
||||||
|
import "./more-info-counter";
|
||||||
import "./more-info-cover";
|
import "./more-info-cover";
|
||||||
import "./more-info-default";
|
import "./more-info-default";
|
||||||
import "./more-info-fan";
|
import "./more-info-fan";
|
||||||
|
70
src/dialogs/more-info/controls/more-info-counter.ts
Normal file
70
src/dialogs/more-info/controls/more-info-counter.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
import {
|
||||||
|
LitElement,
|
||||||
|
html,
|
||||||
|
TemplateResult,
|
||||||
|
CSSResult,
|
||||||
|
css,
|
||||||
|
property,
|
||||||
|
customElement,
|
||||||
|
} from "lit-element";
|
||||||
|
import "@material/mwc-button";
|
||||||
|
import { HassEntity } from "home-assistant-js-websocket";
|
||||||
|
|
||||||
|
import { HomeAssistant } from "../../../types";
|
||||||
|
|
||||||
|
@customElement("more-info-counter")
|
||||||
|
class MoreInfoCounter extends LitElement {
|
||||||
|
@property() public hass!: HomeAssistant;
|
||||||
|
@property() public stateObj?: HassEntity;
|
||||||
|
|
||||||
|
protected render(): TemplateResult | void {
|
||||||
|
if (!this.hass || !this.stateObj) {
|
||||||
|
return html``;
|
||||||
|
}
|
||||||
|
|
||||||
|
return html`
|
||||||
|
<div class="actions">
|
||||||
|
<mwc-button
|
||||||
|
.action="${"increment"}"
|
||||||
|
@click="${this._handleActionClick}"
|
||||||
|
>
|
||||||
|
${this.hass!.localize("ui.card.counter.actions.increment")}
|
||||||
|
</mwc-button>
|
||||||
|
<mwc-button
|
||||||
|
.action="${"decrement"}"
|
||||||
|
@click="${this._handleActionClick}"
|
||||||
|
>
|
||||||
|
${this.hass!.localize("ui.card.counter.actions.decrement")}
|
||||||
|
</mwc-button>
|
||||||
|
<mwc-button .action="${"reset"}" @click="${this._handleActionClick}">
|
||||||
|
${this.hass!.localize("ui.card.counter.actions.reset")}
|
||||||
|
</mwc-button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
private _handleActionClick(e: MouseEvent): void {
|
||||||
|
const action = (e.currentTarget as any).action;
|
||||||
|
this.hass.callService("counter", action, {
|
||||||
|
entity_id: this.stateObj!.entity_id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static get styles(): CSSResult {
|
||||||
|
return css`
|
||||||
|
.actions {
|
||||||
|
margin: 0 8px;
|
||||||
|
padding-top: 20px;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
"more-info-counter": MoreInfoCounter;
|
||||||
|
}
|
||||||
|
}
|
@ -417,6 +417,13 @@
|
|||||||
"away_mode": "Away mode",
|
"away_mode": "Away mode",
|
||||||
"aux_heat": "Aux heat"
|
"aux_heat": "Aux heat"
|
||||||
},
|
},
|
||||||
|
"counter": {
|
||||||
|
"actions": {
|
||||||
|
"increment": "increment",
|
||||||
|
"decrement": "decrement",
|
||||||
|
"reset": "reset"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cover": {
|
"cover": {
|
||||||
"position": "Position",
|
"position": "Position",
|
||||||
"tilt_position": "Tilt position"
|
"tilt_position": "Tilt position"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user