DEVELOPMENT ENVIRONMENT

~liljamo/felu

ref: a31d2cb4d52f56af0252dda738fca6b6d74a7aa5 felu/internal/components/managepartials.templ -rw-r--r-- 1.8 KiB
a31d2cb4Jonni Liljamo feat: update admin index 1 year, 24 days ago
                                                                                
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
package components

import "git.src.quest/~skye/felu-ddns/internal/db"
import "fmt"

templ ManagePartialDomains(domains []db.Domain) {
	if len(domains) > 0 {
		<script>
			function toggleApiKeyVisibility(inputId) {
				var input = document.getElementById(inputId)
				if (input.type === "password") {
					input.type = "text";
				} else {
					input.type = "password";
				}
			}
		</script>
		<table class="table-auto">
			<thead>
				<tr>
					<th class="text-start p-2">
						Domain
					</th>
					<th class="text-start p-2">
						A Record
					</th>
					<th class="text-start p-2">
						Api Key
					</th>
				</tr>
			</thead>
			<tbody>
				for _, domain := range domains {
					<tr class="border">
						<td>
							<div class="p-2">
								<span class="font-bold">{ domain.Domain }</span>
								<span class="">{ getDomainPattern() }</span>
							</div>
						</td>
						<td>
							<div class="p-2">
								<!-- TODO: Make this editable
									And refresh the div with /manage/partials/domains
								-->
								<input class="border" value={ domain.A }/>
							</div>
						</td>
						<td>
							<div class="p-2">
								<!-- TODO: Add refreshing -->
								<input class="border" disabled type="password" value={ domain.ApiKey }
									id={ fmt.Sprintf("domain_apikey_%s", domain.Id) }
								/>
								<!-- TODO: Replace with one of those eye thingies -->
								<input type="checkbox" onclick="toggleApiKeyVisibility(this.previousElementSibling.id)"/>
								<span>show</span>
							</div>
						</td>
						<td>
							<div class="p-2">
								<button class="border p-1" hx-confirm="Sure?"
									hx-delete={ fmt.Sprintf("/manage/domains/%s", domain.Id) }
								>
									Delete
								</button>
							</div>
						</td>
					</tr>
				}
			</tbody>
		</table>
	}
}