mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-17 21:31:56 +01:00
WebClient: load,store and store&deploy for ethernet settings working
This commit is contained in:
parent
24141d5548
commit
e286711234
@ -70,7 +70,11 @@ func InitComponentsNetwork() {
|
||||
hvue.Computed("current", func(vm *hvue.VM) interface{} {
|
||||
interfaces := vm.Get("$store").Get("state").Get("InterfaceSettings").Get("interfaces")
|
||||
idx := vm.Get("currentIdx").Int()
|
||||
return interfaces.Index(idx)
|
||||
currentIface := interfaces.Index(idx)
|
||||
if currentIface == js.Undefined {
|
||||
return &jsEthernetInterfaceSettings{Object:O()}
|
||||
}
|
||||
return currentIface
|
||||
}),
|
||||
hvue.Computed("currentWithDhcp", func(vm *hvue.VM) interface{} {
|
||||
if mode := vm.Get("current").Get("mode").Int(); mode == pb.EthernetInterfaceSettings_Mode_value["DHCP_SERVER"] {
|
||||
@ -109,12 +113,14 @@ func InitComponentsNetwork() {
|
||||
vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_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) {
|
||||
// update network interface
|
||||
promise := vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_ALL_ETHERNET_INTERFACE_SETTINGS)
|
||||
|
||||
promise.Call("then",
|
||||
func() {
|
||||
/*
|
||||
println("Mounting network interface settings, try to select first interface")
|
||||
// current" could be an empty settings object, set to first interface of computed property "interfaces" (if there is one)
|
||||
interfaces := vm.Get("$store").Get("state").Get("InterfaceSettings").Get("interfaces")
|
||||
@ -124,6 +130,8 @@ func InitComponentsNetwork() {
|
||||
} else {
|
||||
println("... No interface found")
|
||||
}
|
||||
*/
|
||||
hvue.Set(vm, "currentIdx", 0)
|
||||
},
|
||||
func() {
|
||||
println("error in THEN ")
|
||||
@ -131,6 +139,7 @@ func InitComponentsNetwork() {
|
||||
)
|
||||
|
||||
}),
|
||||
|
||||
)
|
||||
|
||||
hvue.NewComponent(
|
||||
|
@ -3,12 +3,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
"errors"
|
||||
"github.com/gopherjs/gopherjs/js"
|
||||
"github.com/mame82/P4wnP1_go/common_web"
|
||||
"strconv"
|
||||
pb "github.com/mame82/P4wnP1_go/proto/gopherjs"
|
||||
"github.com/mame82/hvue"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
var eNoLogEvent = errors.New("No log event")
|
||||
@ -630,7 +630,8 @@ func (isl *jsEthernetSettingsList) updateSingleInterface(updatedSettings *jsEthe
|
||||
settings := &jsEthernetInterfaceSettings{Object:isl.Interfaces.Index(i)}
|
||||
if settings.Name == updatedSettings.Name {
|
||||
// this are the settings to update (== replace)
|
||||
isl.Interfaces.SetIndex(i, updatedSettings)
|
||||
//isl.Interfaces.SetIndex(i, updatedSettings.Object)
|
||||
hvue.Set(isl.Interfaces,i, updatedSettings)
|
||||
return // we are done
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user