-
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.
Merge pull request #5 from CerealKiller97/dev
Working on services
- Loading branch information
Showing
27 changed files
with
280 additions
and
23 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
src/app/modules/contact/components/contact/contact.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
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,6 +1,19 @@ | ||
<mat-grid-list cols="2" rowHeight="2:1"> | ||
<mat-grid-list cols="1" rowHeight="2:1"> | ||
<mat-grid-tile> | ||
<h1 class="light-text">Welcome to VideoGamer</h1> | ||
<h5>Explore gaming world.</h5> | ||
<mat-form-field> | ||
<input matInput placeholder="label" value="value"> | ||
</mat-form-field> | ||
<mat-form-field> | ||
<mat-label>Cars</mat-label> | ||
<select matNativeControl required> | ||
<option value="volvo">Volvo</option> | ||
<option value="saab">Saab</option> | ||
<option value="mercedes">Mercedes</option> | ||
<option value="audi">Audi</option> | ||
</select> | ||
</mat-form-field> | ||
<button mat-raised-button color="primary" (click)="onClick();">Explore</button> | ||
</mat-grid-tile> | ||
<mat-grid-tile>2</mat-grid-tile> | ||
</mat-grid-list> |
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,16 +1,46 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { Title } from '@angular/platform-browser'; | ||
import { LoadingService } from 'src/app/modules/shared/loading.service'; | ||
import { LoadingService } from '@service/loading/loading.service'; | ||
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; | ||
import { TeamsService } from '@serviceteams/teams.service'; | ||
import { Subscription } from 'rxjs'; | ||
@Component({ | ||
selector: 'app-home', | ||
templateUrl: './home.component.html', | ||
styleUrls: ['./home.component.css'] | ||
}) | ||
export class HomeComponent implements OnInit { | ||
constructor(private readonly titleService: Title, private readonly loadingService: LoadingService) {} | ||
private subscription: Subscription; | ||
|
||
ngOnInit() { | ||
constructor( | ||
private readonly titleService: Title, | ||
private readonly loadingService: LoadingService, | ||
private readonly snackBar: MatSnackBar, | ||
private readonly teamsService: TeamsService | ||
) {} | ||
|
||
ngOnInit(): void { | ||
this.loadingService.setLoading(true); | ||
this.titleService.setTitle('VideoGamer | Home'); | ||
this.openSnackBar(); | ||
this.subscription = this.teamsService.find(5).subscribe(data => { | ||
console.log(data); | ||
}); | ||
} | ||
|
||
openSnackBar(): void { | ||
const options: MatSnackBarConfig = { | ||
direction: 'ltr', | ||
duration: 4000, | ||
horizontalPosition: 'end', | ||
panelClass: ['example-pizza-party'] | ||
}; | ||
|
||
this.snackBar.open('Welcome to the best NBA analytics app. 👋', 'Dismiss', options); | ||
// this.snackBar.openFromComponent(NotificationComponent, options); | ||
} | ||
|
||
onClick(): void { | ||
this.openSnackBar(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
import { VideoGamerLayoutModule } from './layouts/video-gamer-layout/video-gamer-layout.module'; | ||
import { HomeModule } from './home/home.module'; | ||
import { ContactModule } from './contact/contact.module'; | ||
import { SharedModule } from './shared/shared.module'; | ||
import { SharedComponentsModule } from './shared-components/shared-components.module'; | ||
import { MaterialModule } from './shared-components/material/material.module'; | ||
|
||
export { VideoGamerLayoutModule }; | ||
export { VideoGamerLayoutModule, HomeModule, ContactModule, SharedModule, SharedComponentsModule, MaterialModule }; |
Empty file.
3 changes: 3 additions & 0 deletions
3
src/app/modules/shared-components/components/notification/notification.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,3 @@ | ||
<span class="example-pizza-party"> | ||
{{ message }} | ||
</span> |
25 changes: 25 additions & 0 deletions
25
src/app/modules/shared-components/components/notification/notification.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,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { NotificationComponent } from './notification.component'; | ||
|
||
describe('NotificationComponent', () => { | ||
let component: NotificationComponent; | ||
let fixture: ComponentFixture<NotificationComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ NotificationComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(NotificationComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/app/modules/shared-components/components/notification/notification.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,24 @@ | ||
import { Component, OnInit, Input } from '@angular/core'; | ||
|
||
export enum Color { | ||
SUCCESS = '#00ff00', | ||
ERROR = 'red', | ||
WARNING = 'yellow', | ||
INFO = 'cyan' | ||
} | ||
|
||
@Component({ | ||
selector: 'app-notification', | ||
templateUrl: './notification.component.html', | ||
styleUrls: ['./notification.component.css'] | ||
}) | ||
export class NotificationComponent implements OnInit { | ||
@Input() | ||
message: string; | ||
@Input() | ||
color: string; | ||
|
||
constructor() {} | ||
|
||
ngOnInit() {} | ||
} |
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 @@ | ||
export interface Game { | ||
|
||
} |
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,7 @@ | ||
export interface Player { | ||
id: number; | ||
position: string; | ||
height: string; | ||
weight: string; | ||
club: 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,9 @@ | ||
export interface Team { | ||
id: number; | ||
abbreviation: string; | ||
city: string; | ||
conference: string; | ||
division: string; | ||
fullName: string; | ||
name: 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,11 @@ | ||
import { HttpHeaders } from '@angular/common/http'; | ||
import { environment } from '../../../../environments/environment'; | ||
|
||
export const apiHttpHeaders = { | ||
headers: new HttpHeaders({ | ||
Accept: 'application/json', | ||
'Content-Type': 'application/json', | ||
'x-rapidapi-host': `${environment.xRapidApiHost}`, | ||
'x-rapidapi-key': `${environment.xRapidApiKey}` | ||
}) | ||
}; |
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,7 @@ | ||
import { Observable } from 'rxjs'; | ||
|
||
export interface IApiResource<T = any> { | ||
readonly resourcePath: string; | ||
all(): Observable<T[]>; | ||
find(id: number): Observable<T>; | ||
} |
12 changes: 12 additions & 0 deletions
12
src/app/modules/shared/services/games/games.service.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,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { GamesService } from './games.service'; | ||
|
||
describe('GamesService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: GamesService = TestBed.get(GamesService); | ||
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,29 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { IApiResource } from '@service/IApiResource'; | ||
import { Game } from '@model/Game'; | ||
import { Observable } from 'rxjs'; | ||
import { environment } from '../../../../../environments/environment'; | ||
import { apiHttpHeaders } from '@serviceApiHttpHeaders'; | ||
import { map } from 'rxjs/operators'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class GamesService implements IApiResource<Game> { | ||
public readonly resourcePath: string = `${environment.apiUrl}/games`; | ||
|
||
constructor(private readonly http: HttpClient) {} | ||
|
||
public all(): Observable<Game[]> { | ||
return this.http.get<{ data: Game[] }>(this.resourcePath, apiHttpHeaders).pipe( | ||
map(response => { | ||
return response.data; | ||
}) | ||
); | ||
} | ||
|
||
public find(id: number): Observable<Game> { | ||
return this.http.get<Game>(`${this.resourcePath}/${id}`, apiHttpHeaders); | ||
} | ||
} |
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,5 @@ | ||
import { GamesService } from '@service/games/games.service'; | ||
import { LoadingService } from '@service/loading/loading.service'; | ||
import { TeamsService } from '@service/teams/teams.service'; | ||
|
||
export { GamesService, LoadingService, TeamsService }; |
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions
12
src/app/modules/shared/services/teams/teams.service.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,12 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { TeamsService } from './teams.service'; | ||
|
||
describe('TeamsService', () => { | ||
beforeEach(() => TestBed.configureTestingModule({})); | ||
|
||
it('should be created', () => { | ||
const service: TeamsService = TestBed.get(TeamsService); | ||
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,28 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { environment } from 'environments/environment'; | ||
import { Team } from '@model/Team'; | ||
import { Observable } from 'rxjs'; | ||
import { map } from 'rxjs/operators'; | ||
import { IApiResource } from '@serviceIApiResource'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { apiHttpHeaders } from '@service/ApiHttpHeaders'; | ||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class TeamsService implements IApiResource<Team> { | ||
public readonly resourcePath: string = `${environment.apiUrl}/teams`; | ||
|
||
constructor(private readonly http: HttpClient) {} | ||
|
||
public all(): Observable<Team[]> { | ||
return this.http.get<{ data: Team[] }>(this.resourcePath, apiHttpHeaders).pipe( | ||
map(response => { | ||
return response.data; | ||
}) | ||
); | ||
} | ||
|
||
public find(id: number): Observable<Team> { | ||
return this.http.get<Team>(`${this.resourcePath}/${id}`, apiHttpHeaders); | ||
} | ||
} |
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,8 +1,8 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
import { HttpClientModule } from '@angular/common/http'; | ||
@NgModule({ | ||
declarations: [], | ||
imports: [CommonModule] | ||
imports: [CommonModule, HttpClientModule] | ||
}) | ||
export class SharedModule {} |
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,4 +1,6 @@ | ||
export interface IEnvironment { | ||
production: boolean; | ||
apiKey: string; | ||
xRapidApiHost: string; | ||
xRapidApiKey: string; | ||
apiUrl: 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
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
Oops, something went wrong.
7de1441
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully aliased the URL https://ng-videogamer-aiqaw7djs.now.sh to the following aliases: