Allow deleting templates from load dialogs

This commit is contained in:
MaMe82 2018-10-24 20:01:53 +02:00
parent 9d476f77ab
commit cdb6402287
7 changed files with 144 additions and 12 deletions

View File

@ -65,6 +65,11 @@ func InitCompUSBSettings() {
println("Loading :", name.String())
vm.Get("$store").Call("dispatch", VUEX_ACTION_LOAD_USB_SETTINGS, name)
}),
hvue.Method("deleteStored",
func(vm *hvue.VM, name *js.Object) {
println("Loading :", name.String())
vm.Get("$store").Call("dispatch", VUEX_ACTION_DELETE_STORED_USB_SETTINGS, name)
}),
hvue.Method("deployStored",
func(vm *hvue.VM, name *js.Object) {
println("Loading :", name.String())
@ -101,8 +106,8 @@ func newCompUSBSettingsData(vm *hvue.VM) interface{} {
const (
compUSBSettingsTemplate = `
<q-page padding>
<select-string-from-array :values="$store.state.StoredUSBSettingsList" v-model="showLoadModal" title="Load USB gadget settings" @load="load($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredUSBSettingsList" v-model="showDeployStoredModal" title="Deploy stored USB gadget settings" @load="deployStored($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredUSBSettingsList" v-model="showLoadModal" title="Load USB gadget settings" @load="load($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<select-string-from-array :values="$store.state.StoredUSBSettingsList" v-model="showDeployStoredModal" title="Deploy stored USB gadget settings" @load="deployStored($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<modal-string-input v-model="showStoreModal" title="Store current USB gadget Settings" @save="store($event)"></modal-string-input>

View File

@ -163,6 +163,11 @@ func InitComponentsWiFi() {
println("Loading :", name.String())
vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_STORED_WIFI_SETTINGS, name)
}),
hvue.Method("deleteStored",
func(vm *hvue.VM, name *js.Object) {
println("Loading :", name.String())
vm.Get("$store").Call("dispatch", VUEX_ACTION_DELETE_STORED_WIFI_SETTINGS, name)
}),
hvue.Computed("deploying",
func(vm *hvue.VM) interface{} {
return vm.Get("$store").Get("state").Get("deployingWifiSettings")
@ -178,8 +183,8 @@ func InitComponentsWiFi() {
const templateWiFi = `
<q-page padding>
<select-string-from-array :values="$store.state.StoredWifiSettingsList" v-model="showLoadModal" title="Load WiFi settings" @load="load($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredWifiSettingsList" v-model="showDeployStoredModal" title="Deploy stored WiFi settings" @load="deployStored($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredWifiSettingsList" v-model="showLoadModal" title="Load WiFi settings" @load="load($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<select-string-from-array :values="$store.state.StoredWifiSettingsList" v-model="showDeployStoredModal" title="Deploy stored WiFi settings" @load="deployStored($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<modal-string-input v-model="showStoreModal" title="Store current WiFi Settings" @save="store($event)"></modal-string-input>
<div class="row gutter-sm">

View File

@ -1,3 +1,5 @@
// +build js
package main
import (
@ -35,10 +37,16 @@ func InitComponentsDialog() {
"onLoadPressed",
func(vm *hvue.VM) {
vm.Call("$emit", "load", vm.Get("CurrentSelection"))
println(vm.Get("CurrentSelection"))
//println(vm.Get("CurrentSelection"))
},
),
hvue.Method(
"onDeletePressed",
func(vm *hvue.VM, name *js.Object) {
vm.Call("$emit", "delete", name)
},
),
hvue.PropObj(
"values",
hvue.Required,
@ -48,6 +56,11 @@ func InitComponentsDialog() {
hvue.Required,
hvue.Types(hvue.PBoolean),
),
hvue.PropObj(
"with-delete",
hvue.Types(hvue.PBoolean),
hvue.Default(false),
),
hvue.PropObj(
"title",
hvue.Types(hvue.PString),
@ -135,6 +148,9 @@ const templateSelectStringModal = `
<q-item-main>
<q-item-tile label>{{ name }}</q-item-tile>
</q-item-main>
<q-item-side v-if="withDelete" right>
<q-btn icon="delete" color="negative" @click="onDeletePressed(name)" round flat />
</q-item-side>
</q-item>
<q-item tag="label">
<q-item-main>

View File

@ -112,6 +112,11 @@ func InitComponentsNetwork() {
println("Loading :", name.String())
vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_STORED_ETHERNET_INTERFACE_SETTINGS, name)
}),
hvue.Method("deleteStored",
func(vm *hvue.VM, name *js.Object) {
println("Deleting template :", name.String())
vm.Get("$store").Call("dispatch", VUEX_ACTION_DELETE_STORED_ETHERNET_INTERFACE_SETTINGS, name)
}),
// The following method doesn't make much sense anymore, but is kept as an example for working with promises
hvue.Mounted(func(vm *hvue.VM) {
@ -283,8 +288,8 @@ func InitComponentsNetwork() {
const templateNetwork = `
<q-page padding>
<select-string-from-array :values="$store.state.StoredEthernetInterfaceSettingsList" v-model="showLoadModal" title="Load ethernet interface settings" @load="load($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredEthernetInterfaceSettingsList" v-model="showDeployStoredModal" title="Deploy stored ethernet interface settings" @load="deployStored($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredEthernetInterfaceSettingsList" v-model="showLoadModal" title="Load ethernet interface settings" @load="load($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<select-string-from-array :values="$store.state.StoredEthernetInterfaceSettingsList" v-model="showDeployStoredModal" title="Deploy stored ethernet interface settings" @load="deployStored($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<modal-string-input v-model="showStoreModal" title="Store current ethernet interface Settings" @save="store($event)"></modal-string-input>
<div class="row gutter-sm">

View File

@ -188,6 +188,11 @@ func InitComponentsTriggerActions() {
//vm.Get("$q").Call("notify", "Add '" + storedTASName.String() +"' to current TAS")
vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_ADD, storedTASName)
}),
hvue.Method("deleteStored",
func(vm *hvue.VM, storedTASName *js.Object) {
//vm.Get("$q").Call("notify", "Add '" + storedTASName.String() +"' to current TAS")
vm.Get("$store").Call("dispatch", VUEX_ACTION_DELETE_STORED_TRIGGER_ACTION_SET, storedTASName)
}),
hvue.Method("updateStoredTriggerActionSetsList",
func(vm *hvue.VM) {
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST)
@ -832,8 +837,8 @@ const templateAction = `
const templateTriggerActionManager = `
<q-page padding>
<modal-string-input v-model="showStoreTASModal" title="Store selected TriggerActions" @save="storeTAS($event)"></modal-string-input>
<select-string-from-array :values="$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="$store.state.StoredTriggerActionSetsList" v-model="showAddTASModal" title="Add stored set to current Trigger Actions" @load="addToCurrentTAS($event)"></select-string-from-array>
<select-string-from-array :values="$store.state.StoredTriggerActionSetsList" v-model="showReplaceTASModal" title="Replace current Trigger Actions with stored set" @load="replaceCurrentTAS($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<select-string-from-array :values="$store.state.StoredTriggerActionSetsList" v-model="showAddTASModal" title="Add stored set to current Trigger Actions" @load="addToCurrentTAS($event)" @delete="deleteStored($event)" with-delete></select-string-from-array>
<div class="row gutter-sm">
<div class="col-12">

View File

@ -43,6 +43,7 @@ const (
VUEX_ACTION_LOAD_USB_SETTINGS = "loadUSBSettings"
VUEX_ACTION_DEPLOY_STORED_USB_SETTINGS = "deployStoredUSBSettings"
VUEX_ACTION_UPDATE_STORED_USB_SETTINGS_LIST = "updateStoredUSBSettingsList"
VUEX_ACTION_DELETE_STORED_USB_SETTINGS = "deleteStoredUSBSettings"
VUEX_MUTATION_SET_CURRENT_USB_SETTINGS = "setCurrentUSBSettings"
VUEX_MUTATION_SET_STORED_USB_SETTINGS_LIST = "setStoredUSBSettingsList"
@ -54,6 +55,7 @@ const (
VUEX_ACTION_LOAD_ETHERNET_INTERFACE_SETTINGS = "loadEthernetInterfaceSettings"
VUEX_ACTION_DEPLOY_STORED_ETHERNET_INTERFACE_SETTINGS = "deployStoredEthernetInterfaceSettings"
VUEX_ACTION_UPDATE_STORED_ETHERNET_INTERFACE_SETTINGS_LIST = "updateStoredEthernetInterfaceSettingsList"
VUEX_ACTION_DELETE_STORED_ETHERNET_INTERFACE_SETTINGS = "deleteStoredEthernetInterfaceSettings"
VUEX_MUTATION_SET_STORED_ETHERNET_INTERFACE_SETTINGS_LIST = "setStoredEthernetInterfaceSettingsList"
VUEX_MUTATION_SET_ALL_ETHERNET_INTERFACE_SETTINGS = "setAllEthernetInterfaceSettings"
@ -66,6 +68,7 @@ const (
VUEX_ACTION_STORE_WIFI_SETTINGS = "storeWifiSettings"
VUEX_ACTION_LOAD_WIFI_SETTINGS = "loadWifiSettings"
VUEX_ACTION_DEPLOY_STORED_WIFI_SETTINGS = "deployStoredWifiSettings"
VUEX_ACTION_DELETE_STORED_WIFI_SETTINGS = "deleteStoredWifiSettings"
VUEX_MUTATION_SET_WIFI_STATE = "setCurrentWifiState"
VUEX_MUTATION_SET_STORED_WIFI_SETTINGS_LIST = "setStoredWifiSettingsList"
@ -79,6 +82,7 @@ const (
VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST = "updateStoredTriggerActionSetsList"
VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_REPLACE = "deployStoredTriggerActionSetReplace"
VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_ADD = "deployStoredTriggerActionSetAdd"
VUEX_ACTION_DELETE_STORED_TRIGGER_ACTION_SET = "deleteStoredTriggerActionSet"
VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_REPLACE = "deployCurrentTriggerActionSetReplace"
VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_ADD = "deployCurrentTriggerActionSetAdd"
@ -155,6 +159,66 @@ func createGlobalStateStruct() GlobalState {
return state
}
func actionDeleteStoredUSBSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settingsName *js.Object) {
go func() {
println("Vuex dispatch delete USB settings: ", settingsName.String())
// convert to Go type
err := RpcClient.DeleteStoredUSBSettings(defaultTimeout, &pb.StringMessage{Msg: settingsName.String()})
if err != nil {
QuasarNotifyError("Error deleting stored USB Settings", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
}
QuasarNotifySuccess("USB settings deleted", "", QUASAR_NOTIFICATION_POSITION_TOP)
actionUpdateStoredUSBSettingsList(store,context,state)
}()
}
func actionDeleteStoredTriggerActionSet(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, jsName *js.Object) {
go func() {
name := jsName.String()
println("Vuex delete stored TriggerActionSet: ", name)
// convert to Go type
msg := &pb.StringMessage{Msg: name}
err := RpcClient.DeleteStoredTriggerActionsSet(defaultTimeout, msg)
if err != nil {
QuasarNotifyError("Error deleting TriggerActionSet from store", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
return
}
QuasarNotifySuccess("Deleted TriggerActionSet from store", name, QUASAR_NOTIFICATION_POSITION_TOP)
actionUpdateStoredTriggerActionSetsList(store, context, state)
}()
}
func actionDeleteStoredWifiSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settingsName *js.Object) {
go func() {
println("Vuex dispatch delete WiFi settings: ", settingsName.String())
// convert to Go type
err := RpcClient.DeleteStoredWifiSettings(defaultTimeout, &pb.StringMessage{Msg: settingsName.String()})
if err != nil {
QuasarNotifyError("Error deleting stored WiFi Settings", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
}
QuasarNotifySuccess("Stored WiFi settings deleted", "", QUASAR_NOTIFICATION_POSITION_TOP)
actionUpdateStoredWifiSettingsList(store,context,state)
}()
}
func actionDeleteStoredEthernetInterfaceSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settingsName *js.Object) {
go func() {
println("Vuex dispatch delete stored ethernet interface settings: ", settingsName.String())
// convert to Go type
err := RpcClient.DeleteStoredEthernetInterfaceSettings(defaultTimeoutMid, &pb.StringMessage{Msg: settingsName.String()})
if err != nil {
QuasarNotifyError("Error deleting stored ethernet interface Settings", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
}
QuasarNotifySuccess("Stored ethernet interface settings deleted", "", QUASAR_NOTIFICATION_POSITION_TOP)
//we update all modelview settings of vuex, to reflect the changes
actionUpdateStoredEthernetInterfaceSettingsList(store, context, state)
}()
}
func actionUpdateCurrentBluetoothControllerInformation(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState) {
go func() {
println("Trying to fetch bluetooth controller information")
@ -339,7 +403,7 @@ func actionLoadEthernetInterfaceSettings(store *mvuex.Store, context *mvuex.Acti
func actionDeployStoredEthernetInterfaceSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settingsName *js.Object) {
go func() {
println("Vuex dispatch load ethernet interface settings: ", settingsName.String())
println("Vuex dispatch deploy stored ethernet interface settings: ", settingsName.String())
// convert to Go type
err := RpcClient.DeployStoredEthernetInterfaceSettings(defaultTimeoutMid, &pb.StringMessage{Msg: settingsName.String()})
if err != nil {
@ -541,7 +605,7 @@ func actionLoadWifiSettings(store *mvuex.Store, context *mvuex.ActionContext, st
func actionDeployStoredWifiSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settingsName *js.Object) {
go func() {
println("Vuex dispatch load WiFi settings: ", settingsName.String())
println("Vuex dispatch deploy stored WiFi settings: ", settingsName.String())
// convert to Go type
wstate, err := RpcClient.DeployStoredWifiSettings(defaultTimeoutMid, &pb.StringMessage{Msg: settingsName.String()})
if err != nil {
@ -865,6 +929,7 @@ func initMVuex() *mvuex.Store {
mvuex.Action(VUEX_ACTION_STORE_USB_SETTINGS, actionStoreUSBSettings),
mvuex.Action(VUEX_ACTION_LOAD_USB_SETTINGS, actionLoadUSBSettings),
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_USB_SETTINGS, actionDeployStoredUSBSettings),
mvuex.Action(VUEX_ACTION_DELETE_STORED_USB_SETTINGS, actionDeleteStoredUSBSettings),
mvuex.Action(VUEX_ACTION_UPDATE_STORED_USB_SETTINGS_LIST, actionUpdateStoredUSBSettingsList),
mvuex.Action(VUEX_ACTION_DEPLOY_ETHERNET_INTERFACE_SETTINGS, actionDeployEthernetInterfaceSettings),
@ -881,6 +946,7 @@ func initMVuex() *mvuex.Store {
mvuex.Action(VUEX_ACTION_UPDATE_STORED_TRIGGER_ACTION_SETS_LIST, actionUpdateStoredTriggerActionSetsList),
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_REPLACE, actionDeployStoredTriggerActionSetReplace),
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_TRIGGER_ACTION_SET_ADD, actionDeployStoredTriggerActionSetAdd),
mvuex.Action(VUEX_ACTION_DELETE_STORED_TRIGGER_ACTION_SET, actionDeleteStoredTriggerActionSet),
mvuex.Action(VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_REPLACE, actionDeployTriggerActionSetReplace),
mvuex.Action(VUEX_ACTION_DEPLOY_TRIGGER_ACTION_SET_ADD, actionDeployTriggerActionSetAdd),
@ -893,10 +959,12 @@ func initMVuex() *mvuex.Store {
mvuex.Action(VUEX_ACTION_STORE_WIFI_SETTINGS, actionStoreWifiSettings),
mvuex.Action(VUEX_ACTION_LOAD_WIFI_SETTINGS, actionLoadWifiSettings),
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_WIFI_SETTINGS, actionDeployStoredWifiSettings),
mvuex.Action(VUEX_ACTION_DELETE_STORED_WIFI_SETTINGS, actionDeleteStoredWifiSettings),
mvuex.Action(VUEX_ACTION_STORE_ETHERNET_INTERFACE_SETTINGS, actionStoreEthernetInterfaceSettings),
mvuex.Action(VUEX_ACTION_LOAD_ETHERNET_INTERFACE_SETTINGS, actionLoadEthernetInterfaceSettings),
mvuex.Action(VUEX_ACTION_DEPLOY_STORED_ETHERNET_INTERFACE_SETTINGS, actionDeployStoredEthernetInterfaceSettings),
mvuex.Action(VUEX_ACTION_DELETE_STORED_ETHERNET_INTERFACE_SETTINGS, actionDeleteStoredEthernetInterfaceSettings),
mvuex.Getter("triggerActions", func(state *GlobalState) interface{} {

View File

@ -30,6 +30,35 @@ func NewRpcClient(addr string) Rpc {
return rcl
}
func (rpc *Rpc) DeleteStoredUSBSettings(timeout time.Duration, req *pb.StringMessage) (err error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
_, err = rpc.Client.DeleteStoredUSBSettings(ctx, req)
return
}
func (rpc *Rpc) DeleteStoredWifiSettings(timeout time.Duration, req *pb.StringMessage) (err error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
_, err = rpc.Client.DeleteStoredWifiSettings(ctx, req)
return
}
func (rpc *Rpc) DeleteStoredEthernetInterfaceSettings(timeout time.Duration, req *pb.StringMessage) (err error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
_,err = rpc.Client.DeleteStoredEthernetInterfaceSettings(ctx, req)
return
}
func (rpc *Rpc) DeleteStoredTriggerActionsSet(timeout time.Duration, name *pb.StringMessage) (err error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
_,err = rpc.Client.DeleteStoredTriggerActionSet(ctx, name)
return
}
func (rpc *Rpc) GetBluetoothAgentSettings(timeout time.Duration) (res *jsBluetoothAgentSettings, err error) {
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
@ -317,7 +346,6 @@ func (rpc *Rpc) DeployStoredEthernetInterfaceSettings(timeout time.Duration, req
return
}
func (rpc *Rpc) GetRunningHidJobStates(timeout time.Duration) (states []*pb.HIDRunningJobStateResult, err error) {
println("GetRunningHidJobStates called")