LSaddon::accesslog: improve displaying changes attributes values

This commit is contained in:
Benjamin Renard 2023-08-17 19:55:59 +02:00
parent 3a862ce93e
commit fa5b5ceb6d
Signed by: bn8
GPG key ID: 3E2E1CE1907115BC
3 changed files with 32 additions and 20 deletions

View file

@ -34,3 +34,7 @@ table.objectAccessLogs .col-value div {
margin: 0;
padding: 0;
}
table.objectAccessLogs tr.operation:hover {
font-weight: 600;
}

View file

@ -92,7 +92,6 @@ function mapAccessLogEntry(&$entry) {
foreach(LSldap::getAttr($attrs, 'reqMod', true) as $mod) {
if (preg_match('/^(?P<attr>[^\:]+)\:(?P<op>[^ ]?)( (?P<value>.*))?$/', $mod, $m)) {
$attr = $m['attr'];
$op = $m['op'];
$value = isset($m['value'])?$m['value']:null;
if (!array_key_exists($attr, $mods)) {
$mods[$attr] = array(
@ -100,13 +99,13 @@ function mapAccessLogEntry(&$entry) {
'old_values' => array(),
);
}
$mods[$attr]['changes'][] = array(
'op' => (
array_key_exists($op, $GLOBALS['accesslog_modOps'])?
_($GLOBALS['accesslog_modOps'][$op]): $op
),
'value' => $value,
$op = (
array_key_exists($m['op'], $GLOBALS['accesslog_modOps'])?
_($GLOBALS['accesslog_modOps'][$m['op']]): $m['op']
);
if (!array_key_exists($op, $mods[$attr]['changes']))
$mods[$attr]['changes'][$op] = array();
$mods[$attr]['changes'][$op][] = $value;
}
}
if (LSldap::getAttr($attrs, 'reqOld', true)) {

View file

@ -33,13 +33,14 @@
</thead>
<tbody>
{foreach $log.mods as $attr => $info}
<tr>
<td class="col-op center" {if count($info.changes)>1}rowspan={$info.changes|count}{/if}>{$info.changes.0.op|escape:htmlall}</td>
<td class="col-attr center" {if count($info.changes)>1}rowspan={$info.changes|count}{/if}>{$attr}</td>
<td class="col-value" {if count($info.changes)>1}rowspan={$info.changes|count}{/if}>
{foreach $info.changes as $op => $new_values}
<tr class="operation">
<td class="col-op center">{$op|escape:htmlall}</td>
<td class="col-attr center">{$attr}</td>
<td class="col-value">
{if $info.old_values}
<div class="copyable copyable-no-btn">
{if count($info.old_values) == 1}
{if count($info.old_values) == 1 && count($new_values) <= 1}
{$info.old_values[0]|escape:'htmlall'}
{else}
<ul>
@ -51,15 +52,23 @@
</div>
{/if}
</td>
<td class="col-value"><div class="copyable copyable-no-btn">{$info.changes.0.value|escape:htmlall}</div></td>
</tr>
{if count($info.changes) > 1}
{section name=change loop=$info.changes step=1 start=1}
<tr>
<td class="col-value"><div class="copyable copyable-no-btn">{$info.changes[change].value|escape:htmlall}</div></td>
</tr>
{/section}
<td class="col-value">
{if $new_values}
<div class="copyable copyable-no-btn">
{if count($new_values) == 1 && count($info.old_values) <= 1}
{$new_values[0]|escape:'htmlall'}
{else}
<ul>
{foreach $new_values as $new_value}
<li>{$new_value|escape:'htmlall'}</li>
{/foreach}
</ul>
{/if}
</div>
{/if}
</td>
</tr>
{/foreach}
{/foreach}
</tbody>
</table>