day one build
This commit is contained in:
17
src/app/app-routing.module.ts
Normal file
17
src/app/app-routing.module.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
|
||||
import { GameGridComponent } from './game-grid/game-grid.component'
|
||||
|
||||
const routes: Routes = [
|
||||
{ path: '', redirectTo: '/game-grid', pathMatch: 'full' },
|
||||
{ path: 'game-grid', component: GameGridComponent }
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
RouterModule.forRoot(routes)
|
||||
],
|
||||
exports: [ RouterModule ]
|
||||
})
|
||||
export class AppRoutingModule { }
|
||||
0
src/app/app.component.css
Normal file
0
src/app/app.component.css
Normal file
7
src/app/app.component.html
Normal file
7
src/app/app.component.html
Normal file
@@ -0,0 +1,7 @@
|
||||
<div class="container">
|
||||
<div class="content-wrapper fill">
|
||||
|
||||
<router-outlet></router-outlet>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
27
src/app/app.component.spec.ts
Normal file
27
src/app/app.component.spec.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { TestBed, async } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [
|
||||
AppComponent
|
||||
],
|
||||
}).compileComponents();
|
||||
}));
|
||||
it('should create the app', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
}));
|
||||
it(`should have as title 'app'`, async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.debugElement.componentInstance;
|
||||
expect(app.title).toEqual('app');
|
||||
}));
|
||||
it('should render title in a h1 tag', async(() => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.debugElement.nativeElement;
|
||||
expect(compiled.querySelector('h1').textContent).toContain('Welcome to app!');
|
||||
}));
|
||||
});
|
||||
10
src/app/app.component.ts
Normal file
10
src/app/app.component.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.css']
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'app';
|
||||
}
|
||||
25
src/app/app.module.ts
Normal file
25
src/app/app.module.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
import {HttpClientModule} from '@angular/common/http';
|
||||
|
||||
|
||||
import { AppComponent } from './app.component';
|
||||
import { GamesService } from './games.service';
|
||||
import { GameGridComponent } from './game-grid/game-grid.component';
|
||||
import { AppRoutingModule } from './/app-routing.module';
|
||||
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
GameGridComponent
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
HttpClientModule
|
||||
],
|
||||
providers: [GamesService],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
||||
9
src/app/game-grid/game-grid.component.css
Normal file
9
src/app/game-grid/game-grid.component.css
Normal file
@@ -0,0 +1,9 @@
|
||||
.grid-sizer, .grid-item{
|
||||
width: 25%;
|
||||
}
|
||||
.grid-item {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.grid-item-img{
|
||||
width: 250px;
|
||||
}
|
||||
18
src/app/game-grid/game-grid.component.html
Normal file
18
src/app/game-grid/game-grid.component.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div *ngIf="isEmptyObject(gamesData)">
|
||||
|
||||
<div class="grid">
|
||||
<div class="grid-sizer"></div>
|
||||
<div *ngFor="let game of gamesData; last as isLast;" style="margin:auto">
|
||||
{{renderGridItems(isLast)}}
|
||||
<div class="grid-item text-center">
|
||||
<img class="grid-item-img" src="http://lazypug.net/globalAssets/images/temp1.png">
|
||||
<p>{{game.Title}}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
25
src/app/game-grid/game-grid.component.spec.ts
Normal file
25
src/app/game-grid/game-grid.component.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { GameGridComponent } from './game-grid.component';
|
||||
|
||||
describe('GameGridComponent', () => {
|
||||
let component: GameGridComponent;
|
||||
let fixture: ComponentFixture<GameGridComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ GameGridComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(GameGridComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
79
src/app/game-grid/game-grid.component.ts
Normal file
79
src/app/game-grid/game-grid.component.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { GamesService } from '../games.service';
|
||||
|
||||
declare var jquery:any;
|
||||
declare var $ :any;
|
||||
|
||||
declare var masonry:any;
|
||||
|
||||
@Component({
|
||||
selector: 'app-game-grid',
|
||||
templateUrl: './game-grid.component.html',
|
||||
styleUrls: ['./game-grid.component.css']
|
||||
})
|
||||
export class GameGridComponent implements OnInit {
|
||||
|
||||
gameListSubscription;
|
||||
rawGamesContent;
|
||||
gamesData;
|
||||
|
||||
constructor(
|
||||
private route: ActivatedRoute,
|
||||
private gamesService: GamesService
|
||||
){
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
this.getGamesList();
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
getGamesList(): any{
|
||||
this.gameListSubscription = this.gamesService.getGames( ).subscribe( data => {
|
||||
console.log( data );
|
||||
this.gamesData = data.games;
|
||||
//var tempItemContent = [];
|
||||
|
||||
/* parse out just the input data and set that in object array */
|
||||
/*for( var key in data['ContentBlocks'] ){
|
||||
console.log( data['ContentBlocks'][key]['Type'] );
|
||||
if( data['ContentBlocks'][key]['Type'] == "ItemSelectionSetting" ){
|
||||
tempItemContent.push( data['ContentBlocks'][key]['Content'] );
|
||||
}
|
||||
}
|
||||
this.formItemContent = tempItemContent;
|
||||
*/
|
||||
});
|
||||
}
|
||||
|
||||
isEmptyObject(obj) {
|
||||
return (obj != undefined);
|
||||
}
|
||||
|
||||
isNotEmptyObject(obj) {
|
||||
return (obj == undefined);
|
||||
}
|
||||
|
||||
renderGridItems(lastItem: boolean) {
|
||||
if (lastItem) {
|
||||
$('.grid').masonry({
|
||||
columnWidth: '.grid-sizer',
|
||||
itemSelector: '.grid-item',
|
||||
percentPosition: true
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
15
src/app/games.service.spec.ts
Normal file
15
src/app/games.service.spec.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { TestBed, inject } from '@angular/core/testing';
|
||||
|
||||
import { GamesService } from './games.service';
|
||||
|
||||
describe('GamesService', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [GamesService]
|
||||
});
|
||||
});
|
||||
|
||||
it('should be created', inject([GamesService], (service: GamesService) => {
|
||||
expect(service).toBeTruthy();
|
||||
}));
|
||||
});
|
||||
33
src/app/games.service.ts
Normal file
33
src/app/games.service.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
import 'rxjs/add/operator/map';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' })
|
||||
//headers: new HttpHeaders({ 'Content-Type': 'application/json' })
|
||||
}
|
||||
|
||||
const httpOptionsPut = {
|
||||
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class GamesService {
|
||||
|
||||
APIURL = "http://www.lazypug.net/api.php";
|
||||
|
||||
constructor(
|
||||
private http: HttpClient
|
||||
){ }
|
||||
|
||||
getGames( ): Observable<any> {
|
||||
return this.http.get( this.APIURL + "/games?filter=Played,eq,true&page=1&order=Title&transform=1" )
|
||||
.map(res => {
|
||||
return(
|
||||
res
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user