简体   繁体   English

活动登录仪表板奏鸣曲管理员

[英]Activity Log in dashboard sonata admin

I'm trying to implement activity log in the dashboard ie a notification in each row that says which entities have a change since the last login of a user. 我正在尝试在仪表板中实现活动日志,即每行中的一条通知,该通知指出自用户上次登录以来哪些实体发生了更改。

To do it I'm thinking about overwrite the class AdminListBlockService and the template block_admin_list.html.twig 为此,我正在考虑覆盖类AdminListBlockService和模板block_admin_list.html.twig

but i don't have yet clear how do it. 但是我还不清楚如何做。

someone know a better way to do it? 有人知道更好的方法吗? if that is the better way, how can I achieve it? 如果那是更好的方法,我该如何实现呢?

thanks a lot! 非常感谢!

ok

I found a better way... i have overwritten only the block_admin_list.html.twig so: 我发现了一种更好的方法...我只覆盖了block_admin_list.html.twig这样:

//config.yml //config.yml

sonata_admin:
    templates:
          list_block:          AdminBundle:Block:block_admin_list.html.twig

note the diference "SonataAdminBundle" and "AdminBundle" 请注意区别“ SonataAdminBundle”和“ AdminBundle”

next step add in the template: 下一步添加模板:

{% if admin.activityLog() is defined and admin.isGranted('LIST') %}          
     <a class="btn btn-link" href="{{ admin.generateUrl('list')>admin.activityLog</a>
{% endif %}

and finally create the logic for each Entity where i want the notification 最后为我要通知的每个实体创建逻辑

//in the exempleAdmin

 public function activityLog(){

      // custom code $activity= ....

    return $activity;
 }

if someone know a better way to do it, please let me know, thanks 如果有人知道更好的方法,请告诉我,谢谢

Well what you can do is override the template like this: 好吧,您可以做的是像这样覆盖模板:

In your admin class: 在您的管理员课程中:

// Configure our custom roles for this entity
public function configure() {
    parent::configure();
    $this->setTemplate('list', 'MyAdminBundle:CRUD:list-myentity.html.twig');
}

Then in your template you can do something like: 然后,您可以在模板中执行以下操作:

{# The default template which provides batch and action cells, with the valid colspan computation #}

{% extends 'SonataAdminBundle:CRUD:list.html.twig' %}

{% block table_body %}
    <tbody>
        {% for object in admin.datagrid.results %}
            <style>
                table tr.green-color td {background-color: #2BFF5D !important; }
            </style>
            <tr {% if changed %} class="green-color" {% endif %}>
                {% include admin.getTemplate('inner_list_row') %}
            </tr>
        {% endfor %}
    </tbody>
{% endblock %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM