From fbe1b26a554a3c74647d2f81cd72803c1052d5d5 Mon Sep 17 00:00:00 2001 From: Matt Hill Date: Wed, 7 Jul 2021 22:54:56 -0600 Subject: [PATCH] text spinner component --- .../text-spinner/text-spinner.component.html | 8 ++++++++ .../text-spinner.component.module.ts | 18 +++++++++++++++++ .../text-spinner/text-spinner.component.scss | 0 .../text-spinner/text-spinner.component.ts | 10 ++++++++++ ui/src/app/modals/markdown/markdown.module.ts | 2 ++ ui/src/app/modals/markdown/markdown.page.html | 20 ++++++++++++++++++- ui/src/app/modals/markdown/markdown.page.scss | 3 +++ ui/src/app/modals/markdown/markdown.page.ts | 18 ++++++++++++++++- .../app-config/app-config.module.ts | 2 ++ .../app-config/app-config.page.html | 9 +-------- .../app-release-notes.page.ts | 8 +++++++- .../marketplace-list.module.ts | 2 ++ .../marketplace-list.page.html | 2 +- .../marketplace-list/marketplace-list.page.ts | 9 +++++++-- .../marketplace-show.module.ts | 2 ++ .../marketplace-show.page.html | 4 ++-- .../marketplace-show/marketplace-show.page.ts | 14 +++++++++---- 17 files changed, 111 insertions(+), 20 deletions(-) create mode 100644 ui/src/app/components/text-spinner/text-spinner.component.html create mode 100644 ui/src/app/components/text-spinner/text-spinner.component.module.ts create mode 100644 ui/src/app/components/text-spinner/text-spinner.component.scss create mode 100644 ui/src/app/components/text-spinner/text-spinner.component.ts diff --git a/ui/src/app/components/text-spinner/text-spinner.component.html b/ui/src/app/components/text-spinner/text-spinner.component.html new file mode 100644 index 000000000..f5d5ec6dd --- /dev/null +++ b/ui/src/app/components/text-spinner/text-spinner.component.html @@ -0,0 +1,8 @@ + + + + +

{{ text }}

+
+
+
\ No newline at end of file diff --git a/ui/src/app/components/text-spinner/text-spinner.component.module.ts b/ui/src/app/components/text-spinner/text-spinner.component.module.ts new file mode 100644 index 000000000..fefc966ff --- /dev/null +++ b/ui/src/app/components/text-spinner/text-spinner.component.module.ts @@ -0,0 +1,18 @@ +import { NgModule } from '@angular/core' +import { CommonModule } from '@angular/common' +import { TextSpinnerComponent } from './text-spinner.component' +import { IonicModule } from '@ionic/angular' +import { RouterModule } from '@angular/router' + +@NgModule({ + declarations: [ + TextSpinnerComponent, + ], + imports: [ + CommonModule, + IonicModule, + RouterModule.forChild([]), + ], + exports: [TextSpinnerComponent], +}) +export class TextSpinnerComponentModule { } diff --git a/ui/src/app/components/text-spinner/text-spinner.component.scss b/ui/src/app/components/text-spinner/text-spinner.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/ui/src/app/components/text-spinner/text-spinner.component.ts b/ui/src/app/components/text-spinner/text-spinner.component.ts new file mode 100644 index 000000000..a092860e5 --- /dev/null +++ b/ui/src/app/components/text-spinner/text-spinner.component.ts @@ -0,0 +1,10 @@ +import { Component, Input } from '@angular/core' + +@Component({ + selector: 'text-spinner', + templateUrl: './text-spinner.component.html', + styleUrls: ['./text-spinner.component.scss'], +}) +export class TextSpinnerComponent { + @Input() text: string +} diff --git a/ui/src/app/modals/markdown/markdown.module.ts b/ui/src/app/modals/markdown/markdown.module.ts index 8e3ff6bd1..12d942997 100644 --- a/ui/src/app/modals/markdown/markdown.module.ts +++ b/ui/src/app/modals/markdown/markdown.module.ts @@ -3,12 +3,14 @@ import { CommonModule } from '@angular/common' import { IonicModule } from '@ionic/angular' import { MarkdownPage } from './markdown.page' import { SharingModule } from 'src/app/modules/sharing.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' @NgModule({ imports: [ CommonModule, IonicModule, SharingModule, + TextSpinnerComponentModule, ], declarations: [MarkdownPage], }) diff --git a/ui/src/app/modals/markdown/markdown.page.html b/ui/src/app/modals/markdown/markdown.page.html index a595e240c..42ae32c2b 100644 --- a/ui/src/app/modals/markdown/markdown.page.html +++ b/ui/src/app/modals/markdown/markdown.page.html @@ -1,3 +1,21 @@ + + + + + + + + {{ title | titlecase }} + + + -
+ + + + {{ error }} + + +
+
diff --git a/ui/src/app/modals/markdown/markdown.page.scss b/ui/src/app/modals/markdown/markdown.page.scss index e69de29bb..07b67da33 100644 --- a/ui/src/app/modals/markdown/markdown.page.scss +++ b/ui/src/app/modals/markdown/markdown.page.scss @@ -0,0 +1,3 @@ +.content-padding { + padding: 0 16px 16px 16px +} \ No newline at end of file diff --git a/ui/src/app/modals/markdown/markdown.page.ts b/ui/src/app/modals/markdown/markdown.page.ts index 990de0495..89dc306ed 100644 --- a/ui/src/app/modals/markdown/markdown.page.ts +++ b/ui/src/app/modals/markdown/markdown.page.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core' import { ModalController } from '@ionic/angular' +import { ApiService } from 'src/app/services/api/api.service' @Component({ selector: 'markdown', @@ -7,12 +8,27 @@ import { ModalController } from '@ionic/angular' styleUrls: ['./markdown.page.scss'], }) export class MarkdownPage { - @Input() content: string + @Input() contentUrl: string + @Input() title: string + content: string + loading = true + error = '' constructor ( private readonly modalCtrl: ModalController, + private readonly apiService: ApiService, ) { } + async ngOnInit () { + try { + this.content = await this.apiService.getStatic(this.contentUrl) + } catch (e) { + this.error = e.message + } finally { + this.loading = false + } + } + async dismiss () { return this.modalCtrl.dismiss(true) } diff --git a/ui/src/app/pages/apps-routes/app-config/app-config.module.ts b/ui/src/app/pages/apps-routes/app-config/app-config.module.ts index 430926953..38b653d60 100644 --- a/ui/src/app/pages/apps-routes/app-config/app-config.module.ts +++ b/ui/src/app/pages/apps-routes/app-config/app-config.module.ts @@ -10,6 +10,7 @@ import { AppConfigObjectPageModule } from 'src/app/modals/app-config-object/app- import { AppConfigUnionPageModule } from 'src/app/modals/app-config-union/app-config-union.module' import { AppConfigValuePageModule } from 'src/app/modals/app-config-value/app-config-value.module' import { SharingModule } from 'src/app/modules/sharing.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -25,6 +26,7 @@ const routes: Routes = [ AppConfigObjectPageModule, AppConfigUnionPageModule, AppConfigValuePageModule, + TextSpinnerComponentModule, SharingModule, CommonModule, FormsModule, diff --git a/ui/src/app/pages/apps-routes/app-config/app-config.page.html b/ui/src/app/pages/apps-routes/app-config/app-config.page.html index e0635e24a..31efe6acf 100644 --- a/ui/src/app/pages/apps-routes/app-config/app-config.page.html +++ b/ui/src/app/pages/apps-routes/app-config/app-config.page.html @@ -12,14 +12,7 @@ - - - - -

{{ loadingText }}

-
-
-
+ diff --git a/ui/src/app/pages/marketplace-routes/app-release-notes/app-release-notes.page.ts b/ui/src/app/pages/marketplace-routes/app-release-notes/app-release-notes.page.ts index 0e6dac0be..83559afdc 100644 --- a/ui/src/app/pages/marketplace-routes/app-release-notes/app-release-notes.page.ts +++ b/ui/src/app/pages/marketplace-routes/app-release-notes/app-release-notes.page.ts @@ -1,5 +1,6 @@ -import { Component } from '@angular/core' +import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' +import { IonContent } from '@ionic/angular' import { MarketplaceService } from '../marketplace.service' @Component({ @@ -8,6 +9,7 @@ import { MarketplaceService } from '../marketplace.service' styleUrls: ['./app-release-notes.page.scss'], }) export class AppReleaseNotes { + @ViewChild(IonContent) content: IonContent error = '' selected: string pkgId: string @@ -25,6 +27,10 @@ export class AppReleaseNotes { } } + ngAfterViewInit () { + this.content.scrollToPoint(undefined, 1) + } + setSelected (selected: string) { if (this.selected === selected) { this.selected = null diff --git a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.module.ts b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.module.ts index 693957f9d..0e061a424 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.module.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-list/marketplace-list.module.ts @@ -6,6 +6,7 @@ import { MarketplaceListPage } from './marketplace-list.page' import { SharingModule } from '../../../modules/sharing.module' import { BadgeMenuComponentModule } from 'src/app/components/badge-menu-button/badge-menu.component.module' import { StatusComponentModule } from 'src/app/components/status/status.component.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ @@ -23,6 +24,7 @@ const routes: Routes = [ StatusComponentModule, SharingModule, BadgeMenuComponentModule, + TextSpinnerComponentModule, ], declarations: [MarketplaceListPage], }) 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 bc29ca0a4..6fa53c03e 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 @@ -11,7 +11,7 @@ - + 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 eadcee88e..418c3fdc3 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,8 +1,8 @@ -import { Component } from '@angular/core' +import { Component, ViewChild } from '@angular/core' import { ApiService } from 'src/app/services/api/api.service' import { MarketplaceData, MarketplaceEOS, AvailablePreview } from 'src/app/services/api/api-types' import { wizardModal } from 'src/app/components/install-wizard/install-wizard.component' -import { ModalController } from '@ionic/angular' +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' @@ -14,6 +14,7 @@ import { Subscription } from 'rxjs' styleUrls: ['./marketplace-list.page.scss'], }) export class MarketplaceListPage { + @ViewChild(IonContent) content: IonContent pageLoading = true pkgsLoading = true error = '' @@ -65,6 +66,10 @@ export class MarketplaceListPage { } } + ngAfterViewInit () { + this.content.scrollToPoint(undefined, 1) + } + ngOnDestroy () { this.subs.forEach(sub => sub.unsubscribe()) } diff --git a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.module.ts b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.module.ts index 559da69f8..54c0ec21c 100644 --- a/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.module.ts +++ b/ui/src/app/pages/marketplace-routes/marketplace-show/marketplace-show.module.ts @@ -8,6 +8,7 @@ import { PwaBackComponentModule } from 'src/app/components/pwa-back-button/pwa-b import { BadgeMenuComponentModule } from 'src/app/components/badge-menu-button/badge-menu.component.module' import { StatusComponentModule } from 'src/app/components/status/status.component.module' import { InstallWizardComponentModule } from 'src/app/components/install-wizard/install-wizard.component.module' +import { TextSpinnerComponentModule } from 'src/app/components/text-spinner/text-spinner.component.module' const routes: Routes = [ { @@ -21,6 +22,7 @@ const routes: Routes = [ CommonModule, IonicModule, StatusComponentModule, + TextSpinnerComponentModule, RouterModule.forChild(routes), SharingModule, PwaBackComponentModule, 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 502469548..6c96faf0e 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,7 +12,7 @@ - + @@ -162,7 +162,7 @@ - +

License

{{ pkg.manifest.license }}

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 c874ee857..9c2dead89 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,6 +1,6 @@ -import { Component } from '@angular/core' +import { Component, ViewChild } from '@angular/core' import { ActivatedRoute } from '@angular/router' -import { AlertController, ModalController, NavController } from '@ionic/angular' +import { AlertController, IonContent, ModalController, NavController } 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' @@ -18,6 +18,7 @@ import { MarkdownPage } from 'src/app/modals/markdown/markdown.page' styleUrls: ['./marketplace-show.page.scss'], }) export class MarketplaceShowPage { + @ViewChild(IonContent) content: IonContent error = '' pkgId: string installedPkg: PackageDataEntry @@ -53,6 +54,10 @@ export class MarketplaceShowPage { this.getPkg() } + ngAfterViewInit () { + this.content.scrollToPoint(undefined, 1) + } + ngOnDestroy () { this.subs.forEach(sub => sub.unsubscribe()) } @@ -95,10 +100,11 @@ export class MarketplaceShowPage { await alert.present() } - async presentModalMd (content: string) { + async presentModalMd (title: string) { const modal = await this.modalCtrl.create({ componentProps: { - content, + title, + contentUrl: this.marketplaceService.pkgs[this.pkgId][title], }, component: MarkdownPage, })