mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
parent
ef2d198328
commit
1733d6d520
@ -63,6 +63,8 @@ before switching to a new version.
|
|||||||
* FEATURE: Preserve _override_servicevars on sync, even when replacing vars (#1307)
|
* FEATURE: Preserve _override_servicevars on sync, even when replacing vars (#1307)
|
||||||
|
|
||||||
### Internals
|
### Internals
|
||||||
|
* FIX: problems related to users working from different time zones have been
|
||||||
|
fixed (#1270, #1332)
|
||||||
* FEATURE: Html/Attribute now allows boolean properties
|
* FEATURE: Html/Attribute now allows boolean properties
|
||||||
* FEATURE: Html/Attribute allows colons in attribute names (required for SVGs)
|
* FEATURE: Html/Attribute allows colons in attribute names (required for SVGs)
|
||||||
* FEATURE: Html/Attributes can be prefixed (helps with data-*)
|
* FEATURE: Html/Attributes can be prefixed (helps with data-*)
|
||||||
|
@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director;
|
namespace Icinga\Module\Director;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use DateTimeZone;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use Icinga\Data\ResourceFactory;
|
||||||
|
use Icinga\Exception\ConfigurationError;
|
||||||
use Icinga\Module\Director\Data\Db\DbConnection;
|
use Icinga\Module\Director\Data\Db\DbConnection;
|
||||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Exception\ConfigurationError;
|
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Zend_Db_Expr;
|
use Zend_Db_Expr;
|
||||||
use Zend_Db_Select;
|
use Zend_Db_Select;
|
||||||
@ -47,6 +50,44 @@ class Db extends DbConnection
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function fromResourceName($name)
|
||||||
|
{
|
||||||
|
$connection = new static(ResourceFactory::getResourceConfig($name));
|
||||||
|
|
||||||
|
if ($connection->isMysql()) {
|
||||||
|
$connection->setClientTimezoneForMysql();
|
||||||
|
} elseif ($connection->isPgsql()) {
|
||||||
|
$connection->setClientTimezoneForPgsql();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTimezoneOffset()
|
||||||
|
{
|
||||||
|
$tz = new DateTimeZone(date_default_timezone_get());
|
||||||
|
$offset = $tz->getOffset(new DateTime());
|
||||||
|
$prefix = $offset >= 0 ? '+' : '-';
|
||||||
|
$offset = abs($offset);
|
||||||
|
|
||||||
|
$hours = (int) floor($offset / 3600);
|
||||||
|
$minutes = (int) floor(($offset % 3600) / 60);
|
||||||
|
|
||||||
|
return sprintf('%s%d:%02d', $prefix, $hours, $minutes);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setClientTimezoneForMysql()
|
||||||
|
{
|
||||||
|
$db = $this->getDbAdapter();
|
||||||
|
$db->query($db->quoteInto('SET time_zone = ?', $this->getTimezoneOffset()));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setClientTimezoneForPgsql()
|
||||||
|
{
|
||||||
|
$db = $this->getDbAdapter();
|
||||||
|
$db->query($db->quoteInto('SET TIME ZONE INTERVAL ? HOUR TO MINUTE', $this->getTimezoneOffset()));
|
||||||
|
}
|
||||||
|
|
||||||
public function countActivitiesSinceLastDeployedConfig(IcingaObject $object = null)
|
public function countActivitiesSinceLastDeployedConfig(IcingaObject $object = null)
|
||||||
{
|
{
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
@ -226,6 +267,7 @@ class Db extends DbConnection
|
|||||||
{
|
{
|
||||||
$sql = 'SELECT id, object_type, object_name, action_name,'
|
$sql = 'SELECT id, object_type, object_name, action_name,'
|
||||||
. ' old_properties, new_properties, author, change_time,'
|
. ' old_properties, new_properties, author, change_time,'
|
||||||
|
. ' UNIX_TIMESTAMP(change_time) AS change_time_ts,'
|
||||||
. ' %s AS checksum, %s AS parent_checksum'
|
. ' %s AS checksum, %s AS parent_checksum'
|
||||||
. ' FROM director_activity_log WHERE id = %d';
|
. ' FROM director_activity_log WHERE id = %d';
|
||||||
|
|
||||||
@ -270,6 +312,7 @@ class Db extends DbConnection
|
|||||||
|
|
||||||
$sql = 'SELECT id, object_type, object_name, action_name,'
|
$sql = 'SELECT id, object_type, object_name, action_name,'
|
||||||
. ' old_properties, new_properties, author, change_time,'
|
. ' old_properties, new_properties, author, change_time,'
|
||||||
|
. ' UNIX_TIMESTAMP(change_time) AS change_time_ts,'
|
||||||
. ' %s AS checksum, %s AS parent_checksum'
|
. ' %s AS checksum, %s AS parent_checksum'
|
||||||
. ' FROM director_activity_log WHERE checksum = ?';
|
. ' FROM director_activity_log WHERE checksum = ?';
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class DirectorActivityLog extends DbObject
|
|||||||
'author' => static::username(),
|
'author' => static::username(),
|
||||||
'object_type' => $type,
|
'object_type' => $type,
|
||||||
'new_properties' => $newProps,
|
'new_properties' => $newProps,
|
||||||
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
|
'change_time' => date('Y-m-d H:i:s'),
|
||||||
'parent_checksum' => $db->getLastActivityChecksum()
|
'parent_checksum' => $db->getLastActivityChecksum()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ class DirectorActivityLog extends DbObject
|
|||||||
'object_type' => $type,
|
'object_type' => $type,
|
||||||
'old_properties' => $oldProps,
|
'old_properties' => $oldProps,
|
||||||
'new_properties' => $newProps,
|
'new_properties' => $newProps,
|
||||||
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
|
'change_time' => date('Y-m-d H:i:s'),
|
||||||
'parent_checksum' => $db->getLastActivityChecksum()
|
'parent_checksum' => $db->getLastActivityChecksum()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ class DirectorActivityLog extends DbObject
|
|||||||
'author' => static::username(),
|
'author' => static::username(),
|
||||||
'object_type' => $type,
|
'object_type' => $type,
|
||||||
'old_properties' => $oldProps,
|
'old_properties' => $oldProps,
|
||||||
'change_time' => date('Y-m-d H:i:s'), // TODO -> postgres!
|
'change_time' => date('Y-m-d H:i:s'),
|
||||||
'parent_checksum' => $db->getLastActivityChecksum()
|
'parent_checksum' => $db->getLastActivityChecksum()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Web\Table;
|
|||||||
|
|
||||||
use dipl\Html\Link;
|
use dipl\Html\Link;
|
||||||
use dipl\Web\Table\ZfQueryBasedTable;
|
use dipl\Web\Table\ZfQueryBasedTable;
|
||||||
|
use Icinga\Date\DateFormatter;
|
||||||
|
|
||||||
class DeploymentLogTable extends ZfQueryBasedTable
|
class DeploymentLogTable extends ZfQueryBasedTable
|
||||||
{
|
{
|
||||||
@ -33,7 +34,7 @@ class DeploymentLogTable extends ZfQueryBasedTable
|
|||||||
'director/deployment',
|
'director/deployment',
|
||||||
['id' => $row->id]
|
['id' => $row->id]
|
||||||
)),
|
)),
|
||||||
$this::td(strftime('%H:%M:%S', $row->start_time))
|
$this::td(DateFormatter::formatTime($row->start_time))
|
||||||
])->addAttributes(['class' => $this->getMyRowClasses($row)]);
|
])->addAttributes(['class' => $this->getMyRowClasses($row)]);
|
||||||
|
|
||||||
return $tr;
|
return $tr;
|
||||||
|
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Web\Widget;
|
|||||||
|
|
||||||
use dipl\Html\HtmlDocument;
|
use dipl\Html\HtmlDocument;
|
||||||
use dipl\Html\HtmlElement;
|
use dipl\Html\HtmlElement;
|
||||||
|
use Icinga\Date\DateFormatter;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Module\Director\ConfigDiff;
|
use Icinga\Module\Director\ConfigDiff;
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
@ -380,7 +381,9 @@ class ActivityLogInfo extends HtmlDocument
|
|||||||
$table = new NameValueTable();
|
$table = new NameValueTable();
|
||||||
$table->addNameValuePairs([
|
$table->addNameValuePairs([
|
||||||
$this->translate('Author') => $entry->author,
|
$this->translate('Author') => $entry->author,
|
||||||
$this->translate('Date') => $entry->change_time,
|
$this->translate('Date') => DateFormatter::formatDateTime(
|
||||||
|
$entry->change_time_ts
|
||||||
|
),
|
||||||
|
|
||||||
]);
|
]);
|
||||||
if (null === $this->name) {
|
if (null === $this->name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user