-
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.
Retrieved and display list of footrix.club_player id & name at /players
- Loading branch information
1 parent
4c2c7e9
commit 742bd12
Showing
12 changed files
with
281 additions
and
2 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
backend/src/main/java/com/sg/backend/controllers/PlayerController.java
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,32 @@ | ||
package com.sg.backend.controllers; | ||
|
||
import java.util.List; | ||
|
||
import javax.servlet.http.HttpSession; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.CrossOrigin; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.sg.backend.models.PlayerSQL; | ||
import com.sg.backend.repositories.ClubRepository; | ||
|
||
|
||
@RestController | ||
@RequestMapping | ||
@CrossOrigin(origins = "*", allowedHeaders = "*") | ||
public class PlayerController { | ||
|
||
@Autowired | ||
private ClubRepository clubRepo; | ||
|
||
// use this to retrieve from SQL | ||
@GetMapping(path = "/players") | ||
@CrossOrigin(origins = "*", allowedHeaders = "*") | ||
public List<PlayerSQL> getPlayerList(HttpSession sess){ | ||
List<PlayerSQL> players = clubRepo.getPlayerList(); | ||
return players; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
backend/src/main/java/com/sg/backend/models/PlayerSQL.java
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 @@ | ||
package com.sg.backend.models; | ||
|
||
public class PlayerSQL { | ||
private String id; | ||
private String name; | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "PlayerSQL [id=" + id + ", name=" + name + "]"; | ||
} | ||
|
||
} |
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
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,81 @@ | ||
/* Toolbar */ | ||
.black-toolbar { | ||
background-color: #716b6b; | ||
position: relative; | ||
} | ||
|
||
.black-toolbar::before, | ||
.black-toolbar::after { | ||
content: ""; | ||
position: absolute; | ||
top: 0; | ||
width: 50%; | ||
height: 100%; | ||
background-color: inherit; | ||
z-index: -1; | ||
} | ||
|
||
.black-toolbar::before { | ||
left: 0; | ||
border-radius: 10px 0 0 10px; | ||
} | ||
|
||
.black-toolbar::after { | ||
right: 0; | ||
border-radius: 0 10px 10px 0; | ||
} | ||
|
||
.logo { | ||
height: 50px; | ||
margin-right: 20px; | ||
z-index: 9999; | ||
} | ||
|
||
.button-anim { | ||
transition: transform 0.3s; | ||
} | ||
|
||
.button-anim:hover { | ||
transform: translateY(-3px); | ||
} | ||
|
||
.mat-menu-panel { | ||
background-color: #424242; | ||
} | ||
|
||
.mat-menu-item:hover { | ||
background-color: #757575; | ||
} | ||
|
||
.mat-menu-trigger:hover { | ||
cursor: pointer; | ||
} | ||
|
||
|
||
.button-anim span { | ||
position: relative; | ||
z-index: 1; | ||
} | ||
/* Player list */ | ||
.player-table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
} | ||
|
||
.player-table th, | ||
.player-table td { | ||
padding: 8px; | ||
text-align: left; | ||
font-size: 14px; | ||
border-bottom: 1px solid #ddd; | ||
} | ||
|
||
.player-table th { | ||
background-color: #f2f2f2; | ||
font-weight: bold; | ||
} | ||
|
||
.player-table tr:hover { | ||
background-color: #f5f5f5; | ||
} | ||
|
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,35 @@ | ||
<mat-toolbar color="primary" class="black-toolbar"> | ||
<div style="display: flex; align-items: center;"> | ||
<button mat-button routerLink="/" class="button-anim"> | ||
<img src="../../assets/premier-league.svg" alt="Logo" style="height: 50px; margin-right: 20px;"> | ||
</button> | ||
<div style="flex: 1;"> | ||
<button mat-button [matMenuTriggerFor]="dashboardMenu" matMenuTriggerHover class="button-anim">Dashboard | ||
<mat-icon matSuffix>arrow_drop_down</mat-icon></button> | ||
<mat-menu #dashboardMenu="matMenu"> | ||
<button mat-menu-item routerLink="/analytics">Analytics</button> | ||
<button mat-menu-item routerLink="/matches">Matches</button> | ||
<button mat-menu-item routerLink="/players">Players</button> | ||
<button mat-menu-item routerLink="/club">Clubs</button> | ||
</mat-menu> | ||
<button mat-button routerLink="/account" class="button-anim">Account</button> | ||
<button mat-button routerLink="/contact" class="button-anim">Contact</button> | ||
<button mat-button routerLink="/about" class="button-anim">About Us</button> | ||
</div> | ||
</div> | ||
</mat-toolbar> | ||
|
||
<table class="player-table"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>Name</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let p of playerSQL | async"> | ||
<td>{{ p.id }}</td> | ||
<td>{{ p.name }}</td> | ||
</tr> | ||
</tbody> | ||
</table> |
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 { Component } from '@angular/core'; | ||
import { Observable } from 'rxjs'; | ||
import { PlayerSQL, Stats } from '../models'; | ||
import { StatsService } from '../stats.service'; | ||
|
||
@Component({ | ||
selector: 'app-stats', | ||
templateUrl: './stats.component.html', | ||
styleUrls: ['./stats.component.css'] | ||
}) | ||
export class StatsComponent { | ||
stats: Observable<Stats[]> | undefined; | ||
playerSQL: Observable<PlayerSQL[]> | undefined; | ||
|
||
constructor(private statService: StatsService) { } | ||
|
||
ngOnInit() { | ||
this.getListFromSQL(); | ||
} | ||
|
||
getListFromSQL() { | ||
console.log("fetching from list of players from MySQL") | ||
this.playerSQL = this.statService.getListFromSQL(); | ||
} | ||
} |
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,21 @@ | ||
import { Injectable } from "@angular/core"; | ||
import { HttpClient } from "@angular/common/http"; | ||
import { PlayerSQL, Stats } from "./models"; | ||
|
||
@Injectable() | ||
export class StatsService { | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
getStats(id: String) { | ||
const url = `http://localhost:8080/player/stats?id=${id}`; | ||
console.log("url", url) | ||
return this.http.get<Stats[]>(url); | ||
} | ||
|
||
getListFromSQL() { | ||
const url = `http://localhost:8080/players`; | ||
console.log("url", url) | ||
return this.http.get<PlayerSQL[]>(url); | ||
} | ||
} |
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