mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Move TimeAgo to ipl\Web\Widget
This commit is contained in:
parent
9e57d7f675
commit
3c4c1e7fc4
7 changed files with 6 additions and 43 deletions
|
|
@ -7,7 +7,7 @@ namespace Icinga\Module\Icingadb\Widget\Detail;
|
|||
use Icinga\Date\DateFormatter;
|
||||
use Icinga\Module\Icingadb\Widget\Card;
|
||||
use Icinga\Module\Icingadb\Widget\CheckAttempt;
|
||||
use Icinga\Module\Icingadb\Widget\TimeAgo;
|
||||
use ipl\Web\Widget\TimeAgo;
|
||||
use Icinga\Module\Icingadb\Widget\TimeSince;
|
||||
use Icinga\Module\Icingadb\Widget\TimeUntil;
|
||||
use Icinga\Module\Icingadb\Widget\VerticalKeyValue;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
namespace Icinga\Module\Icingadb\Widget\Detail;
|
||||
|
||||
use Icinga\Module\Icingadb\Model\Downtime;
|
||||
use Icinga\Module\Icingadb\Widget\TimeAgo;
|
||||
use ipl\Web\Widget\TimeAgo;
|
||||
use Icinga\Module\Icingadb\Widget\TimeUntil;
|
||||
use Icinga\Module\Icingadb\Widget\VerticalKeyValue;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ namespace Icinga\Module\Icingadb\Widget;
|
|||
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\Html;
|
||||
use ipl\Web\Widget\TimeAgo;
|
||||
|
||||
class Health extends BaseHtmlElement
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use Icinga\Module\Icingadb\Common\ObjectLinkDisabled;
|
|||
use Icinga\Module\Icingadb\Common\ServiceLink;
|
||||
use Icinga\Module\Icingadb\Model\Comment;
|
||||
use Icinga\Module\Icingadb\Common\BaseListItem;
|
||||
use Icinga\Module\Icingadb\Widget\TimeAgo;
|
||||
use ipl\Web\Widget\TimeAgo;
|
||||
use ipl\Html\Attributes;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\HtmlElement;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use Icinga\Module\Icingadb\Common\BaseListItem;
|
|||
use Icinga\Module\Icingadb\Widget\CheckAttempt;
|
||||
use Icinga\Module\Icingadb\Widget\PluginOutputContainer;
|
||||
use Icinga\Module\Icingadb\Widget\StateChange;
|
||||
use Icinga\Module\Icingadb\Widget\TimeAgo;
|
||||
use ipl\Web\Widget\TimeAgo;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\HtmlElement;
|
||||
use ipl\Html\Text;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use Icinga\Module\Icingadb\Util\PluginOutput;
|
|||
use Icinga\Module\Icingadb\Common\BaseListItem;
|
||||
use Icinga\Module\Icingadb\Widget\PluginOutputContainer;
|
||||
use Icinga\Module\Icingadb\Widget\StateChange;
|
||||
use Icinga\Module\Icingadb\Widget\TimeAgo;
|
||||
use ipl\Web\Widget\TimeAgo;
|
||||
use InvalidArgumentException;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
use ipl\Html\HtmlElement;
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
<?php
|
||||
|
||||
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
||||
|
||||
namespace Icinga\Module\Icingadb\Widget;
|
||||
|
||||
use Icinga\Date\DateFormatter;
|
||||
use ipl\Html\BaseHtmlElement;
|
||||
|
||||
/**
|
||||
* @TODO(el): Move to ipl-web
|
||||
*/
|
||||
class TimeAgo extends BaseHtmlElement
|
||||
{
|
||||
/** @var int */
|
||||
protected $ago;
|
||||
|
||||
protected $tag = 'time';
|
||||
|
||||
protected $defaultAttributes = ['class' => 'time-ago'];
|
||||
|
||||
public function __construct($ago)
|
||||
{
|
||||
$this->ago = (int) $ago;
|
||||
}
|
||||
|
||||
protected function assemble()
|
||||
{
|
||||
$dateTime = DateFormatter::formatDateTime($this->ago);
|
||||
|
||||
$this->addAttributes([
|
||||
'datetime' => $dateTime,
|
||||
'title' => $dateTime
|
||||
]);
|
||||
|
||||
$this->add(DateFormatter::timeAgo($this->ago));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue