From 80626c3d011050d2137c178c9cdbb76e9eb02da4 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Tue, 7 Mar 2023 08:46:20 +0100 Subject: [PATCH] use message field 'class' for identifying component --- assets/js/common.ts | 6 +++--- exampleSite/content/app/test1.md | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/assets/js/common.ts b/assets/js/common.ts index 3cab99e..4c45bd0 100644 --- a/assets/js/common.ts +++ b/assets/js/common.ts @@ -73,9 +73,9 @@ function poll() { function handle(msg) { const data = JSON.parse(msg.payload) - for (const k of Object.keys(data)) { - this.components.data.data[k] = data[k] - } + const [ domain, action, class_, item ] = msg.path.split('/') + //console.log('msgbase: ', domain, action, class_, item) + Object.assign(this.components[class_].data, data) } // basic functions - move to api.ts diff --git a/exampleSite/content/app/test1.md b/exampleSite/content/app/test1.md index dc859f8..080ce2b 100644 --- a/exampleSite/content/app/test1.md +++ b/exampleSite/content/app/test1.md @@ -22,7 +22,8 @@ cyberscopes example site - use petite-vue in Hugo-generated sites. Email: {{< pv/input-textline name="email" default="hm@cy55.de" >}} {{< pv/button >}} - {{< pv/display expr="`${data.firstname} ${data.lastname}`.trim() || '???'" >}} + {{< pv/display linkto="data.id" + expr="`${data.firstname} ${data.lastname}`.trim() || '???'" >}} {{< pv/display name="id" linkto="data.id" >}}