WIP
continuous-integration/drone/push Build is failing Details

pull/81/head
DahmaneYanis 1 year ago
parent 3310078ab5
commit 1d995eba88

@ -16,7 +16,7 @@ body {
#header { #header {
text-align: center; text-align: center;
background-color: var(--main-color); background-color: var(--main-color);
margin : 0px; margin: 0px;
/* border : var(--accent-color) 1px ésolid; */ /* border : var(--accent-color) 1px ésolid; */
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -24,34 +24,34 @@ body {
} }
#IQBall { #IQBall {
color : var(--accent-color); color: var(--accent-color);
font-weight: bold; font-weight: bold;
font-size : 45px; font-size: 45px;
} }
#IQBall { #IQBall {
color : #ffa238; color: #ffa238;
font-weight: bold; font-weight: bold;
font-size : 45px; font-size: 45px;
} }
#body { #body {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
margin:0px; margin: 0px;
height: 100%; height: 100%;
background-color: var(--second-color); background-color: var(--second-color);
} }
.data { .data {
border : 1.5px solid var(--main-contrast-color); border: 1.5px solid var(--main-contrast-color);
background-color: var(--main-color); background-color: var(--main-color);
border-radius: 0.75cap; border-radius: 0.75cap;
color : var(--main-contrast-color); color: var(--main-contrast-color);
} }
.data:hover { .data:hover {
border-color: var(--accent-color) ; border-color: var(--accent-color);
cursor : pointer; cursor: pointer;
} }
.listTactic { .listTactic {
@ -60,17 +60,17 @@ body {
.SetButton { .SetButton {
width: 80%; width: 80%;
margin-left : 5%; margin-left: 5%;
margin-top : 5%; margin-top: 5%;
} }
#img-account { #img-account {
width: 100%; width: 100%;
cursor: pointer; cursor: pointer;
} }
#header-right, #header-left { #header-right,
#header-left {
width: 10%; width: 10%;
/* border: yellow 2px solid; */ /* border: yellow 2px solid; */
} }
@ -83,12 +83,12 @@ body {
} }
#username { #username {
color : var(--main-contrast-color); color: var(--main-contrast-color);
margin : 0; margin: 0;
} }
#clickable-header-right:hover #username { #clickable-header-right:hover #username {
color : var(--accent-color); color: var(--accent-color);
} }
#header-center { #header-center {
@ -98,18 +98,17 @@ body {
#clickable-header-right { #clickable-header-right {
width: 40%; width: 40%;
border-radius: 1cap; border-radius: 1cap;
padding : 2%; padding: 2%;
} }
#clickable-header-right:hover { #clickable-header-right:hover {
border : orange 1px solid; border: orange 1px solid;
} }
.clickable { .clickable {
cursor : pointer; cursor: pointer;
} }
#img-account { #img-account {
width: 100%; width: 100%;
} }

@ -5,7 +5,7 @@
#titlePersonalSpace h2 { #titlePersonalSpace h2 {
text-align: center; text-align: center;
color : var(--main-contrast-color); color: var(--main-contrast-color);
/* font-family: Helvetica; /* font-family: Helvetica;
font-weight: bold; */ font-weight: bold; */
} }
@ -13,26 +13,26 @@
#bodyPersonalSpace { #bodyPersonalSpace {
width: 95%; width: 95%;
/* background-color: #ccc2b7; */ /* background-color: #ccc2b7; */
border : 3px var(--main-color) solid; border: 3px var(--main-color) solid;
border-radius: 0.5cap; border-radius: 0.5cap;
align-self: center; align-self: center;
} }
#bodyPersonalSpace table{ #bodyPersonalSpace table {
width: 100%; width: 100%;
border-collapse : separate; border-collapse: separate;
border-spacing : 1em; border-spacing: 1em;
table-layout: fixed; table-layout: fixed;
overflow: hidden; overflow: hidden;
} }
#bodyPersonalSpace td { #bodyPersonalSpace td {
width: 80px !important; width: 80px !important;
padding-bottom : 1%; padding-bottom: 1%;
padding-top : 1%; padding-top: 1%;
height: fit-content; height: fit-content;
text-align: center; text-align: center;
overflow: hidden ; overflow: hidden;
} }
tbody p { tbody p {

@ -10,7 +10,7 @@
#sideMenu h2 { #sideMenu h2 {
display: inline-block; display: inline-block;
margin-right : 5%; margin-right: 5%;
} }
#sideMenuContent { #sideMenuContent {
@ -25,11 +25,11 @@
#sideMenu .title { #sideMenu .title {
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
color : var(--main-contrast-color); color: var(--main-contrast-color);
letter-spacing: 1px; letter-spacing: 1px;
text-transform: uppercase; text-transform: uppercase;
background-color: var(--main-color); background-color: var(--main-color);
padding : 3%; padding: 3%;
margin-bottom: 0px; margin-bottom: 0px;
margin-right: 3%; margin-right: 3%;
} }
@ -40,8 +40,8 @@
.buttonSideMenu { .buttonSideMenu {
/* border : black solid 1px; */ /* border : black solid 1px; */
border-radius :0.5cap; border-radius: 0.5cap;
width :fit-content; width: fit-content;
padding: 2%; padding: 2%;
margin-top: 3%; margin-top: 3%;
overflow: hidden; overflow: hidden;
@ -49,5 +49,5 @@
.buttonSideMenu:hover { .buttonSideMenu:hover {
/* background-color: #c9d1e0; */ /* background-color: #c9d1e0; */
cursor : pointer; cursor: pointer;
} }

@ -1,7 +1,7 @@
:root { :root {
--main-color : #191a21; --main-color: #191a21;
--second-color : #282a36; --second-color: #282a36;
--third-color : #303341; --third-color: #303341;
--accent-color : #ffa238; --accent-color: #ffa238;
--main-contrast-color : #e6edf3; --main-contrast-color: #e6edf3;
} }

@ -13,7 +13,6 @@ import { BasketCourt } from "../components/editor/BasketCourt"
import plainCourt from "../assets/court/full_court.svg" import plainCourt from "../assets/court/full_court.svg"
import halfCourt from "../assets/court/half_court.svg" import halfCourt from "../assets/court/half_court.svg"
import { BallPiece } from "../components/editor/BallPiece" import { BallPiece } from "../components/editor/BallPiece"
import { Rack } from "../components/Rack" import { Rack } from "../components/Rack"
@ -30,8 +29,7 @@ import SavingState, {
SaveStates, SaveStates,
} from "../components/editor/SavingState" } from "../components/editor/SavingState"
import {CourtObject} from "../tactic/CourtObjects"; import { CourtObject } from "../tactic/CourtObjects"
const ERROR_STYLE: CSSProperties = { const ERROR_STYLE: CSSProperties = {
borderColor: "red", borderColor: "red",
@ -64,14 +62,7 @@ interface RackedPlayer {
type RackedCourtObject = { key: "ball" } type RackedCourtObject = { key: "ball" }
export default function Editor({ id, name, courtType, content }: EditorProps) {
export default function Editor({
id,
name,
courtType,
content,
}: EditorProps) {
const isInGuestMode = id == -1 const isInGuestMode = id == -1
const storage_content = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY) const storage_content = localStorage.getItem(GUEST_MODE_CONTENT_STORAGE_KEY)
@ -143,7 +134,6 @@ function EditorView({
const courtDivContentRef = useRef<HTMLDivElement>(null) const courtDivContentRef = useRef<HTMLDivElement>(null)
const isBoundsOnCourt = (bounds: DOMRect) => { const isBoundsOnCourt = (bounds: DOMRect) => {
const courtBounds = courtDivContentRef.current!.getBoundingClientRect() const courtBounds = courtDivContentRef.current!.getBoundingClientRect()
@ -359,9 +349,7 @@ function EditorView({
<div id="main-div"> <div id="main-div">
<div id="topbar-div"> <div id="topbar-div">
<div id="topbar-left"> <div id="topbar-left">
<SavingState state={saveState} />
<SavingState state={saveState}/>
</div> </div>
<div id="title-input-div"> <div id="title-input-div">
<TitleInput <TitleInput

@ -5,42 +5,67 @@ import "../style/side_menu.css"
import { CSSProperties, useRef } from "react" import { CSSProperties, useRef } from "react"
interface Tactic { interface Tactic {
id : number id: number
name : string name: string
creation_date : string creation_date: string
} }
interface Team { interface Team {
id : number id: number
name : string name: string
picture : string picture: string
main_color : string main_color: string
second_color : string second_color: string
} }
export default function Home({ lastTactics, allTactics, teams, username } : { lastTactics : Tactic[] , allTactics : Tactic[], teams : Team[], username : string}) { export default function Home({
lastTactics,
allTactics,
teams,
username,
}: {
lastTactics: Tactic[]
allTactics: Tactic[]
teams: Team[]
username: string
}) {
return ( return (
<div id="main"> <div id="main">
<Title username={username}/> <Title username={username} />
<Body lastTactics={lastTactics} allTactics={allTactics} teams={teams}/> <Body
lastTactics={lastTactics}
allTactics={allTactics}
teams={teams}
/>
</div> </div>
) )
} }
export function Title({username} : {username : string}) { export function Title({ username }: { username: string }) {
return ( return (
<div id="header"> <div id="header">
<div id="header-left"> <div id="header-left"></div>
</div>
<div id="header-center"> <div id="header-center">
<h1 id="IQBall" className="clickable" onClick={() => {location.pathname="/"}}><span id="IQ">IQ</span><span id="Ball">Ball</span></h1> <h1
id="IQBall"
className="clickable"
onClick={() => {
location.pathname = "/"
}}>
<span id="IQ">IQ</span>
<span id="Ball">Ball</span>
</h1>
</div> </div>
<div id="header-right"> <div id="header-right">
<div className="clickable" id="clickable-header-right"> <div className="clickable" id="clickable-header-right">
{/* <AccountSvg id="img-account" /> */} {/* <AccountSvg id="img-account" /> */}
<img id="img-account" src="account.svg" onClick={() => {location.pathname="/settings"}} /> <img
id="img-account"
src="account.svg"
onClick={() => {
location.pathname = "/settings"
}}
/>
<p id="username">{username}</p> <p id="username">{username}</p>
</div> </div>
</div> </div>
@ -48,37 +73,67 @@ export function Title({username} : {username : string}) {
) )
} }
export function Body({ lastTactics, allTactics, teams } : { lastTactics : Tactic[], allTactics : Tactic[], teams : Team[]}) { export function Body({
const widthPersonalSpace = 78; lastTactics,
const widthSideMenu = 100-widthPersonalSpace allTactics,
teams,
}: {
lastTactics: Tactic[]
allTactics: Tactic[]
teams: Team[]
}) {
const widthPersonalSpace = 78
const widthSideMenu = 100 - widthPersonalSpace
return ( return (
<div id="body"> <div id="body">
<PersonalSpace width = {widthPersonalSpace} allTactics = {allTactics}/> <PersonalSpace width={widthPersonalSpace} allTactics={allTactics} />
<SideMenu width = {widthSideMenu} lastTactics={lastTactics} teams={teams} /> <SideMenu
width={widthSideMenu}
lastTactics={lastTactics}
teams={teams}
/>
</div> </div>
) )
} }
export function SideMenu({ width, lastTactics, teams } : { width : number, lastTactics : Tactic[], teams : Team[]}) { export function SideMenu({
width,
lastTactics,
teams,
}: {
width: number
lastTactics: Tactic[]
teams: Team[]
}) {
return ( return (
<div id="sideMenu" style={{ <div
width : width + "%", id="sideMenu"
}}> style={{
width: width + "%",
}}>
<div id="sideMenuContent"> <div id="sideMenuContent">
<Team teams={teams}/> <Team teams={teams} />
<Tactic lastTactics={lastTactics}/> <Tactic lastTactics={lastTactics} />
</div> </div>
</div> </div>
) )
} }
export function PersonalSpace({ width, allTactics }: { width : number, allTactics : Tactic[] }) { export function PersonalSpace({
width,
allTactics,
}: {
width: number
allTactics: Tactic[]
}) {
return ( return (
<div id="personal-space" style={{ <div
width : width + "%", id="personal-space"
}}> style={{
<TitlePersonalSpace/> width: width + "%",
<BodyPersonalSpace allTactics = {allTactics}/> }}>
<TitlePersonalSpace />
<BodyPersonalSpace allTactics={allTactics} />
</div> </div>
) )
} }
@ -91,157 +146,156 @@ function TitlePersonalSpace() {
) )
} }
function TableData({allTactics} : {allTactics : Tactic[]} ) { function TableData({ allTactics }: { allTactics: Tactic[] }) {
const nbRow = Math.floor(allTactics.length/3)+1; const nbRow = Math.floor(allTactics.length / 3) + 1
let listTactic = Array(nbRow); let listTactic = Array(nbRow)
for (let i = 0; i < nbRow; i++) { for (let i = 0; i < nbRow; i++) {
listTactic[i] = Array(0); listTactic[i] = Array(0)
} }
let i = 0; let i = 0
let j = 0; let j = 0
allTactics.forEach(tactic => { allTactics.forEach((tactic) => {
listTactic[i].push(tactic); listTactic[i].push(tactic)
j++; j++
if (j === 3) { if (j === 3) {
i++; i++
j = 0; j = 0
} }
}) })
i = 0; i = 0
while (i < nbRow) { while (i < nbRow) {
listTactic[i] = listTactic[i].map((tactic : Tactic) => listTactic[i] = listTactic[i].map((tactic: Tactic) => (
<td key={tactic.id} className="data" onClick={() => {location.pathname="/tactic/"+tactic.id+"/edit"}}>{troncName(tactic.name, 25)}</td> <td
); key={tactic.id}
i++; className="data"
onClick={() => {
location.pathname = "/tactic/" + tactic.id + "/edit"
}}>
{troncName(tactic.name, 25)}
</td>
))
i++
} }
if (nbRow == 1) { if (nbRow == 1) {
if (listTactic[0].length < 3) { if (listTactic[0].length < 3) {
for (let i = 0; i <= 3-listTactic[0].length; i++) { for (let i = 0; i <= 3 - listTactic[0].length; i++) {
listTactic[0].push(<td key={"tdNone"+i}></td>); listTactic[0].push(<td key={"tdNone" + i}></td>)
} }
} }
} }
const data = listTactic.map((tactic, rowIndex) => const data = listTactic.map((tactic, rowIndex) => (
<tr key={rowIndex+"row"}> <tr key={rowIndex + "row"}>{tactic}</tr>
{tactic} ))
</tr> return data
);
return data;
} }
function BodyPersonalSpace({ allTactics } : { allTactics : Tactic[]}) { function BodyPersonalSpace({ allTactics }: { allTactics: Tactic[] }) {
let data; let data
if (allTactics.length == 0) { if (allTactics.length == 0) {
data = ( data = <p>Aucune tactique créé !</p>
<p>Aucune tactique créé !</p> } else {
); data = <TableData allTactics={allTactics} />
}
else {
data = (<TableData allTactics={allTactics}/>);
} }
return ( return (
<div id="bodyPersonalSpace"> <div id="bodyPersonalSpace">
<table> <table>
<tbody key="tbody"> <tbody key="tbody">{data}</tbody>
{data}
</tbody>
</table> </table>
</div> </div>
) )
} }
export function Team({teams} : {teams : Team[]}) { export function Team({ teams }: { teams: Team[] }) {
const listTeam = teams.map((team, rowIndex) => const listTeam = teams.map((team, rowIndex) => (
<li <li key={"team" + rowIndex}>
key={"team" + rowIndex}
>
{team.name} {team.name}
<button onClick={() => location.pathname="/team/"+team.id}>open</button> <button onClick={() => (location.pathname = "/team/" + team.id)}>
open
</button>
</li> </li>
); ))
return ( return (
<div id="teams"> <div id="teams">
<div className="titreSideMenu"> <div className="titreSideMenu">
<h2 className="title">Mes équipes</h2> <h2 className="title">Mes équipes</h2>
<button className="new" onClick={() => location.pathname="/team/new"}>+</button> <button
className="new"
onClick={() => (location.pathname = "/team/new")}>
+
</button>
</div> </div>
<SetButtonTeam teams={teams}/> <SetButtonTeam teams={teams} />
</div> </div>
) )
} }
export function Tactic({lastTactics} : { lastTactics : Tactic[]}) { export function Tactic({ lastTactics }: { lastTactics: Tactic[] }) {
return ( return (
<div id="tactic"> <div id="tactic">
<div className="titreSideMenu"> <div className="titreSideMenu">
<h2 className="title">Mes dernières stratégies</h2> <h2 className="title">Mes dernières stratégies</h2>
<button className="new" id="createTactic" onClick={() => (location.pathname = "/tactic/new")}>+</button> <button
</div> className="new"
<SetButtonTactic tactics={lastTactics}/> id="createTactic"
onClick={() => (location.pathname = "/tactic/new")}>
+
</button>
</div>
<SetButtonTactic tactics={lastTactics} />
</div> </div>
) )
} }
function SetButtonTactic({ tactics }: { tactics: Tactic[] }) {
function SetButtonTactic ({tactics} : {tactics : Tactic[]}) { const lastTactics = tactics.map((tactic) => (
const lastTactics = tactics.map(tactic =>
<ButtonLastTactic tactic={tactic} /> <ButtonLastTactic tactic={tactic} />
); ))
return ( return <div className="SetButton">{lastTactics}</div>
<div className="SetButton">
{lastTactics}
</div>
);
} }
function SetButtonTeam({teams} : {teams : Team[]}) { function SetButtonTeam({ teams }: { teams: Team[] }) {
const listTeam = teams.map(teams => const listTeam = teams.map((teams) => <ButtonTeam team={teams} />)
<ButtonTeam team={teams} /> return <div className="SetButton">{listTeam}</div>
);
return (
<div className="SetButton">
{listTeam}
</div>
);
} }
function ButtonTeam ({team} : {team : Team}) { function ButtonTeam({ team }: { team: Team }) {
const name = troncName(team.name, 20); const name = troncName(team.name, 20)
return ( return (
<div> <div>
<div <div
id={"ButtonTeam"+team.id} id={"ButtonTeam" + team.id}
className="buttonSideMenu data" className="buttonSideMenu data"
onClick={() => {location.pathname="/team/"+team.id}} onClick={() => {
> location.pathname = "/team/" + team.id
}}>
{name} {name}
</div> </div>
</div> </div>
) )
} }
function ButtonLastTactic ({tactic} : {tactic : Tactic}) { function ButtonLastTactic({ tactic }: { tactic: Tactic }) {
const name = troncName(tactic.name, 20); const name = troncName(tactic.name, 20)
return ( return (
<div <div
id={"Button"+tactic.id} id={"Button" + tactic.id}
className="buttonSideMenu data" className="buttonSideMenu data"
onClick={() => {location.pathname="/tactic/"+tactic.id+"/edit"}} onClick={() => {
> location.pathname = "/tactic/" + tactic.id + "/edit"
}}>
{name} {name}
</div> </div>
); )
} }
function troncName(name: string, limit: number) : string { function troncName(name: string, limit: number): string {
if (name.length > limit) { if (name.length > limit) {
name = name.substring(0, limit) + "..."; name = name.substring(0, limit) + "..."
} else { } else {
name = name; name = name
} }
return name; return name
} }

@ -38,7 +38,7 @@ function getConnection(): Connection {
} }
function getUserController(): UserController { function getUserController(): UserController {
return new UserController(new TacticModel(new TacticInfoGateway(getConnection())), new TeamModel( new TeamGateway(getConnection()), new MemberGateway(getConnection()), new AccountGateway(getConnection()))); return new UserController(new TacticModel(new TacticInfoGateway(getConnection())), new TeamModel(new TeamGateway(getConnection()), new MemberGateway(getConnection()), new AccountGateway(getConnection())));
} }
function getVisualizerController(): VisualizerController { function getVisualizerController(): VisualizerController {

@ -17,7 +17,7 @@ class UserController {
/** /**
* @param TacticModel $tactics * @param TacticModel $tactics
*/ */
public function __construct(TacticModel $tactics, ?TeamModel $teams = NULL) { public function __construct(TacticModel $tactics, ?TeamModel $teams = null) {
$this->tactics = $tactics; $this->tactics = $tactics;
$this->teams = $teams; $this->teams = $teams;
} }
@ -33,10 +33,9 @@ class UserController {
$name = $session->getAccount()->getName(); $name = $session->getAccount()->getName();
//TODO //TODO
if ($this->teams != NULL) { if ($this->teams != null) {
$teams = $this->teams->getAll($session->getAccount()->getId()); $teams = $this->teams->getAll($session->getAccount()->getId());
} } else {
else {
$teams = []; $teams = [];
} }
@ -44,7 +43,7 @@ class UserController {
"lastTactics" => $lastTactics, "lastTactics" => $lastTactics,
"allTactics" => $allTactics, "allTactics" => $allTactics,
"teams" => $teams, "teams" => $teams,
"username" => $name "username" => $name,
]); ]);
// return ViewHttpResponse::react("views/Home.tsx", []); // return ViewHttpResponse::react("views/Home.tsx", []);
} }

@ -53,7 +53,7 @@ class TacticInfoGateway {
ORDER BY creation_date DESC ORDER BY creation_date DESC
LIMIT :nb", LIMIT :nb",
[ [
":ownerId" => [$ownerId, PDO::PARAM_INT],":nb" => [$nb, PDO::PARAM_INT] ":ownerId" => [$ownerId, PDO::PARAM_INT],":nb" => [$nb, PDO::PARAM_INT],
] ]
); );
if (count($res) == 0) { if (count($res) == 0) {
@ -62,11 +62,11 @@ class TacticInfoGateway {
return $res; return $res;
} }
/** /**
* Get all the tactics of the owner * Get all the tactics of the owner
* *
* @return array<array<string,mixed>> * @return array<array<string,mixed>>
*/ */
public function getAll(int $ownerId): ?array { public function getAll(int $ownerId): ?array {
$res = $this->con->fetch( $res = $this->con->fetch(
"SELECT * "SELECT *
@ -74,7 +74,7 @@ class TacticInfoGateway {
WHERE owner = :ownerId WHERE owner = :ownerId
ORDER BY name DESC", ORDER BY name DESC",
[ [
":ownerId" => [$ownerId, PDO::PARAM_INT] ":ownerId" => [$ownerId, PDO::PARAM_INT],
] ]
); );
if (count($res) == 0) { if (count($res) == 0) {

@ -81,7 +81,13 @@ class TeamGateway {
)[0]['id'] ?? null; )[0]['id'] ?? null;
} }
public function getAll(int $user) : array { /**
* Undocumented function
*
* @param integer $user
* @return array<Team>
*/
public function getAll(int $user): array {
return $this->con->fetch("SELECT * FROM Team", []); return $this->con->fetch("SELECT * FROM Team", []);
} }

@ -64,7 +64,7 @@ class AuthModel {
public function login(string $email, string $password, array &$failures): ?Account { public function login(string $email, string $password, array &$failures): ?Account {
$hash = $this->gateway->getHash($email); $hash = $this->gateway->getHash($email);
if ($hash == null or (!password_verify($password, $hash))) { if ($hash == null or (!password_verify($password, $hash))) {
$failures[] = new ValidationFail("email","Adresse email ou mot de passe invalide"); $failures[] = new ValidationFail("email", "Adresse email ou mot de passe invalide");
return null; return null;
} }
return $this->gateway->getAccountFromMail($email); return $this->gateway->getAccountFromMail($email);

@ -62,7 +62,7 @@ class TacticModel {
/** /**
* Return the nb last tactics * Return the nb last tactics
*/ */
public function getLast(int $nb, int $ownerId): ?array { public function getLast(int $nb, int $ownerId): array {
return $this->tactics->getLast($nb, $ownerId); return $this->tactics->getLast($nb, $ownerId);
} }

Loading…
Cancel
Save