mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Only show history tabs for certain domains (#6895)
Co-authored-by: Zack Barett <arnett.zackary@gmail.com>
This commit is contained in:
parent
1130007d14
commit
e0bdef98a6
@ -55,7 +55,7 @@ class MoreInfoAutomation extends LitElement {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
.actions {
|
.actions {
|
||||||
margin: 36px 0 8px 0;
|
margin: 8px 0;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
@ -29,9 +29,19 @@ import { haStyleDialog } from "../../resources/styles";
|
|||||||
import "../../state-summary/state-card-content";
|
import "../../state-summary/state-card-content";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
import { showConfirmationDialog } from "../generic/show-dialog-box";
|
import { showConfirmationDialog } from "../generic/show-dialog-box";
|
||||||
|
import "./ha-more-info-history";
|
||||||
import "./more-info-content";
|
import "./more-info-content";
|
||||||
|
|
||||||
const DOMAINS_NO_INFO = ["camera", "configurator"];
|
const DOMAINS_NO_INFO = ["camera", "configurator"];
|
||||||
|
const CONTROL_DOMAINS = [
|
||||||
|
"light",
|
||||||
|
"media_player",
|
||||||
|
"vacuum",
|
||||||
|
"alarm_control_panel",
|
||||||
|
"climate",
|
||||||
|
"humidifier",
|
||||||
|
"weather",
|
||||||
|
];
|
||||||
const EDITABLE_DOMAINS_WITH_ID = ["scene", "automation"];
|
const EDITABLE_DOMAINS_WITH_ID = ["scene", "automation"];
|
||||||
const EDITABLE_DOMAINS = ["script"];
|
const EDITABLE_DOMAINS = ["script"];
|
||||||
|
|
||||||
@ -127,7 +137,8 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
</ha-header-bar>
|
</ha-header-bar>
|
||||||
${this._computeShowHistoryComponent(entityId)
|
${CONTROL_DOMAINS.includes(domain) &&
|
||||||
|
this._computeShowHistoryComponent(entityId)
|
||||||
? html`
|
? html`
|
||||||
<mwc-tab-bar
|
<mwc-tab-bar
|
||||||
.activeIndex=${this._currTabIndex}
|
.activeIndex=${this._currTabIndex}
|
||||||
@ -135,7 +146,7 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
>
|
>
|
||||||
<mwc-tab
|
<mwc-tab
|
||||||
.label=${this.hass.localize(
|
.label=${this.hass.localize(
|
||||||
"ui.dialogs.more_info_control.controls"
|
"ui.dialogs.more_info_control.details"
|
||||||
)}
|
)}
|
||||||
></mwc-tab>
|
></mwc-tab>
|
||||||
<mwc-tab
|
<mwc-tab
|
||||||
@ -164,6 +175,13 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
.stateObj=${stateObj}
|
.stateObj=${stateObj}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
></more-info-content>
|
></more-info-content>
|
||||||
|
${!CONTROL_DOMAINS.includes(domain) ||
|
||||||
|
!this._computeShowHistoryComponent(entityId)
|
||||||
|
? ""
|
||||||
|
: html`<ha-more-info-history
|
||||||
|
.hass=${this.hass}
|
||||||
|
.entityId=${this._entityId}
|
||||||
|
></ha-more-info-history>`}
|
||||||
${stateObj.attributes.restored
|
${stateObj.attributes.restored
|
||||||
? html`
|
? html`
|
||||||
<p>
|
<p>
|
||||||
@ -188,10 +206,10 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
: ""}
|
: ""}
|
||||||
`
|
`
|
||||||
: html`
|
: html`
|
||||||
<ha-more-info-tab-history
|
<ha-more-info-history
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.entityId=${this._entityId}
|
.entityId=${this._entityId}
|
||||||
></ha-more-info-tab-history>
|
></ha-more-info-history>
|
||||||
`
|
`
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -199,10 +217,6 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(): void {
|
|
||||||
import("./ha-more-info-tab-history");
|
|
||||||
}
|
|
||||||
|
|
||||||
private _enlarge() {
|
private _enlarge() {
|
||||||
this.large = !this.large;
|
this.large = !this.large;
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ import { getRecentWithCache } from "../../data/cached-history";
|
|||||||
import { HistoryResult } from "../../data/history";
|
import { HistoryResult } from "../../data/history";
|
||||||
import { getLogbookData, LogbookEntry } from "../../data/logbook";
|
import { getLogbookData, LogbookEntry } from "../../data/logbook";
|
||||||
import "../../panels/logbook/ha-logbook";
|
import "../../panels/logbook/ha-logbook";
|
||||||
import { haStyleDialog } from "../../resources/styles";
|
import { haStyle } from "../../resources/styles";
|
||||||
import { HomeAssistant } from "../../types";
|
import { HomeAssistant } from "../../types";
|
||||||
|
|
||||||
@customElement("ha-more-info-tab-history")
|
@customElement("ha-more-info-history")
|
||||||
export class MoreInfoTabHistoryDialog extends LitElement {
|
export class MoreInfoHistory extends LitElement {
|
||||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||||
|
|
||||||
@property() public entityId!: string;
|
@property() public entityId!: string;
|
||||||
@ -43,8 +43,7 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html`
|
return html`<state-history-charts
|
||||||
<state-history-charts
|
|
||||||
up-to-now
|
up-to-now
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.historyData=${this._stateHistory}
|
.historyData=${this._stateHistory}
|
||||||
@ -71,8 +70,9 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
|||||||
.userIdToName=${this._persons}
|
.userIdToName=${this._persons}
|
||||||
></ha-logbook>
|
></ha-logbook>
|
||||||
`
|
`
|
||||||
: ""}
|
: html`<div class="no-entries">
|
||||||
`;
|
${this.hass.localize("ui.components.logbook.entries_not_found")}
|
||||||
|
</div>`}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(): void {
|
protected firstUpdated(): void {
|
||||||
@ -139,13 +139,16 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
|||||||
|
|
||||||
static get styles() {
|
static get styles() {
|
||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyle,
|
||||||
css`
|
css`
|
||||||
state-history-charts {
|
state-history-charts {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
|
.no-entries {
|
||||||
|
text-align: center;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
ha-logbook {
|
ha-logbook {
|
||||||
max-height: 360px;
|
max-height: 360px;
|
||||||
}
|
}
|
||||||
@ -161,6 +164,6 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"ha-more-info-tab-history": MoreInfoTabHistoryDialog;
|
"ha-more-info-history": MoreInfoHistory;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -67,7 +67,7 @@ class HaLogbook extends LitElement {
|
|||||||
if (!this.entries?.length) {
|
if (!this.entries?.length) {
|
||||||
return html`
|
return html`
|
||||||
<div class="container no-entries" .dir=${emitRTLDirection(this._rtl)}>
|
<div class="container no-entries" .dir=${emitRTLDirection(this._rtl)}>
|
||||||
${this.hass.localize("ui.panel.logbook.entries_not_found")}
|
${this.hass.localize("ui.components.logbook.entries_not_found")}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
@ -281,6 +281,9 @@
|
|||||||
"error_required": "Required"
|
"error_required": "Required"
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
|
"logbook": {
|
||||||
|
"entries_not_found": "No logbook entries found."
|
||||||
|
},
|
||||||
"entity": {
|
"entity": {
|
||||||
"entity-picker": {
|
"entity-picker": {
|
||||||
"entity": "Entity",
|
"entity": "Entity",
|
||||||
@ -401,7 +404,7 @@
|
|||||||
"dismiss": "Dismiss dialog",
|
"dismiss": "Dismiss dialog",
|
||||||
"settings": "Entity settings",
|
"settings": "Entity settings",
|
||||||
"edit": "Edit entity",
|
"edit": "Edit entity",
|
||||||
"controls": "Controls",
|
"details": "Details",
|
||||||
"history": "History",
|
"history": "History",
|
||||||
"script": {
|
"script": {
|
||||||
"last_action": "Last Action",
|
"last_action": "Last Action",
|
||||||
@ -2045,7 +2048,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"logbook": {
|
"logbook": {
|
||||||
"entries_not_found": "No logbook entries found.",
|
|
||||||
"ranges": {
|
"ranges": {
|
||||||
"today": "Today",
|
"today": "Today",
|
||||||
"yesterday": "Yesterday",
|
"yesterday": "Yesterday",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user