start with login page; nopoll config param; handle: check message 'class'

This commit is contained in:
Helmut Merz 2023-03-15 12:43:55 +01:00
parent 1aa76a59c8
commit 4bbc3cad0a
7 changed files with 45 additions and 9 deletions

View file

@ -1,7 +1,6 @@
import { createApp } from 'petite-vue'
import { api, polling } from './settings'
import { pageid, domain } from '@params'
import { pageid, domain, nopoll } from '@params'
type Config = {
apiurl: string
@ -10,6 +9,7 @@ type Config = {
itemid: string
sid: string
iid: string
nopoll: boolean
}
export function config (api, polling): Config {
@ -21,7 +21,8 @@ export function config (api, polling): Config {
domain: domain,
itemid: urlparams.get('id'),
sid: getSid(),
iid: createRandString(1)
iid: createRandString(1),
nopoll: nopoll
}
}
@ -29,7 +30,7 @@ export const pvapp = {
run(conf: Config) {
appdata.conf = conf
createApp(appdata).mount()
if (appdata.conf.pollurl) {
if (appdata.conf.pollurl && !appdata.conf.nopoll) {
appdata.poll()
}
}
@ -84,7 +85,10 @@ function handle(msg) {
const [ domain, action, class_, item ] = msg.path.split('/')
//console.log('msgbase: ', domain, action, class_, item)
// TODO: check message parts (using default values), select handler fct
Object.assign(this.components[class_ || 'data'].data, data)
const comp = this.components[class_ || data]
if (comp != undefined) {
Object.assign(comp.data, data)
}
}
// basic functions - move to api.ts

View file

@ -10,4 +10,4 @@ export const domain = 'domain-dummy'
export const action = 'action-dummy'
export const class_ = 'class-dummy'
export const nopolling = false
export const nopoll = false

View file

@ -5,8 +5,8 @@ export const api = {
//export const polling = null // suppress polling
export const polling = {
msgbase: ['system', 'poll', 'service', 'pclt-0001']
//msgbase: ['system', 'poll', 'session']
//msgbase: ['system', 'poll', 'service', 'pclt-0001']
msgbase: ['system', 'poll', 'session']
//msgbase: ['system', 'poll', 'interaction']
}

View file

@ -28,6 +28,7 @@ params:
api:
domain: demo
module: main.ts
nopoll: false
taxonomies:
domain: domains

View file

@ -0,0 +1,29 @@
---
title: Login
summary: Enter Login data
img:
pageid: app-login
domains: [App]
topics: [Examples]
date: 2023-03-14
author: helmutm
draft: false
weight: 100
api:
domain: system
nopoll: false
---
cyberscopes example site - Login Form
{{< pv/fieldset name="login" >}}
Login: {{< pv/input-textline name="login" attrs="autofocus" >}}
Password: {{< pv/input-textline type="password" name="password" >}}
{{< pv/button label="Login" >}}
{{< /pv/fieldset >}}
---
{{< pv/debug >}}

View file

@ -1,7 +1,8 @@
{{- if $jsmod := $.Param "api.module" -}}
{{- $pageid := or .Params.Pageid (and .File .File.UniqueID) "unknown" -}}
{{- $params := dict "pageid" $pageid
"domain" ($.Param "api.domain") -}}
"domain" ($.Param "api.domain")
"nopoll" ($.Param "api.nopoll") | default false -}}
{{- $js := resources.Get (printf "js/%s" $jsmod) | js.Build (
dict "minify" false "params" $params) -}}
<script src="{{ $js.Permalink }}" defer></script>

View file

@ -4,6 +4,7 @@
<div @vue:mounted="mounted('conf')">
<div>item id: {| conf.itemid |}</div>
<div>session id: {| conf.sid |}</div>
<div>interaction id: {| conf.iid |}</div>
</div>
<div @vue:mounted="mounted('output')">