Compare commits
89 Commits
WORK_merge
...
master
@ -0,0 +1,90 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: HeartWave
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Test ✔️
|
||||||
|
- name: test
|
||||||
|
image: composer:2.6
|
||||||
|
commands:
|
||||||
|
- cd Sources
|
||||||
|
- rm -r vendor
|
||||||
|
- rm composer.lock
|
||||||
|
# Installe les dépendances PHP si nécessaire
|
||||||
|
- php composer.phar install --no-interaction
|
||||||
|
- ./vendor/bin/phpunit tests
|
||||||
|
|
||||||
|
# Sonar static code analisis deployment
|
||||||
|
# TODO : use an image that already have unzip
|
||||||
|
- name: code-analysis
|
||||||
|
image: php:8.1-cli
|
||||||
|
environment:
|
||||||
|
SONAR_TOKEN:
|
||||||
|
from_secret: SONAR_TOKEN
|
||||||
|
commands:
|
||||||
|
- apt-get update && apt-get install -y curl unzip
|
||||||
|
- export SONAR_SCANNER_VERSION=4.7.0.2747
|
||||||
|
- export SONAR_SCANNER_HOME=$HOME/.sonar/sonar-scanner-$SONAR_SCANNER_VERSION-linux
|
||||||
|
- curl --create-dirs -sSLo $HOME/.sonar/sonar-scanner.zip https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$SONAR_SCANNER_VERSION-linux.zip
|
||||||
|
- unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
|
||||||
|
- export PATH=$SONAR_SCANNER_HOME/bin:$PATH
|
||||||
|
- export SONAR_SCANNER_OPTS="-server"
|
||||||
|
- cd Sources
|
||||||
|
- sonar-scanner -D sonar.projectKey=HeartTrack -D sonar.host.url=https://codefirst.iut.uca.fr/sonar
|
||||||
|
depends_on: [ test ]
|
||||||
|
# build image and push on the registry ✔️
|
||||||
|
- name: rewrite-urls
|
||||||
|
image: 'busybox:latest'
|
||||||
|
commands:
|
||||||
|
- cd Sources
|
||||||
|
- ls
|
||||||
|
- >-
|
||||||
|
find . -type f -exec sed -i -r
|
||||||
|
"s@(href|src)=\"/@\1=\"$${PLUGIN_CONTAINER_PATH}@g" {} +
|
||||||
|
settings:
|
||||||
|
container_path: https://codefirst.iut.uca.fr/containers/HeartDev-web/
|
||||||
|
|
||||||
|
- name: docker-build-and-push
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
commands: ls
|
||||||
|
dockerfile: Sources/config/Dockerfile
|
||||||
|
context: Sources
|
||||||
|
registry: hub.codefirst.iut.uca.fr
|
||||||
|
repo: hub.codefirst.iut.uca.fr/david.d_almeida/web
|
||||||
|
mirror: https://proxy.iut.uca.fr:8443
|
||||||
|
username:
|
||||||
|
from_secret: SECRET_REGISTRY_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: SECRET_REGISTRY_PASSWORD
|
||||||
|
depends_on:
|
||||||
|
- rewrite-urls
|
||||||
|
|
||||||
|
- name: deploy-container
|
||||||
|
image: >-
|
||||||
|
hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
|
||||||
|
environment:
|
||||||
|
IMAGENAME: 'hub.codefirst.iut.uca.fr/david.d_almeida/web:latest'
|
||||||
|
CONTAINERNAME: web
|
||||||
|
COMMAND: create
|
||||||
|
OVERWRITE: true
|
||||||
|
ADMINS: david.d_almeida
|
||||||
|
depends_on:
|
||||||
|
- docker-build-and-push
|
||||||
|
|
||||||
|
- name: notify
|
||||||
|
image: ruby:2.1
|
||||||
|
when:
|
||||||
|
status: [ success ]
|
||||||
|
ref:
|
||||||
|
include:
|
||||||
|
- refs/tags/*-demo
|
||||||
|
commands:
|
||||||
|
- sh ./notifymail.sh
|
||||||
|
depends_on: [ docker-build-and-push ]
|
||||||
|
|
||||||
|
|
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 27 KiB |
@ -0,0 +1,2 @@
|
|||||||
|
AddType text/css .css
|
||||||
|
AddType application/javascript .js
|
@ -1,17 +1,31 @@
|
|||||||
FROM php:8.2-fpm
|
FROM php:8.2-apache as base
|
||||||
# Installation de dépendances nécessaires pour Composer
|
# Installation de dépendances nécessaires pour Composer
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
git \
|
git \
|
||||||
unzip
|
unzip
|
||||||
|
|
||||||
# Installation de Composer
|
# Installation de Composer
|
||||||
# TODO : should use a image with composer install
|
|
||||||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
|
||||||
|
|
||||||
RUN docker-php-ext-install pdo pdo_mysql
|
RUN docker-php-ext-install pdo pdo_mysql
|
||||||
|
|
||||||
COPY . /var/www/
|
# Copy configs
|
||||||
|
COPY ./config/virtual-host.conf /etc/apache2/sites-available/000-default.conf
|
||||||
|
COPY ./config/httpd.conf /etc/apache2/httpd.conf
|
||||||
|
|
||||||
|
# Setup App
|
||||||
|
RUN mkdir -p /app/public && chown -R www-data:www-data /app
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# add sources code
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
ENV VOLUME_PATH /app/public
|
||||||
|
|
||||||
|
RUN composer install
|
||||||
|
|
||||||
WORKDIR /var/www/
|
EXPOSE 80
|
||||||
|
|
||||||
RUN composer install
|
CMD ["apache2-foreground"]
|
@ -0,0 +1 @@
|
|||||||
|
SetEnv ASSET_PREFIX containers/HeartDev-web/
|
@ -1,28 +1,19 @@
|
|||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
index index.php;
|
index index.php index.html index.htm;
|
||||||
root /var/www/public;
|
root /usr/share/nginx/html;
|
||||||
error_page 404 /index.php;
|
error_page 404 /index.php;
|
||||||
|
|
||||||
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
|
|
||||||
root /var/www/public;
|
|
||||||
}
|
|
||||||
|
|
||||||
location ~ \.php$ {
|
location ~ \.php$ {
|
||||||
fastcgi_pass web:9000; # service name defined in docker-compose.yml file like web
|
|
||||||
fastcgi_param REQUEST_METHOD $request_method;
|
fastcgi_param REQUEST_METHOD $request_method;
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
}
|
}
|
||||||
location ~ /\. {
|
|
||||||
deny all;
|
|
||||||
access_log off;
|
|
||||||
log_not_found off;
|
|
||||||
}
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.php?$query_string;
|
root /usr/share/nginx/html;
|
||||||
|
try_files $uri /index.php;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
<VirtualHost *:80>
|
||||||
|
ServerName default
|
||||||
|
|
||||||
|
<Directory />
|
||||||
|
Options FollowSymLinks
|
||||||
|
AllowOverride None
|
||||||
|
Require all denied
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory ${VOLUME_PATH}>
|
||||||
|
AllowOverride All
|
||||||
|
Require all granted
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
DocumentRoot ${VOLUME_PATH}
|
||||||
|
|
||||||
|
AccessFileName .htaccess
|
||||||
|
<FilesMatch "^\.ht">
|
||||||
|
Require all denied
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
||||||
|
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||||
|
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
||||||
|
LogFormat "%{Referer}i -> %U" referer
|
||||||
|
LogFormat "%{User-agent}i" agent
|
||||||
|
|
||||||
|
CustomLog /proc/self/fd/1 combined
|
||||||
|
|
||||||
|
<FilesMatch \.php$>
|
||||||
|
SetHandler application/x-httpd-php
|
||||||
|
</FilesMatch>
|
||||||
|
|
||||||
|
# Multiple DirectoryIndex directives within the same context will add
|
||||||
|
# to the list of resources to look for rather than replace
|
||||||
|
# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
|
||||||
|
DirectoryIndex disabled
|
||||||
|
DirectoryIndex index.php index.html
|
||||||
|
</VirtualHost>
|
Before Width: | Height: | Size: 136 KiB |
Before Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 692 B After Width: | Height: | Size: 586 B |
@ -1,34 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Start Bootstrap - New Age v6.0.7 (https://startbootstrap.com/theme/new-age)
|
|
||||||
* Copyright 2013-2023 Start Bootstrap
|
|
||||||
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-new-age/blob/master/LICENSE)
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Scripts
|
|
||||||
//
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', event => {
|
|
||||||
|
|
||||||
// Activate Bootstrap scrollspy on the main nav element
|
|
||||||
const mainNav = document.body.querySelector('#mainNav');
|
|
||||||
if (mainNav) {
|
|
||||||
new bootstrap.ScrollSpy(document.body, {
|
|
||||||
target: '#mainNav',
|
|
||||||
offset: 74,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Collapse responsive navbar when toggler is visible
|
|
||||||
const navbarToggler = document.body.querySelector('.navbar-toggler');
|
|
||||||
const responsiveNavItems = [].slice.call(
|
|
||||||
document.querySelectorAll('#navbarResponsive .nav-link')
|
|
||||||
);
|
|
||||||
responsiveNavItems.map(function (responsiveNavItem) {
|
|
||||||
responsiveNavItem.addEventListener('click', () => {
|
|
||||||
if (window.getComputedStyle(navbarToggler).display !== 'none') {
|
|
||||||
navbarToggler.click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,34 +0,0 @@
|
|||||||
/*!
|
|
||||||
* Start Bootstrap - New Age v6.0.7 (https://startbootstrap.com/theme/new-age)
|
|
||||||
* Copyright 2013-2023 Start Bootstrap
|
|
||||||
* Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-new-age/blob/master/LICENSE)
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Scripts
|
|
||||||
//
|
|
||||||
|
|
||||||
window.addEventListener('DOMContentLoaded', event => {
|
|
||||||
|
|
||||||
// Activate Bootstrap scrollspy on the main nav element
|
|
||||||
const mainNav = document.body.querySelector('#mainNav');
|
|
||||||
if (mainNav) {
|
|
||||||
new bootstrap.ScrollSpy(document.body, {
|
|
||||||
target: '#mainNav',
|
|
||||||
offset: 74,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Collapse responsive navbar when toggler is visible
|
|
||||||
const navbarToggler = document.body.querySelector('.navbar-toggler');
|
|
||||||
const responsiveNavItems = [].slice.call(
|
|
||||||
document.querySelectorAll('#navbarResponsive .nav-link')
|
|
||||||
);
|
|
||||||
responsiveNavItems.map(function (responsiveNavItem) {
|
|
||||||
responsiveNavItem.addEventListener('click', () => {
|
|
||||||
if (window.getComputedStyle(navbarToggler).display !== 'none') {
|
|
||||||
navbarToggler.click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
@ -1,422 +0,0 @@
|
|||||||
<?php
|
|
||||||
//
|
|
||||||
//namespace App\Controller;
|
|
||||||
//
|
|
||||||
//use App\Container;
|
|
||||||
//use App\Router\Request\IRequest;
|
|
||||||
//use App\Router\Response\Response;
|
|
||||||
//use Shared\Attributes\Route;
|
|
||||||
//use Twig\Environment;
|
|
||||||
//use Data\Core\Preferences;
|
|
||||||
//use Shared\Log;
|
|
||||||
//
|
|
||||||
//// TODO : Remove this BaseClass
|
|
||||||
//class Controller extends BaseController
|
|
||||||
//{
|
|
||||||
//
|
|
||||||
// #[Route(path: '/activity', name: 'activity', methods: ['GET'])]
|
|
||||||
// public function activity(): Response
|
|
||||||
// {
|
|
||||||
// return $this->render('./page/activity.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// #[Route(path: '/exercices', name: 'exercices', methods: ['POST'])] // 8
|
|
||||||
// public function exercices(String $type, String $intensite, String $date, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
// $exercicesArray = [
|
|
||||||
// [
|
|
||||||
// 'date' => $date,
|
|
||||||
// 'type' => $type,
|
|
||||||
// 'intensite' => $intensite,
|
|
||||||
// 'status' => 'A venur',
|
|
||||||
// ]
|
|
||||||
// ];
|
|
||||||
// return $this->render('./page/exercice.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => $exercicesArray,
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/search-user', name: 'search-user', methods: ['GET'])]
|
|
||||||
// public function searchUser(string $username, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
// $taberror = [];
|
|
||||||
// // FILTER
|
|
||||||
// $utiliArray = [
|
|
||||||
// [
|
|
||||||
// 'nom' => 'John',
|
|
||||||
// 'prenom' => 'Doe',
|
|
||||||
// 'img' => 'john_doe',
|
|
||||||
// 'username' => 'johndoe',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'nom' => 'Alice',
|
|
||||||
// 'prenom' => 'Smith',
|
|
||||||
// 'img' => 'alice_smith',
|
|
||||||
// 'username' => 'alicesmith',
|
|
||||||
// ],
|
|
||||||
// ];
|
|
||||||
// // if(!Validation::val_string($name)){
|
|
||||||
// try {
|
|
||||||
// //code...
|
|
||||||
// // $model->userMgr->addFriend($name);
|
|
||||||
// return $this->render('./page/addfriend.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => $utiliArray,
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => [],
|
|
||||||
// 'responce' => "Notification d'ajout envoyée à $username"
|
|
||||||
// ]);
|
|
||||||
// } catch (\Throwable $th) {
|
|
||||||
// //throw $th;
|
|
||||||
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
|
||||||
// }
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/search-member', name: 'search-member', methods: ['GET'])]
|
|
||||||
// public function searchMember(string $username, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
// $taberror = [];
|
|
||||||
// // FILTER
|
|
||||||
// $utiliArray = [
|
|
||||||
// [
|
|
||||||
// 'nom' => 'John',
|
|
||||||
// 'prenom' => 'Doe',
|
|
||||||
// 'img' => 'john_doe',
|
|
||||||
// 'username' => 'johndoe',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'nom' => 'Alice',
|
|
||||||
// 'prenom' => 'Smith',
|
|
||||||
// 'img' => 'alice_smith',
|
|
||||||
// 'username' => 'alicesmith',
|
|
||||||
// ],
|
|
||||||
// ];
|
|
||||||
// // if(!Validation::val_string($name)){
|
|
||||||
// try {
|
|
||||||
// //code...
|
|
||||||
// // $model->userMgr->addFriend($name);
|
|
||||||
// return $this->render('./page/addmember.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => $utiliArray,
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => [],
|
|
||||||
// 'responce' => "Notification d'ajout envoyée à $username"
|
|
||||||
// ]);
|
|
||||||
// } catch (\Throwable $th) {
|
|
||||||
// //throw $th;
|
|
||||||
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
|
||||||
// }
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/add-member', name: 'add-member', methods: ['POST'])]
|
|
||||||
// public function addmember(string $username, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
// $taberror = [];
|
|
||||||
// $utiliArray = [
|
|
||||||
// [
|
|
||||||
// 'nom' => 'John',
|
|
||||||
// 'prenom' => 'Doe',
|
|
||||||
// 'img' => 'john_doe',
|
|
||||||
// 'username' => 'johndoe',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'nom' => 'Alice',
|
|
||||||
// 'prenom' => 'Smith',
|
|
||||||
// 'img' => 'alice_smith',
|
|
||||||
// 'username' => 'alicesmith',
|
|
||||||
// ],
|
|
||||||
// ];
|
|
||||||
// // if(!Validation::val_string($name)){
|
|
||||||
// try {
|
|
||||||
// //code...
|
|
||||||
// // $model->userMgr->addFriend($name);
|
|
||||||
// return $this->render('./page/addmember.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => $utiliArray,
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => [],
|
|
||||||
// 'responce' => "Notification d'ajout envoyée à $username"
|
|
||||||
// ]);
|
|
||||||
// } catch (\Throwable $th) {
|
|
||||||
// //throw $th;
|
|
||||||
// // return $this->render("addfriend.html.twig", ['tabError' => $taberror ]);
|
|
||||||
// }
|
|
||||||
// // }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/member', name: 'member', methods: ['GET'])]
|
|
||||||
// public function member(): Response
|
|
||||||
// {
|
|
||||||
// $utiliArray = [
|
|
||||||
// [
|
|
||||||
// 'nom' => 'John',
|
|
||||||
// 'prenom' => 'Doe',
|
|
||||||
// 'img' => 'john_doe',
|
|
||||||
// 'username' => 'johndoe',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'nom' => 'Alice',
|
|
||||||
// 'prenom' => 'Smith',
|
|
||||||
// 'img' => 'alice_smith',
|
|
||||||
// 'username' => 'alicesmith',
|
|
||||||
// ],
|
|
||||||
// ];
|
|
||||||
// return $this->render('./page/addmember.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => $utiliArray,
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => [],
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// #[Route(path: '/friendlist', name: 'friendlist', methods: ['POST'])]
|
|
||||||
// public function friendlist(string $username, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
// $utiliArray = [
|
|
||||||
// [
|
|
||||||
// 'nom' => 'John',
|
|
||||||
// 'prenom' => 'Doe',
|
|
||||||
// 'img' => 'john_doe',
|
|
||||||
// 'username' => 'johndoe',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'nom' => 'Alice',
|
|
||||||
// 'prenom' => 'Smith',
|
|
||||||
// 'img' => 'alice_smith',
|
|
||||||
// 'username' => 'alicesmith',
|
|
||||||
// ],
|
|
||||||
// ];
|
|
||||||
// /* TODO */
|
|
||||||
//
|
|
||||||
// // -> Enlever ou bloquer un utilisateur en fonction de son username
|
|
||||||
//
|
|
||||||
// return $this->render('./page/friend.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => $utiliArray,
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => [],
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/friendlist', name: 'friendlist2', methods: ['GET'])]
|
|
||||||
// public function friendlist2(): Response
|
|
||||||
// {
|
|
||||||
// $utiliArray = [
|
|
||||||
// [
|
|
||||||
// 'nom' => 'John',
|
|
||||||
// 'prenom' => 'Doe',
|
|
||||||
// 'img' => 'test',
|
|
||||||
// 'status' => 'johndoe',
|
|
||||||
// 'username' => 'jdoe',
|
|
||||||
// ],
|
|
||||||
// [
|
|
||||||
// 'nom' => 'Alice',
|
|
||||||
// 'prenom' => 'Smith',
|
|
||||||
// 'img' => 'test2',
|
|
||||||
// 'status' => 'alicesmith',
|
|
||||||
// 'username' => 'asmith',
|
|
||||||
// ],
|
|
||||||
// ];
|
|
||||||
// return $this->render('./page/friend.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => $utiliArray,
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => [],
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/coaching', name: 'coaching', methods: ['GET'])]
|
|
||||||
// public function coaching(): Response
|
|
||||||
// {
|
|
||||||
// return $this->render('./page/coaching.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
|
||||||
// public function mail(): Response
|
|
||||||
// {
|
|
||||||
// return $this->render('./page/mail.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// #[Route(path: '/profile', name: 'profile', methods: ['GET'])]
|
|
||||||
// public function profile(): Response
|
|
||||||
// {
|
|
||||||
// return $this->render('./page/profile.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// #[Route(path: '/psettings', name: 'psettings', methods: ['POST'])]
|
|
||||||
// public function psettings(string $nom,string $prenom,string $dateNaissance,string $mail,string $tel, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// return $this->render('./page/settings.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => $prenom,
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// #[Route(path: '/pass', name: 'pass', methods: ['GET'])]
|
|
||||||
// public function pass(): Response
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// // CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
//
|
|
||||||
// return $this->render('./page/password.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// #[Route(path: '/password', name: 'password', methods: ['POST'])]
|
|
||||||
// public function password(string $email, IRequest $req): Response
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// // CONFIRMER LES DONNESS !!!!! IMPORTANT
|
|
||||||
//
|
|
||||||
// return $this->render('./page/login.html.twig',[
|
|
||||||
// 'css' => $this->preference->getCookie(),
|
|
||||||
// 'pp' => "test2",
|
|
||||||
// 'user' => "Doe",
|
|
||||||
// 'role' => "Athlète",
|
|
||||||
// 'friendship' => [],
|
|
||||||
// 'analyzes' => [],
|
|
||||||
// 'mails' => [],
|
|
||||||
// 'users' => [],
|
|
||||||
// 'infoUser' => [],
|
|
||||||
// 'exos' => [],
|
|
||||||
// 'member' => []
|
|
||||||
// ]);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//
|
|
@ -1,95 +1,36 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
// namespace App\Controller;
|
||||||
|
|
||||||
|
// use App\Container;
|
||||||
|
// use App\Router\Request\IRequest;
|
||||||
|
// use App\Router\Response\Response;
|
||||||
|
// use Shared\Attributes\Route;
|
||||||
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
|
// class HeartRateController extends BaseController
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
|
// #[Route(path: '/import', name: 'import', methods: ['GET'])]
|
||||||
|
// public function import(): Response
|
||||||
|
// {
|
||||||
|
// return $this->render('./page/import.html.twig',[
|
||||||
|
// 'css' => $this->preference->getCookie(),
|
||||||
|
// 'pp' => "test2",
|
||||||
|
// 'user' => "Doe",
|
||||||
|
// 'role' => "Athlète",
|
||||||
|
// 'friendship' => [],
|
||||||
|
// 'analyzes' => [],
|
||||||
|
// 'mails' => [],
|
||||||
|
// 'users' => [],
|
||||||
|
// 'infoUser' => [],
|
||||||
|
// 'exos' => [],
|
||||||
|
// 'member' => []
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
|
||||||
use App\Container;
|
|
||||||
use App\Router\Request\IRequest;
|
|
||||||
use App\Router\Response\IResponse;
|
|
||||||
use App\Router\Response\RedirectResponse;
|
|
||||||
use App\Router\Response\Response;
|
|
||||||
use Manager\ActivityManager;
|
|
||||||
use Shared\Attributes\Route;
|
|
||||||
use Twig\Environment;
|
|
||||||
use Data\Core\Preferences;
|
|
||||||
use Shared\Log;
|
|
||||||
|
|
||||||
class HeartRateController extends BaseController
|
|
||||||
{
|
|
||||||
|
|
||||||
private ActivityManager $activityMgr;
|
|
||||||
|
|
||||||
public function __construct(ActivityManager $manager)
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->activityMgr = $manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/import', name: 'import', methods: ['GET'])]
|
|
||||||
public function import(): Response
|
|
||||||
{
|
|
||||||
return $this->render('./page/import.html.twig', [
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Route(path: '/upload', name: 'upload', methods: ['POST'])]
|
// }
|
||||||
public function uploadFile(string $activityType, int $effort, IRequest $req): IResponse
|
|
||||||
{
|
|
||||||
$error = $this->validateRequest($effort);
|
|
||||||
if (!empty($error)) {
|
|
||||||
return $this->renderError($error);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tmp_file = $_FILES['uploaded_file']['tmp_name'];
|
|
||||||
if (!$this->isValidFile($tmp_file)) {
|
|
||||||
return $this->renderError(['Failed to get file be sure that you provide the file']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = file_get_contents($tmp_file);
|
|
||||||
try {
|
|
||||||
|
|
||||||
if ($this->activityMgr->uploadFile($activityType, 5, $content)) {
|
|
||||||
return new RedirectResponse('/');
|
|
||||||
}
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
return $this->renderError([$e->getMessage()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->renderError(['Failed to save activity.']);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function validateRequest(int $effort): array
|
|
||||||
{
|
|
||||||
$error = [];
|
|
||||||
if ($effort < 0 || $effort > 5) {
|
|
||||||
$error[] = 'Invalid effort level.';
|
|
||||||
}
|
|
||||||
$fileExtension = pathinfo($_FILES['uploaded_file']['name'], PATHINFO_EXTENSION);
|
|
||||||
if ($fileExtension !== 'fit') {
|
|
||||||
$error[] = 'Invalid file type. Only .fit files are allowed.';
|
|
||||||
}
|
|
||||||
return $error;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isValidFile(string $tmp_file): bool
|
|
||||||
{
|
|
||||||
return file_exists($tmp_file) && is_uploaded_file($tmp_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function renderError(array $error): Response
|
|
||||||
{
|
|
||||||
// Consolidez la logique de rendu ici
|
|
||||||
return $this->render('./error/error.html.twig', ['title'=> "Failed" , "code" => 400, "name" => "error import", "descr" => $error[0] ], new Response('$error', 400));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,45 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Controller;
|
// namespace App\Controller;
|
||||||
|
|
||||||
use App\Container;
|
// use App\Container;
|
||||||
use App\Router\Request\IRequest;
|
// use App\Router\Request\IRequest;
|
||||||
use App\Router\Response\Response;
|
// use App\Router\Response\Response;
|
||||||
use Shared\Attributes\Route;
|
// use App\Router\Response\IResponse;
|
||||||
use Twig\Environment;
|
|
||||||
use Data\Core\Preferences;
|
|
||||||
use Shared\Log;
|
|
||||||
|
|
||||||
class SocialController extends BaseController
|
// use Shared\Attributes\Route;
|
||||||
{
|
// use Twig\Environment;
|
||||||
|
// use Data\Core\Preferences;
|
||||||
|
// use Shared\Log;
|
||||||
|
|
||||||
private Environment $twig;
|
|
||||||
protected Preferences $preference;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
session_start();
|
|
||||||
$this->preference = new Preferences();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// #[Route(path: '/coach', name: 'coach')]
|
||||||
#[Route(path: '/mail', name: 'mail', methods: ['GET'])]
|
// class CoachController extends BaseController
|
||||||
public function mail(): Response
|
// {
|
||||||
{
|
|
||||||
return $this->render('./page/mail.html.twig',[
|
|
||||||
'css' => $this->preference->getCookie(),
|
|
||||||
'pp' => "test2",
|
|
||||||
'user' => "Doe",
|
|
||||||
'role' => "Athlète",
|
|
||||||
'friendship' => [],
|
|
||||||
'analyzes' => [],
|
|
||||||
'mails' => [],
|
|
||||||
'users' => [],
|
|
||||||
'infoUser' => [],
|
|
||||||
'exos' => [],
|
|
||||||
'member' => []
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,48 +1,40 @@
|
|||||||
{% extends "authbase.html.twig" %}
|
{% extends "authbase.html.twig" %}
|
||||||
|
|
||||||
{% block css %}{{ css }}{% endblock %}
|
{% block css %}{{css}}{% endblock %}
|
||||||
|
|
||||||
{% block title %}Connexion - HearthTrack{% endblock %}
|
{% block title %}Connexion - HearthTrack{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-lg-5">
|
<div class="col-lg-5">
|
||||||
<div class="card shadow-lg border-0 rounded-lg mt-5">
|
<div class="card shadow-lg border-0 rounded-lg mt-5">
|
||||||
<div class="card-header"><h3 class="text-center font-weight-light my-4">Connexion</h3></div>
|
<div class="card-header"><h3 class="text-center font-weight-light my-4">Connexion</h3></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{% if login_error %}
|
<form>
|
||||||
{% for value in login_error %}
|
<div class="form-floating mb-3">
|
||||||
<div class="alert alert-danger" role="alert">
|
<input class="form-control" id="inputEmail" type="email" placeholder="nom@exemple.com" />
|
||||||
{{ value }}
|
<label for="inputEmail">Adresse eMail</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-floating mb-3">
|
||||||
|
<input class="form-control" id="inputPassword" type="password" placeholder="Mot de passe" />
|
||||||
|
<label for="inputPassword">Mot de passe</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check mb-3">
|
||||||
|
<input class="form-check-input" id="inputRememberPassword" type="checkbox" value="" />
|
||||||
|
<label class="form-check-label" for="inputRememberPassword">Mémoriser le mot de passe</label>
|
||||||
|
</div>
|
||||||
|
<div class="d-flex align-items-center justify-content-between mt-4 mb-0">
|
||||||
|
<a class="small" href="password.html">Mot de passe oublié ?</a>
|
||||||
|
<a class="btn btn-primary" href="index.html">Se connecter</a>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer text-center py-3">
|
||||||
|
<div class="small"><a href="register.html">Besoin d'un compte ? Inscrivez-vous !</a></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<form method="post" action="/login">
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<input class="form-control" id="email" name="email" type="text" placeholder="Nom d'utilisateur" />
|
|
||||||
<label for="email">Nom d'utilisateur</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-floating mb-3">
|
|
||||||
<input class="form-control" id="password" name="password" type="password" placeholder="Mot de passe" />
|
|
||||||
<label for="password">Mot de passe</label>
|
|
||||||
</div>
|
|
||||||
<div class="form-check mb-3">
|
|
||||||
<input class="form-check-input" id="inputRememberPassword" type="checkbox" value="" />
|
|
||||||
<label class="form-check-label" for="inputRememberPassword">Mémoriser le mot de passe</label>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-items-center justify-content-between mt-4 mb-0">
|
</div>
|
||||||
<a class="small" href="/forgetPassword">Mot de passe oublié ?</a>
|
|
||||||
<button class="btn btn-primary" type="submit">Se connecter</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer text-center py-3">
|
|
||||||
<div class="small"><a href="/register">Besoin d'un compte ? Inscrivez-vous !</a></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{% endblock %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database;
|
||||||
|
use Model\Activite;
|
||||||
|
|
||||||
|
class ActiviteMapper {
|
||||||
|
public function map(array $data):ActiviteEntity {
|
||||||
|
$activite = new ActiviteEntity();
|
||||||
|
$activite->setIdActivite($data['idActivite']);
|
||||||
|
$activite->setType($data['type']);
|
||||||
|
$activite->setDate($data['date']);
|
||||||
|
$activite->setHeureDebut($data['heureDebut']);
|
||||||
|
$activite->setHeureFin($data['heureFin']);
|
||||||
|
$activite->setEffortRessenti($data['effortRessenti']);
|
||||||
|
$activite->setVariabilite($data['variabilite']);
|
||||||
|
$activite->setVariance($data['variance']);
|
||||||
|
$activite->setEcartType($data['ecartType']);
|
||||||
|
$activite->setMoyenne($data['moyenne']);
|
||||||
|
$activite->setMaximum($data['maximum']);
|
||||||
|
$activite->setMinimum($data['minimum']);
|
||||||
|
$activite->setTemperatureMoyenne($data['temperatureMoyenne']);
|
||||||
|
|
||||||
|
return $activite;
|
||||||
|
}
|
||||||
|
|
||||||
|
//public function ActiviteEntityToModel(ActiviteEntity entity): Activite;
|
||||||
|
|
||||||
|
public function ActiviteEntityToModel(ActiviteEntity $activiteEntity):Activite{
|
||||||
|
|
||||||
|
$act = new Activite(
|
||||||
|
$activiteEntity->getIdActivite(),
|
||||||
|
$activiteEntity->getType(),
|
||||||
|
$activiteEntity->getDate(),
|
||||||
|
$activiteEntity->getHeureDebut(),
|
||||||
|
$activiteEntity->getHeureFin(),
|
||||||
|
$activiteEntity->getEffortRessenti(),
|
||||||
|
$activiteEntity->getVariabilite(),
|
||||||
|
$activiteEntity->getVariance(),
|
||||||
|
$activiteEntity->getEcartType(),
|
||||||
|
$activiteEntity->getMoyenne(),
|
||||||
|
$activiteEntity->getMaximum(),
|
||||||
|
$activiteEntity->getMinimum(),
|
||||||
|
$activiteEntity->getTemperatureMoyenne()
|
||||||
|
);
|
||||||
|
|
||||||
|
return $act;
|
||||||
|
}
|
||||||
|
//public function ActiviteToEntity(Activite model): ActiviteEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,118 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
use Model\Activity;
|
|
||||||
|
|
||||||
class ActivityMapper {
|
|
||||||
public function activitySqlToEntity(array $data):array
|
|
||||||
{
|
|
||||||
$activityEntities = [];
|
|
||||||
|
|
||||||
foreach ($data as $activityData) {
|
|
||||||
$activity = new ActivityEntity();
|
|
||||||
|
|
||||||
if (isset($activityData['idActivity'])) {
|
|
||||||
$activity->setIdActivity($data['idActivity']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['type'])) {
|
|
||||||
$activity->setType($data['type']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['date'])) {
|
|
||||||
$activity->setDate($data['date']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['heureDebut'])) {
|
|
||||||
$activity->setHeureDebut($data['heureDebut']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['heureFin'])) {
|
|
||||||
$activity->setHeureFin($data['heureFin']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['effortRessenti'])) {
|
|
||||||
$activity->setEffortRessenti($data['effortRessenti']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['variabilite'])) {
|
|
||||||
$activity->setVariabilite($data['variabilite']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['variance'])) {
|
|
||||||
$activity->setVariance($data['variance']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['ecartType'])) {
|
|
||||||
$activity->setEcartType($data['ecartType']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['moyenne'])) {
|
|
||||||
$activity->setMoyenne($data['moyenne']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['maximum'])) {
|
|
||||||
$activity->setMaximum($data['maximum']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['minimum'])) {
|
|
||||||
$activity->setMinimum($data['minimum']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($activityData['temperatureMoyenne'])) {
|
|
||||||
$activity->setTemperatureMoyenne($data['temperatureMoyenne']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$activityEntities[] = $activity;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $activityEntities;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \Exception
|
|
||||||
*/
|
|
||||||
public function ActivityEntityToModel(ActivityEntity $activiteEntity):Activity{
|
|
||||||
|
|
||||||
$act = new Activity(
|
|
||||||
$activiteEntity->getIdActivity(),
|
|
||||||
$activiteEntity->getType(),
|
|
||||||
$activiteEntity->getDate(),
|
|
||||||
$activiteEntity->getHeureDebut(),
|
|
||||||
$activiteEntity->getHeureFin(),
|
|
||||||
$activiteEntity->getEffortRessenti(),
|
|
||||||
$activiteEntity->getVariabilite(),
|
|
||||||
$activiteEntity->getVariance(),
|
|
||||||
$activiteEntity->getEcartType(),
|
|
||||||
$activiteEntity->getMoyenne(),
|
|
||||||
$activiteEntity->getMaximum(),
|
|
||||||
$activiteEntity->getMinimum(),
|
|
||||||
$activiteEntity->getTemperatureMoyenne()
|
|
||||||
);
|
|
||||||
|
|
||||||
return $act;
|
|
||||||
}
|
|
||||||
//public function ActivityToEntity(Activity model): ActivityEntity;
|
|
||||||
|
|
||||||
public function activityToEntity(Activity $act):ActivityEntity{
|
|
||||||
|
|
||||||
$act = new ActivityEntity();
|
|
||||||
$act->setIdActivity($act->getIdActivity()());
|
|
||||||
$act->setType($act->getType());
|
|
||||||
$act->setDate($act->getDate());
|
|
||||||
$act->setHeureDebut($act->getHeureDebut());
|
|
||||||
$act->setHeureFin($act->getHeureFin());
|
|
||||||
$act->setEffortRessenti($act->getEffortRessenti());
|
|
||||||
$act->setVariabilite($act->getVariabilite());
|
|
||||||
$act->setVariance($act->getVariance());
|
|
||||||
$act->setEcartType($act->getEcartType());
|
|
||||||
$act->setMoyenne($act->getMoyenne());
|
|
||||||
$act->setMaximum($act->getMaximum());
|
|
||||||
$act->setMinimum($act->getMinimum());
|
|
||||||
$act->setTemperatureMoyenne($act->getTemperatureMoyenne());
|
|
||||||
|
|
||||||
return $act;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@ -1,71 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
|
|
||||||
class EntrainementEntity
|
|
||||||
{
|
|
||||||
private $idEntrainement;
|
|
||||||
private $date;
|
|
||||||
private $description;
|
|
||||||
private $latitude;
|
|
||||||
private $longitude;
|
|
||||||
private $feedback;
|
|
||||||
private $coachId;
|
|
||||||
|
|
||||||
public function getIdEntrainement()
|
|
||||||
{
|
|
||||||
return $this->idEntrainement;
|
|
||||||
}
|
|
||||||
public function getDate()
|
|
||||||
{
|
|
||||||
return $this->date;
|
|
||||||
}
|
|
||||||
public function getDescription()
|
|
||||||
{
|
|
||||||
return $this->description;
|
|
||||||
}
|
|
||||||
public function getLatitude()
|
|
||||||
{
|
|
||||||
return $this->latitude;
|
|
||||||
}
|
|
||||||
public function getLongitude()
|
|
||||||
{
|
|
||||||
return $this->longitude;
|
|
||||||
}
|
|
||||||
public function getFeedback()
|
|
||||||
{
|
|
||||||
return $this->feedback;
|
|
||||||
}
|
|
||||||
public function getCoachId()
|
|
||||||
{
|
|
||||||
return $this->coachId;
|
|
||||||
}
|
|
||||||
public function setIdEntrainement($idEntrainement)
|
|
||||||
{
|
|
||||||
$this->idEntrainement = $idEntrainement;
|
|
||||||
}
|
|
||||||
public function setDate($date)
|
|
||||||
{
|
|
||||||
$this->date = $date;
|
|
||||||
}
|
|
||||||
public function setDescription($description)
|
|
||||||
{
|
|
||||||
$this->description = $description;
|
|
||||||
}
|
|
||||||
public function setLatitude($latitude)
|
|
||||||
{
|
|
||||||
$this->latitude = $latitude;
|
|
||||||
}
|
|
||||||
public function setLongitude($longitude)
|
|
||||||
{
|
|
||||||
$this->longitude = $longitude;
|
|
||||||
}
|
|
||||||
public function setFeedback($feedback)
|
|
||||||
{
|
|
||||||
$this->feedback = $feedback;
|
|
||||||
}
|
|
||||||
public function setCoachId($coachId)
|
|
||||||
{
|
|
||||||
$this->coachId = $coachId;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
|
|
||||||
class EntrainementGateway
|
|
||||||
{
|
|
||||||
private Connexion $connection;
|
|
||||||
|
|
||||||
public function __construct(Connexion $connection) {
|
|
||||||
$this->connection = $connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getEntrainements(): array
|
|
||||||
{
|
|
||||||
$query = "SELECT * FROM Entrainement";
|
|
||||||
$res = $this->connection->executeWithErrorHandling($query);
|
|
||||||
return $res;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Database;
|
|
||||||
|
|
||||||
use Model\Athlete;
|
|
||||||
use Model\Training;
|
|
||||||
use Model\User;
|
|
||||||
|
|
||||||
class EntrainementMapper
|
|
||||||
{
|
|
||||||
public function entrainementSqlToEntity(array $data): array {
|
|
||||||
$entrainementEntities = [];
|
|
||||||
|
|
||||||
foreach ($data as $entrainementData) {
|
|
||||||
$entrainement = new EntrainementEntity();
|
|
||||||
if (isset($entrainementData['idEntrainement'])) {
|
|
||||||
$entrainement->setIdEntrainement($entrainementData['idEntrainement']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($entrainementData['date'])) {
|
|
||||||
$entrainement->setDate($entrainementData['date']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($entrainementData['description'])) {
|
|
||||||
$entrainement->setDescription($entrainementData['description']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($entrainementData['latitude'])) {
|
|
||||||
$entrainement->setLatitude($entrainementData['latitude']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($entrainementData['longitude'])) {
|
|
||||||
$entrainement->setLongitude($entrainementData['longitude']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($entrainementData['feedback'])) {
|
|
||||||
$entrainement->setFeedback($entrainementData['feedback']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($entrainementData['coachId'])) {
|
|
||||||
$entrainement->setCoachId($entrainementData['coachId']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$entrainementEntities[] = $entrainement;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $entrainementEntities;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function entrainementEntityToModel(EntrainementEntity $entrainementEntity): Training {
|
|
||||||
return new Training(
|
|
||||||
$entrainementEntity->getIdEntrainement(),
|
|
||||||
$entrainementEntity->getDate(),
|
|
||||||
$entrainementEntity->getDescription(),
|
|
||||||
$entrainementEntity->getLatitude(),
|
|
||||||
$entrainementEntity->getLongitude(),
|
|
||||||
$entrainementEntity->getFeedback()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function entrainementToEntity(Training $training):EntrainementEntity{
|
|
||||||
|
|
||||||
$train = new EntrainementEntity();
|
|
||||||
$train->setIdEntrainement($training->getId());
|
|
||||||
$train->setDate($training->getDate());
|
|
||||||
$train->setDescription($training->getDescription());
|
|
||||||
$train->setLatitude($training->getLatitude());
|
|
||||||
$train->setLongitude($training->getLongitude());
|
|
||||||
$train->setFeedback($training->getFeedback());
|
|
||||||
$train->setCoachId(1);
|
|
||||||
|
|
||||||
return $train;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +1,158 @@
|
|||||||
DROP TABLE IF EXISTS Athlete, Friendship, Notification, Statistique, Entrainement, Participe, SourceDonnee, Activite, FrequenceCardiaque CASCADE;
|
-- Athlete Table
|
||||||
|
|
||||||
CREATE TABLE Athlete (
|
CREATE TABLE Athlete (
|
||||||
idAthlete SERIAL PRIMARY KEY,
|
idAthlete SERIAL PRIMARY KEY,
|
||||||
nom VARCHAR(255),
|
nom VARCHAR(255),
|
||||||
prenom VARCHAR(255),
|
prenom VARCHAR(255),
|
||||||
email VARCHAR(255) UNIQUE,
|
email VARCHAR(255) UNIQUE,
|
||||||
sexe CHAR(1),
|
sexe CHAR(1),
|
||||||
taille DECIMAL,
|
taille DECIMAL,
|
||||||
poids DECIMAL,
|
poids DECIMAL,
|
||||||
motDePasse VARCHAR(255),
|
motDePasse VARCHAR(255),
|
||||||
dateNaissance DATE,
|
dateNaissance DATE
|
||||||
isCoach BOOLEAN
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Friendship Table
|
||||||
CREATE TABLE Friendship (
|
CREATE TABLE Friendship (
|
||||||
idAthlete1 INT,
|
idAthlete1 INT,
|
||||||
idAthlete2 INT,
|
idAthlete2 INT,
|
||||||
debut DATE,
|
debut DATE,
|
||||||
PRIMARY KEY (idAthlete1, idAthlete2),
|
PRIMARY KEY (idAthlete1, idAthlete2),
|
||||||
FOREIGN KEY (idAthlete1) REFERENCES Athlete(idAthlete),
|
FOREIGN KEY (idAthlete1) REFERENCES Athlete (idAthlete),
|
||||||
FOREIGN KEY (idAthlete2) REFERENCES Athlete(idAthlete)
|
FOREIGN KEY (idAthlete2) REFERENCES Athlete (idAthlete)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Notification Table
|
||||||
CREATE TABLE Notification (
|
CREATE TABLE Notification (
|
||||||
idNotif INT PRIMARY KEY,
|
idNotif SERIAL PRIMARY KEY,
|
||||||
message TEXT,
|
message TEXT,
|
||||||
date DATE,
|
date DATE,
|
||||||
statut BOOLEAN,
|
statut BOOLEAN,
|
||||||
urgence INT,
|
urgence INT,
|
||||||
athleteId INT,
|
athleteId INT,
|
||||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete)
|
||||||
|
);
|
||||||
|
|
||||||
|
-- Coach Table
|
||||||
|
CREATE TABLE Coach (
|
||||||
|
idCoach SERIAL PRIMARY KEY,
|
||||||
|
athleteId INT,
|
||||||
|
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Statistique Table
|
||||||
CREATE TABLE Statistique (
|
CREATE TABLE Statistique (
|
||||||
idStatistique INT PRIMARY KEY,
|
idStatistique SERIAL PRIMARY KEY,
|
||||||
poids DECIMAL,
|
poids DECIMAL,
|
||||||
fcMoyenne DECIMAL,
|
fcMoyenne DECIMAL,
|
||||||
fcMax DECIMAL,
|
fcMax DECIMAL,
|
||||||
caloriesBruleesMoy DECIMAL,
|
caloriesBruleesMoy DECIMAL,
|
||||||
date DATE,
|
date DATE,
|
||||||
athleteId INT,
|
athleteId INT,
|
||||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Entrainement Table
|
||||||
CREATE TABLE Entrainement (
|
CREATE TABLE Entrainement (
|
||||||
idEntrainement INT PRIMARY KEY,
|
idEntrainement SERIAL PRIMARY KEY,
|
||||||
date DATE,
|
date DATE,
|
||||||
description TEXT,
|
description TEXT,
|
||||||
latitude DECIMAL,
|
latitude DECIMAL,
|
||||||
longitude DECIMAL,
|
longitude DECIMAL,
|
||||||
feedback TEXT,
|
feedback TEXT,
|
||||||
athleteId INT,
|
coachId INT,
|
||||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
FOREIGN KEY (coachId) REFERENCES Coach (idCoach)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Participe Table
|
||||||
CREATE TABLE Participe (
|
CREATE TABLE Participe (
|
||||||
athleteId INT,
|
athleteId INT,
|
||||||
entrainementId INT,
|
entrainementId INT,
|
||||||
PRIMARY KEY (athleteId, entrainementId),
|
PRIMARY KEY (athleteId, entrainementId),
|
||||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
|
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete),
|
||||||
FOREIGN KEY (entrainementId) REFERENCES Entrainement(idEntrainement)
|
FOREIGN KEY (entrainementId) REFERENCES Entrainement (idEntrainement)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- SourceDonnee Table
|
||||||
CREATE TABLE SourceDonnee (
|
CREATE TABLE SourceDonnee (
|
||||||
idSource INT PRIMARY KEY,
|
idSource SERIAL PRIMARY KEY,
|
||||||
type VARCHAR(255),
|
type VARCHAR(255),
|
||||||
modele VARCHAR(255),
|
modele VARCHAR(255),
|
||||||
precision2 DECIMAL,
|
precision DECIMAL,
|
||||||
athleteId INT,
|
athleteId INT,
|
||||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete)
|
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- Activite Table
|
||||||
CREATE TABLE Activite (
|
CREATE TABLE Activite (
|
||||||
idActivite INT PRIMARY KEY,
|
idActivite SERIAL PRIMARY KEY,
|
||||||
type VARCHAR(255),
|
type VARCHAR(255),
|
||||||
date DATE,
|
date DATE,
|
||||||
heureDeDebut TIME,
|
heureDeDebut TIME,
|
||||||
heureDeFin TIME,
|
heureDeFin TIME,
|
||||||
effortRessent DECIMAL,
|
effortRessent DECIMAL,
|
||||||
variabilite DECIMAL,
|
variabilite DECIMAL,
|
||||||
variance DECIMAL,
|
variance DECIMAL,
|
||||||
ecartType DECIMAL,
|
ecartType DECIMAL,
|
||||||
moyenne DECIMAL,
|
moyenne DECIMAL,
|
||||||
maximum DECIMAL,
|
maximum DECIMAL,
|
||||||
minimum DECIMAL,
|
minimum DECIMAL,
|
||||||
temperatureMoyenne DECIMAL,
|
temperatureMoyenne DECIMAL,
|
||||||
athleteId INT,
|
athleteId INT,
|
||||||
sourceId INT,
|
sourceId INT,
|
||||||
FOREIGN KEY (athleteId) REFERENCES Athlete(idAthlete),
|
FOREIGN KEY (athleteId) REFERENCES Athlete (idAthlete),
|
||||||
FOREIGN KEY (sourceId) REFERENCES SourceDonnee(idSource)
|
FOREIGN KEY (sourceId) REFERENCES SourceDonnee (idSource)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
-- FrequenceCardiaque Table
|
||||||
CREATE TABLE FrequenceCardiaque (
|
CREATE TABLE FrequenceCardiaque (
|
||||||
idFc INT PRIMARY KEY,
|
idFc SERIAL PRIMARY KEY,
|
||||||
altitude DECIMAL,
|
altitude DECIMAL,
|
||||||
temps TIME,
|
temps TIME,
|
||||||
temperature DECIMAL,
|
temperature DECIMAL,
|
||||||
bpm INT,
|
bpm INT,
|
||||||
longitude DECIMAL,
|
longitude DECIMAL,
|
||||||
latitude DECIMAL,
|
latitude DECIMAL,
|
||||||
activiteId INT,
|
activiteId INT,
|
||||||
FOREIGN KEY (activiteId) REFERENCES Activite(idActivite)
|
FOREIGN KEY (activiteId) REFERENCES Activite (idActivite)
|
||||||
);
|
);
|
||||||
|
|
||||||
INSERT INTO Athlete (idAthlete, nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance, isCoach) VALUES
|
-- Insertion de données dans la table Athlete
|
||||||
(1, 'Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01', FALSE),
|
INSERT INTO Athlete (nom, prenom, email, sexe, taille, poids, motDePasse, dateNaissance) VALUES
|
||||||
(2, 'Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02', TRUE);
|
('Doe', 'John', 'john.doe@example.com', 'M', 1.80, 70, 'password123', '1990-01-01'),
|
||||||
|
('Smith', 'Jane', 'jane.smith@example.com', 'F', 1.65, 60, 'password456', '1992-02-02');
|
||||||
|
|
||||||
|
-- Insertion de données dans la table Friendship
|
||||||
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
|
INSERT INTO Friendship (idAthlete1, idAthlete2, debut) VALUES
|
||||||
(1, 2, '2023-01-01');
|
(1, 2, '2023-01-01');
|
||||||
|
|
||||||
|
-- Insertion de données dans la table Notification
|
||||||
|
INSERT INTO Notification (message, date, statut, urgence, athleteId) VALUES
|
||||||
|
('Training session at 10 AM', '2023-03-10', TRUE, 1, 1);
|
||||||
|
|
||||||
INSERT INTO Notification (idNotif, message, date, statut, urgence, athleteId) VALUES
|
-- Insertion de données dans la table Coach
|
||||||
(1, 'Training session at 10 AM', '2023-03-10', TRUE, 1, 1);
|
INSERT INTO Coach (athleteId) VALUES
|
||||||
|
(1);
|
||||||
|
|
||||||
INSERT INTO Statistique (idStatistique, poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
|
-- Insertion de données dans la table Statistique
|
||||||
(1, 70, 80, 150, 500, '2023-03-10', 1);
|
INSERT INTO Statistique (poids, fcMoyenne, fcMax, caloriesBruleesMoy, date, athleteId) VALUES
|
||||||
|
(70, 80, 150, 500, '2023-03-10', 1);
|
||||||
|
|
||||||
INSERT INTO Entrainement (idEntrainement, date, description, latitude, longitude, feedback, athleteId) VALUES
|
-- Insertion de données dans la table Entrainement
|
||||||
(1, '2023-03-12', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1);
|
INSERT INTO Entrainement (date, description, latitude, longitude, feedback, coachId) VALUES
|
||||||
|
('2023-03-12', 'Long run in the park', 40.7128, -74.0060, 'Good effort', 1);
|
||||||
|
|
||||||
|
-- Insertion de données dans la table Participe
|
||||||
INSERT INTO Participe (athleteId, entrainementId) VALUES
|
INSERT INTO Participe (athleteId, entrainementId) VALUES
|
||||||
(1, 1);
|
(1, 1);
|
||||||
|
|
||||||
INSERT INTO SourceDonnee (idSource, type, modele, precision2, athleteId) VALUES
|
-- Insertion de données dans la table SourceDonnee
|
||||||
(1, 'Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
|
INSERT INTO SourceDonnee (type, modele, precision, athleteId) VALUES
|
||||||
|
('Heart Rate Monitor', 'HRM-Pro', 98.5, 1);
|
||||||
|
|
||||||
INSERT INTO Activite (idActivite, type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
|
-- Insertion de données dans la table Activite
|
||||||
(1, 'Running', '2023-03-10', '08:00:00', '09:00:00', 7, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
|
INSERT INTO Activite (type, date, heureDeDebut, heureDeFin, effortRessent, variabilite, variance, ecartType, moyenne, maximum, minimum, temperatureMoyenne, athleteId, sourceId) VALUES
|
||||||
|
('Running', '2023-03-10', '08:00:00', '09:00:00', 7, 0.5, 1, 0.1, 140, 160, 120, 20, 1, 1);
|
||||||
|
|
||||||
INSERT INTO FrequenceCardiaque (idFc, altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES
|
-- Insertion de données dans la table FrequenceCardiaque
|
||||||
(1, 100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);
|
INSERT INTO FrequenceCardiaque (altitude, temps, temperature, bpm, longitude, latitude, activiteId) VALUES
|
||||||
|
(100, '08:15:00', 15, 130, -74.0060, 40.7128, 1);
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Repository;
|
namespace Repository;
|
||||||
use Model\User;
|
|
||||||
|
|
||||||
interface IUserRepository extends IGenericRepository {
|
interface IUserRepository extends IGenericRepository {
|
||||||
public function addFriend(User $user1,user $user2);
|
public function addFriend(int $user1,int $user2);
|
||||||
public function deleteFriend(User $user1,User $user2);
|
public function deleteFriend(int $user1,int $user2);
|
||||||
|
|
||||||
public function getItemByEmail(string $email);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,215 +0,0 @@
|
|||||||
<?php
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
|
|
||||||
//use Database\{Connexion, AthleteGateway,AthleteEntity};
|
|
||||||
use Database\AthleteEntity;
|
|
||||||
use Database\AthleteGateway;
|
|
||||||
use Database\Connexion;
|
|
||||||
use Database\AthleteMapper;
|
|
||||||
use Database\CoachGateway;
|
|
||||||
use Database\CoachEntity;
|
|
||||||
use Database\CoachMapper;
|
|
||||||
|
|
||||||
class GatewayTest extends TestCase {
|
|
||||||
|
|
||||||
//Partie concernant les Athlètes
|
|
||||||
|
|
||||||
public function testGetAthlete() {
|
|
||||||
|
|
||||||
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
|
||||||
|
|
||||||
require "loginDatabase.php";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
$result = $athleteGateway->getAthlete();
|
|
||||||
//var_dump($result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fonctionne mais en commentaire pour pas add et del a chaque fois
|
|
||||||
public function testAddAthlete(){
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
|
|
||||||
$dateSpecifique = "2023-11-26";
|
|
||||||
$timestamp = strtotime($dateSpecifique);
|
|
||||||
$dateSQL = date("Y-m-d", $timestamp);
|
|
||||||
|
|
||||||
$athleteEntity = new AthleteEntity();
|
|
||||||
$athleteEntity->setNom('John');
|
|
||||||
$athleteEntity->setPrenom('Doe');
|
|
||||||
$athleteEntity->setIdAthlete(1234);
|
|
||||||
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
||||||
$athleteEntity->setSexe('H');
|
|
||||||
$athleteEntity->setTaille(169);
|
|
||||||
$athleteEntity->setPoids(69);
|
|
||||||
$athleteEntity->setMotDePasse('motdepasse');
|
|
||||||
$athleteEntity->setDateNaissance($dateSQL);
|
|
||||||
|
|
||||||
$result2 = $athleteGateway->addAthlete($athleteEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function testDeleteAthlete(){
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
|
||||||
var_dump($result);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public function testUpdateAthlete(){
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
|
|
||||||
$dateSpecifique = "2004-08-26";
|
|
||||||
$timestamp = strtotime($dateSpecifique);
|
|
||||||
$dateSQL = date("Y-m-d", $timestamp);
|
|
||||||
|
|
||||||
$athleteEntity = new AthleteEntity();
|
|
||||||
$athleteEntity->setNom('John');
|
|
||||||
$athleteEntity->setPrenom('Doe');
|
|
||||||
$athleteEntity->setIdAthlete(13);
|
|
||||||
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
||||||
$athleteEntity->setSexe('H');
|
|
||||||
$athleteEntity->setTaille(169);
|
|
||||||
$athleteEntity->setPoids(69);
|
|
||||||
$athleteEntity->setMotDePasse('motdepasse');
|
|
||||||
$athleteEntity->setDateNaissance($dateSQL);
|
|
||||||
$athleteEntity->setIsCoach(FALSE);
|
|
||||||
$athleteEntity->setCoachId(NULL);
|
|
||||||
|
|
||||||
$athleteEntity2 = new AthleteEntity();
|
|
||||||
$athleteEntity2->setNom('Monteiro');
|
|
||||||
$athleteEntity2->setPrenom('Kevin');
|
|
||||||
$athleteEntity2->setIdAthlete(13);
|
|
||||||
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
|
||||||
$athleteEntity2->setSexe('H');
|
|
||||||
$athleteEntity2->setTaille(169);
|
|
||||||
$athleteEntity2->setPoids(69);
|
|
||||||
$athleteEntity2->setMotDePasse('motdepasse');
|
|
||||||
$athleteEntity2->setDateNaissance($dateSQL);
|
|
||||||
$athleteEntity2->setIsCoach(TRUE);
|
|
||||||
$athleteEntity2->setCoachId(1);
|
|
||||||
|
|
||||||
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Partie concernant les Coachs
|
|
||||||
|
|
||||||
public function testGetCoach() {
|
|
||||||
|
|
||||||
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
|
||||||
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
|
|
||||||
$coachGateway = new CoachGateway($connexion);
|
|
||||||
$result = $coachGateway->getCoach();
|
|
||||||
var_dump($result);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
//Fonctionne PAS A PARTIR DE LA
|
|
||||||
public function testAddCoach(){
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
|
|
||||||
$coachGateway = new CoachGateway($connexion);
|
|
||||||
|
|
||||||
$dateSpecifique = "2023-11-26";
|
|
||||||
$timestamp = strtotime($dateSpecifique);
|
|
||||||
$dateSQL = date("Y-m-d", $timestamp);
|
|
||||||
|
|
||||||
$coachEntity = new CoachEntity();
|
|
||||||
$coachEntity->setNom('John');
|
|
||||||
$coachEntity->setPrenom('Doe');
|
|
||||||
$coachEntity->setIdCoach(1234);
|
|
||||||
$coachEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
||||||
$coachEntity->setSexe('H');
|
|
||||||
$coachEntity->setTaille(169);
|
|
||||||
$coachEntity->setPoids(69);
|
|
||||||
$coachEntity->setMotDePasse('motdepasse');
|
|
||||||
$coachEntity->setDateNaissance($dateSQL);
|
|
||||||
|
|
||||||
$result2 = $coachGateway->addCoach($coachEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function testDeleteAthlete(){
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
$result = $athleteGateway->deleteAthlete( //idAthlete );
|
|
||||||
var_dump($result);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
/*
|
|
||||||
public function testUpdateAthlete(){
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
|
|
||||||
$dateSpecifique = "2004-08-26";
|
|
||||||
$timestamp = strtotime($dateSpecifique);
|
|
||||||
$dateSQL = date("Y-m-d", $timestamp);
|
|
||||||
|
|
||||||
$athleteEntity = new AthleteEntity();
|
|
||||||
$athleteEntity->setNom('John');
|
|
||||||
$athleteEntity->setPrenom('Doe');
|
|
||||||
$athleteEntity->setIdAthlete(13);
|
|
||||||
$athleteEntity->setEmail('kevin.monteiro@gmail.fr');
|
|
||||||
$athleteEntity->setSexe('H');
|
|
||||||
$athleteEntity->setTaille(169);
|
|
||||||
$athleteEntity->setPoids(69);
|
|
||||||
$athleteEntity->setMotDePasse('motdepasse');
|
|
||||||
$athleteEntity->setDateNaissance($dateSQL);
|
|
||||||
|
|
||||||
$athleteEntity2 = new AthleteEntity();
|
|
||||||
$athleteEntity2->setNom('Monteiro');
|
|
||||||
$athleteEntity2->setPrenom('Kevin');
|
|
||||||
$athleteEntity2->setIdAthlete(13);
|
|
||||||
$athleteEntity2->setEmail('kevin.monteiro@gmail.fr');
|
|
||||||
$athleteEntity2->setSexe('H');
|
|
||||||
$athleteEntity2->setTaille(169);
|
|
||||||
$athleteEntity2->setPoids(69);
|
|
||||||
$athleteEntity2->setMotDePasse('motdepasse');
|
|
||||||
$athleteEntity2->setDateNaissance($dateSQL);
|
|
||||||
|
|
||||||
$result = $athleteGateway->updateAthlete($athleteEntity, $athleteEntity2);
|
|
||||||
}*/
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
|
|
||||||
use Model\User;
|
|
||||||
use Database\AthleteEntity;
|
|
||||||
use Database\AthleteGateway;
|
|
||||||
use Database\Connexion;
|
|
||||||
use Database\AthleteMapper;
|
|
||||||
|
|
||||||
class MapperTest extends TestCase {
|
|
||||||
|
|
||||||
public function testMapperAthlete() {
|
|
||||||
|
|
||||||
//$dsn = "pgsql:host=londres;port=8888;dbname=dbkemonteiro2;user=kemonteiro2;password=Mdp";
|
|
||||||
|
|
||||||
$dsn = "mysql:host=londres;dbname=dbkemonteiro2;";
|
|
||||||
$username = "kemonteiro2";
|
|
||||||
$password = "#Phpmyadmin63";
|
|
||||||
|
|
||||||
$connexion = new Connexion($dsn,$username,$password);
|
|
||||||
|
|
||||||
|
|
||||||
$athleteGateway = new AthleteGateway($connexion);
|
|
||||||
$result = $athleteGateway->getAthlete();
|
|
||||||
|
|
||||||
$map = new AthleteMapper ();
|
|
||||||
//SQL To AthleteEntity
|
|
||||||
$athleteEntity = $map->athleteSqlToEntity($result);
|
|
||||||
|
|
||||||
|
|
||||||
foreach($athleteEntity as $ath){
|
|
||||||
|
|
||||||
$result = $ath->getNom();
|
|
||||||
var_dump($result);
|
|
||||||
//Pour chaque AthleteEntity : Athlete Entity To User avec Role Athlete(Model)
|
|
||||||
$user = $map->athleteEntityToModel($ath);
|
|
||||||
var_dump($user->getId());
|
|
||||||
//Pour chaque Athlete du Model -> Athlete Entity
|
|
||||||
$res = $map->athleteToEntity($user);
|
|
||||||
var_dump($res->getIdAthlete());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$dsn = "psql:host=localhost;dbname=sae_3;";
|
|
||||||
$username = "Perederii";
|
|
||||||
$password = "";
|
|
||||||
|
|
||||||
?>
|
|