Login fixes

main
František Špaček 2 years ago
parent 5350952bd3
commit b02b80c612

@ -12,3 +12,5 @@ fos_rest:
rules: rules:
- { path: ^/api, prefer_extension: false, fallback_format: json, priorities: [ json, xml ] } - { path: ^/api, prefer_extension: false, fallback_format: json, priorities: [ json, xml ] }
- { path: ^/, prefer_extension: true, fallback_format: html, priorities: [ html, '*/*'] } - { path: ^/, prefer_extension: true, fallback_format: html, priorities: [ html, '*/*'] }
zone:
- { path: ^/api/* }

@ -28,6 +28,8 @@ security:
form_login: form_login:
login_path: users_login login_path: users_login
check_path: users_login check_path: users_login
logout:
path: users_logout
# Easy way to control access for large sections of your site # Easy way to control access for large sections of your site
# Note: Only the *first* access control that matches will be used # Note: Only the *first* access control that matches will be used

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

@ -1,27 +1,44 @@
/* Styles for the main content area */ /* Styles for the main content area */
main { main form {
display: block; display: flex;
flex-direction: column;
width: 100%;
align-items: stretch;
} }
/* Styles for the main container div */ /* Styles for the main container div */
#mainDiv { #mainDiv {
width: 100%; flex-basis: 60%;
width: auto;
display: flex; display: flex;
padding: 10px; align-items: stretch;
margin: 1rem;
} }
/* Styles for the chart container div */ /* Styles for the chart container div */
#chartDiv { #chartDiv {
flex-basis: 75%; flex-basis: 75%;
height: 400px;
} }
/* Styles for the settings container div */ /* Styles for the settings container div */
#settings_div { #settings_div {
text-align: center; text-align: center;
overflow: scroll;
flex-basis: 25%; flex-basis: 25%;
} }
#settings_div h1{
margin: 0.5rem;
}
#settings_div label{
margin-right: 0.3rem;
}
#chart_metadata > div{
margin: 0.3rem
}
/* Styles for submenu label */ /* Styles for submenu label */
.submenuLabel+div { .submenuLabel+div {
display: none; display: none;
@ -41,7 +58,7 @@ div[id^="chart_metadata_group"] {
.submenuLabel::after { .submenuLabel::after {
content: " "; content: " ";
border: solid black; border: solid black;
border-width: 0 2px 2px 0; border-width: 0 0.2rem 0.2rem 0;
display: inline-block; display: inline-block;
padding: 0.2rem; padding: 0.2rem;
margin-left: 0.5rem; margin-left: 0.5rem;
@ -70,8 +87,10 @@ div[id^="chart_metadata_group"] {
/* Styles for secondary div */ /* Styles for secondary div */
#secondaryDiv { #secondaryDiv {
flex-basis: 40%;
width: auto;
display: flex; display: flex;
/* Use flexbox layout */ margin: 1rem;
} }
/* Styles for table elements */ /* Styles for table elements */
@ -129,22 +148,22 @@ div[id^="chart_metadata_group"] {
position: absolute; position: absolute;
background-color: white; background-color: white;
border: 1px solid lightgrey; border: 1px solid lightgrey;
box-shadow: 2px 2px 2px gray; box-shadow: 0.2rem 0.2rem 0.2rem gray;
display: none; display: none;
margin: 0; margin: 0;
width: 180px; width: 10rem;
} }
#rcMenu ul { #rcMenu ul {
list-style-type: none; list-style-type: none;
padding-left: 10px; padding-left: 10px;
width: 180px; width: 10rem;
} }
#rcMenu a { #rcMenu a {
text-decoration: none; text-decoration: none;
border-bottom: 1px solid lightgrey; border-bottom: 1px solid lightgrey;
width: 160px; width: 9rem;
display: block; display: block;
} }

@ -17,7 +17,7 @@ body {
padding: 0; padding: 0;
} }
button { button, #createChart {
background-color: var(--main-dark); background-color: var(--main-dark);
border: none; border: none;
color: white; color: white;
@ -52,6 +52,10 @@ header nav {
justify-content: flex-end; justify-content: flex-end;
} }
header #homepageLink:hover, header #chartsLink:hover {
background-color: var(--main-highlight);
}
header #user { header #user {
flex-basis: 10%; flex-basis: 10%;
display: flex; display: flex;
@ -108,11 +112,23 @@ h2 {
.loginDiv { .loginDiv {
min-width: 300px; min-width: 300px;
width: 60%; width: 60%;
margin: 50px auto; margin: 2rem auto;
padding: 2rem;
text-align: center; text-align: center;
background-color: var(--main); background-color: var(--main);
} }
.loginDiv form {
display: flex;
flex-direction: column;
}
.loginDiv #user div, .loginDiv form > div {
width: auto;
display: flex;
flex-direction: column;
}
.loginDiv .msg { .loginDiv .msg {
color: red; color: red;
} }
@ -121,60 +137,66 @@ h2 {
color: red; color: red;
} }
#myGraphs { #myCharts {
width: 50%; height: 100%;
height: calc(100vh - 4.2em); width: 100%;
margin: 0; margin: 0.5rem;
text-align: center; text-align: center;
background-color: var(--main); background-color: var(--main);
display: inline-block; display: block;
} }
#myGraphs #createGraphBtn { #myCharts #createChart {
color: limegreen; color: var(--dark);
background-color: green;
padding: 1rem;
transition: 300ms;
} }
#myGraphList div, #sharedGraphList div{ #myCharts #createChart:hover {
background-color: darkgreen;
}
#myChartList {
display: flex;
flex-direction: column;
}
#myChartList span{
width: 80%; width: 80%;
margin: 10px 10%; margin: 10px 10%;
border: 1px solid var(--main-dark); /*border: 1px solid var(--main-dark);*/
padding: 5px; background-color: var(--main-dark);
text-align: left; display: flex;
} }
#myGraphList div a, #sharedGraphList div a{ #myChartList span a{
text-decoration: none; text-decoration: none;
display: inline-block; display: inline-block;
height: 100%; height: 100%;
width: 75%; padding: 2rem;
padding: 5px;
} }
#myGraphList div button{ #myChartList #editChart {
color: red; flex-basis: 90%;
display: inline-block; text-align: left;
float: right; transition: 300ms;
margin: 0;
padding: 5px;
} }
#myGraphList div button:hover{ #myChartList #editChart:hover {
background-color: var(--side); background-color: var(--main-highlight);
color: red;
display: flex;
transition: 300ms;
} }
#sharedGraphs { #myChartList #removeChart{
width: 50%; color: red;
height: calc(100vh - 4.2em);
margin: 0;
text-align: center;
background-color: var(--side);
display: inline-block; display: inline-block;
text-align: middle;
flex-basis: 10%;
transition: 300ms;
} }
#sharedGraphs h1{ #myChartList #removeChart:hover{
color: var(--dark); background-color: var(--main-highlight);
padding-bottom: 52px; color: red;
transition: 300ms;
} }

@ -38,7 +38,6 @@ class ChartRestController extends AbstractRestController
$data = json_decode($request->getContent()); $data = json_decode($request->getContent());
$chart = new Chart(); $chart = new Chart();
$chart->setName($data->name); $chart->setName($data->name);
$chart->setCode($data->code);
$chart->setMetadata($data->metadata); $chart->setMetadata($data->metadata);
$chart->setTable($data->table); $chart->setTable($data->table);

@ -13,9 +13,6 @@ class ChartInput
#[Assert\NotBlank()] #[Assert\NotBlank()]
public string $name, public string $name,
#[Assert\Type('string')]
#[Assert\NotBlank()]
public string $code,
public array $metadata, public array $metadata,
public array $table, public array $table,
) { ) {
@ -24,10 +21,7 @@ class ChartInput
public function toEntity(): Chart public function toEntity(): Chart
{ {
$chart = new Chart(); $chart = new Chart();
//$chart->setId();
$chart->setName($this->name); $chart->setName($this->name);
//$chart->setName("name");
$chart->setCode($this->code);
$chart->setMetadata($this->metadata); $chart->setMetadata($this->metadata);
$chart->setTable($this->table); $chart->setTable($this->table);

@ -9,7 +9,6 @@ class ChartOutput
public function __construct( public function __construct(
public ?string $id, public ?string $id,
public ?string $name, public ?string $name,
public ?string $code,
public ?array $metadata, public ?array $metadata,
public ?array $table, public ?array $table,
) { ) {
@ -20,7 +19,6 @@ class ChartOutput
return new self( return new self(
$entity->getId(), $entity->getId(),
$entity->getName(), $entity->getName(),
$entity->getCode(),
$entity->getMetadata(), $entity->getMetadata(),
$entity->getTable(), $entity->getTable(),
); );

@ -11,19 +11,20 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Redirect; use Symfony\Component\HttpFoundation\Redirect;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route(path: '/charts', name: 'charts')] #[Route(path: '/charts', name: 'charts_')]
class ChartController extends AbstractController class ChartController extends AbstractController
{ {
#[Route('/', name: '_list')] #[Route('/', name: 'list')]
public function list(DocumentManager $dm, Request $request) : Response public function list(DocumentManager $dm, Request $request) : Response
{ {
$charts = $dm->getRepository(Chart::class)->findAll(); //$charts = $dm->getRepository(Chart::class)->findAll();
return $this->render('list.html.twig', [ $charts = $this->getUser()->getCharts();
return $this->render('chart/list.html.twig', [
'charts' => $charts 'charts' => $charts
]); ]);
} }
#[Route('/{id}/edit', name: '_edit')] #[Route('/{id}/edit', name: 'edit')]
public function editAction(DocumentManager $dm, Request $request, Chart $chart) : Response public function editAction(DocumentManager $dm, Request $request, Chart $chart) : Response
{ {
$form = $this->createForm(ChartType::class, $chart); $form = $this->createForm(ChartType::class, $chart);
@ -34,32 +35,39 @@ class ChartController extends AbstractController
$dm->persist($chart); $dm->persist($chart);
$dm->flush(); $dm->flush();
//return $this->redirect('/');
} }
return $this->render('edit.html.twig', [ return $this->render('chart/edit.html.twig', [
'chartForm' => $form, 'chartForm' => $form,
'id' => $chart->getId(), 'id' => $chart->getId(),
]); ]);
} }
#[Route('/{id}', name: '_display')] #[Route('/create', name: 'create')]
public function createAction(DocumentManager $dm) : Response
{
$chart = new Chart();
$dm->persist($chart);
$this->getUser()->addChart($chart);
$dm->flush();
return $this->redirectToRoute('charts_edit', ['id' => $chart->getId()]);
}
#[Route('/{id}', name: 'display')]
public function displayAction(DocumentManager $dm, Chart $chart) : Response public function displayAction(DocumentManager $dm, Chart $chart) : Response
{ {
return $this->render('chart.html.twig', [ return $this->render('chart/display.html.twig', [
'id' => $chart->getId() 'id' => $chart->getId()
]); ]);
} }
/*private function findOrFail(DocumentManager $dm, int $id): Chart #[Route('/{id}/remove', name: 'remove')]
public function removeAction(DocumentManager $dm, Chart $chart) : Response
{ {
$chart = $dm->getRepository(Chart::class)->findOneBy(['code' => $id]); $dm->remove($chart);
//$chart = $dm->getRepository(Chart::class)->findAll(); //$this->getUser()->removeChart($chart);
if ($chart === null) { $dm->flush();
throw $this->createNotFoundException(); return $this->redirectToRoute('charts_list');
} }
return $chart;
}*/
} }

@ -7,24 +7,22 @@ use App\Form\Type\UserType;
use App\Form\Type\LoginType; use App\Form\Type\LoginType;
use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ODM\MongoDB\DocumentManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils; use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface; use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Redirect; use Symfony\Component\HttpFoundation\Redirect;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Routing\Annotation\Route;
#[Route(path: '/users', name: 'users_')] #[Route(path: '/users', name: 'users_')]
class UserController extends AbstractController class UserController extends AbstractController
{ {
#[Route('/create', name: 'create')]
#[Route('/create', name: 'create', defaults: ['id' => null])] public function createAction(DocumentManager $dm, Request $request, UserPasswordHasherInterface $passwordHasher, Security $security)
#[Route('/{id}/edit', name: 'edit')]
public function editAction(DocumentManager $dm, Request $request, UserPasswordHasherInterface $passwordHasher, ?string $id)
{ {
$user = $dm->getRepository(User::class)->find($id); $user = new User();
if ($user == null)
$user == new User();
$form = $this->createForm(UserType::class, $user); $form = $this->createForm(UserType::class, $user);
$form->handleRequest($request); $form->handleRequest($request);
@ -38,10 +36,12 @@ class UserController extends AbstractController
$dm->persist($user); $dm->persist($user);
$dm->flush(); $dm->flush();
$security->login($user);
return $this->redirect('/'); return $this->redirect('/');
} }
return $this->render('register.html.twig', [ return $this->render('user/register.html.twig', [
'form' => $form->createView() 'form' => $form->createView()
]); ]);
} }
@ -49,23 +49,38 @@ class UserController extends AbstractController
#[Route('/login', name: 'login')] #[Route('/login', name: 'login')]
public function login(AuthenticationUtils $authenticationUtils): Response public function login(AuthenticationUtils $authenticationUtils): Response
{ {
return $this->render('login.html.twig', [ return $this->render('user/login.html.twig', [
'last_email' => $authenticationUtils->getLastUsername(), 'last_email' => $authenticationUtils->getLastUsername(),
'error' => $authenticationUtils->getLastAuthenticationError(), 'error' => $authenticationUtils->getLastAuthenticationError(),
]); ]);
} }
#[Route('/logout', name: 'logout')]
public function logout(Security $security): Response
{
$response = $security->logout();
return $response;
}
/*#[Route('/{id}', name: 'detail', requirements: ['id' => '\d+'])] #[Route('/{id}/edit', name: 'edit')]
public function detail(DocumentManager $dm, Request $request, User $user): Response public function editAction(DocumentManager $dm, Request $request, UserPasswordHasherInterface $passwordHasher, User $user)
{ {
if ($user === null) $form = $this->createForm(UserType::class, $user);
throw $this->createNotFoundException('Uživatel nenalezen!');
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$user = $form->getData();
$hashedPassword = $passwordHasher->hashPassword($user, $user->getPassword());
$user->setPassword($hashedPassword);
//$this->denyAccessUnlessGranted(UserVoter::VIEW, $user); $dm->persist($user);
$dm->flush();
}
return $this->render('users/detail.html.twig', [ return $this->render('user/edit.html.twig', [
'user' => $user, 'form' => $form->createView()
]); ]);
}*/ }
} }

@ -8,33 +8,52 @@ use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
#[MongoDB\Document(collection: 'charts')] #[MongoDB\Document(collection: 'charts')]
#[MongoDB\Unique(fields: 'code')]
class Chart class Chart
{ {
/** /**
* @MongoDB\Id * @MongoDB\Id
*/ */
#[MongoDB\Id] #[MongoDB\Id]
protected string $id; protected ?string $id = null;
//#[MongoDB\ReferenceOne(targetDocument: User::class, inversedBy: "charts")] #[MongoDB\ReferenceOne(targetDocument: User::class, inversedBy: "charts")]
//protected $user; protected $user;
#[MongoDB\Field(type: 'string')] #[MongoDB\Field(type: 'string', options: ['default' => "Graf"])]
#[Assert\NotBlank] #[Assert\NotBlank]
protected ?string $name = null; protected string $name = "Graf";
#[MongoDB\Field(type: 'string')]
#[Assert\NotBlank]
protected ?string $code = null;
#[MongoDB\Field(type: 'raw')] #[MongoDB\Field(type: 'raw')]
#[Assert\NotBlank] #[Assert\NotBlank]
protected $metadata = null; protected $metadata = [
"type" => "line",
"margin" => 40,
"xLabel" => "x",
"yLabel" => "y",
"displayLegend" => true,
"displayPoints" => true,
"displaySupport" => true,
"backgroundColor" => "#f6f5f4",
"title" => "Nadpis",
"displayTitle" => true,
"yStep" => 1,
"displaySupportLines" => true,
"displayAxisValues" => true,
"pointSize" => 15,
"titleFont" => ["font" => 'Courier New', "size" => 25],
"labelFont" => ["font" => 'Georgia', "size" => 15],
"legendFont" => ["font" => 'Arial', "size" => 10],
"pointBorderSize" => 2,
"pointBorderColor" => "#241f31",
"horizontalZoom" => true
];
#[MongoDB\Field(type: 'hash')] #[MongoDB\Field(type: 'hash')]
//#[Assert\NotBlank] #[Assert\NotBlank]
protected ?array $table = null; protected array $table = [
['col_name' => 'sloupec 1','values' => [1,6,3, 2],'color' => '#ff0000'],
['col_name' => 'sloupec 2','values' => [4,2.5,-1, 1],'color' => '#57e389']
];
public function getId(): string public function getId(): string
{ {
@ -46,20 +65,20 @@ class Chart
* *
* @return User * @return User
*/ */
//public function getUser(): ?User public function getUser(): ?User
//{ {
/// return $this->user; return $this->user;
//} }
/** /**
* Set the user associated with the chart. * Set the user associated with the chart.
* *
* @param User $user The user to set * @param User $user The user to set
*/ */
//public function setUser(?User $user): void public function setUser(?User $user): void
//{ {
// $this->user = $user; $this->user = $user;
//} }
public function getName(): ?string public function getName(): ?string
{ {
@ -71,16 +90,6 @@ class Chart
$this->name = $name; $this->name = $name;
} }
public function getCode(): ?string
{
return $this->code;
}
public function setCode(?string $code): void
{
$this->code = $code;
}
public function getMetadata() public function getMetadata()
{ {
return $this->metadata; return $this->metadata;
@ -93,11 +102,6 @@ class Chart
public function getTable(): ?array public function getTable(): ?array
{ {
/*$decoded = [];
foreach ($this->table as $key => $value) {
$decoded += json_decode($value);
}
return $decoded;*/
return $this->table; return $this->table;
} }

@ -32,8 +32,8 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
#[MongoDB\Field(type: 'collection')] #[MongoDB\Field(type: 'collection')]
private array $roles = ['ROLE_USER']; private array $roles = ['ROLE_USER'];
//#[MongoDB\ReferenceMany(targetDocument: Chart::class, mappedBy: "user")] #[MongoDB\ReferenceMany(targetDocument: Chart::class, mappedBy: "user")]
//protected $charts; protected $charts;
public function getId(): string public function getId(): string
{ {
@ -66,26 +66,26 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface
/** /**
* @return Collection<int, Chart> * @return Collection<int, Chart>
*/ */
//public function getCharts(): Collection public function getCharts(): Collection
//{ {
// return $this->charts; return $this->charts;
//} }
/** /**
* Adds a chart to the user. * Adds a chart to the user.
* *
* @param Chart $chart The chart to add * @param Chart $chart The chart to add
*/ */
//public function addChart(Chart $chart): void public function addChart(Chart $chart): void
//{ {
// Check if the chart already exists in the collection // Check if the chart already exists in the collection
// if (!$this->charts->contains($chart)) { if (!$this->charts->contains($chart)) {
// Add the chart to the collection // Add the chart to the collection
// $this->charts->add($chart); $this->charts->add($chart);
// Set the user reference in the chart entity // Set the user reference in the chart entity
// $chart->setUser($this); $chart->setUser($this);
// } }
//} }
public function getRoles(): array public function getRoles(): array
{ {

@ -15,11 +15,14 @@ class ChartType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
->add('name', TextType::class) ->add('name', TextType::class, [
->add('code', TextType::class) 'label' => 'Jméno grafu'
->add('metadata', MetadataType::class); ])
->add('metadata', MetadataType::class, [
'label' => false
]);
if (sizeof($options['data']->getTable()[0]['values']) <= 1000) if (array_key_exists('data', $options) && sizeof($options['data']->getTable()[0]['values']) <= 1000)
$builder $builder
->add('table', CollectionType::class, [ ->add('table', CollectionType::class, [
'entry_type' => ColumnType::class, 'entry_type' => ColumnType::class,

@ -17,6 +17,7 @@ class FontType extends AbstractType
$builder $builder
->add('font', ChoiceType::class, [ ->add('font', ChoiceType::class, [
'label' => 'Font',
'choices' => [ 'choices' => [
'Arial' => 'Arial', 'Arial' => 'Arial',
'Verdana' => 'Verdana', 'Verdana' => 'Verdana',

@ -16,8 +16,10 @@ class LoginType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
->add('email', EmailType::class) ->add('email', EmailType::class, [
->add('password', PasswordType::class); 'label' => 'Email'])
->add('password', PasswordType::class, [
'label' => 'Heslo']);
} }
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)

@ -26,26 +26,26 @@ class MetadataType extends AbstractType
$builder $builder
->add('type', ChoiceType::class, [ ->add('type', ChoiceType::class, [
'choices' => [ 'choices' => [
'Point' => 'point', 'Bodový' => 'point',
'Line' => 'line', 'Spojnicový' => 'line',
'Smooth line' => 'smoothline', 'Hladký spojnicový' => 'smoothline',
'Area' => 'area', 'Plošný' => 'area',
'Smooth Area' => 'smootharea', 'Hladký plošný' => 'smootharea',
'Pie' => 'pie', 'Koláčový' => 'pie',
'Donut' => 'donut', 'Prstencový' => 'donut',
'Bar' => 'bar', 'Sloupcový' => 'bar',
'Stacked' => 'stacked', 'Skládáný sloupcový' => 'stacked',
], ],
'label' => 'Chart type', 'label' => 'Druh grafu',
]) ])
->add( ->add(
$builder->create('group0', FormType::class, [ $builder->create('group0', FormType::class, [
'inherit_data' => true, 'inherit_data' => true,
'label' => 'Margin settings', 'label' => 'Nastavení odsazení',
'label_attr' => ['class' => 'submenuLabel arrow-down'] 'label_attr' => ['class' => 'submenuLabel arrow-down']
]) ])
->add('margin', IntegerType::class, [ ->add('margin', IntegerType::class, [
'label' => 'Margin', 'label' => 'Odsazení',
'required' => false, 'required' => false,
'constraints' => [ 'constraints' => [
new Assert\PositiveOrZero() new Assert\PositiveOrZero()
@ -56,20 +56,20 @@ class MetadataType extends AbstractType
->add( ->add(
$builder->create('group1', FormType::class, [ $builder->create('group1', FormType::class, [
'inherit_data' => true, 'inherit_data' => true,
'label' => 'Title settings', 'label' => 'Nastavení nadpisu',
'label_attr' => ['class' => 'submenuLabel arrow-down'] 'label_attr' => ['class' => 'submenuLabel arrow-down']
]) ])
->add('title', TextType::class, [ ->add('title', TextType::class, [
'label' => 'Title', 'label' => 'Nadpis',
'required' => false, 'required' => false,
'empty_data' => '' 'empty_data' => ''
]) ])
->add('displayTitle', CheckboxType::class, [ ->add('displayTitle', CheckboxType::class, [
'label' => 'Display title', 'label' => 'Zobrazit nadpis',
'required' => false, 'required' => false,
]) ])
->add('titleFont', FontType::class, [ ->add('titleFont', FontType::class, [
'label' => 'Title font', 'label' => false,
'required' => false, 'required' => false,
]) ])
) )
@ -77,34 +77,34 @@ class MetadataType extends AbstractType
->add( ->add(
$builder->create('group2', FormType::class, [ $builder->create('group2', FormType::class, [
'inherit_data' => true, 'inherit_data' => true,
'label' => 'Labels', 'label' => 'Nastavení popisků os',
'label_attr' => ['class' => 'submenuLabel arrow-down'] 'label_attr' => ['class' => 'submenuLabel arrow-down']
]) ])
->add('xLabel', TextType::class, [ ->add('xLabel', TextType::class, [
'label' => 'X label', 'label' => 'Popisek osy X',
'required' => false, 'required' => false,
]) ])
->add('yLabel', TextType::class, [ ->add('yLabel', TextType::class, [
'label' => 'Y label', 'label' => 'Popisek osy Y',
'required' => false, 'required' => false,
]) ])
->add('yStep', NumberType::class, [ ->add('yStep', NumberType::class, [
'label' => 'Y step', 'label' => 'Krokování hodnot na Y',
'required' => false, 'required' => false,
'constraints' => [ 'constraints' => [
new Assert\PositiveOrZero() new Assert\PositiveOrZero()
], ],
]) ])
->add('displayAxisValues', CheckboxType::class, [ ->add('displayAxisValues', CheckboxType::class, [
'label' => 'Display axis values', 'label' => 'Zobrazit hodnoty',
'required' => false, 'required' => false,
]) ])
->add('displaySupportLines', CheckboxType::class, [ ->add('displaySupportLines', CheckboxType::class, [
'label' => 'Display support lines', 'label' => 'Zobrazit pomocné čáry',
'required' => false, 'required' => false,
]) ])
->add('labelFont', FontType::class, [ ->add('labelFont', FontType::class, [
'label' => 'Label font', 'label' => false,
'required' => false, 'required' => false,
]) ])
) )
@ -112,15 +112,15 @@ class MetadataType extends AbstractType
->add( ->add(
$builder->create('group3', FormType::class, [ $builder->create('group3', FormType::class, [
'inherit_data' => true, 'inherit_data' => true,
'label' => 'Legend settings', 'label' => 'Nastavení legendy',
'label_attr' => ['class' => 'submenuLabel arrow-down'] 'label_attr' => ['class' => 'submenuLabel arrow-down']
]) ])
->add('displayLegend', CheckboxType::class, [ ->add('displayLegend', CheckboxType::class, [
'label' => 'Display legend', 'label' => 'Zobrazit legendu',
'required' => false, 'required' => false,
]) ])
->add('legendFont', FontType::class, [ ->add('legendFont', FontType::class, [
'label' => 'Legend font', 'label' => false,
'required' => false, 'required' => false,
]) ])
) )
@ -128,29 +128,29 @@ class MetadataType extends AbstractType
->add( ->add(
$builder->create('group4', FormType::class, [ $builder->create('group4', FormType::class, [
'inherit_data' => true, 'inherit_data' => true,
'label' => 'Point Settings', 'label' => 'Nastavení bodů',
'label_attr' => ['class' => 'submenuLabel arrow-down'] 'label_attr' => ['class' => 'submenuLabel arrow-down']
]) ])
->add('displayPoints', CheckboxType::class, [ ->add('displayPoints', CheckboxType::class, [
'label' => 'Display points', 'label' => 'Zobrazit body',
'required' => false, 'required' => false,
]) ])
->add('pointSize', IntegerType::class, [ ->add('pointSize', IntegerType::class, [
'label' => 'Point size', 'label' => 'Velikost bodů',
'required' => false, 'required' => false,
'constraints' => [ 'constraints' => [
new Assert\PositiveOrZero() new Assert\PositiveOrZero()
], ],
]) ])
->add('pointBorderSize', IntegerType::class, [ ->add('pointBorderSize', IntegerType::class, [
'label' => 'Point border size', 'label' => 'Šířka ohraničení bodů',
'required' => false, 'required' => false,
'constraints' => [ 'constraints' => [
new Assert\PositiveOrZero() new Assert\PositiveOrZero()
], ],
]) ])
->add('pointBorderColor', ColorType::class, [ ->add('pointBorderColor', ColorType::class, [
'label' => 'Point border color', 'label' => 'Barva ohraničení',
'required' => false, 'required' => false,
]) ])
) )
@ -158,22 +158,30 @@ class MetadataType extends AbstractType
->add( ->add(
$builder->create('group5', FormType::class, [ $builder->create('group5', FormType::class, [
'inherit_data' => true, 'inherit_data' => true,
'label' => 'Zoom Settings', 'label' => 'Nastavení přiblížení',
'label_attr' => ['class' => 'submenuLabel arrow-down'] 'label_attr' => ['class' => 'submenuLabel arrow-down']
]) ])
->add('horizontalZoom', CheckboxType::class, [ ->add('horizontalZoom', CheckboxType::class, [
'label' => 'Enable horizontal zoom', 'label' => 'Zapnout horizontální přibližování',
'required' => false, 'required' => false,
]) ])
->add('verticalZoom', CheckboxType::class, [ ->add('verticalZoom', CheckboxType::class, [
'label' => 'Enable vertical zoom', 'label' => 'Zapnout vertikální přibližování',
'required' => false,
])
)
// Background settings
->add(
$builder->create('group5', FormType::class, [
'inherit_data' => true,
'label' => 'Nastavení pozadí',
'label_attr' => ['class' => 'submenuLabel arrow-down']
])
->add('backgroundColor', ColorType::class, [
'label' => 'Barva pozadí',
'required' => false, 'required' => false,
]) ])
) )
->add('backgroundColor', ColorType::class, [
'label' => 'Background color',
'required' => false,
])
->add('submit', SubmitType::class, ['label' => 'Uložit a vykreslit']); ->add('submit', SubmitType::class, ['label' => 'Uložit a vykreslit']);
} }

@ -15,11 +15,14 @@ class UserType extends AbstractType
{ {
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder->add('email', EmailType::class); $builder->add('email', EmailType::class, [
'label' => 'Email']);
$builder->add('password', RepeatedType::class, [ $builder->add('password', RepeatedType::class, [
'first_name' => 'password', 'first_name' => 'password',
'second_name' => 'confirm', 'second_name' => 'confirm',
'type' => PasswordType::class 'type' => PasswordType::class,
'first_options' => ['label' => 'Heslo'],
'second_options' => ['label' => 'Heslo znovu']
]); ]);
} }

@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title> <title>{% block title %}Welcome!{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 128 128%22><text y=%221.2em%22 font-size=%2296%22>⚫️</text></svg>"> <link rel="icon" href="{{ asset('images/icon.png') }}">
{% block stylesheets %} {% block stylesheets %}
{{ encore_entry_link_tags('app') }} {{ encore_entry_link_tags('app') }}
<link href="{{ asset('styles/web_style.css') }}" rel="stylesheet"/> <link href="{{ asset('styles/web_style.css') }}" rel="stylesheet"/>

@ -0,0 +1,131 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Chyba!</title>
<style>:root
{
--dark: #1E1B18;
--light: #E3E7F1;
--side: #E3E7F1;
--main: #7391C8;
--main-dark: #52688F;
--main-highlight: #31476d;
}
* {
font-family: 'Open Sans', sans-serif;
color: var(--dark);
}
body {
margin: 0;
padding: 0;
}
button {
background-color: var(--main-dark);
border: none;
color: white;
padding: 10px 15px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 5px;
}
button:hover {
background-color: var(--main-highlight);
cursor: pointer;
}
header {
display: flex;
background-color: var(--main-dark);
margin: 0;
}
header #logo {
text-align: center;
flex-basis: 20%;
display: flex;
}
header nav {
display: flex;
flex-basis: 70%;
justify-content: flex-end;
}
header #user {
flex-basis: 10%;
display: flex;
}
header #user a {
flex-basis: 100%;
text-align: center;
background-color: var(--main);
color: var(--dark);
}
header #user a:hover {
background-color: var(--main-dark);
}
header a {
text-decoration: none;
color: var(--light);
font-weight: 600;
font-size: 1em;
line-height: 1.4em;
padding: 1.4em 2em;
transition: 300ms;
}
header a:hover {
background-color: var(--main-dark);
}
body {
background-color: var(--light);
}
main {
height: calc(100vh - 4.2em);
width: 100%;
display: flex;
padding: 0;
}
h1 {
color: var(--light);
font-size: 1.6em;
margin: 2em 0 0;
flex-basis: 100%;
}
h2 {
color: var(--side);
font-size: 1.2em;
}
</style>
</head>
<body>
<header id="mainHeader">
<div id="logo">
<a href="/">EasyCharts</a>
</div>
<div id="user">
<a href="/users/login">Přihlásit</a>
</div>
</header>
<h1>Chyba!</h1>
<section>
<p>
Hledanou stránku nebylo možné najít. Zkontrolujte URL nebo se vraťe na
<a href="/">domovskou stránku</a>.
</p>
</section>
</body></html>

@ -34,13 +34,13 @@
{{ form_start(chartForm) }} {{ form_start(chartForm) }}
<div id="mainDiv"> <div id="mainDiv">
<div id="settings_div"> <div id="settings_div">
<h1>Nastavení grafu</h1>
{{ form_row(chartForm.name) }} {{ form_row(chartForm.name) }}
{{ form_row(chartForm.code) }}
{{ form_row(chartForm.metadata) }} {{ form_row(chartForm.metadata) }}
<!--<button id="saveBtn">Save</button> <!--<button id="saveBtn">Save</button>
<button id="drawBtn">Draw</button>--> <button id="drawBtn">Draw</button>-->
</div> </div>
<iframe id="chartDiv" src={{ "https://spacek.blue/charts/" ~ id }}></iframe> <iframe id="chartDiv" src={{ path('charts_display', {'id': id}) }}></iframe>
</div> </div>
<div id="secondaryDiv"> <div id="secondaryDiv">
<div id="tableDiv"> <div id="tableDiv">

@ -0,0 +1,23 @@
{% extends 'base.html.twig' %}
{% block title %}
List
{% endblock %}
{% block body %}
{{ parent() }}
<main>
<div id="myCharts">
<h1>Grafy</h1>
<a href="{{ path('charts_create') }}" id="createChart">Vytvořit nový graf</a>
<div id="myChartList">
{% for chart in charts %}
<span>
<a href={{ chart.id ~ "/edit" }} id="editChart">{{ chart.name }}</a>
<a href={{ chart.id ~ "/remove" }} id="removeChart">Smazat</a>
</span>
{% endfor %}
</div>
</div>
</main>
{% endblock %}

@ -1,11 +1,15 @@
<header id="mainHeader"> <header id="mainHeader">
<div id="logo"> <div id="logo">
<a href={{ path('homepage') }}>EasyCharts</a> <a href={{ path('homepage') }} id="homepageLink">Index</a>
</div> </div>
<nav> <nav>
<a href={{ path('charts_list') }}>Charts</a> <a href={{ path('charts_list') }} id="chartsLink">Charts</a>
</nav> </nav>
<div id="user"> <div id="user">
<a href={{ path('users_create') }}>Login</a> {% if app.user %}
<a href={{ path('users_edit', {id: app.user.id} ) }}>{{ app.user.email }}</a>
{% else %}
<a href={{ path('users_login') }}>Přihlásit</a>
{% endif %}
</div> </div>
</header> </header>

@ -1,16 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}
List
{% endblock %}
{% block body %}
{{ parent() }}
<main>
<ul>
{% for chart in charts %}
<li><a href={{ chart.id ~ "/edit" }}>{{ chart.name }}</a></li>
{% endfor %}
</ul>
</main>
{% endblock %}

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}
Upravit profil
{% endblock %}
{% block body %}
{{ parent() }}
<main>
<div class="loginDiv">
<h1>Uživatel: <strong>{{ app.user.email }}</strong></h1>
{{ form_start(form) }}
{{ form_row(form.password) }}
<button type="submit">Změnit heslo</button>
{{ form_end(form, {'render_rest': false}) }}
<a id="logoutBtn" href="{{ path('users_logout') }}">Odhlásit se</a>
</div>
</main>
{% endblock %}

@ -24,6 +24,7 @@
<button type="submit">Přihlásit se</button> <button type="submit">Přihlásit se</button>
</form> </form>
<a href="{{ path('users_create') }}">Registrovat se</a>
</div> </div>
</main> </main>
{% endblock %} {% endblock %}

@ -1,7 +1,7 @@
{% extends 'base.html.twig' %} {% extends 'base.html.twig' %}
{% block title %} {% block title %}
Register Registrovat
{% endblock %} {% endblock %}
{% block body %} {% block body %}
@ -11,7 +11,7 @@
{{ form_start(form) }} {{ form_start(form) }}
{{ form_widget(form) }} {{ form_widget(form) }}
<input type="submit"/> <button type="submit">Registrovat se</button>
{{ form_end(form) }} {{ form_end(form) }}
</div> </div>
</main> </main>

@ -15,10 +15,10 @@ return array(
'App\\Controller\\UserController' => $baseDir . '/src/Controller/UserController.php', 'App\\Controller\\UserController' => $baseDir . '/src/Controller/UserController.php',
'App\\Document\\Chart' => $baseDir . '/src/Document/Chart.php', 'App\\Document\\Chart' => $baseDir . '/src/Document/Chart.php',
'App\\Document\\User' => $baseDir . '/src/Document/User.php', 'App\\Document\\User' => $baseDir . '/src/Document/User.php',
'App\\Form\\Type\\CellType' => $baseDir . '/src/Form/Type/CellType.php',
'App\\Form\\Type\\ChartType' => $baseDir . '/src/Form/Type/ChartType.php', 'App\\Form\\Type\\ChartType' => $baseDir . '/src/Form/Type/ChartType.php',
'App\\Form\\Type\\ColumnType' => $baseDir . '/src/Form/Type/ColumnType.php', 'App\\Form\\Type\\ColumnType' => $baseDir . '/src/Form/Type/ColumnType.php',
'App\\Form\\Type\\FontType' => $baseDir . '/src/Form/Type/FontType.php', 'App\\Form\\Type\\FontType' => $baseDir . '/src/Form/Type/FontType.php',
'App\\Form\\Type\\LoginType' => $baseDir . '/src/Form/Type/LoginType.php',
'App\\Form\\Type\\MetadataType' => $baseDir . '/src/Form/Type/MetadataType.php', 'App\\Form\\Type\\MetadataType' => $baseDir . '/src/Form/Type/MetadataType.php',
'App\\Form\\Type\\UserType' => $baseDir . '/src/Form/Type/UserType.php', 'App\\Form\\Type\\UserType' => $baseDir . '/src/Form/Type/UserType.php',
'App\\Kernel' => $baseDir . '/src/Kernel.php', 'App\\Kernel' => $baseDir . '/src/Kernel.php',

@ -659,10 +659,10 @@ class ComposerStaticInit51f3c6df917af85305ff4843868663eb
'App\\Controller\\UserController' => __DIR__ . '/../..' . '/src/Controller/UserController.php', 'App\\Controller\\UserController' => __DIR__ . '/../..' . '/src/Controller/UserController.php',
'App\\Document\\Chart' => __DIR__ . '/../..' . '/src/Document/Chart.php', 'App\\Document\\Chart' => __DIR__ . '/../..' . '/src/Document/Chart.php',
'App\\Document\\User' => __DIR__ . '/../..' . '/src/Document/User.php', 'App\\Document\\User' => __DIR__ . '/../..' . '/src/Document/User.php',
'App\\Form\\Type\\CellType' => __DIR__ . '/../..' . '/src/Form/Type/CellType.php',
'App\\Form\\Type\\ChartType' => __DIR__ . '/../..' . '/src/Form/Type/ChartType.php', 'App\\Form\\Type\\ChartType' => __DIR__ . '/../..' . '/src/Form/Type/ChartType.php',
'App\\Form\\Type\\ColumnType' => __DIR__ . '/../..' . '/src/Form/Type/ColumnType.php', 'App\\Form\\Type\\ColumnType' => __DIR__ . '/../..' . '/src/Form/Type/ColumnType.php',
'App\\Form\\Type\\FontType' => __DIR__ . '/../..' . '/src/Form/Type/FontType.php', 'App\\Form\\Type\\FontType' => __DIR__ . '/../..' . '/src/Form/Type/FontType.php',
'App\\Form\\Type\\LoginType' => __DIR__ . '/../..' . '/src/Form/Type/LoginType.php',
'App\\Form\\Type\\MetadataType' => __DIR__ . '/../..' . '/src/Form/Type/MetadataType.php', 'App\\Form\\Type\\MetadataType' => __DIR__ . '/../..' . '/src/Form/Type/MetadataType.php',
'App\\Form\\Type\\UserType' => __DIR__ . '/../..' . '/src/Form/Type/UserType.php', 'App\\Form\\Type\\UserType' => __DIR__ . '/../..' . '/src/Form/Type/UserType.php',
'App\\Kernel' => __DIR__ . '/../..' . '/src/Kernel.php', 'App\\Kernel' => __DIR__ . '/../..' . '/src/Kernel.php',

@ -1,9 +1,9 @@
<?php return array( <?php return array(
'root' => array( 'root' => array(
'name' => '__root__', 'name' => '__root__',
'pretty_version' => '1.0.0+no-version-set', 'pretty_version' => 'dev-main',
'version' => '1.0.0.0', 'version' => 'dev-main',
'reference' => NULL, 'reference' => '5350952bd30de2a1c645d2096e994343eb5144b3',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),
@ -11,9 +11,9 @@
), ),
'versions' => array( 'versions' => array(
'__root__' => array( '__root__' => array(
'pretty_version' => '1.0.0+no-version-set', 'pretty_version' => 'dev-main',
'version' => '1.0.0.0', 'version' => 'dev-main',
'reference' => NULL, 'reference' => '5350952bd30de2a1c645d2096e994343eb5144b3',
'type' => 'project', 'type' => 'project',
'install_path' => __DIR__ . '/../../', 'install_path' => __DIR__ . '/../../',
'aliases' => array(), 'aliases' => array(),

Loading…
Cancel
Save

Powered by TurnKey Linux.