Commit 1439e979 authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Xavier Perseguers
Browse files

[FOLLOWUP][FEATURE] Introduce System Information dropdown item

* Do not render failed logins
* Render menu by AJAX call
* Add JavaScript method to invoke a reload of the menu

Related: #66234
Resolves: #65767
Releases: master
Change-Id: Ic3d3fcacbf86ad728c200cc3f2e103d138f33680
Reviewed-on: http://review.typo3.org/38434


Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: default avatarMarkus Klein <klein.t3@reelworx.at>
Reviewed-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
Tested-by: Xavier Perseguers's avatarXavier Perseguers <xavier@typo3.org>
parent a2e088c8
......@@ -18,6 +18,7 @@ use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\Utility\IconUtility;
use TYPO3\CMS\Core\Http\AjaxRequestHandler;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
......@@ -46,6 +47,13 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
*/
protected $highestSeverity = '';
/**
* The CSS class for the badge
*
* @var string
*/
protected $severityBadgeClass = '';
/**
* @var array
*/
......@@ -73,7 +81,12 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
$pageRenderer = $this->getPageRenderer();
$pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/SystemInformationMenu');
}
/**
* Collect the information for the menu
*/
protected function collectInformation() {
$this->getWebServer();
$this->getPhpVersion();
$this->getDatabase();
......@@ -83,6 +96,19 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
$this->emitGetSystemInformation();
$this->emitLoadMessages();
$this->severityBadgeClass = $this->highestSeverity !== InformationStatus::STATUS_NOTICE ? 'badge-' . $this->highestSeverity : '';
}
/**
* Renders the menu for AJAX calls
*
* @param array $params
* @param AjaxRequestHandler $ajaxObj
*/
public function renderAjax($params = array(), $ajaxObj) {
$this->collectInformation();
$ajaxObj->addContent('systemInformationMenu', $this->getDropDown());
}
/**
......@@ -240,13 +266,8 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
*/
public function getItem() {
$title = $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:toolbarItems.sysinfo', TRUE);
$item = IconUtility::getSpriteIcon('actions-system-list-open', array('title' => $title));
if ($this->totalCount > 0) {
$severityBadge = $this->highestSeverity !== InformationStatus::STATUS_NOTICE ? 'badge-' . $this->highestSeverity : '';
$item .= '<span id="t3js-systeminformation-counter" class="badge ' . $severityBadge . '">' . $this->totalCount . '</span>';
}
return $item;
return IconUtility::getSpriteIcon('actions-system-list-open', array('title' => $title))
. '<span id="t3js-systeminformation-counter" class="badge"></span>';
}
/**
......@@ -262,6 +283,8 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
$this->getStandaloneView('backend')->assignMultiple(array(
'installToolUrl' => BackendUtility::getModuleUrl('system_InstallInstall'),
'messages' => $this->systemMessages,
'count' => $this->totalCount,
'severityBadgeClass' => $this->severityBadgeClass,
'systemInformation' => $this->systemInformation
));
return $this->getStandaloneView()->render();
......@@ -345,4 +368,4 @@ class SystemInformationToolbarItem extends AbstractToolbarItem implements Toolba
return $this->signalSlotDispatcher;
}
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
<source>Application Information</source>
</trans-unit>
<trans-unit id="systemmessage.intro">
<source><![CDATA[This is a short system overview, for advanced information please head to the <a href="%s">Install Tool</a>.]]></source>
<source><![CDATA[This is a short system overview. For advanced information please head to the <a href="%s">Install Tool</a>.]]></source>
</trans-unit>
<trans-unit id="systemmessage.allgood" xml:space="preserve">
<source>Your system is fully operational.
......
<ul class="dropdown-list">
<ul class="dropdown-list" data-count="{count}" data-severityclass="{severityBadgeClass}">
<li class="dropdown-header"><f:translate key="systemmessage.header" /></li>
<li id="systeminformation_installtool" class="dropdown-intro typo3-module-menu-item submodule mod-system_InstallInstall" data-modulename="system_InstallInstall">
<f:translate key="systemmessage.intro" arguments="{0: '{installToolUrl}'}" />
......@@ -22,7 +22,7 @@
<f:if condition="{messages -> f:count()} > 0">
<f:then>
<f:for each="{messages}" as="message">
<li><span class="text-{message.status}">{message.text}</span></li>
<li><span class="text-{message.status}"><f:format.raw>{message.text}</f:format.raw></span></li>
</f:for>
</f:then>
<f:else>
......
......@@ -17,24 +17,60 @@
define('TYPO3/CMS/Backend/Toolbar/SystemInformationMenu', ['jquery'], function($) {
var SystemInformationMenu = {
identifier: {
containerSelector: '#typo3-cms-backend-backend-toolbaritems-systeminformationtoolbaritem',
toolbarIconSelector: '.dropdown-toggle span.t3-icon',
menuContainerSelector: '.dropdown-menu'
},
elements: {
$counter: $('#t3js-systeminformation-counter')
$counter: $('#t3js-systeminformation-counter'),
$spinnerElement: $('<span>', {
'class': 't3-icon fa fa-circle-o-notch spinner fa-spin'
})
}
};
/**
* register event handlers
* Updates the menu
*/
SystemInformationMenu.initializeEvents = function() {
var count = parseInt(SystemInformationMenu.elements.$counter.text());
SystemInformationMenu.elements.$counter.toggle(count > 0);
SystemInformationMenu.updateMenu = function() {
var $toolbarItemIcon = $(SystemInformationMenu.identifier.toolbarIconSelector, SystemInformationMenu.identifier.containerSelector),
$spinnerIcon = SystemInformationMenu.elements.$spinnerElement.clone(),
$existingIcon = $toolbarItemIcon.replaceWith($spinnerIcon);
$.ajax({
url: TYPO3.settings.ajaxUrls['SystemInformationMenu::load'],
type: 'post',
cache: false,
success: function(data) {
$(SystemInformationMenu.identifier.containerSelector).find(SystemInformationMenu.identifier.menuContainerSelector).html(data);
SystemInformationMenu.updateCounter();
$spinnerIcon.replaceWith($existingIcon);
}
})
};
/**
* Updates the counter
*/
SystemInformationMenu.updateCounter = function() {
var $ul = $(SystemInformationMenu.identifier.containerSelector).find(SystemInformationMenu.identifier.menuContainerSelector).find('ul'),
count = $ul.data('count'),
badgeClass = $ul.data('severityclass');
SystemInformationMenu.elements.$counter.text(count).toggle(count > 0);
SystemInformationMenu.elements.$counter.removeClass();
if (badgeClass !== '') {
SystemInformationMenu.elements.$counter.addClass('badge ' + badgeClass);
}
};
/**
* initialize and return the Opendocs object
* Initialize and return the SystemInformationMenu object
*/
$(document).ready(function() {
SystemInformationMenu.initializeEvents();
SystemInformationMenu.updateMenu();
});
TYPO3.SystemInformationMenu = SystemInformationMenu;
......
......@@ -24,8 +24,7 @@ class SystemInformationController extends AbstractController {
/**
* Modifies the SystemInformation array
*
* @param array $systemMessages Array of system messages
* @return
* @return NULL|array
*/
public function appendMessage() {
$constraint = $this->getConstraintFromBeUserData();
......@@ -35,7 +34,7 @@ class SystemInformationController extends AbstractController {
$this->setStartAndEndTimeFromTimeSelector($constraint);
// we can't use the extbase repository here as the required TypoScript may not be parsed yet
$count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $constraint->getStartTimestamp() . ' AND tstamp <= ' . $constraint->getEndTimestamp() . ' AND error IN(-1,1,2,3)');
$count = $this->getDatabaseConnection()->exec_SELECTcountRows('error', 'sys_log', 'tstamp >= ' . $constraint->getStartTimestamp() . ' AND tstamp <= ' . $constraint->getEndTimestamp() . ' AND error IN(-1,1,2)');
if ($count > 0) {
return array(
......
......@@ -355,7 +355,7 @@
<source>Time</source>
</trans-unit>
<trans-unit id="systemmessage.errorsInPeriod">
<source>We have found %1$d errors. Please check your administration log.</source>
<source>We have found %1$d errors. Please check your system log.</source>
</trans-unit>
</body>
</file>
......
......@@ -677,6 +677,10 @@ return array(
'callbackMethod' => \TYPO3\CMS\Backend\Backend\ToolbarItems\ShortcutToolbarItem::class . '->createAjaxShortcut',
'csrfTokenCheck' => TRUE
),
'SystemInformationMenu::load' => array(
'callbackMethod' => \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class . '->renderAjax',
'csrfTokenCheck' => TRUE
),
'ModuleMenu::reload' => array(
'callbackMethod' => \TYPO3\CMS\Backend\Controller\BackendController::class . '->getModuleMenuForReload',
'csrfTokenCheck' => TRUE
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment