From 01659f3505fe80cff34a3544fe656c500c844f3f Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 16 Mar 2016 22:45:29 +0100 Subject: [PATCH] config/activities: (un)deployed rows, icons, style --- application/controllers/ConfigController.php | 5 +++- application/tables/ActivityLogTable.php | 22 +++++++++++++++++- library/Director/Db.php | 14 ++++++++++++ public/css/module.less | 24 ++++++++++++++++---- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 2b7695da..f448b94d 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -85,7 +85,10 @@ class ConfigController extends ActionController $this->setAutorefreshInterval(10); $this->overviewTabs()->activate('activitylog'); $this->view->title = $this->translate('Activity Log'); - $this->prepareAndRenderTable('activityLog'); + $lastDeployedId = $this->db()->getLastDeploymentActivityLogId(); + $this->prepareTable('activityLog'); + $this->view->table->setLastDeployedId($lastDeployedId); + $this->render('list/table', null, true); } protected function fetchLogs() diff --git a/application/tables/ActivityLogTable.php b/application/tables/ActivityLogTable.php index b6e80346..58459574 100644 --- a/application/tables/ActivityLogTable.php +++ b/application/tables/ActivityLogTable.php @@ -8,6 +8,8 @@ class ActivityLogTable extends QuickTable { protected $filters = array(); + protected $lastDeployedId; + protected $extraParams = array(); public function getColumns() @@ -17,15 +19,33 @@ class ActivityLogTable extends QuickTable 'change_time' => 'l.change_time', 'author' => 'l.author', 'action' => "CONCAT(l.action_name || ' ' || REPLACE(l.object_type, 'icinga_', '')" - . " || ' \"' || l.object_name || '\"')" + . " || ' \"' || l.object_name || '\"')", + 'action_name' => 'l.action_name', ); } + public function setLastDeployedId($id) + { + $this->lastDeployedId = $id; + return $this; + } + protected function listTableClasses() { return array_merge(array('activity-log'), parent::listTableClasses()); } + protected function getRowClasses($row) + { + $action = 'action-' . $row->action_name . ' '; + + if ($row->id > $this->lastDeployedId) { + return $action . 'undeployed'; + } else { + return $action . 'deployed'; + } + } + protected function getActionUrl($row) { return $this->url( diff --git a/library/Director/Db.php b/library/Director/Db.php index df26ae1c..1d40b405 100644 --- a/library/Director/Db.php +++ b/library/Director/Db.php @@ -45,6 +45,20 @@ class Db extends DbConnection return (int) $db->fetchOne($query); } + // TODO: use running config?! + public function getLastDeploymentActivityLogId() + { + $db = $this->db(); + + $query = ' SELECT COALESCE(id, 0) AS id FROM director_activity_log WHERE checksum = (' + . ' SELECT last_activity_checksum FROM director_generated_config WHERE checksum = (' + . ' SELECT config_checksum FROM director_deployment_log ORDER by id desc limit 1' + . ' )' + . ')'; + + return (int) $db->fetchOne($query); + } + public function getMasterZoneName() { if ($zone = $this->getSetting('master_zone')) { diff --git a/public/css/module.less b/public/css/module.less index e0799e19..94584196 100644 --- a/public/css/module.less +++ b/public/css/module.less @@ -734,16 +734,30 @@ table.activity-log { } } - tr.deployed td:first-child::before { - // icon-ok + tr.action-create td:first-child::before { + // icon-plus + color: @color-pending; + content: '\e805'; + } + + tr.action-modify td:first-child::before { + // icon-wrench color: @color-ok; - content: '\e803'; + content: '\e83d'; + } + + tr.action-delete td:first-child::before { + // icon-cancel + color: @color-critical; + content: '\e804'; + } + + tr.undeployed td, tr.undeployed a { + font-weight: bold; } tr.undeployed td:first-child::before { color: @gray; - // icon-clock - content: '\e833'; } }