work in progress: polling, ...
This commit is contained in:
parent
bba0177f9f
commit
d1eb02ee28
3 changed files with 20 additions and 4 deletions
|
@ -3,6 +3,7 @@ import { createApp } from './lib/petite-vue.es.js'
|
|||
createApp({
|
||||
$delimiters: ['{|', '|}'],
|
||||
urlParams: new URL(location.href).searchParams,
|
||||
poll,
|
||||
newdata: '',
|
||||
data: '',
|
||||
save
|
||||
|
@ -10,6 +11,23 @@ createApp({
|
|||
|
||||
function save() {
|
||||
this.data += '\n' + this.newdata
|
||||
this.newdata = ''
|
||||
}
|
||||
|
||||
//let pwait = new Promise(function(resolve, reject) {
|
||||
// poll()
|
||||
//})
|
||||
|
||||
function poll() {
|
||||
fetch('http://localhost:8125/api/system/poll/service/pclt-0001')
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
console.log(data)
|
||||
this.newdata = data['status']
|
||||
this.poll()
|
||||
})
|
||||
console.log('after fetch')
|
||||
return null
|
||||
}
|
||||
|
||||
function Data() {
|
||||
|
@ -24,5 +42,3 @@ function Data() {
|
|||
// p = new URL(location.href).searchParams
|
||||
// id = p.get('id')
|
||||
|
||||
// fetch('http://localhost:8125/api/system/poll/service/pclt-0001').
|
||||
// then((res) => res.json()).then((data) => console.log(data))
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
{{ $js := resources.Get "js/main.ts" | js.Build (dict "minify" false) }}
|
||||
<script src="{{ $js.Permalink }}"></script>
|
||||
<script src="{{ $js.Permalink }}" defer></script>
|
||||
<div v-scope>{| poll() |}</div>
|
||||
|
|
|
@ -16,4 +16,3 @@
|
|||
<div>id = {| urlParams.get('id') |}</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue