diff --git a/application/controllers/HistoryController.php b/application/controllers/HistoryController.php index 28574667..6a270b4d 100644 --- a/application/controllers/HistoryController.php +++ b/application/controllers/HistoryController.php @@ -12,10 +12,14 @@ use Icinga\Module\Icingadb\Web\Control\SearchBar\ObjectSuggestions; use Icinga\Module\Icingadb\Web\Control\ViewModeSwitcher; use Icinga\Module\Icingadb\Web\Controller; 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 { @@ -93,6 +97,14 @@ class HistoryController extends Controller 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); @@ -113,6 +125,7 @@ class HistoryController extends Controller 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 1bb85b0d..5f029270 100644 --- a/public/css/common.less +++ b/public/css/common.less @@ -314,3 +314,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 8a47efc5..084bd532 100644 --- a/public/js/action-list.js +++ b/public/js/action-list.js @@ -644,6 +644,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(); });