// +build js package main import ( "github.com/gopherjs/gopherjs/js" "github.com/mame82/hvue" ) type CompUSBSettingsData struct { *js.Object GadgetSettings *jsGadgetSettings `js:"gadgetSettings"` DeployPending bool `js:"deployPending"` CdcEcmDetails bool `js:"cdcEcmDetails"` RndisDetails bool `js:"rndisDetails"` ShowStoreModal bool `js:"showStoreModal"` ShowLoadModal bool `js:"showLoadModal"` ShowDeployStoredModal bool `js:"showDeployStoredModal"` ShowUmsModal bool `js:"ShowUmsModal"` } //This becomes a method of the Vue Component and encapsulates dispatching of a Vuex action func (c *CompUSBSettingsData) UpdateFromDeployedGadgetSettings(vm *hvue.VM) { vm.Get("$store").Call("dispatch", VUEX_ACTION_UPDATE_CURRENT_USB_SETTINGS) } //This becomes a method of the Vue Component and encapsulates dispatching of a Vuex action func (c *CompUSBSettingsData) ApplyGadgetSettings(vm *hvue.VM) { vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_CURRENT_USB_SETTINGS) } func InitCompUSBSettings() { hvue.NewComponent( "usb-settings", hvue.Template(compUSBSettingsTemplate), hvue.DataFunc(newCompUSBSettingsData), hvue.MethodsOf(&CompUSBSettingsData{}), // Add the methods of CompUSBSettingsData to the Vue Component instance hvue.Computed( "currentGadgetSettings", func(vm *hvue.VM) interface{} { return vm.Get("$store").Get("state").Get("currentGadgetSettings") }), hvue.Computed("deploying", func(vm *hvue.VM) interface{} { return vm.Get("$store").Get("state").Get("deployingGadgetSettings") }), hvue.Mounted(func(vm *hvue.VM) { vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_CURRENT_USB_SETTINGS) }), hvue.Method("store", func(vm *hvue.VM, name *js.Object) { sReq := NewUSBRequestSettingsStorage() sReq.TemplateName = name.String() sReq.Settings = &jsGadgetSettings{ Object: vm.Get("$store").Get("state").Get("currentGadgetSettings"), } println("Storing :", sReq) vm.Get("$store").Call("dispatch", VUEX_ACTION_STORE_USB_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_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()) vm.Get("$store").Call("dispatch", VUEX_ACTION_DEPLOY_STORED_USB_SETTINGS, name) }), hvue.Method("updateStoredSettingsList", func(vm *hvue.VM) { vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_STORED_USB_SETTINGS_LIST) }), ) hvue.NewComponent("ums-settings", hvue.Template(compUSBUmsSettingsTemplate), hvue.DataFunc(func(vm *hvue.VM) interface{} { data := &struct { *js.Object ShowImageSelect bool `js:"ShowImageSelect"` }{Object: O()} data.ShowImageSelect = false return data }), hvue.PropObj("value"), hvue.PropObj( "show", hvue.Required, hvue.Types(hvue.PBoolean), ), hvue.ComputedWithGetSet( "visible", func(vm *hvue.VM) interface{} { return vm.Get("show") }, func(vm *hvue.VM, newValue *js.Object) { vm.Call("$emit", "show", newValue) }, ), hvue.Method("updateFileLists", func(vm *hvue.VM) { vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_UMS_IMAGE_CDROM_LIST) vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_UMS_IMAGE_FLASHDRIVE_LIST) }), hvue.Mounted(func(vm *hvue.VM) { vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_UMS_IMAGE_CDROM_LIST) vm.Store.Call("dispatch", VUEX_ACTION_UPDATE_UMS_IMAGE_FLASHDRIVE_LIST) }), ) } func newCompUSBSettingsData(vm *hvue.VM) interface{} { data := &CompUSBSettingsData{ Object: js.Global.Get("Object").New(), } data.GadgetSettings = NewUSBGadgetSettings() data.ShowStoreModal = false data.ShowLoadModal = false data.ShowDeployStoredModal = false data.DeployPending = false data.RndisDetails = false data.CdcEcmDetails = false data.ShowUmsModal = false return data } const ( compUSBUmsSettingsTemplate = ` USB Mass Storage CD-Rom If enabled, a CD-ROM drive is emulated instead of a writable flashdrive Image file to use
` compUSBSettingsTemplate = `
USB Gadget Settings
If you're connected via Ethernet over USB, you will loose connection during deployment (deadline exceeded error)" 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
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) 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) 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
` )