syncrule/history: dedicated view, show/link actions
This commit is contained in:
parent
65b28fc2f6
commit
68215da96c
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Controllers;
|
|||
|
||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||
use Icinga\Module\Director\Objects\SyncRule;
|
||||
use Icinga\Module\Director\Objects\SyncRun;
|
||||
use Icinga\Module\Director\Import\Sync;
|
||||
use Icinga\Data\Filter\Filter;
|
||||
use Icinga\Web\Notification;
|
||||
|
@ -120,7 +121,17 @@ class SyncruleController extends ActionController
|
|||
->enforceFilter(Filter::where('rule_id', $id))
|
||||
->setConnection($this->db());
|
||||
|
||||
$this->setViewScript('list/table');
|
||||
if ($runId = $this->params->get('run_id')) {
|
||||
$db = $this->db();
|
||||
$this->view->run = SyncRun::load($runId, $db);
|
||||
$this->view->formerId = $db->fetchActivityLogIdByChecksum(
|
||||
$this->view->run->last_former_activity
|
||||
);
|
||||
|
||||
$this->view->lastId = $db->fetchActivityLogIdByChecksum(
|
||||
$this->view->run->last_related_activity
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected function prepareRuleTabs($ruleId = null)
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1><?= $this->escape($this->title) ?></h1>
|
||||
<span<?php if (! $this->stayHere): ?> data-base-target="_next"<?php endif ?>>
|
||||
<?= $this->addLink ?>
|
||||
</span>
|
||||
<?= $this->filterEditor ?>
|
||||
<?= $this->table->getPaginator() ?>
|
||||
</div>
|
||||
|
||||
<div class="content"<?php if (! $this->stayHere): ?> data-base-target="_next"<?php endif ?>>
|
||||
<?php if ($this->run): ?>
|
||||
<h3><?= $this->translate('Sync run details') ?></h3>
|
||||
<table class="key-value-table">
|
||||
<tr>
|
||||
<th><?= $this->translate('Start time') ?></th>
|
||||
<td><?= $this->escape($run->start_time) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Duration') ?></th>
|
||||
<td><?= sprintf('%.2fs', $run->duration_ms / 1000) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?= $this->translate('Activity') ?></th>
|
||||
<td data-base-target="_next"><?php
|
||||
$total = $run->objects_deleted + $run->objects_created + $run->objects_modified;
|
||||
if ($total === 0) {
|
||||
echo $this->translate('No changes have been made');
|
||||
} else {
|
||||
if ($total === 1) {
|
||||
echo $this->translate('One object has been modified');
|
||||
} else {
|
||||
printf(
|
||||
$this->translate('%s objects have been modified'),
|
||||
$total
|
||||
);
|
||||
}
|
||||
|
||||
$activityUrl = sprintf(
|
||||
'director/config/activities?id>%d&id<=%d',
|
||||
$formerId,
|
||||
$lastId
|
||||
);
|
||||
|
||||
$links = array();
|
||||
if ($run->objects_created > 0) {
|
||||
$links[] = $this->qlink(
|
||||
sprintf('%d created', $run->objects_created),
|
||||
$activityUrl,
|
||||
array('action_name' => 'create')
|
||||
);
|
||||
}
|
||||
if ($run->objects_modified > 0) {
|
||||
$links[] = $this->qlink(
|
||||
sprintf('%d modified', $run->objects_modified),
|
||||
$activityUrl,
|
||||
array('action_name' => 'modify')
|
||||
);
|
||||
}
|
||||
if ($run->objects_deleted > 0) {
|
||||
$links[] = $this->qlink(
|
||||
sprintf('%d deleted', $run->objects_deleted),
|
||||
$activityUrl,
|
||||
array('action_name' => 'delete')
|
||||
);
|
||||
}
|
||||
|
||||
if (count($links) > 1) {
|
||||
$links[] = $this->qlink(
|
||||
'Show all actions',
|
||||
$activityUrl
|
||||
);
|
||||
}
|
||||
|
||||
if (! empty($links)) {
|
||||
echo ': ' . implode(', ', $links);
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif ?>
|
||||
<?= $this->table->render() ?>
|
||||
</div>
|
Loading…
Reference in New Issue