mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-08 22:17:57 +00:00
move dashboard relations to the user controller
This commit is contained in:
parent
02e56e4d08
commit
8ee25d3a30
@ -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'
|
||||
);
|
||||
}
|
||||
}
|
@ -12,6 +12,62 @@ use App\Service\TimeService;
|
||||
|
||||
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(
|
||||
'/{_locale}/profile',
|
||||
name: 'user_profile',
|
||||
|
@ -1,2 +0,0 @@
|
||||
{% extends 'default/layout.html.twig' %}
|
||||
{% block title %}{{ 'Home'|trans }} - {{ name }}{% endblock %}
|
@ -13,7 +13,7 @@
|
||||
<header>
|
||||
<div class="container">
|
||||
<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
|
||||
</a>
|
||||
{% block header_search %}
|
||||
|
@ -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="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">
|
||||
<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"/>
|
||||
@ -10,7 +10,7 @@
|
||||
</span>
|
||||
</span>
|
||||
{% 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">
|
||||
<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>
|
||||
|
Loading…
Reference in New Issue
Block a user