mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-17 21:31:56 +01:00
webclient: work on TriggerAction load&store
This commit is contained in:
parent
fb7b4ab37f
commit
636982ead9
87
web_client/hvueComponentsDialog.go
Normal file
87
web_client/hvueComponentsDialog.go
Normal file
@ -0,0 +1,87 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
"github.com/mame82/hvue"
|
||||
)
|
||||
|
||||
func InitComponentsDialog() {
|
||||
hvue.NewComponent(
|
||||
"select-string-from-array",
|
||||
hvue.Template(templateSelectStringModal),
|
||||
hvue.DataFunc(func(vm *hvue.VM) interface{} {
|
||||
data := struct {
|
||||
*js.Object
|
||||
CurrentSelection *js.Object `js:"CurrentSelection"`
|
||||
}{Object:O()}
|
||||
data.CurrentSelection = O()
|
||||
|
||||
return &data
|
||||
}),
|
||||
hvue.Mounted(func(vm *hvue.VM) {
|
||||
vm.Set("CurrentSelection", vm.Get("values").Index(0))
|
||||
println("Index 0 on mount", vm.Get("values").Index(0))
|
||||
}),
|
||||
hvue.ComputedWithGetSet(
|
||||
"visible",
|
||||
func(vm *hvue.VM) interface{} {
|
||||
return vm.Get("value")
|
||||
},
|
||||
func(vm *hvue.VM, newValue *js.Object) {
|
||||
vm.Call("$emit", "input", newValue)
|
||||
},
|
||||
),
|
||||
hvue.Method(
|
||||
"onLoadPressed",
|
||||
func(vm *hvue.VM) {
|
||||
vm.Call("$emit", "load", vm.Get("CurrentSelection"))
|
||||
println(vm.Get("CurrentSelection"))
|
||||
|
||||
},
|
||||
),
|
||||
hvue.PropObj(
|
||||
"values",
|
||||
hvue.Required,
|
||||
),
|
||||
hvue.PropObj(
|
||||
"value",
|
||||
hvue.Required,
|
||||
hvue.Types(hvue.PBoolean),
|
||||
),
|
||||
hvue.PropObj(
|
||||
"title",
|
||||
hvue.Types(hvue.PString),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
const templateSelectStringModal = `
|
||||
<q-modal v-model="visible">
|
||||
<q-modal-layout>
|
||||
<q-toolbar slot="header">
|
||||
<q-toolbar-title>
|
||||
{{ title }}
|
||||
</q-toolbar-title>
|
||||
</q-toolbar>
|
||||
|
||||
<q-list>
|
||||
<q-item link tag="label" v-for="name in values" :key="name">
|
||||
<q-item-side>
|
||||
<q-radio v-model="CurrentSelection" :val="name"/>
|
||||
</q-item-side>
|
||||
<q-item-main>
|
||||
<q-item-tile label>{{ name }}</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
<q-item tag="label">
|
||||
<q-item-main>
|
||||
<q-item-tile>
|
||||
<q-btn color="primary" v-show="CurrentSelection != undefined" label="load" @click="onLoadPressed(); visible=false"/>
|
||||
<q-btn color="secondary" v-close-overlay label="close" />
|
||||
</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-modal-layout>
|
||||
</q-modal>
|
||||
`
|
@ -146,10 +146,12 @@ func InitComponentsTriggerActions() {
|
||||
hvue.DataFunc(func(vm *hvue.VM) interface{} {
|
||||
data := struct {
|
||||
*js.Object
|
||||
ShowLoadModal bool `js:"showLoadModal"`
|
||||
ShowReplaceTASModal bool `js:"showReplaceTASModal"`
|
||||
ShowAddTASModal bool `js:"showAddTASModal"`
|
||||
TemplateName string `js:"templateName"`
|
||||
}{Object: O()}
|
||||
data.ShowLoadModal = false
|
||||
data.ShowReplaceTASModal = false
|
||||
data.ShowAddTASModal = false
|
||||
data.TemplateName = ""
|
||||
return &data
|
||||
}),
|
||||
@ -162,6 +164,14 @@ func InitComponentsTriggerActions() {
|
||||
tas := vm.Get("$store").Get("state").Get("triggerActionList")
|
||||
vm.Get("$store").Call("dispatch", VUEX_ACTION_STORE_TRIGGER_ACTION_SET, tas)
|
||||
}),
|
||||
hvue.Method("replaceCurrentTAS",
|
||||
func(vm *hvue.VM, newTASName *js.Object) {
|
||||
vm.Get("$q").Call("notify", "Replacing TAS with '" + newTASName.String() +"'")
|
||||
}),
|
||||
hvue.Method("addToCurrentTAS",
|
||||
func(vm *hvue.VM, newTASName *js.Object) {
|
||||
vm.Get("$q").Call("notify", "Add '" + newTASName.String() +"' to current TAS")
|
||||
}),
|
||||
hvue.Method("updateStoredTriggerActionSetsList",
|
||||
func(vm *hvue.VM) {
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST)
|
||||
@ -695,44 +705,19 @@ const templateAction = `
|
||||
const templateTriggerActionManager = `
|
||||
<q-page padding>
|
||||
|
||||
<q-modal v-model="showLoadModal">
|
||||
<q-modal-layout>
|
||||
<q-toolbar slot="header">
|
||||
<q-toolbar-title>
|
||||
Load TriggerAction Set
|
||||
</q-toolbar-title>
|
||||
</q-toolbar>
|
||||
|
||||
<q-list>
|
||||
<q-item link tag="label" v-for="tname in this.$store.state.StoredTriggerActionSetsList" :key="tname">
|
||||
<q-item-side>
|
||||
<q-radio v-model="templateName" :val="tname"/>
|
||||
</q-item-side>
|
||||
<q-item-main>
|
||||
<q-item-tile label>{{ tname }}</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
<q-item tag="label">
|
||||
<q-item-main>
|
||||
<q-item-tile>
|
||||
<q-btn color="secondary" v-close-overlay label="close" />
|
||||
<q-btn color="primary" label="load" />
|
||||
<q-btn color="primary" label="deploy" />
|
||||
</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-modal-layout>
|
||||
</q-modal>
|
||||
|
||||
<select-string-from-array :values="this.$store.state.StoredTriggerActionSetsList" v-model="showReplaceTASModal" title="Replace current Trigger Actions with stored set" @load="replaceCurrentTAS($event)"></select-string-from-array>
|
||||
<select-string-from-array :values="this.$store.state.StoredTriggerActionSetsList" v-model="showAddTASModal" title="Add stored set to current Trigger Actions" @load="addToCurrentTAS($event)"></select-string-from-array>
|
||||
|
||||
<div class="row gutter-sm">
|
||||
<div class="col-12">
|
||||
<q-card>
|
||||
<q-card-actions>
|
||||
<q-btn label="add" @click="addTA" icon="event" />
|
||||
<q-btn label="store" @click="storeTAS" icon="event" />
|
||||
<q-btn label="load" @click="updateStoredTriggerActionSetsList(); showLoadModal=true" icon="event" />
|
||||
<q-btn label="add single TriggerAction" @click="addTA" icon="note_add" />
|
||||
<q-btn label="store current set" @click="storeTAS" icon="save" />
|
||||
<q-btn label="replace with stored set" @click="updateStoredTriggerActionSetsList(); showReplaceTASModal=true" icon="settings_backup_restore" />
|
||||
<q-btn label="insert stored set" @click="updateStoredTriggerActionSetsList(); showAddTASModal=true" icon="add_to_photos" />
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</div>
|
||||
|
@ -67,6 +67,7 @@ func main() {
|
||||
)
|
||||
|
||||
|
||||
InitComponentsDialog()
|
||||
InitCompHIDJobs()
|
||||
InitCompHIDEvents()
|
||||
InitCompModal()
|
||||
|
@ -225,7 +225,7 @@ func actionUpdateRunningHidJobs(store *mvuex.Store, context *mvuex.ActionContext
|
||||
|
||||
func actionUpdateStoredTriggerActionSetsList(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState) {
|
||||
go func() {
|
||||
println("Trying to fetch wsList")
|
||||
println("Trying to fetch TriggerActionSetList")
|
||||
//fetch deployed gadget settings
|
||||
tasList, err := RpcClient.ListStoredTriggerActionSets(time.Second * 10)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user