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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
|
<div class="slide-up space-y-6">
<div class="glass rounded-xl glow-border">
<div class="flex items-center justify-between px-5 py-4 border-b border-white/[0.04]">
<div class="flex items-center gap-3">
{% url "domains.manage" as domains_path %}
<a href="{{ domains_path }}" hx-get="{{ domains_path }}" hx-target="#content" hx-swap="innerHTML" hx-push-url="true" class="flex items-center justify-center w-8 h-8 rounded-lg bg-surface-800 hover:bg-surface-700 border border-white/[0.06] transition-colors duration-150">
<svg class="w-4 h-4 text-zinc-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18" />
</svg>
</a>
<div>
<h2 class="text-sm font-medium text-zinc-200">{{ domain.Name }}.{{ domain.TLD.Name }}</h2>
<p class="text-xs text-zinc-600">DNS Records</p>
</div>
</div>
<div class="flex items-center gap-3">
<span class="text-xs text-zinc-600">{{ records|length }} total</span>
<button type="button" class="btn-small" data-toggle-new-record>Add Record</button>
</div>
</div>
<div class="hidden border-b border-white/[0.04]" data-new-record-form>
{% url "domains.records.create" as create_record_path %}
<form hx-post="{{ create_record_path }}" hx-swap="none" class="px-5 py-4 space-y-3">
<input type="hidden" name="domain_id" value="{{ domain.ID }}">
<div class="grid grid-cols-5 gap-3">
<div>
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">Type</label>
<div class="dropdown" data-dropdown data-record-type-dropdown>
<input type="hidden" name="record_type" value="A" data-dropdown-value>
<button type="button" data-dropdown-trigger class="input-field text-xs text-left flex items-center justify-between">
<span class="truncate" data-dropdown-label>A</span>
<svg class="w-3.5 h-3.5 text-zinc-500 shrink-0 ml-1 transition-transform duration-150" data-dropdown-chevron fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
</svg>
</button>
<div class="dropdown-menu" data-dropdown-menu>
<div class="dropdown-options" data-dropdown-options>
<button type="button" class="dropdown-option" data-dropdown-option data-value="A" data-label="A"><p class="text-sm text-zinc-200">A</p><p class="text-xs text-zinc-500">IPv4 address</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="AAAA" data-label="AAAA"><p class="text-sm text-zinc-200">AAAA</p><p class="text-xs text-zinc-500">IPv6 address</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="CNAME" data-label="CNAME"><p class="text-sm text-zinc-200">CNAME</p><p class="text-xs text-zinc-500">Canonical name</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="MX" data-label="MX"><p class="text-sm text-zinc-200">MX</p><p class="text-xs text-zinc-500">Mail exchange</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="TXT" data-label="TXT"><p class="text-sm text-zinc-200">TXT</p><p class="text-xs text-zinc-500">Text record</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="SRV" data-label="SRV"><p class="text-sm text-zinc-200">SRV</p><p class="text-xs text-zinc-500">Service locator</p></button>
</div>
</div>
</div>
</div>
<div>
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">Name</label>
<input type="text" name="name" autocomplete="off" placeholder="@" class="input-field text-xs">
</div>
<div class="col-span-2">
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5" data-value-label>Address (IPv4)</label>
<input type="text" name="value" required autocomplete="off" placeholder="127.0.0.1" class="input-field text-xs" data-value-input>
</div>
<div>
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">TTL</label>
<div class="dropdown" data-dropdown>
<input type="hidden" name="ttl" value="1" data-dropdown-value>
<button type="button" data-dropdown-trigger class="input-field text-xs text-left flex items-center justify-between">
<span class="truncate" data-dropdown-label>Immediate</span>
<svg class="w-3.5 h-3.5 text-zinc-500 shrink-0 ml-1 transition-transform duration-150" data-dropdown-chevron fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
</svg>
</button>
<div class="dropdown-menu" data-dropdown-menu>
<div class="dropdown-options" data-dropdown-options>
<button type="button" class="dropdown-option" data-dropdown-option data-value="1" data-label="Immediate"><p class="text-sm text-zinc-200">Immediate</p><p class="text-xs text-zinc-500">1 second</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="300" data-label="5 minutes"><p class="text-sm text-zinc-200">5 minutes</p><p class="text-xs text-zinc-500">300 seconds</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="900" data-label="15 minutes"><p class="text-sm text-zinc-200">15 minutes</p><p class="text-xs text-zinc-500">900 seconds</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="3600" data-label="1 hour"><p class="text-sm text-zinc-200">1 hour</p><p class="text-xs text-zinc-500">3600 seconds</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="14400" data-label="4 hours"><p class="text-sm text-zinc-200">4 hours</p><p class="text-xs text-zinc-500">14400 seconds</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="86400" data-label="1 day"><p class="text-sm text-zinc-200">1 day</p><p class="text-xs text-zinc-500">86400 seconds</p></button>
</div>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-5 gap-3" data-extra-fields>
<div data-priority-field style="display: none;">
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">Priority</label>
<input type="number" name="priority" value="10" min="0" class="input-field text-xs">
</div>
<div data-srv-weight style="display: none;">
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">Weight</label>
<input type="number" name="weight" value="0" min="0" class="input-field text-xs">
</div>
<div data-srv-port style="display: none;">
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">Port</label>
<input type="number" name="port" value="0" min="0" class="input-field text-xs">
</div>
<div data-srv-protocol style="display: none;">
<label class="block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5">Protocol</label>
<div class="dropdown" data-dropdown>
<input type="hidden" name="protocol" value="tcp" data-dropdown-value>
<button type="button" data-dropdown-trigger class="input-field text-xs text-left flex items-center justify-between">
<span class="truncate" data-dropdown-label>TCP</span>
<svg class="w-3.5 h-3.5 text-zinc-500 shrink-0 ml-1 transition-transform duration-150" data-dropdown-chevron fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" />
</svg>
</button>
<div class="dropdown-menu" data-dropdown-menu>
<div class="dropdown-options" data-dropdown-options>
<button type="button" class="dropdown-option" data-dropdown-option data-value="tcp" data-label="TCP"><p class="text-sm text-zinc-200">TCP</p></button>
<button type="button" class="dropdown-option" data-dropdown-option data-value="udp" data-label="UDP"><p class="text-sm text-zinc-200">UDP</p></button>
</div>
</div>
</div>
</div>
</div>
<div class="flex items-center gap-3 pt-1">
<button type="submit" class="btn-small">Save Record</button>
<a href="javascript:void(0)" class="text-xs text-zinc-500 hover:text-zinc-300 transition-colors duration-150" data-cancel-new-record>Cancel</a>
</div>
</form>
</div>
{% if records %}
<div>
<div class="grid px-5 py-2.5 border-b border-white/[0.06]" style="grid-template-columns: 4.5rem 1fr 2fr 5rem 6rem;">
<span class="text-[10px] font-medium text-zinc-600 uppercase tracking-wider">Type</span>
<span class="text-[10px] font-medium text-zinc-600 uppercase tracking-wider">Name</span>
<span class="text-[10px] font-medium text-zinc-600 uppercase tracking-wider">Content</span>
<span class="text-[10px] font-medium text-zinc-600 uppercase tracking-wider">TTL</span>
<span class="text-[10px] font-medium text-zinc-600 uppercase tracking-wider text-right">Actions</span>
</div>
<div class="divide-y divide-white/[0.04]" data-records-list>
{% for record in records %}
<div class="group" data-record-row="{{ record.Type }}-{{ record.ID }}">
<div class="grid items-center px-5 py-3" style="grid-template-columns: 4.5rem 1fr 2fr 5rem 6rem;">
<span class="inline-flex items-center w-fit px-1.5 py-0.5 rounded text-[10px] font-medium
{% if record.Type == "A" %}bg-blue-500/10 text-blue-400
{% elif record.Type == "AAAA" %}bg-blue-500/10 text-blue-300
{% elif record.Type == "CNAME" %}bg-purple-500/10 text-purple-400
{% elif record.Type == "MX" %}bg-orange-500/10 text-orange-400
{% elif record.Type == "TXT" %}bg-green-500/10 text-green-400
{% elif record.Type == "SRV" %}bg-pink-500/10 text-pink-400
{% endif %}">{{ record.Type }}</span>
<p class="text-sm text-zinc-200 truncate pr-3">{{ record.Name }}</p>
<div class="flex items-center gap-2 min-w-0 pr-3">
<p class="text-sm text-zinc-400 truncate">{{ record.Value }}</p>
{% if record.Priority > 0 %}
<span class="inline-flex items-center px-1.5 py-0.5 rounded text-[10px] bg-surface-800 text-zinc-500 shrink-0">pri {{ record.Priority }}</span>
{% endif %}
</div>
<span class="text-xs text-zinc-600">{{ record.TTL }}s</span>
<div class="flex items-center justify-end gap-3">
<button type="button" class="text-xs text-zinc-600 hover:text-zinc-300 transition-colors duration-150" data-edit-record data-record-type="{{ record.Type }}" data-record-id="{{ record.ID }}" data-record-name="{{ record.Name }}" data-record-value="{{ record.Value }}" data-record-ttl="{{ record.TTL }}" data-record-priority="{{ record.Priority }}">Edit</button>
<button data-confirm-trigger data-confirm-title="Delete {{ record.Type }} record" data-confirm-message="This DNS record will be permanently removed. This action cannot be undone." data-confirm-action="/domains/records/{{ record.Type }}/{{ record.ID }}?domain_id={{ domain.ID }}" class="text-xs text-zinc-600 hover:text-red-400 transition-colors duration-150">Delete</button>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% else %}
<div class="flex flex-col items-center justify-center py-16 text-center">
<div class="flex items-center justify-center w-12 h-12 rounded-2xl bg-surface-800 mb-4">
<svg class="w-6 h-6 text-zinc-600" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 0 0-3.375-3.375h-1.5A1.125 1.125 0 0 1 13.5 7.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 0 0-9-9Z" />
</svg>
</div>
<p class="text-sm text-zinc-400">No DNS records</p>
<p class="mt-1 text-xs text-zinc-600">Click "Add Record" to get started</p>
</div>
{% endif %}
</div>
<div id="confirm-modal" class="fixed inset-0 z-50 hidden">
<div class="absolute inset-0 bg-black/60 backdrop-blur-sm" data-confirm-backdrop></div>
<div class="flex items-center justify-center min-h-screen p-4">
<div class="relative glass rounded-xl glow-border w-full max-w-sm p-6 space-y-4">
<div class="flex items-center gap-3">
<div class="flex items-center justify-center w-10 h-10 rounded-xl bg-red-500/10">
<svg class="w-5 h-5 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
</svg>
</div>
<h3 id="confirm-title" class="text-sm font-medium text-zinc-100"></h3>
</div>
<p id="confirm-message" class="text-xs text-zinc-400 leading-relaxed"></p>
<div class="flex items-center justify-end gap-3 pt-2">
<button data-confirm-cancel class="px-4 py-2 text-xs text-zinc-400 hover:text-zinc-200 rounded-lg bg-surface-800 border border-white/[0.06] hover:border-white/[0.1] transition-all duration-150">Cancel</button>
<button id="confirm-action" class="px-4 py-2 text-xs text-white rounded-lg bg-red-500/80 hover:bg-red-500 border border-red-400/20 transition-all duration-150">Delete</button>
</div>
</div>
</div>
</div>
</div>
<script>
(function() {
var toggleButton = document.querySelector('[data-toggle-new-record]');
var cancelButton = document.querySelector('[data-cancel-new-record]');
var formContainer = document.querySelector('[data-new-record-form]');
var typeDropdown = document.querySelector('[data-record-type-dropdown]');
var typeHiddenInput = typeDropdown.querySelector('[data-dropdown-value]');
var priorityField = document.querySelector('[data-priority-field]');
var srvWeight = document.querySelector('[data-srv-weight]');
var srvPort = document.querySelector('[data-srv-port]');
var srvProtocol = document.querySelector('[data-srv-protocol]');
var valueLabel = document.querySelector('[data-value-label]');
var valueInput = document.querySelector('[data-value-input]');
toggleButton.addEventListener('click', function() {
formContainer.classList.toggle('hidden');
});
cancelButton.addEventListener('click', function() {
formContainer.classList.add('hidden');
});
var fieldConfig = {
'A': { label: 'Address (IPv4)', placeholder: '127.0.0.1', priority: false, srv: false },
'AAAA': { label: 'Address (IPv6)', placeholder: '::1', priority: false, srv: false },
'CNAME': { label: 'Target', placeholder: 'other.example.dove.', priority: false, srv: false },
'MX': { label: 'Mail Server', placeholder: 'mail.example.dove.', priority: true, srv: false },
'TXT': { label: 'Content', placeholder: 'v=spf1 include:...', priority: false, srv: false },
'SRV': { label: 'Target Host', placeholder: 'service.example.dove.', priority: true, srv: true }
};
function updateFields() {
var selectedType = typeHiddenInput.value;
var config = fieldConfig[selectedType];
if (!config) return;
valueLabel.textContent = config.label;
valueInput.placeholder = config.placeholder;
priorityField.style.display = config.priority ? '' : 'none';
srvWeight.style.display = config.srv ? '' : 'none';
srvPort.style.display = config.srv ? '' : 'none';
srvProtocol.style.display = config.srv ? '' : 'none';
}
var typeOptions = typeDropdown.querySelectorAll('[data-dropdown-option]');
typeOptions.forEach(function(option) {
option.addEventListener('click', function() {
setTimeout(updateFields, 10);
});
});
updateFields();
var ttlOptions = [
{ value: '1', label: 'Immediate', desc: '1 second' },
{ value: '300', label: '5 minutes', desc: '300 seconds' },
{ value: '900', label: '15 minutes', desc: '900 seconds' },
{ value: '3600', label: '1 hour', desc: '3600 seconds' },
{ value: '14400', label: '4 hours', desc: '14400 seconds' },
{ value: '86400', label: '1 day', desc: '86400 seconds' }
];
var editFieldConfig = {
'A': { label: 'Address (IPv4)', placeholder: '127.0.0.1', priority: false },
'AAAA': { label: 'Address (IPv6)', placeholder: '::1', priority: false },
'CNAME': { label: 'Target', placeholder: 'other.example.dove.', priority: false },
'MX': { label: 'Mail Server', placeholder: 'mail.example.dove.', priority: true },
'TXT': { label: 'Content', placeholder: 'v=spf1 include:...', priority: false },
'SRV': { label: 'Target Host', placeholder: 'service.example.dove.', priority: true }
};
var chevronSvg = '<svg class="w-3.5 h-3.5 text-zinc-500 shrink-0 ml-1 transition-transform duration-150" data-dropdown-chevron fill="none" stroke="currentColor" viewBox="0 0 24 24" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="m19.5 8.25-7.5 7.5-7.5-7.5" /></svg>';
function buildTtlDropdown(currentTtl) {
var wrapper = document.createElement('div');
wrapper.className = 'dropdown';
wrapper.setAttribute('data-dropdown', '');
var currentLabel = 'Immediate';
for (var i = 0; i < ttlOptions.length; i++) {
if (ttlOptions[i].value === currentTtl) {
currentLabel = ttlOptions[i].label;
break;
}
}
var hidden = document.createElement('input');
hidden.type = 'hidden';
hidden.name = 'ttl';
hidden.value = currentTtl;
hidden.setAttribute('data-dropdown-value', '');
wrapper.appendChild(hidden);
var trigger = document.createElement('button');
trigger.type = 'button';
trigger.setAttribute('data-dropdown-trigger', '');
trigger.className = 'input-field text-xs text-left flex items-center justify-between';
var labelSpan = document.createElement('span');
labelSpan.className = 'truncate';
labelSpan.setAttribute('data-dropdown-label', '');
labelSpan.textContent = currentLabel;
trigger.appendChild(labelSpan);
trigger.insertAdjacentHTML('beforeend', chevronSvg);
wrapper.appendChild(trigger);
var menuDiv = document.createElement('div');
menuDiv.className = 'dropdown-menu';
menuDiv.setAttribute('data-dropdown-menu', '');
var optionsDiv = document.createElement('div');
optionsDiv.className = 'dropdown-options';
optionsDiv.setAttribute('data-dropdown-options', '');
for (var j = 0; j < ttlOptions.length; j++) {
var optBtn = document.createElement('button');
optBtn.type = 'button';
optBtn.className = 'dropdown-option';
optBtn.setAttribute('data-dropdown-option', '');
optBtn.setAttribute('data-value', ttlOptions[j].value);
optBtn.setAttribute('data-label', ttlOptions[j].label);
var optLabel = document.createElement('p');
optLabel.className = 'text-sm text-zinc-200';
optLabel.textContent = ttlOptions[j].label;
optBtn.appendChild(optLabel);
var optDesc = document.createElement('p');
optDesc.className = 'text-xs text-zinc-500';
optDesc.textContent = ttlOptions[j].desc;
optBtn.appendChild(optDesc);
optionsDiv.appendChild(optBtn);
}
menuDiv.appendChild(optionsDiv);
wrapper.appendChild(menuDiv);
return wrapper;
}
function createEditForm(recordType, recordId, recordName, recordValue, recordTtl, recordPriority) {
var config = editFieldConfig[recordType] || editFieldConfig['A'];
var form = document.createElement('form');
form.setAttribute('hx-put', '/domains/records/' + recordType + '/' + recordId + '?domain_id={{ domain.ID }}');
form.setAttribute('hx-swap', 'none');
form.setAttribute('data-inline-edit', '');
form.className = 'px-5 py-4 space-y-3';
var row1 = document.createElement('div');
row1.className = 'grid grid-cols-5 gap-3';
var typeCol = document.createElement('div');
var typeLabel = document.createElement('label');
typeLabel.className = 'block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5';
typeLabel.textContent = 'Type';
typeCol.appendChild(typeLabel);
var typeBadge = document.createElement('div');
typeBadge.className = 'input-field text-xs flex items-center opacity-60 cursor-not-allowed';
typeBadge.textContent = recordType;
typeCol.appendChild(typeBadge);
row1.appendChild(typeCol);
var nameCol = document.createElement('div');
var nameLabel = document.createElement('label');
nameLabel.className = 'block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5';
nameLabel.textContent = 'Name';
nameCol.appendChild(nameLabel);
var nameInput = document.createElement('input');
nameInput.type = 'text';
nameInput.name = 'name';
nameInput.value = recordName;
nameInput.autocomplete = 'off';
nameInput.placeholder = '@';
nameInput.className = 'input-field text-xs';
nameCol.appendChild(nameInput);
row1.appendChild(nameCol);
var valueCol = document.createElement('div');
valueCol.className = 'col-span-2';
var valueLbl = document.createElement('label');
valueLbl.className = 'block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5';
valueLbl.textContent = config.label;
valueCol.appendChild(valueLbl);
var valInput = document.createElement('input');
valInput.type = 'text';
valInput.name = 'value';
valInput.value = recordValue;
valInput.required = true;
valInput.autocomplete = 'off';
valInput.placeholder = config.placeholder;
valInput.className = 'input-field text-xs';
valueCol.appendChild(valInput);
row1.appendChild(valueCol);
var ttlCol = document.createElement('div');
var ttlLabel = document.createElement('label');
ttlLabel.className = 'block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5';
ttlLabel.textContent = 'TTL';
ttlCol.appendChild(ttlLabel);
ttlCol.appendChild(buildTtlDropdown(recordTtl));
row1.appendChild(ttlCol);
form.appendChild(row1);
var hasPriority = config.priority && parseInt(recordPriority, 10) > 0;
if (hasPriority) {
var row2 = document.createElement('div');
row2.className = 'grid grid-cols-5 gap-3';
var priCol = document.createElement('div');
var priLabel = document.createElement('label');
priLabel.className = 'block text-[10px] font-medium text-zinc-500 mb-1 ml-0.5';
priLabel.textContent = 'Priority';
priCol.appendChild(priLabel);
var priInput = document.createElement('input');
priInput.type = 'number';
priInput.name = 'priority';
priInput.value = recordPriority;
priInput.min = '0';
priInput.className = 'input-field text-xs';
priCol.appendChild(priInput);
row2.appendChild(priCol);
form.appendChild(row2);
}
var row3 = document.createElement('div');
row3.className = 'flex items-center gap-3 pt-1';
var saveButton = document.createElement('button');
saveButton.type = 'submit';
saveButton.className = 'btn-small';
saveButton.textContent = 'Save Record';
row3.appendChild(saveButton);
var cancelLink = document.createElement('a');
cancelLink.href = 'javascript:void(0)';
cancelLink.className = 'text-xs text-zinc-500 hover:text-zinc-300 transition-colors duration-150';
cancelLink.textContent = 'Cancel';
cancelLink.setAttribute('data-cancel-edit', '');
row3.appendChild(cancelLink);
form.appendChild(row3);
return form;
}
function handleEditClick(event) {
var button = event.target.closest('[data-edit-record]');
if (!button) return;
var recordType = button.dataset.recordType;
var recordId = button.dataset.recordId;
var recordName = button.dataset.recordName;
var recordValue = button.dataset.recordValue;
var recordTtl = button.dataset.recordTtl;
var recordPriority = button.dataset.recordPriority;
var row = document.querySelector('[data-record-row="' + recordType + '-' + recordId + '"]');
if (!row || row.querySelector('[data-inline-edit]')) return;
var originalContent = row.innerHTML;
var originalClass = row.className;
row.className = 'border-b border-white/[0.04]';
while (row.firstChild) row.removeChild(row.firstChild);
var form = createEditForm(recordType, recordId, recordName, recordValue, recordTtl, recordPriority);
row.appendChild(form);
initDropdowns();
form.querySelector('[data-cancel-edit]').addEventListener('click', function() {
row.className = originalClass;
row.innerHTML = originalContent;
htmx.process(row);
});
htmx.process(row);
}
var recordsList = document.querySelector('[data-records-list]');
if (recordsList) {
recordsList.addEventListener('click', handleEditClick);
}
})();
</script>
|