From 9f7df3333b7548bbdcdfb7820dda9770c55ef9b7 Mon Sep 17 00:00:00 2001 From: Sean Wu Date: Thu, 5 Nov 2020 10:27:40 +0800 Subject: [PATCH] Rebuild information details with angular-material. --- .../proof/information/information.module.ts | 14 ++- .../proof/information/information.page.html | 107 +++++++----------- .../proof/information/information.page.scss | 8 +- .../information/information.page.spec.ts | 16 ++- .../proof/information/information.page.ts | 24 ++-- .../capacitor-provider/capacitor-provider.ts | 2 +- 6 files changed, 84 insertions(+), 87 deletions(-) diff --git a/src/app/pages/storage/proof/information/information.module.ts b/src/app/pages/storage/proof/information/information.module.ts index c0b55be49..b74acb954 100644 --- a/src/app/pages/storage/proof/information/information.module.ts +++ b/src/app/pages/storage/proof/information/information.module.ts @@ -1,6 +1,10 @@ import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { FormsModule } from '@angular/forms'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { MatListModule } from '@angular/material/list'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatToolbarModule } from '@angular/material/toolbar'; import { IonicModule } from '@ionic/angular'; import { TranslocoModule } from '@ngneat/transloco'; import { InformationPageRoutingModule } from './information-routing.module'; @@ -9,10 +13,14 @@ import { InformationPage } from './information.page'; @NgModule({ imports: [ CommonModule, - FormsModule, IonicModule, InformationPageRoutingModule, - TranslocoModule + TranslocoModule, + MatToolbarModule, + MatButtonModule, + MatIconModule, + MatListModule, + MatSnackBarModule ], declarations: [InformationPage] }) diff --git a/src/app/pages/storage/proof/information/information.page.html b/src/app/pages/storage/proof/information/information.page.html index 080a07360..2395c88e4 100644 --- a/src/app/pages/storage/proof/information/information.page.html +++ b/src/app/pages/storage/proof/information/information.page.html @@ -1,69 +1,38 @@ - - - - - - - - {{ t('informationDetails') }} - - - - - - - - {{ t('location') }} - - - - - -

{{ information.name }}

-

{{ information.value }}

-
-
-
-
-
-
-
- - - - - {{ t('other') }} - - - - - -

{{ information.name }}

-

{{ information.value }}

-
-
-
-
-
-
-
- - - - - {{ t('device') }} - - - - - -

{{ information.name }}

-

{{ information.value }}

-
-
-
-
-
-
-
-
\ No newline at end of file + + + {{ t('informationDetails') }} + + +
+ +
{{ t('location') }}
+ + information +
{{ information.name }}
+
{{ information.value }}
+ +
+
{{ t('device') }}
+ + information +
{{ information.name }}
+
{{ information.value }}
+ +
+
{{ t('other') }}
+ + information +
{{ information.name }}
+
{{ information.value }}
+ +
+
+
\ No newline at end of file diff --git a/src/app/pages/storage/proof/information/information.page.scss b/src/app/pages/storage/proof/information/information.page.scss index 410d97ad1..0d9c2d0d0 100644 --- a/src/app/pages/storage/proof/information/information.page.scss +++ b/src/app/pages/storage/proof/information/information.page.scss @@ -1,7 +1,3 @@ -.slide-card { - width: 100%; -} - -.multiline { - white-space: pre-wrap; +mat-toolbar { + background: white; } diff --git a/src/app/pages/storage/proof/information/information.page.spec.ts b/src/app/pages/storage/proof/information/information.page.spec.ts index 53322231a..ded686776 100644 --- a/src/app/pages/storage/proof/information/information.page.spec.ts +++ b/src/app/pages/storage/proof/information/information.page.spec.ts @@ -1,4 +1,9 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { MatButtonModule } from '@angular/material/button'; +import { MatIconModule } from '@angular/material/icon'; +import { MatListModule } from '@angular/material/list'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; +import { MatToolbarModule } from '@angular/material/toolbar'; import { RouterTestingModule } from '@angular/router/testing'; import { IonicModule } from '@ionic/angular'; import { getTranslocoModule } from 'src/app/transloco/transloco-root.module.spec'; @@ -11,7 +16,16 @@ describe('InformationPage', () => { beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [InformationPage], - imports: [IonicModule.forRoot(), RouterTestingModule, getTranslocoModule()] + imports: [ + IonicModule.forRoot(), + RouterTestingModule, + getTranslocoModule(), + MatToolbarModule, + MatButtonModule, + MatIconModule, + MatListModule, + MatSnackBarModule + ] }).compileComponents(); fixture = TestBed.createComponent(InformationPage); diff --git a/src/app/pages/storage/proof/information/information.page.ts b/src/app/pages/storage/proof/information/information.page.ts index a57b8b4da..3fb1aa917 100644 --- a/src/app/pages/storage/proof/information/information.page.ts +++ b/src/app/pages/storage/proof/information/information.page.ts @@ -1,12 +1,17 @@ import { Component } from '@angular/core'; +import { MatSnackBar } from '@angular/material/snack-bar'; import { ActivatedRoute } from '@angular/router'; +import { Plugins } from '@capacitor/core'; +import { TranslocoService } from '@ngneat/transloco'; import { UntilDestroy } from '@ngneat/until-destroy'; -import { map, pluck, switchMap } from 'rxjs/operators'; +import { map, switchMap } from 'rxjs/operators'; import { InformationType } from 'src/app/services/data/information/information'; import { InformationRepository } from 'src/app/services/data/information/information-repository.service'; import { ProofRepository } from 'src/app/services/data/proof/proof-repository.service'; import { isNonNullable } from 'src/app/utils/rx-operators'; +const { Clipboard } = Plugins; + @UntilDestroy({ checkProperties: true }) @Component({ selector: 'app-information', @@ -22,26 +27,31 @@ export class InformationPage { isNonNullable() ); - readonly hash$ = this.proof$.pipe(pluck('hash')); - readonly locationInformation$ = this.proof$.pipe( switchMap(proof => this.informationRepository.getByProof$(proof)), map(informationList => informationList.filter(information => information.type === InformationType.Location)) ); - readonly otherInformation$ = this.proof$.pipe( + readonly deviceInformation$ = this.proof$.pipe( switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => informationList.filter(information => information.type === InformationType.Other)) + map(informationList => informationList.filter(information => information.type === InformationType.Device)) ); - readonly deviceInformation$ = this.proof$.pipe( + readonly otherInformation$ = this.proof$.pipe( switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => informationList.filter(information => information.type === InformationType.Device)) + map(informationList => informationList.filter(information => information.type === InformationType.Other)) ); constructor( private readonly route: ActivatedRoute, private readonly proofRepository: ProofRepository, private readonly informationRepository: InformationRepository, + private readonly translocoService: TranslocoService, + private readonly snackBar: MatSnackBar, ) { } + + copyToClipboard(value: string) { + Clipboard.write({ string: value }); + this.snackBar.open(this.translocoService.translate('message.copiedToClipboard')); + } } diff --git a/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts b/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts index 6b219869a..4fff03219 100644 --- a/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts +++ b/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts @@ -68,7 +68,7 @@ export class CapacitorProvider extends InformationProvider { name: this.translocoService.translate('uuid'), value: String(deviceInfo.uuid), importance: Importance.High, - type: InformationType.Other + type: InformationType.Device }, { proofHash: proof.hash, provider: this.id,