generated from thinkode/modelRepository
settings save optimizations
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
import { t, _ } from 'svelte-i18n'
|
||||
import { generateToast, needProjectSave, peripherals } from "../../stores";
|
||||
import { get } from "svelte/store"
|
||||
import { UpdatePeripheralSetting, GetPeripheralSettings, AddOS2LPeripheral, RemovePeripheral, ConnectFTDI, ActivateFTDI, DeactivateFTDI, DisconnectFTDI, SetDeviceFTDI, AddPeripheral } from "../../../wailsjs/go/main/App";
|
||||
import { UpdatePeripheralSettings, GetPeripheralSettings, AddOS2LPeripheral, RemovePeripheral, ConnectFTDI, ActivateFTDI, DeactivateFTDI, DisconnectFTDI, SetDeviceFTDI, AddPeripheral } from "../../../wailsjs/go/main/App";
|
||||
import RoundedButton from "../General/RoundedButton.svelte";
|
||||
|
||||
function ftdiConnect(){
|
||||
@@ -122,7 +122,8 @@
|
||||
GetPeripheralSettings(peripheral.ProtocolName, peripheral.SerialNumber).then((peripheralSettings) => {
|
||||
selectedPeripheralSettings = peripheralSettings
|
||||
}).catch((error) => {
|
||||
generateToast('error', 'bx-error', $_("getPeripheralSettingsErrorToast"))
|
||||
console.log("Unable to get the peripheral settings: " + error)
|
||||
generateToast('danger', 'bx-error', $_("getPeripheralSettingsErrorToast"))
|
||||
})
|
||||
// Select the current peripheral
|
||||
selectedPeripheralSN = peripheral.SerialNumber
|
||||
@@ -145,11 +146,20 @@
|
||||
// Validate the peripheral settings
|
||||
function validate(settingName, settingValue){
|
||||
console.log("Peripheral setting '" + settingName + "' set to '" + settingValue + "'")
|
||||
// Get the old setting type and convert the new setting to this type
|
||||
const convert = {
|
||||
number: Number,
|
||||
string: String,
|
||||
boolean: Boolean,
|
||||
}[typeof(selectedPeripheralSettings[settingName])] || (x => x)
|
||||
selectedPeripheralSettings[settingName] = convert(settingValue)
|
||||
console.log(typeof(selectedPeripheralSettings[settingName]))
|
||||
let peripheralProtocolName = get(peripherals)[selectedPeripheralSN].ProtocolName
|
||||
UpdatePeripheralSetting(peripheralProtocolName, selectedPeripheralSN, settingName, settingValue).then(()=> {
|
||||
UpdatePeripheralSettings(peripheralProtocolName, selectedPeripheralSN, selectedPeripheralSettings).then(()=> {
|
||||
$needProjectSave = true
|
||||
}).catch((error) => {
|
||||
generateToast('error', 'bx-error', $_("peripheralSettingSaveErrorToast"))
|
||||
console.log("Unable to save the peripheral setting: " + error)
|
||||
generateToast('danger', 'bx-error', $_("peripheralSettingSaveErrorToast"))
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -57,9 +57,9 @@
|
||||
"projectOpenedToast": "The project was opened:",
|
||||
"projectOpenErrorToast": "Unable to open the project",
|
||||
"projectCreatedToast": "The project was created",
|
||||
"peripheralSettingSaveErrorToast": "Unable to save the peripheral setting",
|
||||
"peripheralSettingSaveErrorToast": "Unable to save the peripheral settings",
|
||||
|
||||
"os2lIpSetting": "OS2L server IP",
|
||||
"os2lPortSetting": "OS2L server port"
|
||||
"os2lIp": "OS2L server IP",
|
||||
"os2lPort": "OS2L server port"
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user