From 0b9c6062ed49f9f8067b280fa7a76d82834f6f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 16:59:11 +0100 Subject: [PATCH 01/26] [TASK] Add database table for tasks --- ext_tables.sql | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ext_tables.sql b/ext_tables.sql index 1e1d422..f897223 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -178,3 +178,16 @@ CREATE TABLE tx_t3monitoring_client_extension_mm ( KEY uid_local (uid_local), KEY uid_foreign (uid_foreign) ); + +# +# Table structure for table 'tx_t3monitoring_domain_model_task' +# +CREATE TABLE tx_t3monitoring_domain_model_task ( + description text NOT NULL, + client_task_uid int(11) NOT NULL, + nextexecution int(11) DEFAULT '0' NOT NULL, + lastexecution_time int(11) DEFAULT '0' NOT NULL, + lastexecution_failure text NOT NULL, + lastexecution_context varchar(10) DEFAULT '' NOT NULL, + client int(11) DEFAULT '0' NOT NULL +); \ No newline at end of file From 92c668a43bd4b46b44b1646e1cf73e079e5a2e4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 17:00:25 +0100 Subject: [PATCH 02/26] [TASK] Add model, TCA and repo --- Classes/Domain/Model/Task.php | 220 ++++++++++++++++++ Classes/Domain/Repository/TaskRepository.php | 13 ++ .../TCA/tx_t3monitoring_domain_model_task.php | 98 ++++++++ Resources/Private/Language/locallang.xlf | 27 +++ .../tx_t3monitoring_domain_model_task.svg | 2 + 5 files changed, 360 insertions(+) create mode 100644 Classes/Domain/Model/Task.php create mode 100644 Classes/Domain/Repository/TaskRepository.php create mode 100644 Configuration/TCA/tx_t3monitoring_domain_model_task.php create mode 100644 Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg diff --git a/Classes/Domain/Model/Task.php b/Classes/Domain/Model/Task.php new file mode 100644 index 0000000..9ab3435 --- /dev/null +++ b/Classes/Domain/Model/Task.php @@ -0,0 +1,220 @@ +clientTaskUid; + } + + /** + * Set the uid of the task on the client system. + * + * @param int $clientTaskUid The uid of the tasks on the client system. + * + * @return void + */ + public function setClientTaskUid(int $clientTaskUid): void + { + $this->clientTaskUid = $clientTaskUid; + } + + /** + * Get the task description. + * + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * Set the task description. + * + * @param string $description The task description. + * + * @return void + */ + public function setDescription(string $description): void + { + $this->description = $description; + } + + /** + * Get the next execution timestamp + * + * @return int + */ + public function getNextexecution(): int + { + return $this->nextexecution; + } + + /** + * Set the next execution timestamp + * + * @param int $nextexecution The next execution timestamp + * + * @return void + */ + public function setNextexecution(int $nextexecution): void + { + $this->nextexecution = $nextexecution; + } + + /** + * Get the last execution timestamp + * + * @return int + */ + public function getLastexecutionTimestamp(): int + { + return $this->lastexecutionTimestamp; + } + + /** + * Set the last execution timestamp + * + * @param int $lastexecutionTimestamp The last execution timestamp + * + * @return void + */ + public function setLastexecutionTimestamp(int $lastexecutionTimestamp): void + { + $this->lastexecutionTimestamp = $lastexecutionTimestamp; + } + + /** + * Get the last execution failure error message + * + * @return string + */ + public function getLastexecutionFailure(): string + { + return $this->lastexecutionFailure; + } + + /** + * Set the last execution failure error message + * + * @param string $lastexecutionFailure The last execution failure error message + * + * @return void + */ + public function setLastexecutionFailure(string $lastexecutionFailure): void + { + $this->lastexecutionFailure = $lastexecutionFailure; + } + + /** + * Get the last execution context + * + * @return string + */ + public function getLastexecutionContext(): string + { + return $this->lastexecutionContext; + } + + /** + * Set the last execution context + * + * @param string $lastexecutionContext The last execution context + * + * @return void + */ + public function setLastexecutionContext(string $lastexecutionContext): void + { + $this->lastexecutionContext = $lastexecutionContext; + } + + /** + * Get the attached client + * + * @return Client + */ + public function getClient(): Client + { + return $this->client; + } + + /** + * Set the attached client + * + * @param Client $client The attached client + * + * @return void + */ + public function setClient(Client $client): void + { + $this->client = $client; + } +} diff --git a/Classes/Domain/Repository/TaskRepository.php b/Classes/Domain/Repository/TaskRepository.php new file mode 100644 index 0000000..a187e5e --- /dev/null +++ b/Classes/Domain/Repository/TaskRepository.php @@ -0,0 +1,13 @@ + [ + 'title' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task', + 'label' => 'description', + 'tstamp' => 'tstamp', + 'crdate' => 'crdate', + 'cruser_id' => 'cruser_id', + 'delete' => 'deleted', + 'searchFields' => 'description, lastexecution_failure', + 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg', + ], + 'interface' => [ + 'showRecordFieldList' => 'description, client_task_uid, nextexecution, lastexecution_time, lastexecution_failure, lastexecution_context, client', + ], + 'types' => [ + '1' => [ + 'showitem' => 'description, client_task_uid, nextexecution, lastexecution_time, lastexecution_failure, lastexecution_context, client'], + ], + 'columns' => [ + 'description' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.description', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'text', + 'default' => '', + 'enableRichtext' => 'false' + ], + ], + 'client_task_uid' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.client_task_uid', + 'config' => [ + 'type' => 'input', + 'size' => 10, + 'eval' => 'trim,required', + 'readOnly' => 'true' + ], + ], + 'nextexecution' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.nextexecution', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'input', + 'renderType' => 'inputDateTime', + 'size' => 10, + 'default' => 0, + 'eval' => 'datetime' + ], + ], + 'lastexecution_time' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.lastexecution_time', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'input', + 'renderType' => 'inputDateTime', + 'size' => 10, + 'default' => 0, + 'eval' => 'datetime' + ], + ], + 'lastexecution_failure' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.lastexecution_failure', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'text', + 'default' => '' + ], + ], + 'lastexecution_context' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.lastexecution_context', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'client' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.client', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'select', + 'renderType' => 'selectSingle', + 'foreign_table' => 'tx_t3monitoring_domain_model_client', + 'minitems' => 1, + 'maxitems' => 1 + ], + ], + ], +]; diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index a1824c2..bd6d08f 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -237,6 +237,30 @@ Description + + Task + + + Task description + + + Task UID on the client installation + + + Next task execution + + + Last task execution + + + Error occured on last execution + + + Last task execution context + + + Client + Update available @@ -312,6 +336,9 @@ Administration + + Scheduled Tasks + Available extensions diff --git a/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg b/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg new file mode 100644 index 0000000..1179843 --- /dev/null +++ b/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file From b6c58d4529cd292534c71fe2ce0a09a4886ff183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 17:01:43 +0100 Subject: [PATCH 03/26] [TASK] Add controller and list action --- Classes/Controller/TaskController.php | 21 +++++++++++++++++++++ Resources/Private/Templates/Task/List.html | 1 + ext_tables.php | 2 ++ 3 files changed, 24 insertions(+) create mode 100644 Classes/Controller/TaskController.php create mode 100644 Resources/Private/Templates/Task/List.html diff --git a/Classes/Controller/TaskController.php b/Classes/Controller/TaskController.php new file mode 100644 index 0000000..d876ffa --- /dev/null +++ b/Classes/Controller/TaskController.php @@ -0,0 +1,21 @@ +view->assign('tasks', ['test']); + } + } diff --git a/Resources/Private/Templates/Task/List.html b/Resources/Private/Templates/Task/List.html new file mode 100644 index 0000000..110d29e --- /dev/null +++ b/Resources/Private/Templates/Task/List.html @@ -0,0 +1 @@ +Task List \ No newline at end of file diff --git a/ext_tables.php b/ext_tables.php index b90636b..62c067f 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -15,6 +15,7 @@ function () { 'Extension' => 'list, show', 'Sla' => 'list, show', 'Tag' => 'list, show', + 'Task' => 'list' ], [ 'access' => 'user,group', @@ -28,5 +29,6 @@ function () { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_t3monitoring_domain_model_extension'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_t3monitoring_domain_model_sla'); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_t3monitoring_domain_model_tag'); + \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages('tx_t3monitoring_domain_model_task'); } ); From b13256fb34213430f3cd81bc606272f397fd97b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 17:02:02 +0100 Subject: [PATCH 04/26] [TASK] Add option to display tasks --- Classes/Controller/BaseController.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Classes/Controller/BaseController.php b/Classes/Controller/BaseController.php index 8364f84..0feb342 100644 --- a/Classes/Controller/BaseController.php +++ b/Classes/Controller/BaseController.php @@ -140,6 +140,7 @@ protected function createMenu() ['controller' => 'Sla', 'action' => 'list', 'label' => $this->getLabel('sla')], ['controller' => 'Tag', 'action' => 'list', 'label' => $this->getLabel('tag')], ['controller' => 'Statistic', 'action' => 'administration', 'label' => $this->getLabel('administration')], + ['controller' => 'Task', 'action' => 'list', 'label' => $this->getLabel('tasks')] ]; foreach ($actions as $action) { @@ -195,8 +196,10 @@ protected function getButtons() $addUserGroupButton = $buttonBar->makeLinkButton() ->setHref($uriBuilder->buildUriFromRoute('record_edit', $parameters)) ->setTitle($this->getLabel('createNew.client')) - ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-document-new', - Icon::SIZE_SMALL)); + ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon( + 'actions-document-new', + Icon::SIZE_SMALL + )); $buttonBar->addButton($addUserGroupButton, ButtonBar::BUTTON_POSITION_LEFT); // client single view @@ -210,16 +213,20 @@ protected function getButtons() $editClientButton = $buttonBar->makeLinkButton() ->setHref($uriBuilder->buildUriFromRoute('record_edit', $parameters)) ->setTitle($this->getLabel('edit.client')) - ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-open', - Icon::SIZE_SMALL)); + ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon( + 'actions-open', + Icon::SIZE_SMALL + )); $buttonBar->addButton($editClientButton, ButtonBar::BUTTON_POSITION_LEFT); // fetch client data $downloadClientDataButton = $buttonBar->makeLinkButton() ->setHref($this->getUriBuilder()->reset()->uriFor('fetch', ['client' => $clientId], 'Client')) ->setTitle($this->getLabel('fetchClient.link')) - ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-system-extension-download', - Icon::SIZE_SMALL)); + ->setIcon($this->view->getModuleTemplate()->getIconFactory()->getIcon( + 'actions-system-extension-download', + Icon::SIZE_SMALL + )); $buttonBar->addButton($downloadClientDataButton, ButtonBar::BUTTON_POSITION_LEFT); } } From 4ea04193a418f3bfe9a8b7b90f6fced91e3d823a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 17:02:18 +0100 Subject: [PATCH 05/26] [DOC] Extend readme --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index f4e1c15..dcb0b4b 100644 --- a/README.rst +++ b/README.rst @@ -8,6 +8,7 @@ This extensions provides the possibility to monitor all of your TYPO3 installati - used TYPO3 version and if it is up to date - available TYPO3 extensions and if those are installed, insecure or if there are bugfix, minor or major updates - additional information like PHP & Mysql versions. +- overview and status of the client's scheduled tasks **Requirements** From 7d51cf9f5632349309daabdccc7ae8b7b55db56b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 21:13:17 +0100 Subject: [PATCH 06/26] [TASK] Add TaskImport --- Classes/Service/Import/ClientImport.php | 17 ++++-- Classes/Service/Import/TaskImport.php | 80 +++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 Classes/Service/Import/TaskImport.php diff --git a/Classes/Service/Import/ClientImport.php b/Classes/Service/Import/ClientImport.php index e88f1da..8cd38bb 100644 --- a/Classes/Service/Import/ClientImport.php +++ b/Classes/Service/Import/ClientImport.php @@ -40,6 +40,9 @@ class ClientImport extends BaseImport /** @var EmailNotification */ protected $emailNotification; + /** @var TaskImport */ + protected $taskImporter = null; + /** * Constructor */ @@ -47,6 +50,7 @@ public function __construct() { $this->coreVersions = $this->getAllCoreVersions(); $this->emailNotification = GeneralUtility::makeInstance(EmailNotification::class); + $this->taskImporter = GeneralUtility::makeInstance(TaskImport::class); parent::__construct(); } @@ -131,6 +135,10 @@ protected function importSingleClient(array $row) ->getConnectionForTable(self::TABLE); $connection->update(self::TABLE, $update, ['uid' => (int)$row['uid']]); + if (isset($json['tasks']) && count($json['tasks']) > 0) { + $this->taskImporter->importTasks($row, $json['tasks']); + } + $this->responseCount['success']++; } catch (Exception $e) { $this->handleError($row, $e); @@ -165,7 +173,8 @@ protected function handleError(array $client, Exception $error) $connection = GeneralUtility::makeInstance(ConnectionPool::class) ->getConnectionForTable(self::TABLE); - $connection->update(self::TABLE, + $connection->update( + self::TABLE, [ 'error_message' => $error->getMessage(), 'error_count' => $client['error_count'] + 1 @@ -246,9 +255,9 @@ protected function handleExtensionRelations($client, array $extensions = []) $whereClause = []; foreach ($extensions as $key => $data) { $whereClause[] = $queryBuilder->expr()->andX( - $queryBuilder->expr()->eq('version', $queryBuilder->createNamedParameter($data['version'])), - $queryBuilder->expr()->eq('name', $queryBuilder->createNamedParameter($key)) - ); + $queryBuilder->expr()->eq('version', $queryBuilder->createNamedParameter($data['version'])), + $queryBuilder->expr()->eq('name', $queryBuilder->createNamedParameter($key)) + ); } $existingExtensions = $queryBuilder diff --git a/Classes/Service/Import/TaskImport.php b/Classes/Service/Import/TaskImport.php new file mode 100644 index 0000000..9637c3f --- /dev/null +++ b/Classes/Service/Import/TaskImport.php @@ -0,0 +1,80 @@ + $client The client + * @param array $tasks The client's scheduled tasks + * + * @return void + */ + public function importTasks(array $client, array $tasks): void + { + $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE); + $statement = $queryBuilder + ->select('uid', 'client_task_uid') + ->from(self::TABLE) + ->where( + $queryBuilder->expr()->eq('deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), + $queryBuilder->expr()->eq('client', $queryBuilder->createNamedParameter(intval($client['uid'], \PDO::PARAM_INT))) + ) + ->execute(); + + if (is_object($statement)) { + $rows = $statement->fetchAll(); + + $previousTasks = []; + foreach ($rows as $row) { + $previousTasks[$row['client_task_uid']] = $row; + } + + $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(self::TABLE); + $connection->beginTransaction(); + try { + foreach ($tasks as $task) { + $task['pid'] = $this->emConfiguration->getPid(); + $task['client_task_uid'] = $task['uid']; + $task['tstamp'] = $GLOBALS['EXEC_TIME']; + $task['client'] = $client['uid']; + + if (isset($previousTasks[$task['uid']])) { + $connection->update( + self::TABLE, + $task, + [ + 'uid' => $previousTasks[$task['uid']]['uid'], + 'client' => $client['uid'] + ], + ); + } else { + unset($task['uid']); + $task['crdate'] = $GLOBALS['EXEC_TIME']; + $connection->insert( + self::TABLE, + $task + ); + } + } + $connection->commit(); + } catch (\Exception $e) { + $connection->rollBack(); + throw $e; + } + } + } +} From 6774a8dd0e992cddb3b74c92890e5079caed38cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 22:37:21 +0100 Subject: [PATCH 07/26] [TASK] Rename field to lastexecution --- Classes/Domain/Model/Task.php | 12 ++++++------ Classes/Service/Import/TaskImport.php | 3 +++ .../TCA/tx_t3monitoring_domain_model_task.php | 8 ++++---- Resources/Private/Language/locallang.xlf | 2 +- ext_tables.sql | 2 +- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Classes/Domain/Model/Task.php b/Classes/Domain/Model/Task.php index 9ab3435..6901799 100644 --- a/Classes/Domain/Model/Task.php +++ b/Classes/Domain/Model/Task.php @@ -41,7 +41,7 @@ class Task extends AbstractEntity * * @var int */ - protected $lastexecutionTimestamp = 0; + protected $lastexecution = 0; /** * The last execution failure error message @@ -135,21 +135,21 @@ public function setNextexecution(int $nextexecution): void * * @return int */ - public function getLastexecutionTimestamp(): int + public function getLastexecution(): int { - return $this->lastexecutionTimestamp; + return $this->lastexecution; } /** * Set the last execution timestamp * - * @param int $lastexecutionTimestamp The last execution timestamp + * @param int $lastexecution The last execution timestamp * * @return void */ - public function setLastexecutionTimestamp(int $lastexecutionTimestamp): void + public function setLastexecution(int $lastexecution): void { - $this->lastexecutionTimestamp = $lastexecutionTimestamp; + $this->lastexecution = $lastexecution; } /** diff --git a/Classes/Service/Import/TaskImport.php b/Classes/Service/Import/TaskImport.php index 9637c3f..0737047 100644 --- a/Classes/Service/Import/TaskImport.php +++ b/Classes/Service/Import/TaskImport.php @@ -47,6 +47,9 @@ public function importTasks(array $client, array $tasks): void $connection->beginTransaction(); try { foreach ($tasks as $task) { + $task['lastexecution'] = $task['lastexecution_time']; + unset($task['lastexecution_time']); + $task['pid'] = $this->emConfiguration->getPid(); $task['client_task_uid'] = $task['uid']; $task['tstamp'] = $GLOBALS['EXEC_TIME']; diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_task.php b/Configuration/TCA/tx_t3monitoring_domain_model_task.php index 868a47f..cec580d 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_task.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_task.php @@ -12,11 +12,11 @@ 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg', ], 'interface' => [ - 'showRecordFieldList' => 'description, client_task_uid, nextexecution, lastexecution_time, lastexecution_failure, lastexecution_context, client', + 'showRecordFieldList' => 'description, client_task_uid, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, client', ], 'types' => [ '1' => [ - 'showitem' => 'description, client_task_uid, nextexecution, lastexecution_time, lastexecution_failure, lastexecution_context, client'], + 'showitem' => 'description, client_task_uid, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, client'], ], 'columns' => [ 'description' => [ @@ -51,9 +51,9 @@ 'eval' => 'datetime' ], ], - 'lastexecution_time' => [ + 'lastexecution' => [ 'exclude' => false, - 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.lastexecution_time', + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.lastexecution', 'config' => [ 'readOnly' => 'true', 'type' => 'input', diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index bd6d08f..8954c5b 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -249,7 +249,7 @@ Next task execution - + Last task execution diff --git a/ext_tables.sql b/ext_tables.sql index f897223..b5b0f08 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -186,7 +186,7 @@ CREATE TABLE tx_t3monitoring_domain_model_task ( description text NOT NULL, client_task_uid int(11) NOT NULL, nextexecution int(11) DEFAULT '0' NOT NULL, - lastexecution_time int(11) DEFAULT '0' NOT NULL, + lastexecution int(11) DEFAULT '0' NOT NULL, lastexecution_failure text NOT NULL, lastexecution_context varchar(10) DEFAULT '' NOT NULL, client int(11) DEFAULT '0' NOT NULL From e5037ef187ec481330a3eef349b4b86cf5b80d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 26 Feb 2021 22:37:58 +0100 Subject: [PATCH 08/26] [TASK] Fix language label for menu item --- Classes/Controller/BaseController.php | 2 +- Resources/Private/Language/locallang.xlf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Classes/Controller/BaseController.php b/Classes/Controller/BaseController.php index 0feb342..5b842d3 100644 --- a/Classes/Controller/BaseController.php +++ b/Classes/Controller/BaseController.php @@ -140,7 +140,7 @@ protected function createMenu() ['controller' => 'Sla', 'action' => 'list', 'label' => $this->getLabel('sla')], ['controller' => 'Tag', 'action' => 'list', 'label' => $this->getLabel('tag')], ['controller' => 'Statistic', 'action' => 'administration', 'label' => $this->getLabel('administration')], - ['controller' => 'Task', 'action' => 'list', 'label' => $this->getLabel('tasks')] + ['controller' => 'Task', 'action' => 'list', 'label' => $this->getLabel('task')] ]; foreach ($actions as $action) { diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 8954c5b..7fdc244 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -336,8 +336,8 @@ Administration - - Scheduled Tasks + + Scheduled tasks Available extensions From 63fbecf0acb55345fe80f30102251c2f09d3852e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 5 Mar 2021 21:32:39 +0100 Subject: [PATCH 09/26] [TASK] Added properties for task --- Classes/Domain/Model/Task.php | 116 ++++++++++++++++++ .../TCA/tx_t3monitoring_domain_model_task.php | 47 +++++-- Resources/Private/Language/de.locallang.xlf | 84 +++++++++++++ Resources/Private/Language/locallang.xlf | 90 ++++++++++---- ext_tables.sql | 5 + 5 files changed, 303 insertions(+), 39 deletions(-) diff --git a/Classes/Domain/Model/Task.php b/Classes/Domain/Model/Task.php index 6901799..f590eac 100644 --- a/Classes/Domain/Model/Task.php +++ b/Classes/Domain/Model/Task.php @@ -57,6 +57,34 @@ class Task extends AbstractEntity */ protected $lastexecutionContext = ''; + /** + * The task class + * + * @var string + */ + protected $class = ''; + + /** + * Multiple executions allowed? + * + * @var bool + */ + protected $multiple = false; + + /** + * The type of the task (Single, Recurring) + * + * @var int + */ + protected $type = 2; + + /** + * The tasks frequency (seconds or cronCmd) + * + * @var string + */ + protected $frequency = ''; + /** * The attached client * @@ -196,6 +224,94 @@ public function setLastexecutionContext(string $lastexecutionContext): void $this->lastexecutionContext = $lastexecutionContext; } + /** + * Get the class + * + * @return string + */ + public function getClass(): string + { + return $this->class; + } + + /** + * Set the class + * + * @param string $class The task class + * + * @return void + */ + public function setClass(string $class): void + { + $this->class = $class; + } + + /** + * Get the multiple + * + * @return bool + */ + public function getMultiple(): bool + { + return $this->multiple; + } + + /** + * Set the multiple + * + * @param bool $multiple The task multiple + * + * @return void + */ + public function setMultiple(bool $multiple): void + { + $this->multiple = $multiple; + } + + /** + * Get the type + * + * @return int + */ + public function gettype(): int + { + return $this->type; + } + + /** + * Set the type + * + * @param int $type The task type + * + * @return void + */ + public function setType(int $type): void + { + $this->type = $type; + } + + /** + * Get the frequency + * + * @return string + */ + public function getFrequency(): string + { + return $this->frequency; + } + + /** + * Set the frequency + * + * @param string $frequency The task frequency + * + * @return void + */ + public function setFrequency(string $frequency): void + { + $this->frequency = $frequency; + } + /** * Get the attached client * diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_task.php b/Configuration/TCA/tx_t3monitoring_domain_model_task.php index cec580d..28f5c74 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_task.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_task.php @@ -12,23 +12,13 @@ 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg', ], 'interface' => [ - 'showRecordFieldList' => 'description, client_task_uid, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, client', + 'showRecordFieldList' => 'client_task_uid, description, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, class, multiple, type, frequency, client', ], 'types' => [ '1' => [ - 'showitem' => 'description, client_task_uid, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, client'], + 'showitem' => 'client_task_uid, description, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, class, multiple, type, frequency, client'], ], 'columns' => [ - 'description' => [ - 'exclude' => false, - 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.description', - 'config' => [ - 'readOnly' => 'true', - 'type' => 'text', - 'default' => '', - 'enableRichtext' => 'false' - ], - ], 'client_task_uid' => [ 'exclude' => false, 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.client_task_uid', @@ -39,6 +29,16 @@ 'readOnly' => 'true' ], ], + 'description' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.description', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'text', + 'default' => '', + 'enableRichtext' => 'false' + ], + ], 'nextexecution' => [ 'exclude' => false, 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.nextexecution', @@ -82,6 +82,29 @@ 'eval' => 'trim' ], ], + 'class' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.class', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim' + ], + ], + 'type' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.type', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'select', + 'renderType' => 'selectSingle', + 'items' => [ + ['LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.type.1:', '1'], + ['LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.type.2', '2'], + ], + ], + ], 'client' => [ 'exclude' => false, 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.client', diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index e518b02..656dde9 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -587,6 +587,90 @@ The data of the client has been successfully fetched! Die Daten des Clients wurden erfolgreich abgerufen! + + Task + Task + + + Task uid on client + Uid des Task am Client + + + Task description + Task + + + Next execution + Nächste Ausführung + + + Last execution + Letzte Ausführung + + + Error occured on last execution + Fehler bei der letzten Ausführung + + + Last execution context + Context der letzten Ausführung + + + The task class + Die Task Klasse + + + Allow paralell execution + Paralelle Ausführung + + + Type + Typ + + + Single + Einmalig + + + Recurring + Widerkehrend + + + Frequency (interval or cron command) + Frequenz (Interval oder Cron Befehl) + + + Client + Client + + + Scheduled tasks + Geplante Tasks + + + No scheduled tasks found + Keine geplanten Tasks gefunden + + + Scheduled tasks + Geplante Tasks + + + Scheduled tasks (%s) + Geplante Tasks (%s) + + + Error + Fehler + + + OK + OK + + + Client task Uid + Client Task Uid + diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 7fdc244..5c24944 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -237,30 +237,6 @@ Description - - Task - - - Task description - - - Task UID on the client installation - - - Next task execution - - - Last task execution - - - Error occured on last execution - - - Last task execution context - - - Client - Update available @@ -336,9 +312,6 @@ Administration - - Scheduled tasks - Available extensions @@ -524,6 +497,69 @@ The data of the client has been successfully fetched! + + Task + + + Task uid on client + + + Task description + + + Next execution + + + Last execution + + + Error occured on last execution + + + Last execution context + + + The task class + + + Allow paralell execution + + + Type + + + Single + + + Recurring + + + Frequency (interval or cron command) + + + Client + + + Scheduled tasks + + + No scheduled tasks found + + + Scheduled tasks + + + Scheduled tasks (%s) + + + Error + + + OK + + + Client task UID + diff --git a/ext_tables.sql b/ext_tables.sql index b5b0f08..0cfa969 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -189,5 +189,10 @@ CREATE TABLE tx_t3monitoring_domain_model_task ( lastexecution int(11) DEFAULT '0' NOT NULL, lastexecution_failure text NOT NULL, lastexecution_context varchar(10) DEFAULT '' NOT NULL, + class varchar(255) DEFAULT '' NOT NULL, + multiple tinyint(4) unsigned DEFAULT '0' NOT NULL, + type varchar(50) DEFAULT '' NOT NULL, + frequency varchar(50) DEFAULT '' NOT NULL, + command varchar(255) DEFAULT '' NOT NULL, client int(11) DEFAULT '0' NOT NULL ); \ No newline at end of file From 9d2642639a71787fff67ae9c530dd47f6ec087e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 5 Mar 2021 21:33:07 +0100 Subject: [PATCH 10/26] [TASK] Added task importer --- Classes/Service/Import/TaskImport.php | 109 ++++++++++++++++---------- 1 file changed, 68 insertions(+), 41 deletions(-) diff --git a/Classes/Service/Import/TaskImport.php b/Classes/Service/Import/TaskImport.php index 0737047..ec85a79 100644 --- a/Classes/Service/Import/TaskImport.php +++ b/Classes/Service/Import/TaskImport.php @@ -1,6 +1,7 @@ getTasksForClient($client['uid']); + + $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(self::TABLE); + $connection->beginTransaction(); + try { + foreach ($importTasks as $importTask) { + $importTask['lastexecution'] = $importTask['lastexecution_time']; + unset($importTask['lastexecution_time']); + + $importTask['pid'] = $this->emConfiguration->getPid(); + + $importTask['client_task_uid'] = $importTask['uid']; + $importTask['tstamp'] = $GLOBALS['EXEC_TIME']; + $importTask['client'] = $client['uid']; + + if (isset($currentTasks[$importTask['uid']])) { + $importTaskUid = $importTask['uid']; + unset($importTask['uid']); + $connection->update( + self::TABLE, + $importTask, + [ + 'uid' => $currentTasks[$importTaskUid], + 'client' => $client['uid'] + ], + ); + unset($currentTasks[$importTaskUid]); + } else { + unset($importTask['uid']); + $importTask['crdate'] = $GLOBALS['EXEC_TIME']; + $connection->insert( + self::TABLE, + $importTask + ); + } + } + foreach ($currentTasks as $deleteTaskUid) { + $connection->delete( + self::TABLE, + ['uid' => (int)$deleteTaskUid], + [Connection::PARAM_INT] + ); + } + $connection->commit(); + + // TODO: Delete "old" tasks --> Check "currentTasks" array --> If there are tasks in there, which are not present in "tasks --> Delete them + } catch (\Exception $e) { + $connection->rollBack(); + throw $e; + } + } + + /** + * Returns the current tasks of this client from the database + * + * @param int $clientUid The uid of the client + * + * @return array Array holding the UIDs of the tasks in this database + */ + private function getTasksForClient(int $clientUid): array { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(self::TABLE); $statement = $queryBuilder @@ -31,53 +93,18 @@ public function importTasks(array $client, array $tasks): void ->from(self::TABLE) ->where( $queryBuilder->expr()->eq('deleted', $queryBuilder->createNamedParameter(0, \PDO::PARAM_INT)), - $queryBuilder->expr()->eq('client', $queryBuilder->createNamedParameter(intval($client['uid'], \PDO::PARAM_INT))) + $queryBuilder->expr()->eq('client', $queryBuilder->createNamedParameter(intval($clientUid, \PDO::PARAM_INT))) ) ->execute(); if (is_object($statement)) { $rows = $statement->fetchAll(); - - $previousTasks = []; + $currentTasks = []; foreach ($rows as $row) { - $previousTasks[$row['client_task_uid']] = $row; - } - - $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable(self::TABLE); - $connection->beginTransaction(); - try { - foreach ($tasks as $task) { - $task['lastexecution'] = $task['lastexecution_time']; - unset($task['lastexecution_time']); - - $task['pid'] = $this->emConfiguration->getPid(); - $task['client_task_uid'] = $task['uid']; - $task['tstamp'] = $GLOBALS['EXEC_TIME']; - $task['client'] = $client['uid']; - - if (isset($previousTasks[$task['uid']])) { - $connection->update( - self::TABLE, - $task, - [ - 'uid' => $previousTasks[$task['uid']]['uid'], - 'client' => $client['uid'] - ], - ); - } else { - unset($task['uid']); - $task['crdate'] = $GLOBALS['EXEC_TIME']; - $connection->insert( - self::TABLE, - $task - ); - } - } - $connection->commit(); - } catch (\Exception $e) { - $connection->rollBack(); - throw $e; + $currentTasks[$row['client_task_uid']] = $row['uid']; } + return $currentTasks; } + return []; } } From a0b7c1460efe0d1de987c3052dc8f94ba6274e1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 5 Mar 2021 21:33:26 +0100 Subject: [PATCH 11/26] [TASK] List of tasks --- Classes/Controller/TaskController.php | 41 +++++++++--- Resources/Private/Templates/Task/List.html | 78 +++++++++++++++++++++- 2 files changed, 108 insertions(+), 11 deletions(-) diff --git a/Classes/Controller/TaskController.php b/Classes/Controller/TaskController.php index d876ffa..6458f36 100644 --- a/Classes/Controller/TaskController.php +++ b/Classes/Controller/TaskController.php @@ -2,6 +2,8 @@ namespace T3Monitor\T3monitoring\Controller; +use T3Monitor\T3monitoring\Domain\Repository\TaskRepository; + /* * This file is part of the t3monitoring extension for TYPO3 CMS. * @@ -9,13 +11,32 @@ * LICENSE.txt file that was distributed with this source code. */ - /** - * Class TaskController - */ - class TaskController extends BaseController - { - protected function listAction() - { - $this->view->assign('tasks', ['test']); - } - } +/** + * TaskController + */ +class TaskController extends BaseController +{ + /** + * The task repository + * + * @var TaskRepository + */ + protected $taskRepository = null; + + public function injectTaskRepository(TaskRepository $taskRepository) + { + $this->taskRepository = $taskRepository; + } + + /** + * List action shows all tasks + * + * @return void + */ + protected function listAction(): void + { + $this->view->assignMultiple([ + 'tasks' => $this->taskRepository->findAll() + ]); + } +} diff --git a/Resources/Private/Templates/Task/List.html b/Resources/Private/Templates/Task/List.html index 110d29e..646a1cd 100644 --- a/Resources/Private/Templates/Task/List.html +++ b/Resources/Private/Templates/Task/List.html @@ -1 +1,77 @@ -Task List \ No newline at end of file + + + + + +

{f:translate(key:'task.header')}

+ + +
+
+ {f:translate(key:'task.total', arguments:'{0:\'{tasks -> f:count()}\'}')} +
+ + + + + + + + + + + + + + + + + + + + + + + +
{f:translate(key:'tx_t3monitoring_domain_model_client')}{f:translate(key:'tx_t3monitoring_domain_model_task.table.col.client_task_uid')}{f:translate(key:'tx_t3monitoring_domain_model_task.description')}{f:translate(key:'tx_t3monitoring_domain_model_task.lastexecution')}{f:translate(key:'tx_t3monitoring_domain_model_task.nextexecution')}
+ + + + + + + + + + + + + + + + + + {task.client.title} + + + + + {task.clientTaskUid} + + {task.description} + + {task.lastexecution} ({task.lastexecutionContext}) + + {task.nextexecution} +
+
+
+ +
+ {f:translate(key:'task.notFound')} +
+
+
+
\ No newline at end of file From 446104af1b70e7a1efadf2d13c620c59801323f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Wed, 17 Mar 2021 21:11:39 +0100 Subject: [PATCH 12/26] [TASK] Add frequency to TCA --- .../TCA/tx_t3monitoring_domain_model_task.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_task.php b/Configuration/TCA/tx_t3monitoring_domain_model_task.php index 28f5c74..771cc9b 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_task.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_task.php @@ -105,6 +105,16 @@ ], ], ], + 'frequency' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.frequency', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim' + ], + ], 'client' => [ 'exclude' => false, 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.client', From 5470fc27d4cb9f43b812d01ecafa39c5d51c0ef9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Wed, 17 Mar 2021 21:12:34 +0100 Subject: [PATCH 13/26] [TASK] Add columns to task list --- Resources/Private/Language/de.locallang.xlf | 18 +++++++++++++----- Resources/Private/Language/locallang.xlf | 12 +++++++++--- Resources/Private/Templates/Task/List.html | 14 +++++++++++++- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 656dde9..44ea558 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -597,7 +597,7 @@
Task description - Task + Task Beschreibung Next execution @@ -616,8 +616,8 @@ Context der letzten Ausführung - The task class - Die Task Klasse + Class + Klasse Allow paralell execution @@ -636,8 +636,8 @@ Widerkehrend - Frequency (interval or cron command) - Frequenz (Interval oder Cron Befehl) + Frequency + Frequenz Client @@ -671,6 +671,14 @@ Client task Uid Client Task Uid + + There are no tasks for this client. + Es gibt keine "Geplanten Tasks" für diesen Client. + + + Available tasks + Vorhandene Tasks + diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 5c24944..d0ec02b 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -519,7 +519,7 @@ Last execution context
- The task class + Class Allow paralell execution @@ -534,7 +534,7 @@ Recurring - Frequency (interval or cron command) + Frequency Client @@ -558,7 +558,13 @@ OK - Client task UID + Task + + + There are no tasks for this client. + + + Available tasks diff --git a/Resources/Private/Templates/Task/List.html b/Resources/Private/Templates/Task/List.html index 646a1cd..75648e9 100644 --- a/Resources/Private/Templates/Task/List.html +++ b/Resources/Private/Templates/Task/List.html @@ -17,8 +17,11 @@

{f:translate(key:'task.header')}

{f:translate(key:'tx_t3monitoring_domain_model_client')} - {f:translate(key:'tx_t3monitoring_domain_model_task.table.col.client_task_uid')} + Uid + {f:translate(key:'tx_t3monitoring_domain_model_task.class')} + {f:translate(key:'tx_t3monitoring_domain_model_task.type')} {f:translate(key:'tx_t3monitoring_domain_model_task.description')} + {f:translate(key:'tx_t3monitoring_domain_model_task.frequency')} {f:translate(key:'tx_t3monitoring_domain_model_task.lastexecution')} {f:translate(key:'tx_t3monitoring_domain_model_task.nextexecution')} @@ -53,9 +56,18 @@

{f:translate(key:'task.header')}

{task.clientTaskUid} + + {task.classShort} + + + + {task.description} + + {task.frequency} + {task.lastexecution} ({task.lastexecutionContext}) From 3faff2b2c4f6a9769c50f9e02dfe4cd50e04ae70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 17:06:56 +0100 Subject: [PATCH 14/26] [TASK] Add late field --- Classes/Domain/Model/Task.php | 42 +++++++++++++++++++ .../TCA/tx_t3monitoring_domain_model_task.php | 21 +++++++++- ext_tables.sql | 3 +- 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/Classes/Domain/Model/Task.php b/Classes/Domain/Model/Task.php index f590eac..41ea1b8 100644 --- a/Classes/Domain/Model/Task.php +++ b/Classes/Domain/Model/Task.php @@ -92,6 +92,13 @@ class Task extends AbstractEntity */ protected $client = null; + /** + * Whether the task is late or not + * + * @var bool + */ + protected $late = false; + /** * Get the uid of the tasks on the client system. * @@ -333,4 +340,39 @@ public function setClient(Client $client): void { $this->client = $client; } + + /** + * Explodes the class name and returns the last part + * + * @return string The last class part + */ + public function getClassShort(): string + { + $parts = explode('\\', $this->class); + return end($parts); + } + + /** + * Get whether the task is late or not + * + * @return bool + */ + public function getLate() + { + return $this->late; + } + + /** + * Set whether the task is late or not + * + * @param bool $late Whether the task is late or not + * + * @return self + */ + public function setLate(bool $late) + { + $this->late = $late; + + return $this; + } } diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_task.php b/Configuration/TCA/tx_t3monitoring_domain_model_task.php index 771cc9b..1d6aaa3 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_task.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_task.php @@ -12,11 +12,11 @@ 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_task.svg', ], 'interface' => [ - 'showRecordFieldList' => 'client_task_uid, description, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, class, multiple, type, frequency, client', + 'showRecordFieldList' => 'client_task_uid, description, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, class, multiple, type, frequency, client, late', ], 'types' => [ '1' => [ - 'showitem' => 'client_task_uid, description, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, class, multiple, type, frequency, client'], + 'showitem' => 'client_task_uid, description, nextexecution, lastexecution, lastexecution_failure, lastexecution_context, class, multiple, type, frequency, client, late'], ], 'columns' => [ 'client_task_uid' => [ @@ -127,5 +127,22 @@ 'maxitems' => 1 ], ], + 'late' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_task.late', + 'config' => [ + 'readOnly' => 'true', + 'type' => 'check', + 'renderType' => 'checkboxToggle', + 'items' => [ + '0' => [ + '0' => '', + '1' => 'late', + 'labelChecked' => 'Enabled', + 'labelUnchecked' => 'Disabled' + ] + ] + ] + ] ], ]; diff --git a/ext_tables.sql b/ext_tables.sql index 0cfa969..8d16d27 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -194,5 +194,6 @@ CREATE TABLE tx_t3monitoring_domain_model_task ( type varchar(50) DEFAULT '' NOT NULL, frequency varchar(50) DEFAULT '' NOT NULL, command varchar(255) DEFAULT '' NOT NULL, - client int(11) DEFAULT '0' NOT NULL + client int(11) DEFAULT '0' NOT NULL, + late tinyint(1) unsigned DEFAULT '0' NOT NULL ); \ No newline at end of file From c1c56a007f0123195eced5b80534bfa89b5ee73b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 17:07:24 +0100 Subject: [PATCH 15/26] [TASK] Remove old comment --- Classes/Service/Import/TaskImport.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Classes/Service/Import/TaskImport.php b/Classes/Service/Import/TaskImport.php index ec85a79..33421ad 100644 --- a/Classes/Service/Import/TaskImport.php +++ b/Classes/Service/Import/TaskImport.php @@ -70,8 +70,6 @@ public function importTasks(array $client, array $importTasks): void ); } $connection->commit(); - - // TODO: Delete "old" tasks --> Check "currentTasks" array --> If there are tasks in there, which are not present in "tasks --> Delete them } catch (\Exception $e) { $connection->rollBack(); throw $e; From d76529d6324cf9fd7666c877a10e300a545fd78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 17:07:44 +0100 Subject: [PATCH 16/26] [TASK] Add late language fields --- Resources/Private/Language/de.locallang.xlf | 4 ++++ Resources/Private/Language/locallang.xlf | 3 +++ 2 files changed, 7 insertions(+) diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 44ea558..97c1b63 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -639,6 +639,10 @@ Frequency Frequenz
+ + Late + Verspätet + Client Client diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index d0ec02b..7828447 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -536,6 +536,9 @@ Frequency + + Late + Client From 3c45df43ffbe668d5c9c389a73eae64079a03b5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 17:08:39 +0100 Subject: [PATCH 17/26] [TASK] Add findByClientId repo method --- Classes/Domain/Repository/TaskRepository.php | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Classes/Domain/Repository/TaskRepository.php b/Classes/Domain/Repository/TaskRepository.php index a187e5e..d1e47e8 100644 --- a/Classes/Domain/Repository/TaskRepository.php +++ b/Classes/Domain/Repository/TaskRepository.php @@ -1,6 +1,8 @@ setDefaultOrderings(['client' => QueryInterface::ORDER_ASCENDING]); + } + + /** + * Function returns all tasks for a specific clientId + * + * @param integer $clientId The id of the desired client + * + * @return array The tasks of this client + */ + public function findByClientId(int $clientId) + { + $query = $this->getQuery(); + $query->matching($query->equals('client', intval($clientId))); + $tasks = $query->execute()->toArray(); + return $tasks; + } } From 13deffaa18bb0fa8c5a048841c769864f0188632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 17:08:57 +0100 Subject: [PATCH 18/26] [TASK] Move table to partial --- Resources/Private/Partials/Task/Table.html | 93 ++++++++++++++++++++++ Resources/Private/Templates/Task/List.html | 67 +--------------- 2 files changed, 94 insertions(+), 66 deletions(-) create mode 100644 Resources/Private/Partials/Task/Table.html diff --git a/Resources/Private/Partials/Task/Table.html b/Resources/Private/Partials/Task/Table.html new file mode 100644 index 0000000..023b3dc --- /dev/null +++ b/Resources/Private/Partials/Task/Table.html @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + warninginfo + + + + + + + + + + + + + + +
{f:translate(key:'tx_t3monitoring_domain_model_client')}Uid{f:translate(key:'tx_t3monitoring_domain_model_task.class')}{f:translate(key:'tx_t3monitoring_domain_model_task.type')}{f:translate(key:'tx_t3monitoring_domain_model_task.description')}{f:translate(key:'tx_t3monitoring_domain_model_task.frequency')}{f:translate(key:'tx_t3monitoring_domain_model_task.lastexecution')}{f:translate(key:'tx_t3monitoring_domain_model_task.nextexecution')}
+ + + + + + + + + + + + + + + + + + + + + + + + {task.client.title} + + + + + {task.clientTaskUid} + + {task.classShort} + + + + + + + + + + + + + + + {task.description} + + {task.frequency} + + + + {task.lastexecution} ({task.lastexecutionContext}) + + + - + + + + {task.nextexecution} +
\ No newline at end of file diff --git a/Resources/Private/Templates/Task/List.html b/Resources/Private/Templates/Task/List.html index 75648e9..daf3068 100644 --- a/Resources/Private/Templates/Task/List.html +++ b/Resources/Private/Templates/Task/List.html @@ -12,72 +12,7 @@

{f:translate(key:'task.header')}

{f:translate(key:'task.total', arguments:'{0:\'{tasks -> f:count()}\'}')}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{f:translate(key:'tx_t3monitoring_domain_model_client')}Uid{f:translate(key:'tx_t3monitoring_domain_model_task.class')}{f:translate(key:'tx_t3monitoring_domain_model_task.type')}{f:translate(key:'tx_t3monitoring_domain_model_task.description')}{f:translate(key:'tx_t3monitoring_domain_model_task.frequency')}{f:translate(key:'tx_t3monitoring_domain_model_task.lastexecution')}{f:translate(key:'tx_t3monitoring_domain_model_task.nextexecution')}
- - - - - - - - - - - - - - - - - - {task.client.title} - - - - - {task.clientTaskUid} - - {task.classShort} - - - - {task.description} - - {task.frequency} - - {task.lastexecution} ({task.lastexecutionContext}) - - {task.nextexecution} -
+ From 7193af1f528225e0fd9e4152469cb54a2d299b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 17:09:12 +0100 Subject: [PATCH 19/26] [TASK] Show tasks in client detail --- Classes/Controller/ClientController.php | 17 +++++++++++++++++ Resources/Private/Templates/Client/Show.html | 14 ++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Classes/Controller/ClientController.php b/Classes/Controller/ClientController.php index de8a0c7..65e61e6 100644 --- a/Classes/Controller/ClientController.php +++ b/Classes/Controller/ClientController.php @@ -10,6 +10,7 @@ */ use T3Monitor\T3monitoring\Domain\Model\Client; +use T3Monitor\T3monitoring\Domain\Repository\TaskRepository; use T3Monitor\T3monitoring\Service\Import\ClientImport; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -19,6 +20,21 @@ class ClientController extends BaseController { + /** + * @var \T3Monitor\T3monitoring\Domain\Repository\TaskRepository + */ + protected $taskRepository = null; + + /** + * Constructor for new client controller objects + * + * @param TaskRepository $taskRepository The task repository + */ + public function __construct(TaskRepository $taskRepository) + { + $this->taskRepository = $taskRepository; + } + /** * Show client * @@ -35,6 +51,7 @@ public function showAction(Client $client = null) $this->view->assignMultiple([ 'client' => $client, + 'tasks' => $this->taskRepository->findByClientId($client->getUid()) ]); } diff --git a/Resources/Private/Templates/Client/Show.html b/Resources/Private/Templates/Client/Show.html index a47dec5..d3d6bfd 100644 --- a/Resources/Private/Templates/Client/Show.html +++ b/Resources/Private/Templates/Client/Show.html @@ -218,6 +218,20 @@

+ + + +
+
+ {f:translate(key:'client.show.tasks.available')} ({tasks -> f:count()}) +
+ +
+
+ + + +
From d77c16dc783a59244094f8231717aa4454035ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 20:47:06 +0100 Subject: [PATCH 20/26] [TASK] Add status info in client list --- Classes/Domain/Model/Client.php | 17 +++++- Classes/Domain/Repository/TaskRepository.php | 55 +++++++++++++++++++ Resources/Private/Language/de.locallang.xlf | 6 +- Resources/Private/Language/locallang.xlf | 3 + Resources/Private/Partials/Task/Table.html | 4 +- .../Private/Templates/Statistic/Index.html | 17 ++++++ 6 files changed, 98 insertions(+), 4 deletions(-) diff --git a/Classes/Domain/Model/Client.php b/Classes/Domain/Model/Client.php index dbcef66..bbf7962 100644 --- a/Classes/Domain/Model/Client.php +++ b/Classes/Domain/Model/Client.php @@ -8,9 +8,12 @@ * LICENSE.txt file that was distributed with this source code. */ +use T3Monitor\T3monitoring\Domain\Repository\TaskRepository; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Object\ObjectManager; +use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; use TYPO3\CMS\Extbase\Persistence\Generic\LazyLoadingProxy; -use TYPO3\CMS\Extbase\Persistence\ObjectStorage; /** * Client @@ -772,4 +775,16 @@ public function getExtraDangerAsArray() } return []; } + + /** + * Return the overall task status for a client. + * + * @return int + */ + public function getTaskStatus(): int + { + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + $taskRepository = $objectManager->get(TaskRepository::class); + return $taskRepository->getTaskStatusForClientId($this->uid); + } } diff --git a/Classes/Domain/Repository/TaskRepository.php b/Classes/Domain/Repository/TaskRepository.php index d1e47e8..e0699a3 100644 --- a/Classes/Domain/Repository/TaskRepository.php +++ b/Classes/Domain/Repository/TaskRepository.php @@ -31,4 +31,59 @@ public function findByClientId(int $clientId) $tasks = $query->execute()->toArray(); return $tasks; } + + /** + * Method returns the overall task status for a given client. + * Depending on the Function checks the overall task status. + * Depending on the tasks following return values are valid: + * - 0: All tasks are ok + * - 1: At least 1 task is late, no task is failing + * - 2: At least 1 task is failing + * + * @param integer $clientId + * @return void + */ + public function getTaskStatusForClientId(int $clientId) + { + $lateCount = 0; + $errorCount = 0; + + $query = $this->getQuery(); + $query->matching( + $query->logicalAnd( + $query->equals('client', intval($clientId)), + $query->logicalOr([ + $query->equals('late', 1), + $query->logicalNot($query->equals('lastexecution_failure', '')) + ]) + ) + ); + $errorTasks = $query->execute()->toArray(); + + if ($errorTasks) { + foreach ($errorTasks as $errorTask) { + if ($errorTask->getLate() == 1) { + $lateCount++; + } + if ($errorTask->getLastexecutionFailure() != '') { + $errorCount++; + } + } + + if ($errorCount) { + return 2; // Overall: Error + } + + if ($lateCount) { + return 1; // Overall: Warning + } + } else { + $query = $this->getQuery(); + $taskCount = $query->matching($query->equals('client', intval($clientId)))->count(); + if ($taskCount) { + return 3; // Overall: Ok + } + } + return 0; // OVerall: Empty + } } diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index 97c1b63..ec0386c 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -665,12 +665,16 @@ Error - Fehler + Error OK OK + + Tasks + Tasks + Client task Uid Client Task Uid diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 7828447..d58fe4b 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -560,6 +560,9 @@ OK + + Tasks + Task diff --git a/Resources/Private/Partials/Task/Table.html b/Resources/Private/Partials/Task/Table.html index 023b3dc..8e305c0 100644 --- a/Resources/Private/Partials/Task/Table.html +++ b/Resources/Private/Partials/Task/Table.html @@ -31,7 +31,7 @@ - + @@ -62,7 +62,7 @@ - + diff --git a/Resources/Private/Templates/Statistic/Index.html b/Resources/Private/Templates/Statistic/Index.html index c2b3e5c..36845c6 100644 --- a/Resources/Private/Templates/Statistic/Index.html +++ b/Resources/Private/Templates/Statistic/Index.html @@ -308,6 +308,7 @@ {f:translate(key:'tx_t3monitoring_domain_model_client')} {f:translate(key:'tx_t3monitoring_domain_model_client.domain')} {f:translate(key:'tx_t3monitoring_domain_model_client.status')} + {f:translate(key:'task.status')} {f:translate(key:'tx_t3monitoring_domain_model_sla')} {f:translate(key:'tx_t3monitoring_domain_model_tag')} {f:translate(key:'tx_t3monitoring_domain_model_core')} @@ -360,6 +361,22 @@ + + + + - + + + + + + + + + + + + From b584d4f1094d75de85e737e1fb3798f4d66c92d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Sat, 20 Mar 2021 21:16:04 +0100 Subject: [PATCH 21/26] [TASK] Add alert notification options for tasks 2 new options for task alerting: - Alert on tasks which are late - Alert on tasks which have an error --- Classes/Domain/Model/Client.php | 54 +++++++++++++++++++ .../tx_t3monitoring_domain_model_client.php | 18 ++++++- Resources/Private/Language/de.locallang.xlf | 8 +++ Resources/Private/Language/locallang.xlf | 6 +++ ext_tables.sql | 2 + 5 files changed, 86 insertions(+), 2 deletions(-) diff --git a/Classes/Domain/Model/Client.php b/Classes/Domain/Model/Client.php index bbf7962..60c499e 100644 --- a/Classes/Domain/Model/Client.php +++ b/Classes/Domain/Model/Client.php @@ -158,6 +158,16 @@ class Client extends AbstractEntity */ protected $tag = null; + /** + * @var bool + */ + protected $taskAlertLate = false; + + /** + * @var bool + */ + protected $taskAlertError = false; + /** * __construct */ @@ -787,4 +797,48 @@ public function getTaskStatus(): int $taskRepository = $objectManager->get(TaskRepository::class); return $taskRepository->getTaskStatusForClientId($this->uid); } + + /** + * Get the value of taskAlertLate + * + * @return bool + */ + public function getTaskAlertLate() + { + return $this->taskAlertLate; + } + + /** + * Set the value of taskAlertLate + * + * @param bool $taskAlertLate + * + * @return void + */ + public function setTaskAlertLate(bool $taskAlertLate): void + { + $this->taskAlertLate = $taskAlertLate; + } + + /** + * Get the value of taskAlertError + * + * @return bool + */ + public function getTaskAlertError() + { + return $this->taskAlertError; + } + + /** + * Set the value of taskAlertError + * + * @param bool $taskAlertError + * + * @return void + */ + public function setTaskAlertError(bool $taskAlertError): void + { + $this->taskAlertError = $taskAlertError; + } } diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_client.php b/Configuration/TCA/tx_t3monitoring_domain_model_client.php index 180eb2e..85ca422 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_client.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_client.php @@ -10,16 +10,17 @@ 'enablecolumns' => [ 'disabled' => 'hidden', ], - 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,disk_total_space,disk_free_space,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,core,sla,tag', + 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,disk_total_space,disk_free_space,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,core,sla,tag, task_alert_late, task_alert_error', 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_client.svg' ], 'interface' => [ - 'showRecordFieldList' => 'hidden, title, domain, secret, basic_auth_username, basic_auth_password, host_header, ignore_cert_errors, force_ip_resolve, php_version, mysql_version, disk_total_space, disk_free_space, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, core, sla, tag', + 'showRecordFieldList' => 'hidden, title, domain, secret, basic_auth_username, basic_auth_password, host_header, ignore_cert_errors, force_ip_resolve, php_version, mysql_version, disk_total_space, disk_free_space, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, core, sla, tag, task_alert_late, task_alert_error', ], 'types' => [ 1 => [ 'showitem' => ' --div--;General,--palette--;;paletteTitle, --palette--;;paletteDomain,email,sla,tag, + --div--;Tasks,--palette--;;paletteTitle, --palette--;;paletteTask, --div--;Readonly information,last_successful_import,error_message,--palette--;;paletteCore, --palette--;;paletteExtensions, --palette--;;paletteVersions, --palette--;;paletteDiskSpace, --div--;Extra,extra_info,extra_warning,extra_danger, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, @@ -34,6 +35,7 @@ 'paletteDomain' => ['showitem' => 'domain, secret, --linebreak--, basic_auth_username, basic_auth_password, host_header, --linebreak--, ignore_cert_errors, force_ip_resolve'], 'paletteVersions' => ['showitem' => 'php_version, mysql_version'], 'paletteDiskSpace' => ['showitem' => 'disk_total_space, disk_free_space'], + 'paletteTask' => ['showitem' => 'task_alert_late, task_alert_error'] ], 'columns' => [ 'hidden' => [ @@ -296,5 +298,17 @@ 'minitems' => 0, ], ], + 'task_alert_late' => [ + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.task_alert_late', + 'config' => [ + 'type' => 'check', + ], + ], + 'task_alert_error' => [ + 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.task_alert_error', + 'config' => [ + 'type' => 'check', + ], + ] ], ]; diff --git a/Resources/Private/Language/de.locallang.xlf b/Resources/Private/Language/de.locallang.xlf index ec0386c..7395704 100644 --- a/Resources/Private/Language/de.locallang.xlf +++ b/Resources/Private/Language/de.locallang.xlf @@ -87,6 +87,14 @@ Sla Sla + + Alert on late tasks? + Benachrichtigung bei verspäteten Tasks? + + + Alert on error tasks? + Benachrichtigung bei fehlerhaften Tasks? + Extension Extension diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index d58fe4b..1357ad9 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -96,6 +96,12 @@ Tag + + Alert on late tasks? + + + Alert on error tasks? + Extension diff --git a/ext_tables.sql b/ext_tables.sql index 8d16d27..68ec5a4 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -33,6 +33,8 @@ CREATE TABLE tx_t3monitoring_domain_model_client ( core int(11) unsigned DEFAULT '0', sla int(11) unsigned DEFAULT '0', tag tinytext, + task_alert_late tinyint(4) unsigned DEFAULT '0' NOT NULL, + task_alert_error tinyint(4) unsigned DEFAULT '0' NOT NULL, tstamp int(11) unsigned DEFAULT '0' NOT NULL, crdate int(11) unsigned DEFAULT '0' NOT NULL, From f8b4a427bebea70112c6c015b279770fd97528fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Tue, 30 Mar 2021 12:38:19 +0200 Subject: [PATCH 22/26] [DOC] Adapt code documentation --- Classes/Service/Import/TaskImport.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Classes/Service/Import/TaskImport.php b/Classes/Service/Import/TaskImport.php index 33421ad..615b81c 100644 --- a/Classes/Service/Import/TaskImport.php +++ b/Classes/Service/Import/TaskImport.php @@ -77,7 +77,8 @@ public function importTasks(array $client, array $importTasks): void } /** - * Returns the current tasks of this client from the database + * Returns the the uid and the client_task_uid of all tasks of + * a specific client. * * @param int $clientUid The uid of the client * From 2a9c2012d652b5c07870e8887f6fabdc15e53360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Fri, 9 Apr 2021 21:01:46 +0200 Subject: [PATCH 23/26] [TASK] Remove task notification options --- Classes/Domain/Model/Client.php | 54 ------------------- .../tx_t3monitoring_domain_model_client.php | 19 +------ 2 files changed, 2 insertions(+), 71 deletions(-) diff --git a/Classes/Domain/Model/Client.php b/Classes/Domain/Model/Client.php index 60c499e..bbf7962 100644 --- a/Classes/Domain/Model/Client.php +++ b/Classes/Domain/Model/Client.php @@ -158,16 +158,6 @@ class Client extends AbstractEntity */ protected $tag = null; - /** - * @var bool - */ - protected $taskAlertLate = false; - - /** - * @var bool - */ - protected $taskAlertError = false; - /** * __construct */ @@ -797,48 +787,4 @@ public function getTaskStatus(): int $taskRepository = $objectManager->get(TaskRepository::class); return $taskRepository->getTaskStatusForClientId($this->uid); } - - /** - * Get the value of taskAlertLate - * - * @return bool - */ - public function getTaskAlertLate() - { - return $this->taskAlertLate; - } - - /** - * Set the value of taskAlertLate - * - * @param bool $taskAlertLate - * - * @return void - */ - public function setTaskAlertLate(bool $taskAlertLate): void - { - $this->taskAlertLate = $taskAlertLate; - } - - /** - * Get the value of taskAlertError - * - * @return bool - */ - public function getTaskAlertError() - { - return $this->taskAlertError; - } - - /** - * Set the value of taskAlertError - * - * @param bool $taskAlertError - * - * @return void - */ - public function setTaskAlertError(bool $taskAlertError): void - { - $this->taskAlertError = $taskAlertError; - } } diff --git a/Configuration/TCA/tx_t3monitoring_domain_model_client.php b/Configuration/TCA/tx_t3monitoring_domain_model_client.php index 85ca422..6a0ce3c 100644 --- a/Configuration/TCA/tx_t3monitoring_domain_model_client.php +++ b/Configuration/TCA/tx_t3monitoring_domain_model_client.php @@ -10,17 +10,16 @@ 'enablecolumns' => [ 'disabled' => 'hidden', ], - 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,disk_total_space,disk_free_space,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,core,sla,tag, task_alert_late, task_alert_error', + 'searchFields' => 'title,domain,secret,email,php_version,mysql_version,disk_total_space,disk_free_space,insecure_core,outdated_core,insecure_extensions,outdated_extensions,error_message,extensions,core,sla,tag', 'iconfile' => 'EXT:t3monitoring/Resources/Public/Icons/tx_t3monitoring_domain_model_client.svg' ], 'interface' => [ - 'showRecordFieldList' => 'hidden, title, domain, secret, basic_auth_username, basic_auth_password, host_header, ignore_cert_errors, force_ip_resolve, php_version, mysql_version, disk_total_space, disk_free_space, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, core, sla, tag, task_alert_late, task_alert_error', + 'showRecordFieldList' => 'hidden, title, domain, secret, basic_auth_username, basic_auth_password, host_header, ignore_cert_errors, force_ip_resolve, php_version, mysql_version, disk_total_space, disk_free_space, insecure_core, outdated_core, insecure_extensions, outdated_extensions, error_message, extensions, core, sla, tag', ], 'types' => [ 1 => [ 'showitem' => ' --div--;General,--palette--;;paletteTitle, --palette--;;paletteDomain,email,sla,tag, - --div--;Tasks,--palette--;;paletteTitle, --palette--;;paletteTask, --div--;Readonly information,last_successful_import,error_message,--palette--;;paletteCore, --palette--;;paletteExtensions, --palette--;;paletteVersions, --palette--;;paletteDiskSpace, --div--;Extra,extra_info,extra_warning,extra_danger, --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access, @@ -34,8 +33,6 @@ 'paletteExtensions' => ['showitem' => 'extensions, --linebreak--, insecure_extensions, outdated_extensions,'], 'paletteDomain' => ['showitem' => 'domain, secret, --linebreak--, basic_auth_username, basic_auth_password, host_header, --linebreak--, ignore_cert_errors, force_ip_resolve'], 'paletteVersions' => ['showitem' => 'php_version, mysql_version'], - 'paletteDiskSpace' => ['showitem' => 'disk_total_space, disk_free_space'], - 'paletteTask' => ['showitem' => 'task_alert_late, task_alert_error'] ], 'columns' => [ 'hidden' => [ @@ -297,18 +294,6 @@ 'foreign_table' => 'tx_t3monitoring_domain_model_core', 'minitems' => 0, ], - ], - 'task_alert_late' => [ - 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.task_alert_late', - 'config' => [ - 'type' => 'check', - ], - ], - 'task_alert_error' => [ - 'label' => 'LLL:EXT:t3monitoring/Resources/Private/Language/locallang.xlf:tx_t3monitoring_domain_model_client.task_alert_error', - 'config' => [ - 'type' => 'check', - ], ] ], ]; From 3bdc9133023a5cb3c767ba41dc78067ff340efa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=B6rmann-Engl?= Date: Thu, 9 Sep 2021 16:50:09 +0200 Subject: [PATCH 24/26] [BUGFIX] Fix task deletion when none are given --- Classes/Service/Import/ClientImport.php | 5 ++--- Classes/Service/Import/TaskImport.php | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Classes/Service/Import/ClientImport.php b/Classes/Service/Import/ClientImport.php index 8cd38bb..3bb1a29 100644 --- a/Classes/Service/Import/ClientImport.php +++ b/Classes/Service/Import/ClientImport.php @@ -135,9 +135,8 @@ protected function importSingleClient(array $row) ->getConnectionForTable(self::TABLE); $connection->update(self::TABLE, $update, ['uid' => (int)$row['uid']]); - if (isset($json['tasks']) && count($json['tasks']) > 0) { - $this->taskImporter->importTasks($row, $json['tasks']); - } + // Import tasks --> if no json for tasks is given, only deletions + $this->taskImporter->importTasks($row, $json['tasks']); $this->responseCount['success']++; } catch (Exception $e) { diff --git a/Classes/Service/Import/TaskImport.php b/Classes/Service/Import/TaskImport.php index 615b81c..fc41760 100644 --- a/Classes/Service/Import/TaskImport.php +++ b/Classes/Service/Import/TaskImport.php @@ -20,11 +20,11 @@ class TaskImport extends BaseImport * Import the given tasks for a client into the database. * * @param array $client The client - * @param array $tasks The client's scheduled tasks + * @param array ?$importTasks The client's scheduled tasks * * @return void */ - public function importTasks(array $client, array $importTasks): void + public function importTasks(array $client, ?array $importTasks): void { $currentTasks = $this->getTasksForClient($client['uid']); From d944b88936161cfdaebbca5935630d6002e8a19d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=83rmann-Engl?= Date: Tue, 28 Jun 2022 21:47:25 +0200 Subject: [PATCH 25/26] bugfix: only import if there is a json for tasks --- Classes/Service/Import/ClientImport.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/Service/Import/ClientImport.php b/Classes/Service/Import/ClientImport.php index 3bb1a29..9dcb677 100644 --- a/Classes/Service/Import/ClientImport.php +++ b/Classes/Service/Import/ClientImport.php @@ -136,7 +136,9 @@ protected function importSingleClient(array $row) $connection->update(self::TABLE, $update, ['uid' => (int)$row['uid']]); // Import tasks --> if no json for tasks is given, only deletions - $this->taskImporter->importTasks($row, $json['tasks']); + if ($json['tasks']) { + $this->taskImporter->importTasks($row, $json['tasks']); + } $this->responseCount['success']++; } catch (Exception $e) { From 0a562b754dcfb754fb75983a32a5d676d89d2358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Klaus=20H=C3=83rmann-Engl?= Date: Thu, 15 Dec 2022 08:29:10 +0100 Subject: [PATCH 26/26] task: display php version in overview --- Resources/Private/Templates/Statistic/Index.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Resources/Private/Templates/Statistic/Index.html b/Resources/Private/Templates/Statistic/Index.html index 072f5cc..9a7a07b 100644 --- a/Resources/Private/Templates/Statistic/Index.html +++ b/Resources/Private/Templates/Statistic/Index.html @@ -312,6 +312,7 @@ {f:translate(key:'tx_t3monitoring_domain_model_sla')} {f:translate(key:'tx_t3monitoring_domain_model_tag')} {f:translate(key:'tx_t3monitoring_domain_model_core')} + PHP - - - @@ -400,9 +401,17 @@ - + {client.core.version} + QUICK AND DIRTY ;-) + + danger + danger + success + + {client.phpVersion}