mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-17 21:31:56 +01:00
Webclient: TriggerAction 'DeployTemplate' shows proper modals for stored template selection
This commit is contained in:
parent
be227cbd67
commit
91b422968a
@ -1,74 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
"github.com/mame82/hvue"
|
||||
)
|
||||
|
||||
|
||||
type modalLoadBashScriptData struct {
|
||||
*js.Object
|
||||
IsVisible bool `js:"isVisible"`
|
||||
}
|
||||
|
||||
func InitCompsLoadModals() {
|
||||
hvue.NewComponent(
|
||||
"modalLoadBashScript",
|
||||
hvue.Template(templateLoadBashScript),
|
||||
hvue.DataFunc(func(vm *hvue.VM) interface{} {
|
||||
data := &modalLoadBashScriptData{Object:O()}
|
||||
data.IsVisible = false
|
||||
|
||||
return data
|
||||
}),
|
||||
hvue.PropObj(
|
||||
"show",
|
||||
hvue.Types(hvue.PBoolean),
|
||||
),
|
||||
hvue.Method("setVisible",
|
||||
func(vm *hvue.VM, visible bool) {
|
||||
data := &modalLoadBashScriptData{Object:vm.Data}
|
||||
data.IsVisible = visible
|
||||
},
|
||||
),
|
||||
hvue.Mounted(func(vm *hvue.VM) {
|
||||
data := &modalLoadBashScriptData{Object:vm.Data}
|
||||
data.IsVisible = vm.Get("show").Bool()
|
||||
// ToDo: update BashScriptList via vuex store action
|
||||
return
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
const templateLoadBashScript = `
|
||||
<q-modal v-model="isVisible">
|
||||
<q-modal-layout>
|
||||
<q-toolbar slot="header">
|
||||
<q-toolbar-title>
|
||||
Load WiFi settings
|
||||
</q-toolbar-title>
|
||||
</q-toolbar>
|
||||
|
||||
<q-list>
|
||||
<q-item link tag="label" v-for="tname in $store.state.StoredWifiSettingsList" :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>
|
||||
|
||||
`
|
@ -442,9 +442,11 @@ func InitComponentsTriggerActions() {
|
||||
*js.Object
|
||||
ShowSelectHIDScriptModal bool `js:"ShowSelectHIDScriptModal"`
|
||||
ShowSelectBashScriptModal bool `js:"ShowSelectBashScriptModal"`
|
||||
ShowSelectTemplateModal bool `js:"ShowSelectTemplateModal"`
|
||||
}{Object: O()}
|
||||
data.ShowSelectHIDScriptModal = false
|
||||
data.ShowSelectBashScriptModal = false
|
||||
data.ShowSelectTemplateModal = false
|
||||
return &data
|
||||
}),
|
||||
hvue.Method("updateStoredHIDScriptsList",
|
||||
@ -455,6 +457,64 @@ func InitComponentsTriggerActions() {
|
||||
func(vm *hvue.VM) {
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_BASH_SCRIPTS_LIST)
|
||||
}),
|
||||
hvue.Computed(
|
||||
"typedTemplateList",
|
||||
func(vm *hvue.VM) interface{} {
|
||||
// template type: ta.ActionData.Type
|
||||
ta:=&jsTriggerAction{Object: vm.Get("ta")}
|
||||
if !ta.IsActionDeploySettingsTemplate() {
|
||||
return []string{}
|
||||
}
|
||||
aData := &jsActionDeploySettingsTemplate{Object: ta.ActionData}
|
||||
switch aData.Type {
|
||||
case TemplateTypeFullSettings:
|
||||
//ToDo: Implement
|
||||
case TemplateTypeBluetooth:
|
||||
//ToDo: Implement
|
||||
case TemplateTypeUSB:
|
||||
//return USB list
|
||||
return vm.Store.Get("state").Get("StoredUSBSettingsList")
|
||||
case TemplateTypeTriggerActions:
|
||||
//return TriggerAction list
|
||||
return vm.Store.Get("state").Get("StoredTriggerActionSetsList")
|
||||
case TemplateTypeWifi:
|
||||
//return WiFi settings list
|
||||
return vm.Store.Get("state").Get("StoredWifiSettingsList")
|
||||
case TemplateTypeNetwork:
|
||||
//return ethernet interface settings list
|
||||
return vm.Store.Get("state").Get("StoredEthernetInterfaceSettingsList")
|
||||
}
|
||||
return []string{} //empty list
|
||||
}),
|
||||
hvue.Method(
|
||||
"actionTemplateTypeUpdate",
|
||||
func(vm *hvue.VM) interface{} {
|
||||
// template type: ta.ActionData.Type
|
||||
ta:=&jsTriggerAction{Object: vm.Get("ta")}
|
||||
if !ta.IsActionDeploySettingsTemplate() {
|
||||
return []string{}
|
||||
}
|
||||
aData := &jsActionDeploySettingsTemplate{Object: ta.ActionData}
|
||||
switch aData.Type {
|
||||
case TemplateTypeFullSettings:
|
||||
//ToDo: Implement
|
||||
case TemplateTypeBluetooth:
|
||||
//ToDo: Implement
|
||||
case TemplateTypeUSB:
|
||||
//update USB list
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_USB_SETTINGS_LIST)
|
||||
case TemplateTypeTriggerActions:
|
||||
//update TriggerAction list
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST)
|
||||
case TemplateTypeWifi:
|
||||
//update WiFi settings template list
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_WIFI_SETTINGS_LIST)
|
||||
case TemplateTypeNetwork:
|
||||
//update ethernet interface settings template list
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_ETHERNET_INTERFACE_SETTINGS_LIST)
|
||||
}
|
||||
return []string{} //empty list
|
||||
}),
|
||||
hvue.Computed("actiontypes", func(vm *hvue.VM) interface{} {
|
||||
return generateSelectOptionsAction()
|
||||
}),
|
||||
@ -747,17 +807,18 @@ const templateAction = `
|
||||
<q-item-tile label>Type</q-item-tile>
|
||||
<q-item-tile sublabel>Name of the stored settings template to load</q-item-tile>
|
||||
<q-item-tile>
|
||||
<q-select v-model="ta.ActionData.Type" :options="templatetypes" color="secondary" inverted :disable="!ta.IsActive"></q-select>
|
||||
<q-select v-model="ta.ActionData.Type" :options="templatetypes" color="secondary" @input="ta.ActionData.TemplateName=''" inverted :disable="!ta.IsActive"></q-select>
|
||||
</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
|
||||
<q-item tag="label" v-if="isActionDeploySettingsTemplate">
|
||||
<select-string-from-array :values="typedTemplateList" v-model="ShowSelectTemplateModal" title="Select template" @load="ta.ActionData.TemplateName=$event"></select-string-from-array>
|
||||
<q-item-main>
|
||||
<q-item-tile label>Template name</q-item-tile>
|
||||
<q-item-tile sublabel>Name of the stored settings template to load</q-item-tile>
|
||||
<q-item-tile>
|
||||
<q-input v-model="ta.ActionData.TemplateName" color="secondary" inverted :disable="!ta.IsActive"></q-input>
|
||||
<q-input @click="actionTemplateTypeUpdate(); ShowSelectTemplateModal=true" v-model="ta.ActionData.TemplateName" color="secondary" inverted readonly :after="[{icon: 'more_horiz', handler(){}}]" :disable="!ta.IsActive"></q-input>
|
||||
</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
|
@ -80,7 +80,6 @@ func main() {
|
||||
InitComponentsNetwork()
|
||||
InitComponentsWiFi()
|
||||
InitComponentsTriggerActions()
|
||||
InitCompsLoadModals()
|
||||
vm := hvue.NewVM(
|
||||
hvue.El("#app"),
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user