DEVELOPMENT ENVIRONMENT

~liljamo/felu

f9956b2cdb7c170d8cb2163421cbf5f50cd858c7 — Jonni Liljamo 24 days ago 230d0a9
feat: refresh tsigKey frontend, revamp reused components
2 files changed, 65 insertions(+), 26 deletions(-)

M internal/components/managepartials.templ
M static/styles.css
M internal/components/managepartials.templ => internal/components/managepartials.templ +57 -26
@@ 3,10 3,10 @@ package components
import "git.src.quest/~liljamo/felu/internal/db"
import "fmt"

script toggleApiKeyVisibility(id string) {
	var input = document.getElementById("domain_apikey_" + id);
	var eye_vis = document.getElementById("domain_eye_vis_" + id);
	var eye_hid = document.getElementById("domain_eye_hid_" + id);
script toggleKeyVisibility(t string) {
	var input = document.getElementById("domain_key_" + t);
	var eye_vis = document.getElementById("domain_eye_vis_" + t);
	var eye_hid = document.getElementById("domain_eye_hid_" + t);
	if (input.type === "password") {
		input.type = "text";
	} else {


@@ 16,6 16,34 @@ script toggleApiKeyVisibility(id string) {
	eye_hid.classList.toggle("hidden");
}

templ EyeToggle(t string) {
	<div class="border p-1 flex items-center justify-center">
		<input class="absolute w-6 h-6 appearance-none cursor-pointer" type="checkbox"
			onClick={ toggleKeyVisibility(t) }
		/>
		<div>
			<svg id={ fmt.Sprintf("domain_eye_vis_%s", t) } class="hidden w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
				<path d="M15.0007 12C15.0007 13.6569 13.6576 15 12.0007 15C10.3439 15 9.00073 13.6569 9.00073 12C9.00073 10.3431 10.3439 9 12.0007 9C13.6576 9 15.0007 10.3431 15.0007 12Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
				<path d="M12.0012 5C7.52354 5 3.73326 7.94288 2.45898 12C3.73324 16.0571 7.52354 19 12.0012 19C16.4788 19 20.2691 16.0571 21.5434 12C20.2691 7.94291 16.4788 5 12.0012 5Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
			</svg>

			<svg id={ fmt.Sprintf("domain_eye_hid_%s", t) } class="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
				<path d="M2.99902 3L20.999 21M9.8433 9.91364C9.32066 10.4536 8.99902 11.1892 8.99902 12C8.99902 13.6569 10.3422 15 11.999 15C12.8215 15 13.5667 14.669 14.1086 14.133M6.49902 6.64715C4.59972 7.90034 3.15305 9.78394 2.45703 12C3.73128 16.0571 7.52159 19 11.9992 19C13.9881 19 15.8414 18.4194 17.3988 17.4184M10.999 5.04939C11.328 5.01673 11.6617 5 11.9992 5C16.4769 5 20.2672 7.94291 21.5414 12C21.2607 12.894 20.8577 13.7338 20.3522 14.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
			</svg>
		</div>
	</div>
}

templ RefreshButton(t string) {
	<button class="border p-1" hx-confirm="Refresh?"
		hx-post={ fmt.Sprintf("/manage/domains/%s", t) }
	>
		<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
			<path d="M11.5 20.5C6.80558 20.5 3 16.6944 3 12C3 7.30558 6.80558 3.5 11.5 3.5C16.1944 3.5 20 7.30558 20 12C20 13.5433 19.5887 14.9905 18.8698 16.238M22.5 15L18.8698 16.238M17.1747 12.3832L18.5289 16.3542L18.8698 16.238" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
		</svg>
	</button>
}

templ ManagePartialDomains(domains []db.Domain) {
	if len(domains) > 0 {
		<table class="table-auto">


@@ 60,31 88,12 @@ templ ManagePartialDomains(domains []db.Domain) {
						<td>
							<div class="p-2 flex items-center gap-1">
								<input class="border" disabled type="password" value={ domain.APIKey }
									id={ fmt.Sprintf("domain_apikey_%s", domain.ID) }
									id={ fmt.Sprintf("domain_key_api_%s", domain.ID) }
								/>
								<div class="border p-1 flex items-center justify-center">
									<input class="absolute w-6 h-6 appearance-none cursor-pointer" type="checkbox"
										onClick={ toggleApiKeyVisibility(domain.ID) }
									/>
									<div>
										<svg id={ fmt.Sprintf("domain_eye_vis_%s", domain.ID) } class="hidden w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M15.0007 12C15.0007 13.6569 13.6576 15 12.0007 15C10.3439 15 9.00073 13.6569 9.00073 12C9.00073 10.3431 10.3439 9 12.0007 9C13.6576 9 15.0007 10.3431 15.0007 12Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
											<path d="M12.0012 5C7.52354 5 3.73326 7.94288 2.45898 12C3.73324 16.0571 7.52354 19 12.0012 19C16.4788 19 20.2691 16.0571 21.5434 12C20.2691 7.94291 16.4788 5 12.0012 5Z" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
										</svg>

										<svg id={ fmt.Sprintf("domain_eye_hid_%s", domain.ID) } class="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
											<path d="M2.99902 3L20.999 21M9.8433 9.91364C9.32066 10.4536 8.99902 11.1892 8.99902 12C8.99902 13.6569 10.3422 15 11.999 15C12.8215 15 13.5667 14.669 14.1086 14.133M6.49902 6.64715C4.59972 7.90034 3.15305 9.78394 2.45703 12C3.73128 16.0571 7.52159 19 11.9992 19C13.9881 19 15.8414 18.4194 17.3988 17.4184M10.999 5.04939C11.328 5.01673 11.6617 5 11.9992 5C16.4769 5 20.2672 7.94291 21.5414 12C21.2607 12.894 20.8577 13.7338 20.3522 14.5" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
										</svg>
									</div>
								</div>
								@EyeToggle(fmt.Sprintf("%s_%s", "api", domain.ID))

								<button class="border p-1" hx-confirm="Refresh?"
									hx-post={ fmt.Sprintf("/manage/domains/%s/api_key", domain.ID) }
								>
									<svg class="w-5 h-5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
										<path d="M11.5 20.5C6.80558 20.5 3 16.6944 3 12C3 7.30558 6.80558 3.5 11.5 3.5C16.1944 3.5 20 7.30558 20 12C20 13.5433 19.5887 14.9905 18.8698 16.238M22.5 15L18.8698 16.238M17.1747 12.3832L18.5289 16.3542L18.8698 16.238" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
									</svg>
								</button>
								@RefreshButton(fmt.Sprintf("%s/%s", domain.ID, "api_key"))
							</div>
						</td>
						<td>


@@ 97,6 106,28 @@ templ ManagePartialDomains(domains []db.Domain) {
							</div>
						</td>
					</tr>
					<tr class="border">
						<td colspan="4">
							<details class="p-2">
								<summary class="list-none flex border p-1 items-center cursor-pointer select-none">
									<div>More</div>
								</summary>
								<div class="flex flex-row items-center">
									<p>TSIG key:</p>

									<div class="p-2 flex items-center gap-1">
										<input class="border" disabled type="password" value={ domain.TsigKey }
											id={ fmt.Sprintf("domain_key_tsig_%s", domain.ID) }
										/>

										@EyeToggle(fmt.Sprintf("%s_%s", "tsig", domain.ID))

										@RefreshButton(fmt.Sprintf("%s/%s", domain.ID, "tsig_key"))
									</div>
								</div>
							</details>
						</td>
					</tr>
				}
			</tbody>
		</table>

M static/styles.css => static/styles.css +8 -0
@@ 612,6 612,10 @@ video {
          user-select: none;
}

.list-inside {
  list-style-position: inside;
}

.list-none {
  list-style-type: none;
}


@@ 622,6 626,10 @@ video {
          appearance: none;
}

.flex-row {
  flex-direction: row;
}

.flex-row-reverse {
  flex-direction: row-reverse;
}