mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
parent
994030260a
commit
428a49f433
@ -622,6 +622,13 @@ abstract class QuickForm extends QuickBaseForm
|
|||||||
$post = $req->getPost();
|
$post = $req->getPost();
|
||||||
$this->hasBeenSent = array_key_exists(self::ID, $post) &&
|
$this->hasBeenSent = array_key_exists(self::ID, $post) &&
|
||||||
$post[self::ID] === $this->getName();
|
$post[self::ID] === $this->getName();
|
||||||
|
|
||||||
|
if (
|
||||||
|
$this->hasBeenSent
|
||||||
|
&& (! isset($post[self::CSRF]) || ! CsrfToken::isValid($post[self::CSRF]))
|
||||||
|
) {
|
||||||
|
die('Invalid CSRF token provided');
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->hasBeenSent = false;
|
$this->hasBeenSent = false;
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Web\Table;
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
use gipfl\Format\LocalTimeFormat;
|
use DateTime;
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
|
||||||
use Icinga\Module\Director\Auth\Permission;
|
use Icinga\Module\Director\Auth\Permission;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
|
use IntlDateFormatter;
|
||||||
use ipl\Html\Html;
|
use ipl\Html\Html;
|
||||||
use ipl\Html\HtmlElement;
|
use ipl\Html\HtmlElement;
|
||||||
|
|
||||||
class ActivityLogTable extends ZfQueryBasedTable
|
class ActivityLogTable extends IntlZfQueryBasedTable
|
||||||
{
|
{
|
||||||
protected $filters = [];
|
protected $filters = [];
|
||||||
|
|
||||||
@ -28,9 +28,6 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||||||
'object_type',
|
'object_type',
|
||||||
];
|
];
|
||||||
|
|
||||||
/** @var LocalTimeFormat */
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
protected $ranges = [];
|
protected $ranges = [];
|
||||||
|
|
||||||
/** @var ?object */
|
/** @var ?object */
|
||||||
@ -45,7 +42,6 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||||||
public function __construct($db)
|
public function __construct($db)
|
||||||
{
|
{
|
||||||
parent::__construct($db);
|
parent::__construct($db);
|
||||||
$this->timeFormat = new LocalTimeFormat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function assemble()
|
public function assemble()
|
||||||
@ -97,7 +93,9 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||||||
if (! $this->hasObjectFilter) {
|
if (! $this->hasObjectFilter) {
|
||||||
$columns[] = $this->makeRangeInfo($row->id);
|
$columns[] = $this->makeRangeInfo($row->id);
|
||||||
}
|
}
|
||||||
$columns[] = $this::td($this->timeFormat->getTime($row->ts_change_time));
|
|
||||||
|
|
||||||
|
$columns[] = $this::td($this->getTime($row->ts_change_time));
|
||||||
|
|
||||||
return $this::tr($columns)->addAttributes(['class' => $action]);
|
return $this::tr($columns)->addAttributes(['class' => $action]);
|
||||||
}
|
}
|
||||||
@ -108,7 +106,7 @@ class ActivityLogTable extends ZfQueryBasedTable
|
|||||||
*/
|
*/
|
||||||
protected function renderDayIfNew($timestamp)
|
protected function renderDayIfNew($timestamp)
|
||||||
{
|
{
|
||||||
$day = $this->getDateFormatter()->getFullDay($timestamp);
|
$day = $this->getDateFormatter()->format((new DateTime())->setTimestamp($timestamp));
|
||||||
|
|
||||||
if ($this->lastDay !== $day) {
|
if ($this->lastDay !== $day) {
|
||||||
$this->nextHeader()->add(
|
$this->nextHeader()->add(
|
||||||
|
@ -4,13 +4,12 @@ namespace Icinga\Module\Director\Web\Table;
|
|||||||
|
|
||||||
use ipl\Html\Html;
|
use ipl\Html\Html;
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
|
||||||
use Icinga\Date\DateFormatter;
|
use Icinga\Date\DateFormatter;
|
||||||
use Icinga\Module\Director\Core\Json;
|
use Icinga\Module\Director\Core\Json;
|
||||||
use Icinga\Module\Director\DirectorObject\Automation\Basket;
|
use Icinga\Module\Director\DirectorObject\Automation\Basket;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
|
|
||||||
class BasketSnapshotTable extends ZfQueryBasedTable
|
class BasketSnapshotTable extends IntlZfQueryBasedTable
|
||||||
{
|
{
|
||||||
use DbHelper;
|
use DbHelper;
|
||||||
|
|
||||||
|
@ -2,16 +2,14 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Web\Table;
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
use gipfl\Format\LocalTimeFormat;
|
|
||||||
use Icinga\Module\Director\Auth\Permission;
|
use Icinga\Module\Director\Auth\Permission;
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
use Icinga\Module\Director\Db\Branch\BranchActivity;
|
use Icinga\Module\Director\Db\Branch\BranchActivity;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
|
||||||
use Ramsey\Uuid\UuidInterface;
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
|
||||||
class BranchActivityTable extends ZfQueryBasedTable
|
class BranchActivityTable extends IntlZfQueryBasedTable
|
||||||
{
|
{
|
||||||
protected $extraParams = [];
|
protected $extraParams = [];
|
||||||
|
|
||||||
@ -21,16 +19,12 @@ class BranchActivityTable extends ZfQueryBasedTable
|
|||||||
/** @var ?UuidInterface */
|
/** @var ?UuidInterface */
|
||||||
protected $objectUuid;
|
protected $objectUuid;
|
||||||
|
|
||||||
/** @var LocalTimeFormat */
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
protected $linkToObject = true;
|
protected $linkToObject = true;
|
||||||
|
|
||||||
public function __construct(UuidInterface $branchUuid, $db, UuidInterface $objectUuid = null)
|
public function __construct(UuidInterface $branchUuid, $db, UuidInterface $objectUuid = null)
|
||||||
{
|
{
|
||||||
$this->branchUuid = $branchUuid;
|
$this->branchUuid = $branchUuid;
|
||||||
$this->objectUuid = $objectUuid;
|
$this->objectUuid = $objectUuid;
|
||||||
$this->timeFormat = new LocalTimeFormat();
|
|
||||||
parent::__construct($db);
|
parent::__construct($db);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +40,7 @@ class BranchActivityTable extends ZfQueryBasedTable
|
|||||||
$activity = BranchActivity::fromDbRow($row);
|
$activity = BranchActivity::fromDbRow($row);
|
||||||
return $this::tr([
|
return $this::tr([
|
||||||
$this::td($this->makeBranchLink($activity))->setSeparator(' '),
|
$this::td($this->makeBranchLink($activity))->setSeparator(' '),
|
||||||
$this::td($this->timeFormat->getTime($ts))
|
$this::td($this->getTime($ts))
|
||||||
])->addAttributes(['class' => ['action-' . $activity->getAction(), 'branched']]);
|
])->addAttributes(['class' => ['action-' . $activity->getAction(), 'branched']]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,9 @@
|
|||||||
namespace Icinga\Module\Director\Web\Table;
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
|
||||||
use Icinga\Date\DateFormatter;
|
use Icinga\Date\DateFormatter;
|
||||||
|
|
||||||
class DeploymentLogTable extends ZfQueryBasedTable
|
class DeploymentLogTable extends IntlZfQueryBasedTable
|
||||||
{
|
{
|
||||||
use DbHelper;
|
use DbHelper;
|
||||||
|
|
||||||
|
51
library/Director/Web/Table/IntlZfQueryBasedTable.php
Normal file
51
library/Director/Web/Table/IntlZfQueryBasedTable.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
||||||
|
use IntlDateFormatter;
|
||||||
|
use Locale;
|
||||||
|
|
||||||
|
abstract class IntlZfQueryBasedTable extends ZfQueryBasedTable
|
||||||
|
{
|
||||||
|
protected function getDateFormatter()
|
||||||
|
{
|
||||||
|
return (new IntlDateFormatter(
|
||||||
|
Locale::getDefault(),
|
||||||
|
IntlDateFormatter::FULL,
|
||||||
|
IntlDateFormatter::NONE
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $timestamp
|
||||||
|
*/
|
||||||
|
protected function renderDayIfNew($timestamp)
|
||||||
|
{
|
||||||
|
$day = $this->getDateFormatter()->format((new DateTime())->setTimestamp($timestamp));
|
||||||
|
|
||||||
|
if ($this->lastDay !== $day) {
|
||||||
|
$this->nextHeader()->add(
|
||||||
|
$this::th($day, [
|
||||||
|
'colspan' => 2,
|
||||||
|
'class' => 'table-header-day'
|
||||||
|
])
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->lastDay = $day;
|
||||||
|
$this->nextBody();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getTime(int $timeStamp)
|
||||||
|
{
|
||||||
|
$timeFormatter = $this->getDateFormatter();
|
||||||
|
|
||||||
|
$timeFormatter->setPattern(
|
||||||
|
in_array(Locale::getDefault(), ['en_US', 'en_US.UTF-8']) ? 'h:mm:ss a': 'H:mm:ss'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $timeFormatter->format((new DateTime())->setTimestamp($timeStamp));
|
||||||
|
}
|
||||||
|
}
|
@ -2,22 +2,17 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Web\Table;
|
namespace Icinga\Module\Director\Web\Table;
|
||||||
|
|
||||||
use gipfl\Format\LocalTimeFormat;
|
|
||||||
use Icinga\Module\Director\Objects\SyncRule;
|
use Icinga\Module\Director\Objects\SyncRule;
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use gipfl\IcingaWeb2\Table\ZfQueryBasedTable;
|
|
||||||
|
|
||||||
class SyncRunTable extends ZfQueryBasedTable
|
class SyncRunTable extends IntlZfQueryBasedTable
|
||||||
{
|
{
|
||||||
/** @var SyncRule */
|
/** @var SyncRule */
|
||||||
protected $rule;
|
protected $rule;
|
||||||
|
|
||||||
protected $timeFormat;
|
|
||||||
|
|
||||||
public function __construct(SyncRule $rule)
|
public function __construct(SyncRule $rule)
|
||||||
{
|
{
|
||||||
parent::__construct($rule->getConnection());
|
parent::__construct($rule->getConnection());
|
||||||
$this->timeFormat = new LocalTimeFormat();
|
|
||||||
$this->getAttributes()
|
$this->getAttributes()
|
||||||
->set('data-base-target', '_self')
|
->set('data-base-target', '_self')
|
||||||
->add('class', 'history');
|
->add('class', 'history');
|
||||||
@ -31,7 +26,7 @@ class SyncRunTable extends ZfQueryBasedTable
|
|||||||
return $this::tr([
|
return $this::tr([
|
||||||
$this::td($this->makeSummary($row)),
|
$this::td($this->makeSummary($row)),
|
||||||
$this::td(new Link(
|
$this::td(new Link(
|
||||||
$this->timeFormat->getTime($time),
|
$this->getTime($time),
|
||||||
'director/syncrule/history',
|
'director/syncrule/history',
|
||||||
[
|
[
|
||||||
'id' => $row->rule_id,
|
'id' => $row->rule_id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user