Skip to content

Commit 267a528

Browse files
committed
add crontab human readable
1 parent a088d95 commit 267a528

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/features/CrontabGenerator.jsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ const CrontabGenerator = () => {
6767
setExpression(`${newFields.minute} ${newFields.hour} ${newFields.day} ${newFields.month} ${newFields.weekday}`);
6868
};
6969

70+
const handleExpressionChange = (value) => {
71+
setExpression(value.trim().replace(/\s+/g, ' '));
72+
};
73+
7074
// Auto-remove '*' when focusing
7175
const handleFocus = (field) => {
7276
if (fields[field] === '*') {
@@ -83,7 +87,7 @@ const CrontabGenerator = () => {
8387

8488
// Update fields when expression changes (simple split)
8589
useEffect(() => {
86-
const parts = expression.split(' ');
90+
const parts = expression.trim().split(/\s+/);
8791
if (parts.length === 5) {
8892
setFields({
8993
minute: parts[0],
@@ -159,6 +163,19 @@ const CrontabGenerator = () => {
159163
</div>
160164
</div>
161165

166+
{/* Direct Input */}
167+
<div className="flex flex-col gap-2">
168+
<label className="text-xs text-slate-400 font-medium uppercase tracking-wider">Cron Expression</label>
169+
<input
170+
type="text"
171+
value={expression}
172+
onChange={(e) => handleExpressionChange(e.target.value)}
173+
placeholder="0 5 * * *"
174+
className="w-full bg-slate-900 border border-slate-700 rounded-lg px-4 py-3 text-base md:text-lg font-mono text-slate-200 focus:border-blue-500 outline-none focus:ring-1 focus:ring-blue-500/50 transition-all"
175+
/>
176+
<span className="text-[11px] text-slate-500">Example: <code className="text-blue-400">0 5 * * *</code> (every day at 05:00)</span>
177+
</div>
178+
162179
{/* Editor Fields */}
163180
<div className="grid grid-cols-5 gap-2 md:gap-4">
164181
{[

0 commit comments

Comments
 (0)