From b109cfc3bcf613de5b5d044deb3b78b7f1f7a8e9 Mon Sep 17 00:00:00 2001 From: Johannes Goslar <jogo@kronberger-spiele.de> Date: Thu, 1 Jun 2017 18:22:31 +0200 Subject: [PATCH] [TASK] SystemInformationMenu: Automatically refresh counter badge Automatically reload the SystemInformation every 5 minutes. Resolves: #68920 Releases: master, 8.7 Change-Id: Ie21d345d6bcbbae30f0fd77f084c22b1b2a0f6f2 Reviewed-on: https://review.typo3.org/53001 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Johannes Goslar <jogo@kronberger-spiele.de> Reviewed-by: Sascha Egerer <sascha@sascha-egerer.de> Tested-by: Sascha Egerer <sascha@sascha-egerer.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch> --- .../Toolbar/SystemInformationMenu.js | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/SystemInformationMenu.js b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/SystemInformationMenu.js index b3bb52e8d14b..5421ca4fe970 100644 --- a/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/SystemInformationMenu.js +++ b/typo3/sysext/backend/Resources/Public/JavaScript/Toolbar/SystemInformationMenu.js @@ -45,6 +45,11 @@ define([ $(SystemInformationMenu.identifier.moduleLinks).on('click', SystemInformationMenu.openModule); }; + /** + * Timer for auto reloading the SystemInformation + */ + SystemInformationMenu.timer = null; + /** * Updates the menu */ @@ -53,9 +58,9 @@ define([ $existingIcon = $toolbarItemIcon.clone(), $menuContainer = $(SystemInformationMenu.identifier.containerSelector).find(SystemInformationMenu.identifier.menuContainerSelector); - // hide the menu if it's active - if ($menuContainer.is(':visible')) { - $menuContainer.click(); + if (SystemInformationMenu.timer !== null) { + clearTimeout(SystemInformationMenu.timer); + SystemInformationMenu.timer = null; } Icons.getIcon('spinner-circle-light', Icons.sizes.small).done(function(spinner) { @@ -64,6 +69,9 @@ define([ $.ajax({ url: TYPO3.settings.ajaxUrls['systeminformation_render'], + data: { + skipSessionUpdate: 1 + }, type: 'post', cache: false, success: function(data) { @@ -73,6 +81,12 @@ define([ SystemInformationMenu.initialize(); } + }).done(function(){ + // reload error data every five minutes + SystemInformationMenu.timer = setTimeout( + SystemInformationMenu.updateMenu, + 1000 * 300 + ); }); }; @@ -86,10 +100,14 @@ define([ badgeClass = $container.data('severityclass'); $counter.text(count).toggle(parseInt(count) > 0); - $counter.removeClass(); + // ensure all default classes are available and previous + // (at this time in processing unknown) class is removed + $counter.removeClass(); + $counter.addClass('t3js-systeminformation-counter toolbar-item-badge badge'); + // badgeClass e.g. could be 'badge-info', 'badge-danger', ... if (badgeClass !== '') { - $counter.addClass('toolbar-item-badge badge ' + badgeClass); + $counter.addClass(badgeClass); } }; -- GitLab