diff --git a/application/controllers/HistoryController.php b/application/controllers/HistoryController.php index 08a96889b..cfca10266 100644 --- a/application/controllers/HistoryController.php +++ b/application/controllers/HistoryController.php @@ -10,10 +10,14 @@ use Icinga\Module\Icingadb\Web\Controller; use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use Icinga\Module\Icingadb\Widget\ItemList\LoadMoreObjectList; +use ipl\Html\Attributes; +use ipl\Html\HtmlElement; use ipl\Stdlib\Filter; use ipl\Web\Control\LimitControl; use ipl\Web\Control\SortControl; use ipl\Web\Url; +use ipl\Web\Widget\ActionLink; +use ipl\Web\Widget\ButtonLink; class HistoryController extends Controller { @@ -89,6 +93,14 @@ public function indexAction() yield $this->export($history); + $this->addControl( + new ActionLink( + 'Scroll to top', + $this->getRequest()->getUrl() . '#page-1', + 'angles-up', + new Attributes(['class' => 'scroll-to-top']) + ) + ); $this->addControl($sortControl); $this->addControl($limitControl); $this->addControl($viewModeSwitcher); @@ -109,6 +121,7 @@ public function indexAction() if ($compact && $page > 1) { $this->document->addFrom($historyList); } else { + $this->addContent(new HtmlElement('span', new Attributes(['id' => 'page-1']))); $this->addContent($historyList); } diff --git a/public/css/common.less b/public/css/common.less index 2b21b271d..e378787ba 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -309,3 +309,21 @@ form[name="form_confirm_removal"] { opacity: .9; } } + +.scroll-to-top { + border-radius: .4em; + padding: .25em; + display: inline-flex; + align-items: baseline; +} + +.scroll-to-top:hover { + background: @control-hover-bg; + text-decoration: none; +} + +#page-1 { + display: block; + width: 1px; + margin: -1em 0 1em -1em; +} diff --git a/public/js/action-list.js b/public/js/action-list.js index d48739048..91ff7fbb5 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -643,6 +643,7 @@ // Set data-icinga-url to make it available for Icinga.History.getCurrentState() req.$target.closest('.container').data('icingaUrl', url); + req.$target.closest('.container').find('.controls .scroll-to-top').attr('href', url.split('#')[0] + '#page-1'); this.icinga.history.replaceCurrentState(); });