From 6bbe19aed7070641a04b36e1b9d915b62f76e435 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Tue, 13 Jul 2021 23:43:39 -0600 Subject: [PATCH] toast errors and some styling --- ui/src/app/app-routing.module.ts | 1 + ui/src/app/app.component.scss | 5 +- ui/src/app/modals/markdown/markdown.page.html | 5 +- ui/src/app/modals/markdown/markdown.page.ts | 6 +- .../app/modals/os-welcome/os-welcome.page.ts | 3 +- .../app-instructions.page.html | 4 - .../app-instructions/app-instructions.page.ts | 35 +- .../apps-routes/app-logs/app-logs.page.html | 4 - .../apps-routes/app-logs/app-logs.page.ts | 6 +- .../app-metrics/app-metrics.page.html | 72 ++-- .../app-metrics/app-metrics.page.scss | 43 +- .../app-metrics/app-metrics.page.ts | 17 +- .../app-properties/app-properties.page.html | 6 +- .../app-properties/app-properties.page.ts | 24 +- .../app-restore/app-restore.module.ts | 2 + .../app-restore/app-restore.page.html | 13 +- .../apps-routes/app-show/app-show.page.html | 4 - .../apps-routes/app-show/app-show.page.ts | 24 +- .../marketplace-list.page.html | 7 +- .../marketplace-list.page.scss | 1 + .../marketplace-list/marketplace-list.page.ts | 9 +- .../marketplace-show.page.html | 402 +++++++++--------- .../marketplace-show/marketplace-show.page.ts | 13 +- .../notifications/notifications.page.html | 5 - .../pages/notifications/notifications.page.ts | 9 +- .../dev-ssh-keys/dev-ssh-keys.module.ts | 2 + .../dev-ssh-keys/dev-ssh-keys.page.html | 6 +- .../dev-ssh-keys/dev-ssh-keys.page.ts | 10 +- .../server-backup/server-backup.module.ts | 2 + .../server-backup/server-backup.page.html | 7 +- .../server-logs/server-logs.module.ts | 2 + .../server-logs/server-logs.page.html | 6 +- .../server-logs/server-logs.page.ts | 6 +- .../server-metrics/server-metrics.module.ts | 2 + .../server-metrics/server-metrics.page.html | 6 +- .../server-metrics/server-metrics.page.ts | 8 +- .../wifi/wifi-add/wifi-add.page.html | 5 - .../wifi/wifi-add/wifi-add.page.ts | 9 +- .../pages/server-routes/wifi/wifi.page.html | 4 - .../app/pages/server-routes/wifi/wifi.page.ts | 10 +- ui/src/app/services/api/mock-api.service.ts | 4 +- ui/src/app/services/error-toast.service.ts | 47 ++ ui/src/global.scss | 10 + 43 files changed, 463 insertions(+), 403 deletions(-) create mode 100644 ui/src/app/services/error-toast.service.ts diff --git a/ui/src/app/app-routing.module.ts b/ui/src/app/app-routing.module.ts index dfb54cdfc..b49c52c05 100644 --- a/ui/src/app/app-routing.module.ts +++ b/ui/src/app/app-routing.module.ts @@ -49,6 +49,7 @@ const routes: Routes = [ @NgModule({ imports: [ RouterModule.forRoot(routes, { + scrollPositionRestoration: 'enabled', preloadingStrategy: PreloadAllModules, initialNavigation: 'disabled', useHash: true, diff --git a/ui/src/app/app.component.scss b/ui/src/app/app.component.scss index ae0a824eb..aee63ce2d 100644 --- a/ui/src/app/app.component.scss +++ b/ui/src/app/app.component.scss @@ -5,7 +5,10 @@ .menu-style { border-style: solid; border-width: 0px 1px 0px 0px; - border-color: #ff4960; + border-color: var(--ion-color-danger); + ion-item::part(native) { + height: 56px; + } } .selected-badge { diff --git a/ui/src/app/modals/markdown/markdown.page.html b/ui/src/app/modals/markdown/markdown.page.html index f6a7cbf93..d61b820e1 100644 --- a/ui/src/app/modals/markdown/markdown.page.html +++ b/ui/src/app/modals/markdown/markdown.page.html @@ -11,11 +11,8 @@ - - - {{ error }} - +
diff --git a/ui/src/app/modals/markdown/markdown.page.ts b/ui/src/app/modals/markdown/markdown.page.ts index 89dc306ed..3f7efb35a 100644 --- a/ui/src/app/modals/markdown/markdown.page.ts +++ b/ui/src/app/modals/markdown/markdown.page.ts @@ -1,6 +1,7 @@ import { Component, Input } from '@angular/core' import { ModalController } from '@ionic/angular' import { ApiService } from 'src/app/services/api/api.service' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'markdown', @@ -12,10 +13,10 @@ export class MarkdownPage { @Input() title: string content: string loading = true - error = '' constructor ( private readonly modalCtrl: ModalController, + private readonly errToast: ErrorToastService, private readonly apiService: ApiService, ) { } @@ -23,7 +24,8 @@ export class MarkdownPage { try { this.content = await this.apiService.getStatic(this.contentUrl) } catch (e) { - this.error = e.message + console.error(e.message) + this.errToast.present(e.message) } finally { this.loading = false } 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 f301abdbd..67af67eeb 100644 --- a/ui/src/app/modals/os-welcome/os-welcome.page.ts +++ b/ui/src/app/modals/os-welcome/os-welcome.page.ts @@ -18,7 +18,8 @@ export class OSWelcomePage { ) { } async dismiss () { - this.apiService.setDbValue({ pointer: '/welcome-ack', value: this.config.version }).catch(console.error) + this.apiService.setDbValue({ pointer: '/welcome-ack', value: this.config.version }) + .catch(console.error) // return false to skip subsequent alert modals (e.g. check for updates modals) // return true to show subsequent alert modals diff --git a/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.html b/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.html index 6be97af18..a21ad8d1b 100644 --- a/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.html +++ b/ui/src/app/pages/apps-routes/app-instructions/app-instructions.page.html @@ -11,10 +11,6 @@ - - {{ error }} - -
\ No newline at end of file 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 de395e084..d4e71c4d2 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,10 +1,9 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { IonContent } from '@ionic/angular' -import { Subscription } from 'rxjs' -import { concatMap, take, tap } from 'rxjs/operators' import { PatchDbModel } from 'src/app/services/patch-db/patch-db.service' import { ApiService } from 'src/app/services/api/api.service' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'app-instructions', @@ -14,42 +13,30 @@ import { ApiService } from 'src/app/services/api/api.service' export class AppInstructionsPage { instructions: string loading = true - error = '' @ViewChild(IonContent) content: IonContent - subs: Subscription[] = [] constructor ( private readonly route: ActivatedRoute, + private readonly errToast: ErrorToastService, private readonly apiService: ApiService, private readonly patch: PatchDbModel, ) { } async ngOnInit () { const pkgId = this.route.snapshot.paramMap.get('pkgId') - this.patch.watch$('package-data', pkgId) - .pipe( - concatMap(pkg => this.apiService.getStatic(pkg['static-files'].instructions)), - tap(instructions => { - this.instructions = instructions - }), - take(1), - ) - .subscribe( - () => { this.loading = false }, - e => { - this.error = e.message - this.loading = false - }, - () => console.log('COMPLETE'), - ) + const url = this.patch.data['package-data'][pkgId]['static-files'].instructions + try { + this.instructions = await this.apiService.getStatic(url) + } catch (e) { + console.error(e) + this.errToast.present(e.message) + } finally { + this.loading = false + } } ngAfterViewInit () { this.content.scrollToPoint(undefined, 1) } - - ngOnDestroy () { - this.subs.forEach(sub => sub.unsubscribe()) - } } diff --git a/ui/src/app/pages/apps-routes/app-logs/app-logs.page.html b/ui/src/app/pages/apps-routes/app-logs/app-logs.page.html index 5844eacb8..23a61df63 100644 --- a/ui/src/app/pages/apps-routes/app-logs/app-logs.page.html +++ b/ui/src/app/pages/apps-routes/app-logs/app-logs.page.html @@ -14,10 +14,6 @@ - - {{ error }} - -
{{ logs }}
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 9662ef20b..f13747e4d 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 @@ -2,6 +2,7 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ApiService } from 'src/app/services/api/api.service' import { IonContent } from '@ionic/angular' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'app-logs', @@ -12,10 +13,10 @@ export class AppLogsPage { @ViewChild(IonContent, { static: false }) private content: IonContent pkgId: string logs = '' - error = '' constructor ( private readonly route: ActivatedRoute, + private readonly errToast: ErrorToastService, private readonly apiService: ApiService, ) { } @@ -32,7 +33,8 @@ export class AppLogsPage { this.logs = logs.map(l => `${l.timestamp} ${l.log}`).join('\n\n') setTimeout(async () => await this.content.scrollToBottom(100), 200) } catch (e) { - this.error = e.message + console.error(e) + this.errToast.present(e.message) } } } diff --git a/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.html b/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.html index 7fc6a0176..d4813b285 100644 --- a/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.html +++ b/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.html @@ -7,10 +7,8 @@ - - - {{ error }} - + + @@ -19,41 +17,61 @@ - + -
- - - - - -

{{ health.key }}

-

{{ health.value.error }}

-
+ No health checks
- - No health checks + + + +
+ + + + + +

{{ health.key }}

+

{{ health.value.error }}

+
+
+
+ - - Service Metrics + + Metrics - - - {{ metric.key }} - - - {{ metric.value.value }} {{ metric.value.unit }} - - + +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + {{ metric.key }} + + + {{ metric.value.value }} {{ metric.value.unit }} + + +
-
diff --git a/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.scss b/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.scss index eea898305..29b21a6a0 100644 --- a/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.scss +++ b/ui/src/app/pages/apps-routes/app-metrics/app-metrics.page.scss @@ -1,3 +1,44 @@ .metric-note { font-size: 16px; -} \ No newline at end of file +} + +$base-color: #7b7b7b; +$shine-color: #8a8a8a; +$animation-duration: 1.2s; + +@mixin background-gradient { + background-image: linear-gradient(90deg, $base-color 0px, $shine-color 40px, $base-color 80px); + background-size: 100px; +} + +.post { + height: 52px; + position: relative; + left: 12px; + .label { + float: left; + left: 30px; + width: 55%; + height: 24px; + margin: 14px 0; + border-radius: 7px; + @include background-gradient; + animation: shine-lines $animation-duration infinite linear + } + .note { + float: right; + position: relative; + right: 12px; + width: 30%; + height: 24px; + margin: 14px 0; + border-radius: 7px; + @include background-gradient; + animation: shine-lines $animation-duration infinite linear + } +} + +@keyframes shine-lines { + 0% { background-position: -100px; } + 40%, 100% { background-position: 140px; } +} 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 0255f9650..6ab0cfa33 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 @@ -3,6 +3,7 @@ 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 { 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 { pauseFor } from 'src/app/util/misc.util' @@ -13,6 +14,7 @@ import { pauseFor } from 'src/app/util/misc.util' styleUrls: ['./app-metrics.page.scss'], }) export class AppMetricsPage { + loading = true pkgId: string pkg: PackageDataEntry going = false @@ -22,6 +24,7 @@ export class AppMetricsPage { constructor ( private readonly route: ActivatedRoute, + private readonly errToast: ErrorToastService, private readonly patch: PatchDbModel, private readonly apiService: ApiService, ) { } @@ -33,6 +36,10 @@ export class AppMetricsPage { this.startDaemon() } + ngAfterViewInit () { + this.content.scrollToPoint(undefined, 1) + } + ngOnDestroy () { this.stopDaemon() } @@ -53,16 +60,14 @@ export class AppMetricsPage { try { this.metrics = await this.apiService.getPkgMetrics({ id: this.pkgId}) } catch (e) { + console.error(e) + this.errToast.present(e.message) this.stopDaemon() - await pauseFor(1000) - this.startDaemon() + } finally { + this.loading = false } } - ngAfterViewInit () { - this.content.scrollToPoint(undefined, 1) - } - asIsOrder (a: any, b: any) { return 0 } diff --git a/ui/src/app/pages/apps-routes/app-properties/app-properties.page.html b/ui/src/app/pages/apps-routes/app-properties/app-properties.page.html index efcf971c4..35f4ce147 100644 --- a/ui/src/app/pages/apps-routes/app-properties/app-properties.page.html +++ b/ui/src/app/pages/apps-routes/app-properties/app-properties.page.html @@ -16,12 +16,8 @@ - - {{ error }} - - - +

Service not running. Information on this page could be inaccurate.

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 6873fcf65..eeb64510b 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 @@ -7,9 +7,9 @@ import { AlertController, IonContent, NavController, PopoverController, ToastCon 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 * as JsonPointer from 'json-pointer' -import { FEStatus } from 'src/app/services/pkg-status-rendering.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' @Component({ selector: 'app-properties', @@ -17,11 +17,9 @@ import { PackageMainStatus } from 'src/app/services/patch-db/data-model' styleUrls: ['./app-properties.page.scss'], }) export class AppPropertiesPage { - error = '' loading = true pkgId: string pointer: string - qrCode: string properties: PackageProperties node: PackageProperties unmasked: { [key: string]: boolean } = { } @@ -33,15 +31,17 @@ export class AppPropertiesPage { constructor ( private readonly route: ActivatedRoute, private readonly apiService: ApiService, + private readonly errToast: ErrorToastService, private readonly alertCtrl: AlertController, private readonly toastCtrl: ToastController, private readonly popoverCtrl: PopoverController, private readonly navCtrl: NavController, - public readonly patch: PatchDbModel, + private readonly patch: PatchDbModel, ) { } async ngOnInit () { this.pkgId = this.route.snapshot.paramMap.get('pkgId') + this.running = this.patch.data['package-data'][this.pkgId].installed?.status.main.status === PackageMainStatus.Running await this.getProperties() @@ -51,10 +51,6 @@ export class AppPropertiesPage { this.pointer = queryParams['pointer'] this.node = JsonPointer.get(this.properties, this.pointer || '') }), - this.patch.watch$('package-data', this.pkgId, 'installed', 'status', 'main', 'status') - .subscribe(status => { - this.running = status === PackageMainStatus.Running - }), ] } @@ -116,10 +112,6 @@ export class AppPropertiesPage { this.unmasked[key] = !this.unmasked[key] } - asIsOrder (a: any, b: any) { - return 0 - } - private async getProperties (): Promise { this.loading = true try { @@ -127,9 +119,13 @@ export class AppPropertiesPage { this.node = JsonPointer.get(this.properties, this.pointer || '') } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) } finally { this.loading = false } } + + asIsOrder (a: any, b: any) { + return 0 + } } diff --git a/ui/src/app/pages/apps-routes/app-restore/app-restore.module.ts b/ui/src/app/pages/apps-routes/app-restore/app-restore.module.ts index 3de7bfe19..965ddf52b 100644 --- a/ui/src/app/pages/apps-routes/app-restore/app-restore.module.ts +++ b/ui/src/app/pages/apps-routes/app-restore/app-restore.module.ts @@ -6,6 +6,7 @@ import { RouterModule, Routes } from '@angular/router' import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module' import { BackupConfirmationComponentModule } from 'src/app/modals/backup-confirmation/backup-confirmation.component.module' import { SharingModule } from 'src/app/modules/sharing.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -22,6 +23,7 @@ const routes: Routes = [ RouterModule.forChild(routes), BackupConfirmationComponentModule, PwaBackComponentModule, + TextSpinnerComponentModule, ], declarations: [ AppRestorePage, diff --git a/ui/src/app/pages/apps-routes/app-restore/app-restore.page.html b/ui/src/app/pages/apps-routes/app-restore/app-restore.page.html index 9533a8470..fa5bc597a 100644 --- a/ui/src/app/pages/apps-routes/app-restore/app-restore.page.html +++ b/ui/src/app/pages/apps-routes/app-restore/app-restore.page.html @@ -14,20 +14,9 @@ - - - - -

Loading Drives

-
-
-
+ - - {{ error }} - -

Warning

diff --git a/ui/src/app/pages/apps-routes/app-show/app-show.page.html b/ui/src/app/pages/apps-routes/app-show/app-show.page.html index 33f28fa23..afede4879 100644 --- a/ui/src/app/pages/apps-routes/app-show/app-show.page.html +++ b/ui/src/app/pages/apps-routes/app-show/app-show.page.html @@ -11,10 +11,6 @@ - - {{ error }} - -
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 21391d1f0..8597fd203 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 @@ -12,6 +12,7 @@ import { PatchDbModel } 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' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'app-show', @@ -19,7 +20,6 @@ import { ConnectionService } from 'src/app/services/connection.service' styleUrls: ['./app-show.page.scss'], }) export class AppShowPage { - error: string pkgId: string pkg: PackageDataEntry hideLAN: boolean @@ -37,6 +37,7 @@ export class AppShowPage { private readonly alertCtrl: AlertController, private readonly route: ActivatedRoute, private readonly navCtrl: NavController, + private readonly errToast: ErrorToastService, private readonly loader: LoaderService, private readonly modalCtrl: ModalController, private readonly apiService: ApiService, @@ -62,9 +63,9 @@ export class AppShowPage { this.setButtons() } - ngAfterViewInit () { - this.content.scrollToPoint(undefined, 1) - } + // ngAfterViewInit () { + // this.content.scrollToPoint(undefined, 1) + // } ngOnDestroy () { this.subs.forEach(sub => sub.unsubscribe()) @@ -215,23 +216,24 @@ export class AppShowPage { } private setError (e: Error): Observable { - this.error = e.message + console.error(e) + this.errToast.present(e.message) return of() } setButtons (): void { this.buttons = [ { - action: () => this.navCtrl.navigateForward(['metrics'], { relativeTo: this.route }), - title: 'Health', - icon: 'medkit-outline', + action: () => this.navCtrl.navigateForward(['instructions'], { relativeTo: this.route }), + title: 'Instructions', + icon: 'list-outline', color: 'danger', disabled: [], }, { - action: () => this.navCtrl.navigateForward(['instructions'], { relativeTo: this.route }), - title: 'Instructions', - icon: 'list-outline', + action: () => this.navCtrl.navigateForward(['metrics'], { relativeTo: this.route }), + title: 'Monitor', + icon: 'medkit-outline', color: 'danger', disabled: [], }, diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html index d47524b2d..09d98df88 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.html @@ -14,11 +14,6 @@ - - - {{ error }} - - Now Available... @@ -50,7 +45,7 @@ - + diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.scss b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.scss index 4df2d43c9..595a7579d 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.scss +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.page.scss @@ -23,4 +23,5 @@ .cat-selected { border-width: 0 0 1px 0; border-style: solid; + border-color: var(--ion-color-primary); } 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 05203eeb8..cd7c4832c 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 @@ -5,8 +5,9 @@ import { wizardModal } from 'src/app/components/install-wizard/install-wizard.co 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 { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model' +import { PackageState } from 'src/app/services/patch-db/data-model' import { Subscription } from 'rxjs' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'marketplace-list', @@ -17,7 +18,6 @@ export class MarketplaceListPage { @ViewChild(IonContent) content: IonContent pageLoading = true pkgsLoading = true - error = '' category = 'all' query: string @@ -37,6 +37,7 @@ export class MarketplaceListPage { constructor ( private readonly apiService: ApiService, private readonly modalCtrl: ModalController, + private readonly errToast: ErrorToastService, private readonly wizardBaker: WizardBaker, public readonly patch: PatchDbModel, ) { } @@ -55,7 +56,7 @@ export class MarketplaceListPage { this.pkgs = pkgs } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) } finally { this.pageLoading = false this.pkgsLoading = false @@ -106,7 +107,7 @@ export class MarketplaceListPage { return pkgs } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) } finally { this.pkgsLoading = false } diff --git a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.html b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.html index 901aabfe9..0c2e66fcd 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.html +++ b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.page.html @@ -12,213 +12,211 @@ - + - - - {{ error }} - - - - - -
- -
-

{{ pkg.manifest.title }}

-

{{ pkg.manifest.version | displayEmver }}

-
- -

- Not Installed -

- - -

- - {{ installedPkg.state }} - -

- - -

- Installed at {{ installedPkg.manifest.version | displayEmver }} -

-
-
-
-
-
-
- - - - Install - - - - - - - Update - - - Downgrade - - - - -
-
- - - - -

- - - - {{ rec.dependentTitle }} -

-
-

{{ rec.description }}

-

{{ pkg.manifest.title }} version {{ pkg.manifest.version | displayEmver }} is compatible.

-

{{ pkg.manifest.title }} version {{ pkg.manifest.version | displayEmver }} is NOT compatible.

- - - -
-
-
- - - - - New in {{ pkg.manifest.version | displayEmver }} - - All Release Notes - - - - - -
-
-
- - Description - - -
{{ pkg.manifest.description.long }}
-
-
- - - Dependencies - - - - - - - - -

- {{ pkg['dependency-metadata'][dep.key].title }} - (recommended) -

-

{{ dep.value.version | displayEmver }}

-

{{ dep.value.description }}

-
-
-
-
-
-
-
- - Additional Info - + + - - - - -

Service ID

-

{{ pkg.manifest.id }}

-
-
- - -

Categories

-

{{ pkg.categories.join(', ') }}

-
-
- - -

Other Versions

-

Click to view other versions

-
- -
- - -

License

-

{{ pkg.manifest.license }}

-
- -
- - -

Instructions

-

Click to view instructions

-
- -
-
+ +
+ +
+

{{ pkg.manifest.title }}

+

{{ pkg.manifest.version | displayEmver }}

+
+ +

+ Not Installed +

+ + +

+ + {{ installedPkg.state }} + +

+ + +

+ Installed at {{ installedPkg.manifest.version | displayEmver }} +

+
+
+
+
+
- - - - -

Source Repository

-

{{ pkg.manifest['upstream-repo'] }}

-
- -
- - -

Wrapper Repository

-

{{ pkg.manifest['wrapper-repo'] }}

-
- -
- - -

Support Site

-

{{ pkg.manifest['support-site'] }}

-
- -
- - -

Marketing Site

-

{{ pkg.manifest['marketing-site'] }}

-
- -
- - -

Donation Site

-

{{ donationUrl }}

-
- -
-
+ + + + Install + + + + + + + Update + + + Downgrade + + +
-
-
+ + + + +

+ + + + {{ rec.dependentTitle }} +

+
+

{{ rec.description }}

+

{{ pkg.manifest.title }} version {{ pkg.manifest.version | displayEmver }} is compatible.

+

{{ pkg.manifest.title }} version {{ pkg.manifest.version | displayEmver }} is NOT compatible.

+ + + +
+
+
+ + + + + New in {{ pkg.manifest.version | displayEmver }} + + All Release Notes + + + + + +
+
+
+ + Description + + +
{{ pkg.manifest.description.long }}
+
+
+ + + Dependencies + + + + + + + + +

+ {{ pkg['dependency-metadata'][dep.key].title }} + (recommended) +

+

{{ dep.value.version | displayEmver }}

+

{{ dep.value.description }}

+
+
+
+
+
+
+
+ + Additional Info + + + + + + + +

Service ID

+

{{ pkg.manifest.id }}

+
+
+ + +

Categories

+

{{ pkg.categories.join(', ') }}

+
+
+ + +

Other Versions

+

Click to view other versions

+
+ +
+ + +

License

+

{{ pkg.manifest.license }}

+
+ +
+ + +

Instructions

+

Click to view instructions

+
+ +
+
+
+ + + + +

Source Repository

+

{{ pkg.manifest['upstream-repo'] }}

+
+ +
+ + +

Wrapper Repository

+

{{ pkg.manifest['wrapper-repo'] }}

+
+ +
+ + +

Support Site

+

{{ pkg.manifest['support-site'] }}

+
+ +
+ + +

Marketing Site

+

{{ pkg.manifest['marketing-site'] }}

+
+ +
+ + +

Donation Site

+

{{ donationUrl }}

+
+ +
+
+
+
+
+
+ +
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 32f73abca..9963d457e 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 @@ -1,12 +1,13 @@ import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { AlertController, IonContent, ModalController, NavController } from '@ionic/angular' +import { AlertController, IonContent, ModalController, NavController, ToastController } from '@ionic/angular' import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component' 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 { ErrorToastService } from 'src/app/services/error-toast.service' import { PackageDataEntry, PackageState } from 'src/app/services/patch-db/data-model' import { MarketplaceService } from '../marketplace.service' import { Subscription } from 'rxjs' @@ -19,7 +20,7 @@ import { MarkdownPage } from 'src/app/modals/markdown/markdown.page' }) export class MarketplaceShowPage { @ViewChild(IonContent) content: IonContent - error = '' + loading = true pkgId: string installedPkg: PackageDataEntry PackageState = PackageState @@ -32,11 +33,12 @@ export class MarketplaceShowPage { private readonly route: ActivatedRoute, private readonly alertCtrl: AlertController, private readonly modalCtrl: ModalController, + private readonly errToast: ErrorToastService, private readonly wizardBaker: WizardBaker, private readonly navCtrl: NavController, private readonly emver: Emver, private readonly patch: PatchDbModel, - public readonly marketplaceService: MarketplaceService, + private readonly marketplaceService: MarketplaceService, ) { } async ngOnInit () { @@ -66,7 +68,10 @@ export class MarketplaceShowPage { await this.marketplaceService.setPkg(this.pkgId, version) } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) + } finally { + await pauseFor(100) + this.loading = false } } diff --git a/ui/src/app/pages/notifications/notifications.page.html b/ui/src/app/pages/notifications/notifications.page.html index 03ea404d9..db6deade7 100644 --- a/ui/src/app/pages/notifications/notifications.page.html +++ b/ui/src/app/pages/notifications/notifications.page.html @@ -11,15 +11,10 @@ - - - {{ error }} - - diff --git a/ui/src/app/pages/notifications/notifications.page.ts b/ui/src/app/pages/notifications/notifications.page.ts index f39afcf28..9b92d657d 100644 --- a/ui/src/app/pages/notifications/notifications.page.ts +++ b/ui/src/app/pages/notifications/notifications.page.ts @@ -4,6 +4,7 @@ import { LoaderService } from 'src/app/services/loader.service' 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' @Component({ selector: 'notifications', @@ -11,7 +12,6 @@ import { ActivatedRoute } from '@angular/router' styleUrls: ['notifications.page.scss'], }) export class NotificationsPage { - error = '' loading = true notifications: ServerNotifications = [] page = 1 @@ -22,6 +22,7 @@ export class NotificationsPage { constructor ( private readonly apiService: ApiService, private readonly loader: LoaderService, + private readonly errToast: ErrorToastService, private readonly alertCtrl: AlertController, private readonly route: ActivatedRoute, ) { } @@ -50,10 +51,9 @@ export class NotificationsPage { notifications = await this.apiService.getNotifications({ page: this.page, 'per-page': this.perPage }) this.needInfinite = notifications.length >= this.perPage this.page++ - this.error = '' } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) } finally { return notifications } @@ -67,11 +67,10 @@ export class NotificationsPage { }).displayDuringP( this.apiService.deleteNotification({ id }).then(() => { this.notifications.splice(index, 1) - this.error = '' }), ).catch(e => { console.error(e) - this.error = e.message + this.errToast.present(e.message) }) } diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.module.ts b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.module.ts index c5602b137..290229ab1 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.module.ts +++ b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.module.ts @@ -5,6 +5,7 @@ import { RouterModule, Routes } from '@angular/router' import { DevSSHKeysPage } from './dev-ssh-keys.page' import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module' import { SharingModule } from 'src/app/modules/sharing.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -20,6 +21,7 @@ const routes: Routes = [ RouterModule.forChild(routes), PwaBackComponentModule, SharingModule, + TextSpinnerComponentModule, ], declarations: [DevSSHKeysPage], }) diff --git a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.html b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.html index 45e1ad0f1..b851aa581 100644 --- a/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.html +++ b/ui/src/app/pages/server-routes/developer-routes/dev-ssh-keys/dev-ssh-keys.page.html @@ -13,11 +13,7 @@ - - {{ error }} - - - + Saved Keys 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 91e7b8ffc..3383bd6d3 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 @@ -5,6 +5,7 @@ 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 { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'dev-ssh-keys', @@ -12,21 +13,19 @@ import { SSHKeys } from 'src/app/services/api/api-types' styleUrls: ['dev-ssh-keys.page.scss'], }) export class DevSSHKeysPage { - error = '' loading = true sshKeys: SSHKeys subs: Subscription[] = [] constructor ( private readonly loader: LoaderService, + private readonly errToast: ErrorToastService, private readonly serverConfigService: ServerConfigService, private readonly alertCtrl: AlertController, private readonly sshService: SSHService, ) { } async ngOnInit () { - await this.sshService.getKeys() - this.subs = [ this.sshService.watch$() .subscribe(keys => { @@ -34,6 +33,8 @@ export class DevSSHKeysPage { }), ] + await this.sshService.getKeys() + this.loading = false } @@ -68,7 +69,6 @@ export class DevSSHKeysPage { } async delete (hash: string): Promise { - this.error = '' this.loader.of({ message: 'Deleting...', spinner: 'lines', @@ -77,7 +77,7 @@ export class DevSSHKeysPage { await this.sshService.delete(hash) }).catch(e => { console.error(e) - this.error = '' + this.errToast.present(e.message) }) } diff --git a/ui/src/app/pages/server-routes/server-backup/server-backup.module.ts b/ui/src/app/pages/server-routes/server-backup/server-backup.module.ts index 5d7a5efc1..7a411305d 100644 --- a/ui/src/app/pages/server-routes/server-backup/server-backup.module.ts +++ b/ui/src/app/pages/server-routes/server-backup/server-backup.module.ts @@ -5,6 +5,7 @@ import { ServerBackupPage } from './server-backup.page' import { RouterModule, Routes } from '@angular/router' import { BackupConfirmationComponentModule } from 'src/app/modals/backup-confirmation/backup-confirmation.component.module' import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -20,6 +21,7 @@ const routes: Routes = [ RouterModule.forChild(routes), BackupConfirmationComponentModule, PwaBackComponentModule, + TextSpinnerComponentModule, ], declarations: [ ServerBackupPage, diff --git a/ui/src/app/pages/server-routes/server-backup/server-backup.page.html b/ui/src/app/pages/server-routes/server-backup/server-backup.page.html index 5798aadc8..426bfa35a 100644 --- a/ui/src/app/pages/server-routes/server-backup/server-backup.page.html +++ b/ui/src/app/pages/server-routes/server-backup/server-backup.page.html @@ -13,12 +13,7 @@ - - - {{ error }} - - - + diff --git a/ui/src/app/pages/server-routes/server-logs/server-logs.module.ts b/ui/src/app/pages/server-routes/server-logs/server-logs.module.ts index 2640d0619..e1a7b0490 100644 --- a/ui/src/app/pages/server-routes/server-logs/server-logs.module.ts +++ b/ui/src/app/pages/server-routes/server-logs/server-logs.module.ts @@ -4,6 +4,7 @@ import { Routes, RouterModule } from '@angular/router' import { IonicModule } from '@ionic/angular' import { ServerLogsPage } from './server-logs.page' import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -18,6 +19,7 @@ const routes: Routes = [ IonicModule, RouterModule.forChild(routes), PwaBackComponentModule, + TextSpinnerComponentModule, ], declarations: [ServerLogsPage], }) diff --git a/ui/src/app/pages/server-routes/server-logs/server-logs.page.html b/ui/src/app/pages/server-routes/server-logs/server-logs.page.html index c1b8be35c..6747d77a8 100644 --- a/ui/src/app/pages/server-routes/server-logs/server-logs.page.html +++ b/ui/src/app/pages/server-routes/server-logs/server-logs.page.html @@ -13,11 +13,7 @@ - - {{ error }} - - - +

{{ logs }}

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 dde826239..f0b79c93c 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,6 +1,7 @@ import { Component, ViewChild } from '@angular/core' import { ApiService } from 'src/app/services/api/api.service' import { IonContent } from '@ionic/angular' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'server-logs', @@ -10,10 +11,10 @@ import { IonContent } from '@ionic/angular' export class ServerLogsPage { @ViewChild(IonContent, { static: false }) private content: IonContent loading = true - error = '' logs: string constructor ( + private readonly errToast: ErrorToastService, private readonly apiService: ApiService, ) { } @@ -27,11 +28,10 @@ export class ServerLogsPage { try { const logs = await this.apiService.getServerLogs({ }) this.logs = logs.map(l => `${l.timestamp} ${l.log}`).join('\n\n') - this.error = '' setTimeout(async () => await this.content.scrollToBottom(100), 200) } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) } finally { this.loading = false } diff --git a/ui/src/app/pages/server-routes/server-metrics/server-metrics.module.ts b/ui/src/app/pages/server-routes/server-metrics/server-metrics.module.ts index a15976226..5cc4b27bb 100644 --- a/ui/src/app/pages/server-routes/server-metrics/server-metrics.module.ts +++ b/ui/src/app/pages/server-routes/server-metrics/server-metrics.module.ts @@ -4,6 +4,7 @@ import { Routes, RouterModule } from '@angular/router' import { IonicModule } from '@ionic/angular' import { ServerMetricsPage } from './server-metrics.page' import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-back.component.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -18,6 +19,7 @@ const routes: Routes = [ IonicModule, RouterModule.forChild(routes), PwaBackComponentModule, + TextSpinnerComponentModule, ], declarations: [ServerMetricsPage], }) diff --git a/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.html b/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.html index ad39aaad3..a114156ae 100644 --- a/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.html +++ b/ui/src/app/pages/server-routes/server-metrics/server-metrics.page.html @@ -8,11 +8,7 @@ - - {{ error }} - - - + 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 d2e1e680a..84cd72822 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,7 @@ import { Component } from '@angular/core' import { Metrics } from 'src/app/services/api/api-types' import { ApiService } from 'src/app/services/api/api.service' +import { ErrorToastService } from 'src/app/services/error-toast.service' import { pauseFor } from 'src/app/util/misc.util' @Component({ @@ -9,17 +10,16 @@ import { pauseFor } from 'src/app/util/misc.util' styleUrls: ['./server-metrics.page.scss'], }) export class ServerMetricsPage { - error = '' loading = true going = false metrics: Metrics = { } constructor ( + private readonly errToast: ErrorToastService, private readonly apiService: ApiService, ) { } ngOnInit () { - this.loading = false this.startDaemon() } @@ -44,8 +44,10 @@ export class ServerMetricsPage { this.metrics = await this.apiService.getServerMetrics({ }) } catch (e) { console.error(e) - this.error = e.message + this.errToast.present(e.message) this.stopDaemon() + } finally { + this.loading = false } } diff --git a/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.html b/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.html index c8b50cadf..db9008fa5 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.html +++ b/ui/src/app/pages/server-routes/wifi/wifi-add/wifi-add.page.html @@ -8,11 +8,6 @@ - - - {{ error }} - - Select Country 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 d451e9057..acc86d8d4 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 @@ -3,6 +3,7 @@ import { NavController } from '@ionic/angular' import { ApiService } from 'src/app/services/api/api.service' import { WifiService } from '../wifi.service' import { LoaderService } from 'src/app/services/loader.service' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'wifi-add', @@ -14,17 +15,16 @@ export class WifiAddPage { countryCode = 'US' ssid = '' password = '' - error = '' constructor ( private readonly navCtrl: NavController, + private readonly errToast: ErrorToastService, private readonly apiService: ApiService, private readonly loader: LoaderService, private readonly wifiService: WifiService, ) { } async save (): Promise { - this.error = '' this.loader.of({ message: 'Saving...', spinner: 'lines', @@ -40,12 +40,11 @@ export class WifiAddPage { this.navCtrl.back() }).catch(e => { console.error(e) - this.error = e.message + this.errToast.present(e.message) }) } async saveAndConnect (): Promise { - this.error = '' this.loader.of({ message: 'Connecting. This could take while...', spinner: 'lines', @@ -64,7 +63,7 @@ export class WifiAddPage { } }).catch (e => { console.error(e) - this.error = e.message + this.errToast.present(e.message) }) } diff --git a/ui/src/app/pages/server-routes/wifi/wifi.page.html b/ui/src/app/pages/server-routes/wifi/wifi.page.html index de3dce57c..54ab80ebe 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.page.html +++ b/ui/src/app/pages/server-routes/wifi/wifi.page.html @@ -13,10 +13,6 @@ - - {{ error }} - - 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 c27f6c6e7..209ce95fe 100644 --- a/ui/src/app/pages/server-routes/wifi/wifi.page.ts +++ b/ui/src/app/pages/server-routes/wifi/wifi.page.ts @@ -7,6 +7,7 @@ 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 { Subscription } from 'rxjs' +import { ErrorToastService } from 'src/app/services/error-toast.service' @Component({ selector: 'wifi', @@ -14,12 +15,12 @@ import { Subscription } from 'rxjs' styleUrls: ['wifi.page.scss'], }) export class WifiListPage { - error = '' subs: Subscription[] = [] constructor ( private readonly apiService: ApiService, private readonly loader: LoaderService, + private readonly errToast: ErrorToastService, private readonly actionCtrl: ActionSheetController, private readonly wifiService: WifiService, public readonly patch: PatchDbModel, @@ -56,7 +57,6 @@ export class WifiListPage { // Let's add country code here async connect (ssid: string): Promise { - this.error = '' this.loader.of({ message: 'Connecting. This could take while...', spinner: 'lines', @@ -66,22 +66,20 @@ export class WifiListPage { this.wifiService.confirmWifi(ssid) }).catch(e => { console.error(e) - this.error = '' + this.errToast.present(e.message) }) } async delete (ssid: string): Promise { - this.error = '' this.loader.of({ message: 'Deleting...', spinner: 'lines', cssClass: 'loader', }).displayDuringAsync(async () => { await this.apiService.deleteWifi({ ssid }) - this.error = '' }).catch(e => { console.error(e) - this.error = '' + this.errToast.present(e.message) }) } } diff --git a/ui/src/app/services/api/mock-api.service.ts b/ui/src/app/services/api/mock-api.service.ts index c35592316..a2fb2c275 100644 --- a/ui/src/app/services/api/mock-api.service.ts +++ b/ui/src/app/services/api/mock-api.service.ts @@ -494,8 +494,6 @@ export class MockApiService extends ApiService { const url = `${registryURL}/sys/version/eos` let eos = await this.http.simpleGet(url) return (eos as any) - await pauseFor(2000) - return Mock.MarketplaceEos } async getAvailableList (params: RR.GetAvailableListReq): Promise { @@ -515,7 +513,7 @@ export class MockApiService extends ApiService { await pauseFor(2000) return Mock.AvailableShow[params.id][params.version || 'latest'] } - const url = `${registryURL}/marketplace/available?id=${params.id}&version=${params.version || '1.3.0'}` + const url = `${registryURL}/marketplace/available?id=${params.id}` let res = await this.http.simpleGet(url) console.log('res RES RES', res) return (res as any) diff --git a/ui/src/app/services/error-toast.service.ts b/ui/src/app/services/error-toast.service.ts new file mode 100644 index 000000000..e9cc948e8 --- /dev/null +++ b/ui/src/app/services/error-toast.service.ts @@ -0,0 +1,47 @@ +import { Injectable } from '@angular/core' +import { IonicSafeString, ToastController } from '@ionic/angular' +import { ToastButton } from '@ionic/core' + +@Injectable({ + providedIn: 'root', +}) +export class ErrorToastService { + private toast: HTMLIonToastElement + + constructor ( + private readonly toastCtrl: ToastController, + ) { } + + async present (message: string | IonicSafeString, link?: string): Promise { + if (this.toast) return + + if (link) { + message = new IonicSafeString(message + `

Get Help`) + } + + this.toast = await this.toastCtrl.create({ + header: 'Error', + message, + duration: 0, + position: 'top', + cssClass: 'error-toast', + buttons: [ + { + side: 'end', + icon: 'close', + handler: () => { + this.dismiss() + }, + }, + ], + }) + await this.toast.present() + } + + async dismiss (): Promise { + if (this.toast) { + await this.toast.dismiss() + this.toast = undefined + } + } +} \ No newline at end of file diff --git a/ui/src/global.scss b/ui/src/global.scss index 97d0cda0a..218a0dbe8 100644 --- a/ui/src/global.scss +++ b/ui/src/global.scss @@ -73,6 +73,16 @@ ion-toast { --border-color: var(--ion-color-warning); } +.error-toast { + --border-color: var(--ion-color-danger); + width: 40%; + min-width: 400px; + --end: 8px; + right: 8px; + left: unset; + top: 64px; +} + .sublist-spinner { text-align: center; margin-top: 40px;