Spaces:
Running
Running
Commit ·
d2f22d5
1
Parent(s): 6ed24e2
team ratings tab fix
Browse files- frontend/src/components/PitchView.jsx +2 -2
- frontend/src/components/PlayerCardVisual.jsx +2 -2
- frontend/src/components/TeamRatings.jsx +13 -3
- logos/1044.png +0 -3
- logos/328.png +0 -3
- logos/341.png +0 -3
- logos/351.png +0 -3
- logos/354.png +0 -3
- logos/397.png +0 -3
- logos/402.png +0 -3
- logos/563.png +0 -3
- logos/57.png +0 -3
- logos/58.png +0 -3
- logos/61.png +0 -3
- logos/62.png +0 -3
- logos/63.png +0 -3
- logos/64.png +0 -3
- logos/65.png +0 -3
- logos/66.png +0 -3
- logos/67.png +0 -3
- logos/71.png +0 -3
- logos/73.png +0 -3
- logos/76.png +0 -3
- main.py +2 -38
frontend/src/components/PitchView.jsx
CHANGED
|
@@ -20,7 +20,7 @@ export const PitchView = ({
|
|
| 20 |
chipsByGw,
|
| 21 |
}) => {
|
| 22 |
return (
|
| 23 |
-
<div className="w-full bg-[#0a3a2a] rounded-2xl border-4 border-[#072a1e] min-h-[
|
| 24 |
{/* PITCH LINES */}
|
| 25 |
<div className="absolute inset-0 pointer-events-none opacity-30 flex flex-col items-center">
|
| 26 |
<div className="w-full h-1/2 border-b-2 border-white/40 absolute top-0"></div>
|
|
@@ -34,7 +34,7 @@ export const PitchView = ({
|
|
| 34 |
|
| 35 |
{/* STARTERS */}
|
| 36 |
<div className="flex-1 w-full overflow-x-auto custom-scrollbar">
|
| 37 |
-
<div className="flex flex-col justify-evenly gap-y-10 z-10 pt-8 pb-12 px-4 min-w-max sm:min-w-0 min-h-full h-full mx-auto">
|
| 38 |
{["G", "D", "M", "F"].map((pos) => {
|
| 39 |
const rowPlayers = teamData.slice(0, 11).filter((p) => p.Pos === pos);
|
| 40 |
if (rowPlayers.length === 0) return null;
|
|
|
|
| 20 |
chipsByGw,
|
| 21 |
}) => {
|
| 22 |
return (
|
| 23 |
+
<div className="w-full bg-[#0a3a2a] rounded-2xl border-4 border-[#072a1e] min-h-[540px] sm:min-h-[700px] xl:min-h-[850px] relative overflow-hidden flex flex-col shadow-[0_0_50px_rgba(0,0,0,0.5)]">
|
| 24 |
{/* PITCH LINES */}
|
| 25 |
<div className="absolute inset-0 pointer-events-none opacity-30 flex flex-col items-center">
|
| 26 |
<div className="w-full h-1/2 border-b-2 border-white/40 absolute top-0"></div>
|
|
|
|
| 34 |
|
| 35 |
{/* STARTERS */}
|
| 36 |
<div className="flex-1 w-full overflow-x-auto custom-scrollbar">
|
| 37 |
+
<div className="flex flex-col justify-evenly gap-y-4 sm:gap-y-10 z-10 pt-6 sm:pt-8 pb-10 sm:pb-12 px-2 sm:px-4 min-w-max sm:min-w-0 min-h-full h-full mx-auto">
|
| 38 |
{["G", "D", "M", "F"].map((pos) => {
|
| 39 |
const rowPlayers = teamData.slice(0, 11).filter((p) => p.Pos === pos);
|
| 40 |
if (rowPlayers.length === 0) return null;
|
frontend/src/components/PlayerCardVisual.jsx
CHANGED
|
@@ -22,7 +22,7 @@ export const PlayerCardVisual = ({
|
|
| 22 |
return (
|
| 23 |
<div
|
| 24 |
onClick={onPlayerClick}
|
| 25 |
-
className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[
|
| 26 |
>
|
| 27 |
{player.replacedPlayer && (
|
| 28 |
<div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
|
|
@@ -147,7 +147,7 @@ export const PlayerCardVisual = ({
|
|
| 147 |
return (
|
| 148 |
<div
|
| 149 |
onClick={onPlayerClick}
|
| 150 |
-
className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[
|
| 151 |
>
|
| 152 |
<div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
|
| 153 |
{!isBench && handleCapChange && (
|
|
|
|
| 22 |
return (
|
| 23 |
<div
|
| 24 |
onClick={onPlayerClick}
|
| 25 |
+
className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[85px] sm:h-[105px] md:h-[120px] flex flex-col items-center justify-center cursor-pointer border-2 border-dashed border-slate-500 bg-slate-900/60 rounded-xl hover:bg-slate-800 hover:border-emerald-400 transition-all z-20 shadow-inner group transform scale-[0.82] sm:scale-100 origin-bottom"
|
| 26 |
>
|
| 27 |
{player.replacedPlayer && (
|
| 28 |
<div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
|
|
|
|
| 147 |
return (
|
| 148 |
<div
|
| 149 |
onClick={onPlayerClick}
|
| 150 |
+
className="relative w-[64px] sm:w-[76px] md:w-[88px] h-[85px] sm:h-[105px] md:h-[120px] flex flex-col items-center justify-end cursor-grab active:cursor-grabbing transform scale-[0.82] sm:scale-100 origin-bottom"
|
| 151 |
>
|
| 152 |
<div className="absolute left-[-14px] top-[-10px] flex flex-col gap-1 z-40 pointer-events-auto">
|
| 153 |
{!isBench && handleCapChange && (
|
frontend/src/components/TeamRatings.jsx
CHANGED
|
@@ -1,5 +1,14 @@
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
export default function TeamRatings() {
|
| 4 |
const [data, setData] = useState([]);
|
| 5 |
const [isLoading, setIsLoading] = useState(true);
|
|
@@ -73,6 +82,7 @@ export default function TeamRatings() {
|
|
| 73 |
{data.map(team => {
|
| 74 |
const leftPct = ((maxDef - team.Defence) / (maxDef - minDef)) * 100;
|
| 75 |
const bottomPct = ((team.Attack - minAttack) / (maxAttack - minAttack)) * 100;
|
|
|
|
| 76 |
|
| 77 |
return (
|
| 78 |
<div
|
|
@@ -80,10 +90,10 @@ export default function TeamRatings() {
|
|
| 80 |
className="absolute w-10 h-10 -ml-5 -mb-5 group z-10 hover:z-50 transition-transform hover:scale-125 cursor-pointer"
|
| 81 |
style={{ left: `${leftPct}%`, bottom: `${bottomPct}%` }}
|
| 82 |
>
|
| 83 |
-
{
|
| 84 |
-
<img src={
|
| 85 |
) : (
|
| 86 |
-
<div className="w-4 h-4 m-3 bg-luigi-500 rounded-full shadow-[0_0_15px_rgba(16,185,129,0.8)]" />
|
| 87 |
)}
|
| 88 |
|
| 89 |
<div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-max px-3 py-2 bg-slate-900 border border-slate-700 text-xs rounded opacity-0 group-hover:opacity-100 pointer-events-none shadow-2xl z-50 transition-opacity">
|
|
|
|
| 1 |
import React, { useState, useEffect } from 'react';
|
| 2 |
|
| 3 |
+
const TEAM_LOGOS = {
|
| 4 |
+
"Arsenal": 57, "Manchester City": 65, "Liverpool": 64, "Chelsea": 61,
|
| 5 |
+
"Newcastle United": 67, "Aston Villa": 58, "Manchester United": 66,
|
| 6 |
+
"Brentford": 402, "Brighton and Hove Albion": 397, "AFC Bournemouth": 1044,
|
| 7 |
+
"Tottenham Hotspur": 73, "Crystal Palace": 354, "Fulham": 63,
|
| 8 |
+
"Nottingham Forest": 351, "Everton": 62, "Leeds United": 341,
|
| 9 |
+
"West Ham United": 563, "Wolverhampton Wanderers": 76, "Sunderland": 71, "Burnley": 328,
|
| 10 |
+
};
|
| 11 |
+
|
| 12 |
export default function TeamRatings() {
|
| 13 |
const [data, setData] = useState([]);
|
| 14 |
const [isLoading, setIsLoading] = useState(true);
|
|
|
|
| 82 |
{data.map(team => {
|
| 83 |
const leftPct = ((maxDef - team.Defence) / (maxDef - minDef)) * 100;
|
| 84 |
const bottomPct = ((team.Attack - minAttack) / (maxAttack - minAttack)) * 100;
|
| 85 |
+
const logoId = TEAM_LOGOS[team.Team];
|
| 86 |
|
| 87 |
return (
|
| 88 |
<div
|
|
|
|
| 90 |
className="absolute w-10 h-10 -ml-5 -mb-5 group z-10 hover:z-50 transition-transform hover:scale-125 cursor-pointer"
|
| 91 |
style={{ left: `${leftPct}%`, bottom: `${bottomPct}%` }}
|
| 92 |
>
|
| 93 |
+
{logoId ? (
|
| 94 |
+
<img src={`/logos/${logoId}.png`} alt={team.Team} className="w-full h-full object-contain md:drop-shadow-xl" />
|
| 95 |
) : (
|
| 96 |
+
<div className="w-4 h-4 m-3 bg-luigi-500 rounded-full md:shadow-[0_0_15px_rgba(16,185,129,0.8)]" />
|
| 97 |
)}
|
| 98 |
|
| 99 |
<div className="absolute bottom-full left-1/2 -translate-x-1/2 mb-2 w-max px-3 py-2 bg-slate-900 border border-slate-700 text-xs rounded opacity-0 group-hover:opacity-100 pointer-events-none shadow-2xl z-50 transition-opacity">
|
logos/1044.png
DELETED
Git LFS Details
|
logos/328.png
DELETED
Git LFS Details
|
logos/341.png
DELETED
Git LFS Details
|
logos/351.png
DELETED
Git LFS Details
|
logos/354.png
DELETED
Git LFS Details
|
logos/397.png
DELETED
Git LFS Details
|
logos/402.png
DELETED
Git LFS Details
|
logos/563.png
DELETED
Git LFS Details
|
logos/57.png
DELETED
Git LFS Details
|
logos/58.png
DELETED
Git LFS Details
|
logos/61.png
DELETED
Git LFS Details
|
logos/62.png
DELETED
Git LFS Details
|
logos/63.png
DELETED
Git LFS Details
|
logos/64.png
DELETED
Git LFS Details
|
logos/65.png
DELETED
Git LFS Details
|
logos/66.png
DELETED
Git LFS Details
|
logos/67.png
DELETED
Git LFS Details
|
logos/71.png
DELETED
Git LFS Details
|
logos/73.png
DELETED
Git LFS Details
|
logos/76.png
DELETED
Git LFS Details
|
main.py
CHANGED
|
@@ -514,47 +514,11 @@ def update_player(req: UpdateRequest):
|
|
| 514 |
|
| 515 |
@app.get("/api/ratings")
|
| 516 |
def get_ratings():
|
| 517 |
-
import base64
|
| 518 |
-
|
| 519 |
if os.path.exists("team_ratings_dual_speed.csv"):
|
| 520 |
df = pd.read_csv("team_ratings_dual_speed.csv")
|
| 521 |
df.rename(columns=lambda x: x.strip(), inplace=True)
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
team_ids = {
|
| 525 |
-
"Arsenal": 57,
|
| 526 |
-
"Manchester City": 65,
|
| 527 |
-
"Liverpool": 64,
|
| 528 |
-
"Chelsea": 61,
|
| 529 |
-
"Newcastle United": 67,
|
| 530 |
-
"Aston Villa": 58,
|
| 531 |
-
"Manchester United": 66,
|
| 532 |
-
"Brentford": 402,
|
| 533 |
-
"Brighton and Hove Albion": 397,
|
| 534 |
-
"AFC Bournemouth": 1044,
|
| 535 |
-
"Tottenham Hotspur": 73,
|
| 536 |
-
"Crystal Palace": 354,
|
| 537 |
-
"Fulham": 63,
|
| 538 |
-
"Nottingham Forest": 351,
|
| 539 |
-
"Everton": 62,
|
| 540 |
-
"Leeds United": 341,
|
| 541 |
-
"West Ham United": 563,
|
| 542 |
-
"Wolverhampton Wanderers": 76,
|
| 543 |
-
"Sunderland": 71,
|
| 544 |
-
"Burnley": 328,
|
| 545 |
-
}
|
| 546 |
-
|
| 547 |
-
def get_logo(t_name):
|
| 548 |
-
tid = team_ids.get(t_name)
|
| 549 |
-
logo_path = f"logos/{tid}.png"
|
| 550 |
-
if tid and os.path.exists(logo_path):
|
| 551 |
-
with open(logo_path, "rb") as f:
|
| 552 |
-
return (
|
| 553 |
-
"data:image/png;base64," + base64.b64encode(f.read()).decode()
|
| 554 |
-
)
|
| 555 |
-
return None
|
| 556 |
-
|
| 557 |
-
df["Logo"] = df["Team"].apply(get_logo)
|
| 558 |
return df.to_dict(orient="records")
|
| 559 |
return []
|
| 560 |
|
|
|
|
| 514 |
|
| 515 |
@app.get("/api/ratings")
|
| 516 |
def get_ratings():
|
|
|
|
|
|
|
| 517 |
if os.path.exists("team_ratings_dual_speed.csv"):
|
| 518 |
df = pd.read_csv("team_ratings_dual_speed.csv")
|
| 519 |
df.rename(columns=lambda x: x.strip(), inplace=True)
|
| 520 |
+
# Strip trailing spaces just in case!
|
| 521 |
+
df["Team"] = df["Team"].str.strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 522 |
return df.to_dict(orient="records")
|
| 523 |
return []
|
| 524 |
|