mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-03-17 21:31:56 +01:00
WebClient: WifiSettings store&load
This commit is contained in:
parent
8f95503b52
commit
b0b2a26622
@ -1,3 +1,5 @@
|
||||
// +build linux
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
|
@ -162,7 +162,7 @@ const (
|
||||
<div class="col-6 col-sm"><q-btn class="fit" color="secondary" label="store" icon="save" @click="ShowStoreHIDScriptModal=true" /></div>
|
||||
<div class="col-6 col-sm"><q-btn class="fit" color="warning" label="load & replace" icon="settings_backup_restore" @click="updateStoredHIDScriptsList(); ShowLoadHIDScriptModal=true"/></div>
|
||||
<div class="col-6 col-sm"><q-btn class="fit" color="warning" label="load & prepend" icon="add_to_photos" @click="updateStoredHIDScriptsList(); ShowLoadHIDScriptPrependModal=true"/></div>
|
||||
<div class="col-12 col-sm md"><q-btn class="fit" color="negative" label="import DuckyScript" icon="accessible" @click="ShowRansom=true"/></div>
|
||||
<div class="col-12 col-sm lg"><q-btn class="fit" color="negative" label="import DuckyScript" icon="accessible" @click="ShowRansom=true"/></div>
|
||||
</div>
|
||||
</q-card-main>
|
||||
|
||||
|
@ -141,9 +141,9 @@ func InitComponentsWiFi() {
|
||||
vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_WIFI_SETTINGS_LIST)
|
||||
}),
|
||||
hvue.Method("store",
|
||||
func(vm *hvue.VM) {
|
||||
func(vm *hvue.VM, name *js.Object) {
|
||||
sReq := NewWifiRequestSettingsStorage()
|
||||
sReq.TemplateName = vm.Get("templateName").String()
|
||||
sReq.TemplateName = name.String()
|
||||
sReq.Settings = &jsWiFiSettings{
|
||||
Object: vm.Get("$store").Get("state").Get("wifiState").Get("CurrentSettings"),
|
||||
}
|
||||
@ -151,6 +151,11 @@ func InitComponentsWiFi() {
|
||||
vm.Get("$store").Call("dispatch", VUEX_ACTION_STORE_WIFI_SETTINGS, sReq)
|
||||
vm.Set("showStoreModal", false)
|
||||
}),
|
||||
hvue.Method("load",
|
||||
func(vm *hvue.VM, name *js.Object) {
|
||||
println("Loading :", name.String())
|
||||
vm.Get("$store").Call("dispatch", VUEX_ACTION_LOAD_WIFI_SETTINGS, name)
|
||||
}),
|
||||
hvue.Computed("deploying",
|
||||
func(vm *hvue.VM) interface{} {
|
||||
return vm.Get("$store").Get("state").Get("deployingWifiSettings")
|
||||
@ -164,65 +169,10 @@ func InitComponentsWiFi() {
|
||||
|
||||
const templateWiFi = `
|
||||
<q-page padding>
|
||||
|
||||
|
||||
<div class="row gutter-sm">
|
||||
<q-modal v-model="showLoadModal">
|
||||
<q-modal-layout>
|
||||
<q-toolbar slot="header">
|
||||
<q-toolbar-title>
|
||||
Load WiFi settings
|
||||
</q-toolbar-title>
|
||||
</q-toolbar>
|
||||
<select-string-from-array :values="this.$store.state.StoredWifiSettingsList" v-model="showLoadModal" title="Load WiFi settings" @load="load($event)"></select-string-from-array>
|
||||
<modal-string-input v-model="showStoreModal" title="Store current WiFi Settings" @save="store($event)"></modal-string-input>
|
||||
|
||||
<q-list>
|
||||
<q-item link tag="label" v-for="tname in this.$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>
|
||||
<q-modal v-model="showStoreModal">
|
||||
<q-modal-layout>
|
||||
<q-toolbar slot="header">
|
||||
<q-toolbar-title>
|
||||
Store current WiFi Settings
|
||||
</q-toolbar-title>
|
||||
</q-toolbar>
|
||||
<q-list>
|
||||
<q-item tag="label">
|
||||
<q-item-main>
|
||||
<q-item-tile label>Template name</q-item-tile>
|
||||
<q-item-tile>
|
||||
<q-input v-model="templateName" inverted></q-input>
|
||||
</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" @click="store" label="store" />
|
||||
</q-item-tile>
|
||||
</q-item-main>
|
||||
</q-item>
|
||||
</q-list>
|
||||
</q-modal-layout>
|
||||
</q-modal>
|
||||
<div class="col-lg-4">
|
||||
<q-card class="full-height">
|
||||
<q-card-title>
|
||||
|
@ -221,7 +221,7 @@ func InitComponentsNetwork() {
|
||||
const templateNetwork = `
|
||||
<q-page padding>
|
||||
<div class="row gutter-sm">
|
||||
<div class="col-xl-3">
|
||||
<div class="col-12 col-xl-3">
|
||||
<q-card class="full-height">
|
||||
<q-card-title>
|
||||
Network interface settings
|
||||
@ -248,7 +248,7 @@ const templateNetwork = `
|
||||
</q-card>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-9">
|
||||
<div class="col-12 col-xl-9">
|
||||
<dhcp-config :interface="current" v-if="currentWithDhcp"></dhcp-config>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,10 +37,10 @@ const (
|
||||
|
||||
VUEX_ACTION_UPDATE_STORED_WIFI_SETTINGS_LIST = "updateStoredWifiSettingsList"
|
||||
VUEX_ACTION_STORE_WIFI_SETTINGS = "storeWifiSettings"
|
||||
VUEX_ACTION_LOAD_WIFI_SETTINGS = "storeWifiSettings"
|
||||
VUEX_ACTION_LOAD_WIFI_SETTINGS = "loadWifiSettings"
|
||||
|
||||
VUEX_MUTATION_SET_CURRENT_GADGET_SETTINGS_TO = "setCurrentGadgetSettings"
|
||||
VUEX_MUTATION_SET_WIFI_STATE = "setCurrentWifiSettings"
|
||||
VUEX_MUTATION_SET_WIFI_STATE = "setCurrentWifiState"
|
||||
VUEX_MUTATION_SET_CURRENT_HID_SCRIPT_SOURCE_TO = "setCurrentHIDScriptSource"
|
||||
VUEX_MUTATION_SET_STORED_WIFI_SETTINGS_LIST = "setStoredWifiSettingsList"
|
||||
|
||||
@ -51,6 +51,7 @@ const (
|
||||
VUEX_ACTION_STORE_CURRENT_HID_SCRIPT_SOURCE_TO_REMOTE_FILE = "storeCurrentHidScriptSourceToRemoteFile"
|
||||
|
||||
|
||||
VUEX_MUTATION_SET_CURRENT_WIFI_SETTINGS = "setCurrentWifiSettings"
|
||||
VUEX_MUTATION_SET_STORED_BASH_SCRIPTS_LIST = "setStoredBashScriptsList"
|
||||
VUEX_MUTATION_SET_STORED_HID_SCRIPTS_LIST = "setStoredHIDScriptsList"
|
||||
|
||||
@ -275,6 +276,23 @@ func actionStoreWifiSettings(store *mvuex.Store, context *mvuex.ActionContext, s
|
||||
}()
|
||||
}
|
||||
|
||||
func actionLoadWifiSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settingsName *js.Object) {
|
||||
go func() {
|
||||
println("Vuex dispatch load WiFi settings: ", settingsName.String())
|
||||
// convert to Go type
|
||||
settings,err := RpcClient.GetStoredWifiSettings(defaultTimeout, &pb.StringMessage{Msg:settingsName.String()})
|
||||
if err != nil {
|
||||
QuasarNotifyError("Error fetching stored WiFi Settings", err.Error(), QUASAR_NOTIFICATION_POSITION_BOTTOM)
|
||||
}
|
||||
|
||||
jsSettings := NewWifiSettings()
|
||||
jsSettings.fromGo(settings)
|
||||
context.Commit(VUEX_MUTATION_SET_CURRENT_WIFI_SETTINGS, jsSettings)
|
||||
|
||||
QuasarNotifySuccess("New WiFi settings loaded", "", QUASAR_NOTIFICATION_POSITION_TOP)
|
||||
}()
|
||||
}
|
||||
|
||||
func actionDeployWifiSettings(store *mvuex.Store, context *mvuex.ActionContext, state *GlobalState, settings *jsWiFiSettings) {
|
||||
go func() {
|
||||
|
||||
@ -529,6 +547,10 @@ func initMVuex() *mvuex.Store {
|
||||
state.WiFiState = wifiState
|
||||
return
|
||||
}),
|
||||
mvuex.Mutation(VUEX_MUTATION_SET_CURRENT_WIFI_SETTINGS, func(store *mvuex.Store, state *GlobalState, wifiSettings *jsWiFiSettings) {
|
||||
state.WiFiState.CurrentSettings = wifiSettings
|
||||
return
|
||||
}),
|
||||
mvuex.Mutation(VUEX_MUTATION_SET_STORED_WIFI_SETTINGS_LIST, func(store *mvuex.Store, state *GlobalState, wsList []interface{}) {
|
||||
println("New ws list", wsList)
|
||||
hvue.Set(state, "StoredWifiSettingsList", wsList)
|
||||
@ -575,6 +597,7 @@ func initMVuex() *mvuex.Store {
|
||||
mvuex.Action(VUEX_ACTION_UPDATE_STORED_HID_SCRIPTS_LIST, actionUpdateStoredHIDScriptsList),
|
||||
mvuex.Action(VUEX_ACTION_UPDATE_CURRENT_HID_SCRIPT_SOURCE_FROM_REMOTE_FILE, actionUpdateCurrentHidScriptSourceFromRemoteFile),
|
||||
mvuex.Action(VUEX_ACTION_STORE_CURRENT_HID_SCRIPT_SOURCE_TO_REMOTE_FILE, actionStoreCurrentHidScriptSourceToRemoteFile),
|
||||
mvuex.Action(VUEX_ACTION_LOAD_WIFI_SETTINGS, actionLoadWifiSettings),
|
||||
|
||||
|
||||
mvuex.Getter("triggerActions", func(state *GlobalState) interface{} {
|
||||
|
@ -131,6 +131,15 @@ func (rpc *Rpc) StoreWifiSettings(timeout time.Duration, req *pb.WifiRequestSett
|
||||
return
|
||||
}
|
||||
|
||||
func (rpc *Rpc) GetStoredWifiSettings(timeout time.Duration, req *pb.StringMessage) (settings *pb.WiFiSettings, err error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
settings, err = rpc.Client.GetStoredWifiSettings(ctx, req)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
func (rpc *Rpc) GetWifiState(timeout time.Duration) (state *jsWiFiState, err error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
|
Loading…
x
Reference in New Issue
Block a user