ActivityLogTable: friendlier layout, show days
This commit is contained in:
parent
382e615f02
commit
102925ee84
|
@ -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 = "<thead>\n <tr>\n";
|
||||
} else {
|
||||
$htm = "</tbody>\n<thead>\n <tr>\n";
|
||||
}
|
||||
|
||||
if ($this->columnCount === null) {
|
||||
$this->columnCount = count($this->getTitles());
|
||||
}
|
||||
|
||||
$htm .= '<th colspan="' . $this->columnCount . '">' . $this->view()->escape($day) . '</th>' . "\n";
|
||||
if ($this->lastDay === null) {
|
||||
$htm .= " </tr>\n";
|
||||
} else {
|
||||
$htm .= " </tr>\n</thead>\n";
|
||||
}
|
||||
|
||||
$this->lastDay = $day;
|
||||
|
||||
return $htm . "<tbody>\n";
|
||||
}
|
||||
|
||||
public function filterObject($type, $name)
|
||||
{
|
||||
$this->filters[] = array('l.object_type = ?', $type);
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue