Added a store page
This commit is contained in:
parent
fa8df74ece
commit
10db284541
@ -14,22 +14,35 @@ import {HomeComponent} from './home/home.component';
|
|||||||
import {ServiceWorkerModule} from '@angular/service-worker';
|
import {ServiceWorkerModule} from '@angular/service-worker';
|
||||||
import {FormulaManagerComponent} from './formulaManager/formulaManager.component';
|
import {FormulaManagerComponent} from './formulaManager/formulaManager.component';
|
||||||
import {NgxElectronModule} from 'ngx-electron';
|
import {NgxElectronModule} from 'ngx-electron';
|
||||||
import { AboutComponent } from './about/about.component';
|
import {AboutComponent} from './about/about.component';
|
||||||
|
import {CategoriesComponent} from './store/categories.component';
|
||||||
|
import {AngularFireStorageModule} from 'angularfire2/storage';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [AppComponent, ConvertFromGPipe, ConvertToGPipe, FormulaManagerComponent, HomeComponent, ScalePipe, AboutComponent],
|
declarations: [
|
||||||
|
AppComponent,
|
||||||
|
CategoriesComponent,
|
||||||
|
ConvertFromGPipe,
|
||||||
|
ConvertToGPipe,
|
||||||
|
FormulaManagerComponent,
|
||||||
|
HomeComponent,
|
||||||
|
ScalePipe,
|
||||||
|
AboutComponent
|
||||||
|
],
|
||||||
imports: [
|
imports: [
|
||||||
AngularMaterialModule,
|
AngularMaterialModule,
|
||||||
AngularFireModule.initializeApp(environment.firebase),
|
AngularFireModule.initializeApp(environment.firebase),
|
||||||
AngularFirestoreModule,
|
AngularFirestoreModule,
|
||||||
|
AngularFireStorageModule,
|
||||||
BrowserAnimationsModule,
|
BrowserAnimationsModule,
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
FormsModule,
|
FormsModule,
|
||||||
NgxElectronModule,
|
NgxElectronModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
RouterModule.forRoot([
|
RouterModule.forRoot([
|
||||||
{path: 'formulaManager', component: FormulaManagerComponent},
|
|
||||||
{path: 'about', component: AboutComponent},
|
{path: 'about', component: AboutComponent},
|
||||||
|
{path: 'formulaManager', component: FormulaManagerComponent},
|
||||||
|
{path: 'store', component: CategoriesComponent},
|
||||||
{path: '**', component: HomeComponent}
|
{path: '**', component: HomeComponent}
|
||||||
]),
|
]),
|
||||||
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production})
|
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production})
|
||||||
|
11
src/app/store/categories.component.html
Normal file
11
src/app/store/categories.component.html
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="row py-5">
|
||||||
|
<mat-card *ngFor="let c of categories | async">
|
||||||
|
<img mat-card-image [src]="c.image | async" [alt]="c.name">
|
||||||
|
<mat-divider class="custom-line"></mat-divider>
|
||||||
|
<mat-card-content>
|
||||||
|
<h3>{{c.name}}</h3>
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</div>
|
||||||
|
</div>
|
26
src/app/store/categories.component.ts
Normal file
26
src/app/store/categories.component.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import {Component} from '@angular/core';
|
||||||
|
import {AngularFirestore} from 'angularfire2/firestore';
|
||||||
|
import {AngularFireStorage} from 'angularfire2/storage';
|
||||||
|
import {map} from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'store',
|
||||||
|
templateUrl: 'categories.component.html'
|
||||||
|
})
|
||||||
|
export class CategoriesComponent {
|
||||||
|
categories;
|
||||||
|
|
||||||
|
constructor(private db: AngularFirestore, private storage: AngularFireStorage) {
|
||||||
|
this.categories = this.db
|
||||||
|
.collection('categories')
|
||||||
|
.valueChanges()
|
||||||
|
.pipe(
|
||||||
|
map(rows =>
|
||||||
|
rows.map((row: any) => {
|
||||||
|
row.image = this.storage.ref(`${row.name.toLowerCase()}.jpg`).getDownloadURL();
|
||||||
|
return row;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user