mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 14:27:20 +00:00
Make "Show more" show everything starting from yesterday (#10533)
This commit is contained in:
parent
4719636176
commit
3c67fc96b1
@ -1,3 +1,4 @@
|
|||||||
|
import { startOfYesterday } from "date-fns";
|
||||||
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||||
@ -22,6 +23,8 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
|
|
||||||
@state() private _stateHistory?: HistoryResult;
|
@state() private _stateHistory?: HistoryResult;
|
||||||
|
|
||||||
|
private _showMoreHref = "";
|
||||||
|
|
||||||
private _throttleGetStateHistory = throttle(() => {
|
private _throttleGetStateHistory = throttle(() => {
|
||||||
this._getStateHistory();
|
this._getStateHistory();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
@ -31,14 +34,12 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
const href = "/history?entity_id=" + this.entityId;
|
|
||||||
|
|
||||||
return html`${isComponentLoaded(this.hass, "history")
|
return html`${isComponentLoaded(this.hass, "history")
|
||||||
? html` <div class="header">
|
? html` <div class="header">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
${this.hass.localize("ui.dialogs.more_info_control.history")}
|
${this.hass.localize("ui.dialogs.more_info_control.history")}
|
||||||
</div>
|
</div>
|
||||||
<a href=${href} @click=${this._close}
|
<a href=${this._showMoreHref} @click=${this._close}
|
||||||
>${this.hass.localize(
|
>${this.hass.localize(
|
||||||
"ui.dialogs.more_info_control.show_more"
|
"ui.dialogs.more_info_control.show_more"
|
||||||
)}</a
|
)}</a
|
||||||
@ -63,6 +64,10 @@ export class MoreInfoHistory extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._showMoreHref = `/history?entity_id=${
|
||||||
|
this.entityId
|
||||||
|
}&start_date=${startOfYesterday().toISOString()}`;
|
||||||
|
|
||||||
this._throttleGetStateHistory();
|
this._throttleGetStateHistory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { startOfYesterday } from "date-fns";
|
||||||
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
import { css, html, LitElement, PropertyValues, TemplateResult } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, state } from "lit/decorators";
|
||||||
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
import { isComponentLoaded } from "../../common/config/is_component_loaded";
|
||||||
@ -30,6 +31,8 @@ export class MoreInfoLogbook extends LitElement {
|
|||||||
|
|
||||||
private _error?: string;
|
private _error?: string;
|
||||||
|
|
||||||
|
private _showMoreHref = "";
|
||||||
|
|
||||||
private _throttleGetLogbookEntries = throttle(() => {
|
private _throttleGetLogbookEntries = throttle(() => {
|
||||||
this._getLogBookData();
|
this._getLogBookData();
|
||||||
}, 10000);
|
}, 10000);
|
||||||
@ -44,8 +47,6 @@ export class MoreInfoLogbook extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
|
|
||||||
const href = "/logbook?entity_id=" + this.entityId;
|
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
${isComponentLoaded(this.hass, "logbook")
|
${isComponentLoaded(this.hass, "logbook")
|
||||||
? this._error
|
? this._error
|
||||||
@ -67,7 +68,7 @@ export class MoreInfoLogbook extends LitElement {
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
${this.hass.localize("ui.dialogs.more_info_control.logbook")}
|
${this.hass.localize("ui.dialogs.more_info_control.logbook")}
|
||||||
</div>
|
</div>
|
||||||
<a href=${href} @click=${this._close}
|
<a href=${this._showMoreHref} @click=${this._close}
|
||||||
>${this.hass.localize(
|
>${this.hass.localize(
|
||||||
"ui.dialogs.more_info_control.show_more"
|
"ui.dialogs.more_info_control.show_more"
|
||||||
)}</a
|
)}</a
|
||||||
@ -106,6 +107,10 @@ export class MoreInfoLogbook extends LitElement {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this._showMoreHref = `/logbook?entity_id=${
|
||||||
|
this.entityId
|
||||||
|
}&start_date=${startOfYesterday().toISOString()}`;
|
||||||
|
|
||||||
this._throttleGetLogbookEntries();
|
this._throttleGetLogbookEntries();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,11 @@ class HaPanelHistory extends LitElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._entityId = extractSearchParam("entity_id") ?? "";
|
this._entityId = extractSearchParam("entity_id") ?? "";
|
||||||
|
|
||||||
|
const startDate = extractSearchParam("start_date");
|
||||||
|
if (startDate) {
|
||||||
|
this._startDate = new Date(startDate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues) {
|
protected updated(changedProps: PropertyValues) {
|
||||||
|
@ -161,6 +161,11 @@ export class HaPanelLogbook extends LitElement {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this._entityId = extractSearchParam("entity_id") ?? "";
|
this._entityId = extractSearchParam("entity_id") ?? "";
|
||||||
|
|
||||||
|
const startDate = extractSearchParam("start_date");
|
||||||
|
if (startDate) {
|
||||||
|
this._startDate = new Date(startDate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues<this>) {
|
protected updated(changedProps: PropertyValues<this>) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user