diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ad8f8b0408b36e84a8c56fd67f0d3c4b996bbfa..17ccf92547bf32abb07de5870006e4f3f96da1a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ v2.3.1 ====== +* FEATURE: Display number of messages and errors in admin top header * FEATURE: Add license url for the data * BUG: Fix using images in marker popup template diff --git a/app/Resources/SonataAdminBundle/views/layout.html.twig b/app/Resources/SonataAdminBundle/views/layout.html.twig index fefa157e765701f47e53f3328110d6d91b922201..5bc038cbf1535116287bf7efe71509eef36bdddd 100755 --- a/app/Resources/SonataAdminBundle/views/layout.html.twig +++ b/app/Resources/SonataAdminBundle/views/layout.html.twig @@ -75,6 +75,11 @@ } .text-and-iframe-container:before { display: table; content: " "; } .text-and-iframe-container:after { clear: both; display: table; content: " ";} + + .main-header { display: flex; } + .main-header .logo { width: auto; } + .main-header .logo label:hover { cursor: pointer; } + .main-header .navbar { flex: auto; margin-left: 0; } </style> @@ -144,6 +149,30 @@ {% endblock %} +{% block logo %} + {% spaceless %} + <a class="logo" href="{{ path('sonata_admin_dashboard') }}"> + <img src="{{ asset('assets/img/default-icon.png') }}"> + <span>GoGoCarto Administration</span> + {% set newMsgsCount = new_msgs_count() %} + {% if newMsgsCount > 0 %} + <label class="label label-info" style="margin-left: 6px"> + <i class="fa fa-bell" style="margin-right: 3px;"></i> + {{ newMsgsCount }} {{ newMsgsCount == 1 ? ' message' : ' messages' }} + </label> + {% endif %} + {% set newErrorsCount = errors_count() %} + {% if newErrorsCount > 0 %} + <label class="label label-danger" style="margin-left: 6px"> + <i class="fa fa-warning" style="margin-right: 3px;"></i> + {{ newErrorsCount }} {{ newErrorsCount == 1 ? 'erreur' : 'erreurs' }} + </label> + {% endif %} + + </a> + {% endspaceless %} +{% endblock %} + {% block sonata_sidebar_search %} <div class="btn-group side-bar-links"> <a type="button" href={{ path('biopen_homepage') }} target='_blank' class="btn btn-primary">Retour au site</a> diff --git a/app/config/config_sonata.yml b/app/config/config_sonata.yml index 2238c9c6a8859500089f68baae9ee0b9fd10a2aa..07e6295064cd703451c81012b5aabfebdb2f00ec 100755 --- a/app/config/config_sonata.yml +++ b/app/config/config_sonata.yml @@ -54,8 +54,6 @@ sonata_formatter: extensions: [] # Twig formatter cannot have extensions sonata_admin: - title: 'GoGoCarto Administration' - # title_logo: 'assets/img/favicon.png' security: handler: sonata.admin.security.handler.role options: diff --git a/app/config/services.yml b/app/config/services.yml index 7a10c1e4b5d6a4bc4d647c9aaafd4838e303f027..022d8948ac0c603612f5b34db8412de4cb10d105 100755 --- a/app/config/services.yml +++ b/app/config/services.yml @@ -16,5 +16,6 @@ services: app.twig_extension: class: Application\Twig\AppExtension public: false + arguments: [ "@doctrine.odm.mongoDB.document_manager" ] tags: - { name: twig.extension } \ No newline at end of file diff --git a/src/Application/Twig/AppExtension.php b/src/Application/Twig/AppExtension.php index 885274731cfd03c0b2e758a73f28038309959acd..8087051d94b649b936b2cf8aeb6e7929521ceaf9 100644 --- a/src/Application/Twig/AppExtension.php +++ b/src/Application/Twig/AppExtension.php @@ -9,6 +9,11 @@ use Biopen\SaasBundle\Helper\SaasHelper; class AppExtension extends AbstractExtension { + public function __construct($dm) + { + $this->dm = $dm; + } + public function getFilters() { return array( @@ -25,6 +30,8 @@ class AppExtension extends AbstractExtension { return array( new TwigFunction('is_root_project', array($this, 'isRootProject')), + new TwigFunction('new_msgs_count', array($this, 'getNewMessagesCount')), + new TwigFunction('errors_count', array($this, 'getErrorsCount')), ); } @@ -33,4 +40,14 @@ class AppExtension extends AbstractExtension $sassHelper = new SaasHelper(); return $sassHelper->isRootProject(); } + + public function getNewMessagesCount() + { + return count($this->dm->getRepository('BiopenCoreBundle:GoGoLog')->findBy(['type' => 'update', 'hidden' => false])); + } + + public function getErrorsCount() + { + return count($this->dm->getRepository('BiopenCoreBundle:GoGoLog')->findBy(['level' => 'error', 'hidden' => false])); + } } \ No newline at end of file