diff --git a/web_client/hvueCompUSBSettings.go b/web_client/hvueCompUSBSettings.go index c9afbdc..faa0542 100644 --- a/web_client/hvueCompUSBSettings.go +++ b/web_client/hvueCompUSBSettings.go @@ -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 = ` - - + + diff --git a/web_client/hvueComponentWiFi.go b/web_client/hvueComponentWiFi.go index 02b7a0e..c0a4bbb 100644 --- a/web_client/hvueComponentWiFi.go +++ b/web_client/hvueComponentWiFi.go @@ -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 = ` - - + +
diff --git a/web_client/hvueComponentsDialog.go b/web_client/hvueComponentsDialog.go index 9e784a5..4a7278a 100644 --- a/web_client/hvueComponentsDialog.go +++ b/web_client/hvueComponentsDialog.go @@ -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 = ` {{ name }} + + + diff --git a/web_client/hvueComponentsNetwork.go b/web_client/hvueComponentsNetwork.go index 6e8404f..0a2a361 100644 --- a/web_client/hvueComponentsNetwork.go +++ b/web_client/hvueComponentsNetwork.go @@ -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 = ` - - + +
diff --git a/web_client/hvueComponentsTriggerActions.go b/web_client/hvueComponentsTriggerActions.go index 8aaf782..d3fba97 100644 --- a/web_client/hvueComponentsTriggerActions.go +++ b/web_client/hvueComponentsTriggerActions.go @@ -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 = ` - - + +
diff --git a/web_client/mvuexGlobalState.go b/web_client/mvuexGlobalState.go index 1994ac1..c385b10 100644 --- a/web_client/mvuexGlobalState.go +++ b/web_client/mvuexGlobalState.go @@ -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{} { diff --git a/web_client/rpcClient.go b/web_client/rpcClient.go index 9f36ff0..09df095 100644 --- a/web_client/rpcClient.go +++ b/web_client/rpcClient.go @@ -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")