dev: automated commit - 2025-06-17 16:15:21

This commit is contained in:
Mariano Z. 2025-06-17 16:15:21 -03:00
parent 73e91db78b
commit 27775e6b29
16 changed files with 1860 additions and 1240 deletions

View file

@ -43,17 +43,16 @@ templ Index(props IndexProps) {
<h1>{ props.Title }</h1>
<div class="current-ip d-flex align-items-center">
<span class="me-2">Current IP:</span>
<span id="current-ip" class="fw-bold">{ props.CurrentIP }</span>
<button
class="btn btn-sm btn-outline-secondary ms-2"
title="Refresh current IP"
hx-get="/refresh-ip"
hx-target="#current-ip"
hx-indicator="#refresh-spinner"
<span id="current-ip" x-init class="fw-bold">{ props.CurrentIP }</span>
<a
href="/refresh-ip"
x-target="current-ip"
class="btn btn-sm btn-outline-secondary ms-2 d-inline-flex align-items-center"
@ajax:before="$el.querySelector('.bi-arrow-clockwise').classList.add('spin')"
@ajax:after="$el.querySelector('.bi-arrow-clockwise').classList.remove('spin')"
>
<i class="bi bi-arrow-clockwise"></i>
<span id="refresh-spinner" class="htmx-indicator spinner-border spinner-border-sm ms-1"></span>
</button>
</a>
</div>
</div>
if !props.IsConfigured {
@ -62,12 +61,9 @@ templ Index(props IndexProps) {
@ConfigStatus(props.Config)
@DNSRecordsSection(props.Records, props.CurrentIP)
}
@ConfigModal(props.Config, props.UpdateFreqs)
@RecordModal(props.Config.Domain)
</div>
</div>
</div>
<div class="toast-container"></div>
}
}
@ -86,16 +82,34 @@ templ ConfigWarning() {
}
templ ConfigStatus(config ConfigData) {
<div class="card mb-4">
<div class="card-header d-flex justify-content-between align-items-center">
<div class="card mb-4" id="config-status">
<div
class="card-header d-flex justify-content-between align-items-center"
x-init
x-data="{ editLoading: false, deleteLoading: false }"
@ajax:success="$dispatch('dialog:open')"
>
<h5 class="mb-0">Configuration</h5>
<button
class="btn btn-sm btn-outline-primary"
data-bs-toggle="modal"
data-bs-target="#configModal"
<a
href="/config"
@ajax:before="editLoading = true"
@ajax:success="$dispatch('dialog:open')"
@ajax:after="editLoading = false"
@ajax:error="editLoading = false"
x-target="contact"
class="btn btn-sm btn-outline-primary me-2"
:disabled="editLoading || deleteLoading"
>
Edit
</button>
<template x-if="!editLoading">
<span class="ms-1">
Edit
<i class="bi bi-pencil"></i>
</span>
</template>
<template x-if="editLoading">
<span class="spinner-border spinner-border-sm"></span>
</template>
</a>
</div>
<div class="card-body">
<div class="row">
@ -118,25 +132,57 @@ templ DNSRecordsSection(records []DNSRecord, currentIP string) {
<div class="card">
<div class="card-header d-flex justify-content-between align-items-center">
<h5 class="mb-0">DNS Records</h5>
<div>
<button
class="btn btn-sm btn-success me-2"
hx-post="/update-all-records"
hx-target="#dns-records-table"
hx-confirm="Are you sure you want to update all A records to your current IP?"
hx-indicator="#update-all-spinner"
<div x-data="{ updating: false, addingRecord: false }">
<form
method="post"
action="/update-all-records"
x-target="dns-records-table"
@ajax:before="confirm('Are you sure you want to update all A records to your current IP?') || $event.preventDefault(); updating = true"
@ajax:after="updating = false"
@ajax:error="updating = false"
style="display: inline;"
>
<i class="bi bi-arrow-repeat"></i> Update All to Current IP
<span id="update-all-spinner" class="htmx-indicator spinner-border spinner-border-sm ms-1"></span>
</button>
<button
class="btn btn-sm btn-primary"
data-bs-toggle="modal"
data-bs-target="#recordModal"
onclick="resetRecordForm()"
<button
class="btn btn-sm btn-success me-2"
type="submit"
:disabled="updating || addingRecord"
>
<template x-if="!updating">
<span class="d-flex align-items-center">
<i class="bi bi-arrow-repeat me-1"></i>
Update All to Current IP
</span>
</template>
<template x-if="updating">
<span class="d-flex align-items-center">
<span class="spinner-border spinner-border-sm me-2"></span>
Updating All Records...
</span>
</template>
</button>
</form>
<a
href="/records/new"
x-target="contact"
@ajax:before="addingRecord = true; $dispatch('dialog:open')"
@ajax:after="addingRecord = false"
@ajax:error="addingRecord = false"
class="btn btn-primary"
:disabled="updating || addingRecord"
>
<i class="bi bi-plus-lg"></i> Add Record
</button>
<template x-if="!addingRecord">
<span class="d-flex align-items-center">
<i class="bi bi-plus-lg me-1"></i>
Add Record
</span>
</template>
<template x-if="addingRecord">
<span class="d-flex align-items-center">
<span class="spinner-border spinner-border-sm me-2"></span>
Loading...
</span>
</template>
</a>
</div>
</div>
<div class="card-body p-0">
@ -174,7 +220,7 @@ templ DNSRecordsTable(records []DNSRecord, currentIP string) {
}
templ DNSRecordRow(record DNSRecord, currentIP string) {
<tr>
<tr x-data="{ editLoading: false, deleteLoading: false }">
<td>{ record.Type }</td>
<td>{ record.Name }</td>
<td>
@ -200,23 +246,46 @@ templ DNSRecordRow(record DNSRecord, currentIP string) {
}
</td>
<td>
<button
class="btn btn-sm btn-outline-primary me-1"
hx-get={ fmt.Sprintf("/edit-record/%s", record.ID) }
hx-target="#record-modal-content"
hx-on::after-request="if(event.detail.successful) bootstrap.Modal.getOrCreateInstance(document.getElementById('recordModal')).show()"
<a
href={ templ.URL(fmt.Sprintf("/edit-record/%s", record.ID)) }
@ajax:before="editLoading = true"
@ajax:success="$dispatch('dialog:open')"
@ajax:after="editLoading = false"
@ajax:error="editLoading = false"
x-target="contact"
class="btn btn-sm btn-outline-primary me-2"
:disabled="editLoading || deleteLoading"
>
<i class="bi bi-pencil"></i>
</button>
<button
class="btn btn-sm btn-outline-danger"
hx-delete={ fmt.Sprintf("/records/%s", record.ID) }
hx-target="closest tr"
hx-swap="outerHTML"
hx-confirm={ fmt.Sprintf("Are you sure you want to delete the record for \"%s\"?", record.Name) }
<template x-if="!editLoading">
<i class="bi bi-pencil"></i>
</template>
<template x-if="editLoading">
<span class="spinner-border spinner-border-sm"></span>
</template>
</a>
<form
method="delete"
action={ templ.URL(fmt.Sprintf("/records/%s", record.ID)) }
x-target="closest tr"
@ajax:before={ fmt.Sprintf(`confirm('Are you sure you want to delete the record for "%s"?') || $event.preventDefault(); deleteLoading = true`, record.Name) }
@ajax:after="deleteLoading = false"
@ajax:error="deleteLoading = false"
@ajax:success="$el.closest('tr').remove()"
style="display: inline;"
>
<i class="bi bi-trash"></i>
</button>
<button
class="btn btn-sm btn-outline-danger"
type="submit"
:disabled="editLoading || deleteLoading"
>
<template x-if="!deleteLoading">
<i class="bi bi-trash"></i>
</template>
<template x-if="deleteLoading">
<span class="spinner-border spinner-border-sm"></span>
</template>
</button>
</form>
</td>
</tr>
}