Commit f2db5c57 authored by Arnaud Bey's avatar Arnaud Bey

add img upload & inthepipeline property

parent 6a51f9d7
......@@ -26,6 +26,7 @@
!/application/public/export/.gitkeep
/application/public/js
/application/public/upload/*
!/application/public/upload/.gitkeep
/application/npm-debug.log
/application/yarn-error.log
/application/package-lock.json
......
......@@ -13,3 +13,6 @@
#main-container .card.clickable{
cursor: pointer;
}
.custom-file-label { opacity: 0; }
.custom-file-input { opacity: 1; }
......@@ -4,6 +4,7 @@ parameters:
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
upload_directory: '%kernel.project_dir%/public/upload'
doctrine:
dbal:
......
......@@ -32,6 +32,19 @@ class AdminController extends AbstractController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($file = $form['image']->getData()) {
$fullFileName = $file->getClientOriginalName();
$fileName = pathinfo($fullFileName, PATHINFO_FILENAME);
$random = md5(uniqid());
$directory = $this->getUploadDir();
$extension = $file->guessExtension();
$finalFileName = $fileName.'-'.$random.'.'.$extension;
$file->move($directory, $finalFileName);
$square->setImageURL($finalFileName);
}
$square->setLastUpdate(new \Datetime);
$em->persist($square);
$em->flush();
......@@ -45,6 +58,12 @@ class AdminController extends AbstractController
]);
}
private function getUploadDir()
{
return $this->getParameter('upload_directory');
}
/**
* @Route("/remove/{id}", name="remove_square")
*/
......
......@@ -16,13 +16,12 @@ class DefaultController extends AbstractController
public function index(EntityManagerInterface $em)
{
$elan = $em->getRepository(Elan::class)->findAll();
$elan = ($elan)
? $elan[0]
: null;
$elan = ($elan) ? $elan[0] : null;
$squares = $em->getRepository(Square::class)->findBy([], ["position" => "ASC"]);
$squares = $em->getRepository(Square::class)->findBy(["inThePipeline" => false], ["position" => "ASC"]);
$inThePipelines = $em->getRepository(Square::class)->findBy(["inThePipeline" => true], ["position" => "ASC"]);
return $this->render('default/index.html.twig', ["squares" => $squares, 'elan' => $elan]);
return $this->render('default/index.html.twig', ["squares" => $squares, 'elan' => $elan, "inThePipelines" => $inThePipelines]);
}
/**
......
......@@ -91,6 +91,16 @@ class Square
*/
private $position = 2;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $inThePipeline = false;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $imageURL;
public function getId(): ?int
{
......@@ -276,4 +286,28 @@ class Square
return $this;
}
public function getInThePipeline(): ?bool
{
return $this->inThePipeline;
}
public function setInThePipeline(bool $inThePipeline): self
{
$this->inThePipeline = $inThePipeline;
return $this;
}
public function getImageURL(): ?string
{
return $this->imageURL;
}
public function setImageURL(?string $imageURL): self
{
$this->imageURL = $imageURL;
return $this;
}
}
......@@ -3,14 +3,16 @@
namespace App\Form;
use App\Entity\Square;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\ColorType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class SquareType extends AbstractType
{
......@@ -25,7 +27,19 @@ class SquareType extends AbstractType
'label' => 'Sous-titre',
'required' => false,
])
->add('image', FileType::class, [
'label' => 'Image',
'mapped' => false,
'required' => false,
])
->add('position')
->add('inThePipeline', ChoiceType::class, [
'expanded' => true,
'multiple' => false,
'label' => 'Dans les tuyaux (sera placé plus bas, sans modale)',
'required' => true,
'choices' => ['Oui' => true, 'Non' => false],
])
->add('twoWords', CKEditorType::class, [
'label' => '2 mots à propos du projet',
'required' => false,
......
{% if elan %}
<div data-toggle="modal" data-target="#square-elan" class="col-6">
<div class="card clickable" style="background:rgba(255, 255, 255, 0.7);">
<div class="card-body" style="color:rgba(0, 0, 0);">
<h1 class="card-title text-center">{{elan.title}}</h1>
<h4 class="card-text text-center">{{elan.subtitle}}</h4>
</div>
<div class="card-footer text-center">
<a target="_blank" href="https://www.univ-grenoble-alpes.fr/">
<img src="{{asset('img/logo_univ_grenoble_alpes.jpg')}}"/>
</a>
<a target="_blank" href="http://www.cnrs.fr">
<img src="{{asset('img/logo_cnrs.jpg')}}"/>
</a>
<a target="_blank" href="http://litt-arts.univ-grenoble-alpes.fr/">
<img src="{{asset('img/logo_littarts.png')}}"/>
</a>
</div>
</div>
</div>
<div id="square-elan" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header" style="background:rgba(255, 255, 255, 0.7);color:rgba(0, 0, 0);">
<h5 class="modal-title">{{elan.title ~ ' - ' ~ elan.subtitle}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-justify">
<div class="row">
<div class="col">
<p class="text-muted text-right">
<small>
Dernière mise à jour : {{elan.lastUpdate|date}}
{% if isAdmin %}<a href="{{path('admin_create_elan', {id: elan.id})}}"><i class="fas fa-edit"></i></a>{% endif %}
</small>
</p>
<p>
{{ elan.content|raw }}
</p>
</div>
<div class="col-3 text-center">
{% if elan.link %}
<a class="btn btn-secondary" target="_blank" href="{{ elan.link }}">Accéder au site</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% else %}
{% if isAdmin %}
<div class="col-3 text-white text-center">
<div class="card">
<div class="card-body" >
<h5 class="card-title">Init. ELAN</h5>
<p class="card-text">
<a href="{{path('admin_create_elan')}}"><i class="fas fa-plus fa-6x"></i></a>
</p>
</div>
</div>
</div>
{% endif %}
{% endif %}
......@@ -3,144 +3,10 @@
{% block title %} {{parent()}} Page d'accueil{% endblock %}
{% block body %}
{% if elan %}
<div data-toggle="modal" data-target="#square-elan" class="col-6">
<div class="card clickable" style="background:rgba(255, 255, 255, 0.7);">
<div class="card-body" style="color:rgba(0, 0, 0);">
<h1 class="card-title text-center">{{elan.title}}</h1>
<h4 class="card-text text-center">{{elan.subtitle}}</h4>
</div>
<div class="card-footer text-center">
<a target="_blank" href="https://www.univ-grenoble-alpes.fr/">
<img src="{{asset('img/logo_univ_grenoble_alpes.jpg')}}"/>
</a>
<a target="_blank" href="http://www.cnrs.fr">
<img src="{{asset('img/logo_cnrs.jpg')}}"/>
</a>
<a target="_blank" href="http://litt-arts.univ-grenoble-alpes.fr/">
<img src="{{asset('img/logo_littarts.png')}}"/>
</a>
</div>
</div>
</div>
<div id="square-elan" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header" style="background:rgba(255, 255, 255, 0.7);color:rgba(0, 0, 0);">
<h5 class="modal-title">{{elan.title ~ ' - ' ~ elan.subtitle}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-justify">
<div class="row">
<div class="col">
<p class="text-muted text-right">
<small>
Dernière mise à jour : {{elan.lastUpdate|date}}
{% if isAdmin %}<a href="{{path('admin_create_elan', {id: elan.id})}}"><i class="fas fa-edit"></i></a>{% endif %}
</small>
</p>
<p>
{{ elan.content|raw }}
</p>
</div>
<div class="col-3 text-center">
{% if elan.link %}
<a class="btn btn-secondary" target="_blank" href="{{ elan.link }}">Accéder au site</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% else %}
{% if isAdmin %}
<div class="col-3 text-white text-center">
<div class="card">
<div class="card-body" >
<h5 class="card-title">Init. ELAN</h5>
<p class="card-text">
<a href="{{path('admin_create_elan')}}"><i class="fas fa-plus fa-6x"></i></a>
</p>
</div>
</div>
</div>
{% endif %}
{% endif %}
{% include 'default/elan.html.twig' %}
{% for square in squares %}
<div data-toggle="modal" data-target="#square-{{ square.id }}" class="col-{{ square.width }}">
<div class="card clickable" style="background:rgba({{ square.color|hex2rgb(0.7) }});">
<div class="card-body" style="color:rgba({{ square.textColor|hex2rgb(1) }});">
<h4 class="card-title text-center">{{ square.title }}</h4>
<p class="card-text text-center">{{ square.subtitle }}</p>
</div>
</div>
</div>
<div id="square-{{ square.id }}" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header" style="background:rgba({{ square.color|hex2rgb(1) }});color:rgba({{ square.textColor|hex2rgb(1) }});">
<h5 class="modal-title">{{ square.title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-justify">
<div class="row">
<div class="col">
<p class="text-muted text-right">
<small>
Dernière mise à jour : {{square.lastUpdate|date}}
{% if isAdmin %}<a href="{{path('admin_create_square', {id:square.id} )}}"><i class="fas fa-edit"></i></a>{% endif %}
</small>
</p>
{% if square.manager %}
<p><strong>Responsable :</strong> {{ square.manager|raw }}</p>
{% endif %}
{% if square.twoWords %}
<strong>Le projet en deux mots :</strong>
<p>{{ square.twoWords|raw }}</p>
{% endif %}
<div class="bg-light rounded p-4">
<strong>ELAN dans ce projet :</strong>
<p>{{ square.elan|raw }}</p>
{% if square.dataType %}
<p><strong>Type de données :</strong> {{ square.dataType }}</p>
{% endif %}
{% if square.startDate %}
<p><strong>Début du projet :</strong> {{ square.startDate }}</p>
{% endif %}
{% if square.endDate %}
<p><strong>Fin du projet :</strong> {{ square.endDate }}</p>
{% endif %}
{% if square.state %}
<p><strong>Etat du projet :</strong> {{ square.state }}</p>
{% endif %}
</div>
</div>
<div class="col-3 text-center">
{% if square.link %}
<a class="btn btn-secondary" target="_blank" href="{{ square.link }}">Accéder au site</a>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% include 'default/square.html.twig' %}
{% endfor %}
{% if isAdmin %}
......@@ -155,4 +21,15 @@
</div>
</div>
{% endif %}
</div>
<div class="row">
<div class="col-12">
<h3>Dans les tuyaux</h3>
</div>
{% for inThePipeline in inThePipelines %}
{% include 'default/square.html.twig' %}
{% endfor %}
{% endblock %}
<div data-toggle="modal" data-target="#square-{{ square.id }}" class="col-{{ square.width }}">
<div class="card clickable" style="background:rgba({{ square.color|hex2rgb(0.7) }});">
<div class="card-body" style="color:rgba({{ square.textColor|hex2rgb(1) }});">
<h4 class="card-title text-center">{{ square.title }}</h4>
<p class="card-text text-center">{{ square.subtitle }}</p>
</div>
</div>
</div>
{% if not square.inThePipeline %}
<div id="square-{{ square.id }}" class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header" style="background:rgba({{ square.color|hex2rgb(1) }});color:rgba({{ square.textColor|hex2rgb(1) }});">
<h5 class="modal-title">{{ square.title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body text-justify">
<div class="row">
<div class="col">
<p class="text-muted text-right">
<small>
Dernière mise à jour : {{square.lastUpdate|date}}
{% if isAdmin %}<a href="{{path('admin_create_square', {id:square.id} )}}"><i class="fas fa-edit"></i></a>{% endif %}
</small>
</p>
{% if square.manager %}
<p><strong>Responsable :</strong> {{ square.manager|raw }}</p>
{% endif %}
{% if square.twoWords %}
<strong>Le projet en deux mots :</strong>
<p>{{ square.twoWords|raw }}</p>
{% endif %}
<div class="bg-light rounded p-4">
<strong>ELAN dans ce projet :</strong>
<p>{{ square.elan|raw }}</p>
{% if square.dataType %}
<p><strong>Type de données :</strong> {{ square.dataType }}</p>
{% endif %}
{% if square.startDate %}
<p><strong>Début du projet :</strong> {{ square.startDate }}</p>
{% endif %}
{% if square.endDate %}
<p><strong>Fin du projet :</strong> {{ square.endDate }}</p>
{% endif %}
{% if square.state %}
<p><strong>Etat du projet :</strong> {{ square.state }}</p>
{% endif %}
</div>
</div>
<div class="col-3 text-center">
{% if square.link %}
<a style="display:block;width:100%" class="btn btn-secondary mb-2" target="_blank" href="{{ square.link }}">Accéder au site</a>
{% endif %}
{% if square.imageURL %}
<img width="100%" src="{{asset('upload/'~square.imageURL)}}"/>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment