Use image field instead of fire storage
This commit is contained in:
parent
617a4b42aa
commit
c43eeee09e
@ -9,8 +9,8 @@
|
|||||||
</nav>
|
</nav>
|
||||||
<ng-container *ngFor="let c of categories | async">
|
<ng-container *ngFor="let c of categories | async">
|
||||||
<mat-card class="m-3" (click)="navigate(c.name)">
|
<mat-card class="m-3" (click)="navigate(c.name)">
|
||||||
<img *ngIf="c.ready" mat-card-image [src]="c.image | async" [alt]="c.name" style="width: 200px; height: 200px;">
|
<img *ngIf="c.image" mat-card-image [src]="c.image" [alt]="c.name" style="width: 200px; height: 200px;">
|
||||||
<mat-divider *ngIf="c.ready" class="custom-line"></mat-divider>
|
<mat-divider *ngIf="c.image" class="custom-line"></mat-divider>
|
||||||
<mat-card-content>
|
<mat-card-content>
|
||||||
<h5>{{c.name}}</h5>
|
<h5>{{c.name}}</h5>
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
|
@ -15,7 +15,6 @@ export class CategoriesComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private db: AngularFirestore,
|
private db: AngularFirestore,
|
||||||
private storage: AngularFireStorage,
|
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
public breadcrumb: BreadcrumbService
|
public breadcrumb: BreadcrumbService
|
||||||
@ -32,13 +31,7 @@ export class CategoriesComponent {
|
|||||||
.valueChanges()
|
.valueChanges()
|
||||||
.pipe(
|
.pipe(
|
||||||
map(rows =>
|
map(rows =>
|
||||||
rows
|
rows.filter((row: any) => (!this.category && !row.parent) || (this.category && row.parent == this.category))
|
||||||
.filter((row: any) => (!this.category && !row.parent) || (this.category && row.parent == this.category))
|
|
||||||
.map((row: any) => {
|
|
||||||
row.image = this.storage.ref(`${row.name.toLowerCase()}.jpg`).getDownloadURL();
|
|
||||||
row.image.subscribe(() => (row.ready = true));
|
|
||||||
return row;
|
|
||||||
})
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user