mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-01-22 12:44:25 +00:00
draft activity feature #4
This commit is contained in:
parent
8ee25d3a30
commit
d73086231f
@ -129,18 +129,6 @@ class UserController extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
// Generate identicon
|
||||
$identicon = new \Jdenticon\Identicon();
|
||||
|
||||
$identicon->setValue($user->getAddress());
|
||||
$identicon->setSize(48);
|
||||
$identicon->setStyle(
|
||||
[
|
||||
'backgroundColor' => 'rgba(255, 255, 255, 0)',
|
||||
'padding' => 0
|
||||
]
|
||||
);
|
||||
|
||||
// Render template
|
||||
return $this->render(
|
||||
'default/user/profile.html.twig',
|
||||
@ -156,7 +144,10 @@ class UserController extends AbstractController
|
||||
'added' => $timeService->ago(
|
||||
$user->getAdded()
|
||||
),
|
||||
'identicon' => $identicon->getImageDataUri('webp'),
|
||||
'identicon' => $userService->identicon(
|
||||
$user->getAddress(),
|
||||
48
|
||||
),
|
||||
],
|
||||
'locales' => explode('|', $this->getParameter('app.locales'))
|
||||
]
|
||||
@ -185,18 +176,6 @@ class UserController extends AbstractController
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
// Generate identicon
|
||||
$identicon = new \Jdenticon\Identicon();
|
||||
|
||||
$identicon->setValue($user->getAddress());
|
||||
$identicon->setSize(48);
|
||||
$identicon->setStyle(
|
||||
[
|
||||
'backgroundColor' => 'rgba(255, 255, 255, 0)',
|
||||
'padding' => 0
|
||||
]
|
||||
);
|
||||
|
||||
// Render template
|
||||
return $this->render(
|
||||
'default/user/info.html.twig',
|
||||
@ -212,7 +191,10 @@ class UserController extends AbstractController
|
||||
'added' => $timeService->ago(
|
||||
$user->getAdded()
|
||||
),
|
||||
'identicon' => $identicon->getImageDataUri('webp'),
|
||||
'identicon' => $userService->identicon(
|
||||
$user->getAddress(),
|
||||
48
|
||||
),
|
||||
]
|
||||
]
|
||||
);
|
||||
|
@ -40,4 +40,13 @@ class UserRepository extends ServiceEntityRepository
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
}
|
||||
|
||||
public function findAllByAddedFieldDesc(): array
|
||||
{
|
||||
return $this->createQueryBuilder('u')
|
||||
->orderBy('u.added', 'DESC')
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
}
|
||||
}
|
||||
|
@ -58,6 +58,31 @@ class UserService
|
||||
return $this->userRepository->findOneByIdField($id);
|
||||
}
|
||||
|
||||
public function getAllByAddedFieldDesc(): array
|
||||
{
|
||||
return $this->userRepository->findAllByAddedFieldDesc();
|
||||
}
|
||||
|
||||
public function identicon(
|
||||
mixed $value,
|
||||
int $size = 16,
|
||||
array $style =
|
||||
[
|
||||
'backgroundColor' => 'rgba(255, 255, 255, 0)',
|
||||
'padding' => 0
|
||||
],
|
||||
string $format = 'webp'
|
||||
): string
|
||||
{
|
||||
$identicon = new \Jdenticon\Identicon();
|
||||
|
||||
$identicon->setValue($value);
|
||||
$identicon->setSize($size);
|
||||
$identicon->setStyle($style);
|
||||
|
||||
return $identicon->getImageDataUri($format);
|
||||
}
|
||||
|
||||
public function save(User $user) : void
|
||||
{
|
||||
$this->entityManager->persist($user);
|
||||
|
23
templates/default/user/dashboard.html.twig
Normal file
23
templates/default/user/dashboard.html.twig
Normal file
@ -0,0 +1,23 @@
|
||||
{% extends 'default/layout.html.twig' %}
|
||||
{% block title %}{{ 'Last activity'|trans }} - {{ name }}{% endblock %}
|
||||
{% block main_content %}
|
||||
{% for activity in activities %}
|
||||
<div class="padding-16-px margin-y-8-px border-radius-3-px background-color-night">
|
||||
<div class="row">
|
||||
<div class="column width-80">
|
||||
<a href="{{ path('user_info', {'id': activity.user.id}) }}">
|
||||
<img class="vertical-align-middle border-radius-50 border-default border-width-2-px margin-r-8-px"
|
||||
src="{{ activity.user.identicon }}"
|
||||
alt="{{ 'identicon'|trans }}" />
|
||||
</a>
|
||||
{% if activity.type == 'join' %}
|
||||
{{ 'joined'|trans }} {{ name }}
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="column width-20 text-right padding-y-4-px">
|
||||
{{ activity.added }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user