From 9027e26a81ec0872ac86361788285efb618059df Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:17:08 +0800 Subject: [PATCH 01/26] add information page --- .../information/information-routing.module.ts | 14 ++++ .../pages/information/information.module.ts | 19 +++++ .../pages/information/information.page.html | 75 +++++++++++++++++++ .../pages/information/information.page.scss | 12 +++ .../information/information.page.spec.ts | 0 src/app/pages/information/information.page.ts | 50 +++++++++++++ 6 files changed, 170 insertions(+) create mode 100644 src/app/pages/information/information-routing.module.ts create mode 100644 src/app/pages/information/information.module.ts create mode 100644 src/app/pages/information/information.page.html create mode 100644 src/app/pages/information/information.page.scss create mode 100644 src/app/pages/information/information.page.spec.ts create mode 100644 src/app/pages/information/information.page.ts diff --git a/src/app/pages/information/information-routing.module.ts b/src/app/pages/information/information-routing.module.ts new file mode 100644 index 000000000..f1c33bb10 --- /dev/null +++ b/src/app/pages/information/information-routing.module.ts @@ -0,0 +1,14 @@ +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; +import { InformationPage } from './information.page'; + +const routes: Routes = [{ + path: '', + component: InformationPage +}]; + +@NgModule({ + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], +}) +export class InformationPageRoutingModule { } diff --git a/src/app/pages/information/information.module.ts b/src/app/pages/information/information.module.ts new file mode 100644 index 000000000..fe1f599f2 --- /dev/null +++ b/src/app/pages/information/information.module.ts @@ -0,0 +1,19 @@ +import { CommonModule } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { FormsModule } from '@angular/forms'; +import { IonicModule } from '@ionic/angular'; +import { TranslocoModule } from '@ngneat/transloco'; +import { InformationPageRoutingModule } from './information-routing.module'; +import { InformationPage } from './information.page'; + +@NgModule({ + imports: [ + CommonModule, + FormsModule, + IonicModule, + InformationPageRoutingModule, + TranslocoModule + ], + declarations: [InformationPage] +}) +export class InformationPageModule { } diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html new file mode 100644 index 000000000..e27a24bd6 --- /dev/null +++ b/src/app/pages/information/information.page.html @@ -0,0 +1,75 @@ + + + + + + + + {{ t('informationDetails') }} + + + + + + + + + Location + + + + + +

{{information.name}}

+

{{information.value}}

+
+
+
+
+
+
+
+
+ + + + + + Hash + + + + + +

{{information.name}}

+

{{information.value}}

+
+
+
+
+
+
+
+
+ + + + + + Other + + + + + +

{{information.name}}

+

{{information.value}}

+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss new file mode 100644 index 000000000..f18d4a9cf --- /dev/null +++ b/src/app/pages/information/information.page.scss @@ -0,0 +1,12 @@ +ion-slides { + width: 100%; + } + + .slide-card { + width: 100%; + margin-bottom: 35px; + } + + .multiline { + white-space: pre-wrap; + } \ No newline at end of file diff --git a/src/app/pages/information/information.page.spec.ts b/src/app/pages/information/information.page.spec.ts new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/pages/information/information.page.ts b/src/app/pages/information/information.page.ts new file mode 100644 index 000000000..b4c21af90 --- /dev/null +++ b/src/app/pages/information/information.page.ts @@ -0,0 +1,50 @@ +import { Component } from '@angular/core'; +import { ActivatedRoute, Router } from '@angular/router'; +import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; +import { map, switchMap, switchMapTo } from 'rxjs/operators'; +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/type'; + +@UntilDestroy({ checkProperties: true }) +@Component({ + selector: 'app-information', + templateUrl: './information.page.html', + styleUrls: ['./information.page.scss'], +}) +export class InformationPage { + + readonly proof$ = this.route.paramMap.pipe( + map(params => params.get('hash')), + isNonNullable(), + switchMap(hash => this.proofRepository.getByHash$(hash)), + isNonNullable() + ); + + readonly hash$ = this.proof$.pipe(map(proof => proof.hash)); + + readonly providersWithInformationList$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const providers = new Set(informationList.map(information => information.provider)); + return [...providers].map(provider => ({ + provider, + informationList: informationList.filter(information => information.provider === provider) + })); + }) + ); + + constructor( + private readonly router: Router, + private readonly route: ActivatedRoute, + private readonly proofRepository: ProofRepository, + private readonly informationRepository: InformationRepository, + ) { } + + ionViewWillEnter() { + this.proofRepository.refresh$().pipe( + switchMapTo(this.informationRepository.refresh$()), + untilDestroyed(this) + ).subscribe(); + } +} From 9c81dec7b5d1d7708e8c50464006afea090057d2 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:17:37 +0800 Subject: [PATCH 02/26] updated app-routing with info page route --- src/app/app-routing.module.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 2f0641283..fe9b363ed 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -14,6 +14,9 @@ const routes: Routes = [{ }, { path: 'proof', loadChildren: () => import('./pages/proof/proof.module').then(m => m.ProofPageModule) +}, { + path: 'information', + loadChildren: () => import('./pages/information/information.module').then(m => m.InformationPageModule) }]; @NgModule({ From f9637cb5155156fdc0d55d59a875251e018e8614 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:18:35 +0800 Subject: [PATCH 03/26] updated proofs page --- src/app/pages/proof/proof.page.html | 8 ++++++-- src/app/pages/proof/proof.page.ts | 6 ++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/app/pages/proof/proof.page.html b/src/app/pages/proof/proof.page.html index 5e31f6333..4d9b3cf95 100644 --- a/src/app/pages/proof/proof.page.html +++ b/src/app/pages/proof/proof.page.html @@ -64,14 +64,18 @@

{{ t('information') }}

{{ providerWithInformationList.provider }} - - + +

{{ information.name }}

{{ information.value }}

+
+ View All + +
diff --git a/src/app/pages/proof/proof.page.ts b/src/app/pages/proof/proof.page.ts index 537b09f6b..e9fa119aa 100644 --- a/src/app/pages/proof/proof.page.ts +++ b/src/app/pages/proof/proof.page.ts @@ -26,6 +26,7 @@ export class ProofPage { switchMap(hash => this.proofRepository.getByHash$(hash)), isNonNullable() ); + readonly rawBase64$ = this.proof$.pipe(switchMap(proof => this.proofRepository.getRawFile$(proof))); readonly hash$ = this.proof$.pipe(map(proof => proof.hash)); readonly mimeType$ = this.proof$.pipe(map(proof => proof.mimeType.type)); @@ -47,6 +48,7 @@ export class ProofPage { })); }) ); + readonly signatures$ = this.proof$.pipe( switchMap(proof => this.signatureRepository.getByProof$(proof)) ); @@ -116,6 +118,10 @@ export class ProofPage { ).subscribe(); } + openInformationPage() { + this.router.navigate(['/information']); + } + private saveCaption(text: string) { this.proof$.pipe( switchMap(proof => this.captionRepository.addOrEdit$({ From 469321d02cc4f0b37f04fad66b47307befd1a9dc Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:20:03 +0800 Subject: [PATCH 04/26] added important and type attribute to info interface --- .../capacitor-provider/capacitor-provider.ts | 68 ++++++++++++++----- .../services/data/information/information.ts | 2 + 2 files changed, 53 insertions(+), 17 deletions(-) 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 b2c405651..d96fe6ce8 100644 --- a/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts +++ b/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts @@ -64,67 +64,93 @@ export class CapacitorProvider extends InformationProvider { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceName'), - value: String(deviceInfo.name) + value: String(deviceInfo.name), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceModel'), - value: String(deviceInfo.model) + value: String(deviceInfo.model), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('devicePlatform'), - value: String(deviceInfo.platform) + value: String(deviceInfo.platform), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('uuid'), - value: String(deviceInfo.uuid) + value: String(deviceInfo.uuid), + important: true, + type: 2 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('appVersion'), - value: String(deviceInfo.appVersion) + value: String(deviceInfo.appVersion), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('appVersionCode'), - value: String(deviceInfo.appBuild) + value: String(deviceInfo.appBuild), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('operatingSystem'), - value: String(deviceInfo.operatingSystem) + value: String(deviceInfo.operatingSystem), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('osVersion'), - value: String(deviceInfo.osVersion) + value: String(deviceInfo.osVersion), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceManufacturer'), - value: String(deviceInfo.manufacturer) + value: String(deviceInfo.manufacturer), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('runningOnVm'), - value: String(deviceInfo.isVirtual) + value: String(deviceInfo.isVirtual), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('usedMemory'), - value: String(deviceInfo.memUsed) + value: String(deviceInfo.memUsed), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('freeDiskSpace'), - value: String(deviceInfo.diskFree) + value: String(deviceInfo.diskFree), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('totalDiskSpace'), - value: String(deviceInfo.diskTotal) + value: String(deviceInfo.diskTotal), + important: false, + type: 0 }); } if (batteryInfo !== undefined) { @@ -132,12 +158,16 @@ export class CapacitorProvider extends InformationProvider { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('batteryLevel'), - value: String(batteryInfo.batteryLevel) + value: String(batteryInfo.batteryLevel), + important: false, + type: 0 }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('batteryCharging'), - value: String(batteryInfo.isCharging) + value: String(batteryInfo.isCharging), + important: false, + type: 0 }); } if (languageCode !== undefined) { @@ -145,7 +175,9 @@ export class CapacitorProvider extends InformationProvider { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceLanguageCode'), - value: String(languageCode.value) + value: String(languageCode.value), + important: false, + type: 0 }); } if (geolocationPosition !== undefined) { @@ -153,7 +185,9 @@ export class CapacitorProvider extends InformationProvider { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('location'), - value: `(${geolocationPosition.coords.latitude}, ${geolocationPosition.coords.longitude})` + value: `(${geolocationPosition.coords.latitude}, ${geolocationPosition.coords.longitude})`, + important: true, + type: 1 }); } return informationList; diff --git a/src/app/services/data/information/information.ts b/src/app/services/data/information/information.ts index 8cd23f736..5ca13e61e 100644 --- a/src/app/services/data/information/information.ts +++ b/src/app/services/data/information/information.ts @@ -3,4 +3,6 @@ export interface Information { readonly provider: string; readonly name: string; readonly value: string; + readonly important: boolean; + readonly type: number; } From 7d7f1962638d8a28a6d196323e01189ca45c4e05 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:25:41 +0800 Subject: [PATCH 05/26] updated --- src/assets/i18n/en-us.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/assets/i18n/en-us.json b/src/assets/i18n/en-us.json index 7ca2f07f7..82a0e3af1 100644 --- a/src/assets/i18n/en-us.json +++ b/src/assets/i18n/en-us.json @@ -2,8 +2,10 @@ "capture": "Capture", "settings": "Settings", "proofDetails": "Proof Details", + "informationDetails": "Information Details", "caption": "Caption", "hash": "Hash", + "other": "Other", "mimeType": "MIME Type", "timestamp": "Timestamp", "information": "Information", From d10c1b4dbfc97aeff53db2e88438182ef060e676 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:26:25 +0800 Subject: [PATCH 06/26] updated information page --- src/app/pages/information/information.page.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index e27a24bd6..9defeb156 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -14,7 +14,7 @@ - Location + {{ t('location') }} @@ -35,7 +35,7 @@

{{information.name}}

- Hash + {{ t('hash') }} @@ -56,7 +56,7 @@

{{information.name}}

- Other + {{ t('other') }} From 097ddfdf9c02d334d382a8f22f5387ab22944f5f Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 13:44:33 +0800 Subject: [PATCH 07/26] updated page routing --- src/app/pages/information/information.page.html | 2 +- src/app/pages/proof/proof.page.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index 9defeb156..7e8fb5782 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -1,7 +1,7 @@ - + diff --git a/src/app/pages/proof/proof.page.html b/src/app/pages/proof/proof.page.html index 4d9b3cf95..b87171266 100644 --- a/src/app/pages/proof/proof.page.html +++ b/src/app/pages/proof/proof.page.html @@ -1,7 +1,7 @@ - + From f21b7ffbcb43ab1c36185843b4db86ec3106f75d Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 22:52:20 +0800 Subject: [PATCH 08/26] updated data structure for information page --- .../pages/information/information.page.html | 18 +++++------ src/app/pages/information/information.page.ts | 32 ++++++++++++++++--- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index 7e8fb5782..d99de864b 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -11,14 +11,14 @@ - + {{ t('location') }} - - + +

{{information.name}}

{{information.value}}

@@ -32,14 +32,14 @@

{{information.name}}

- + {{ t('hash') }} - - + +

{{information.name}}

{{information.value}}

@@ -53,14 +53,14 @@

{{information.name}}

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

{{information.name}}

{{information.value}}

diff --git a/src/app/pages/information/information.page.ts b/src/app/pages/information/information.page.ts index b4c21af90..b7a50d415 100644 --- a/src/app/pages/information/information.page.ts +++ b/src/app/pages/information/information.page.ts @@ -23,13 +23,35 @@ export class InformationPage { readonly hash$ = this.proof$.pipe(map(proof => proof.hash)); - readonly providersWithInformationList$ = this.proof$.pipe( + readonly locationInformation$ = this.proof$.pipe( switchMap(proof => this.informationRepository.getByProof$(proof)), map(informationList => { - const providers = new Set(informationList.map(information => information.provider)); - return [...providers].map(provider => ({ - provider, - informationList: informationList.filter(information => information.provider === provider) + const types = new Array(informationList.map(information => information.type)); + return [...types].map(type => ({ + type, + informationList: informationList.filter(information => information.type === 1) + })); + }) + ); + + readonly hashInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const types = new Array(informationList.map(information => information.type)); + return [...types].map(type => ({ + type, + informationList: informationList.filter(information => information.type === 2) + })); + }) + ); + + readonly otherInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const types = new Array(informationList.map(information => information.type)); + return [...types].map(type => ({ + type, + informationList: informationList.filter(information => information.type === 0) })); }) ); From 33076a19f68bd996f6d9bb23a69db0bbc396c01f Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Tue, 11 Aug 2020 22:53:06 +0800 Subject: [PATCH 09/26] updated data structure for proof page --- src/app/pages/proof/proof.page.html | 9 +++++---- src/app/pages/proof/proof.page.ts | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/app/pages/proof/proof.page.html b/src/app/pages/proof/proof.page.html index b87171266..32b075252 100644 --- a/src/app/pages/proof/proof.page.html +++ b/src/app/pages/proof/proof.page.html @@ -58,14 +58,15 @@

{{ t('information') }}

- - + + {{ providerWithInformationList.provider }} - - + +

{{ information.name }}

{{ information.value }}

diff --git a/src/app/pages/proof/proof.page.ts b/src/app/pages/proof/proof.page.ts index e9fa119aa..b335272c1 100644 --- a/src/app/pages/proof/proof.page.ts +++ b/src/app/pages/proof/proof.page.ts @@ -49,6 +49,17 @@ export class ProofPage { }) ); + readonly information$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const importants = new Array(informationList.map(information => information.important)); + return [...importants].map(important => ({ + important, + informationList: informationList.filter(information => information.important === true) + })); + }) + ); + readonly signatures$ = this.proof$.pipe( switchMap(proof => this.signatureRepository.getByProof$(proof)) ); From c68018a75e780b9c48020fd89da630739097ad5a Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Fri, 14 Aug 2020 08:36:12 +0800 Subject: [PATCH 10/26] fixed file --- .../pages/information/information.page.scss | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss index f18d4a9cf..3904abee3 100644 --- a/src/app/pages/information/information.page.scss +++ b/src/app/pages/information/information.page.scss @@ -1,12 +1,12 @@ ion-slides { - width: 100%; - } - - .slide-card { - width: 100%; - margin-bottom: 35px; - } - - .multiline { - white-space: pre-wrap; - } \ No newline at end of file + width: 100%; +} + +.slide-card { + width: 100%; + margin-bottom: 35px; +} + +.multiline { + white-space: pre-wrap; +} \ No newline at end of file From 81c7f628076780c0b49b85426641bb7f59fceefc Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Fri, 14 Aug 2020 08:46:03 +0800 Subject: [PATCH 11/26] capacitor-provider change --- .../capacitor-provider/capacitor-provider.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 d96fe6ce8..2aac0d74d 100644 --- a/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts +++ b/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts @@ -61,6 +61,13 @@ export class CapacitorProvider extends InformationProvider { const informationList: Information[] = []; if (deviceInfo !== undefined) { informationList.push({ + proofHash: proof.hash, + provider: this.name, + name: this.translocoService.translate('uuid'), + value: String(deviceInfo.uuid), + important: true, + type: 2 + }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceName'), @@ -81,13 +88,6 @@ export class CapacitorProvider extends InformationProvider { value: String(deviceInfo.platform), important: false, type: 0 - }, { - proofHash: proof.hash, - provider: this.name, - name: this.translocoService.translate('uuid'), - value: String(deviceInfo.uuid), - important: true, - type: 2 }, { proofHash: proof.hash, provider: this.name, From b99d4d57e6af9a05b6305e127ed00ad0457255d2 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Fri, 14 Aug 2020 10:34:34 +0800 Subject: [PATCH 12/26] fixed import in information --- src/app/pages/information/information.page.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/pages/information/information.page.ts b/src/app/pages/information/information.page.ts index b7a50d415..a68baf97f 100644 --- a/src/app/pages/information/information.page.ts +++ b/src/app/pages/information/information.page.ts @@ -4,7 +4,7 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; import { map, switchMap, switchMapTo } from 'rxjs/operators'; 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/type'; +import { isNonNullable } from 'src/app/utils/rx-operators'; @UntilDestroy({ checkProperties: true }) @Component({ From fbb387d7289ac4b53cd2d1a9496eff0b4730f965 Mon Sep 17 00:00:00 2001 From: Sean Wu Date: Sun, 16 Aug 2020 22:03:02 +0800 Subject: [PATCH 13/26] Add basic spec for InformationPage. --- .../information/information.page.spec.ts | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/app/pages/information/information.page.spec.ts b/src/app/pages/information/information.page.spec.ts index e69de29bb..53322231a 100644 --- a/src/app/pages/information/information.page.spec.ts +++ b/src/app/pages/information/information.page.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { RouterTestingModule } from '@angular/router/testing'; +import { IonicModule } from '@ionic/angular'; +import { getTranslocoModule } from 'src/app/transloco/transloco-root.module.spec'; +import { InformationPage } from './information.page'; + +describe('InformationPage', () => { + let component: InformationPage; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [InformationPage], + imports: [IonicModule.forRoot(), RouterTestingModule, getTranslocoModule()] + }).compileComponents(); + + fixture = TestBed.createComponent(InformationPage); + component = fixture.componentInstance; + fixture.detectChanges(); + })); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); From a230db12d00a6f9461dc6a69737c9c896d252da0 Mon Sep 17 00:00:00 2001 From: Sean Wu Date: Sun, 16 Aug 2020 22:08:27 +0800 Subject: [PATCH 14/26] Format spaces: 2 --- .../information/information-routing.module.ts | 8 +- .../pages/information/information.module.ts | 16 +- .../pages/information/information.page.html | 142 +++++++++--------- src/app/pages/information/information.page.ts | 104 ++++++------- 4 files changed, 135 insertions(+), 135 deletions(-) diff --git a/src/app/pages/information/information-routing.module.ts b/src/app/pages/information/information-routing.module.ts index f1c33bb10..dc82f9a3e 100644 --- a/src/app/pages/information/information-routing.module.ts +++ b/src/app/pages/information/information-routing.module.ts @@ -3,12 +3,12 @@ import { RouterModule, Routes } from '@angular/router'; import { InformationPage } from './information.page'; const routes: Routes = [{ - path: '', - component: InformationPage + path: '', + component: InformationPage }]; @NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], + imports: [RouterModule.forChild(routes)], + exports: [RouterModule], }) export class InformationPageRoutingModule { } diff --git a/src/app/pages/information/information.module.ts b/src/app/pages/information/information.module.ts index fe1f599f2..c0b55be49 100644 --- a/src/app/pages/information/information.module.ts +++ b/src/app/pages/information/information.module.ts @@ -7,13 +7,13 @@ import { InformationPageRoutingModule } from './information-routing.module'; import { InformationPage } from './information.page'; @NgModule({ - imports: [ - CommonModule, - FormsModule, - IonicModule, - InformationPageRoutingModule, - TranslocoModule - ], - declarations: [InformationPage] + imports: [ + CommonModule, + FormsModule, + IonicModule, + InformationPageRoutingModule, + TranslocoModule + ], + declarations: [InformationPage] }) export class InformationPageModule { } diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index d99de864b..2ad78fdf0 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -1,75 +1,75 @@ - - - - - - - {{ t('informationDetails') }} - + + + + + + + {{ t('informationDetails') }} + - - - - - - {{ t('location') }} - - - - - -

{{information.name}}

-

{{information.value}}

-
-
-
-
-
-
-
-
- - - - - - {{ t('hash') }} - - - - - -

{{information.name}}

-

{{information.value}}

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

{{information.name}}

-

{{information.value}}

-
-
-
-
-
-
-
-
+ + + + + + {{ t('location') }} + + + + + +

{{information.name}}

+

{{information.value}}

+
+
+
+
+
+
+
+
+ + + + + + {{ t('hash') }} + + + + + +

{{information.name}}

+

{{information.value}}

+
+
+
+
+
+
+
+
+ + + + + + {{ t('other') }} + + + + + +

{{information.name}}

+

{{information.value}}

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/pages/information/information.page.ts b/src/app/pages/information/information.page.ts index a68baf97f..525b08dd5 100644 --- a/src/app/pages/information/information.page.ts +++ b/src/app/pages/information/information.page.ts @@ -8,65 +8,65 @@ import { isNonNullable } from 'src/app/utils/rx-operators'; @UntilDestroy({ checkProperties: true }) @Component({ - selector: 'app-information', - templateUrl: './information.page.html', - styleUrls: ['./information.page.scss'], + selector: 'app-information', + templateUrl: './information.page.html', + styleUrls: ['./information.page.scss'], }) export class InformationPage { - readonly proof$ = this.route.paramMap.pipe( - map(params => params.get('hash')), - isNonNullable(), - switchMap(hash => this.proofRepository.getByHash$(hash)), - isNonNullable() - ); + readonly proof$ = this.route.paramMap.pipe( + map(params => params.get('hash')), + isNonNullable(), + switchMap(hash => this.proofRepository.getByHash$(hash)), + isNonNullable() + ); - readonly hash$ = this.proof$.pipe(map(proof => proof.hash)); + readonly hash$ = this.proof$.pipe(map(proof => proof.hash)); - readonly locationInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const types = new Array(informationList.map(information => information.type)); - return [...types].map(type => ({ - type, - informationList: informationList.filter(information => information.type === 1) - })); - }) - ); + readonly locationInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const types = new Array(informationList.map(information => information.type)); + return [...types].map(type => ({ + type, + informationList: informationList.filter(information => information.type === 1) + })); + }) + ); - readonly hashInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const types = new Array(informationList.map(information => information.type)); - return [...types].map(type => ({ - type, - informationList: informationList.filter(information => information.type === 2) - })); - }) - ); + readonly hashInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const types = new Array(informationList.map(information => information.type)); + return [...types].map(type => ({ + type, + informationList: informationList.filter(information => information.type === 2) + })); + }) + ); - readonly otherInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const types = new Array(informationList.map(information => information.type)); - return [...types].map(type => ({ - type, - informationList: informationList.filter(information => information.type === 0) - })); - }) - ); + readonly otherInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => { + const types = new Array(informationList.map(information => information.type)); + return [...types].map(type => ({ + type, + informationList: informationList.filter(information => information.type === 0) + })); + }) + ); - constructor( - private readonly router: Router, - private readonly route: ActivatedRoute, - private readonly proofRepository: ProofRepository, - private readonly informationRepository: InformationRepository, - ) { } + constructor( + private readonly router: Router, + private readonly route: ActivatedRoute, + private readonly proofRepository: ProofRepository, + private readonly informationRepository: InformationRepository, + ) { } - ionViewWillEnter() { - this.proofRepository.refresh$().pipe( - switchMapTo(this.informationRepository.refresh$()), - untilDestroyed(this) - ).subscribe(); - } + ionViewWillEnter() { + this.proofRepository.refresh$().pipe( + switchMapTo(this.informationRepository.refresh$()), + untilDestroyed(this) + ).subscribe(); + } } From 3f4b84d0f01002e6a416d8fbdfe0e5497b028e4d Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 15:43:16 +0800 Subject: [PATCH 15/26] edited information.page --- .../pages/information/information.page.html | 136 +++++++++--------- .../pages/information/information.page.scss | 5 - src/app/pages/information/information.page.ts | 102 ++++++------- 3 files changed, 107 insertions(+), 136 deletions(-) diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index 2ad78fdf0..d20574371 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -1,75 +1,69 @@ - - - - - - - {{ t('informationDetails') }} - + + + + + + + {{ t('informationDetails') }} + - - - - - - {{ t('location') }} - - - - - -

{{information.name}}

-

{{information.value}}

-
-
-
-
-
-
-
-
- - - - - - {{ t('hash') }} - - - - - -

{{information.name}}

-

{{information.value}}

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

{{information.name}}

-

{{information.value}}

-
-
-
-
-
-
-
-
+ + + + + {{ t('location') }} + + + + + +

{{ locationInfo.name }}

+

{{ locationInfo.value }}

+
+
+
+
+
+
+
+ + + + + {{ t('other') }} + + + + + +

{{ otherInfo.name }}

+

{{ otherInfo.value }}

+
+
+
+
+
+
+
+ + + + + {{ t('device') }} + + + + + +

{{ deviceInfo.name }}

+

{{ deviceInfo.value }}

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss index 3904abee3..8a38ab24e 100644 --- a/src/app/pages/information/information.page.scss +++ b/src/app/pages/information/information.page.scss @@ -1,10 +1,5 @@ -ion-slides { - width: 100%; -} - .slide-card { width: 100%; - margin-bottom: 35px; } .multiline { diff --git a/src/app/pages/information/information.page.ts b/src/app/pages/information/information.page.ts index 525b08dd5..697a7bc8e 100644 --- a/src/app/pages/information/information.page.ts +++ b/src/app/pages/information/information.page.ts @@ -1,72 +1,54 @@ import { Component } from '@angular/core'; -import { ActivatedRoute, Router } from '@angular/router'; +import { ActivatedRoute } from '@angular/router'; import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy'; -import { map, switchMap, switchMapTo } from 'rxjs/operators'; +import { map, pluck, switchMap, switchMapTo } 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'; @UntilDestroy({ checkProperties: true }) @Component({ - selector: 'app-information', - templateUrl: './information.page.html', - styleUrls: ['./information.page.scss'], + selector: 'app-information', + templateUrl: './information.page.html', + styleUrls: ['./information.page.scss'], }) export class InformationPage { - readonly proof$ = this.route.paramMap.pipe( - map(params => params.get('hash')), - isNonNullable(), - switchMap(hash => this.proofRepository.getByHash$(hash)), - isNonNullable() - ); - - readonly hash$ = this.proof$.pipe(map(proof => proof.hash)); - - readonly locationInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const types = new Array(informationList.map(information => information.type)); - return [...types].map(type => ({ - type, - informationList: informationList.filter(information => information.type === 1) - })); - }) - ); - - readonly hashInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const types = new Array(informationList.map(information => information.type)); - return [...types].map(type => ({ - type, - informationList: informationList.filter(information => information.type === 2) - })); - }) - ); - - readonly otherInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const types = new Array(informationList.map(information => information.type)); - return [...types].map(type => ({ - type, - informationList: informationList.filter(information => information.type === 0) - })); - }) - ); - - constructor( - private readonly router: Router, - private readonly route: ActivatedRoute, - private readonly proofRepository: ProofRepository, - private readonly informationRepository: InformationRepository, - ) { } - - ionViewWillEnter() { - this.proofRepository.refresh$().pipe( - switchMapTo(this.informationRepository.refresh$()), - untilDestroyed(this) - ).subscribe(); - } + readonly proof$ = this.route.paramMap.pipe( + map(params => params.get('hash')), + isNonNullable(), + switchMap(hash => this.proofRepository.getByHash$(hash)), + 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( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => informationList.filter(information => information.type === InformationType.Other)) + ); + + readonly deviceInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => informationList.filter(information => information.type === InformationType.Device)) + ); + + constructor( + private readonly route: ActivatedRoute, + private readonly proofRepository: ProofRepository, + private readonly informationRepository: InformationRepository, + ) { } + + ionViewWillEnter() { + this.proofRepository.refresh$().pipe( + switchMapTo(this.informationRepository.refresh$()), + untilDestroyed(this) + ).subscribe(); + } } From 1209a11915947b2e928273576a1bf45e905ddaaf Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 15:43:54 +0800 Subject: [PATCH 16/26] edited proof.page --- src/app/pages/proof/proof.page.html | 6 ++--- src/app/pages/proof/proof.page.ts | 39 ++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/app/pages/proof/proof.page.html b/src/app/pages/proof/proof.page.html index 32b075252..22410603f 100644 --- a/src/app/pages/proof/proof.page.html +++ b/src/app/pages/proof/proof.page.html @@ -58,14 +58,14 @@

{{ t('information') }}

- + + *ngFor="let providerWithInformationList of (providersWithImportantInformation$ | async)"> {{ providerWithInformationList.provider }} - +

{{ information.name }}

diff --git a/src/app/pages/proof/proof.page.ts b/src/app/pages/proof/proof.page.ts index 5dfd3df8f..46760c2d1 100644 --- a/src/app/pages/proof/proof.page.ts +++ b/src/app/pages/proof/proof.page.ts @@ -7,6 +7,7 @@ import { defer } from 'rxjs'; import { first, map, pluck, switchMap, switchMapTo } from 'rxjs/operators'; import { ConfirmAlert } from 'src/app/services/confirm-alert/confirm-alert.service'; import { CaptionRepository } from 'src/app/services/data/caption/caption-repository.service'; +import { Importance } 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 { SignatureRepository } from 'src/app/services/data/signature/signature-repository.service'; @@ -39,27 +40,41 @@ export class ProofPage { return ''; }) ); - readonly providersWithInformationList$ = this.proof$.pipe( + // readonly providersWithInformationList$ = this.proof$.pipe( + // switchMap(proof => this.informationRepository.getByProof$(proof)), + // map(informationList => { + // const providers = new Set(informationList.map(information => information.provider)); + // return [...providers].map(provider => ({ + // provider, + // informationList: informationList.filter(information => information.provider === provider) + // })); + // }) + // ); + + readonly providersWithImportantInformation$ = this.proof$.pipe( switchMap(proof => this.informationRepository.getByProof$(proof)), map(informationList => { const providers = new Set(informationList.map(information => information.provider)); return [...providers].map(provider => ({ provider, - informationList: informationList.filter(information => information.provider === provider) + informationList: informationList.filter( + information => information.provider === provider + && information.important === Importance.High + ) })); }) ); - readonly information$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => { - const importants = new Array(informationList.map(information => information.important)); - return [...importants].map(important => ({ - important, - informationList: informationList.filter(information => information.important === true) - })); - }) - ); + // readonly information$ = this.proof$.pipe( + // switchMap(proof => this.informationRepository.getByProof$(proof)), + // map(informationList => { + // const importants = new Array(informationList.map(information => information.important)); + // return [...importants].map(important => ({ + // important, + // informationList: informationList.filter(information => information.important === true) + // })); + // }) + // ); readonly signatures$ = this.proof$.pipe( switchMap(proof => this.signatureRepository.getByProof$(proof)) From e39ac6d20c97e2edb3c8e5f2f63f5fb02c2ab25b Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 15:44:37 +0800 Subject: [PATCH 17/26] edit capacitor-provider --- .../capacitor-provider/capacitor-provider.ts | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) 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 236ce3c04..7d8ebae32 100644 --- a/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts +++ b/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts @@ -2,7 +2,7 @@ import { Plugins } from '@capacitor/core'; import { TranslocoService } from '@ngneat/transloco'; import { defer, Observable, of, zip } from 'rxjs'; import { first, map, switchMap } from 'rxjs/operators'; -import { Information } from 'src/app/services/data/information/information'; +import { Importance, Information, InformationType } from 'src/app/services/data/information/information'; import { InformationRepository } from 'src/app/services/data/information/information-repository.service'; import { Proof } from 'src/app/services/data/proof/proof'; import { PreferenceManager } from 'src/app/utils/preferences/preference-manager'; @@ -66,92 +66,92 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('uuid'), value: String(deviceInfo.uuid), - important: true, - type: 2 + important: Importance.High, + type: InformationType.Other }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceName'), value: String(deviceInfo.name), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceModel'), value: String(deviceInfo.model), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('devicePlatform'), value: String(deviceInfo.platform), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('appVersion'), value: String(deviceInfo.appVersion), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('appVersionCode'), value: String(deviceInfo.appBuild), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('operatingSystem'), value: String(deviceInfo.operatingSystem), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('osVersion'), value: String(deviceInfo.osVersion), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceManufacturer'), value: String(deviceInfo.manufacturer), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('runningOnVm'), value: String(deviceInfo.isVirtual), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('usedMemory'), value: String(deviceInfo.memUsed), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('freeDiskSpace'), value: String(deviceInfo.diskFree), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('totalDiskSpace'), value: String(deviceInfo.diskTotal), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }); } if (batteryInfo !== undefined) { @@ -160,15 +160,15 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('batteryLevel'), value: String(batteryInfo.batteryLevel), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('batteryCharging'), value: String(batteryInfo.isCharging), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }); } if (languageCode !== undefined) { @@ -177,8 +177,8 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('deviceLanguageCode'), value: String(languageCode.value), - important: false, - type: 0 + important: Importance.Low, + type: InformationType.Device }); } if (geolocationPosition !== undefined) { @@ -187,8 +187,8 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('location'), value: `(${geolocationPosition.coords.latitude}, ${geolocationPosition.coords.longitude})`, - important: true, - type: 1 + important: Importance.High, + type: InformationType.Location }); } return informationList; From 199f95140592b741cfa644ac6a0ddc1f99cb0043 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 15:45:07 +0800 Subject: [PATCH 18/26] added enum importance & informationtype --- src/app/services/data/information/information.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/services/data/information/information.ts b/src/app/services/data/information/information.ts index 5ca13e61e..01eb06e51 100644 --- a/src/app/services/data/information/information.ts +++ b/src/app/services/data/information/information.ts @@ -1,8 +1,19 @@ +export const enum Importance { + Low = 'low', + High = 'high' +} + +export const enum InformationType { + Device = 'device', + Location = 'location', + Other = 'other' +} + export interface Information { readonly proofHash: string; readonly provider: string; readonly name: string; readonly value: string; - readonly important: boolean; - readonly type: number; + readonly important: Importance; + readonly type: InformationType; } From d6ce508e7779b3d133db44ea03e4e1d6d5767062 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 15:45:29 +0800 Subject: [PATCH 19/26] edited en-us.json --- src/assets/i18n/en-us.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/assets/i18n/en-us.json b/src/assets/i18n/en-us.json index 48ca98c8d..13e95a7dd 100644 --- a/src/assets/i18n/en-us.json +++ b/src/assets/i18n/en-us.json @@ -50,6 +50,9 @@ "collectDeviceInfo": "Collect Device Info", "collectLocationInfo": "Collect Location Info", "unknownError": "Unknown Error", + "low": "Low", + "high": "High", + "device": "Device", "message": { "areYouSure": "This action cannot be undone.", "publishingProof": "Publishing proof {{hash}} to {{publisherName}}.", From a779c23f7209bf26ecf2e61afffe71475ccaa755 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 15:46:50 +0800 Subject: [PATCH 20/26] removed extra comments --- src/app/pages/proof/proof.page.ts | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/app/pages/proof/proof.page.ts b/src/app/pages/proof/proof.page.ts index 46760c2d1..d484d8dc7 100644 --- a/src/app/pages/proof/proof.page.ts +++ b/src/app/pages/proof/proof.page.ts @@ -40,16 +40,6 @@ export class ProofPage { return ''; }) ); - // readonly providersWithInformationList$ = this.proof$.pipe( - // switchMap(proof => this.informationRepository.getByProof$(proof)), - // map(informationList => { - // const providers = new Set(informationList.map(information => information.provider)); - // return [...providers].map(provider => ({ - // provider, - // informationList: informationList.filter(information => information.provider === provider) - // })); - // }) - // ); readonly providersWithImportantInformation$ = this.proof$.pipe( switchMap(proof => this.informationRepository.getByProof$(proof)), @@ -65,17 +55,6 @@ export class ProofPage { }) ); - // readonly information$ = this.proof$.pipe( - // switchMap(proof => this.informationRepository.getByProof$(proof)), - // map(informationList => { - // const importants = new Array(informationList.map(information => information.important)); - // return [...importants].map(important => ({ - // important, - // informationList: informationList.filter(information => information.important === true) - // })); - // }) - // ); - readonly signatures$ = this.proof$.pipe( switchMap(proof => this.signatureRepository.getByProof$(proof)) ); From 9549aecb5040f26060fbd69016b7a69c21133cd7 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 20:05:49 +0800 Subject: [PATCH 21/26] change spacing --- .../pages/information/information.page.html | 130 +++++++++--------- src/app/pages/information/information.page.ts | 78 +++++------ 2 files changed, 104 insertions(+), 104 deletions(-) diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index d20574371..59de5d854 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -1,69 +1,69 @@ - - - - - - - {{ t('informationDetails') }} - + + + + + + + {{ t('informationDetails') }} + - - - - - {{ t('location') }} - - - - - -

{{ locationInfo.name }}

-

{{ locationInfo.value }}

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

{{ otherInfo.name }}

-

{{ otherInfo.value }}

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

{{ deviceInfo.name }}

-

{{ deviceInfo.value }}

-
-
-
-
-
-
-
+ + + + + {{ t('location') }} + + + + + +

{{ locationInfo.name }}

+

{{ locationInfo.value }}

+
+
+
+
+
+
+
+ + + + + {{ t('other') }} + + + + + +

{{ otherInfo.name }}

+

{{ otherInfo.value }}

+
+
+
+
+
+
+
+ + + + + {{ t('device') }} + + + + + +

{{ deviceInfo.name }}

+

{{ deviceInfo.value }}

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/src/app/pages/information/information.page.ts b/src/app/pages/information/information.page.ts index 697a7bc8e..bab91ab3b 100644 --- a/src/app/pages/information/information.page.ts +++ b/src/app/pages/information/information.page.ts @@ -9,46 +9,46 @@ import { isNonNullable } from 'src/app/utils/rx-operators'; @UntilDestroy({ checkProperties: true }) @Component({ - selector: 'app-information', - templateUrl: './information.page.html', - styleUrls: ['./information.page.scss'], + selector: 'app-information', + templateUrl: './information.page.html', + styleUrls: ['./information.page.scss'], }) export class InformationPage { - readonly proof$ = this.route.paramMap.pipe( - map(params => params.get('hash')), - isNonNullable(), - switchMap(hash => this.proofRepository.getByHash$(hash)), - 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( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => informationList.filter(information => information.type === InformationType.Other)) - ); - - readonly deviceInformation$ = this.proof$.pipe( - switchMap(proof => this.informationRepository.getByProof$(proof)), - map(informationList => informationList.filter(information => information.type === InformationType.Device)) - ); - - constructor( - private readonly route: ActivatedRoute, - private readonly proofRepository: ProofRepository, - private readonly informationRepository: InformationRepository, - ) { } - - ionViewWillEnter() { - this.proofRepository.refresh$().pipe( - switchMapTo(this.informationRepository.refresh$()), - untilDestroyed(this) - ).subscribe(); - } + readonly proof$ = this.route.paramMap.pipe( + map(params => params.get('hash')), + isNonNullable(), + switchMap(hash => this.proofRepository.getByHash$(hash)), + 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( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => informationList.filter(information => information.type === InformationType.Other)) + ); + + readonly deviceInformation$ = this.proof$.pipe( + switchMap(proof => this.informationRepository.getByProof$(proof)), + map(informationList => informationList.filter(information => information.type === InformationType.Device)) + ); + + constructor( + private readonly route: ActivatedRoute, + private readonly proofRepository: ProofRepository, + private readonly informationRepository: InformationRepository, + ) { } + + ionViewWillEnter() { + this.proofRepository.refresh$().pipe( + switchMapTo(this.informationRepository.refresh$()), + untilDestroyed(this) + ).subscribe(); + } } From 58f7fcc456124bcff6514f721417540e26787ac4 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 20:07:03 +0800 Subject: [PATCH 22/26] changed important attribute to importance --- src/app/pages/proof/proof.page.ts | 2 +- .../capacitor-provider/capacitor-provider.ts | 34 +++++++++---------- .../services/data/information/information.ts | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/app/pages/proof/proof.page.ts b/src/app/pages/proof/proof.page.ts index d484d8dc7..b166490e8 100644 --- a/src/app/pages/proof/proof.page.ts +++ b/src/app/pages/proof/proof.page.ts @@ -49,7 +49,7 @@ export class ProofPage { provider, informationList: informationList.filter( information => information.provider === provider - && information.important === Importance.High + && information.importance === Importance.High ) })); }) 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 7d8ebae32..2005d8726 100644 --- a/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts +++ b/src/app/services/collector/information/capacitor-provider/capacitor-provider.ts @@ -66,91 +66,91 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('uuid'), value: String(deviceInfo.uuid), - important: Importance.High, + importance: Importance.High, type: InformationType.Other }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceName'), value: String(deviceInfo.name), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceModel'), value: String(deviceInfo.model), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('devicePlatform'), value: String(deviceInfo.platform), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('appVersion'), value: String(deviceInfo.appVersion), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('appVersionCode'), value: String(deviceInfo.appBuild), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('operatingSystem'), value: String(deviceInfo.operatingSystem), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('osVersion'), value: String(deviceInfo.osVersion), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('deviceManufacturer'), value: String(deviceInfo.manufacturer), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('runningOnVm'), value: String(deviceInfo.isVirtual), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('usedMemory'), value: String(deviceInfo.memUsed), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('freeDiskSpace'), value: String(deviceInfo.diskFree), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('totalDiskSpace'), value: String(deviceInfo.diskTotal), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }); } @@ -160,14 +160,14 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('batteryLevel'), value: String(batteryInfo.batteryLevel), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }, { proofHash: proof.hash, provider: this.name, name: this.translocoService.translate('batteryCharging'), value: String(batteryInfo.isCharging), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }); } @@ -177,7 +177,7 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('deviceLanguageCode'), value: String(languageCode.value), - important: Importance.Low, + importance: Importance.Low, type: InformationType.Device }); } @@ -187,7 +187,7 @@ export class CapacitorProvider extends InformationProvider { provider: this.name, name: this.translocoService.translate('location'), value: `(${geolocationPosition.coords.latitude}, ${geolocationPosition.coords.longitude})`, - important: Importance.High, + importance: Importance.High, type: InformationType.Location }); } diff --git a/src/app/services/data/information/information.ts b/src/app/services/data/information/information.ts index 01eb06e51..99579c40e 100644 --- a/src/app/services/data/information/information.ts +++ b/src/app/services/data/information/information.ts @@ -14,6 +14,6 @@ export interface Information { readonly provider: string; readonly name: string; readonly value: string; - readonly important: Importance; + readonly importance: Importance; readonly type: InformationType; } From cc0a6b8343355c18f9ce7998d0632f0f1df5b03b Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 20:44:03 +0800 Subject: [PATCH 23/26] fixed formatting --- src/app/pages/information/information.page.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss index 8a38ab24e..410d97ad1 100644 --- a/src/app/pages/information/information.page.scss +++ b/src/app/pages/information/information.page.scss @@ -4,4 +4,4 @@ .multiline { white-space: pre-wrap; -} \ No newline at end of file +} From bc4197e7304ee7ca77ff0ed9996df67e0137ecb0 Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 20:58:11 +0800 Subject: [PATCH 24/26] fix Unexpected missing end-of-source newline (no-missing-end-of-source-newline) --- src/app/pages/information/information.page.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss index 410d97ad1..fc6068660 100644 --- a/src/app/pages/information/information.page.scss +++ b/src/app/pages/information/information.page.scss @@ -3,5 +3,5 @@ } .multiline { - white-space: pre-wrap; + white-space: pre-wrap; } From 565a7a8b2291a8313cc2f9ec42796797bb0cfd3b Mon Sep 17 00:00:00 2001 From: ethanwu155 Date: Mon, 17 Aug 2020 21:05:44 +0800 Subject: [PATCH 25/26] fix Unexpected missing end-of-source newline (no-missing-end-of-source-newline) --- src/app/pages/information/information.page.scss | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss index fc6068660..18bf6e8a3 100644 --- a/src/app/pages/information/information.page.scss +++ b/src/app/pages/information/information.page.scss @@ -1,7 +1,8 @@ .slide-card { width: 100%; + margin-bottom: 35px; } .multiline { - white-space: pre-wrap; + white-space: pre-wrap; } From ffe49c43b94cb126b4e456c59e980d772200baa2 Mon Sep 17 00:00:00 2001 From: Sean Wu Date: Mon, 17 Aug 2020 23:46:27 +0800 Subject: [PATCH 26/26] Improve readability. --- .../pages/information/information.page.html | 18 +++++++++--------- .../pages/information/information.page.scss | 1 - src/app/pages/proof/proof.page.ts | 7 +------ 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/app/pages/information/information.page.html b/src/app/pages/information/information.page.html index 59de5d854..8ddba8475 100644 --- a/src/app/pages/information/information.page.html +++ b/src/app/pages/information/information.page.html @@ -16,11 +16,11 @@ {{ t('location') }} - + -

{{ locationInfo.name }}

-

{{ locationInfo.value }}

+

{{ information.name }}

+

{{ information.value }}

@@ -35,11 +35,11 @@

{{ locationInfo.name }}

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

{{ otherInfo.name }}

-

{{ otherInfo.value }}

+

{{ information.name }}

+

{{ information.value }}

@@ -54,11 +54,11 @@

{{ otherInfo.name }}

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

{{ deviceInfo.name }}

-

{{ deviceInfo.value }}

+

{{ information.name }}

+

{{ information.value }}

diff --git a/src/app/pages/information/information.page.scss b/src/app/pages/information/information.page.scss index 18bf6e8a3..410d97ad1 100644 --- a/src/app/pages/information/information.page.scss +++ b/src/app/pages/information/information.page.scss @@ -1,6 +1,5 @@ .slide-card { width: 100%; - margin-bottom: 35px; } .multiline { diff --git a/src/app/pages/proof/proof.page.ts b/src/app/pages/proof/proof.page.ts index b166490e8..aaf868bfe 100644 --- a/src/app/pages/proof/proof.page.ts +++ b/src/app/pages/proof/proof.page.ts @@ -48,8 +48,7 @@ export class ProofPage { return [...providers].map(provider => ({ provider, informationList: informationList.filter( - information => information.provider === provider - && information.importance === Importance.High + information => information.provider === provider && information.importance === Importance.High ) })); }) @@ -124,10 +123,6 @@ export class ProofPage { ).subscribe(); } - openInformationPage() { - this.router.navigate(['/information']); - } - private saveCaption(text: string) { this.proof$.pipe( switchMap(proof => this.captionRepository.addOrEdit$({