Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9027e26
add information page
ethanwu155 Aug 11, 2020
9c81dec
updated app-routing with info page route
ethanwu155 Aug 11, 2020
f9637cb
updated proofs page
ethanwu155 Aug 11, 2020
469321d
added important and type attribute to info interface
ethanwu155 Aug 11, 2020
7d7f196
updated
ethanwu155 Aug 11, 2020
d10c1b4
updated information page
ethanwu155 Aug 11, 2020
097ddfd
updated page routing
ethanwu155 Aug 11, 2020
f21b7ff
updated data structure for information page
ethanwu155 Aug 11, 2020
33076a1
updated data structure for proof page
ethanwu155 Aug 11, 2020
c68018a
fixed file
ethanwu155 Aug 14, 2020
81c7f62
capacitor-provider change
ethanwu155 Aug 14, 2020
701bbca
Merge branch 'develop' into feature-metadata-dialogue
ethanwu155 Aug 14, 2020
b99d4d5
fixed import in information
ethanwu155 Aug 14, 2020
c1b037b
Merge branch 'feature-metadata-dialogue' of https://github.com/number…
ethanwu155 Aug 14, 2020
fbb387d
Add basic spec for InformationPage.
seanwu1105 Aug 16, 2020
a230db1
Format spaces: 2
seanwu1105 Aug 16, 2020
12185cd
Merge branch 'develop' into feature-metadata-dialogue
seanwu1105 Aug 16, 2020
3f4b84d
edited information.page
ethanwu155 Aug 17, 2020
1209a11
edited proof.page
ethanwu155 Aug 17, 2020
e39ac6d
edit capacitor-provider
ethanwu155 Aug 17, 2020
199f951
added enum importance & informationtype
ethanwu155 Aug 17, 2020
d6ce508
edited en-us.json
ethanwu155 Aug 17, 2020
a779c23
removed extra comments
ethanwu155 Aug 17, 2020
9549aec
change spacing
ethanwu155 Aug 17, 2020
58f7fcc
changed important attribute to importance
ethanwu155 Aug 17, 2020
cc0a6b8
fixed formatting
ethanwu155 Aug 17, 2020
bc4197e
fix Unexpected missing end-of-source newline (no-missing-end-of-sourc…
ethanwu155 Aug 17, 2020
565a7a8
fix Unexpected missing end-of-source newline (no-missing-end-of-sourc…
ethanwu155 Aug 17, 2020
e1803b6
Merge branch 'develop' into feature-metadata-dialogue
seanwu1105 Aug 17, 2020
ffe49c4
Improve readability.
seanwu1105 Aug 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
14 changes: 14 additions & 0 deletions src/app/pages/information/information-routing.module.ts
Original file line number Diff line number Diff line change
@@ -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 { }
19 changes: 19 additions & 0 deletions src/app/pages/information/information.module.ts
Original file line number Diff line number Diff line change
@@ -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 { }
69 changes: 69 additions & 0 deletions src/app/pages/information/information.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<ion-header *transloco="let t">
<ion-toolbar>
<ion-buttons slot="start">
<ion-button [routerLink]="['/proof', {hash: (hash$ | async)}]" routerDirection="back">
<ion-icon slot="icon-only" name="arrow-back"></ion-icon>
</ion-button>
</ion-buttons>
<ion-title>{{ t('informationDetails') }}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content *transloco="let t">
<ion-item>
<ion-slide>
<ion-card class="slide-card">
<ion-card-header>
<ion-card-title>{{ t('location') }}</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-list lines="none" *ngFor="let information of (locationInformation$ | async)">
<ion-item>
<ion-label class="ion-text-wrap">
<h3>{{ information.name }}</h3>
<p>{{ information.value }}</p>
</ion-label>
</ion-item>
</ion-list>
</ion-card-content>
</ion-card>
</ion-slide>
</ion-item>
<ion-item>
<ion-slide>
<ion-card class="slide-card">
<ion-card-header>
<ion-card-title>{{ t('other') }}</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-list lines="none" *ngFor="let information of (otherInformation$ | async)">
<ion-item>
<ion-label class="ion-text-wrap">
<h3>{{ information.name }}</h3>
<p>{{ information.value }}</p>
</ion-label>
</ion-item>
</ion-list>
</ion-card-content>
</ion-card>
</ion-slide>
</ion-item>
<ion-item>
<ion-slide>
<ion-card class="slide-card">
<ion-card-header>
<ion-card-title>{{ t('device') }}</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-list lines="none" *ngFor="let information of (deviceInformation$ | async)">
<ion-item>
<ion-label class="ion-text-wrap">
<h3>{{ information.name }}</h3>
<p>{{ information.value }}</p>
</ion-label>
</ion-item>
</ion-list>
</ion-card-content>
</ion-card>
</ion-slide>
</ion-item>
</ion-content>
7 changes: 7 additions & 0 deletions src/app/pages/information/information.page.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.slide-card {
width: 100%;
}

.multiline {
white-space: pre-wrap;
}
25 changes: 25 additions & 0 deletions src/app/pages/information/information.page.spec.ts
Original file line number Diff line number Diff line change
@@ -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<InformationPage>;

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();
});
});
54 changes: 54 additions & 0 deletions src/app/pages/information/information.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
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'],
})
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();
}
}
15 changes: 10 additions & 5 deletions src/app/pages/proof/proof.page.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<ion-header *transloco="let t">
<ion-toolbar>
<ion-buttons slot="start">
<ion-button routerLink=".." routerDirection="back">
<ion-button [routerLink]="['/storage']" routerDirection="back">
<ion-icon slot="icon-only" name="arrow-back"></ion-icon>
</ion-button>
</ion-buttons>
Expand Down Expand Up @@ -58,20 +58,25 @@ <h2>{{ t('information') }}</h2>
</ion-list-header>
<ion-item>
<ion-slides pager>
<ion-slide *ngFor="let providerWithInformationList of (providersWithInformationList$ | async)">
<ion-card class="slide-card">
<ion-slide>
<ion-card class="slide-card"
*ngFor="let providerWithInformationList of (providersWithImportantInformation$ | async)">
<ion-card-header>
<ion-card-title>{{ providerWithInformationList.provider }}</ion-card-title>
</ion-card-header>
<ion-card-content>
<ion-list>
<ion-item *ngFor="let information of providerWithInformationList.informationList">
<ion-list *ngFor="let information of providerWithInformationList.informationList">
<ion-item>
<ion-label class="ion-text-wrap">
<h3>{{ information.name }}</h3>
<p>{{ information.value }}</p>
</ion-label>
</ion-item>
</ion-list>
<section>
<ion-button expand="block" [routerLink]="['/information', {hash: (hash$ | async)}]">View All
</ion-button>
</section>
</ion-card-content>
</ion-card>
</ion-slide>
Expand Down
10 changes: 8 additions & 2 deletions src/app/pages/proof/proof.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -27,6 +28,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(pluck('hash'));
readonly mimeType$ = this.proof$.pipe(pluck('mimeType', 'type'));
Expand All @@ -38,16 +40,20 @@ export class ProofPage {
return '';
})
);
readonly providersWithInformationList$ = this.proof$.pipe(

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.importance === Importance.High
)
}));
})
);

readonly signatures$ = this.proof$.pipe(
switchMap(proof => this.signatureRepository.getByProof$(proof))
);
Expand Down
Loading