Browse Source

move dashboard relations to the user controller

main
ghost 1 year ago
parent
commit
8ee25d3a30
  1. 43
      src/Controller/DashboardController.php
  2. 56
      src/Controller/UserController.php
  3. 2
      templates/default/dashboard/index.html.twig
  4. 2
      templates/default/layout.html.twig
  5. 4
      templates/default/user/module.html.twig

43
src/Controller/DashboardController.php

@ -1,43 +0,0 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use App\Service\UserService;
class DashboardController extends AbstractController
{
#[Route('/')]
public function root(
Request $request,
UserService $userService
): Response
{
// Init user
$user = $userService->init(
$request->getClientIp()
);
return $this->redirectToRoute(
'dashboard_index',
[
'_locale' => $user->getLocale()
]
);
}
#[Route(
'/{_locale}',
name: 'dashboard_index'
)]
public function index(Request $request): Response
{
return $this->render(
'default/dashboard/index.html.twig'
);
}
}

56
src/Controller/UserController.php

@ -12,6 +12,62 @@ use App\Service\TimeService;
class UserController extends AbstractController class UserController extends AbstractController
{ {
#[Route('/')]
public function root(
Request $request,
UserService $userService
): Response
{
$user = $userService->init(
$request->getClientIp()
);
return $this->redirectToRoute(
'user_dashboard',
[
'_locale' => $user->getLocale()
]
);
}
#[Route(
'/{_locale}',
name: 'user_dashboard'
)]
public function index(
Request $request,
UserService $userService,
TimeService $timeService
): Response
{
$activities = [];
foreach ($userService->getAllByAddedFieldDesc() as $user)
{
$activities[] =
[
'user' =>
[
'id' => $user->getId(),
'identicon' => $userService->identicon(
$user->getAddress(),
24
)
],
'type' => 'join',
'added' => $timeService->ago(
$user->getAdded()
)
];
}
return $this->render(
'default/user/dashboard.html.twig',
[
'activities' => $activities
]
);
}
#[Route( #[Route(
'/{_locale}/profile', '/{_locale}/profile',
name: 'user_profile', name: 'user_profile',

2
templates/default/dashboard/index.html.twig

@ -1,2 +0,0 @@
{% extends 'default/layout.html.twig' %}
{% block title %}{{ 'Home'|trans }} - {{ name }}{% endblock %}

2
templates/default/layout.html.twig

@ -13,7 +13,7 @@
<header> <header>
<div class="container"> <div class="container">
<div class="row margin-y-16-px text-center"> <div class="row margin-y-16-px text-center">
<a class="logo" href="{{ path('dashboard_activity') }}"> <a class="logo" href="{{ path('user_dashboard') }}">
<span>YGG</span>tracker <span>YGG</span>tracker
</a> </a>
{% block header_search %} {% block header_search %}

4
templates/default/user/module.html.twig

@ -1,6 +1,6 @@
<div class="margin-y-8-px position-fixed width-180-px margin-l--196-px background-color-night border-radius-3-px"> <div class="margin-y-8-px position-fixed width-180-px margin-l--196-px background-color-night border-radius-3-px">
<div class="padding-y-8-px"> <div class="padding-y-8-px">
{% if route == 'dashboard_index' %} {% if route == 'user_dashboard' %}
<span class="padding-x-16-px padding-y-8-px display-block background-color-green cursor-default text-color-white"> <span class="padding-x-16-px padding-y-8-px display-block background-color-green cursor-default text-color-white">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/> <path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/>
@ -10,7 +10,7 @@
</span> </span>
</span> </span>
{% else %} {% else %}
<a class="padding-x-16-px padding-y-8-px display-block background-color-hover-night-light text-color-default" href="{{ path('dashboard_index') }}"> <a class="padding-x-16-px padding-y-8-px display-block background-color-hover-night-light text-color-default" href="{{ path('user_dashboard') }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/> <path d="M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z"/>
</svg> </svg>

Loading…
Cancel
Save