Add actions display
This commit is contained in:
parent
6670fbc8b8
commit
7e272b2b2f
|
|
@ -8,6 +8,7 @@
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mercure" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mercure" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mercure-bundle" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/mercure-bundle" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/vendor/firebase/php-jwt" />
|
<excludeFolder url="file://$MODULE_DIR$/vendor/firebase/php-jwt" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/vendor/knplabs/knp-time-bundle" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,6 @@
|
||||||
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
|
<path value="$PROJECT_DIR$/vendor/lcobucci/jwt" />
|
||||||
<path value="$PROJECT_DIR$/vendor/lcobucci/clock" />
|
<path value="$PROJECT_DIR$/vendor/lcobucci/clock" />
|
||||||
<path value="$PROJECT_DIR$/vendor/twig/twig" />
|
<path value="$PROJECT_DIR$/vendor/twig/twig" />
|
||||||
<path value="$PROJECT_DIR$/vendor/twig/extra-bundle" />
|
|
||||||
<path value="$PROJECT_DIR$/vendor/composer" />
|
<path value="$PROJECT_DIR$/vendor/composer" />
|
||||||
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
|
<path value="$PROJECT_DIR$/vendor/theseer/tokenizer" />
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
|
<path value="$PROJECT_DIR$/vendor/symfony/deprecation-contracts" />
|
||||||
|
|
@ -163,6 +162,8 @@
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/mercure" />
|
<path value="$PROJECT_DIR$/vendor/symfony/mercure" />
|
||||||
<path value="$PROJECT_DIR$/vendor/symfony/mercure-bundle" />
|
<path value="$PROJECT_DIR$/vendor/symfony/mercure-bundle" />
|
||||||
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
|
<path value="$PROJECT_DIR$/vendor/firebase/php-jwt" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/doctrine/cache" />
|
||||||
|
<path value="$PROJECT_DIR$/vendor/knplabs/knp-time-bundle" />
|
||||||
</include_path>
|
</include_path>
|
||||||
</component>
|
</component>
|
||||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
|
<component name="PhpProjectSharedConfiguration" php_language_level="8.2" />
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.4",
|
"doctrine/doctrine-migrations-bundle": "^3.4",
|
||||||
"doctrine/orm": "^3.3",
|
"doctrine/orm": "^3.3",
|
||||||
"firebase/php-jwt": "^6.11",
|
"firebase/php-jwt": "^6.11",
|
||||||
|
"knplabs/knp-time-bundle": "^2.4",
|
||||||
"league/oauth2-server-bundle": "^0.11.0",
|
"league/oauth2-server-bundle": "^0.11.0",
|
||||||
"nelmio/cors-bundle": "^2.5",
|
"nelmio/cors-bundle": "^2.5",
|
||||||
"phpdocumentor/reflection-docblock": "^5.6",
|
"phpdocumentor/reflection-docblock": "^5.6",
|
||||||
|
|
@ -49,7 +50,6 @@
|
||||||
"symfony/validator": "7.2.*",
|
"symfony/validator": "7.2.*",
|
||||||
"symfony/web-link": "7.2.*",
|
"symfony/web-link": "7.2.*",
|
||||||
"symfony/yaml": "7.2.*",
|
"symfony/yaml": "7.2.*",
|
||||||
"twig/extra-bundle": "^2.12|^3.0",
|
|
||||||
"twig/twig": "^2.12|^3.0"
|
"twig/twig": "^2.12|^3.0"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "ec18ea9254732e2793a2fc5e0e6919aa",
|
"content-hash": "51f33a9cb3451faf4b58c6984f46bb5d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/semver",
|
"name": "composer/semver",
|
||||||
|
|
@ -1411,6 +1411,81 @@
|
||||||
},
|
},
|
||||||
"time": "2025-04-09T20:32:01+00:00"
|
"time": "2025-04-09T20:32:01+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "knplabs/knp-time-bundle",
|
||||||
|
"version": "v2.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/KnpLabs/KnpTimeBundle.git",
|
||||||
|
"reference": "93e9528415b28a19872d74b28e816045c0fd217b"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/KnpLabs/KnpTimeBundle/zipball/93e9528415b28a19872d74b28e816045c0fd217b",
|
||||||
|
"reference": "93e9528415b28a19872d74b28e816045c0fd217b",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.1",
|
||||||
|
"symfony/config": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/translation": "^5.4|^6.0|^7.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"phpunit/phpunit": "<8.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpstan/phpstan": "^1.11",
|
||||||
|
"phpunit/phpunit": "^9.6",
|
||||||
|
"symfony/framework-bundle": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/phpunit-bridge": "^5.4|^6.0|^7.0",
|
||||||
|
"symfony/twig-bundle": "^5.4|^6.0|^7.0"
|
||||||
|
},
|
||||||
|
"suggest": {
|
||||||
|
"symfony/twig-bundle": "to use the Twig `time_diff()` function and `|time_diff`/`|duration` filter"
|
||||||
|
},
|
||||||
|
"type": "symfony-bundle",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Knp\\Bundle\\TimeBundle\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "KnpLabs Team",
|
||||||
|
"homepage": "https://knplabs.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://github.com/KnpLabs/KnpTimeBundle/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Making your dates and durations look sensible and descriptive",
|
||||||
|
"homepage": "https://github.com/KnpLabs/KnpTimeBundle",
|
||||||
|
"keywords": [
|
||||||
|
"bundle",
|
||||||
|
"date",
|
||||||
|
"descriptive time",
|
||||||
|
"duration",
|
||||||
|
"knp",
|
||||||
|
"knplabs",
|
||||||
|
"time"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/KnpLabs/KnpTimeBundle/issues",
|
||||||
|
"source": "https://github.com/KnpLabs/KnpTimeBundle/tree/v2.4.0"
|
||||||
|
},
|
||||||
|
"time": "2024-06-11T09:38:28+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "lcobucci/clock",
|
"name": "lcobucci/clock",
|
||||||
"version": "3.3.1",
|
"version": "3.3.1",
|
||||||
|
|
@ -8841,80 +8916,6 @@
|
||||||
],
|
],
|
||||||
"time": "2025-06-03T06:57:06+00:00"
|
"time": "2025-06-03T06:57:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "twig/extra-bundle",
|
|
||||||
"version": "v3.21.0",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/twigphp/twig-extra-bundle.git",
|
|
||||||
"reference": "62d1cf47a1aa009cbd07b21045b97d3d5cb79896"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/62d1cf47a1aa009cbd07b21045b97d3d5cb79896",
|
|
||||||
"reference": "62d1cf47a1aa009cbd07b21045b97d3d5cb79896",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=8.1.0",
|
|
||||||
"symfony/framework-bundle": "^5.4|^6.4|^7.0",
|
|
||||||
"symfony/twig-bundle": "^5.4|^6.4|^7.0",
|
|
||||||
"twig/twig": "^3.2|^4.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"league/commonmark": "^1.0|^2.0",
|
|
||||||
"symfony/phpunit-bridge": "^6.4|^7.0",
|
|
||||||
"twig/cache-extra": "^3.0",
|
|
||||||
"twig/cssinliner-extra": "^3.0",
|
|
||||||
"twig/html-extra": "^3.0",
|
|
||||||
"twig/inky-extra": "^3.0",
|
|
||||||
"twig/intl-extra": "^3.0",
|
|
||||||
"twig/markdown-extra": "^3.0",
|
|
||||||
"twig/string-extra": "^3.0"
|
|
||||||
},
|
|
||||||
"type": "symfony-bundle",
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Twig\\Extra\\TwigExtraBundle\\": ""
|
|
||||||
},
|
|
||||||
"exclude-from-classmap": [
|
|
||||||
"/Tests/"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Fabien Potencier",
|
|
||||||
"email": "fabien@symfony.com",
|
|
||||||
"homepage": "http://fabien.potencier.org",
|
|
||||||
"role": "Lead Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "A Symfony bundle for extra Twig extensions",
|
|
||||||
"homepage": "https://twig.symfony.com",
|
|
||||||
"keywords": [
|
|
||||||
"bundle",
|
|
||||||
"extra",
|
|
||||||
"twig"
|
|
||||||
],
|
|
||||||
"support": {
|
|
||||||
"source": "https://github.com/twigphp/twig-extra-bundle/tree/v3.21.0"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"url": "https://github.com/fabpot",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"url": "https://tidelift.com/funding/github/packagist/twig/twig",
|
|
||||||
"type": "tidelift"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"time": "2025-02-19T14:29:33+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.21.1",
|
"version": "v3.21.1",
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ return [
|
||||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||||
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
|
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
|
||||||
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
|
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
|
||||||
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
|
||||||
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
|
||||||
|
|
@ -18,4 +17,5 @@ return [
|
||||||
League\Bundle\OAuth2ServerBundle\LeagueOAuth2ServerBundle::class => ['all' => true],
|
League\Bundle\OAuth2ServerBundle\LeagueOAuth2ServerBundle::class => ['all' => true],
|
||||||
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
|
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
|
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
|
||||||
|
Knp\Bundle\TimeBundle\KnpTimeBundle::class => ['all' => true],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ namespace App\Controller;
|
||||||
use App\Entity\Apps;
|
use App\Entity\Apps;
|
||||||
use App\Entity\Roles;
|
use App\Entity\Roles;
|
||||||
use App\Entity\UsersOrganizations;
|
use App\Entity\UsersOrganizations;
|
||||||
|
use App\Service\ActionService;
|
||||||
use App\Service\OrganizationsService;
|
use App\Service\OrganizationsService;
|
||||||
use App\Service\UserOrganizationService;
|
use App\Service\UserOrganizationService;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
@ -52,7 +53,7 @@ class OrganizationController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route(path: '/{id}', name: 'show', methods: ['GET'])]
|
#[Route(path: '/{id}', name: 'show', methods: ['GET'])]
|
||||||
public function show(int $id): Response
|
public function show(int $id, ActionService $actionService): Response
|
||||||
{
|
{
|
||||||
if ($this->isGranted('ROLE_ADMIN')) {
|
if ($this->isGranted('ROLE_ADMIN')) {
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
@ -78,6 +79,15 @@ class OrganizationController extends AbstractController
|
||||||
// get all applications
|
// get all applications
|
||||||
$applications = $this->organizationsService->getApplicationsWithAccessStatus($organization);
|
$applications = $this->organizationsService->getApplicationsWithAccessStatus($organization);
|
||||||
|
|
||||||
|
$actions = $organization->getActions()->toArray();
|
||||||
|
$activities = array_map(static function($activity) use ($actionService) {
|
||||||
|
return [
|
||||||
|
'date' => $activity->getDate(), // or however you access the date
|
||||||
|
'actionType' => $activity->getActionType(),
|
||||||
|
'users' => $activity->getUsers(),
|
||||||
|
'color' => $actionService->getActivityColor($activity->getDate())
|
||||||
|
];
|
||||||
|
}, $actions);
|
||||||
}else{
|
}else{
|
||||||
throw $this->createNotFoundException(self::ACCESS_DENIED);
|
throw $this->createNotFoundException(self::ACCESS_DENIED);
|
||||||
}
|
}
|
||||||
|
|
@ -88,6 +98,7 @@ class OrganizationController extends AbstractController
|
||||||
'newUsers' => $newUsers,
|
'newUsers' => $newUsers,
|
||||||
'org' => $org[0],
|
'org' => $org[0],
|
||||||
'applications' => $applications,
|
'applications' => $applications,
|
||||||
|
'activities' => $activities
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
class ActionService
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getActivityColor(\DateTimeImmutable $activityTime): string
|
||||||
|
{
|
||||||
|
$now = new \DateTimeImmutable();
|
||||||
|
$diffInSeconds = $now->getTimestamp() - $activityTime->getTimestamp();
|
||||||
|
|
||||||
|
if ($diffInSeconds < 15 * 60) { // less than 15 minutes
|
||||||
|
return '#086572';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($diffInSeconds < 60 * 60) { // less than 1 hour
|
||||||
|
return '#247208';
|
||||||
|
}
|
||||||
|
return '#C76633';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -35,6 +35,9 @@
|
||||||
"migrations/.gitignore"
|
"migrations/.gitignore"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"knplabs/knp-time-bundle": {
|
||||||
|
"version": "v2.4.0"
|
||||||
|
},
|
||||||
"league/oauth2-server-bundle": {
|
"league/oauth2-server-bundle": {
|
||||||
"version": "0.11",
|
"version": "0.11",
|
||||||
"recipe": {
|
"recipe": {
|
||||||
|
|
@ -381,8 +384,5 @@
|
||||||
"files": [
|
"files": [
|
||||||
"config/packages/messenger.yaml"
|
"config/packages/messenger.yaml"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"twig/extra-bundle": {
|
|
||||||
"version": "v3.20.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,32 +6,20 @@
|
||||||
<h3>{{ title }}</h3>
|
<h3>{{ title }}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
{# {% if activities|length == 0 %}#}
|
{% if activities|length == 0 %}
|
||||||
{# <p>Aucune activité récente.</p>#}
|
<p>Aucune activité récente.</p>
|
||||||
{# {% else %}#}
|
{% else %}
|
||||||
|
{% set sortedActivities = activities|sort((a, b) => a.date <=> b.date)|reverse %}
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
{# {% for activity in activities %}#}
|
{% for activity in sortedActivities%}
|
||||||
<li class="list-group-item">
|
{% include 'user/organization/userActivity.html.twig' with {
|
||||||
<p> 5 mins ago</p>
|
activityTime: activity.date,
|
||||||
</li>
|
action: activity.actionType,
|
||||||
<li class="list-group-item">
|
userName: activity.users.name,
|
||||||
<p> 5 mins ago</p>
|
color: activity.color
|
||||||
</li>
|
} %}
|
||||||
<li class="list-group-item">
|
{% endfor %}
|
||||||
<p> 5 mins ago</p>
|
|
||||||
</li>
|
|
||||||
<li class="list-group-item">
|
|
||||||
<p> 5 mins ago</p>
|
|
||||||
</li>
|
|
||||||
<li class="list-group-item">
|
|
||||||
<p> 5 mins ago</p>
|
|
||||||
</li>
|
|
||||||
<li class="list-group-item">
|
|
||||||
<p> 5 mins ago</p>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
{# {% endfor %}#}
|
|
||||||
</ul>
|
</ul>
|
||||||
{# {% endif %}#}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
{% block body %}
|
||||||
|
|
||||||
|
<div class="card border">
|
||||||
|
<div class="card-header d-flex align-items-center border-0">
|
||||||
|
<div class="row align-items-center">
|
||||||
|
|
||||||
|
<h4 class="mb-0">
|
||||||
|
<span style="display:inline-block; width:16px; height:16px; border-radius:50%; background:{{ color }}; margin-right:10px;"></span>
|
||||||
|
{{ activityTime|ago }}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<p>{{ userName }} - {{ action }}</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
Loading…
Reference in New Issue