-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,032 additions
and
2,307 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/app/cats/containers/cat-facts-container/cat-facts-container.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div *ngIf="catFact" class="fact"> | ||
<h1>Did you know?</h1> | ||
<h3>{{ catFact && (catFact | async).data && (catFact | async).data[0] }}</h3> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
src/app/cats/containers/cat-facts-container/cat-facts-container.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.fact { | ||
text-align: center; | ||
margin: 0 25% | ||
} |
21 changes: 21 additions & 0 deletions
21
src/app/cats/containers/cat-facts-container/cat-facts-container.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { CatFactsContainerComponent } from './cat-facts-container.component'; | ||
|
||
describe('CatFactsContainerComponent', () => { | ||
let component: CatFactsContainerComponent; | ||
let fixture: ComponentFixture<CatFactsContainerComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [CatFactsContainerComponent] | ||
}); | ||
fixture = TestBed.createComponent(CatFactsContainerComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
src/app/cats/containers/cat-facts-container/cat-facts-container.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { CatFacadeService } from '@app/core/cats/facades/cat-facade.service'; | ||
import { CatFact } from '@app/core/cats/models/cat-fact'; | ||
import { Observable } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'app-cat-facts-container', | ||
templateUrl: './cat-facts-container.component.html', | ||
styleUrls: ['./cat-facts-container.component.scss'] | ||
}) | ||
export class CatFactsContainerComponent implements OnInit { | ||
catFact: Observable<CatFact>; | ||
|
||
constructor(private facade: CatFacadeService) { } | ||
|
||
ngOnInit(): void { | ||
this.catFact = this.facade.getNewFact(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div style="margin-bottom: 2vh"> | ||
<p>Powered by: <a style="color: white" target="_blank" href="https://http.cat/">http.cat</a> and <a style="color: white" target="_blank" href="https://meowfacts.herokuapp.com/">meowfacts</a></p> | ||
</div> |
Empty file.
21 changes: 21 additions & 0 deletions
21
src/app/cats/containers/powered-by/powered-by.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PoweredByComponent } from './powered-by.component'; | ||
|
||
describe('PoweredByComponent', () => { | ||
let component: PoweredByComponent; | ||
let fixture: ComponentFixture<PoweredByComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [PoweredByComponent] | ||
}); | ||
fixture = TestBed.createComponent(PoweredByComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ChangeDetectionStrategy, Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-powered-by', | ||
templateUrl: './powered-by.component.html', | ||
styleUrls: ['./powered-by.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class PoweredByComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CatImageService } from '../services/cat-image.service'; | ||
import { CatFactsService } from '../services/cat-facts.service'; | ||
import { Cat } from '../models/cat'; | ||
import { Observable } from 'rxjs'; | ||
import { CatFact } from '../models/cat-fact'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CatFacadeService { | ||
|
||
constructor(private service: CatImageService) { } | ||
constructor( | ||
private httpCatService: CatImageService, | ||
private catFactsService: CatFactsService | ||
) { } | ||
|
||
getRandomCat(): Observable<Cat> { | ||
return this.service.getNewCat(); | ||
return this.httpCatService.getNewCat(); | ||
} | ||
|
||
getNewCat(catCode: string): Observable<Cat> { | ||
const parsedCatCode = +catCode; | ||
const catExists = this.service.exists(+parsedCatCode); | ||
const catExists = this.httpCatService.exists(+parsedCatCode); | ||
|
||
if(catExists) return this.service.getNewCat(parsedCatCode); | ||
if(catExists) return this.httpCatService.getNewCat(parsedCatCode); | ||
else return null; | ||
} | ||
|
||
getNewFact(): Observable<CatFact> { | ||
return this.catFactsService.getNewFact() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface CatFact { | ||
data: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { CatFactsService } from './cat-facts.service'; | ||
|
||
describe('CatFactsService', () => { | ||
let service: CatFactsService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(CatFactsService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { CatFact } from '../models/cat-fact'; | ||
|
||
export const catFactsURL = "https://meowfacts.herokuapp.com/" | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class CatFactsService { | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
getNewFact() : Observable<CatFact> { | ||
return this.http.get<CatFact>(catFactsURL); | ||
} | ||
} |