Commit d76e0223 authored by Sebastian Castro's avatar Sebastian Castro

Display number of new messages and errors in admin logo title

parent 5341b5f6
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
......
......@@ -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>
......
......@@ -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:
......
......@@ -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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment