Enhance cron job builder with "Select All" options for time units and remove "custom" option

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 705f2157-ef97-4fbd-89e4-8c7f2ecaea90
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7ed01c5f-a82d-405a-b728-b2e3d127c60c/3e43a46b-eb88-40c4-b4c3-92293e8327e6.jpg
This commit is contained in:
alphaeusmote
2025-04-11 03:39:30 +00:00
parent 5a0ed471f3
commit 15347237e7
2 changed files with 89 additions and 6 deletions
@@ -281,10 +281,8 @@ export const CronJobBuilder: React.FC<CronJobBuilderProps> = ({
return `Runs weekly on ${schedule.dayOfWeek || 'Monday'} at ${formatTime(schedule.hour, schedule.minute)}`;
case 'monthly':
return `Runs monthly on day ${schedule.dayOfMonth || 1} at ${formatTime(schedule.hour, schedule.minute)}`;
case 'custom':
return 'Custom schedule';
default:
return 'Custom schedule';
return 'Advanced schedule';
}
};
@@ -724,6 +722,34 @@ export const CronJobBuilder: React.FC<CronJobBuilderProps> = ({
</AccordionTrigger>
<AccordionContent>
<div className="space-y-4 pt-2">
<div className="mb-2 flex justify-between items-center">
<Button
variant="outline"
size="sm"
onClick={() => {
// Select all days of week
updateSchedule(index, {
daysOfWeek: [...weekdays],
customSchedule: true
});
}}
>
Select All
</Button>
<Button
variant="outline"
size="sm"
onClick={() => {
// Clear all selected days
updateSchedule(index, {
daysOfWeek: [],
customSchedule: true
});
}}
>
Clear All
</Button>
</div>
<div className="grid grid-cols-3 sm:grid-cols-4 gap-2">
{weekdays.map((day) => (
<Button
@@ -760,6 +786,35 @@ export const CronJobBuilder: React.FC<CronJobBuilderProps> = ({
</AccordionTrigger>
<AccordionContent>
<div className="space-y-4 pt-2">
<div className="mb-2 flex justify-between items-center">
<Button
variant="outline"
size="sm"
onClick={() => {
// Select all days of month (1-31)
const allDays = Array.from({ length: 31 }, (_, i) => i + 1);
updateSchedule(index, {
daysOfMonth: allDays,
customSchedule: true
});
}}
>
Select All
</Button>
<Button
variant="outline"
size="sm"
onClick={() => {
// Clear all selected days
updateSchedule(index, {
daysOfMonth: [],
customSchedule: true
});
}}
>
Clear All
</Button>
</div>
<div className="grid grid-cols-7 gap-2">
{Array.from({ length: 31 }, (_, i) => i + 1).map((day) => (
<Button
@@ -796,6 +851,35 @@ export const CronJobBuilder: React.FC<CronJobBuilderProps> = ({
</AccordionTrigger>
<AccordionContent>
<div className="space-y-4 pt-2">
<div className="mb-2 flex justify-between items-center">
<Button
variant="outline"
size="sm"
onClick={() => {
// Select all months (1-12)
const allMonths = Array.from({ length: 12 }, (_, i) => i + 1);
updateSchedule(index, {
months: allMonths,
customSchedule: true
});
}}
>
Select All
</Button>
<Button
variant="outline"
size="sm"
onClick={() => {
// Clear all selected months
updateSchedule(index, {
months: [],
customSchedule: true
});
}}
>
Clear All
</Button>
</div>
<div className="grid grid-cols-3 sm:grid-cols-4 gap-2">
{[
'January', 'February', 'March', 'April',
+2 -3
View File
@@ -154,8 +154,7 @@ export const scheduleFrequencies = [
"daily",
"weekly",
"monthly",
"yearly",
"custom"
"yearly"
] as const;
export const weekdays = [
@@ -172,7 +171,7 @@ export const weekdays = [
export const scheduleRules = pgTable("schedule_rules", {
id: serial("id").primaryKey(),
ruleId: integer("rule_id").references(() => dynamicGroupRules.id, { onDelete: "cascade" }).notNull(),
frequency: text("frequency").notNull(), // once, minutely, hourly, daily, weekly, monthly, yearly, custom
frequency: text("frequency").notNull(), // once, minutely, hourly, daily, weekly, monthly, yearly
minute: integer("minute"), // 0-59
hour: integer("hour"), // 0-23
dayOfMonth: integer("day_of_month"), // 1-31