mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-04-01 21:13:09 +00:00
fix occasional issues with stale state
This commit is contained in:
committed by
Aiden McClelland
parent
8056285a7f
commit
442bb4c224
10
ui/README.md
10
ui/README.md
@@ -12,13 +12,13 @@ npm --version
|
|||||||
v8.0.0
|
v8.0.0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Building The Mock Development Server
|
### Running The Mock Development Server
|
||||||
|
|
||||||
`git clone https://github.com/Start9Labs/ws-example.git`
|
`git clone https://github.com/Start9Labs/ws-example.git`
|
||||||
|
|
||||||
`cd ws-example`
|
`cd ws-example`
|
||||||
|
|
||||||
**Start the server**
|
`git submodule update --init --recursive`
|
||||||
|
|
||||||
`cargo run -- -vvv -c example-config.toml`
|
`cargo run -- -vvv -c example-config.toml`
|
||||||
|
|
||||||
@@ -36,10 +36,10 @@ v8.0.0
|
|||||||
|
|
||||||
`npm --prefix . install @ionic/cli`
|
`npm --prefix . install @ionic/cli`
|
||||||
|
|
||||||
`npm --prefix . run build-deps`
|
|
||||||
|
|
||||||
`npm --prefix . install`
|
`npm --prefix . install`
|
||||||
|
|
||||||
|
`npm --prefix . run build-deps`
|
||||||
|
|
||||||
Copy `config-sample.json` to new file `config.json`
|
Copy `config-sample.json` to new file `config.json`
|
||||||
In `config.json`, edit the "mocks" section to look like the following:
|
In `config.json`, edit the "mocks" section to look like the following:
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ You can also enable or disable startup alerts.
|
|||||||
If you want to update mock data inside ws-example, you must do the following:
|
If you want to update mock data inside ws-example, you must do the following:
|
||||||
|
|
||||||
1. Stop the ws-example server
|
1. Stop the ws-example server
|
||||||
1. Run `rm embassy.db`
|
1. In es-example, run `rm embassy.db`
|
||||||
1. Delete `patch-db-cache` from your browser's Local Storage
|
1. Delete `patch-db-cache` from your browser's Local Storage
|
||||||
1. Restart ws-example
|
1. Restart ws-example
|
||||||
1. Refresh the browser window
|
1. Refresh the browser window
|
||||||
@@ -42,7 +42,7 @@ export class AppConfigPage {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
async ngOnInit () {
|
async ngOnInit () {
|
||||||
this.pkg = this.patch.data['package-data'][this.pkgId]
|
this.pkg = this.patch.getData()['package-data'][this.pkgId]
|
||||||
this.hasConfig = !!this.pkg.manifest.config
|
this.hasConfig = !!this.pkg.manifest.config
|
||||||
|
|
||||||
if (!this.hasConfig) return
|
if (!this.hasConfig) return
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export class AppRecoverSelectPage {
|
|||||||
...this.backupInfo['package-backups'][id],
|
...this.backupInfo['package-backups'][id],
|
||||||
id,
|
id,
|
||||||
checked: false,
|
checked: false,
|
||||||
installed: !!this.patch.data['package-data'][id],
|
installed: !!this.patch.getData()['package-data'][id],
|
||||||
'newer-eos': this.emver.compare(this.backupInfo['package-backups'][id]['os-version'], this.config.version) === 1,
|
'newer-eos': this.emver.compare(this.backupInfo['package-backups'][id]['os-version'], this.config.version) === 1,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class AppInterfacesPage {
|
|||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
const pkgId = this.route.snapshot.paramMap.get('pkgId')
|
const pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||||
const pkg = this.patch.data['package-data'][pkgId]
|
const pkg = this.patch.getData()['package-data'][pkgId]
|
||||||
const interfaces = pkg.manifest.interfaces
|
const interfaces = pkg.manifest.interfaces
|
||||||
const uiKey = getUiInterfaceKey(interfaces)
|
const uiKey = getUiInterfaceKey(interfaces)
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ export class AppShowPage {
|
|||||||
|
|
||||||
async ngOnInit () {
|
async ngOnInit () {
|
||||||
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
this.pkgId = this.route.snapshot.paramMap.get('pkgId')
|
||||||
this.pkg = this.patch.data['package-data'][this.pkgId]
|
this.pkg = this.patch.getData()['package-data'][this.pkgId]
|
||||||
this.statuses = renderPkgStatus(this.pkg)
|
this.statuses = renderPkgStatus(this.pkg)
|
||||||
this.healthChecks = Object.keys(this.pkg.manifest['health-checks']).reduce((obj, key) => {
|
this.healthChecks = Object.keys(this.pkg.manifest['health-checks']).reduce((obj, key) => {
|
||||||
obj[key] = null
|
obj[key] = null
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export class MarketplaceService {
|
|||||||
const [data, eos, pkgs] = await Promise.all([
|
const [data, eos, pkgs] = await Promise.all([
|
||||||
this.api.getMarketplaceData({ }),
|
this.api.getMarketplaceData({ }),
|
||||||
this.api.getEos({
|
this.api.getEos({
|
||||||
'eos-version-compat': this.patch.data['server-info']['eos-version-compat'],
|
'eos-version-compat': this.patch.getData()['server-info']['eos-version-compat'],
|
||||||
}),
|
}),
|
||||||
this.getPkgs(1, 100),
|
this.getPkgs(1, 100),
|
||||||
])
|
])
|
||||||
@@ -40,7 +40,7 @@ export class MarketplaceService {
|
|||||||
const idAndCurrentVersions = Object.keys(localPkgs).map(key => ({ id: key, version: localPkgs[key].manifest.version }))
|
const idAndCurrentVersions = Object.keys(localPkgs).map(key => ({ id: key, version: localPkgs[key].manifest.version }))
|
||||||
const latestPkgs = await this.api.getMarketplacePkgs({
|
const latestPkgs = await this.api.getMarketplacePkgs({
|
||||||
ids: idAndCurrentVersions,
|
ids: idAndCurrentVersions,
|
||||||
'eos-version-compat': this.patch.data['server-info']['eos-version-compat'],
|
'eos-version-compat': this.patch.getData()['server-info']['eos-version-compat'],
|
||||||
})
|
})
|
||||||
|
|
||||||
return latestPkgs.filter(latestPkg => {
|
return latestPkgs.filter(latestPkg => {
|
||||||
@@ -53,7 +53,7 @@ export class MarketplaceService {
|
|||||||
async getPkg (id: string, version?: string): Promise<MarketplacePkg> {
|
async getPkg (id: string, version?: string): Promise<MarketplacePkg> {
|
||||||
const pkgs = await this.api.getMarketplacePkgs({
|
const pkgs = await this.api.getMarketplacePkgs({
|
||||||
ids: [{ id, version: version || '*' }],
|
ids: [{ id, version: version || '*' }],
|
||||||
'eos-version-compat': this.patch.data['server-info']['eos-version-compat'],
|
'eos-version-compat': this.patch.getData()['server-info']['eos-version-compat'],
|
||||||
})
|
})
|
||||||
const pkg = pkgs.find(pkg => pkg.manifest.id == id)
|
const pkg = pkgs.find(pkg => pkg.manifest.id == id)
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ export class MarketplaceService {
|
|||||||
const pkgs = await this.api.getMarketplacePkgs({
|
const pkgs = await this.api.getMarketplacePkgs({
|
||||||
page: String(page),
|
page: String(page),
|
||||||
'per-page': String(perPage),
|
'per-page': String(perPage),
|
||||||
'eos-version-compat': this.patch.data['server-info']['eos-version-compat'],
|
'eos-version-compat': this.patch.getData()['server-info']['eos-version-compat'],
|
||||||
})
|
})
|
||||||
|
|
||||||
return pkgs
|
return pkgs
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class PreferencesPage {
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.defaultName = `Embassy-${this.patch.data['server-info'].id}`
|
this.defaultName = `Embassy-${this.patch.getData()['server-info'].id}`
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit () {
|
ngAfterViewInit () {
|
||||||
@@ -40,7 +40,7 @@ export class PreferencesPage {
|
|||||||
useMask: false,
|
useMask: false,
|
||||||
placeholder: this.defaultName,
|
placeholder: this.defaultName,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
value: this.patch.data.ui.name,
|
value: this.patch.getData().ui.name,
|
||||||
buttonText: 'Save',
|
buttonText: 'Save',
|
||||||
loadingText: 'Saving',
|
loadingText: 'Saving',
|
||||||
submitFn: (value: string) => this.setDbValue('name', value || this.defaultName),
|
submitFn: (value: string) => this.setDbValue('name', value || this.defaultName),
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ export class PatchDbService {
|
|||||||
private patchSub: Subscription
|
private patchSub: Subscription
|
||||||
data: DataModel
|
data: DataModel
|
||||||
|
|
||||||
|
getData () { return this.patchDb.store.cache.data }
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
@Inject(PATCH_SOURCE) private readonly source: Source<DataModel>,
|
@Inject(PATCH_SOURCE) private readonly source: Source<DataModel>,
|
||||||
@Inject(PATCH_HTTP) private readonly http: ApiService,
|
@Inject(PATCH_HTTP) private readonly http: ApiService,
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import { ServerConfigService } from './server-config.service'
|
|||||||
})
|
})
|
||||||
export class StartupAlertsService {
|
export class StartupAlertsService {
|
||||||
private checks: Check<any>[]
|
private checks: Check<any>[]
|
||||||
data: DataModel
|
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private readonly alertCtrl: AlertController,
|
private readonly alertCtrl: AlertController,
|
||||||
@@ -72,8 +71,7 @@ export class StartupAlertsService {
|
|||||||
filter(data => !isEmptyObject(data)),
|
filter(data => !isEmptyObject(data)),
|
||||||
take(1),
|
take(1),
|
||||||
)
|
)
|
||||||
.subscribe(async data => {
|
.subscribe(async () => {
|
||||||
this.data = data
|
|
||||||
await this.checks
|
await this.checks
|
||||||
.filter(c => !this.config.skipStartupAlerts && c.shouldRun())
|
.filter(c => !this.config.skipStartupAlerts && c.shouldRun())
|
||||||
// returning true in the below block means to continue to next modal
|
// returning true in the below block means to continue to next modal
|
||||||
@@ -98,25 +96,25 @@ export class StartupAlertsService {
|
|||||||
// ** should run **
|
// ** should run **
|
||||||
|
|
||||||
private shouldRunOsWelcome (): boolean {
|
private shouldRunOsWelcome (): boolean {
|
||||||
return this.data.ui['ack-welcome'] !== this.config.version
|
return this.patch.getData().ui['ack-welcome'] !== this.config.version
|
||||||
}
|
}
|
||||||
private shouldRunShareStats (): boolean {
|
private shouldRunShareStats (): boolean {
|
||||||
return !this.data.ui['ack-share-stats']
|
return !this.patch.getData().ui['ack-share-stats']
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldRunOsUpdateCheck (): boolean {
|
private shouldRunOsUpdateCheck (): boolean {
|
||||||
return this.data.ui['auto-check-updates']
|
return this.patch.getData().ui['auto-check-updates']
|
||||||
}
|
}
|
||||||
|
|
||||||
private shouldRunAppsCheck (): boolean {
|
private shouldRunAppsCheck (): boolean {
|
||||||
return this.data.ui['auto-check-updates']
|
return this.patch.getData().ui['auto-check-updates']
|
||||||
}
|
}
|
||||||
|
|
||||||
// ** check **
|
// ** check **
|
||||||
|
|
||||||
private async osUpdateCheck (): Promise<RR.GetMarketplaceEOSRes | undefined> {
|
private async osUpdateCheck (): Promise<RR.GetMarketplaceEOSRes | undefined> {
|
||||||
const res = await this.api.getEos({
|
const res = await this.api.getEos({
|
||||||
'eos-version-compat': this.patch.data['server-info']['eos-version-compat'],
|
'eos-version-compat': this.patch.getData()['server-info']['eos-version-compat'],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.emver.compare(this.config.version, res.version) === -1) {
|
if (this.emver.compare(this.config.version, res.version) === -1) {
|
||||||
@@ -127,7 +125,7 @@ export class StartupAlertsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async appsCheck (): Promise<boolean> {
|
private async appsCheck (): Promise<boolean> {
|
||||||
const updates = await this.marketplaceService.getUpdates(this.data['package-data'])
|
const updates = await this.marketplaceService.getUpdates(this.patch.getData()['package-data'])
|
||||||
return !!updates.length
|
return !!updates.length
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +151,7 @@ export class StartupAlertsService {
|
|||||||
|
|
||||||
private async displayShareStats (): Promise<boolean> {
|
private async displayShareStats (): Promise<boolean> {
|
||||||
return new Promise(async resolve => {
|
return new Promise(async resolve => {
|
||||||
const alert = await this.serverConfig.presentAlert('share-stats', this.data['server-info']['share-stats'])
|
const alert = await this.serverConfig.presentAlert('share-stats', this.patch.getData()['server-info']['share-stats'])
|
||||||
|
|
||||||
alert.onDidDismiss().then(() => {
|
alert.onDidDismiss().then(() => {
|
||||||
this.api.setDbValue({ pointer: '/ack-share-stats', value: this.config.version })
|
this.api.setDbValue({ pointer: '/ack-share-stats', value: this.config.version })
|
||||||
|
|||||||
Reference in New Issue
Block a user