diff --git a/ui/config-sample.json b/ui/config-sample.json index 0550fd161..fc5cc388f 100644 --- a/ui/config-sample.json +++ b/ui/config-sample.json @@ -14,6 +14,7 @@ }, "mocks": { "enabled": true, + "marketplace": true, "connection": "ws", "rpcPort": "5959", "wsPort": "5960", diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts index 239b99f6b..f37485c7e 100644 --- a/ui/src/app/app.component.ts +++ b/ui/src/app/app.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' import { Storage } from '@ionic/storage' import { AuthService, AuthState } from './services/auth.service' -import { ApiService } from './services/api/api.service' +import { ApiService } from './services/api/embassy/embassy-api.service' import { Router, RoutesRecognized } from '@angular/router' import { debounceTime, distinctUntilChanged, filter, finalize, takeWhile } from 'rxjs/operators' import { AlertController, IonicSafeString, ToastController } from '@ionic/angular' @@ -9,10 +9,11 @@ import { LoaderService } from './services/loader.service' import { Emver } from './services/emver.service' import { SplitPaneTracker } from './services/split-pane.service' import { LoadingOptions, ToastButton } from '@ionic/core' -import { PatchDbModel } from './services/patch-db/patch-db.service' +import { PatchDbService } from './services/patch-db/patch-db.service' import { HttpService } from './services/http.service' import { ServerStatus } from './services/patch-db/data-model' import { ConnectionFailure, ConnectionService } from './services/connection.service' +import { StartupAlertsService } from './services/startup-alerts.service' @Component({ selector: 'app-root', @@ -59,8 +60,9 @@ export class AppComponent { private readonly loader: LoaderService, private readonly emver: Emver, private readonly connectionService: ConnectionService, + private readonly startupAlertsService: StartupAlertsService, private readonly toastCtrl: ToastController, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, readonly splitPane: SplitPaneTracker, ) { // set dark theme @@ -93,6 +95,8 @@ export class AppComponent { this.watchStatus(auth) // watch unread notification count to display toast this.watchNotifications(auth) + // run startup alerts + this.startupAlertsService.runChecks() // UNVERIFIED } else if (auth === AuthState.UNVERIFIED) { this.http.authReqEnabled = false diff --git a/ui/src/app/app.module.ts b/ui/src/app/app.module.ts index 29247bc54..c9a64052a 100644 --- a/ui/src/app/app.module.ts +++ b/ui/src/app/app.module.ts @@ -7,20 +7,20 @@ import { IonicStorageModule } from '@ionic/storage-angular' import { HttpClientModule } from '@angular/common/http' import { AppComponent } from './app.component' import { AppRoutingModule } from './app-routing.module' -import { ApiService } from './services/api/api.service' +import { ApiService } from './services/api/embassy/embassy-api.service' import { ApiServiceFactory, MarketplaceApiServiceFactory } from './services/api/api.service.factory' -import { PatchDbModelFactory } from './services/patch-db/patch-db.factory' +import { PatchDbServiceFactory } from './services/patch-db/patch-db.factory' import { HttpService } from './services/http.service' import { ConfigService } from './services/config.service' import { QRCodeModule } from 'angularx-qrcode' import { appConfigComponents } from './modals/app-config-injectable' import { OSWelcomePageModule } from './modals/os-welcome/os-welcome.module' import { MarkdownPageModule } from './modals/markdown/markdown.module' -import { PatchDbModel } from './services/patch-db/patch-db.service' +import { PatchDbService } from './services/patch-db/patch-db.service' import { LocalStorageBootstrap } from './services/patch-db/local-storage-bootstrap' import { SharingModule } from './modules/sharing.module' import { APP_CONFIG_COMPONENT_MAPPING } from './services/tracking-modal-controller.service' -import { MarketplaceApiService } from './services/api/marketplace-api.service' +import { MarketplaceApiService } from './services/api/marketplace/marketplace-api.service' @NgModule({ declarations: [AppComponent], @@ -45,8 +45,8 @@ import { MarketplaceApiService } from './services/api/marketplace-api.service' Storage, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, { provide: ApiService , useFactory: ApiServiceFactory, deps: [ConfigService, HttpService] }, { provide: ApiService , useFactory: ApiServiceFactory, deps: [ConfigService, HttpService] }, - { provide: MarketplaceApiService , useFactory: MarketplaceApiServiceFactory, deps: [ConfigService, HttpService, PatchDbModel] }, - { provide: PatchDbModel, useFactory: PatchDbModelFactory, deps: [ConfigService, LocalStorageBootstrap, ApiService] }, + { provide: MarketplaceApiService , useFactory: MarketplaceApiServiceFactory, deps: [ConfigService, HttpService, PatchDbService] }, + { provide: PatchDbService, useFactory: PatchDbServiceFactory, deps: [ConfigService, LocalStorageBootstrap, ApiService] }, { provide: APP_CONFIG_COMPONENT_MAPPING, useValue: appConfigComponents }, ], bootstrap: [AppComponent], diff --git a/ui/src/app/components/badge-menu-button/badge-menu.component.ts b/ui/src/app/components/badge-menu-button/badge-menu.component.ts index eac9e814b..507810d97 100644 --- a/ui/src/app/components/badge-menu-button/badge-menu.component.ts +++ b/ui/src/app/components/badge-menu-button/badge-menu.component.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { SplitPaneTracker } from 'src/app/services/split-pane.service' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { combineLatest, Subscription } from 'rxjs' @Component({ @@ -17,7 +17,7 @@ export class BadgeMenuComponent { constructor ( private readonly splitPane: SplitPaneTracker, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/components/install-wizard/dependents/dependents.component.ts b/ui/src/app/components/install-wizard/dependents/dependents.component.ts index b58e1780c..d439dcf37 100644 --- a/ui/src/app/components/install-wizard/dependents/dependents.component.ts +++ b/ui/src/app/components/install-wizard/dependents/dependents.component.ts @@ -1,7 +1,7 @@ import { Component, Input, OnInit } from '@angular/core' import { BehaviorSubject, from, Subject } from 'rxjs' import { takeUntil, tap } from 'rxjs/operators' -import { Breakages } from 'src/app/services/api/api-types' +import { Breakages } from 'src/app/services/api/api.types' import { markAsLoadingDuring$ } from 'src/app/services/loader.service' import { capitalizeFirstLetter, isEmptyObject } from 'src/app/util/misc.util' import { Loadable } from '../loadable' diff --git a/ui/src/app/components/install-wizard/notes/notes.component.html b/ui/src/app/components/install-wizard/notes/notes.component.html index 880f9cf35..0cb01d813 100644 --- a/ui/src/app/components/install-wizard/notes/notes.component.html +++ b/ui/src/app/components/install-wizard/notes/notes.component.html @@ -1,8 +1,9 @@
- - {{ params.title }} + +

{{ params.title }}

+

{{ params.headline }}

diff --git a/ui/src/app/components/install-wizard/notes/notes.component.ts b/ui/src/app/components/install-wizard/notes/notes.component.ts index 6b9126886..bdf913f4e 100644 --- a/ui/src/app/components/install-wizard/notes/notes.component.ts +++ b/ui/src/app/components/install-wizard/notes/notes.component.ts @@ -12,6 +12,7 @@ export class NotesComponent implements OnInit, Loadable { notes: { [version: string]: string } title: string titleColor: string + headline: string } loading$ = new BehaviorSubject(false) diff --git a/ui/src/app/components/install-wizard/prebaked-wizards.ts b/ui/src/app/components/install-wizard/prebaked-wizards.ts index 0438b436c..5836b00f6 100644 --- a/ui/src/app/components/install-wizard/prebaked-wizards.ts +++ b/ui/src/app/components/install-wizard/prebaked-wizards.ts @@ -1,8 +1,8 @@ import { Injectable } from '@angular/core' import { PackageDataEntry } from 'src/app/services/patch-db/data-model' -import { Breakages } from 'src/app/services/api/api-types' +import { Breakages } from 'src/app/services/api/api.types' import { exists } from 'src/app/util/misc.util' -import { ApiService } from '../../services/api/api.service' +import { ApiService } from '../../services/api/embassy/embassy-api.service' import { InstallWizardComponent, SlideDefinition, TopbarParams } from './install-wizard.component' @Injectable({ providedIn: 'root' }) @@ -12,7 +12,10 @@ export class WizardBaker { ) { } install (values: { - id: string, title: string, version: string, installAlert?: string + id: string + title: string + version: string + installAlert?: string }): InstallWizardComponent['params'] { const { id, title, version, installAlert } = values @@ -53,7 +56,10 @@ export class WizardBaker { } update (values: { - id: string, title: string, version: string, installAlert?: string + id: string + title: string + version: string + installAlert?: string }): InstallWizardComponent['params'] { const { id, title, version, installAlert } = values @@ -111,9 +117,11 @@ export class WizardBaker { } updateOS (values: { - version: string, releaseNotes: { [version: string]: string } + version: string + releaseNotes: { [version: string]: string } + headline: string }): InstallWizardComponent['params'] { - const { version, releaseNotes } = values + const { version, releaseNotes, headline } = values const action = 'update' const title = 'EmbassyOS' @@ -127,6 +135,7 @@ export class WizardBaker { notes: releaseNotes, title: 'Release Notes', titleColor: 'dark', + headline, }, }, bottomBar: { @@ -153,7 +162,10 @@ export class WizardBaker { } downgrade (values: { - id: string, title: string, version: string, installAlert?: string + id: string + title: string + version: string + installAlert?: string }): InstallWizardComponent['params'] { const { id, title, version, installAlert } = values @@ -205,7 +217,10 @@ export class WizardBaker { } uninstall (values: { - id: string, title: string, version: string, uninstallAlert?: string + id: string + title: string + version: string + uninstallAlert?: string }): InstallWizardComponent['params'] { const { id, title, version, uninstallAlert } = values @@ -253,7 +268,10 @@ export class WizardBaker { } stop (values: { - breakages: Breakages, id: string, title: string, version: string + id: string + title: string + version: string + breakages: Breakages }): InstallWizardComponent['params'] { const { breakages, title, version } = values @@ -277,7 +295,10 @@ export class WizardBaker { return { toolbar, slideDefinitions } } - configure (values: { breakages: Breakages, pkg: PackageDataEntry }): InstallWizardComponent['params'] { + configure (values: { + pkg: PackageDataEntry + breakages: Breakages + }): InstallWizardComponent['params'] { const { breakages, pkg } = values const { title, version } = pkg.manifest const action = 'configure' diff --git a/ui/src/app/guards/maintenance.guard.ts b/ui/src/app/guards/maintenance.guard.ts index 4368cc304..b234b48af 100644 --- a/ui/src/app/guards/maintenance.guard.ts +++ b/ui/src/app/guards/maintenance.guard.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { CanActivate, Router, CanActivateChild } from '@angular/router' import { tap } from 'rxjs/operators' import { ServerStatus } from '../services/patch-db/data-model' -import { PatchDbModel } from '../services/patch-db/patch-db.service' +import { PatchDbService } from '../services/patch-db/patch-db.service' @Injectable({ providedIn: 'root', @@ -10,7 +10,7 @@ import { PatchDbModel } from '../services/patch-db/patch-db.service' export class MaintenanceGuard implements CanActivate, CanActivateChild { constructor ( private readonly router: Router, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } canActivate (): boolean { diff --git a/ui/src/app/guards/unmaintenance.guard.ts b/ui/src/app/guards/unmaintenance.guard.ts index 8abc33a03..884946ba2 100644 --- a/ui/src/app/guards/unmaintenance.guard.ts +++ b/ui/src/app/guards/unmaintenance.guard.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { CanActivate, Router } from '@angular/router' import { tap } from 'rxjs/operators' import { ServerStatus } from '../services/patch-db/data-model' -import { PatchDbModel } from '../services/patch-db/patch-db.service' +import { PatchDbService } from '../services/patch-db/patch-db.service' @Injectable({ providedIn: 'root', @@ -12,7 +12,7 @@ export class UnmaintenanceGuard implements CanActivate { constructor ( private readonly router: Router, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { this.patch.sequence$.subscribe(_ => { this.serverStatus = this.patch.data['server-info'].status diff --git a/ui/src/app/modals/markdown/markdown.page.ts b/ui/src/app/modals/markdown/markdown.page.ts index 3f7efb35a..781d82f01 100644 --- a/ui/src/app/modals/markdown/markdown.page.ts +++ b/ui/src/app/modals/markdown/markdown.page.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core' import { ModalController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ diff --git a/ui/src/app/modals/os-welcome/os-welcome.page.ts b/ui/src/app/modals/os-welcome/os-welcome.page.ts index 67af67eeb..ca5e89e70 100644 --- a/ui/src/app/modals/os-welcome/os-welcome.page.ts +++ b/ui/src/app/modals/os-welcome/os-welcome.page.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core' import { ModalController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ConfigService } from 'src/app/services/config.service' @Component({ diff --git a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts index b647bc1b9..60a07091b 100644 --- a/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts +++ b/ui/src/app/pages/apps-routes/app-actions/app-actions.page.ts @@ -1,10 +1,10 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { AlertController, IonContent, ModalController, NavController } from '@ionic/angular' import { LoaderService } from 'src/app/services/loader.service' import { HttpErrorResponse } from '@angular/common/http' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { Action, Manifest, PackageDataEntry, PackageMainStatus } from 'src/app/services/patch-db/data-model' import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component' import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards' @@ -32,7 +32,7 @@ export class AppActionsPage { private readonly loaderService: LoaderService, private readonly wizardBaker: WizardBaker, private readonly navCtrl: NavController, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-config/app-config.page.ts b/ui/src/app/pages/apps-routes/app-config/app-config.page.ts index f831bfa5f..5b79fbba2 100644 --- a/ui/src/app/pages/apps-routes/app-config/app-config.page.ts +++ b/ui/src/app/pages/apps-routes/app-config/app-config.page.ts @@ -1,7 +1,7 @@ import { Component, ViewChild } from '@angular/core' import { NavController, AlertController, ModalController, IonContent } from '@ionic/angular' import { ActivatedRoute } from '@angular/router' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { isEmptyObject, Recommendation } from 'src/app/util/misc.util' import { LoaderService } from 'src/app/services/loader.service' import { TrackingModalController } from 'src/app/services/tracking-modal-controller.service' @@ -12,7 +12,7 @@ import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards' import { ConfigSpec } from 'src/app/pkg-config/config-types' import { ConfigCursor } from 'src/app/pkg-config/config-cursor' import { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' @Component({ selector: 'app-config', @@ -55,7 +55,7 @@ export class AppConfigPage { private readonly alertCtrl: AlertController, private readonly modalController: ModalController, private readonly trackingModalCtrl: TrackingModalController, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } async ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.ts b/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.ts index d4e71c4d2..54ee897b5 100644 --- a/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.ts +++ b/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.ts @@ -1,8 +1,8 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { IonContent } from '@ionic/angular' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' -import { ApiService } from 'src/app/services/api/api.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ @@ -20,7 +20,7 @@ export class AppInstructionsPage { private readonly route: ActivatedRoute, private readonly errToast: ErrorToastService, private readonly apiService: ApiService, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } async ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts b/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts index c2529dffb..8fc38f34d 100644 --- a/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts +++ b/ui/src/app/pages/apps-routes/app-interfaces/app-interfaces.page.ts @@ -3,7 +3,7 @@ import { ActivatedRoute } from '@angular/router' import { IonContent, ToastController } from '@ionic/angular' import { Subscription } from 'rxjs' import { InstalledPackageDataEntry, PackageDataEntry } from 'src/app/services/patch-db/data-model' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { ConfigService } from 'src/app/services/config.service' import { copyToClipboard } from 'src/app/util/web.util' @@ -22,7 +22,7 @@ export class AppInterfacesPage { private readonly route: ActivatedRoute, private readonly toastCtrl: ToastController, private readonly config: ConfigService, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts index 62afbea2e..55c972cdd 100644 --- a/ui/src/app/pages/apps-routes/app-list/app-list.page.ts +++ b/ui/src/app/pages/apps-routes/app-list/app-list.page.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' import { ConfigService } from 'src/app/services/config.service' import { ConnectionService } from 'src/app/services/connection.service' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { PackageDataEntry } from 'src/app/services/patch-db/data-model' import { combineLatest, Subscription } from 'rxjs' import { PkgStatusRendering, renderPkgStatus } from 'src/app/services/pkg-status-rendering.service' @@ -25,7 +25,7 @@ export class AppListPage { constructor ( private readonly config: ConfigService, public readonly connectionService: ConnectionService, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-logs/app-logs.page.ts b/ui/src/app/pages/apps-routes/app-logs/app-logs.page.ts index f13747e4d..99c71cdc8 100644 --- a/ui/src/app/pages/apps-routes/app-logs/app-logs.page.ts +++ b/ui/src/app/pages/apps-routes/app-logs/app-logs.page.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { IonContent } from '@ionic/angular' import { ErrorToastService } from 'src/app/services/error-toast.service' diff --git a/ui/src/app/pages/apps-routes/app-manifest/app-manifest.page.ts b/ui/src/app/pages/apps-routes/app-manifest/app-manifest.page.ts index 99b92350c..852ee7dfd 100644 --- a/ui/src/app/pages/apps-routes/app-manifest/app-manifest.page.ts +++ b/ui/src/app/pages/apps-routes/app-manifest/app-manifest.page.ts @@ -2,7 +2,7 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { Subscription } from 'rxjs' import { PackageDataEntry } from 'src/app/services/patch-db/data-model' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { getManifest } from 'src/app/services/config.service' import * as JsonPointer from 'json-pointer' import { IonContent } from '@ionic/angular' @@ -23,7 +23,7 @@ export class AppManifestPage { constructor ( private readonly route: ActivatedRoute, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.ts b/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.ts index 6ab0cfa33..f3ceefa98 100644 --- a/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.ts +++ b/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.ts @@ -1,11 +1,11 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { IonContent } from '@ionic/angular' -import { Metric } from 'src/app/services/api/api-types' -import { ApiService } from 'src/app/services/api/api.service' +import { Metric } from 'src/app/services/api/api.types' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ErrorToastService } from 'src/app/services/error-toast.service' import { PackageDataEntry } from 'src/app/services/patch-db/data-model' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { pauseFor } from 'src/app/util/misc.util' @Component({ @@ -25,7 +25,7 @@ export class AppMetricsPage { constructor ( private readonly route: ActivatedRoute, private readonly errToast: ErrorToastService, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, private readonly apiService: ApiService, ) { } diff --git a/ui/src/app/pages/apps-routes/app-properties/app-properties.page.ts b/ui/src/app/pages/apps-routes/app-properties/app-properties.page.ts index eeb64510b..775c7c031 100644 --- a/ui/src/app/pages/apps-routes/app-properties/app-properties.page.ts +++ b/ui/src/app/pages/apps-routes/app-properties/app-properties.page.ts @@ -1,12 +1,12 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { Subscription } from 'rxjs' import { copyToClipboard } from 'src/app/util/web.util' import { AlertController, IonContent, NavController, PopoverController, ToastController } from '@ionic/angular' import { PackageProperties } from 'src/app/util/properties.util' import { QRComponent } from 'src/app/components/qr/qr.component' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { PackageMainStatus } from 'src/app/services/patch-db/data-model' import { ErrorToastService } from 'src/app/services/error-toast.service' import * as JsonPointer from 'json-pointer' @@ -36,7 +36,7 @@ export class AppPropertiesPage { private readonly toastCtrl: ToastController, private readonly popoverCtrl: PopoverController, private readonly navCtrl: NavController, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } async ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts b/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts index 903763657..53ddddaf7 100644 --- a/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts +++ b/ui/src/app/pages/apps-routes/app-restore/app-restore.page.ts @@ -1,10 +1,10 @@ import { Component, ViewChild } from '@angular/core' import { IonContent, LoadingController, ModalController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { BackupConfirmationComponent } from 'src/app/modals/backup-confirmation/backup-confirmation.component' -import { DiskInfo } from 'src/app/services/api/api-types' +import { DiskInfo } from 'src/app/services/api/api.types' import { ActivatedRoute } from '@angular/router' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' @Component({ @@ -28,7 +28,7 @@ export class AppRestorePage { private readonly modalCtrl: ModalController, private readonly apiService: ApiService, private readonly loadingCtrl: LoadingController, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts index 8597fd203..120ce4083 100644 --- a/ui/src/app/pages/apps-routes/app-show/app-show.page.ts +++ b/ui/src/app/pages/apps-routes/app-show/app-show.page.ts @@ -1,6 +1,6 @@ import { Component, ViewChild } from '@angular/core' import { AlertController, NavController, ModalController, IonContent } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ActivatedRoute, NavigationExtras } from '@angular/router' import { chill, isEmptyObject, Recommendation } from 'src/app/util/misc.util' import { LoaderService } from 'src/app/services/loader.service' @@ -8,7 +8,7 @@ import { combineLatest, Observable, of, Subscription } from 'rxjs' import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component' import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards' import { ConfigService } from 'src/app/services/config.service' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { DependencyErrorConfigUnsatisfied, DependencyErrorNotInstalled, DependencyErrorType, PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model' import { FEStatus, PkgStatusRendering, renderPkgStatus } from 'src/app/services/pkg-status-rendering.service' import { ConnectionService } from 'src/app/services/connection.service' @@ -43,7 +43,7 @@ export class AppShowPage { private readonly apiService: ApiService, private readonly wizardBaker: WizardBaker, private readonly config: ConfigService, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, public readonly connectionService: ConnectionService, ) { } diff --git a/ui/src/app/pages/maintenance/maintenance.page.ts b/ui/src/app/pages/maintenance/maintenance.page.ts index bee3a1204..7edc359fc 100644 --- a/ui/src/app/pages/maintenance/maintenance.page.ts +++ b/ui/src/app/pages/maintenance/maintenance.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { ServerStatus } from 'src/app/services/patch-db/data-model' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' @Component({ selector: 'Maintenance', @@ -11,7 +11,7 @@ export class MaintenancePage { ServerStatus = ServerStatus constructor ( - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } } diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts index 643158cfc..d96e6274e 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.ts @@ -1,14 +1,14 @@ import { Component, ViewChild } from '@angular/core' -import { MarketplaceData, MarketplaceEOS, MarketplacePkg } from 'src/app/services/api/api-types' +import { MarketplaceData, MarketplaceEOS, MarketplacePkg } from 'src/app/services/api/api.types' import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component' import { IonContent, ModalController } from '@ionic/angular' import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { PackageState } from 'src/app/services/patch-db/data-model' import { Subscription } from 'rxjs' import { ErrorToastService } from 'src/app/services/error-toast.service' import { MarketplaceService } from '../marketplace.service' -import { MarketplaceApiService } from 'src/app/services/api/marketplace-api.service' +import { MarketplaceApiService } from 'src/app/services/api/marketplace/marketplace-api.service' @Component({ selector: 'marketplace-list', @@ -41,7 +41,7 @@ export class MarketplaceListPage { private readonly modalCtrl: ModalController, private readonly errToast: ErrorToastService, private readonly wizardBaker: WizardBaker, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } async ngOnInit () { @@ -91,6 +91,7 @@ export class MarketplaceListPage { this.modalCtrl, this.wizardBaker.updateOS({ version: this.eos.version, + headline: this.eos.headline, releaseNotes: this.eos['release-notes'], }), ) diff --git a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts index 72a8184ec..d69f960f3 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.ts @@ -6,7 +6,7 @@ import { WizardBaker } from 'src/app/components/install-wizard/prebaked-wizards' import { Emver } from 'src/app/services/emver.service' import { displayEmver } from 'src/app/pipes/emver.pipe' import { pauseFor, Recommendation } from 'src/app/util/misc.util' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { ErrorToastService } from 'src/app/services/error-toast.service' import { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model' import { MarketplaceService } from '../marketplace.service' @@ -37,7 +37,7 @@ export class MarketplaceShowPage { private readonly wizardBaker: WizardBaker, private readonly navCtrl: NavController, private readonly emver: Emver, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, private readonly marketplaceService: MarketplaceService, ) { } diff --git a/ui/src/app/pages/marketplace-routes/marketplace.service.ts b/ui/src/app/pages/marketplace-routes/marketplace.service.ts index 1476c79b4..9a2a5aff7 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace.service.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' -import { MarketplacePkg } from 'src/app/services/api/api-types' -import { MarketplaceApiService } from 'src/app/services/api/marketplace-api.service' +import { MarketplacePkg } from 'src/app/services/api/api.types' +import { MarketplaceApiService } from 'src/app/services/api/marketplace/marketplace-api.service' @Injectable({ providedIn: 'root', diff --git a/ui/src/app/pages/notifications/notifications.page.ts b/ui/src/app/pages/notifications/notifications.page.ts index 9b92d657d..f14657073 100644 --- a/ui/src/app/pages/notifications/notifications.page.ts +++ b/ui/src/app/pages/notifications/notifications.page.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { LoaderService } from 'src/app/services/loader.service' -import { ServerNotification, ServerNotifications } from 'src/app/services/api/api-types' +import { ServerNotification, ServerNotifications } from 'src/app/services/api/api.types' import { AlertController } from '@ionic/angular' import { ActivatedRoute } from '@angular/router' import { ErrorToastService } from 'src/app/services/error-toast.service' diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts b/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts index 4e36df01e..529e46ed9 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts +++ b/ui/src/app/pages/server-routes/developer-routes/dev-options/dev-options.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { ServerConfigService } from 'src/app/services/server-config.service' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' @Component({ selector: 'dev-options', @@ -11,7 +11,7 @@ export class DevOptionsPage { constructor ( private readonly serverConfigService: ServerConfigService, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } async presentModalValueEdit (key: string, current?: any): Promise { diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.ts b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.ts index 3383bd6d3..04e428262 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.ts +++ b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.ts @@ -4,7 +4,7 @@ import { AlertController } from '@ionic/angular' import { LoaderService } from 'src/app/services/loader.service' import { SSHService } from './ssh.service' import { Subscription } from 'rxjs' -import { SSHKeys } from 'src/app/services/api/api-types' +import { SSHKeys } from 'src/app/services/api/api.types' import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/ssh.service.ts b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/ssh.service.ts index 50fd6d949..fff7918e7 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/ssh.service.ts +++ b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/ssh.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { BehaviorSubject } from 'rxjs' -import { SSHKeys } from 'src/app/services/api/api-types' -import { ApiService } from 'src/app/services/api/api.service' +import { SSHKeys } from 'src/app/services/api/api.types' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' @Injectable({ providedIn: 'root', diff --git a/ui/src/app/pages/server-routes/lan/lan.page.ts b/ui/src/app/pages/server-routes/lan/lan.page.ts index f3091ffa5..f76b2b6e5 100644 --- a/ui/src/app/pages/server-routes/lan/lan.page.ts +++ b/ui/src/app/pages/server-routes/lan/lan.page.ts @@ -3,8 +3,8 @@ import { isPlatform, ToastController } from '@ionic/angular' import { copyToClipboard } from 'src/app/util/web.util' import { ConfigService } from 'src/app/services/config.service' import { LoaderService } from 'src/app/services/loader.service' -import { ApiService } from 'src/app/services/api/api.service' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' @Component({ @@ -27,7 +27,7 @@ export class LANPage { private readonly config: ConfigService, private readonly loader: LoaderService, private readonly apiService: ApiService, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } ngOnInit () { diff --git a/ui/src/app/pages/server-routes/privacy/privacy.page.ts b/ui/src/app/pages/server-routes/privacy/privacy.page.ts index 7344fb3f3..99aa55768 100644 --- a/ui/src/app/pages/server-routes/privacy/privacy.page.ts +++ b/ui/src/app/pages/server-routes/privacy/privacy.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { ServerConfigService } from 'src/app/services/server-config.service' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' import { ConfigService } from 'src/app/services/config.service' @@ -15,7 +15,7 @@ export class PrivacyPage { constructor ( private readonly serverConfigService: ServerConfigService, public readonly config: ConfigService, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } async presentModalValueEdit (key: string, current?: string): Promise { diff --git a/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts b/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts index 9133c192e..e0b4b156d 100644 --- a/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts +++ b/ui/src/app/pages/server-routes/server-backup/server-backup.page.ts @@ -1,8 +1,8 @@ import { Component } from '@angular/core' import { LoadingController, ModalController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { BackupConfirmationComponent } from 'src/app/modals/backup-confirmation/backup-confirmation.component' -import { DiskInfo } from 'src/app/services/api/api-types' +import { DiskInfo } from 'src/app/services/api/api.types' @Component({ selector: 'server-backup', diff --git a/ui/src/app/pages/server-routes/server-logs/server-logs.page.ts b/ui/src/app/pages/server-routes/server-logs/server-logs.page.ts index f0b79c93c..c5b1b1d1d 100644 --- a/ui/src/app/pages/server-routes/server-logs/server-logs.page.ts +++ b/ui/src/app/pages/server-routes/server-logs/server-logs.page.ts @@ -1,5 +1,5 @@ import { Component, ViewChild } from '@angular/core' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { IonContent } from '@ionic/angular' import { ErrorToastService } from 'src/app/services/error-toast.service' diff --git a/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.ts b/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.ts index 84cd72822..2c3056fbe 100644 --- a/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.ts +++ b/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' -import { Metrics } from 'src/app/services/api/api-types' -import { ApiService } from 'src/app/services/api/api.service' +import { Metrics } from 'src/app/services/api/api.types' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ErrorToastService } from 'src/app/services/error-toast.service' import { pauseFor } from 'src/app/util/misc.util' diff --git a/ui/src/app/pages/server-routes/server-show/server-show.page.ts b/ui/src/app/pages/server-routes/server-show/server-show.page.ts index e3a7bab6c..6e04e424e 100644 --- a/ui/src/app/pages/server-routes/server-show/server-show.page.ts +++ b/ui/src/app/pages/server-routes/server-show/server-show.page.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' import { LoadingOptions } from '@ionic/core' import { AlertController, NavController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { LoaderService } from 'src/app/services/loader.service' import { ActivatedRoute } from '@angular/router' diff --git a/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts b/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts index 8dadb6d80..9aa535b81 100644 --- a/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts +++ b/ui/src/app/pages/server-routes/server-specs/server-specs.page.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' import { ToastController } from '@ionic/angular' import { copyToClipboard } from 'src/app/util/web.util' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' @Component({ @@ -14,7 +14,7 @@ export class ServerSpecsPage { constructor ( private readonly toastCtrl: ToastController, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } async copy (address: string) { diff --git a/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.ts b/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.ts index acc86d8d4..347abe6b2 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.ts +++ b/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.ts @@ -1,6 +1,6 @@ import { Component } from '@angular/core' import { NavController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { WifiService } from '../wifi.service' import { LoaderService } from 'src/app/services/loader.service' import { ErrorToastService } from 'src/app/services/error-toast.service' diff --git a/ui/src/app/pages/server-routes/wifi/wifi.page.ts b/ui/src/app/pages/server-routes/wifi/wifi.page.ts index 209ce95fe..133a70f72 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.page.ts +++ b/ui/src/app/pages/server-routes/wifi/wifi.page.ts @@ -1,11 +1,11 @@ import { Component } from '@angular/core' import { ActionSheetController } from '@ionic/angular' -import { ApiService } from 'src/app/services/api/api.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' import { ActionSheetButton } from '@ionic/core' import { WifiService } from './wifi.service' import { LoaderService } from 'src/app/services/loader.service' import { WiFiInfo } from 'src/app/services/patch-db/data-model' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' import { Subscription } from 'rxjs' import { ErrorToastService } from 'src/app/services/error-toast.service' @@ -23,7 +23,7 @@ export class WifiListPage { private readonly errToast: ErrorToastService, private readonly actionCtrl: ActionSheetController, private readonly wifiService: WifiService, - public readonly patch: PatchDbModel, + public readonly patch: PatchDbService, ) { } async presentAction (ssid: string, wifi: WiFiInfo) { diff --git a/ui/src/app/pages/server-routes/wifi/wifi.service.ts b/ui/src/app/pages/server-routes/wifi/wifi.service.ts index 6add227c5..df4ca2599 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.service.ts +++ b/ui/src/app/pages/server-routes/wifi/wifi.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core' import { AlertController, ToastController } from '@ionic/angular' import { merge, Observable, timer } from 'rxjs' import { filter, map, take, tap } from 'rxjs/operators' -import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' +import { PatchDbService } from 'src/app/services/patch-db/patch-db.service' @Injectable({ providedIn: 'root', @@ -12,7 +12,7 @@ export class WifiService { constructor ( private readonly toastCtrl: ToastController, private readonly alertCtrl: AlertController, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } confirmWifi (ssid: string): Observable { diff --git a/ui/src/app/pipes/notification-color.pipe.ts b/ui/src/app/pipes/notification-color.pipe.ts index 4b2830ca6..6b48def86 100644 --- a/ui/src/app/pipes/notification-color.pipe.ts +++ b/ui/src/app/pipes/notification-color.pipe.ts @@ -1,5 +1,5 @@ import { Pipe, PipeTransform } from '@angular/core' -import { NotificationLevel, ServerNotification } from '../services/api/api-types' +import { NotificationLevel, ServerNotification } from '../services/api/api.types' @Pipe({ name: 'notificationColor', diff --git a/ui/src/app/pipes/status.pipe.ts b/ui/src/app/pipes/status.pipe.ts index 38a6ea55d..f9fe7eb5e 100644 --- a/ui/src/app/pipes/status.pipe.ts +++ b/ui/src/app/pipes/status.pipe.ts @@ -1,7 +1,7 @@ import { Pipe, PipeTransform } from '@angular/core' import { combineLatest, Observable } from 'rxjs' import { map } from 'rxjs/operators' -import { PatchDbModel } from '../services/patch-db/patch-db.service' +import { PatchDbService } from '../services/patch-db/patch-db.service' import { FEStatus, renderPkgStatus } from '../services/pkg-status-rendering.service' @Pipe({ @@ -10,7 +10,7 @@ import { FEStatus, renderPkgStatus } from '../services/pkg-status-rendering.serv export class StatusPipe implements PipeTransform { constructor ( - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } transform (pkgId: string): Observable { diff --git a/ui/src/app/services/api/mock-app-fixures.ts b/ui/src/app/services/api/api.fixures.ts similarity index 99% rename from ui/src/app/services/api/mock-app-fixures.ts rename to ui/src/app/services/api/api.fixures.ts index 46927bd52..c6a80ea4a 100644 --- a/ui/src/app/services/api/mock-app-fixures.ts +++ b/ui/src/app/services/api/api.fixures.ts @@ -1,5 +1,5 @@ import { DependencyErrorType, DockerIoFormat, Manifest, PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model' -import { MarketplacePkg, Metric, NotificationLevel, RR, ServerNotification, ServerNotifications } from './api-types' +import { MarketplacePkg, Metric, NotificationLevel, RR, ServerNotification, ServerNotifications } from './api.types' export module Mock { diff --git a/ui/src/app/services/api/api.service.factory.ts b/ui/src/app/services/api/api.service.factory.ts index d671fca03..ab80d4562 100644 --- a/ui/src/app/services/api/api.service.factory.ts +++ b/ui/src/app/services/api/api.service.factory.ts @@ -1,23 +1,23 @@ import { HttpService } from '../http.service' -import { MockApiService } from './mock-api.service' -import { LiveApiService } from './live-api.service' +import { MockApiService } from './embassy/embassy-mock-api.service' +import { LiveApiService } from './embassy/embassy-live-api.service' import { ConfigService } from '../config.service' -import { PatchDbModel } from '../patch-db/patch-db.service' -import { MarketplaceLiveApiService } from './marketplace-live-api.service' -import { MarketplaceMockApiService } from './marketplace-mock-api.service' +import { PatchDbService } from '../patch-db/patch-db.service' +import { MarketplaceLiveApiService } from './marketplace/marketplace-live-api.service' +import { MarketplaceMockApiService } from './marketplace/marketplace-mock-api.service' export function ApiServiceFactory (config: ConfigService, http: HttpService) { if (config.mocks.enabled) { - return new MockApiService(config, http) + return new MockApiService(http, config) } else { - return new LiveApiService(config, http) + return new LiveApiService(http, config) } } -export function MarketplaceApiServiceFactory (config: ConfigService, http: HttpService, patch: PatchDbModel) { +export function MarketplaceApiServiceFactory (config: ConfigService, http: HttpService, patch: PatchDbService) { if (config.mocks.enabled) { - return new MarketplaceMockApiService(http, patch) + return new MarketplaceMockApiService(http, config, patch) } else { - return new MarketplaceLiveApiService(http, patch) + return new MarketplaceLiveApiService(http, config, patch) } } \ No newline at end of file diff --git a/ui/src/app/services/api/api-types.ts b/ui/src/app/services/api/api.types.ts similarity index 97% rename from ui/src/app/services/api/api-types.ts rename to ui/src/app/services/api/api.types.ts index bc2ea2373..bc16e057f 100644 --- a/ui/src/app/services/api/api-types.ts +++ b/ui/src/app/services/api/api.types.ts @@ -167,7 +167,17 @@ export module RR { export type GetMarketplaceEOSReq = { } export type GetMarketplaceEOSRes = MarketplaceEOS - export type GetMarketplacePackagesReq = { id?: string, version?: string, category?: string, query?: string, page?: string, 'per-page'?: string } + export type GetMarketplacePackagesReq = { + ids?: string[] + id?: string + // iff id + version?: string + // iff !id + category?: string + query?: string + page?: string + 'per-page'?: string + } export type GetMarketplacePackagesRes = MarketplacePkg[] export type GetReleaseNotesReq = { id: string } diff --git a/ui/src/app/services/api/api.service.ts b/ui/src/app/services/api/embassy/embassy-api.service.ts similarity index 99% rename from ui/src/app/services/api/api.service.ts rename to ui/src/app/services/api/embassy/embassy-api.service.ts index 2a84abd46..575494e8b 100644 --- a/ui/src/app/services/api/api.service.ts +++ b/ui/src/app/services/api/embassy/embassy-api.service.ts @@ -1,6 +1,6 @@ import { Subject, Observable } from 'rxjs' import { Http, Update, Operation, Revision, Source, Store } from 'patch-db-client' -import { RR } from './api-types' +import { RR } from '../api.types' import { DataModel } from 'src/app/services/patch-db/data-model' export abstract class ApiService implements Source, Http { diff --git a/ui/src/app/services/api/live-api.service.ts b/ui/src/app/services/api/embassy/embassy-live-api.service.ts similarity index 97% rename from ui/src/app/services/api/live-api.service.ts rename to ui/src/app/services/api/embassy/embassy-live-api.service.ts index a501adf44..f80eebb87 100644 --- a/ui/src/app/services/api/live-api.service.ts +++ b/ui/src/app/services/api/embassy/embassy-live-api.service.ts @@ -1,16 +1,16 @@ import { Injectable } from '@angular/core' -import { HttpService, Method } from '../http.service' -import { ApiService } from './api.service' -import { RR } from './api-types' +import { HttpService, Method } from '../../http.service' +import { ApiService } from './embassy-api.service' +import { RR } from '../api.types' import { parsePropertiesPermissive } from 'src/app/util/properties.util' -import { ConfigService } from '../config.service' +import { ConfigService } from '../../config.service' @Injectable() export class LiveApiService extends ApiService { constructor ( - private readonly config: ConfigService, private readonly http: HttpService, + private readonly config: ConfigService, ) { super() } async getStatic (url: string): Promise { diff --git a/ui/src/app/services/api/mock-api.service.ts b/ui/src/app/services/api/embassy/embassy-mock-api.service.ts similarity index 97% rename from ui/src/app/services/api/mock-api.service.ts rename to ui/src/app/services/api/embassy/embassy-mock-api.service.ts index 4b835a652..1c5f54d1f 100644 --- a/ui/src/app/services/api/mock-api.service.ts +++ b/ui/src/app/services/api/embassy/embassy-mock-api.service.ts @@ -1,22 +1,22 @@ import { Injectable } from '@angular/core' -import { pauseFor } from '../../util/misc.util' -import { ApiService } from './api.service' +import { pauseFor } from '../../../util/misc.util' +import { ApiService } from './embassy-api.service' import { PatchOp } from 'patch-db-client' import { PackageDataEntry, PackageMainStatus, PackageState, ServerStatus } from 'src/app/services/patch-db/data-model' -import { RR, WithRevision } from './api-types' +import { RR, WithRevision } from '../api.types' import { parsePropertiesPermissive } from 'src/app/util/properties.util' -import { Mock } from './mock-app-fixures' -import { HttpService } from '../http.service' +import { Mock } from '../api.fixures' +import { HttpService } from '../../http.service' import markdown from 'raw-loader!src/assets/markdown/md-sample.md' -import { ConfigService } from '../config.service' +import { ConfigService } from '../../config.service' @Injectable() export class MockApiService extends ApiService { welcomeAck = false constructor ( - private readonly config: ConfigService, private readonly http: HttpService, + private readonly config: ConfigService, ) { super() } async getStatic (url: string): Promise { diff --git a/ui/src/app/services/api/marketplace-api.service.ts b/ui/src/app/services/api/marketplace-api.service.ts deleted file mode 100644 index dff685697..000000000 --- a/ui/src/app/services/api/marketplace-api.service.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { RR } from './api-types' -// import { DataModel } from 'src/app/services/patch-db/data-model' -import { DataModel } from '../../../../src/app/services/patch-db/data-model' - -export abstract class MarketplaceApiService { - abstract getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise - - abstract getEos (params: RR.GetMarketplaceEOSReq): Promise - - abstract getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise - - abstract getReleaseNotes (params: RR.GetReleaseNotesReq): Promise - -} - -export function getMarketURL (eosOrPackage: 'eos' | 'package', data: DataModel): string { - const eosMarketplace = data['server-info']['eos-marketplace'] - if (eosOrPackage === 'eos') { - return eosMarketplace - } else { - const packageMarketplace = data['server-info']['package-marketplace'] - return packageMarketplace || eosMarketplace - } -} \ No newline at end of file diff --git a/ui/src/app/services/api/marketplace-live-api.service.ts b/ui/src/app/services/api/marketplace-live-api.service.ts deleted file mode 100644 index f92c18478..000000000 --- a/ui/src/app/services/api/marketplace-live-api.service.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { Injectable } from '@angular/core' -import { HttpService } from '../http.service' -import { getMarketURL } from './marketplace-api.service' -import { RR } from './api-types' -import { MarketplaceApiService } from './marketplace-api.service' -import { PatchDbModel } from '../patch-db/patch-db.service' - -@Injectable() -export class MarketplaceLiveApiService extends MarketplaceApiService { - - constructor ( - private readonly http: HttpService, - private readonly patch: PatchDbModel, - ) { super() } - - async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise { - return this.http.simpleGet(getMarketURL('package', this.patch.data), params) - } - - async getEos (params: RR.GetMarketplaceEOSReq): Promise { - return this.http.simpleGet(getMarketURL('eos', this.patch.data), params) - } - - async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise { - return this.http.simpleGet(getMarketURL('package', this.patch.data), params) - } - - async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise { - return this.http.simpleGet(getMarketURL('package', this.patch.data), params) - } -} diff --git a/ui/src/app/services/api/marketplace/marketplace-api.service.ts b/ui/src/app/services/api/marketplace/marketplace-api.service.ts new file mode 100644 index 000000000..9baea6ee6 --- /dev/null +++ b/ui/src/app/services/api/marketplace/marketplace-api.service.ts @@ -0,0 +1,29 @@ +import { RR } from '../api.types' +import { ConfigService } from '../../config.service' +import { PatchDbService } from '../../patch-db/patch-db.service' + +export abstract class MarketplaceApiService { + + constructor ( + readonly config: ConfigService, + readonly patch: PatchDbService, + ) { } + + abstract getEos (params: RR.GetMarketplaceEOSReq): Promise + + abstract getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise + + abstract getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise + + abstract getReleaseNotes (params: RR.GetReleaseNotesReq): Promise + + getMarketplaceURL (type: 'eos' | 'package'): string { + const eosMarketplace = this.patch.data['server-info']['eos-marketplace'] || this.config.start9Marketplace.clearnet + if (type === 'eos') { + return eosMarketplace + } else { + const packageMarketplace = this.patch.data['server-info']['package-marketplace'] + return packageMarketplace || eosMarketplace + } + } +} \ No newline at end of file diff --git a/ui/src/app/services/api/marketplace/marketplace-live-api.service.ts b/ui/src/app/services/api/marketplace/marketplace-live-api.service.ts new file mode 100644 index 000000000..54478e045 --- /dev/null +++ b/ui/src/app/services/api/marketplace/marketplace-live-api.service.ts @@ -0,0 +1,34 @@ +import { Injectable } from '@angular/core' +import { HttpService } from '../../http.service' +import { RR } from '../api.types' +import { MarketplaceApiService } from './marketplace-api.service' +import { PatchDbService } from '../../patch-db/patch-db.service' +import { ConfigService } from '../../config.service' + +@Injectable() +export class MarketplaceLiveApiService extends MarketplaceApiService { + + constructor ( + private readonly http: HttpService, + config: ConfigService, + patch: PatchDbService, + ) { + super(config, patch) + } + + async getEos (params: RR.GetMarketplaceEOSReq): Promise { + return this.http.simpleGet(this.getMarketplaceURL('eos'), params) + } + + async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise { + return this.http.simpleGet(this.getMarketplaceURL('package'), params) + } + + async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise { + return this.http.simpleGet(this.getMarketplaceURL('package'), params) + } + + async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise { + return this.http.simpleGet(this.getMarketplaceURL('package'), params) + } +} diff --git a/ui/src/app/services/api/marketplace-mock-api.service.ts b/ui/src/app/services/api/marketplace/marketplace-mock-api.service.ts similarity index 57% rename from ui/src/app/services/api/marketplace-mock-api.service.ts rename to ui/src/app/services/api/marketplace/marketplace-mock-api.service.ts index c98facd45..7803b8106 100644 --- a/ui/src/app/services/api/marketplace-mock-api.service.ts +++ b/ui/src/app/services/api/marketplace/marketplace-mock-api.service.ts @@ -1,62 +1,68 @@ import { Injectable } from '@angular/core' -import { pauseFor } from '../../util/misc.util' -import { RR } from './api-types' -import { Mock } from './mock-app-fixures' -import { HttpService } from '../http.service' +import { pauseFor } from '../../../util/misc.util' +import { RR } from '../api.types' +import { Mock } from '../api.fixures' +import { HttpService } from '../../http.service' import { MarketplaceApiService } from './marketplace-api.service' -import { getMarketURL } from './marketplace-api.service' -import { PatchDbModel } from '../patch-db/patch-db.service' +import { PatchDbService } from '../../patch-db/patch-db.service' +import { ConfigService } from '../../config.service' @Injectable() export class MarketplaceMockApiService extends MarketplaceApiService { - welcomeAck = false constructor ( private readonly http: HttpService, - private readonly patch: PatchDbModel, - ) { super() } + config: ConfigService, + patch: PatchDbService, + ) { + super(config, patch) + } // marketplace + async getEos (params: RR.GetMarketplaceEOSReq): Promise { + let url = this.getMarketplaceURL('eos') + if (this.useLocal(url)) { + await pauseFor(2000) + return Mock.MarketplaceEos + } + url = `${url}/sys/version/eos` + return this.http.simpleGet(url) + } + async getMarketplaceData (params: RR.GetMarketplaceDataReq): Promise { - const registryURL = getMarketURL('package', this.patch.data) - if (!registryURL) { + let url = this.getMarketplaceURL('package') + if (this.useLocal(url)) { await pauseFor(2000) return { categories: ['featured', 'bitcoin', 'lightning', 'data', 'messaging', 'social', 'alt coin'], } } - const url = `${registryURL}/marketplace/data` + url = `${url}/marketplace/data` return this.http.simpleGet(url) } - async getEos (params: RR.GetMarketplaceEOSReq): Promise { - const registryURL = getMarketURL('eos', this.patch.data) - if (!registryURL) { - await pauseFor(2000) - return Mock.MarketplaceEos - } - const url = `${registryURL}/sys/version/eos` - return this.http.simpleGet(url) - } - async getMarketplacePkgs (params: RR.GetMarketplacePackagesReq): Promise { - const registryURL = getMarketURL('package', this.patch.data) - if (!registryURL) { + let url = this.getMarketplaceURL('package') + if (this.useLocal(url)) { await pauseFor(2000) return Mock.AvailableList } - const url = `${registryURL}/marketplace/packages` + url = `${url}/marketplace/packages` return this.http.simpleGet(url, params) } async getReleaseNotes (params: RR.GetReleaseNotesReq): Promise { - const registryURL = getMarketURL('package', this.patch.data) - if (!registryURL) { + let url = this.getMarketplaceURL('package') + if (this.useLocal(url)) { await pauseFor(2000) return Mock.ReleaseNotes } - const url = `${registryURL}/marketplace/release-notes` + url = `${url}/marketplace/release-notes` return this.http.simpleGet(url) } + + private useLocal (url: string): boolean { + return !url || this.config.mocks.marketplace + } } diff --git a/ui/src/app/services/auth.service.ts b/ui/src/app/services/auth.service.ts index 725a64d41..15be57add 100644 --- a/ui/src/app/services/auth.service.ts +++ b/ui/src/app/services/auth.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core' import { BehaviorSubject, Observable } from 'rxjs' import { distinctUntilChanged } from 'rxjs/operators' -import { ApiService } from './api/api.service' +import { ApiService } from './api/embassy/embassy-api.service' import { Storage } from '@ionic/storage' export enum AuthState { diff --git a/ui/src/app/services/config.service.ts b/ui/src/app/services/config.service.ts index ae3ef9b10..4f8dd8ed2 100644 --- a/ui/src/app/services/config.service.ts +++ b/ui/src/app/services/config.service.ts @@ -19,6 +19,7 @@ type UiConfig = { } mocks: { enabled: boolean + marketplace: boolean connection: 'ws' | 'poll' rpcPort: number wsPort: number diff --git a/ui/src/app/services/connection.service.ts b/ui/src/app/services/connection.service.ts index cbd9007d8..c8e20a160 100644 --- a/ui/src/app/services/connection.service.ts +++ b/ui/src/app/services/connection.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { BehaviorSubject, combineLatest, fromEvent, merge, Subscription } from 'rxjs' -import { ConnectionStatus, PatchDbModel } from './patch-db/patch-db.service' +import { ConnectionStatus, PatchDbService } from './patch-db/patch-db.service' import { HttpService, Method } from './http.service' import { distinctUntilChanged } from 'rxjs/operators' import { ConfigService } from './config.service' @@ -16,7 +16,7 @@ export class ConnectionService { constructor ( private readonly httpService: HttpService, private readonly configService: ConfigService, - private readonly patch: PatchDbModel, + private readonly patch: PatchDbService, ) { } watchFailure$ () { diff --git a/ui/src/app/services/patch-db/patch-db.factory.ts b/ui/src/app/services/patch-db/patch-db.factory.ts index 313e8e31f..068a0fd25 100644 --- a/ui/src/app/services/patch-db/patch-db.factory.ts +++ b/ui/src/app/services/patch-db/patch-db.factory.ts @@ -2,14 +2,14 @@ import { PollSource, Source, WebsocketSource } from 'patch-db-client' import { ConfigService } from 'src/app/services/config.service' import { DataModel } from './data-model' import { LocalStorageBootstrap } from './local-storage-bootstrap' -import { PatchDbModel } from './patch-db.service' -import { ApiService } from 'src/app/services/api/api.service' +import { PatchDbService } from './patch-db.service' +import { ApiService } from 'src/app/services/api/embassy/embassy-api.service' -export function PatchDbModelFactory ( +export function PatchDbServiceFactory ( config: ConfigService, bootstrapper: LocalStorageBootstrap, apiService: ApiService, -): PatchDbModel { +): PatchDbService { const { mocks, patchDb: { poll }, isConsulate } = config @@ -31,5 +31,5 @@ export function PatchDbModelFactory ( } } - return new PatchDbModel(source, apiService, bootstrapper) + return new PatchDbService(source, apiService, bootstrapper) } \ No newline at end of file diff --git a/ui/src/app/services/patch-db/patch-db.service.ts b/ui/src/app/services/patch-db/patch-db.service.ts index 6a7cea320..1460debdc 100644 --- a/ui/src/app/services/patch-db/patch-db.service.ts +++ b/ui/src/app/services/patch-db/patch-db.service.ts @@ -2,7 +2,7 @@ import { Inject, Injectable, InjectionToken } from '@angular/core' import { Bootstrapper, PatchDB, Source, Store } from 'patch-db-client' import { BehaviorSubject, Observable, of, Subscription } from 'rxjs' import { catchError, debounceTime, finalize, map, tap } from 'rxjs/operators' -import { ApiService } from '../api/api.service' +import { ApiService } from '../api/embassy/embassy-api.service' import { DataModel } from './data-model' export const PATCH_HTTP = new InjectionToken>('app.config') @@ -18,7 +18,7 @@ export enum ConnectionStatus { @Injectable({ providedIn: 'root', }) -export class PatchDbModel { +export class PatchDbService { connectionStatus$ = new BehaviorSubject(ConnectionStatus.Initializing) sequence$: Observable data: DataModel diff --git a/ui/src/app/services/server-config.service.ts b/ui/src/app/services/server-config.service.ts index 1d1030d60..6408f17e4 100644 --- a/ui/src/app/services/server-config.service.ts +++ b/ui/src/app/services/server-config.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core' import { AppConfigValuePage } from '../modals/app-config-value/app-config-value.page' -import { ApiService } from './api/api.service' +import { ApiService } from './api/embassy/embassy-api.service' import { ConfigSpec } from '../pkg-config/config-types' import { ConfigCursor } from '../pkg-config/config-cursor' import { SSHService } from '../pages/server-routes/developer-routes/dev-ssh-keys/ssh.service' diff --git a/ui/src/app/services/startup-alerts.notifier.ts b/ui/src/app/services/startup-alerts.service.ts similarity index 62% rename from ui/src/app/services/startup-alerts.notifier.ts rename to ui/src/app/services/startup-alerts.service.ts index a9c09bee6..c71e5be15 100644 --- a/ui/src/app/services/startup-alerts.notifier.ts +++ b/ui/src/app/services/startup-alerts.service.ts @@ -4,60 +4,65 @@ import { wizardModal } from '../components/install-wizard/install-wizard.compone import { WizardBaker } from '../components/install-wizard/prebaked-wizards' import { OSWelcomePage } from '../modals/os-welcome/os-welcome.page' import { displayEmver } from '../pipes/emver.pipe' -import { ApiService } from './api/api.service' +import { RR } from './api/api.types' +import { MarketplaceApiService } from './api/marketplace/marketplace-api.service' +import { PatchDbService } from './patch-db/patch-db.service' import { ConfigService } from './config.service' import { Emver } from './emver.service' -import { OsUpdateService } from './os-update.service' -@Injectable({providedIn: 'root' }) -export class StartupAlertsNotifier { +@Injectable({ + providedIn: 'root', +}) +export class StartupAlertsService { + private checks: Check[] + constructor ( private readonly alertCtrl: AlertController, private readonly navCtrl: NavController, private readonly config: ConfigService, private readonly modalCtrl: ModalController, - private readonly apiService: ApiService, + private readonly marketplaceApi: MarketplaceApiService, private readonly emver: Emver, - private readonly osUpdateService: OsUpdateService, private readonly wizardBaker: WizardBaker, + private readonly patch: PatchDbService, ) { - const welcome: Check = { + const welcome: Check = { name: 'welcome', - shouldRun: s => this.shouldRunOsWelcome(s), - check: async s => s, - display: s => this.displayOsWelcome(s), + shouldRun: () => this.shouldRunOsWelcome(), + check: async () => true, + display: () => this.displayOsWelcome(), hasRun: this.config.skipStartupAlerts, } - const osUpdate: Check = { + const osUpdate: Check = { name: 'osUpdate', - shouldRun: s => this.shouldRunOsUpdateCheck(s), - check: s => this.osUpdateCheck(s), - display: vl => this.displayOsUpdateCheck(vl), + shouldRun: () => this.shouldRunOsUpdateCheck(), + check: () => this.osUpdateCheck(), + display: pkg => this.displayOsUpdateCheck(pkg), hasRun: this.config.skipStartupAlerts, } const apps: Check = { name: 'apps', - shouldRun: s => this.shouldRunAppsCheck(s), + shouldRun: () => this.shouldRunAppsCheck(), check: () => this.appsCheck(), display: () => this.displayAppsCheck(), hasRun: this.config.skipStartupAlerts, } - this.checks = [welcome, osUpdate, v1StatusUpdate, apps] + this.checks = [welcome, osUpdate, apps] } // This takes our three checks and filters down to those that should run. // Then, the reduce fires, quickly iterating through yielding a promise (previousDisplay) to the next element // Each promise fires more or less concurrently, so each c.check(server) is run concurrently - // Then, since we await previoudDisplay before c.display(res), each promise executing gets hung awaiting the display of the previous run - async runChecks (server: Readonly): Promise { + // Then, since we await previousDisplay before c.display(res), each promise executing gets hung awaiting the display of the previous run + async runChecks (): Promise { await this.checks - .filter(c => !c.hasRun && c.shouldRun(server)) + .filter(c => !c.hasRun && c.shouldRun()) // returning true in the below block means to continue to next modal // returning false means to skip all subsequent modals .reduce(async (previousDisplay, c) => { let checkRes: any try { - checkRes = await c.check(server) + checkRes = await c.check() } catch (e) { console.error(`Exception in ${c.name} check:`, e) return true @@ -70,44 +75,49 @@ export class StartupAlertsNotifier { }, Promise.resolve(true)) } - checks: Check[] - - private shouldRunOsWelcome (s: S9Server): boolean { - return !s.welcomeAck && s.versionInstalled === this.config.version + private shouldRunOsWelcome (): boolean { + const data = this.patch.data + return !data.ui['welcome-ack'] && data['server-info'].version === this.config.version } - private shouldRunAppsCheck (server: S9Server): boolean { - return server.autoCheckUpdates + private shouldRunOsUpdateCheck (): boolean { + return this.patch.data.ui['auto-check-updates'] } - private shouldRunOsUpdateCheck (server: S9Server): boolean { - return server.autoCheckUpdates + private shouldRunAppsCheck (): boolean { + return this.patch.data.ui['auto-check-updates'] } - private async v1StatusCheck (): Promise { - return this.apiService.checkV1Status() - } + private async osUpdateCheck (): Promise { + const res = await this.marketplaceApi.getEos({ }) - private async osUpdateCheck (s: Readonly): Promise { - const res = await this.apiService.getVersionLatest() - return this.osUpdateService.updateIsAvailable(s.versionInstalled, res) ? res : undefined + if (this.emver.compare(this.patch.data['server-info'].version, res.version) === -1) { + return res + } else { + return undefined + } } private async appsCheck (): Promise { - const availableApps = await this.apiService.getAvailableApps() - return !!availableApps.find( - app => app.versionInstalled && this.emver.compare(app.versionInstalled, app.versionLatest) === -1, - ) + const pkgs = await this.marketplaceApi.getMarketplacePkgs({ + ids: Object.keys(this.patch.data['package-data']).filter(id => { + return !!this.patch.data['package-data'][id].installed + }), + }) + return !!pkgs.find(pkg => { + const versionInstalled = this.patch.data['package-data'][pkg.manifest.id].manifest.version + return this.emver.compare(versionInstalled, pkg.manifest.version) === -1 + }) } - private async displayOsWelcome (s: Readonly): Promise { + private async displayOsWelcome (): Promise { return new Promise(async resolve => { const modal = await this.modalCtrl.create({ backdropDismiss: false, component: OSWelcomePage, presentingElement: await this.modalCtrl.getTop(), componentProps: { - version: s.versionInstalled, + version: this.patch.data['server-info'].version, }, }) @@ -118,14 +128,15 @@ export class StartupAlertsNotifier { }) } - private async displayOsUpdateCheck (res: ReqRes.GetVersionLatestRes): Promise { - const { update } = await this.presentAlertNewOS(res.versionLatest) + private async displayOsUpdateCheck (eos: RR.GetMarketplaceEOSRes): Promise { + const { update } = await this.presentAlertNewOS(eos.version) if (update) { const { cancelled } = await wizardModal( this.modalCtrl, this.wizardBaker.updateOS({ - version: res.versionLatest, - releaseNotes: res.releaseNotes, + version: eos.version, + headline: eos.headline, + releaseNotes: eos['release-notes'], }), ) if (cancelled) return true @@ -134,33 +145,6 @@ export class StartupAlertsNotifier { return true } - private async displayV1Check (s: V1Status): Promise { - return new Promise(async resolve => { - if (s.status !== 'available') return resolve(true) - const alert = await this.alertCtrl.create({ - backdropDismiss: true, - header: `EmbassyOS ${s.version} Now Available!`, - message: `Version ${s.version} introduces SSD support and a whole lot more.`, - buttons: [ - { - text: 'Cancel', - role: 'cancel', - handler: () => resolve(true), - }, - { - text: 'View Instructions', - handler: () => { - window.open(`https://start9.com/eos-${s.version}`, '_blank') - resolve(false) - }, - }, - ], - }) - - await alert.present() - }) - } - private async displayAppsCheck (): Promise { return new Promise(async resolve => { const alert = await this.alertCtrl.create({ @@ -223,9 +207,9 @@ export class StartupAlertsNotifier { type Check = { // validates whether a check should run based on server properties - shouldRun: (s: S9Server) => boolean + shouldRun: () => boolean // executes a check, often requiring api call. It should return a false-y value if there should be no display. - check: (s: S9Server) => Promise + check: () => Promise // display an alert based on the result of the check. // return false if subsequent modals should not be displayed display: (a: T) => Promise