Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI series #606

Merged
merged 16 commits into from
Apr 2, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
[routerLink]="['post-capture-details', { id: postCapture.id }]"
>
<ion-img [src]="postCapture.asset_file_thumbnail"></ion-img>
<mat-icon class="uploaded">shopping_bag</mat-icon>
<mat-icon class="from-store">shopping_bag</mat-icon>
</mat-grid-tile>
</mat-grid-list>
</div>

<div class="series-wrapper" *ngSwitchCase="'Series'">
<app-series-card routerLink="series"></app-series-card>
<app-series-card
*ngFor="let series of getSeries$ | async"
[src]="series.cover_image"
<div
CS6 marked this conversation as resolved.
Show resolved Hide resolved
class="series-image"
*ngFor="let series of series$ | async"
[routerLink]="['series', { id: series.id, cover: series.cover_image }]"
>
</app-series-card>
<ion-img [src]="series.cover_image"></ion-img>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
margin: 0;
padding: 8px;
text-align: center;
background-color: var(--ion-color-light);
color: darkgray;
font-weight: 500;
font-size: 0.9em;
background-color: var(--ion-color-light);
}

.segments {
Expand Down Expand Up @@ -54,10 +54,29 @@ mat-icon {
z-index: 10;
}

mat-icon.uploaded {
mat-icon.from-store {
position: absolute;
bottom: 5px;
left: 5px;
font-size: 20px;
opacity: 90%;
}

.series-image {
margin-top: 10px;
margin-bottom: 20px;
width: 100%;
height: 300px;
max-width: 500px;
max-height: 300px;
overflow: hidden;
box-sizing: border-box;
box-shadow: 4px 0 4px #a5a5a5;
border-radius: 5px;

ion-img {
object-fit: cover;
object-position: center;
height: 100%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,11 @@ export class PostCaptureTabComponent {
)
);

// collected=True
readonly getSeries$ = this.networkService.connected$.pipe(
readonly series$ = this.networkService.connected$.pipe(
switchMap(isConnected =>
iif(
() => isConnected,
this.diaBackendSeriesRepository.readSeries$().pipe(
this.diaBackendSeriesRepository.fetchSeries$().pipe(
pluck('results')
// map(series => series.filter(a => a.in_store == true))
CS6 marked this conversation as resolved.
Show resolved Hide resolved
)
Expand Down
10 changes: 6 additions & 4 deletions src/app/features/home/post-capture-tab/series/series.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@
<div class="toolbar-spacer"></div>
</mat-toolbar>
<div class="page-content">
<app-series-card [src]="cover"></app-series-card>
<div class="series-image">
CS6 marked this conversation as resolved.
Show resolved Hide resolved
<ion-img [src]="cover"></ion-img>
</div>
<mat-grid-list cols="3" gutterSize="8px">
<mat-grid-tile
class="collection-general"
*ngFor="let collection of collectionGeneral"
>
<img *ngIf="collection.img != null" [src]="collection.img" />
<ion-img *ngIf="collection.img" [src]="collection.img"></ion-img>
</mat-grid-tile>
<mat-grid-tile
class="collection-special"
*ngFor="let collection of collectionSpecial"
>
<img *ngIf="collection.img != null" [src]="collection.img" />
<ion-img *ngIf="collection.img" [src]="collection.img"></ion-img>
</mat-grid-tile>
<mat-grid-tile
class="collection-rare"
*ngFor="let collection of collectionRare"
>
<img *ngIf="collection.img != null" [src]="collection.img" />
<ion-img *ngIf="collection.img" [src]="collection.img"></ion-img>
</mat-grid-tile>
</mat-grid-list>
</div>
23 changes: 20 additions & 3 deletions src/app/features/home/post-capture-tab/series/series.page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ mat-grid-tile {
}

.page-content {
padding-left: 16px;
padding-right: 16px;
padding-bottom: 16px;
padding: 16px;
}

.collection-general {
Expand All @@ -50,3 +48,22 @@ mat-grid-tile {
border-radius: 4px;
background: #ffaced;
}

.series-image {
margin-top: 10px;
margin-bottom: 20px;
width: 100%;
height: 300px;
max-width: 500px;
max-height: 300px;
overflow: hidden;
box-sizing: border-box;
box-shadow: 4px 0 4px #a5a5a5;
border-radius: 5px;

ion-img {
object-fit: cover;
object-position: center;
height: 100%;
}
}
27 changes: 10 additions & 17 deletions src/app/features/home/post-capture-tab/series/series.page.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Component } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-series',
templateUrl: './series.page.html',
styleUrls: ['./series.page.scss'],
})
export class SeriesPage implements OnInit {
id: string | null | undefined;
cover: string | null | undefined;
collectionGeneral = [
export class SeriesPage {
readonly id = this.route.snapshot.paramMap.get('id');
CS6 marked this conversation as resolved.
Show resolved Hide resolved
readonly cover = this.route.snapshot.paramMap.get('cover');

readonly collectionGeneral = [
{ img: null },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace null with undefined. Always prefer undefined if possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace null with undefined if possible.

{ img: 'https://material.angular.io/assets/img/examples/shiba1.jpg' },
{ img: null },
Expand All @@ -22,20 +23,12 @@ export class SeriesPage implements OnInit {
{ img: null },
{ img: null },
];
collectionSpecial = [{ img: null }, { img: null }, { img: null }];
collectionRare = [
readonly collectionSpecial = [{ img: null }, { img: null }, { img: null }];
readonly collectionRare = [
{ img: null },
{ img: 'https://material.angular.io/assets/img/examples/shiba2.jpg' },
{ img: null },
];

async ngOnInit() {
this.id = this.route.snapshot.paramMap.get('id');
this.cover = this.route.snapshot.paramMap.get('cover');
}

constructor(
private readonly router: Router,
private readonly route: ActivatedRoute
) {}
constructor(private readonly route: ActivatedRoute) {}
}
5 changes: 0 additions & 5 deletions src/app/shared/core/series-card/series-card.component.html

This file was deleted.

34 changes: 0 additions & 34 deletions src/app/shared/core/series-card/series-card.component.scss

This file was deleted.

24 changes: 0 additions & 24 deletions src/app/shared/core/series-card/series-card.component.spec.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/app/shared/core/series-card/series-card.component.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
// tslint:disable: no-magic-numbers
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments for TSLint. It's deprecated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mark this "unresolved" converation resolved? Still, you did not remove the deprecated comments for TSLint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why mark this "unresolved" converation resolved? Still, you did not remove the deprecated comments for TSLint.

import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { defer, Subject, throwError } from 'rxjs';
import { defer, ReplaySubject, throwError } from 'rxjs';
import { catchError, concatMap } from 'rxjs/operators';
import { DiaBackendAuthService } from '../auth/dia-backend-auth.service';
import { NotFoundErrorResponse } from '../errors';
import { PaginatedResponse } from '../pagination';
import { BASE_URL } from '../secret';

@Injectable({
providedIn: 'root',
})
export class DiaBackendSeriesRepository {
private readonly postCapturesUpdated$ = new Subject<{ reason?: string }>();

private readonly postCapturesCache$ = new ReplaySubject<
CS6 marked this conversation as resolved.
Show resolved Hide resolved
PaginatedResponse<DiaBackendSeries>
>(1);
constructor(
private readonly httpClient: HttpClient,
private readonly authService: DiaBackendAuthService
) {}

readSeries$() {
fetchSeries$() {
CS6 marked this conversation as resolved.
Show resolved Hide resolved
return defer(() => this.authService.getAuthHeaders()).pipe(
concatMap(headers =>
this.httpClient.get<DiaBackendSeries>(`${BASE_URL}/api/v2/series/`, {
headers,
})
this.httpClient.get<PaginatedResponse<DiaBackendSeries>>(
`${BASE_URL}/api/v2/series/`,
{
headers,
}
)
),
catchError((err: unknown) => {
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
CS6 marked this conversation as resolved.
Show resolved Hide resolved
if (err instanceof HttpErrorResponse && err.status === 404) {
return throwError(new NotFoundErrorResponse(err));
}
Expand All @@ -39,14 +43,6 @@ export class DiaBackendSeriesRepository {
export interface DiaBackendSeries {
CS6 marked this conversation as resolved.
Show resolved Hide resolved
readonly id: string;
readonly collections: string;
readonly in_store: boolean | null | undefined;
readonly owner: string;
readonly owner_name: string;
readonly type: string;
readonly cover_image: string | null | undefined;
readonly title: string;
readonly collected: boolean;
readonly description: string;
readonly created_at: string;
readonly updated_at: string;
readonly in_store: boolean | null;
readonly cover_image: string | null;
}