File size: 10,648 Bytes
16a0ca6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | <!-- Script Form Partial -->
<div class="space-y-6">
<!-- Name -->
<div>
<label for="id_name" class="block text-sm font-medium text-code-text mb-2">
{{ form.name.label }}
</label>
{{ form.name }}
{% if form.name.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.name.errors.0 }}</p>
{% endif %}
</div>
<!-- Description -->
<div>
<label for="id_description" class="block text-sm font-medium text-code-text mb-2">
{{ form.description.label }}
</label>
{{ form.description }}
{% if form.description.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.description.errors.0 }}</p>
{% endif %}
</div>
<!-- Code -->
<div>
<label for="id_code" class="block text-sm font-medium text-code-text mb-2">
{{ form.code.label }}
</label>
<!-- Hidden textarea for Django form submission -->
{{ form.code }}
<!-- Ace Editor container -->
<div id="code-editor-container" style="height: 400px;" class="rounded-lg border border-code-border overflow-hidden"></div>
{% if form.code.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.code.errors.0 }}</p>
{% endif %}
</div>
<!-- Environment and Timeout Row -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Environment -->
<div>
<label for="id_environment" class="block text-sm font-medium text-code-text mb-2">
{{ form.environment.label }}
</label>
{{ form.environment }}
{% if form.environment.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.environment.errors.0 }}</p>
{% endif %}
</div>
<!-- Timeout -->
<div>
<label for="id_timeout_seconds" class="block text-sm font-medium text-code-text mb-2">
{{ form.timeout_seconds.label }}
</label>
{{ form.timeout_seconds }}
{% if form.timeout_seconds.help_text %}
<p class="mt-1 text-xs text-code-muted">{{ form.timeout_seconds.help_text }}</p>
{% endif %}
{% if form.timeout_seconds.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.timeout_seconds.errors.0 }}</p>
{% endif %}
</div>
</div>
<!-- Tags -->
<div>
<label class="block text-sm font-medium text-code-text mb-2">
{{ form.tags.label }}
</label>
<div class="flex flex-wrap gap-2 p-4 bg-code-bg border border-code-border rounded-lg min-h-[3rem]">
{% for checkbox in form.tags %}
<label class="inline-flex items-center px-3 py-1.5 rounded-full cursor-pointer border transition-colors
{% if checkbox.data.selected %}border-code-accent bg-code-accent/20{% else %}border-code-border bg-code-surface hover:border-code-accent/50{% endif %}">
<input type="checkbox" name="tags" value="{{ checkbox.data.value }}" {% if checkbox.data.selected %}checked{% endif %} class="sr-only peer">
<span class="w-2 h-2 rounded-full mr-2 tag-dot-{{ checkbox.data.attrs.data_color|default:'gray' }}"></span>
<span class="text-sm text-code-text">{{ checkbox.choice_label }}</span>
</label>
{% empty %}
<p class="text-sm text-code-muted">No tags available. <a href="{% url 'cpanel:tag_list' %}" class="text-code-accent hover:underline">Create tags</a></p>
{% endfor %}
</div>
{% if form.tags.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.tags.errors.0 }}</p>
{% endif %}
</div>
<!-- Enabled -->
<div class="flex items-center space-x-3">
{{ form.is_enabled }}
<label for="id_is_enabled" class="text-sm font-medium text-code-text">
{{ form.is_enabled.label }}
</label>
{% if form.is_enabled.errors %}
<p class="text-sm text-code-red">{{ form.is_enabled.errors.0 }}</p>
{% endif %}
</div>
{% if schedule_form %}
<!-- Schedule Configuration Section -->
<div class="mt-8 pt-6 border-t border-code-border">
<h3 class="text-lg font-semibold text-code-text mb-4">Schedule Configuration</h3>
<!-- Run Mode Selection -->
<div class="mb-6">
<label class="block text-sm font-medium text-code-text mb-3">Run Mode</label>
<div class="grid grid-cols-3 gap-4">
{% for radio in schedule_form.run_mode %}
<label class="relative flex items-center justify-center p-4 border border-code-border rounded-lg cursor-pointer hover:border-code-accent transition-colors {% if radio.data.selected %}border-code-accent bg-code-accent/10{% endif %}">
<input type="radio" name="run_mode" value="{{ radio.data.value }}" {% if radio.data.selected %}checked{% endif %} class="sr-only peer" onchange="toggleScheduleOptions(this.value)">
<span class="text-code-text font-medium">{{ radio.choice_label }}</span>
</label>
{% endfor %}
</div>
{% if schedule_form.run_mode.errors %}
<p class="mt-1 text-sm text-code-red">{{ schedule_form.run_mode.errors.0 }}</p>
{% endif %}
</div>
<!-- Interval Options (shown when interval mode selected) -->
<div id="interval-options" class="mb-6 {% if schedule_form.instance.run_mode != 'interval' %}hidden{% endif %}">
<label for="id_interval_minutes" class="block text-sm font-medium text-code-text mb-2">
{{ schedule_form.interval_minutes.label }}
</label>
{{ schedule_form.interval_minutes }}
{% if schedule_form.interval_minutes.errors %}
<p class="mt-1 text-sm text-code-red">{{ schedule_form.interval_minutes.errors.0 }}</p>
{% endif %}
</div>
<!-- Daily Options (shown when daily mode selected) -->
<div id="daily-options" class="mb-6 {% if schedule_form.instance.run_mode != 'daily' %}hidden{% endif %}">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<label for="id_daily_times_input" class="block text-sm font-medium text-code-text mb-2">
{{ schedule_form.daily_times_input.label }}
</label>
{{ schedule_form.daily_times_input }}
<p class="mt-1 text-xs text-code-muted">{{ schedule_form.daily_times_input.help_text }}</p>
{% if schedule_form.daily_times_input.errors %}
<p class="mt-1 text-sm text-code-red">{{ schedule_form.daily_times_input.errors.0 }}</p>
{% endif %}
</div>
<div>
<label for="id_timezone" class="block text-sm font-medium text-code-text mb-2">
Timezone
</label>
{{ schedule_form.timezone }}
{% if schedule_form.timezone.errors %}
<p class="mt-1 text-sm text-code-red">{{ schedule_form.timezone.errors.0 }}</p>
{% endif %}
</div>
</div>
</div>
<!-- Schedule Active Toggle -->
<div class="flex items-center space-x-3">
{{ schedule_form.is_active }}
<label for="id_is_active" class="text-sm font-medium text-code-text">
{{ schedule_form.is_active.label }}
</label>
{% if schedule_form.is_active.errors %}
<p class="text-sm text-code-red">{{ schedule_form.is_active.errors.0 }}</p>
{% endif %}
</div>
</div>
<script>
function toggleScheduleOptions(mode) {
document.getElementById('interval-options').classList.toggle('hidden', mode !== 'interval');
document.getElementById('daily-options').classList.toggle('hidden', mode !== 'daily');
}
</script>
{% endif %}
<!-- Notification Configuration Section -->
<div class="mt-8 pt-6 border-t border-code-border">
<h3 class="text-lg font-semibold text-code-text mb-4">Notification Settings</h3>
<div class="space-y-6">
<!-- Notify On -->
<div>
<label for="id_notify_on" class="block text-sm font-medium text-code-text mb-2">
{{ form.notify_on.label }}
</label>
{{ form.notify_on }}
{% if form.notify_on.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.notify_on.errors.0 }}</p>
{% endif %}
</div>
<!-- Override Email -->
<div>
<label for="id_notify_email" class="block text-sm font-medium text-code-text mb-2">
{{ form.notify_email.label }}
</label>
{{ form.notify_email }}
{% if form.notify_email.help_text %}
<p class="mt-1 text-xs text-code-muted">{{ form.notify_email.help_text }}</p>
{% endif %}
{% if form.notify_email.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.notify_email.errors.0 }}</p>
{% endif %}
</div>
<!-- Webhook Configuration -->
<div class="p-4 bg-code-bg rounded-lg space-y-4">
<div class="flex items-center space-x-3">
{{ form.notify_webhook_enabled }}
<label for="id_notify_webhook_enabled" class="text-sm font-medium text-code-text">
{{ form.notify_webhook_enabled.label }}
</label>
</div>
<div>
<label for="id_notify_webhook_url" class="block text-sm font-medium text-code-text mb-2">
{{ form.notify_webhook_url.label }}
</label>
{{ form.notify_webhook_url }}
{% if form.notify_webhook_url.help_text %}
<p class="mt-1 text-xs text-code-muted">{{ form.notify_webhook_url.help_text }}</p>
{% endif %}
{% if form.notify_webhook_url.errors %}
<p class="mt-1 text-sm text-code-red">{{ form.notify_webhook_url.errors.0 }}</p>
{% endif %}
</div>
</div>
</div>
</div>
</div>
|