dev: automated commit - 2025-08-10 18:18:05
This commit is contained in:
parent
47fb2fb928
commit
81967b4d8e
13 changed files with 438 additions and 53 deletions
|
|
@ -26,6 +26,7 @@ type DNSRecord struct {
|
|||
Content string
|
||||
TTL int
|
||||
Proxied bool
|
||||
IsStatic bool // Nueva propiedad para indicar si es estático
|
||||
CreatedOn string
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +138,7 @@ templ DNSRecordsSection(records []DNSRecord, currentIP string) {
|
|||
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:before="confirm('Are you sure you want to update all non-static A records to your current IP?') || $event.preventDefault(); updating = true"
|
||||
@ajax:after="updating = false"
|
||||
@ajax:error="updating = false"
|
||||
style="display: inline;"
|
||||
|
|
@ -201,13 +202,14 @@ templ DNSRecordsTable(records []DNSRecord, currentIP string) {
|
|||
<th>Content</th>
|
||||
<th>TTL</th>
|
||||
<th>Proxied</th>
|
||||
<th>Static</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
if len(records) == 0 {
|
||||
<tr>
|
||||
<td colspan="6" class="text-center">No DNS records found</td>
|
||||
<td colspan="7" class="text-center">No DNS records found</td>
|
||||
</tr>
|
||||
} else {
|
||||
for _, record := range records {
|
||||
|
|
@ -220,12 +222,12 @@ templ DNSRecordsTable(records []DNSRecord, currentIP string) {
|
|||
}
|
||||
|
||||
templ DNSRecordRow(record DNSRecord, currentIP string) {
|
||||
<tr x-data="{ editLoading: false, deleteLoading: false }">
|
||||
<tr x-data="{ editLoading: false, deleteLoading: false, toggleLoading: false }">
|
||||
<td>{ record.Type }</td>
|
||||
<td>{ record.Name }</td>
|
||||
<td>
|
||||
{ record.Content }
|
||||
if record.Type == "A" {
|
||||
if record.Type == "A" && !record.IsStatic {
|
||||
if record.Content == currentIP {
|
||||
<span class="badge bg-success update-badge">Current IP</span>
|
||||
} else {
|
||||
|
|
@ -245,6 +247,39 @@ templ DNSRecordRow(record DNSRecord, currentIP string) {
|
|||
<i class="bi bi-check-lg text-success"></i>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
if record.Type == "A" {
|
||||
<form
|
||||
method="post"
|
||||
action={ templ.URL(fmt.Sprintf("/records/%s/toggle-static", record.ID)) }
|
||||
x-target="dns-records-table"
|
||||
@ajax:before="toggleLoading = true"
|
||||
@ajax:after="toggleLoading = false"
|
||||
@ajax:error="toggleLoading = false"
|
||||
style="display: inline;"
|
||||
>
|
||||
<button
|
||||
type="submit"
|
||||
class={ "btn btn-sm", templ.KV("btn-outline-secondary", !record.IsStatic), templ.KV("btn-secondary", record.IsStatic) }
|
||||
:disabled="editLoading || deleteLoading || toggleLoading"
|
||||
title={ getStaticToggleTitle(record.IsStatic) }
|
||||
>
|
||||
<template x-if="!toggleLoading">
|
||||
if record.IsStatic {
|
||||
<i class="bi bi-lock-fill"></i>
|
||||
} else {
|
||||
<i class="bi bi-unlock"></i>
|
||||
}
|
||||
</template>
|
||||
<template x-if="toggleLoading">
|
||||
<span class="spinner-border spinner-border-sm"></span>
|
||||
</template>
|
||||
</button>
|
||||
</form>
|
||||
} else {
|
||||
<span class="text-muted">-</span>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
href={ templ.URL(fmt.Sprintf("/edit-record/%s", record.ID)) }
|
||||
|
|
@ -254,7 +289,7 @@ templ DNSRecordRow(record DNSRecord, currentIP string) {
|
|||
@ajax:error="editLoading = false"
|
||||
x-target="contact"
|
||||
class="btn btn-sm btn-outline-primary me-2"
|
||||
:disabled="editLoading || deleteLoading"
|
||||
:disabled="editLoading || deleteLoading || toggleLoading"
|
||||
>
|
||||
<template x-if="!editLoading">
|
||||
<i class="bi bi-pencil"></i>
|
||||
|
|
@ -276,7 +311,7 @@ templ DNSRecordRow(record DNSRecord, currentIP string) {
|
|||
<button
|
||||
class="btn btn-sm btn-outline-danger"
|
||||
type="submit"
|
||||
:disabled="editLoading || deleteLoading"
|
||||
:disabled="editLoading || deleteLoading || toggleLoading"
|
||||
>
|
||||
<template x-if="!deleteLoading">
|
||||
<i class="bi bi-trash"></i>
|
||||
|
|
@ -322,3 +357,11 @@ func getRecordName(fullName, domain string) string {
|
|||
}
|
||||
return fullName
|
||||
}
|
||||
|
||||
// Helper function for static toggle title
|
||||
func getStaticToggleTitle(isStatic bool) string {
|
||||
if isStatic {
|
||||
return "Make dynamic (will auto-update)"
|
||||
}
|
||||
return "Make static (won't auto-update)"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue