繁体   English   中英

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

[英]Activity Log in dashboard sonata admin

我正在尝试在仪表板中实现活动日志,即每行中的一条通知,该通知指出自用户上次登录以来哪些实体发生了更改。

为此,我正在考虑覆盖类AdminListBlockService和模板block_admin_list.html.twig

但是我还不清楚如何做。

有人知道更好的方法吗? 如果那是更好的方法,我该如何实现呢?

非常感谢!

我发现了一种更好的方法...我只覆盖了block_admin_list.html.twig这样:

//config.yml

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

请注意区别“ SonataAdminBundle”和“ AdminBundle”

下一步添加模板:

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

最后为我要通知的每个实体创建逻辑

//in the exempleAdmin

 public function activityLog(){

      // custom code $activity= ....

    return $activity;
 }

如果有人知道更好的方法,请告诉我,谢谢

好吧,您可以做的是像这样覆盖模板:

在您的管理员课程中:

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

然后,您可以在模板中执行以下操作:

{# 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