From 24141d5548913f720e2eb91675922a9882d7e371 Mon Sep 17 00:00:00 2001 From: MaMe82 <mame8282@googlemail.com> Date: Sun, 14 Oct 2018 20:17:34 +0200 Subject: [PATCH] WebClient: Fix viewmodel update of ethernet interface settings on change --- web_client/hvueComponentsNetwork.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/web_client/hvueComponentsNetwork.go b/web_client/hvueComponentsNetwork.go index 320b6d4..1eb387a 100644 --- a/web_client/hvueComponentsNetwork.go +++ b/web_client/hvueComponentsNetwork.go @@ -33,12 +33,12 @@ func InitComponentsNetwork() { hvue.DataFunc(func(vm *hvue.VM) interface{} { data := &struct { *js.Object - CurrentInterface *jsEthernetInterfaceSettings `js:"current"` + CurrentInterface int `js:"currentIdx"` ShowStoreModal bool `js:"showStoreModal"` ShowLoadModal bool `js:"showLoadModal"` ShowDeployStoredModal bool `js:"showDeployStoredModal"` }{Object: O()} - data.CurrentInterface = &jsEthernetInterfaceSettings{Object: O()} + data.CurrentInterface = 0 data.ShowStoreModal = false data.ShowLoadModal = false data.ShowDeployStoredModal = false @@ -56,17 +56,22 @@ func InitComponentsNetwork() { option := struct { *js.Object Label string `js:"label"` - Value *jsEthernetInterfaceSettings `js:"value"` + Value int `js:"value"` }{Object: O()} currentIf := &jsEthernetInterfaceSettings{ Object: interfaces.Index(i), } option.Label = currentIf.Name - option.Value = currentIf + option.Value = i selectIf.Call("push", option) } return selectIf }), + 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) + }), hvue.Computed("currentWithDhcp", func(vm *hvue.VM) interface{} { if mode := vm.Get("current").Get("mode").Int(); mode == pb.EthernetInterfaceSettings_Mode_value["DHCP_SERVER"] { return true @@ -294,7 +299,7 @@ const templateNetwork = ` <q-item-tile label>Interface</q-item-tile> <q-item-tile sublabel>Select which interface to configure</q-item-tile> <q-item-tile> - <q-select v-model="current" :options="selectOptionsInterface" color="secondary" inverted></q-select> + <q-select v-model="currentIdx" :options="selectOptionsInterface" color="secondary" inverted></q-select> </q-item-tile> </q-item-main> </q-item>