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

View file

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