mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 01:04:12 +02:00
show/activitylog: show object syntax, not props
This commit is contained in:
parent
7b1fda25bd
commit
632873595b
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
|
||||||
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
|
|
||||||
@ -14,6 +15,30 @@ class Director_ShowController extends ActionController
|
|||||||
$this->view->entry = $this->db()->fetchActivityLogEntry(Util::hex2binary($checksum));
|
$this->view->entry = $this->db()->fetchActivityLogEntry(Util::hex2binary($checksum));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entry = $this->view->entry;
|
||||||
|
|
||||||
|
if ($entry->old_properties) {
|
||||||
|
$old = $this->createObject($entry->object_type, $entry->old_properties);
|
||||||
|
if ($entry->new_properties) {
|
||||||
|
$new = $this->createObject($entry->object_type, $entry->old_properties);
|
||||||
|
$new->setProperties((array) json_decode($entry->new_properties));
|
||||||
|
} else {
|
||||||
|
$new = null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$old = null;
|
||||||
|
$new = $this->createObject($entry->object_type, $entry->new_properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->view->entry = $entry;
|
||||||
|
$this->view->newObject = $new;
|
||||||
|
$this->view->oldObject = $old;
|
||||||
$this->view->title = $this->translate('Activity');
|
$this->view->title = $this->translate('Activity');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function createObject($type, $props)
|
||||||
|
{
|
||||||
|
$props = json_decode($props);
|
||||||
|
return IcingaObject::createByType($type, (array) $props, $this->db());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,5 @@
|
|||||||
$entry->object_name
|
$entry->object_name
|
||||||
) ?></h2>
|
) ?></h2>
|
||||||
|
|
||||||
<h3><?= $this->translate('Properties') ?></h3>
|
<pre><?= $this->escape((string) $this->newObject) ?></pre>
|
||||||
|
|
||||||
<table class="log-properties">
|
|
||||||
<?php
|
|
||||||
$new = json_decode($entry->new_properties);
|
|
||||||
|
|
||||||
foreach ($new as $key => $value) {
|
|
||||||
if ($key === 'id') continue;
|
|
||||||
|
|
||||||
if ($value === null) continue;
|
|
||||||
|
|
||||||
if (is_array($value)) $value = implode(', ', $value);
|
|
||||||
if (is_object($value)) $value = json_encode($value);
|
|
||||||
|
|
||||||
echo ' <tr><th>' . $this->escape($key) . '</th><td>';
|
|
||||||
echo $this->escape($value);
|
|
||||||
echo "</td></tr>\n";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
@ -4,38 +4,14 @@
|
|||||||
$entry->object_name
|
$entry->object_name
|
||||||
) ?></h2>
|
) ?></h2>
|
||||||
|
|
||||||
<h3><?= $this->translate('Properties') ?></h3>
|
|
||||||
|
|
||||||
<table class="log-properties">
|
<table class="log-properties">
|
||||||
<?php
|
<!-- TODO: diff, old/new class -->
|
||||||
$old = json_decode($entry->old_properties);
|
<tr><td style="vertical-align: top; width: 50%">
|
||||||
$new = json_decode($entry->new_properties);
|
<h3><?= $this->translate('Former state') ?></h3>
|
||||||
|
<pre><?= $this->escape((string) $this->oldObject) ?></pre>
|
||||||
foreach ($old as $key => $value) {
|
</td><td style="vertical-align: top; width: 50%">
|
||||||
if ($key === 'id') continue;
|
<h3><?= $this->translate('New object') ?></h3>
|
||||||
|
<pre><?= $this->escape((string) $this->newObject) ?></pre>
|
||||||
$modified = array_key_exists($key, $new);
|
</td></tr>
|
||||||
|
|
||||||
if ($value === null && ! $modified) continue;
|
|
||||||
|
|
||||||
if (is_array($value)) $value = implode(', ', $value);
|
|
||||||
if (is_object($value)) $value = json_encode($value);
|
|
||||||
|
|
||||||
echo ' <tr><th>' . $this->escape($key) . '</th><td>';
|
|
||||||
if ($modified) {
|
|
||||||
$newval = $new->$key;
|
|
||||||
if (is_array($newval)) $newval = implode(', ', $newval);
|
|
||||||
if (is_object($newval)) $newval = json_encode($newval);
|
|
||||||
printf(
|
|
||||||
'<span class="old">%s</span> <span class="new">%s</span>',
|
|
||||||
$this->escape($value),
|
|
||||||
$this->escape($newval)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
echo $this->escape($value);
|
|
||||||
}
|
|
||||||
echo "</td></tr>\n";
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user