commit
167db8ef3e
@ -0,0 +1,68 @@
|
||||
@startuml
|
||||
class Team {
|
||||
- name: String
|
||||
- picture: Url
|
||||
- members: array<int, MemberRole>
|
||||
|
||||
+ getName(): String
|
||||
+ getPicture(): Url
|
||||
+ getMainColor(): Color
|
||||
+ getSecondColor(): Color
|
||||
+ listMembers(): array<Member>
|
||||
}
|
||||
|
||||
Team --> "- mainColor" Color
|
||||
Team --> "- secondColor" Color
|
||||
|
||||
class Color {
|
||||
- value: string
|
||||
- __construct(value : string)
|
||||
+ getValue(): string
|
||||
+ from(value: string): Color
|
||||
+ tryFrom(value : string) : ?Color
|
||||
}
|
||||
|
||||
class TeamGateway{
|
||||
--
|
||||
+ __construct(con : Connexion)
|
||||
+ insert(name : string ,picture : string, mainColor : Color, secondColor : Color)
|
||||
+ listByName(name : string): array
|
||||
}
|
||||
|
||||
TeamGateway *--"- con" Connexion
|
||||
TeamGateway ..> Color
|
||||
|
||||
class TeamModel{
|
||||
---
|
||||
+ __construct(gateway : TeamGateway)
|
||||
+ createTeam(name : string,picture : string, mainColorValue : int, secondColorValue : int, errors : array)
|
||||
+ listByName(name : string ,errors : array) : ?array
|
||||
+ displayTeam(id : int): Team
|
||||
}
|
||||
|
||||
TeamModel *--"- gateway" TeamGateway
|
||||
TeamModel ..> Team
|
||||
TeamModel ..> Color
|
||||
|
||||
class TeamController{
|
||||
- twig : Environement
|
||||
--
|
||||
+ __construct( model : TeamModel, twig : Environement)
|
||||
+ displaySubmitTeam() : HttpResponse
|
||||
+ submitTeam(request : array) : HttpResponse
|
||||
+ displayListTeamByName(): HttpResponse
|
||||
+ listTeamByName(request : array) : HttpResponse
|
||||
+ displayTeam(id : int): HttpResponse
|
||||
}
|
||||
|
||||
TeamController *--"- model" TeamModel
|
||||
|
||||
class Connexion{
|
||||
- pdo : PDO
|
||||
--
|
||||
+ __constructor(pdo : PDO)
|
||||
+ exec(query : string, args : array)
|
||||
+ fetch(query string, args array): array
|
||||
}
|
||||
|
||||
@enduml
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Api;
|
||||
|
||||
use App\Controller\Control;
|
||||
use App\Http\HttpRequest;
|
||||
use App\Http\HttpResponse;
|
||||
use App\Http\JsonHttpResponse;
|
||||
use App\Model\AuthModel;
|
||||
use App\Validation\Validators;
|
||||
|
||||
class APIAuthController {
|
||||
private AuthModel $model;
|
||||
|
||||
/**
|
||||
* @param AuthModel $model
|
||||
*/
|
||||
public function __construct(AuthModel $model) {
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
|
||||
public function authorize(): HttpResponse {
|
||||
return Control::runChecked([
|
||||
"email" => [Validators::regex("/^\\S+@\\S+\\.\\S+$/"), Validators::lenBetween(5, 256)],
|
||||
"password" => [Validators::lenBetween(6, 256)],
|
||||
], function (HttpRequest $req) {
|
||||
$failures = [];
|
||||
$account = $this->model->login($req["email"], $req["password"], $failures);
|
||||
|
||||
if (!empty($failures)) {
|
||||
return new JsonHttpResponse($failures);
|
||||
}
|
||||
|
||||
return new JsonHttpResponse(["authorization" => $account->getToken()]);
|
||||
}, true);
|
||||
}
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
require_once __DIR__ . "/../react-display.php";
|
||||
|
||||
use App\Validation\ValidationFail;
|
||||
use Twig\Environment;
|
||||
use Twig\Error\LoaderError;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Error\SyntaxError;
|
||||
|
||||
class ErrorController {
|
||||
/**
|
||||
* @param ValidationFail[] $failures
|
||||
* @param Environment $twig
|
||||
* @return void
|
||||
*/
|
||||
public static function displayFailures(array $failures, Environment $twig): void {
|
||||
try {
|
||||
$twig->display("error.html.twig", ['failures' => $failures]);
|
||||
} catch (LoaderError|RuntimeError|SyntaxError $e) {
|
||||
echo "Twig error: $e";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller\Sub;
|
||||
|
||||
use App\Http\HttpRequest;
|
||||
use App\Http\HttpResponse;
|
||||
use App\Http\ViewHttpResponse;
|
||||
use App\Model\TeamModel;
|
||||
use App\Validation\FieldValidationFail;
|
||||
use App\Validation\Validators;
|
||||
|
||||
class TeamController {
|
||||
private TeamModel $model;
|
||||
|
||||
/**
|
||||
* @param TeamModel $model
|
||||
*/
|
||||
public function __construct(TeamModel $model) {
|
||||
$this->model = $model;
|
||||
}
|
||||
|
||||
public function displaySubmitTeam(): HttpResponse {
|
||||
return ViewHttpResponse::twig("insert_team.html.twig", []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $request
|
||||
* @return HttpResponse
|
||||
*/
|
||||
public function submitTeam(array $request): HttpResponse {
|
||||
$errors = [];
|
||||
|
||||
$request = HttpRequest::from($request, $errors, [
|
||||
"name" => [Validators::lenBetween(1, 32), Validators::nameWithSpaces()],
|
||||
"mainColor" => [Validators::regex('/#(?:[0-9a-fA-F]{6})/')],
|
||||
"secondColor" => [Validators::regex('/#(?:[0-9a-fA-F]{6})/')],
|
||||
"picture" => [Validators::isURL()],
|
||||
]);
|
||||
if (!empty($errors)) {
|
||||
$badFields = [];
|
||||
foreach ($errors as $e) {
|
||||
if ($e instanceof FieldValidationFail) {
|
||||
$badFields[] = $e->getFieldName();
|
||||
}
|
||||
}
|
||||
return ViewHttpResponse::twig('insert_team.html.twig', ['bad_fields' => $badFields]);
|
||||
}
|
||||
return $this->getTeam($this->model->createTeam($request['name'], $request['picture'], $request['mainColor'], $request['secondColor']));
|
||||
}
|
||||
|
||||
public function displayListTeamByName(): HttpResponse {
|
||||
return ViewHttpResponse::twig("list_team_by_name.html.twig", []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string , mixed> $request
|
||||
* @return HttpResponse
|
||||
*/
|
||||
public function listTeamByName(array $request): HttpResponse {
|
||||
$errors = [];
|
||||
$request = HttpRequest::from($request, $errors, [
|
||||
"name" => [Validators::lenBetween(1, 32), Validators::nameWithSpaces()],
|
||||
]);
|
||||
|
||||
if (!empty($errors) && $errors[0] instanceof FieldValidationFail) {
|
||||
$badField = $errors[0]->getFieldName();
|
||||
return ViewHttpResponse::twig('list_team_by_name.html.twig', ['bad_field' => $badField]);
|
||||
}
|
||||
|
||||
$results = $this->model->listByName($request['name']);
|
||||
|
||||
if (empty($results)) {
|
||||
return ViewHttpResponse::twig('display_teams.html.twig', []);
|
||||
}
|
||||
|
||||
return ViewHttpResponse::twig('display_teams.html.twig', ['teams' => $results]);
|
||||
}
|
||||
|
||||
public function getTeam(int $id): HttpResponse {
|
||||
$result = $this->model->displayTeam($id);
|
||||
return ViewHttpResponse::twig('display_team.html.twig', ['team' => $result]);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Connexion;
|
||||
use App\Gateway\AccountGateway;
|
||||
use App\Http\HttpResponse;
|
||||
use App\Model\AuthModel;
|
||||
use App\Session\MutableSessionHandle;
|
||||
|
||||
class VisitorController {
|
||||
final public function register(MutableSessionHandle $session): HttpResponse {
|
||||
$model = new AuthModel(new AccountGateway(new Connexion(get_database())));
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
return (new Sub\AuthController($model))->displayRegister();
|
||||
}
|
||||
return (new Sub\AuthController($model))->confirmRegister($_POST, $session);
|
||||
}
|
||||
|
||||
final public function login(MutableSessionHandle $session): HttpResponse {
|
||||
$model = new AuthModel(new AccountGateway(new Connexion(get_database())));
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
return (new Sub\AuthController($model))->displayLogin();
|
||||
}
|
||||
return (new Sub\AuthController($model))->confirmLogin($_POST, $session);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Gateway;
|
||||
|
||||
use App\Connexion;
|
||||
use App\Data\Account;
|
||||
use PDO;
|
||||
|
||||
class AccountGateway {
|
||||
private Connexion $con;
|
||||
|
||||
/**
|
||||
* @param Connexion $con
|
||||
*/
|
||||
public function __construct(Connexion $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
|
||||
public function insertAccount(string $name, string $email, string $token, string $hash): int {
|
||||
$this->con->exec("INSERT INTO Account(username, hash, email, token) VALUES (:username,:hash,:email,:token)", [
|
||||
':username' => [$name, PDO::PARAM_STR],
|
||||
':hash' => [$hash, PDO::PARAM_STR],
|
||||
':email' => [$email, PDO::PARAM_STR],
|
||||
':token' => [$token, PDO::PARAM_STR],
|
||||
]);
|
||||
return intval($this->con->lastInsertId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return array<string, mixed>|null
|
||||
*/
|
||||
private function getRowsFromMail(string $email): ?array {
|
||||
return $this->con->fetch("SELECT * FROM Account WHERE email = :email", [':email' => [$email, PDO::PARAM_STR]])[0] ?? null;
|
||||
}
|
||||
|
||||
|
||||
public function getHash(string $email): ?string {
|
||||
$results = $this->getRowsFromMail($email);
|
||||
if ($results == null) {
|
||||
return null;
|
||||
}
|
||||
return $results['hash'];
|
||||
}
|
||||
|
||||
public function exists(string $email): bool {
|
||||
return $this->getRowsFromMail($email) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return Account|null
|
||||
*/
|
||||
public function getAccountFromMail(string $email): ?Account {
|
||||
$acc = $this->getRowsFromMail($email);
|
||||
if (empty($acc)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Account($email, $acc["username"], $acc["token"], $acc["id"]);
|
||||
}
|
||||
|
||||
public function getAccountFromToken(string $token): ?Account {
|
||||
$acc = $this->con->fetch("SELECT * FROM Account WHERE token = :token", [':token' => [$token, PDO::PARAM_STR]])[0] ?? null;
|
||||
if (empty($acc)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Account($acc["email"], $acc["username"], $acc["token"], $acc["id"]);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Gateway;
|
||||
|
||||
use App\Connexion;
|
||||
use PDO;
|
||||
|
||||
class AuthGateway {
|
||||
private Connexion $con;
|
||||
|
||||
/**
|
||||
* @param Connexion $con
|
||||
*/
|
||||
public function __construct(Connexion $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
|
||||
public function mailExist(string $email): bool {
|
||||
return $this->getUserFields($email) != null;
|
||||
}
|
||||
|
||||
|
||||
public function insertAccount(string $username, string $hash, string $email): void {
|
||||
$this->con->exec("INSERT INTO AccountUser VALUES (:username,:hash,:email)", [':username' => [$username, PDO::PARAM_STR],':hash' => [$hash, PDO::PARAM_STR],':email' => [$email, PDO::PARAM_STR]]);
|
||||
}
|
||||
|
||||
public function getUserHash(string $email): string {
|
||||
$results = $this->con->fetch("SELECT hash FROM AccountUser WHERE email = :email", [':email' => [$email, PDO::PARAM_STR]]);
|
||||
return $results[0]['hash'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return array<string,string>|null
|
||||
*/
|
||||
public function getUserFields(string $email): ?array {
|
||||
$results = $this->con->fetch("SELECT username,email FROM AccountUser WHERE email = :email", [':email' => [$email, PDO::PARAM_STR]]);
|
||||
$firstRow = $results[0] ?? null;
|
||||
return $firstRow;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace App\Gateway;
|
||||
|
||||
use App\Connexion;
|
||||
use PDO;
|
||||
|
||||
class TeamGateway {
|
||||
private Connexion $con;
|
||||
|
||||
public function __construct(Connexion $con) {
|
||||
$this->con = $con;
|
||||
}
|
||||
|
||||
public function insert(string $name, string $picture, string $mainColor, string $secondColor): void {
|
||||
$this->con->exec(
|
||||
"INSERT INTO Team(name, picture, mainColor, secondColor) VALUES (:teamName , :picture, :mainColor, :secondColor)",
|
||||
[
|
||||
":teamName" => [$name, PDO::PARAM_STR],
|
||||
":picture" => [$picture, PDO::PARAM_STR],
|
||||
":mainColor" => [$mainColor, PDO::PARAM_STR],
|
||||
":secondColor" => [$secondColor, PDO::PARAM_STR],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return array<string,mixed>[]
|
||||
*/
|
||||
public function listByName(string $name): array {
|
||||
return $this->con->fetch(
|
||||
"SELECT id,name,picture,mainColor,secondColor FROM Team WHERE name LIKE '%' || :name || '%'",
|
||||
[
|
||||
":name" => [$name, PDO::PARAM_STR],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array<string,mixed>[]
|
||||
*/
|
||||
public function getTeamById(int $id): array {
|
||||
return $this->con->fetch(
|
||||
"SELECT id,name,picture,mainColor,secondColor FROM Team WHERE id = :id",
|
||||
[
|
||||
":id" => [$id, PDO::PARAM_INT],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return array<string,int>[]
|
||||
*/
|
||||
public function getIdTeamByName(string $name): array {
|
||||
return $this->con->fetch(
|
||||
"SELECT id FROM Team WHERE name = :name",
|
||||
[
|
||||
":name" => [$name, PDO::PARAM_STR],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return array<string,mixed>[]
|
||||
*/
|
||||
public function getMembersById(int $id): array {
|
||||
return $this->con->fetch(
|
||||
"SELECT m.role,u.id FROM User u,Team t,Member m WHERE t.id = :id AND m.idTeam = t.id AND m.idMember = u.id",
|
||||
[
|
||||
":id" => [$id, PDO::PARAM_INT],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use App\Gateway\TeamGateway;
|
||||
use App\Data\Team;
|
||||
use App\Data\Member;
|
||||
use App\Data\MemberRole;
|
||||
use App\Data\Color;
|
||||
|
||||
class TeamModel {
|
||||
private TeamGateway $gateway;
|
||||
|
||||
/**
|
||||
* @param TeamGateway $gateway
|
||||
*/
|
||||
public function __construct(TeamGateway $gateway) {
|
||||
$this->gateway = $gateway;
|
||||
}
|
||||
|
||||
public function createTeam(string $name, string $picture, string $mainColor, string $secondColor): int {
|
||||
$this->gateway->insert($name, $picture, $mainColor, $secondColor);
|
||||
$result = $this->gateway->getIdTeamByName($name);
|
||||
return intval($result[0]['id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Team[]
|
||||
*/
|
||||
public function listByName(string $name): array {
|
||||
$teams = [];
|
||||
$results = $this->gateway->listByName($name);
|
||||
foreach ($results as $row) {
|
||||
$teams[] = new Team($row['id'], $row['name'], $row['picture'], Color::from($row['mainColor']), Color::from($row['secondColor']));
|
||||
}
|
||||
return $teams;
|
||||
}
|
||||
|
||||
public function displayTeam(int $id): Team {
|
||||
$members = [];
|
||||
$result = $this->gateway->getTeamById($id)[0];
|
||||
$resultMembers = $this->gateway->getMembersById($id);
|
||||
foreach ($resultMembers as $row) {
|
||||
if ($row['role'] == 'C') {
|
||||
$role = MemberRole::coach();
|
||||
} else {
|
||||
$role = MemberRole::player();
|
||||
}
|
||||
$members[] = new Member($row['id'], $role);
|
||||
}
|
||||
return new Team(intval($result['id']), $result['name'], $result['picture'], Color::from($result['mainColor']), Color::from($result['secondColor']), $members);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Session;
|
||||
|
||||
use App\Data\Account;
|
||||
|
||||
/**
|
||||
* The mutable side of a session handle
|
||||
*/
|
||||
interface MutableSessionHandle extends SessionHandle {
|
||||
/**
|
||||
* @param string|null $url the url to redirect the user to after authentication.
|
||||
*/
|
||||
public function setInitialTarget(?string $url): void;
|
||||
|
||||
/**
|
||||
* @param Account $account update the session's account
|
||||
*/
|
||||
public function setAccount(Account $account): void;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Session;
|
||||
|
||||
use App\Data\Account;
|
||||
|
||||
/**
|
||||
* A PHP session handle
|
||||
*/
|
||||
class PhpSessionHandle implements MutableSessionHandle {
|
||||
public static function init(): self {
|
||||
if (session_status() !== PHP_SESSION_NONE) {
|
||||
throw new \Exception("A php session is already started !");
|
||||
}
|
||||
session_start();
|
||||
return new PhpSessionHandle();
|
||||
}
|
||||
|
||||
public function getAccount(): ?Account {
|
||||
return $_SESSION["account"] ?? null;
|
||||
}
|
||||
|
||||
public function getInitialTarget(): ?string {
|
||||
return $_SESSION["target"] ?? null;
|
||||
}
|
||||
|
||||
public function setAccount(Account $account): void {
|
||||
$_SESSION["account"] = $account;
|
||||
}
|
||||
|
||||
public function setInitialTarget(?string $url): void {
|
||||
$_SESSION["target"] = $url;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Session;
|
||||
|
||||
use App\Data\Account;
|
||||
|
||||
/**
|
||||
* An immutable session handle
|
||||
*/
|
||||
interface SessionHandle {
|
||||
/**
|
||||
* The initial target url if the user wanted to perform an action that requires authentication
|
||||
* but has been required to login first in the application.
|
||||
* @return string|null Get the initial targeted URL
|
||||
*/
|
||||
public function getInitialTarget(): ?string;
|
||||
|
||||
/**
|
||||
* The session account if the user is logged in.
|
||||
* @return Account|null
|
||||
*/
|
||||
public function getAccount(): ?Account;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Validator;
|
||||
|
||||
use App\Data\TacticInfo;
|
||||
use App\Validation\ValidationFail;
|
||||
|
||||
class TacticValidator {
|
||||
public static function validateAccess(?TacticInfo $tactic, int $tacticId, int $ownerId): ?ValidationFail {
|
||||
if ($tactic == null) {
|
||||
return ValidationFail::notFound("La tactique $tacticId n'existe pas");
|
||||
}
|
||||
|
||||
if ($tactic->getOwnerId() != $ownerId) {
|
||||
return ValidationFail::unauthorized("Vous ne pouvez pas accéder à cette tactique.");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Twig view</title>
|
||||
<style>
|
||||
body{
|
||||
background-color: #f1f1f1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
section{
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.square{
|
||||
width:50px;
|
||||
height:50px;
|
||||
}
|
||||
|
||||
#mainColor{
|
||||
background-color: {{ team.mainColor.getValue() }};
|
||||
{% if team.mainColor.getValue() == "#ffffff" %}
|
||||
border-color: #666666;
|
||||
{% endif %}
|
||||
}
|
||||
#secondColor{
|
||||
background-color: {{ team.secondColor.getValue() }};
|
||||
{% if team.secondColor.getValue() == "#ffffff" %}
|
||||
border-color: #666666;
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
.container{
|
||||
background-color: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
.team{
|
||||
border-color: darkgrey;
|
||||
border-radius: 20px;
|
||||
|
||||
}
|
||||
|
||||
.color{
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.logo{
|
||||
height: 80px;
|
||||
width: 80px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1><a href="/">IQBall</a></h1>
|
||||
</header>
|
||||
|
||||
<section class="container">
|
||||
|
||||
<div class="team container">
|
||||
<div>
|
||||
<h1>{{ team.name }}</h1>
|
||||
<img src="{{ team.picture }}" alt="Logo d'équipe" class="logo">
|
||||
</div>
|
||||
<div>
|
||||
<div class="color"><p>Couleur principale : </p><div class="square" id="mainColor"></div> </div>
|
||||
<div class="color"><p>Couleur secondaire : </p><div class="square" id="secondColor"></div></div>
|
||||
</div>
|
||||
{% for m in team.members %}
|
||||
<p> m.id </p>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Twig view</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{% if teams is empty %}
|
||||
<p>Aucune équipe n'a été trouvée</p>
|
||||
<div class="container">
|
||||
<h2>Chercher une équipe</h2>
|
||||
<form action="/listTea" method="post">
|
||||
<div class="form-group">
|
||||
<label for="name">Nom de l'équipe :</label>
|
||||
<input type="text" id="name" name="name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Confirmer">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% else %}
|
||||
{% for t in teams %}
|
||||
<div class="team" onclick="window.location.href = '/getTeam/{{ t.id }}'">
|
||||
<p>Nom de l'équipe : {{ t.name }}</p>
|
||||
<img src="{{ t.picture }}" alt="logo de l'équipe">
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,85 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insertion view</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
{% for item in bad_fields %}
|
||||
#{{ item }}{
|
||||
border-color: red;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
input[type="text"], input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="submit"]:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h2>Créer une équipe</h2>
|
||||
<form action="/createTeam" method="post">
|
||||
<div class="form-group">
|
||||
<label for="name">Nom de l'équipe :</label>
|
||||
<input type="text" id="name" name="name" required>
|
||||
<label for= "picture">Logo:</label>
|
||||
<input type="text" id="picture" name="picture" required >
|
||||
<label for="mainColor">Couleur principale</label>
|
||||
<input type="color" id="mainColor" name="mainColor" required>
|
||||
<label for="secondColor">Couleur secondaire</label>
|
||||
<input type="color" id="secondColor" name="secondColor" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Confirmer">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,77 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Insertion view</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
background-color: #f1f1f1;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 400px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #fff;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
{% for item in bad_fields %}
|
||||
#{{ item }}{
|
||||
border-color: red;
|
||||
}
|
||||
{% endfor %}
|
||||
|
||||
input[type="text"], input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
background-color: #007bff;
|
||||
color: #fff;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
input[type="submit"]:hover {
|
||||
background-color: #0056b3;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="container">
|
||||
<h2>Chercher une équipe</h2>
|
||||
<form action="/listTeams" method="post">
|
||||
<div class="form-group">
|
||||
<label for="name">Nom de l'équipe :</label>
|
||||
<input type="text" id="name" name="name" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="submit" value="Confirmer">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in new issue