This commit is contained in:
2018-05-12 17:07:08 -04:00
parent 4bc9c83e38
commit e3053414e4
5 changed files with 28 additions and 13 deletions

View File

@@ -31,6 +31,8 @@ if( ( (string)$tokenCheck != (string)$providedToken ) ){
die();
}
unset($_GET['token']);
interface DatabaseInterface {
public function getSql($name);

View File

@@ -45,7 +45,7 @@ export class GameGridComponent implements OnInit {
getGamesList(): any{
this.gameListSubscription = this.gamesService.getGames( this.queryFilters, this.querryPage, this.queryOrder, this.pageSize ).subscribe( data => {
this.gameListSubscription = this.gamesService.getGames( this.queryFilters, this.querryPage, this.queryOrder, this.pageSize, this.currentUser.id ).subscribe( data => {
this.length = data["_results"];
this.gamesData = data.games;
});
@@ -53,7 +53,7 @@ export class GameGridComponent implements OnInit {
onKey( event: any ){
if( event.target.value != "" ){
this.gamesService.searchGamesByText( event.target.value ).subscribe( data => {
this.gamesService.searchGamesByText( event.target.value, this.currentUser.token, this.currentUser.id ).subscribe( data => {
this.gamesData = data.games;
});
}else{

View File

@@ -26,8 +26,8 @@ export class GamesService {
private http: HttpClient
){ }
searchGamesByText( searchText ): Observable<any> {
return this.http.get( this.APIURL + "/games?filter=Title,cs," + searchText + "&transform=1" )
searchGamesByText( searchText, userToken, userId ): Observable<any> {
return this.http.get( this.APIURL + "/games?filter[]=Title,cs," + searchText + "&filter[]=userId,eq,"+ userId + "&transform=1&transform=1&token=" + userToken )
.map(res => {
return(
res
@@ -35,9 +35,9 @@ export class GamesService {
});
}
getGames( queryFilters, querryPage, queryOrder, queryRecordMax ): Observable<any> {
getGames( queryFilters, querryPage, queryOrder, queryRecordMax, userId ): Observable<any> {
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
return this.http.get( this.APIURL + "/games?filter="+ queryFilters +"&page="+ querryPage + "," + queryRecordMax +"&order="+ queryOrder +"&transform=1&token=" + currentUser.token )
return this.http.get( this.APIURL + "/games?filter[]=" + queryFilters + "&filter[]=userId,eq,"+ userId + " &page="+ querryPage + "," + queryRecordMax +"&order="+ queryOrder +"&transform=1&token=" + currentUser.token )
.map(res => {
return(
res
@@ -54,8 +54,8 @@ export class GamesService {
});
}
getGameById( gameId ): Observable<any> {
return this.http.get( this.APIURL + "/games/" + gameId )
getGameById( gameId, userToken, userId ): Observable<any> {
return this.http.get( this.APIURL + "/games/" + gameId + "?filter[]=userId,eq,"+ userId + "&token=" + userToken)
.map(res => {
return(
res

View File

@@ -2,7 +2,7 @@
<div class="row">
<div class="col-sm-12" id="gameImageHeaderContainer">
<img class="card-img-top" src="http://lazypug.net/globalAssets/images/temp1.png" alt="">
<img class="card-img-top" [src]="imageSample" alt="">
<br />
</div>

View File

@@ -18,6 +18,9 @@ export class ViewCardComponent implements OnInit {
gameData: Game;
form: any;
fileToUpload: File = null;
imageSample = "http://lazypug.net/globalAssets/images/temp1.png";
currentUser;
constructor(
@@ -28,9 +31,10 @@ export class ViewCardComponent implements OnInit {
ngOnInit(){
this.gid = this.route.snapshot.paramMap.get('gid');
this.currentUser = JSON.parse(localStorage.getItem('currentUser'));
if( this.gid != null ){
this.gameSubscription = this.gamesService.getGameById( this.gid ).subscribe( data => {
this.gameSubscription = this.gamesService.getGameById( this.gid, this.currentUser.token, this.currentUser.id ).subscribe( data => {
this.gameData = data;
this.buildForm();
});
@@ -87,9 +91,18 @@ export class ViewCardComponent implements OnInit {
}
handleFileInput( $event ) {
this.fileToUpload = $event.target.files[0];
this.uploadFileToActivity();
if ($event.target.files && $event.target.files[0]) {
var reader = new FileReader();
reader.onload = (event:any) => {
console.log( event.target.result );
this.imageSample = event.target.result;
//$('#blah').attr('src', e.target.result);
};
//console.log($event.target.files[0]);
reader.readAsDataURL( $event.target.files[0] );
}
//this.fileToUpload = $event.target.files[0];
//this.uploadFileToActivity();
}
uploadFileToActivity() {