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

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

@ -18,4 +18,4 @@ function asset(string $assetURI): string {
global $_data_source_name;
$data_source_name = $_data_source_name;
const DATABASE_USER = _DATABASE_USER;
const DATABASE_PASSWORD = _DATABASE_PASSWORD;
const DATABASE_PASSWORD = _DATABASE_PASSWORD;

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

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

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

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

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

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

@ -38,7 +38,7 @@ function getConnection(): Connection {
}
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 {
@ -124,4 +124,4 @@ function runMatch($match, MutableSessionHandle $session): HttpResponse {
//this is a global variable
$basePath = get_public_path(__DIR__);
App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), fn() => getTwig());
App::render(runMatch(getRoutes()->match(), PhpSessionHandle::init()), fn() => getTwig());

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

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

@ -81,8 +81,14 @@ class TeamGateway {
)[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", []);
}
}

@ -64,7 +64,7 @@ class AuthModel {
public function login(string $email, string $password, array &$failures): ?Account {
$hash = $this->gateway->getHash($email);
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 $this->gateway->getAccountFromMail($email);

@ -62,7 +62,7 @@ class TacticModel {
/**
* 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);
}

Loading…
Cancel
Save