|
|
@ -23,29 +23,16 @@ export type accentColor = |
|
|
| "pink"; |
|
|
| "pink"; |
|
|
|
|
|
|
|
|
export class ConfigPreset { |
|
|
export class ConfigPreset { |
|
|
|
|
|
|
|
|
public children: ConfigPreset[] = []; |
|
|
public children: ConfigPreset[] = []; |
|
|
public count: number = 0; |
|
|
public count: number = 0; |
|
|
public overrideValues: {[fieldName: string]: boolean}; |
|
|
public overrideValues: {[fieldName: string]: boolean}; |
|
|
|
|
|
|
|
|
public constructor(public name: string, public parent?: ConfigPreset, public config : Protobuf.LocalConfig = new Protobuf.LocalConfig()) { |
|
|
public constructor(public name: string, public parent?: ConfigPreset, public config = ConfigPreset.createDefaultConfig()) { |
|
|
if(parent) { |
|
|
if(parent) { |
|
|
// Root config should not be overridable
|
|
|
// Root config should not be overridable
|
|
|
this.overrideValues = {}; |
|
|
this.overrideValues = {}; |
|
|
} |
|
|
} |
|
|
if(config.device === undefined) |
|
|
|
|
|
config.device = new Protobuf.Config_DeviceConfig(); |
|
|
|
|
|
if(config.position === undefined) |
|
|
|
|
|
config.position = new Protobuf.Config_PositionConfig(); |
|
|
|
|
|
if(config.power === undefined) |
|
|
|
|
|
config.power = new Protobuf.Config_PowerConfig(); |
|
|
|
|
|
if(config.network === undefined) |
|
|
|
|
|
config.network = new Protobuf.Config_NetworkConfig(); |
|
|
|
|
|
if(config.display === undefined) |
|
|
|
|
|
config.display = new Protobuf.Config_DisplayConfig(); |
|
|
|
|
|
if(config.lora === undefined) |
|
|
|
|
|
config.lora = new Protobuf.Config_LoRaConfig(); |
|
|
|
|
|
if(config.bluetooth === undefined) |
|
|
|
|
|
config.bluetooth = new Protobuf.Config_BluetoothConfig(); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public saveConfigTree() { |
|
|
public saveConfigTree() { |
|
|
@ -143,6 +130,7 @@ export class ConfigPreset { |
|
|
|
|
|
|
|
|
public static loadOrCreate(): ConfigPreset { |
|
|
public static loadOrCreate(): ConfigPreset { |
|
|
const storedConfigs = localStorage.getItem("PresetConfigs"); |
|
|
const storedConfigs = localStorage.getItem("PresetConfigs"); |
|
|
|
|
|
debugger; |
|
|
if(storedConfigs !== null) { |
|
|
if(storedConfigs !== null) { |
|
|
const rootPreset = this.tryFromJson(storedConfigs); |
|
|
const rootPreset = this.tryFromJson(storedConfigs); |
|
|
if(rootPreset !== undefined) |
|
|
if(rootPreset !== undefined) |
|
|
@ -175,6 +163,21 @@ export class ConfigPreset { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static createDefaultConfig(): Protobuf.LocalConfig { |
|
|
|
|
|
return new Protobuf.LocalConfig({ |
|
|
|
|
|
device: new Protobuf.Config_DeviceConfig({ |
|
|
|
|
|
serialEnabled: true, |
|
|
|
|
|
nodeInfoBroadcastSecs: 10800 |
|
|
|
|
|
}), |
|
|
|
|
|
position: new Protobuf.Config_PositionConfig({ }), |
|
|
|
|
|
power: new Protobuf.Config_PowerConfig({ }), |
|
|
|
|
|
network: new Protobuf.Config_NetworkConfig({ }), |
|
|
|
|
|
display: new Protobuf.Config_DisplayConfig({ }), |
|
|
|
|
|
lora: new Protobuf.Config_LoRaConfig({ }), |
|
|
|
|
|
bluetooth: new Protobuf.Config_BluetoothConfig({ }), |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function loadFirmwareListFromStorage(): FirmwareVersion[] { |
|
|
function loadFirmwareListFromStorage(): FirmwareVersion[] { |
|
|
|