diff --git a/application/tables/ActivityLogTable.php b/application/tables/ActivityLogTable.php index 58459574..3e644b79 100644 --- a/application/tables/ActivityLogTable.php +++ b/application/tables/ActivityLogTable.php @@ -12,14 +12,22 @@ class ActivityLogTable extends QuickTable protected $extraParams = array(); + protected $lastDay; + + protected $columnCount; + + protected $isUsEnglish; + public function getColumns() { return array( 'id' => 'l.id', 'change_time' => 'l.change_time', + 'ts_change_time' => 'UNIX_TIMESTAMP(l.change_time)', 'author' => 'l.author', - 'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '')" - . " || ' \"' || l.object_name || '\"')", + 'action' => 'l.action_name', + 'log_message' => "'[' || l.author || '] ' || l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '')" + . " || ' \"' || l.object_name || '\"'", 'action_name' => 'l.action_name', ); } @@ -35,6 +43,12 @@ class ActivityLogTable extends QuickTable return array_merge(array('activity-log'), parent::listTableClasses()); } + protected function renderRow($row) + { + $row->change_time = strftime('%H:%M:%S', $row->ts_change_time); + return $this->renderDayIfNew($row) . parent::renderRow($row); + } + protected function getRowClasses($row) { $action = 'action-' . $row->action_name . ' '; @@ -58,12 +72,62 @@ class ActivityLogTable extends QuickTable { $view = $this->view(); return array( + // 'author' => $view->translate('Author'), + 'log_message' => $view->translate('Action'), 'change_time' => $view->translate('Timestamp'), - 'author' => $view->translate('Author'), - 'action' => $view->translate('Action'), ); } + protected function renderTitles($row) + { + return ''; + } + + protected function isUsEnglish() + { + if ($this->isUsEnglish === null) { + $this->isUsEnglish = in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C')); + } + + return $this->isUsEnglish; + } + + protected function renderDayIfNew($row) + { + $view = $this->view(); + + if ($this->isUsEnglish()) { + $day = date('l, jS F Y', (int) $row->ts_change_time); + } else { + $day = strftime('%A, %e. %B, %Y', (int) $row->ts_change_time); + } + + if ($this->lastDay === $day) { + return; + } + + if ($this->lastDay === null) { + $htm = "\n \n"; + } else { + $htm = "\n\n \n"; + } + + if ($this->columnCount === null) { + $this->columnCount = count($this->getTitles()); + } + + $htm .= '' . $this->view()->escape($day) . '' . "\n"; + if ($this->lastDay === null) { + $htm .= " \n"; + } else { + $htm .= " \n\n"; + } + + $this->lastDay = $day; + + return $htm . "\n"; + } + public function filterObject($type, $name) { $this->filters[] = array('l.object_type = ?', $type); diff --git a/public/css/module.less b/public/css/module.less index fe062f35..39b4b042 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -942,11 +942,19 @@ table.endpoints { } table.activity-log { + thead th { + text-align: right; + } tr th:first-child { padding-left: 2em; } + tr td:last-child { + text-align: right; + white-space: nowrap; + } + tr td:first-child { padding-left: 2em; &::before {