-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor some data classes into their own files. Rename profile manager.
- Loading branch information
Showing
16 changed files
with
156 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 3 additions & 115 deletions
118
src/model/ProfileManager/ProfileManager.ts → src/model/AppDataManager/AppDataManager.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { makeAutoObservable } from "mobx"; | ||
import { ProfileV2, ProfileV3 } from "./Profile"; | ||
import { RootConfigV2, RootConfigV3 } from "./RootConfig"; | ||
|
||
/** | ||
* This class represents all the data that the app needs to store/load from | ||
* local storage (i.e. the root object). It must be serializable to JSON. | ||
*/ | ||
export class AppDataV1 { | ||
|
||
version = 1; | ||
|
||
profiles: ProfileV2[] = []; | ||
|
||
/** | ||
* Represents the current application configuration. This is saved regularly so that when the app reloads, | ||
* it can restore the last known configuration. | ||
*/ | ||
currentAppConfig: RootConfigV2 = new RootConfigV2(); | ||
|
||
constructor() { | ||
makeAutoObservable(this); | ||
} | ||
} | ||
|
||
export class AppDataV2 { | ||
|
||
version = 2; | ||
|
||
profiles: ProfileV3[] = []; | ||
|
||
/** | ||
* Represents the current application configuration. This is saved regularly so that when the app reloads, | ||
* it can restore the last known configuration. | ||
*/ | ||
currentAppConfig: RootConfigV3 = new RootConfigV3(); | ||
|
||
constructor() { | ||
this.profiles = []; | ||
this.profiles.push(new ProfileV3('Default profile')); | ||
makeAutoObservable(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { makeAutoObservable } from "mobx"; | ||
import { RootConfigV2, RootConfigV3 } from "./RootConfig"; | ||
|
||
/** | ||
* This class represents all the data stored in a user profile. It is used to store use-specific | ||
* settings for the application (e.g. all the settings to talk to a particular | ||
* embedded device). The class is serializable to JSON. | ||
*/ | ||
export class ProfileV2 { | ||
name: string = ''; | ||
rootConfig: RootConfigV2 = new RootConfigV2(); | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
makeAutoObservable(this); | ||
} | ||
} | ||
|
||
export class ProfileV3 { | ||
name: string = ''; | ||
rootConfig: RootConfigV3 = new RootConfigV3(); | ||
|
||
constructor(name: string) { | ||
this.name = name; | ||
makeAutoObservable(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { MacroControllerConfig } from "src/model/Terminals/RightDrawer/Macros/MacroController"; | ||
import { RightDrawerConfig } from "src/model/Terminals/RightDrawer/RightDrawer"; | ||
import { LastUsedSerialPort } from "../AppDataManager"; | ||
import { TxSettingsConfig } from "src/model/Settings/TxSettings/TxSettings"; | ||
import { RxSettingsConfig } from "src/model/Settings/RxSettings/RxSettings"; | ||
import { DisplaySettingsConfig } from "src/model/Settings/DisplaySettings/DisplaySettings"; | ||
import { GeneralSettingsConfig } from "src/model/Settings/GeneralSettings/GeneralSettings"; | ||
import { PortConfigurationConfigV2, PortConfigurationConfigV3 } from "src/model/Settings/PortConfigurationSettings/PortConfigurationSettings"; | ||
|
||
/** | ||
* Everything in this class must be POD (plain old data) and serializable to JSON. | ||
*/ | ||
export class RootConfigV2 { | ||
version = 2; | ||
|
||
terminal = { | ||
macroController: new MacroControllerConfig(), | ||
rightDrawer: new RightDrawerConfig(), | ||
}; | ||
|
||
lastUsedSerialPort: LastUsedSerialPort = new LastUsedSerialPort(); | ||
|
||
settings = { | ||
portSettings: new PortConfigurationConfigV2(), | ||
txSettings: new TxSettingsConfig(), | ||
rxSettings: new RxSettingsConfig(), | ||
displaySettings: new DisplaySettingsConfig(), | ||
generalSettings: new GeneralSettingsConfig(), | ||
}; | ||
} | ||
|
||
/** | ||
* Everything in this class must be POD (plain old data) and serializable to JSON. | ||
*/ | ||
export class RootConfigV3 { | ||
version = 3; | ||
|
||
terminal = { | ||
macroController: new MacroControllerConfig(), | ||
rightDrawer: new RightDrawerConfig(), | ||
}; | ||
|
||
lastUsedSerialPort: LastUsedSerialPort = new LastUsedSerialPort(); | ||
|
||
settings = { | ||
portSettings: new PortConfigurationConfigV3(), | ||
txSettings: new TxSettingsConfig(), | ||
rxSettings: new RxSettingsConfig(), | ||
displaySettings: new DisplaySettingsConfig(), | ||
generalSettings: new GeneralSettingsConfig(), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.