Show last import time beside each import configuration in backend module (#77)

This commit is contained in:
Daniel Siepmann 2022-09-29 15:17:06 +02:00 committed by GitHub
parent 0ae738c1f2
commit 5447b95c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 4 deletions

View file

@ -26,6 +26,7 @@ namespace WerkraumMedia\ThueCat\Domain\Model\Backend;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
use WerkraumMedia\ThueCat\Domain\Import\Entity\Properties\ForeignReference;
use WerkraumMedia\ThueCat\Domain\Import\ImportConfiguration as ImportConfigurationInterface;
use WerkraumMedia\ThueCat\Domain\Import\ResolveForeignReference;
@ -52,6 +53,11 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI
*/
protected $tstamp = null;
/**
* @var ObjectStorage<ImportLog>
*/
protected $logs;
/**
* @var string[]|null
*/
@ -62,6 +68,11 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI
*/
protected $allowedTypes = [];
public function __construct()
{
$this->logs = new ObjectStorage();
}
public function getTitle(): string
{
return $this->title;
@ -82,6 +93,17 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI
return $this->tstamp;
}
public function getLastImported(): ?\DateTimeImmutable
{
$positionOfLastLog = count($this->logs) - 1;
$lastImport = $this->logs->offsetGet((string) $positionOfLastLog);
if (!$lastImport instanceof ImportLog) {
return null;
}
return $lastImport->getCreated();
}
public function getStoragePid(): int
{
if ($this->configuration === '') {

View file

@ -68,6 +68,15 @@ return (static function (string $extensionKey, string $tableName) {
'readOnly' => true,
],
],
// Configured for usage within Extbase, not TCA itself
'logs' => [
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_thuecat_import_log',
'foreign_field' => 'configuration',
'readOnly' => true,
],
],
],
'types' => [
'0' => [

View file

@ -9,7 +9,9 @@ Nothing
Features
--------
Add support for TYPO3 v11 and PHP 8.0 + 8.1.
* Add support for TYPO3 v11 and PHP 8.0 + 8.1.
* Last import date is now shown within backend module beside each import configuration.
Fixes
-----
@ -34,7 +36,7 @@ Fixes
Tasks
-----
Removed API Key from site configuration.
* Removed API Key from site configuration.
The key was already moved to extension configuration as documented.
Still we extended the site configuration, which is now cleaned up, see: https://github.com/werkraum-media/thuecat/issues/55

View file

@ -46,6 +46,12 @@
<trans-unit id="module.importConfigurations.lastChanged" xml:space="preserve">
<source>Last changed</source>
</trans-unit>
<trans-unit id="module.importConfigurations.lastImported" xml:space="preserve">
<source>Last imported</source>
</trans-unit>
<trans-unit id="module.importConfigurations.lastImported.never" xml:space="preserve">
<source>Never</source>
</trans-unit>
<trans-unit id="module.importConfigurations.missing.text" xml:space="preserve">
<source><![CDATA[No import configuration is available yet. Please <a href="%1$s">create the first</a> to get started.]]></source>
</trans-unit>

View file

@ -55,6 +55,7 @@
<tr>
<th>{f:translate(id: 'module.importConfigurations.title')}</th>
<th>{f:translate(id: 'module.importConfigurations.lastChanged')}</th>
<th>{f:translate(id: 'module.importConfigurations.lastImported')}</th>
<th>{f:translate(id: 'module.actions')}</th>
</tr>
</thead>
@ -63,6 +64,16 @@
<tr>
<td>{importConfiguration.title}</td>
<td>{importConfiguration.lastChanged -> f:format.date(format: 'd.m.Y H:i')}</td>
<td>
<f:if condition="{importConfiguration.lastImported}">
<f:then>
{importConfiguration.lastImported -> f:format.date(format: 'd.m.Y H:i')}
</f:then>
<f:else>
{f:translate(id: 'module.importConfigurations.lastImported.never')}
</f:else>
</f:if>
</td>
<td>
<f:link.editRecord
uid="{importConfiguration.uid}"

View file

@ -6,6 +6,7 @@ CREATE TABLE tx_thuecat_import_configuration (
title varchar(255) DEFAULT '' NOT NULL,
type varchar(255) DEFAULT '' NOT NULL,
configuration text,
logs int(11) unsigned DEFAULT '0' NOT NULL,
);
CREATE TABLE tx_thuecat_import_log (