{# Linux Cron Job Scheduler Page #} {% extends "base.html" %} {# --- Page Title Block --- #} {% block title %}{{ super() }} - Cron Scheduler: {{ server_name }}{% endblock %} {# --- Head Scripts Block --- #} {% block head_scripts %} {# Define page-specific JS variables within a namespace #} {# Core utilities #} {# JS specific to Linux cron job interactions #} {% endblock %} {# --- Main Content Block --- #} {% block content %} {# Main heading for the page #}

Cron Job Scheduler (Linux)

{# Server context #}

Server Context: {{ server_name }}

{# --- Status Message Area --- #} {# Targeted by JavaScript (showStatusMessage) #}
{# Server-side flash messages (handled by base.html) #} {# --- Section to Display Existing Cron Jobs --- #}
{# Use list-section for consistency #}

Current Scheduled Jobs

List of cron jobs associated with this server context found in the user's crontab.

{# Check if table_data (passed from route) has jobs #} {% if table_data %} {# Responsive table wrapper #}
{# Table headers #} {# Readable time #} {# Display command #} {# Loop through formatted job data #} {% for job in table_data %} {# Display raw schedule parts #} {# Display human-readable schedule #} {# Display simplified command #} {# Action links/buttons #} {% endfor %}
Min Hour Day Mon DoW Readable ScheduleCommand ActionActions
{{ job.minute }} {{ job.hour }} {{ job.day_of_month }} {{ job.month }} {{ job.day_of_week }}{{ job.schedule_time }}{{ job.command_display }}
{# Wrapper for buttons #} {# Modify Link: Calls JS function to populate form #} {# Arguments need escaping for JS string literals #} Modify {# Delete Link: Calls JS function with confirmation #} {# Construct the full original string needed by the delete API #} {% set original_cron_string = job.minute ~ ' ' ~ job.hour ~ ' ' ~ job.day_of_month ~ ' ' ~ job.month ~ ' ' ~ job.day_of_week ~ ' ' ~ job.command %} Delete
{# --- End .table-responsive-wrapper --- #} {% else %} {# Message if no jobs are found for this server #}

{# Use consistent class #} No specific cron jobs found scheduled for server context '{{ server_name }}'.

{% endif %} {# Navigation/Action related to the list view #}
« Back to Dashboard {# Button to scroll to/show the Add form #}
{# --- End .schedule-tasks-section --- #} {# --- Section for Add/Modify Form --- #}
{# Use ID for scrolling/linking #} {# Form title will be updated by JS when modifying #}

Add New Cron Job

{# Use onsubmit on the form tag to call JS handler #} {# novalidate disables default browser validation bubbles #}
{# CSRF token - important if your JS sends it via header (like in utils.js) #} {# Although crontab modification might not need CSRF if done server-side, keep for consistency if API uses it #} {# Add data attribute to pass EXPATH to JS if needed #} {# --- Command Selection --- #}
{# Placeholder for JS validation #}
{# --- Cron Time Fields --- #}

Enter schedule time (* = any value):

{# Use grid layout for better alignment #}
{# Basic pattern validation for guidance; full validation server-side/JS #} 0-59, *
0-23, *
1-31, *
1-12, *
0-6 (Sun=0), *
{# --- End .cron-grid --- #} {# Hidden input stores the original full cron string when modifying #} {# JS uses this to determine if it's an ADD or MODIFY action #} {# --- Form Actions --- #}
{# JS should change text to 'Update Job' when modifying #} {# Button type="submit" triggers form's onsubmit event #} {# Use start-button style #} {# Optional button to clear/reset the form fields #}
{# --- End #cron-form --- #}
{# --- End .add-cron-job-section --- #} {% endblock %}