feat(frontend): added description handling the /profile

This commit is contained in:
Maieul BOYER 2025-12-22 19:38:02 +01:00
parent 2ace5a9a94
commit 98f2af3f46
No known key found for this signature in database
7 changed files with 57 additions and 9 deletions

View file

@ -47,6 +47,14 @@
<button id="passwordButton"
class="w-full bg-blue-600 text-white py-2 rounded hover:bg-blue-700">Update</button>
</div>
<!-- Description -->
<div id="descWrapper" class="py-2">
<label class="block font-medium mb-1 text-gray-700">Description</label>
<input id="descBox" type="text" placeholder="Description..." name="Description"
class="w-full px-4 py-2 border border-gray-300 text-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500" />
<button id="descButton"
class="w-full bg-blue-600 text-white py-2 rounded hover:bg-blue-700">Update</button>
</div>
<!-- TOTP -->
<div class="border rounded p-4" id="totpWrapper" hidden>
<h2 class="font-semibold text-lg mb-2">Two-Factor Authentication (TOTP)</h2>

View file

@ -97,6 +97,13 @@ async function route(url: string, _args: { [k: string]: string }) {
let providerUserBox =
app.querySelector<HTMLDivElement>("#providerUserBox")!;
let descWrapper =
app.querySelector<HTMLDivElement>("#descWrapper")!;
let descBox =
app.querySelector<HTMLInputElement>("#descBox")!;
let descButton =
app.querySelector<HTMLButtonElement>("#descButton")!;
let accountTypeBox =
app.querySelector<HTMLDivElement>("#accountType")!;
displayNameBox.value = user.name;
@ -119,12 +126,8 @@ async function route(url: string, _args: { [k: string]: string }) {
let totpWrapper =
app.querySelector<HTMLDivElement>("#totpWrapper")!;
if (user.guest) {
for (let c of passwordButton.classList.values()) {
if (c.startsWith("bg-") || c.startsWith("hover:bg-"))
passwordButton.classList.remove(c);
}
}
descBox.value = user.desc;
if (user.guest) {
removeBgColor(
passwordButton,
@ -132,8 +135,16 @@ async function route(url: string, _args: { [k: string]: string }) {
enableBtn,
disableBtn,
showSecretBtn,
descButton,
);
descButton.classList.add(
"bg-gray-700",
"hover:bg-gray-700",
);
descButton.disabled = true;
descBox.disabled = true;
passwordButton.classList.add(
"bg-gray-700",
"hover:bg-gray-700",
@ -257,6 +268,16 @@ async function route(url: string, _args: { [k: string]: string }) {
showError(`Failed to update: ${req.msg}`);
}
};
descButton.onclick = async () => {
let req = await client.changeDesc({ changeDescRequest: { desc: descBox.value } });
if (req.kind === "success") {
showSuccess("Successfully changed description");
handleRoute();
}
else {
showError(`Failed to update: ${req.msg}`);
}
};
// Initialize UI state
refreshTotpUI();