mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +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;
|
||||
}
|
||||
.actions {
|
||||
margin: 36px 0 8px 0;
|
||||
margin: 8px 0;
|
||||
text-align: right;
|
||||
}
|
||||
`;
|
||||
|
@ -29,9 +29,19 @@ import { haStyleDialog } from "../../resources/styles";
|
||||
import "../../state-summary/state-card-content";
|
||||
import { HomeAssistant } from "../../types";
|
||||
import { showConfirmationDialog } from "../generic/show-dialog-box";
|
||||
import "./ha-more-info-history";
|
||||
import "./more-info-content";
|
||||
|
||||
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 = ["script"];
|
||||
|
||||
@ -127,7 +137,8 @@ export class MoreInfoDialog extends LitElement {
|
||||
`
|
||||
: ""}
|
||||
</ha-header-bar>
|
||||
${this._computeShowHistoryComponent(entityId)
|
||||
${CONTROL_DOMAINS.includes(domain) &&
|
||||
this._computeShowHistoryComponent(entityId)
|
||||
? html`
|
||||
<mwc-tab-bar
|
||||
.activeIndex=${this._currTabIndex}
|
||||
@ -135,7 +146,7 @@ export class MoreInfoDialog extends LitElement {
|
||||
>
|
||||
<mwc-tab
|
||||
.label=${this.hass.localize(
|
||||
"ui.dialogs.more_info_control.controls"
|
||||
"ui.dialogs.more_info_control.details"
|
||||
)}
|
||||
></mwc-tab>
|
||||
<mwc-tab
|
||||
@ -164,6 +175,13 @@ export class MoreInfoDialog extends LitElement {
|
||||
.stateObj=${stateObj}
|
||||
.hass=${this.hass}
|
||||
></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
|
||||
? html`
|
||||
<p>
|
||||
@ -188,10 +206,10 @@ export class MoreInfoDialog extends LitElement {
|
||||
: ""}
|
||||
`
|
||||
: html`
|
||||
<ha-more-info-tab-history
|
||||
<ha-more-info-history
|
||||
.hass=${this.hass}
|
||||
.entityId=${this._entityId}
|
||||
></ha-more-info-tab-history>
|
||||
></ha-more-info-history>
|
||||
`
|
||||
)}
|
||||
</div>
|
||||
@ -199,10 +217,6 @@ export class MoreInfoDialog extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
protected firstUpdated(): void {
|
||||
import("./ha-more-info-tab-history");
|
||||
}
|
||||
|
||||
private _enlarge() {
|
||||
this.large = !this.large;
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ import { getRecentWithCache } from "../../data/cached-history";
|
||||
import { HistoryResult } from "../../data/history";
|
||||
import { getLogbookData, LogbookEntry } from "../../data/logbook";
|
||||
import "../../panels/logbook/ha-logbook";
|
||||
import { haStyleDialog } from "../../resources/styles";
|
||||
import { haStyle } from "../../resources/styles";
|
||||
import { HomeAssistant } from "../../types";
|
||||
|
||||
@customElement("ha-more-info-tab-history")
|
||||
export class MoreInfoTabHistoryDialog extends LitElement {
|
||||
@customElement("ha-more-info-history")
|
||||
export class MoreInfoHistory extends LitElement {
|
||||
@property({ attribute: false }) public hass!: HomeAssistant;
|
||||
|
||||
@property() public entityId!: string;
|
||||
@ -43,8 +43,7 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
||||
return html``;
|
||||
}
|
||||
|
||||
return html`
|
||||
<state-history-charts
|
||||
return html`<state-history-charts
|
||||
up-to-now
|
||||
.hass=${this.hass}
|
||||
.historyData=${this._stateHistory}
|
||||
@ -71,8 +70,9 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
||||
.userIdToName=${this._persons}
|
||||
></ha-logbook>
|
||||
`
|
||||
: ""}
|
||||
`;
|
||||
: html`<div class="no-entries">
|
||||
${this.hass.localize("ui.components.logbook.entries_not_found")}
|
||||
</div>`}`;
|
||||
}
|
||||
|
||||
protected firstUpdated(): void {
|
||||
@ -139,13 +139,16 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
||||
|
||||
static get styles() {
|
||||
return [
|
||||
haStyleDialog,
|
||||
haStyle,
|
||||
css`
|
||||
state-history-charts {
|
||||
display: block;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.no-entries {
|
||||
text-align: center;
|
||||
padding: 16px;
|
||||
}
|
||||
ha-logbook {
|
||||
max-height: 360px;
|
||||
}
|
||||
@ -161,6 +164,6 @@ export class MoreInfoTabHistoryDialog extends LitElement {
|
||||
|
||||
declare global {
|
||||
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) {
|
||||
return html`
|
||||
<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>
|
||||
`;
|
||||
}
|
||||
|
@ -281,6 +281,9 @@
|
||||
"error_required": "Required"
|
||||
},
|
||||
"components": {
|
||||
"logbook": {
|
||||
"entries_not_found": "No logbook entries found."
|
||||
},
|
||||
"entity": {
|
||||
"entity-picker": {
|
||||
"entity": "Entity",
|
||||
@ -401,7 +404,7 @@
|
||||
"dismiss": "Dismiss dialog",
|
||||
"settings": "Entity settings",
|
||||
"edit": "Edit entity",
|
||||
"controls": "Controls",
|
||||
"details": "Details",
|
||||
"history": "History",
|
||||
"script": {
|
||||
"last_action": "Last Action",
|
||||
@ -2045,7 +2048,6 @@
|
||||
}
|
||||
},
|
||||
"logbook": {
|
||||
"entries_not_found": "No logbook entries found.",
|
||||
"ranges": {
|
||||
"today": "Today",
|
||||
"yesterday": "Yesterday",
|
||||
|
Loading…
x
Reference in New Issue
Block a user