Skip to content

Commit

Permalink
Notification and Booked cuisines from database
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraagrijal3138 committed Apr 17, 2018
1 parent 0e2dcef commit b22e0c9
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/app/cuisines/cuisines.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ export class CuisinesService {

cuisines : Observable<any[]>;
usercuisines: Observable<any[]>;
notification: Observable<any[]>;
bookedCuisines: Observable<any[]>;

constructor(db: AngularFireDatabase, as: AuthService){
this.cuisines = db.list('cuisines').valueChanges();
this.usercuisines = db.list('user-cuisines/'+as.auth.currentUser.uid).valueChanges();
this.notification = db.list('users/'+as.auth.currentUser.uid+ '/notification').valueChanges();
this.bookedCuisines = db.list('users/'+as.auth.currentUser.uid+ '/bokedcuisines').valueChanges();
}
}

Expand Down
37 changes: 35 additions & 2 deletions src/app/dashboard/dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,39 @@ <h1>
</p>
<app-hostcuisines></app-hostcuisines>
</mat-tab>
<mat-tab label="Booked Cuisines">Content 2</mat-tab>
<mat-tab label="Notifications">Content 2</mat-tab>
<mat-tab label="Booked Cuisines">
<mat-expansion-panel *ngFor="let book of (booked | async)">
<mat-expansion-panel-header>
<mat-panel-title>
{{ book.cuisineName }}
</mat-panel-title>
</mat-expansion-panel-header>
<mat-panel-description>
<mat-list>
<mat-list-item>Date: {{ book.date }}</mat-list-item>
<mat-list-item>Time: {{ book.startTime }}</mat-list-item>
<mat-list-item>Dorm: {{ book.dormName }}</mat-list-item>
<mat-list-item>Address1: {{ book.streetAddress1 }}</mat-list-item>
<mat-list-item>Address2: {{ book.streetAddress2 }}</mat-list-item>
<mat-divider></mat-divider>
</mat-list>
</mat-panel-description>
</mat-expansion-panel>
</mat-tab>
<mat-tab label="Notifications">
<mat-list *ngFor="let notifi of (notifications | async)">
<mat-list-item>{{ notifi.notification }}</mat-list-item>
<mat-divider></mat-divider>
</mat-list>
</mat-tab>
</mat-tab-group>

<!-- <mat-list *ngFor="let book of (booked | async)">
<mat-list-item>Cuisine Name: {{ book.cuisineName }}</mat-list-item>
<mat-list-item>Date: {{ book.date }}</mat-list-item>
<mat-list-item>Time: {{ book.startTime }}</mat-list-item>
<mat-list-item>Dorm: {{ book.dormName }}</mat-list-item>
<mat-list-item>Address1: {{ book.streetAddress1 }}</mat-list-item>
<mat-list-item>Address2: {{ book.streetAddress2 }}</mat-list-item>
<mat-divider></mat-divider>
</mat-list> -->
17 changes: 15 additions & 2 deletions src/app/dashboard/dashboard.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth.service';
import { Router } from '@angular/router';
import { CuisinesService } from '../cuisines/cuisines.service';
import { Observable } from 'rxjs/Observable';

@Component({
selector: 'app-dashboard',
Expand All @@ -9,13 +11,24 @@ import { Router } from '@angular/router';
})
export class DashboardComponent implements OnInit {
userName: String;

notifications : Observable<any[]>;
booked: Observable<any[]>;
constructor(private authService: AuthService,
private router: Router) {
private router: Router,
private cuisinesService: CuisinesService) {
this.userName = this.authService.auth.currentUser.displayName;
console.log(this.notifications);
}


ngOnInit() {
this.notifications = this.cuisinesService.notification;
this.booked = this.cuisinesService.bookedCuisines;
// this.cuisinesService.notification
// .subscribe(
// (message : any) => {
// console.log(message);
// }
// );
}
}
6 changes: 6 additions & 0 deletions src/app/material.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {MatIconModule} from '@angular/material/icon';
import {MatCheckboxModule} from '@angular/material/checkbox';
import {MatTabsModule} from '@angular/material/tabs';
import {MatExpansionModule} from '@angular/material/expansion';
import {MatDividerModule} from '@angular/material/divider';
import {MatListModule} from '@angular/material/list';

@NgModule({
imports: [MatInputModule,
Expand All @@ -22,6 +24,8 @@ import {MatExpansionModule} from '@angular/material/expansion';
MatIconModule,
MatTabsModule,
MatExpansionModule,
MatDividerModule,
MatListModule,
MatFormFieldModule],
exports: [MatInputModule,
MatStepperModule,
Expand All @@ -33,6 +37,8 @@ import {MatExpansionModule} from '@angular/material/expansion';
MatIconModule,
MatTabsModule,
MatExpansionModule,
MatDividerModule,
MatListModule,
MatFormFieldModule],
})
export class Material { }

0 comments on commit b22e0c9

Please sign in to comment.