From ad0d232b7ca6f9ef1d2483a2f2488d0798d20d23 Mon Sep 17 00:00:00 2001 From: Armin Pleisch Date: Mon, 5 Jun 2023 11:07:23 +0200 Subject: [PATCH] feat: Add cleanup maintenance command --- src/ProcessManagerBundle/Controller/ProcessController.php | 7 ++++--- .../DependencyInjection/Configuration.php | 2 +- .../Resources/public/pimcore/js/processes.js | 8 ++++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ProcessManagerBundle/Controller/ProcessController.php b/src/ProcessManagerBundle/Controller/ProcessController.php index dc4282d..149ff34 100644 --- a/src/ProcessManagerBundle/Controller/ProcessController.php +++ b/src/ProcessManagerBundle/Controller/ProcessController.php @@ -18,6 +18,7 @@ use Pimcore\Db; use ProcessManagerBundle\Model\Process; use ProcessManagerBundle\Model\ProcessInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -106,14 +107,14 @@ public function stopAction(Request $request): JsonResponse ); } - public function clearAction(Request $request): JsonResponse + public function clearAction(Request $request, ParameterBagInterface $parameterBag): JsonResponse { $seconds = (int)$request->get('seconds', 604_800); $connection = Db::get(); $connection->executeStatement('DELETE FROM process_manager_processes WHERE started < UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL ? SECOND))', [$seconds]); - $logDirectory = \Pimcore::getContainer()->getParameter('process_manager.log_directory'); - $keepLogs = \Pimcore::getContainer()->getParameter('process_manager.keep_logs'); + $logDirectory = $parameterBag->get('process_manager.log_directory'); + $keepLogs = $parameterBag->get('process_manager.keep_logs'); if (!$keepLogs && is_dir($logDirectory)) { $files = scandir($logDirectory); foreach ($files as $file) { diff --git a/src/ProcessManagerBundle/DependencyInjection/Configuration.php b/src/ProcessManagerBundle/DependencyInjection/Configuration.php index d7eb121..8576d89 100644 --- a/src/ProcessManagerBundle/DependencyInjection/Configuration.php +++ b/src/ProcessManagerBundle/DependencyInjection/Configuration.php @@ -42,7 +42,7 @@ public function getConfigTreeBuilder(): TreeBuilder ->children() ->scalarNode('driver')->defaultValue(CoreShopResourceBundle::DRIVER_PIMCORE)->end() ->scalarNode('log_directory')->defaultValue('%kernel.logs_dir%')->end() - ->booleanNode('keep_logs')->defaultValue(false)->end() + ->booleanNode('keep_logs')->defaultValue(true)->end() ->end() ; diff --git a/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js b/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js index 70f2163..af7c217 100644 --- a/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js +++ b/src/ProcessManagerBundle/Resources/public/pimcore/js/processes.js @@ -145,6 +145,7 @@ pimcore.plugin.processmanager.processes = Class.create({ xtype: 'grid', store: store, bbar: pimcore.helpers.grid.buildDefaultPagingToolbar(store), + plugins: 'gridfilters', columns: [ { text: t('id'), @@ -154,12 +155,14 @@ pimcore.plugin.processmanager.processes = Class.create({ { text: t('name'), dataIndex: 'name', - width: 300 + width: 400, + filter: 'string' }, { text: t('processmanager_message'), dataIndex: 'message', - flex : 1 + flex : 1, + filter: 'string' }, { text: t('processmanager_started'), @@ -273,6 +276,7 @@ pimcore.plugin.processmanager.processes = Class.create({ text : t('processmanager_status'), width: 100, dataIndex: 'status', + filter: 'string', renderer: function (value, metadata, record) { if (record.data.status != '' && record.data.status != null) { return t('processmanager_' + record.data.status);