mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-25 13:57:21 +00:00
DevTools: Navigate to History from last changed/last updated (#11133)
This commit is contained in:
parent
ed462dc257
commit
6053b64b2e
@ -1,3 +1,4 @@
|
|||||||
|
import { addHours } from "date-fns";
|
||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import {
|
import {
|
||||||
mdiClipboardTextMultipleOutline,
|
mdiClipboardTextMultipleOutline,
|
||||||
@ -200,12 +201,18 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
|||||||
<p>
|
<p>
|
||||||
<b
|
<b
|
||||||
>[[localize('ui.panel.developer-tools.tabs.states.last_changed')]]:</b
|
>[[localize('ui.panel.developer-tools.tabs.states.last_changed')]]:</b
|
||||||
><br />[[lastChangedString(_entity)]]
|
><br />
|
||||||
|
<a href="[[historyFromLastChanged(_entity)]]"
|
||||||
|
>[[lastChangedString(_entity)]]</a
|
||||||
|
>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<b
|
<b
|
||||||
>[[localize('ui.panel.developer-tools.tabs.states.last_updated')]]:</b
|
>[[localize('ui.panel.developer-tools.tabs.states.last_updated')]]:</b
|
||||||
><br />[[lastUpdatedString(_entity)]]
|
><br />
|
||||||
|
<a href="[[historyFromLastUpdated(_entity)]]"
|
||||||
|
>[[lastUpdatedString(_entity)]]</a
|
||||||
|
>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@ -407,6 +414,20 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
|
|||||||
this._expanded = true;
|
this._expanded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_getHistoryURL(entityId, inputDate) {
|
||||||
|
const date = new Date(inputDate);
|
||||||
|
const hourBefore = addHours(date, -1).toISOString();
|
||||||
|
return `/history?entity_id=${entityId}&start_date=${hourBefore}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
historyFromLastChanged(entity) {
|
||||||
|
return this._getHistoryURL(entity.entity_id, entity.last_changed);
|
||||||
|
}
|
||||||
|
|
||||||
|
historyFromLastUpdated(entity) {
|
||||||
|
return this._getHistoryURL(entity.entity_id, entity.last_updated);
|
||||||
|
}
|
||||||
|
|
||||||
expandedChanged(ev) {
|
expandedChanged(ev) {
|
||||||
this._expanded = ev.detail.expanded;
|
this._expanded = ev.detail.expanded;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user