From 002c53b4d491d7e8cfed6d64b588696fc9a472a7 Mon Sep 17 00:00:00 2001 From: DoodleyJC Date: Thu, 4 Apr 2024 23:03:10 +0200 Subject: [PATCH] added separate object for post requests, added index to get request object --- bluenps/src/app/backend.service.ts | 11 +++++-- .../app/home-page/home-page.component.html | 30 ++++++++++++++---- .../src/app/home-page/home-page.component.ts | 18 ++++++++--- bluenpsbackend/db.sqlite3 | Bin 135168 -> 135168 bytes 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/bluenps/src/app/backend.service.ts b/bluenps/src/app/backend.service.ts index 214747c..3f754e5 100644 --- a/bluenps/src/app/backend.service.ts +++ b/bluenps/src/app/backend.service.ts @@ -3,6 +3,13 @@ import { HttpClient, HttpHeaders} from '@angular/common/http'; import { environment } from 'src/environments/environment'; export type signup = { + index: number; + name: string; + time: string; + court: string; +} + +export type signupPost = { name: string; time: string; court: string; @@ -24,10 +31,10 @@ export class BackendService { } - postSignup(newPlayer:signup){ + postSignup(newPlayer:signupPost){ console.log(newPlayer); var headers = new HttpHeaders().set("Content-Type", "application/json; charset=utf-8"); - return this.http.post(this.url, newPlayer, {headers: headers}); + return this.http.post(this.url, newPlayer, {headers: headers}); } diff --git a/bluenps/src/app/home-page/home-page.component.html b/bluenps/src/app/home-page/home-page.component.html index 3d2b1ec..7754072 100644 --- a/bluenps/src/app/home-page/home-page.component.html +++ b/bluenps/src/app/home-page/home-page.component.html @@ -19,14 +19,32 @@ + + +
-
  • -
    -
    {{player.name}}
    -
    {{player.time}}
    -
    {{player.court}}
    -
    +
    +
    +
    +
    +
    {{player.name}}
    +
    {{player.time}}
    +
    {{player.court}}
    +
    +
    +
    +
    +
    +
    +
    +
    {{player.name}}
    +
    {{player.time}}
    +
    {{player.court}}
    +
    +
    +
    +
    \ No newline at end of file diff --git a/bluenps/src/app/home-page/home-page.component.ts b/bluenps/src/app/home-page/home-page.component.ts index 56dd3bf..1aecd07 100644 --- a/bluenps/src/app/home-page/home-page.component.ts +++ b/bluenps/src/app/home-page/home-page.component.ts @@ -1,7 +1,7 @@ import { Component, OnInit } from '@angular/core'; import {formatDate} from '@angular/common'; import { HttpClient, HttpResponse } from '@angular/common/http'; -import {signup, BackendService } from '../backend.service'; +import {signup, BackendService, signupPost } from '../backend.service'; import { RouterModule } from '@angular/router'; @Component({ selector: 'app-home-page', @@ -11,7 +11,10 @@ import { RouterModule } from '@angular/router'; export class HomePageComponent implements OnInit { title = 'bluenps'; test: any; - data: signup[]= [{name: "uninitialized", court: "uninitialized", time: "please wait"}]; + data: signup[]= [{index: 0, name: "uninitialized", court: "uninitialized", time: "please wait"}]; + npsdata: signup[]= [{index: 0,name: "nps", court: "uninitialized", time: "please wait"}]; + bluedata: signup[] = [{index: 0,name: "blue", court: "uninitialized", time: "please wait"}]; + constructor(private http: HttpClient, private backendService: BackendService){} ngOnInit(){ @@ -21,7 +24,14 @@ export class HomePageComponent implements OnInit { refreshData(){ console.log("refreshing data"); this.backendService.getAllData() - .subscribe( data => this.data = data); + .subscribe( data => this.setData(data)); + } + + + setData(data:signup[]){ + this.data = data; + this.npsdata = data.filter((activity) => activity.court === "nps"); + this.bluedata = data.filter((activity) => activity.court === "blue"); } submitCourtName(): void{ var e = (document.getElementById("courtSelection") as HTMLInputElement); @@ -34,7 +44,7 @@ export class HomePageComponent implements OnInit { } var dateString = formatDate(date, "yyyy-MM-dd", 'en') - var newSignup:signup = { + var newSignup:signupPost = { "name" : name, "time" : dateString, "court" : court diff --git a/bluenpsbackend/db.sqlite3 b/bluenpsbackend/db.sqlite3 index 70fb1aa20c511d18a4114322cb6d7c0e90ce77aa..02f85696509751280f66f90a21a5d6fc6184c5fc 100644 GIT binary patch delta 158 zcmZozz|pXPV}dl}kBKtQj6XIei0U)0X)e>>UZ&63cY#rEDl3x>`x>5OKL zP^?jtl|fih)X>P-$iT=%*8qeh8?{&&Bo#$n5;KcaD-q&JIi;!7>v))C^hFs&6@?Rl e04gcjDBh^f3KSG|%u7MjA`!OB`5Zvm)#L8os zS)5v#R#v))C^z|7;6@?Rl04gWhsKm-3 S4cCIAL!wb_`$--qb7lZc_$yKX