From 6d51820f7632c4a55bb0e7647a17b29e4219b0ee Mon Sep 17 00:00:00 2001 From: MaMe82 Date: Wed, 5 Sep 2018 17:39:57 +0200 Subject: [PATCH] Webclient: Reworked most components, intergrated vuex getters --- dist/www/index.html | 4 +- web_client/hvueCompHIDEvents.go | 72 ++++++ web_client/hvueCompHIDJobs.go | 64 +---- web_client/hvueCompHIDScript.go | 26 +- web_client/hvueCompUSBSettings.go | 362 ++++++++++++++-------------- web_client/hvueComponentWiFi.go | 39 ++- web_client/hvueComponentsNetwork.go | 54 +++-- web_client/main.go | 1 + web_client/mvuexGlobalState.go | 67 ++--- 9 files changed, 372 insertions(+), 317 deletions(-) create mode 100644 web_client/hvueCompHIDEvents.go diff --git a/dist/www/index.html b/dist/www/index.html index c102f82..cca9f31 100644 --- a/dist/www/index.html +++ b/dist/www/index.html @@ -48,8 +48,8 @@ - - + + diff --git a/web_client/hvueCompHIDEvents.go b/web_client/hvueCompHIDEvents.go new file mode 100644 index 0000000..e2f2b71 --- /dev/null +++ b/web_client/hvueCompHIDEvents.go @@ -0,0 +1,72 @@ +// +build js + +package main + +import ( + "github.com/HuckRidgeSW/hvue" + "github.com/mame82/P4wnP1_go/common_web" + "github.com/gopherjs/gopherjs/js" +) + +type CompHIDEventsData struct { + *js.Object + Pagination *jsDataTablePagination `js:"pagination"` +} + +func newCompHIDEventsData(vm *hvue.VM) interface{} { + data := &CompHIDEventsData{ Object: O() } + data.Pagination = newPagination(0, 1) + return data +} + +func InitCompHIDEvents() { + + hvue.NewComponent( + "hid-job-event-overview", + hvue.Template(compHIDJobEventOverviewTemplate), + hvue.DataFunc(newCompHIDEventsData), + hvue.Computed("events", + func(vm *hvue.VM) interface{} { + return vm.Get("$store").Get("state").Get("eventReceiver").Get("eventHidArray") + }), + hvue.Method("evIdToString", func(vm *hvue.VM, evID int64) (res string) { + println("EvID", evID) + return common_web.EventType_name[evID] + }), + ) + +} + +const ( + //{ "evtype": 0, "vmId": 2, "jobId": 3, "hasError": false, "result": "null", "error": "", "message": "Script started", "time": "2018-07-30 04:56:42.297533 +0000 UTC m=+7625.097825001" } + compHIDJobEventOverviewTemplate = ` + + +
+ + + + {{ evIdToString(props.value) }} + + + {{ props.value.slice(0,30) }} + + + +
+
{{ props.value }}
+
+
+
+
+
+
+
+` +) diff --git a/web_client/hvueCompHIDJobs.go b/web_client/hvueCompHIDJobs.go index deb563e..9df2caf 100644 --- a/web_client/hvueCompHIDJobs.go +++ b/web_client/hvueCompHIDJobs.go @@ -5,7 +5,6 @@ package main import ( "github.com/gopherjs/gopherjs/js" "github.com/HuckRidgeSW/hvue" - "github.com/mame82/P4wnP1_go/common_web" ) type CompHIDJobsData struct { @@ -28,25 +27,11 @@ func InitCompHIDJobs() { hvue.DataFunc(newCompHIDJobsData), hvue.Computed("jobs", func(vm *hvue.VM) interface{} { - jobList := vm.Get("$store").Get("state").Get("hidJobList").Get("jobs") - return js.Global.Get("Object").Call("values",jobList) + //return vm.Get("$store").Get("state").Get("hidJobList").Get("jobs") + return vm.Get("$store").Get("getters").Get("hidjobs") }), ) - hvue.NewComponent( - "hid-job-event-overview", - hvue.Template(compHIDJobEventOverviewTemplate), - hvue.DataFunc(newCompHIDJobsData), - hvue.Computed("events", - func(vm *hvue.VM) interface{} { - return vm.Get("$store").Get("state").Get("eventReceiver").Get("eventHidArray") - }), - hvue.Method("evIdToString", func (vm *hvue.VM, evID int64) (res string) { - println("EvID",evID) - return common_web.EventType_name[evID] - }), - ) - hvue.NewComponent( "hid-job-overview-item", hvue.Template(compHIDJobOverViewItemTemplate), @@ -142,44 +127,21 @@ ScriptSource string `js:"textSource"` //{ "evtype": 0, "vmId": 2, "jobId": 3, "hasError": false, "result": "null", "error": "", "message": "Script started", "time": "2018-07-30 04:56:42.297533 +0000 UTC m=+7625.097825001" } compHIDJobOverviewTemplate = ` - + + + HIDScript jobs + + - HID Script jobs - + Running + + Succeeded + + Failed + -` - //{ "evtype": 0, "vmId": 2, "jobId": 3, "hasError": false, "result": "null", "error": "", "message": "Script started", "time": "2018-07-30 04:56:42.297533 +0000 UTC m=+7625.097825001" } - compHIDJobEventOverviewTemplate = ` - -
- - - - - - - - - - - - - - - - - - - - - - -
Event TypeVM IDJob IDHas errorResultErrorMessageTime
{{ evIdToString(e.evtype) }}{{ e.vmId }}{{ e.jobId }}{{ e.hasError }}{{ e.result }}{{ e.error }}{{ e.message }}{{ e.time }}
-
- -
` ) diff --git a/web_client/hvueCompHIDScript.go b/web_client/hvueCompHIDScript.go index 0ba42a2..ccd7533 100644 --- a/web_client/hvueCompHIDScript.go +++ b/web_client/hvueCompHIDScript.go @@ -100,24 +100,22 @@ func InitComponentsHIDScript() { const ( compHIDScriptTemplate = ` - -
-
- + +
+
+ +
+
+ +
+
+ +
-
- -
-
-
- -
- - ` compHIDScriptCodeEditorTemplate = ` - + HIDScript editor diff --git a/web_client/hvueCompUSBSettings.go b/web_client/hvueCompUSBSettings.go index 328240c..d5cdb77 100644 --- a/web_client/hvueCompUSBSettings.go +++ b/web_client/hvueCompUSBSettings.go @@ -63,195 +63,205 @@ func newCompUSBSettingsData(vm *hvue.VM) interface{} { const ( compUSBSettingsTemplate = ` - - - - USB Gadget Settings - - - - + +
+
+ + + Generic USB Gadget Settings + + + + - + - If you're connected via Ethernet over USB, you will loose connection during deployment (deadline exceeded error)" + If you're connected via Ethernet over USB, you will loose connection during deployment (deadline exceeded error)" - - + + - Generic - - - - - - Enabled - Enable/Disable USB gadget (if enabled, at least one function has to be turned on) - - - - - Vendor ID - Example: 0x1d6b - - - - - - - - Product ID - Example: 0x1337 - - - - - - - - Manufacturer Name - - - - - - - - - Product Name - - - - - - - - - Serial Number - - - - - - + + + + + + Enabled + Enable/Disable USB gadget (if enabled, at least one function has to be turned on) + + + + + Vendor ID + Example: 0x1d6b + + + + + + + + Product ID + Example: 0x1337 + + + + + + + + Manufacturer Name + + + + + + + + + Product Name + + + + + + + + + Serial Number + + + + + + + + +
+
+ + + USB Gadget Functions + + - + - Functions - - - - - - CDC ECM - Ethernet over USB for Linux, Unix and OSX - - + + + + + + CDC ECM + Ethernet over USB for Linux, Unix and OSX + + - - - - Host Address - MAC of USB adapter on remote host (format: AA:BB:CC:DD:EE:FF) - - - - - - - - Device Address - MAC address on P4wnP1's end (format: AA:BB:CC:DD:EE:FF) - - - - - - + + + + Host Address + MAC of USB adapter on remote host (format: AA:BB:CC:DD:EE:FF) + + + + + + + + Device Address + MAC address on P4wnP1's end (format: AA:BB:CC:DD:EE:FF) + + + + + + - - - - - - RNDIS - Ethernet over USB for Windows (and some Linux kernels) - - + + + + + + RNDIS + Ethernet over USB for Windows (and some Linux kernels) + + - - - - Host Address - MAC of USB adapter on remote host - could get overwritten by host (format: AA:BB:CC:DD:EE:FF) - - - - - - - - Device Address - MAC address on P4wnP1's end (format: AA:BB:CC:DD:EE:FF) - - - - - - + + + + Host Address + MAC of USB adapter on remote host - could get overwritten by host (format: AA:BB:CC:DD:EE:FF) + + + + + + + + Device Address + MAC address on P4wnP1's end (format: AA:BB:CC:DD:EE:FF) + + + + + + - - - - - - Keyboard - HID Keyboard functionality (needed for HID Script) - - - - - - - - Mouse - HID Mouse functionality (needed for HID Script) - - - - - - - - Custom HID device - Raw HID device function, used for covert channel - - - - - - - - Serial Interface - Provides a serial port over USB - - - - - - - - Mass Storage - Emulates USB flash drive or CD-ROM - - - - - - + + + + + + Keyboard + HID Keyboard functionality (needed for HID Script) + + + + + + + + Mouse + HID Mouse functionality (needed for HID Script) + + + + + + + + Custom HID device + Raw HID device function, used for covert channel + + + + + + + + Serial Interface + Provides a serial port over USB + + + + + + + + Mass Storage + Emulates USB flash drive or CD-ROM + + + + +
+
+ ` ) diff --git a/web_client/hvueComponentWiFi.go b/web_client/hvueComponentWiFi.go index fb30682..e43a373 100644 --- a/web_client/hvueComponentWiFi.go +++ b/web_client/hvueComponentWiFi.go @@ -88,8 +88,10 @@ func InitComponentsWiFi() { } const templateWiFi = ` - - + +
+
+ WiFi settings @@ -139,9 +141,18 @@ const templateWiFi = ` - + + +
-