feature: Refresh dashboards when entity files change. (#319)

* feature: Refresh dashboards when entities change

* feature: Refresh dashboards when entities change

* bugfix: Concurrency, lock around websocket write
This commit is contained in:
James Read
2024-05-24 22:10:38 +00:00
committed by GitHub
parent 18423a9888
commit 3904f8563d
7 changed files with 74 additions and 12 deletions
+7 -1
View File
@@ -14,6 +14,8 @@ export function initMarshaller () {
window.initialHash = window.location.hash
window.currentSection = ''
window.addEventListener('EventExecutionFinished', onExecutionFinished)
}
@@ -99,6 +101,8 @@ function onExecutionFinished (evt) {
function showSection (title) {
title = title.replaceAll(' ', '')
window.currentSection = title
for (const section of document.querySelectorAll('section')) {
if (section.title === title) {
section.style.display = 'block'
@@ -213,7 +217,9 @@ function marshalDashboardStructureToHtml (json) {
}
}
if (window.initialHash !== '' && document.body.getAttribute('initial-marshal-complete') === null) {
if (window.currentSection !== '') {
showSection(window.currentSection)
} else if (window.initialHash !== '' && document.body.getAttribute('initial-marshal-complete') === null) {
showSection(window.initialHash.replace('#', ''))
} else {
if (rootGroup.querySelectorAll('action-button').length === 0 && json.dashboards.length > 0) {
+2 -1
View File
@@ -42,10 +42,11 @@ function websocketOnMessage (msg) {
switch (j.type) {
case 'EventConfigChanged':
case 'EventExecutionFinished':
case 'EventEntityChanged':
window.dispatchEvent(e)
break
default:
window.showBigError('Unknown message type from server: ' + j.type)
window.showBigError('ws-unhandled-message', 'handling websocket message', 'Unhandled websocket message type from server: ' + j.type, true)
}
}