diff --git a/src/app/core/core.module.ts b/src/app/core/core.module.ts index a13e14b..8aa1ffe 100644 --- a/src/app/core/core.module.ts +++ b/src/app/core/core.module.ts @@ -5,8 +5,6 @@ import { HeaderComponent } from "./header/header.component"; import { HomeComponent } from "./home/home.component"; import { SharedModule } from "../shared/shared.module"; import { AppRoutingModule } from "../app-routing.module"; -import { RecipeService } from "../recipes/recipe.service"; -import { DataStorageService } from "../shared/data-storage.service"; import { AuthInterceptor } from "../shared/auth.interceptor"; import { LoggingInterceptor } from "../shared/logging.interceptor"; @@ -24,8 +22,6 @@ import { LoggingInterceptor } from "../shared/logging.interceptor"; HeaderComponent ], providers: [ - RecipeService, - DataStorageService, {provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true}, {provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptor, multi: true} ], diff --git a/src/app/core/header/header.component.ts b/src/app/core/header/header.component.ts index fb6863a..732863a 100644 --- a/src/app/core/header/header.component.ts +++ b/src/app/core/header/header.component.ts @@ -2,7 +2,6 @@ import { Component, OnInit } from "@angular/core"; import { Store } from "@ngrx/store"; import { Observable } from "rxjs/Observable"; -import { DataStorageService } from "../../shared/data-storage.service"; import * as fromApp from '../../ngrx/app.reducers'; import * as fromAuth from '../../auth/ngrx/auth.reducers'; import * as AuthActions from '../../auth/ngrx/auth.actions'; @@ -15,7 +14,7 @@ import * as RecipeActions from '../../recipes/ngrx/recipe.actions'; export class HeaderComponent implements OnInit { authState: Observable; - constructor(private dataStorageService: DataStorageService, private store: Store) {} + constructor(private store: Store) {} ngOnInit() { this.authState = this.store.select('auth') diff --git a/src/app/recipes/recipe-detail/recipe-detail.component.ts b/src/app/recipes/recipe-detail/recipe-detail.component.ts index 4f29d52..0a59a87 100644 --- a/src/app/recipes/recipe-detail/recipe-detail.component.ts +++ b/src/app/recipes/recipe-detail/recipe-detail.component.ts @@ -7,7 +7,7 @@ import { Recipe } from '../recipe.model'; import * as ShoppingListActions from '../../shopping-list/ngrx/shopping-list.actions'; import * as fromApp from '../../ngrx/app.reducers'; import * as fromRecipe from '../ngrx/recipe.reducers'; -import * as RecipeACtions from '../ngrx/recipe.actions'; +import * as RecipeActions from '../ngrx/recipe.actions'; @Component({ selector: 'app-recipe-detail', @@ -45,7 +45,7 @@ export class RecipeDetailComponent implements OnInit { } onDelete() { - this.store.dispatch(new RecipeACtions.DeleteRecipe(this.id)); + this.store.dispatch(new RecipeActions.DeleteRecipe(this.id)); this.router.navigate(['/recipes']); } } diff --git a/src/app/recipes/recipe-list/recipe-list.component.ts b/src/app/recipes/recipe-list/recipe-list.component.ts index a849cd2..5e63ae9 100644 --- a/src/app/recipes/recipe-list/recipe-list.component.ts +++ b/src/app/recipes/recipe-list/recipe-list.component.ts @@ -3,9 +3,6 @@ import { Router, ActivatedRoute } from '@angular/router'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs/Observable'; - -import { Recipe } from '../recipe.model'; -import { RecipeService } from '../recipe.service'; import * as fromRecipe from '../ngrx/recipe.reducers'; @Component({ diff --git a/src/app/recipes/recipe.service.ts b/src/app/recipes/recipe.service.ts deleted file mode 100644 index 6b8c0e5..0000000 --- a/src/app/recipes/recipe.service.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { EventEmitter } from "@angular/core"; -import { Subject } from "rxjs/Subject"; - -import { Recipe } from "./recipe.model"; -import { Ingredient } from "../shared/ingredient.model"; - -export class RecipeService { - recipesChanged = new Subject(); - private recipes: Recipe[] = []; - - replaceRecipes(recipes: Recipe[]) { - this.recipes = recipes; - this.recipesChanged.next(this.recipes.slice()); - } - - getRecipes() { - return this.recipes.slice(); - } -} \ No newline at end of file diff --git a/src/app/recipes/recipes.component.ts b/src/app/recipes/recipes.component.ts index 03c0f2d..443d3b9 100644 --- a/src/app/recipes/recipes.component.ts +++ b/src/app/recipes/recipes.component.ts @@ -1,7 +1,5 @@ import { Component, OnInit } from '@angular/core'; -import { RecipeService } from './recipe.service'; - @Component({ selector: 'app-recipes', templateUrl: './recipes.component.html', diff --git a/src/app/shared/data-storage.service.ts b/src/app/shared/data-storage.service.ts deleted file mode 100644 index 20ec663..0000000 --- a/src/app/shared/data-storage.service.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Injectable } from '@angular/core'; -import { HttpClient, HttpParams, HttpRequest } from '@angular/common/http'; - -import { RecipeService } from '../recipes/recipe.service'; -import { Recipe } from '../recipes/recipe.model'; - -@Injectable() -export class DataStorageService { - readonly baseUrl: string = 'https://my-recipe-book-cb837.firebaseio.com/'; - - constructor(private httpClient: HttpClient, - private recipeService: RecipeService) {} - - storeRecipes() { - // const token = this.authService.getToken(); - // return this.httpClient.put(this.baseUrl + 'recipes.json?auth=' + token, this.recipeService.getRecipes()); - // const req = new HttpRequest('PUT', this.baseUrl, this.recipeService.getRecipes(), {reportProgress: true, params: new HttpParams().set('auth', token)}); - // return this.httpClient.request(req); - return this.httpClient.put(this.baseUrl + 'recipes.json', this.recipeService.getRecipes()); - } - - fetchRecipes() { - this.httpClient.get(this.baseUrl + 'recipes.json').subscribe( - recipes => { - this.recipeService.replaceRecipes(recipes); - } - ) - } -} \ No newline at end of file