From 1186bc8508acf1119344e1770b7c9e0764e77da4 Mon Sep 17 00:00:00 2001 From: zvon Date: Tue, 15 Sep 2020 22:57:03 +0200 Subject: [PATCH] Use proper source, only update menus when changing week/today not whole restaurant --- .../restaurants/restaurants.component.html | 4 ++-- src/app/restaurants/restaurants.component.ts | 24 ++++++++++++++----- src/app/services/lunch/lunch.service.ts | 2 +- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/app/restaurants/restaurants.component.html b/src/app/restaurants/restaurants.component.html index ba74281..d8e57fb 100644 --- a/src/app/restaurants/restaurants.component.html +++ b/src/app/restaurants/restaurants.component.html @@ -1,6 +1,6 @@

Restaurants

- - + +
diff --git a/src/app/restaurants/restaurants.component.ts b/src/app/restaurants/restaurants.component.ts index 25ca122..7a371b8 100644 --- a/src/app/restaurants/restaurants.component.ts +++ b/src/app/restaurants/restaurants.component.ts @@ -19,12 +19,6 @@ export class RestaurantsComponent implements OnInit { this.getTodayOnly(); } - getAllDays(): void { - this.lunchService.getRestaurants().subscribe( restaurants => { - this.restaurants = restaurants; - }); - } - getTodayOnly(): void { const d = new Date(); const dayName = this.days[d.getDay()]; @@ -33,4 +27,22 @@ export class RestaurantsComponent implements OnInit { }); } + getTodayOnlyUpdate(): void { + const d = new Date(); + const dayName = this.days[d.getDay()]; + this.lunchService.getRestaurantsForDay(dayName).subscribe( restaurants => { + for (let i = 0; i < restaurants.length; i++) { + this.restaurants[i].menus = restaurants[i].menus; + } + }); + } + + getAllDaysUpdate(): void { + this.lunchService.getRestaurants().subscribe( restaurants => { + for (let i = 0; i < restaurants.length; i++) { + this.restaurants[i].menus = restaurants[i].menus; + } + }); + } + } diff --git a/src/app/services/lunch/lunch.service.ts b/src/app/services/lunch/lunch.service.ts index da96f4f..57f7e98 100644 --- a/src/app/services/lunch/lunch.service.ts +++ b/src/app/services/lunch/lunch.service.ts @@ -20,7 +20,7 @@ export class LunchService { private restaurantAdapter: RestaurantAdapter, private menuAdapter: MenuAdapter, private mealAdapter: MealAdapter) { - this.serviceUri = 'http://localhost:1984/'; + this.serviceUri = 'https://lunch.zvon.tech:1985/'; this.getUri = 'get'; this.getRestaurantParam = 'restaurant'; this.getDayParam = 'day';