diff --git a/docs/.vitepress/theme/index.js b/docs/.vitepress/theme/index.js index 2911112c..655588b8 100644 --- a/docs/.vitepress/theme/index.js +++ b/docs/.vitepress/theme/index.js @@ -1,5 +1,6 @@ import DefaultTheme from 'vitepress/theme' -import { onMounted } from 'vue'; +import { onMounted, watch, nextTick } from 'vue'; +import { useRoute } from 'vitepress'; import mediumZoom from 'medium-zoom'; // override options: https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css import './dashboard.css' @@ -11,12 +12,20 @@ import ControlsTable from '../../components/ControlsTable.vue' export default { extends: DefaultTheme, setup() { - onMounted(() => { + const route = useRoute(); + const initZoom = () => { mediumZoom('[data-zoomable]', { background: 'black', margin: 24 }); - }) + }; + onMounted(() => { + initZoom(); + }); + watch( + () => route.path, + () => nextTick(() => initZoom()) + ); }, enhanceApp(ctx) { // register your custom global components diff --git a/docs/contributing/guides/events.md b/docs/contributing/guides/events.md index 19fa0e4e..1666f97b 100644 --- a/docs/contributing/guides/events.md +++ b/docs/contributing/guides/events.md @@ -10,9 +10,9 @@ An important part of the Dashboard is how Node-RED and the Dashboard communicate This is a comprehensive list of all events that are sent between Node-RED and the Dashboard via socket.io. ### `ui-config` -- Payload: `object{ pages, dashboard, widgets }` +- Payload: `object{ dashboards, theme, pages, groups, widgets }` -Used to transport dashboard/page/[widget](#widget) layout data. +Used to transport dashboard/theme/page/groups/[widget](#widget) layout data, each mapped by their respective id's. ### `msg-input:` - Payload: `` diff --git a/nodes/config/ui_base.js b/nodes/config/ui_base.js index 76f516d9..8b96f1dc 100644 --- a/nodes/config/ui_base.js +++ b/nodes/config/ui_base.js @@ -169,30 +169,30 @@ module.exports = function(RED) { // map themes by their ID if (!node.ui.themes.has(page.theme)) { const theme = RED.nodes.getNode(page.theme) - node.ui.themes.set(page.theme, theme) + // eslint-disable-next-line no-unused-vars + const { _wireCount, _inputCallback, _inputCallbacks, _closeCallbacks, wires, type, ...t } = theme + node.ui.themes.set(page.theme, t) } // map pages by their ID if (!node.ui.pages.has(page.id)) { - node.ui.pages.set(page.id, page) + // eslint-disable-next-line no-unused-vars + const { _user, type, ...p } = page + node.ui.pages.set(page.id, p) } // map groups on a page-by-page basis - if (!node.ui.groups.has(page.id)) { - node.ui.groups.set(page.id, {}) + if (!node.ui.groups.has(group.id)) { + // eslint-disable-next-line no-unused-vars + const { _user, type, ...g } = group + node.ui.groups.set(group.id, g) } // map widgets on a group-by-group basis - if (!node.ui.widgets.has(group.id)) { - node.ui.widgets.set(group.id, {}) + if (!node.ui.widgets.has(widget.id)) { + node.ui.widgets.set(widget.id, widget) } - // add the widget to the page-mapping - node.ui.groups.get(page.id)[group.id] = group - - // add the widget to the page-mapping - node.ui.widgets.get(group.id)[widget.id] = widget - // add Node-RED listener to the widget for when it's corresponding node receives a msg in Node-RED widgetNode.on('input', async function (msg, send, done) { // send a message to the UI to let it know we've received a msg diff --git a/ui/src/App.vue b/ui/src/App.vue index ae59adb4..762486b8 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -48,12 +48,11 @@ export default { // loop over the widgets defined in Node-RED, // map their respective Vue component for rendering on a page - Object.keys(payload.widgets).forEach(page => { - Object.values(payload.widgets[page]).forEach(widget => { - console.log("adding widget", widget.type) - // widget.component = 'hello world' - widget.component = markRaw(widgetComponents[widget.type]) - }) + Object.keys(payload.widgets).forEach(id => { + const widget = payload.widgets[id] + console.log("adding widget", widget.type) + // widget.component = 'hello world' + widget.component = markRaw(widgetComponents[widget.type]) }) // store this data in our VueX store for access across the app @@ -62,6 +61,7 @@ export default { this.$store.commit('ui/groups', payload.groups) this.$store.commit('ui/widgets', payload.widgets) this.$store.commit('ui/themes', payload.themes) + console.log('all stored') }) }, methods: { diff --git a/ui/src/layouts/Flex.vue b/ui/src/layouts/Flex.vue index 18def674..1ac890c1 100644 --- a/ui/src/layouts/Flex.vue +++ b/ui/src/layouts/Flex.vue @@ -8,7 +8,7 @@