diff --git a/frontend/projects/ui/src/app/app.component.ts b/frontend/projects/ui/src/app/app.component.ts index 095cdcb8d..07f6618a3 100644 --- a/frontend/projects/ui/src/app/app.component.ts +++ b/frontend/projects/ui/src/app/app.component.ts @@ -19,11 +19,7 @@ import { Emver } from './services/emver.service' import { SplitPaneTracker } from './services/split-pane.service' import { ToastButton } from '@ionic/core' import { PatchDbService } from './services/patch-db/patch-db.service' -import { - ServerStatus, - UIData, - UIMarketplaceData, -} from './services/patch-db/data-model' +import { ServerStatus, UIData } from './services/patch-db/data-model' import { ConnectionFailure, ConnectionService, @@ -35,7 +31,7 @@ import { ErrorToastService } from './services/error-toast.service' import { Subscription } from 'rxjs' import { LocalStorageService } from './services/local-storage.service' import { EOSService } from './services/eos.service' -import { v4 } from 'uuid' +import { MarketplaceService } from './pages/marketplace-routes/marketplace.service' @Component({ selector: 'app-root', @@ -100,6 +96,7 @@ export class AppComponent { private readonly emver: Emver, private readonly connectionService: ConnectionService, private readonly startupAlertsService: StartupAlertsService, + private readonly marketplaceService: MarketplaceService, private readonly toastCtrl: ToastController, private readonly errToast: ErrorToastService, private readonly config: ConfigService, @@ -138,7 +135,6 @@ export class AppComponent { this.watchConnection(), // watch router to highlight selected menu item this.watchRouter(), - // watch status to display/hide maintenance page ]) this.patch @@ -160,6 +156,8 @@ export class AppComponent { this.watchVersion(), // watch unread notification count to display toast this.watchNotifications(), + // watch marketplace URL for changes + this.marketplaceService.init(), // run startup alerts this.startupAlertsService.runChecks(), ]) diff --git a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts index 3148d48d4..40a0e7b86 100644 --- a/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts +++ b/frontend/projects/ui/src/app/pages/marketplace-routes/marketplace.service.ts @@ -1,4 +1,5 @@ import { Injectable } from '@angular/core' +import { Subscription } from 'rxjs' import { MarketplaceData, MarketplacePkg, @@ -23,15 +24,15 @@ export class MarketplaceService { } = {} marketplaceUrl: string - constructor ( + constructor( private readonly api: ApiService, private readonly emver: Emver, private readonly patch: PatchDbService, private readonly config: ConfigService, - ) { } + ) {} - async init () { - this.patch.watch$('ui', 'marketplace').subscribe(marketplace => { + init(): Subscription { + return this.patch.watch$('ui', 'marketplace').subscribe(marketplace => { if (!marketplace || !marketplace['selected-id']) { this.marketplaceUrl = this.config.marketplace.url } else { @@ -41,7 +42,7 @@ export class MarketplaceService { }) } - async load (): Promise { + async load(): Promise { try { const [data, pkgs] = await Promise.all([ this.getMarketplaceData({}), @@ -66,7 +67,7 @@ export class MarketplaceService { } } - async getUpdates (localPkgs: { + async getUpdates(localPkgs: { [id: string]: PackageDataEntry }): Promise { const id = this.patch.getData().ui.marketplace?.['selected-id'] @@ -96,7 +97,7 @@ export class MarketplaceService { }) } - async getPkg (id: string, version = '*'): Promise { + async getPkg(id: string, version = '*'): Promise { const pkgs = await this.getMarketplacePkgs({ ids: [{ id, version }], 'eos-version-compat': @@ -111,11 +112,11 @@ export class MarketplaceService { } } - async cacheReleaseNotes (id: string): Promise { + async cacheReleaseNotes(id: string): Promise { this.releaseNotes[id] = await this.getReleaseNotes({ id }) } - private async getPkgs ( + private async getPkgs( page: number, perPage: number, ): Promise { @@ -129,7 +130,7 @@ export class MarketplaceService { return pkgs } - async getMarketplaceData ( + async getMarketplaceData( params: RR.GetMarketplaceDataReq, url?: string, ): Promise { @@ -137,7 +138,7 @@ export class MarketplaceService { return this.api.marketplaceProxy('/package/v0/data', params, url) } - async getMarketplacePkgs ( + async getMarketplacePkgs( params: RR.GetMarketplacePackagesReq, ): Promise { if (params.query) params.category = undefined @@ -151,7 +152,7 @@ export class MarketplaceService { ) } - async getReleaseNotes ( + async getReleaseNotes( params: RR.GetReleaseNotesReq, ): Promise { return this.api.marketplaceProxy( diff --git a/frontend/projects/ui/src/app/pages/server-routes/preferences/preferences.page.html b/frontend/projects/ui/src/app/pages/server-routes/preferences/preferences.page.html index 433eb29ac..2a69140d8 100644 --- a/frontend/projects/ui/src/app/pages/server-routes/preferences/preferences.page.html +++ b/frontend/projects/ui/src/app/pages/server-routes/preferences/preferences.page.html @@ -25,11 +25,6 @@ > - - Marketplace { + async getStatic(url: string): Promise { return this.http.httpRequest({ method: Method.GET, url, @@ -27,75 +25,75 @@ export class LiveApiService extends ApiService { // db - async getRevisions (since: number): Promise { + async getRevisions(since: number): Promise { return this.http.rpcRequest({ method: 'db.revisions', params: { since } }) } - async getDump (): Promise { + async getDump(): Promise { return this.http.rpcRequest({ method: 'db.dump' }) } - async setDbValueRaw (params: RR.SetDBValueReq): Promise { + async setDbValueRaw(params: RR.SetDBValueReq): Promise { return this.http.rpcRequest({ method: 'db.put.ui', params }) } // auth - async login (params: RR.LoginReq): Promise { + async login(params: RR.LoginReq): Promise { return this.http.rpcRequest({ method: 'auth.login', params }) } - async logout (params: RR.LogoutReq): Promise { + async logout(params: RR.LogoutReq): Promise { return this.http.rpcRequest({ method: 'auth.logout', params }) } - async getSessions (params: RR.GetSessionsReq): Promise { + async getSessions(params: RR.GetSessionsReq): Promise { return this.http.rpcRequest({ method: 'auth.session.list', params }) } - async killSessions (params: RR.KillSessionsReq): Promise { + async killSessions(params: RR.KillSessionsReq): Promise { return this.http.rpcRequest({ method: 'auth.session.kill', params }) } // server - async setShareStatsRaw ( + async setShareStatsRaw( params: RR.SetShareStatsReq, ): Promise { return this.http.rpcRequest({ method: 'server.config.share-stats', params }) } - async getServerLogs ( + async getServerLogs( params: RR.GetServerLogsReq, ): Promise { return this.http.rpcRequest({ method: 'server.logs', params }) } - async getServerMetrics ( + async getServerMetrics( params: RR.GetServerMetricsReq, ): Promise { return this.http.rpcRequest({ method: 'server.metrics', params }) } - async updateServerRaw ( + async updateServerRaw( params: RR.UpdateServerReq, ): Promise { return this.http.rpcRequest({ method: 'server.update', params }) } - async restartServer ( + async restartServer( params: RR.RestartServerReq, ): Promise { return this.http.rpcRequest({ method: 'server.restart', params }) } - async shutdownServer ( + async shutdownServer( params: RR.ShutdownServerReq, ): Promise { return this.http.rpcRequest({ method: 'server.shutdown', params }) } - async systemRebuild ( + async systemRebuild( params: RR.RestartServerReq, ): Promise { return this.http.rpcRequest({ method: 'server.rebuild', params }) @@ -103,7 +101,7 @@ export class LiveApiService extends ApiService { // marketplace URLs - async marketplaceProxy (path: string, params: {}, url: string): Promise { + async marketplaceProxy(path: string, params: {}, url: string): Promise { const fullURL = `${url}${path}?${new URLSearchParams(params).toString()}` return this.http.rpcRequest({ method: 'marketplace.get', @@ -111,7 +109,7 @@ export class LiveApiService extends ApiService { }) } - async getEos ( + async getEos( params: RR.GetMarketplaceEOSReq, ): Promise { return this.marketplaceProxy( @@ -121,26 +119,21 @@ export class LiveApiService extends ApiService { ) } - // password - // async updatePassword (params: RR.UpdatePasswordReq): Promise { - // return this.http.rpcRequest({ method: 'password.set', params }) - // } - // notification - async getNotificationsRaw ( + async getNotificationsRaw( params: RR.GetNotificationsReq, ): Promise { return this.http.rpcRequest({ method: 'notification.list', params }) } - async deleteNotification ( + async deleteNotification( params: RR.DeleteNotificationReq, ): Promise { return this.http.rpcRequest({ method: 'notification.delete', params }) } - async deleteAllNotifications ( + async deleteAllNotifications( params: RR.DeleteAllNotificationsReq, ): Promise { return this.http.rpcRequest({ @@ -151,79 +144,79 @@ export class LiveApiService extends ApiService { // wifi - async getWifi ( + async getWifi( params: RR.GetWifiReq, timeout?: number, ): Promise { return this.http.rpcRequest({ method: 'wifi.get', params, timeout }) } - async setWifiCountry ( + async setWifiCountry( params: RR.SetWifiCountryReq, ): Promise { return this.http.rpcRequest({ method: 'wifi.country.set', params }) } - async addWifi (params: RR.AddWifiReq): Promise { + async addWifi(params: RR.AddWifiReq): Promise { return this.http.rpcRequest({ method: 'wifi.add', params }) } - async connectWifi (params: RR.ConnectWifiReq): Promise { + async connectWifi(params: RR.ConnectWifiReq): Promise { return this.http.rpcRequest({ method: 'wifi.connect', params }) } - async deleteWifi (params: RR.DeleteWifiReq): Promise { + async deleteWifi(params: RR.DeleteWifiReq): Promise { return this.http.rpcRequest({ method: 'wifi.delete', params }) } // ssh - async getSshKeys (params: RR.GetSSHKeysReq): Promise { + async getSshKeys(params: RR.GetSSHKeysReq): Promise { return this.http.rpcRequest({ method: 'ssh.list', params }) } - async addSshKey (params: RR.AddSSHKeyReq): Promise { + async addSshKey(params: RR.AddSSHKeyReq): Promise { return this.http.rpcRequest({ method: 'ssh.add', params }) } - async deleteSshKey (params: RR.DeleteSSHKeyReq): Promise { + async deleteSshKey(params: RR.DeleteSSHKeyReq): Promise { return this.http.rpcRequest({ method: 'ssh.delete', params }) } // backup - async getBackupTargets ( + async getBackupTargets( params: RR.GetBackupTargetsReq, ): Promise { return this.http.rpcRequest({ method: 'backup.target.list', params }) } - async addBackupTarget ( + async addBackupTarget( params: RR.AddBackupTargetReq, ): Promise { params.path = params.path.replace('/\\/g', '/') return this.http.rpcRequest({ method: 'backup.target.cifs.add', params }) } - async updateBackupTarget ( + async updateBackupTarget( params: RR.UpdateBackupTargetReq, ): Promise { return this.http.rpcRequest({ method: 'backup.target.cifs.update', params }) } - async removeBackupTarget ( + async removeBackupTarget( params: RR.RemoveBackupTargetReq, ): Promise { return this.http.rpcRequest({ method: 'backup.target.cifs.remove', params }) } - async getBackupInfo ( + async getBackupInfo( params: RR.GetBackupInfoReq, ): Promise { return this.http.rpcRequest({ method: 'backup.target.info', params }) } - async createBackupRaw ( + async createBackupRaw( params: RR.CreateBackupReq, ): Promise { return this.http.rpcRequest({ method: 'backup.create', params }) @@ -231,7 +224,7 @@ export class LiveApiService extends ApiService { // package - async getPackageProperties ( + async getPackageProperties( params: RR.GetPackagePropertiesReq, ): Promise['data']> { return this.http @@ -239,95 +232,95 @@ export class LiveApiService extends ApiService { .then(parsePropertiesPermissive) } - async getPackageLogs ( + async getPackageLogs( params: RR.GetPackageLogsReq, ): Promise { return this.http.rpcRequest({ method: 'package.logs', params }) } - async getPkgMetrics ( + async getPkgMetrics( params: RR.GetPackageMetricsReq, ): Promise { return this.http.rpcRequest({ method: 'package.metrics', params }) } - async installPackageRaw ( + async installPackageRaw( params: RR.InstallPackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.install', params }) } - async dryUpdatePackage ( + async dryUpdatePackage( params: RR.DryUpdatePackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.update.dry', params }) } - async getPackageConfig ( + async getPackageConfig( params: RR.GetPackageConfigReq, ): Promise { return this.http.rpcRequest({ method: 'package.config.get', params }) } - async drySetPackageConfig ( + async drySetPackageConfig( params: RR.DrySetPackageConfigReq, ): Promise { return this.http.rpcRequest({ method: 'package.config.set.dry', params }) } - async setPackageConfigRaw ( + async setPackageConfigRaw( params: RR.SetPackageConfigReq, ): Promise { return this.http.rpcRequest({ method: 'package.config.set', params }) } - async restorePackagesRaw ( + async restorePackagesRaw( params: RR.RestorePackagesReq, ): Promise { return this.http.rpcRequest({ method: 'package.backup.restore', params }) } - async executePackageAction ( + async executePackageAction( params: RR.ExecutePackageActionReq, ): Promise { return this.http.rpcRequest({ method: 'package.action', params }) } - async startPackageRaw ( + async startPackageRaw( params: RR.StartPackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.start', params }) } - async dryStopPackage ( + async dryStopPackage( params: RR.DryStopPackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.stop.dry', params }) } - async stopPackageRaw (params: RR.StopPackageReq): Promise { + async stopPackageRaw(params: RR.StopPackageReq): Promise { return this.http.rpcRequest({ method: 'package.stop', params }) } - async dryUninstallPackage ( + async dryUninstallPackage( params: RR.DryUninstallPackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.uninstall.dry', params }) } - async deleteRecoveredPackageRaw ( + async deleteRecoveredPackageRaw( params: RR.DeleteRecoveredPackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.delete-recovered', params }) } - async uninstallPackageRaw ( + async uninstallPackageRaw( params: RR.UninstallPackageReq, ): Promise { return this.http.rpcRequest({ method: 'package.uninstall', params }) } - async dryConfigureDependency ( + async dryConfigureDependency( params: RR.DryConfigureDependencyReq, ): Promise { return this.http.rpcRequest({ diff --git a/frontend/projects/ui/src/app/services/server-config.service.ts b/frontend/projects/ui/src/app/services/server-config.service.ts index c99699de2..dc1ed4477 100644 --- a/frontend/projects/ui/src/app/services/server-config.service.ts +++ b/frontend/projects/ui/src/app/services/server-config.service.ts @@ -107,9 +107,6 @@ export class ServerConfigService { 'share-stats': async (enabled: boolean) => { return this.embassyApi.setShareStats({ value: enabled }) }, - // password: async (password: string) => { - // return this.embassyApi.updatePassword({ password }) - // }, } } @@ -129,16 +126,4 @@ export const serverConfig: ConfigSpec = { ) as any, default: false, }, - // password: { - // type: 'string', - // name: 'Change Password', - // description: `Your Embassy's master password, used for authentication and disk encryption.`, - // nullable: false, - // // @TODO regex for 12 chars - // // pattern: '', - // 'pattern-description': 'Must contain at least 12 characters.', - // warning: 'If you forget your master password, there is absolutely no way to recover your data. This can result in loss of money! Keep in mind, old backups will still be encrypted by the password used to encrypt them.', - // masked: false, - // copyable: false, - // }, }