fix handling of js @params (only global); fieldset/component: + 'domain'
This commit is contained in:
parent
4bbc3cad0a
commit
36abaf6f74
6 changed files with 17 additions and 17 deletions
|
@ -1,6 +1,6 @@
|
||||||
import { createApp } from 'petite-vue'
|
import { createApp } from 'petite-vue'
|
||||||
|
|
||||||
import { pageid, domain, nopoll } from '@params'
|
import { domain, nopoll } from '@params'
|
||||||
|
|
||||||
type Config = {
|
type Config = {
|
||||||
apiurl: string
|
apiurl: string
|
||||||
|
@ -51,10 +51,12 @@ const appdata = {
|
||||||
|
|
||||||
// components
|
// components
|
||||||
|
|
||||||
function Data(name: string, action: string): object {
|
function Data(name, action, domain: string): object {
|
||||||
|
domain = domain || this.conf.domain
|
||||||
const comp = {
|
const comp = {
|
||||||
name: name, // matches/determines class of incoming/outgoing message
|
name: name, // -> class of incoming/outgoing message
|
||||||
action: action, // (default) action of outgoing message
|
action: action, // (default) action of outgoing message
|
||||||
|
domain: domain, // domain of incoming/outgoing message
|
||||||
data: {}, // model (2-way data store)
|
data: {}, // model (2-way data store)
|
||||||
exec // default function to execute upon button click
|
exec // default function to execute upon button click
|
||||||
}
|
}
|
||||||
|
@ -76,21 +78,24 @@ function exec() {
|
||||||
sendMsg(conf, [conf.domain, this.action, this.name, data.id], data)
|
sendMsg(conf, [conf.domain, this.action, this.name, data.id], data)
|
||||||
}
|
}
|
||||||
|
|
||||||
function poll() {
|
|
||||||
dopoll(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle(msg) {
|
function handle(msg) {
|
||||||
const data = JSON.parse(msg.payload)
|
const data = JSON.parse(msg.payload)
|
||||||
const [ domain, action, class_, item ] = msg.path.split('/')
|
const [ domain, action, class_, item ] = msg.path.split('/')
|
||||||
//console.log('msgbase: ', domain, action, class_, item)
|
//console.log('msgbase: ', domain, action, class_, item)
|
||||||
// TODO: check message parts (using default values), select handler fct
|
// TODO: check message parts (using default values), select handler fct
|
||||||
const comp = this.components[class_ || data]
|
const comp = this.components[class_ || data]
|
||||||
|
if (domain && domain != comp.domain) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (comp != undefined) {
|
if (comp != undefined) {
|
||||||
Object.assign(comp.data, data)
|
Object.assign(comp.data, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function poll() {
|
||||||
|
dopoll(this)
|
||||||
|
}
|
||||||
|
|
||||||
// basic functions - move to api.ts
|
// basic functions - move to api.ts
|
||||||
|
|
||||||
async function sendMsg(conf: Config, basemsg: string[], data: any) {
|
async function sendMsg(conf: Config, basemsg: string[], data: any) {
|
||||||
|
|
|
@ -9,9 +9,6 @@ date: 2023-03-14
|
||||||
author: helmutm
|
author: helmutm
|
||||||
draft: false
|
draft: false
|
||||||
weight: 100
|
weight: 100
|
||||||
api:
|
|
||||||
domain: system
|
|
||||||
nopoll: false
|
|
||||||
---
|
---
|
||||||
|
|
||||||
cyberscopes example site - Login Form
|
cyberscopes example site - Login Form
|
||||||
|
|
|
@ -9,8 +9,6 @@ date: 2023-03-12
|
||||||
author: helmutm
|
author: helmutm
|
||||||
draft: false
|
draft: false
|
||||||
weight: 100
|
weight: 100
|
||||||
api:
|
|
||||||
domain: test
|
|
||||||
---
|
---
|
||||||
|
|
||||||
cyberscopes example site - use petite-vue in Hugo-generated sites.
|
cyberscopes example site - use petite-vue in Hugo-generated sites.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
{{- if $jsmod := $.Param "api.module" -}}
|
{{- if $jsmod := $.Param "api.module" -}}
|
||||||
{{- $pageid := or .Params.Pageid (and .File .File.UniqueID) "unknown" -}}
|
{{- $params := dict "domain" .Site.Params.api.domain
|
||||||
{{- $params := dict "pageid" $pageid
|
"nopoll" .Site.Params.api.nopoll | default false -}}
|
||||||
"domain" ($.Param "api.domain")
|
|
||||||
"nopoll" ($.Param "api.nopoll") | default false -}}
|
|
||||||
{{- $js := resources.Get (printf "js/%s" $jsmod) | js.Build (
|
{{- $js := resources.Get (printf "js/%s" $jsmod) | js.Build (
|
||||||
dict "minify" false "params" $params) -}}
|
dict "minify" false "params" $params) -}}
|
||||||
<script src="{{ $js.Permalink }}" defer></script>
|
<script src="{{ $js.Permalink }}" defer></script>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
<h3>Debug Information</h3>
|
<h3>Debug Information</h3>
|
||||||
|
|
||||||
<div @vue:mounted="mounted('conf')">
|
<div @vue:mounted="mounted('conf')">
|
||||||
|
<div>domain: {| conf.domain |}</div>
|
||||||
<div>item id: {| conf.itemid |}</div>
|
<div>item id: {| conf.itemid |}</div>
|
||||||
<div>session id: {| conf.sid |}</div>
|
<div>session id: {| conf.sid |}</div>
|
||||||
<div>interaction id: {| conf.iid |}</div>
|
<div>interaction id: {| conf.iid |}</div>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{{- $name := .Get "name" | default "data" -}}
|
{{- $name := .Get "name" | default "data" -}}
|
||||||
{{- $action := .Get "action" | default "data" -}}
|
{{- $action := .Get "action" | default "data" -}}
|
||||||
|
{{- $domain := .Get "domain" -}}
|
||||||
{{- $comp := .Get "component" | default "Data" -}}
|
{{- $comp := .Get "component" | default "Data" -}}
|
||||||
<div v-scope="{{ $comp }}('{{ $name }}', '{{ $action }}')">
|
<div v-scope="{{ $comp }}('{{ $name }}', '{{ $action }}', '{{ $domain }}')">
|
||||||
{{ .Inner }}
|
{{ .Inner }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue