mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-02 01:54:13 +00:00
add last user activity on profile page
This commit is contained in:
parent
9c9dc5b5a4
commit
cc6c68957c
@ -15,7 +15,7 @@ use App\Service\TorrentService;
|
|||||||
|
|
||||||
class ActivityController extends AbstractController
|
class ActivityController extends AbstractController
|
||||||
{
|
{
|
||||||
public function template(
|
public function event(
|
||||||
$activity,
|
$activity,
|
||||||
ActivityService $activityService,
|
ActivityService $activityService,
|
||||||
UserService $userService,
|
UserService $userService,
|
||||||
|
@ -57,7 +57,7 @@ class UserController extends AbstractController
|
|||||||
return $this->render(
|
return $this->render(
|
||||||
'default/user/dashboard.html.twig',
|
'default/user/dashboard.html.twig',
|
||||||
[
|
[
|
||||||
'activities' => $activityService->findLastEvents(
|
'activities' => $activityService->findLastActivities(
|
||||||
$user->getEvents()
|
$user->getEvents()
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
@ -254,8 +254,12 @@ class UserController extends AbstractController
|
|||||||
$userTarget->getId()
|
$userTarget->getId()
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
'activities' => $activityService->findLastActivitiesByUserId(
|
||||||
|
$userTarget->getId(),
|
||||||
|
$userTarget->getEvents()
|
||||||
|
)
|
||||||
],
|
],
|
||||||
'events' => $activityService->getEventsTree()
|
'events' => $activityService->getEventsTree(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ class ActivityService
|
|||||||
return $events;
|
return $events;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findLastEvents(
|
public function findLastActivities(
|
||||||
array $whitelist
|
array $whitelist
|
||||||
): array
|
): array
|
||||||
{
|
{
|
||||||
@ -376,6 +376,24 @@ class ActivityService
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findLastActivitiesByUserId(
|
||||||
|
int $userId,
|
||||||
|
array $whitelist
|
||||||
|
): array
|
||||||
|
{
|
||||||
|
return $this->entityManagerInterface
|
||||||
|
->getRepository(Activity::class)
|
||||||
|
->findBy(
|
||||||
|
[
|
||||||
|
'userId' => $userId,
|
||||||
|
'event' => $whitelist
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'DESC'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// User
|
// User
|
||||||
public function addEventUserAdd(
|
public function addEventUserAdd(
|
||||||
int $userId,
|
int $userId,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
{% for activity in activities %}
|
{% for activity in activities %}
|
||||||
<div class="padding-16-px margin-y-8-px border-radius-3-px background-color-night">
|
<div class="padding-16-px margin-y-8-px border-radius-3-px background-color-night">
|
||||||
{{ render(controller(
|
{{ render(controller(
|
||||||
'App\\Controller\\ActivityController::template',
|
'App\\Controller\\ActivityController::event',
|
||||||
{ activity : activity }
|
{ activity : activity }
|
||||||
)) }}
|
)) }}
|
||||||
</div>
|
</div>
|
||||||
|
@ -218,4 +218,20 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
{% if user.activities %}
|
||||||
|
<div class="padding-x-24-px padding-y-8-px margin-y-16-px">
|
||||||
|
<h2>{{ 'Last activity' | trans }}</h2>
|
||||||
|
<sup>
|
||||||
|
<a href="#">RSS</a>
|
||||||
|
</sup>
|
||||||
|
</div>
|
||||||
|
{% for activity in user.activities %}
|
||||||
|
<div class="padding-x-24-px padding-y-16-px margin-y-8-px border-radius-3-px background-color-night">
|
||||||
|
{{ render(controller(
|
||||||
|
'App\\Controller\\ActivityController::event',
|
||||||
|
{ activity : activity }
|
||||||
|
)) }}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user