From fbbab439483c24f4c51593d700cb4ae10a9017cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Fri, 5 Feb 2021 08:22:35 +0100 Subject: [PATCH] Improve backend module layout, remove buttons, add sysinfo --- .../SystemInformationToolbarItemExtension.php | 18 +++++---- .../Classes/Controller/BackendController.php | 40 +++---------------- .../Service/ContingentImportService.php | 11 ++--- .../Classes/Service/DateImportService.php | 17 ++------ .../Private/Templates/Backend/Index.html | 32 ++++++++------- 5 files changed, 42 insertions(+), 76 deletions(-) diff --git a/public/typo3conf/ext/ep_products/Classes/Backend/SystemInformationToolbarItemExtension.php b/public/typo3conf/ext/ep_products/Classes/Backend/SystemInformationToolbarItemExtension.php index ad0fbe29..6ecada96 100644 --- a/public/typo3conf/ext/ep_products/Classes/Backend/SystemInformationToolbarItemExtension.php +++ b/public/typo3conf/ext/ep_products/Classes/Backend/SystemInformationToolbarItemExtension.php @@ -2,21 +2,25 @@ namespace EP\EpProducts\Backend; +use EP\EpProducts\Service\ImportTimestampService; use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem as CoreSystemInformationToolbarItem; -use TYPO3\CMS\Core\Utility\GeneralUtility; class SystemInformationToolbarItemExtension { public function addBpnImportInformation(CoreSystemInformationToolbarItem $systemInformation) { - $updatedTimestampPath = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport/.lastupdate'); - if ($updatedTimestampPath && file_exists($updatedTimestampPath)) { - $updatedTimestamp = file_get_contents($updatedTimestampPath); - } + $timestampService = new ImportTimestampService(); + $productDataUpdatedTimestamp = $timestampService->readImportTimestamp('fileadmin/products_import.info'); + $contingentsDataUpdatedTimestamp = $timestampService->readImportTimestamp('fileadmin/contingents_import.info'); $systemInformation->addSystemInformation( - 'Letzer XML Abruf', - $updatedTimestamp ?: '-', + 'Letzer Produktdaten-Import', + $productDataUpdatedTimestamp ? $productDataUpdatedTimestamp->format('d.m.y H:i:s') : '-', + 'ep-logo' + ); + $systemInformation->addSystemInformation( + 'Letzer Kontingente Import', + $contingentsDataUpdatedTimestamp ? $contingentsDataUpdatedTimestamp->format('d.m.y H:i:s') : '-', 'ep-logo' ); } diff --git a/public/typo3conf/ext/ep_products/Classes/Controller/BackendController.php b/public/typo3conf/ext/ep_products/Classes/Controller/BackendController.php index 40550a27..c971f17e 100644 --- a/public/typo3conf/ext/ep_products/Classes/Controller/BackendController.php +++ b/public/typo3conf/ext/ep_products/Classes/Controller/BackendController.php @@ -68,10 +68,6 @@ class BackendController extends ActionController * @var ContingentImportService */ protected $contingentImportService; - /** - * @var ImportTimestampService - */ - private $importTimestampService; /** * @param DateImportService $dateImportService @@ -84,8 +80,7 @@ class BackendController extends ActionController DateImportService $dateImportService, ContingentImportService $contingentImportService, SnowreportImportService $snowreportService, - LogService $logService, - ImportTimestampService $importTimestampService + LogService $logService ) { parent::__construct(); @@ -94,40 +89,17 @@ class BackendController extends ActionController $this->contingentImportService = $contingentImportService; $this->snowreportImportService = $snowreportService; $this->logService = $logService; - $this->importTimestampService = $importTimestampService; } public function indexAction() { - $updatedTimestamp = $this->importTimestampService->readImportTimestamp('fileadmin/products_import.info'); + $timestampService = new ImportTimestampService(); - $this->view->assign('updatedTimestamp', $updatedTimestamp); - } + $productDataUpdatedTimestamp = $timestampService->readImportTimestamp('fileadmin/products_import.info'); + $contingentsDataUpdatedTimestamp = $timestampService->readImportTimestamp('fileadmin/contingents_import.info'); - public function importProductsAction() - { - $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexport'); - if ($this->dateImportService->checkActiveUpload($path)) { - $this->addFlashMessage( - 'Datenexport aus BusProNet aktiv. Import nicht möglich.', - 'Import fehlgeschlagen', - AbstractMessage::WARNING - ); - } else { - $dateCount = $this->dateImportService->import($path); - $this->addFlashMessage($dateCount . ' Termine importiert', 'Import abgechlossen', AbstractMessage::OK); - $resellerPageUid = $this->settings['resellerExportPageUid']; - $this->cacheService->clearPageCache($resellerPageUid); - } - $this->redirect('index'); - } - - public function importContingentsAction() - { - $path = GeneralUtility::getFileAbsFileName('fileadmin/xmlexportzimmer'); - $count = $this->contingentImportService->import($path); - $this->addFlashMessage($count . ' Datensätze importiert', 'Import abgechlossen', AbstractMessage::OK); - $this->redirect('index'); + $this->view->assign('productDataUpdatedTimestamp', $productDataUpdatedTimestamp); + $this->view->assign('contingentsDataUpdatedTimestamp', $contingentsDataUpdatedTimestamp); } public function importSnowReportAction() diff --git a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php index 872cdd99..84772f8c 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/ContingentImportService.php @@ -57,19 +57,14 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac * @var Connection */ protected $db; - /** - * @var ImportTimestampService - */ - private $importTimestampService; /** * @param ConfigurationManagerInterface $manager * @throws \Doctrine\DBAL\DBALException */ - public function __construct(ConfigurationManagerInterface $manager, ImportTimestampService $importTimestampService) + public function __construct(ConfigurationManagerInterface $manager) { $this->configurationManager = $manager; - $this->importTimestampService = $importTimestampService; $settings = GeneralUtility::removeDotsFromTS( $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) @@ -100,7 +95,9 @@ class ContingentImportService implements SingletonInterface, LoggerAwareInterfac public function isImportRequired(): bool { - return $this->importTimestampService->isImportRequired( + $timestampService = new ImportTimestampService(); + + return $timestampService->isImportRequired( 'fileadmin/xmlexportzimmer/uebertragung.info', 'fileadmin/contingents_import.info' ); diff --git a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php index d5e27804..02c7257b 100644 --- a/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php +++ b/public/typo3conf/ext/ep_products/Classes/Service/DateImportService.php @@ -85,11 +85,6 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface */ protected $cacheService; - /** - * @var ImportTimestampService - */ - private $importTimestampService; - /** * @var array */ @@ -101,15 +96,9 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface * @param ConfigurationManagerInterface $configurationManager * @param CacheService $cacheService */ - public function __construct - ( - ConfigurationManagerInterface $configurationManager, - CacheService $cacheService, - ImportTimestampService $importTimestampService - ) { + public function __construct(ConfigurationManagerInterface $configurationManager, CacheService $cacheService) { $this->configurationManager = $configurationManager; $this->cacheService = $cacheService; - $this->importTimestampService = $importTimestampService; $settings = GeneralUtility::removeDotsFromTS( $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT) @@ -145,7 +134,9 @@ class DateImportService implements SingletonInterface, LoggerAwareInterface public function isImportRequired(): bool { - return $this->importTimestampService->isImportRequired( + $timestampService = new ImportTimestampService(); + + return $timestampService->isImportRequired( 'fileadmin/xmlexport/uebertragung.info', 'fileadmin/products_import.info' ); diff --git a/public/typo3conf/ext/ep_products/Resources/Private/Templates/Backend/Index.html b/public/typo3conf/ext/ep_products/Resources/Private/Templates/Backend/Index.html index dddf8db0..a632d29b 100644 --- a/public/typo3conf/ext/ep_products/Resources/Private/Templates/Backend/Index.html +++ b/public/typo3conf/ext/ep_products/Resources/Private/Templates/Backend/Index.html @@ -7,21 +7,23 @@

E&P Funktionen

-

- Letzter automatischer XML Import: {f:if(condition: updatedTimestamp, then: '{updatedTimestamp -> f:format.date(format: \'d.m.Y H:i:s\')}', else: '-')} -

-

- - - Produktdaten aus BusProNet importieren - -

-

- - - Kontingentdaten aus BusProNet importieren - -

+
+
+

BusPro Daten

+
+
+

+ Letzter Produktdaten-Import: {f:if(condition: productDataUpdatedTimestamp, then: '{productDataUpdatedTimestamp -> f:format.date(format: \'d.m.Y H:i:s\')}', else: '-')} +

+

+ Letzter Kontingente-Import: {f:if(condition: contingentsDataUpdatedTimestamp, then: '{contingentsDataUpdatedTimestamp -> f:format.date(format: \'d.m.Y H:i:s\')}', else: '-')} +

+

+ Hinweis: TYPO3 prüft alle 15 Minuten, ob ein XML Upload aus BusPro erfolgt ist (automatisch + oder manuell) und führt sofort einen Import durch falls erforderlich. +

+
+