diff --git a/bluenps/src/app/app.module.ts b/bluenps/src/app/app.module.ts index 6db8dc8..85d1b93 100644 --- a/bluenps/src/app/app.module.ts +++ b/bluenps/src/app/app.module.ts @@ -7,13 +7,15 @@ import { AppComponent } from './app.component'; import { HomePageComponent } from './home-page/home-page.component'; import { AppRoutingModule } from './app-routing.module'; import { HashLocationStrategy, LocationStrategy } from '@angular/common'; +import { SignupsComponent } from './signups/signups.component'; @NgModule({ declarations: [ AppComponent, - DeleteComponent, - HomePageComponent, + //DeleteComponent, + //HomePageComponent, + //SignupsComponent, ], imports: [ HttpClientModule, diff --git a/bluenps/src/app/backend.service.ts b/bluenps/src/app/backend.service.ts index 3f754e5..1bd2c6f 100644 --- a/bluenps/src/app/backend.service.ts +++ b/bluenps/src/app/backend.service.ts @@ -1,6 +1,7 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders} from '@angular/common/http'; import { environment } from 'src/environments/environment'; +import { Observable } from 'rxjs'; export type signup = { index: number; @@ -27,10 +28,10 @@ export class BackendService { getAllData( ){ console.log("test"); return this.http.get(this.url); - - } + + postSignup(newPlayer:signupPost){ console.log(newPlayer); var headers = new HttpHeaders().set("Content-Type", "application/json; charset=utf-8"); @@ -44,6 +45,6 @@ export class BackendService { headers = headers.set("nameQuery", regexString); console.log(headers); return this.http.delete(this.url + "delete", {headers: headers}); - } + } diff --git a/bluenps/src/app/delete/delete.component.ts b/bluenps/src/app/delete/delete.component.ts index 06a0b0e..5a491cc 100644 --- a/bluenps/src/app/delete/delete.component.ts +++ b/bluenps/src/app/delete/delete.component.ts @@ -4,7 +4,8 @@ import { BackendService } from '../backend.service'; @Component({ selector: 'app-delete', templateUrl: './delete.component.html', - styleUrls: ['./delete.component.css'] + styleUrls: ['./delete.component.css'], + standalone:true, }) export class DeleteComponent { constructor(private backendService: BackendService){} diff --git a/bluenps/src/app/home-page/home-page.component.html b/bluenps/src/app/home-page/home-page.component.html index 7754072..56be5e3 100644 --- a/bluenps/src/app/home-page/home-page.component.html +++ b/bluenps/src/app/home-page/home-page.component.html @@ -1,50 +1,3 @@ - -
-
- Blue -
-
- NPS -
-
-
-
- - - - -
-
- - - -
-
-
-
-
-
{{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 1aecd07..8f9180b 100644 --- a/bluenps/src/app/home-page/home-page.component.ts +++ b/bluenps/src/app/home-page/home-page.component.ts @@ -3,10 +3,15 @@ import {formatDate} from '@angular/common'; import { HttpClient, HttpResponse } from '@angular/common/http'; import {signup, BackendService, signupPost } from '../backend.service'; import { RouterModule } from '@angular/router'; +import { SignupsComponent } from '../signups/signups.component'; + + @Component({ selector: 'app-home-page', templateUrl: './home-page.component.html', - styleUrls: ['./home-page.component.css'] + styleUrls: ['./home-page.component.css'], + standalone: true, + imports: [SignupsComponent] }) export class HomePageComponent implements OnInit { title = 'bluenps'; diff --git a/bluenps/src/app/signups/signups.component.css b/bluenps/src/app/signups/signups.component.css new file mode 100644 index 0000000..208258b --- /dev/null +++ b/bluenps/src/app/signups/signups.component.css @@ -0,0 +1,15 @@ +.bluecourt{ + background-color: rgb(0, 247, 255); + padding-top: 2px; + padding-bottom: 2px; +} + +.npscourt{ + background-color: rgb(0,255,0); + padding-top: 3px; + padding-bottom: 3px; +} + +.tablestyle{ + background-color: rgb(255, 165, 0); +} \ No newline at end of file diff --git a/bluenps/src/app/signups/signups.component.html b/bluenps/src/app/signups/signups.component.html new file mode 100644 index 0000000..580d1f0 --- /dev/null +++ b/bluenps/src/app/signups/signups.component.html @@ -0,0 +1,50 @@ +
+ + +
+
+ Blue +
+
+ NPS +
+
+ +
+
+ + + + +
+
+ + +
+
+
+
+
+
{{player.name}}
+
{{player.time}}
+
{{player.court}}
+
+
+
+
+
+
+
+
{{player.name}}
+
{{player.time}}
+
{{player.court}}
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/bluenps/src/app/signups/signups.component.spec.ts b/bluenps/src/app/signups/signups.component.spec.ts new file mode 100644 index 0000000..73d1e11 --- /dev/null +++ b/bluenps/src/app/signups/signups.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { SignupsComponent } from './signups.component'; + +describe('SignupsComponent', () => { + let component: SignupsComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [SignupsComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(SignupsComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/bluenps/src/app/signups/signups.component.ts b/bluenps/src/app/signups/signups.component.ts new file mode 100644 index 0000000..f00b664 --- /dev/null +++ b/bluenps/src/app/signups/signups.component.ts @@ -0,0 +1,67 @@ +import { Component, OnInit } from '@angular/core'; +import {formatDate, NgFor} from '@angular/common'; +import { HttpClient, HttpResponse } from '@angular/common/http'; +import {signup, BackendService, signupPost } from '../backend.service'; + +@Component({ + selector: 'app-signups', + templateUrl: './signups.component.html', + styleUrl: './signups.component.css', + standalone: true, + imports:[NgFor] +}) + +export class SignupsComponent { + 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(){ + this.refreshData(); + } + + refreshData(){ + console.log("refreshing data"); + this.backendService.getAllData() + .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); + var court = e.value; + var name = (document.getElementById("nameInput") as HTMLInputElement).value; + var date = new Date(); + if(name==undefined || date==undefined || court == undefined){ + alert("error"); + return; + } + var dateString = formatDate(date, "yyyy-MM-dd", 'en') + + var newSignup:signupPost = { + "name" : name, + "time" : dateString, + "court" : court + } + this.backendService.postSignup(newSignup).subscribe({ + next: (value) =>this.refreshData(), + error:(e)=>{console.log("error",e); this.refreshData()}} + ) + this.refreshData(); + } + deletePlayer(player: signup): void{ + this.backendService.deleteData(player.name).subscribe( + { + next: (value) => {this.refreshData();}, + error: (e) => {console.log("errordeleting:", e);this.refreshData();} + } + ) + } +} diff --git a/bluenpsbackend/db.sqlite3 b/bluenpsbackend/db.sqlite3 index 02f8569..fe53e0d 100644 Binary files a/bluenpsbackend/db.sqlite3 and b/bluenpsbackend/db.sqlite3 differ