From f2c6d8aee111ae9396f100e96a3ebe686125d824 Mon Sep 17 00:00:00 2001 From: Kevin Papst Date: Wed, 29 Jan 2020 15:18:10 +0100 Subject: [PATCH] better handling of custom field columns in tables (#1419) --- src/Controller/DoctorController.php | 4 +++- templates/activity/index.html.twig | 4 ++-- templates/customer/index.html.twig | 4 ++-- templates/doctor/index.html.twig | 14 +++++++++++--- templates/project/index.html.twig | 4 ++-- templates/user/index.html.twig | 4 ++-- 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Controller/DoctorController.php b/src/Controller/DoctorController.php index 88b74575..cb316a08 100644 --- a/src/Controller/DoctorController.php +++ b/src/Controller/DoctorController.php @@ -175,8 +175,10 @@ class DoctorController extends AbstractController $result = []; - if ($iterator->valid()) { + try { $result = iterator_to_array($iterator); + } catch (\Exception $ex) { + $result = ['ATTENTION: Failed reading log file']; } if (!is_writable($logfile)) { diff --git a/templates/activity/index.html.twig b/templates/activity/index.html.twig index d32d45b4..94f12533 100644 --- a/templates/activity/index.html.twig +++ b/templates/activity/index.html.twig @@ -12,7 +12,7 @@ } %} {% for field in metaColumns %} {% set columns = columns|merge({ - ('mf_' ~ field.name): {'title': field.label, 'class': 'hidden-xs hidden-sm', 'orderBy': false} + ('mf_' ~ field.name): {'title': field.label|trans, 'class': 'hidden-xs hidden-sm', 'orderBy': false} }) %} {% endfor %} {% if showVisibility %} @@ -58,7 +58,7 @@ {{ entry.comment|comment2html }} {% for field in metaColumns %} - + {{ tables.datatable_meta_column(entry, field) }} {% endfor %} diff --git a/templates/customer/index.html.twig b/templates/customer/index.html.twig index 71fb7939..42db1db7 100644 --- a/templates/customer/index.html.twig +++ b/templates/customer/index.html.twig @@ -11,7 +11,7 @@ } %} {% for field in metaColumns %} {% set columns = columns|merge({ - ('mf_' ~ field.name): {'title': field.label, 'class': 'hidden-xs hidden-sm', 'orderBy': false} + ('mf_' ~ field.name): {'title': field.label|trans, 'class': 'hidden-xs hidden-sm', 'orderBy': false} }) %} {% endfor %} {% set columns = columns|merge({ @@ -52,7 +52,7 @@ {{ entry.comment|comment2html }} {% for field in metaColumns %} - + {{ tables.datatable_meta_column(entry, field) }} {% endfor %} diff --git a/templates/doctor/index.html.twig b/templates/doctor/index.html.twig index 19f43c56..fa5bec56 100644 --- a/templates/doctor/index.html.twig +++ b/templates/doctor/index.html.twig @@ -83,9 +83,17 @@ {% if logSize > 52428800 %}

Your logfile is larger than 50 MB, consider deleting it (it will be re-created automatically).

{% endif %} -
{% for logLine in logs %}
-                {{- logLine -}}
-            {% endfor %}
+
{% for logLine in logs -%}
+                {%- set logLineClass = '' -%}
+                {%- if '.CRITICAL' in logLine -%}
+                    {%- set logLineClass = 'text-danger text-bold' -%}
+                {%- elseif '.ERROR' in logLine -%}
+                    {%- set logLineClass = 'text-warning text-bold' -%}
+                {%- elseif '.DEBUG' in logLine -%}
+                    {%- set logLineClass = 'text-muted' -%}
+                {%- endif -%}
+                {{- logLine -}}
+            {%- endfor %}
{% endblock %} {% endembed %} diff --git a/templates/project/index.html.twig b/templates/project/index.html.twig index 30f282bf..4038358f 100644 --- a/templates/project/index.html.twig +++ b/templates/project/index.html.twig @@ -12,7 +12,7 @@ } %} {% for field in metaColumns %} {% set columns = columns|merge({ - ('mf_' ~ field.name): {'title': field.label, 'class': 'hidden-xs hidden-sm', 'orderBy': false} + ('mf_' ~ field.name): {'title': field.label|trans, 'class': 'hidden-xs hidden-sm', 'orderBy': false} }) %} {% endfor %} {% set columns = columns|merge({ @@ -52,7 +52,7 @@ {{ entry.comment|comment2html() }} {% for field in metaColumns %} - + {{ tables.datatable_meta_column(entry, field) }} {% endfor %} diff --git a/templates/user/index.html.twig b/templates/user/index.html.twig index 37b2ae93..a8756d52 100644 --- a/templates/user/index.html.twig +++ b/templates/user/index.html.twig @@ -14,7 +14,7 @@ }) %} {% for pref in preferences %} {% set columns = columns|merge({ - ('mf_' ~ pref.name): {'title': pref.label, 'class': 'hidden-xs hidden-sm', 'orderBy': false} + ('mf_' ~ pref.name): {'title': pref.label|trans, 'class': 'hidden-xs hidden-sm', 'orderBy': false} }) %} {% endfor %} {% set columns = columns|merge({ @@ -59,7 +59,7 @@ {% endfor %} {% for pref in preferences %} - + {% set metaField = entry.preference(pref.name) %} {% if not metaField is null and metaField.value is not null and metaField.value is not empty %} {{ widgets.form_type_value(pref.type, metaField.value, entry) }}