Commit 1d7642ae authored by Georg Ringer's avatar Georg Ringer Committed by Andreas Fernandez
Browse files

[FEATURE] Add interval presets for cron command field of scheduler task

Improve the usability by having presets for the cron command field
of a scheduler task.

Resolves: #44297
Releases: master
Change-Id: Iedf4da6c36bc3a77ac2886401efedbfd491c5005
Reviewed-on: https://review.typo3.org/57293


Reviewed-by: default avatarSebastian Hofer <sebastian.hofer@marit.ag>
Tested-by: default avatarSebastian Hofer <sebastian.hofer@marit.ag>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Jonas Götze's avatarJonas Götze <jonnsn@gmail.com>
Tested-by: Jonas Götze's avatarJonas Götze <jonnsn@gmail.com>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
parent 57225f2c
.. include:: ../../Includes.txt
=====================================================================
Feature: #44297 - Interval presets for cron command of scheduler task
=====================================================================
See :issue:`44297`
Description
===========
To support administrators creating scheduler tasks, presets have been added to the frequency field.
The default presets are:
.. code-block:: php
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions'] = [
'0 9,15 * * 1-5' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example1',
'0 */2 * * *' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example2',
'*/20 * * * *' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example3',
'0 7 * * 2' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example4',
];
.. index:: Backend, ext:scheduler
......@@ -701,6 +701,7 @@ class SchedulerModuleController
$this->view->assign('returnUrl', (string)GeneralUtility::getIndpEnv('REQUEST_URI'));
$this->view->assign('table', implode(LF, $table));
$this->view->assign('now', $this->getServerTime());
$this->view->assign('frequencyOptions', (array)$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions']);
return $this->view->render();
}
......
......@@ -441,6 +441,18 @@
<trans-unit id="label.ipAnonymization.mask.2">
<source>Last 2 bytes for IPv4 / Interface &amp; SLA ID for IPv6</source>
</trans-unit>
<trans-unit id="command.example1">
<source>Every day-of-week from Monday through Friday. at 09:00 and 15:00</source>
</trans-unit>
<trans-unit id="command.example2">
<source>Every 2 hours</source>
</trans-unit>
<trans-unit id="command.example3">
<source>Every 20 minutes</source>
</trans-unit>
<trans-unit id="command.example4">
<source>Every Tuesday at 07:00</source>
</trans-unit>
</body>
</file>
</xliff>
......@@ -97,7 +97,25 @@
<div class="form-group">
<f:be.labels.csh table="{csh}" field="task_frequency" label="{lang}label.frequency.long"/>
<div class="form-control-wrap">
<input type="text" name="tx_scheduler[frequency]" class="form-control" id="task_frequency" value="{frequency}">
<div class="form-wizards-wrap">
<div class="form-wizards-element">
<input type="text" name="tx_scheduler[frequency]" class="form-control" id="task_frequency" value="{frequency}">
</div>
<f:if condition="{frequencyOptions}">
<div class="form-wizards-items-aside">
<div class="btn-group">
<select
class="form-control tceforms-select tceforms-wizardselect"
onchange="document.getElementById('task_frequency').value=this.options[this.selectedIndex].value;this.blur();this.selectedIndex=0;">
<option></option>
<f:for each="{frequencyOptions}" as="label" key="command">
<option value="{command}">{f:translate(key:label,default:label)} ({command})</option>
</f:for>
</select>
</div>
</div>
</f:if>
</div>
</div>
</div>
</div>
......
......@@ -124,3 +124,11 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Sched
'additionalFields' => \TYPO3\CMS\Scheduler\Task\OptimizeDatabaseTableAdditionalFieldProvider::class
];
// Available frequency options
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions'] = [
'0 9,15 * * 1-5' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example1',
'0 */2 * * *' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example2',
'*/20 * * * *' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example3',
'0 7 * * 2' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example4',
];
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