feat(frontend): added description handling the /profile
This commit is contained in:
parent
2ace5a9a94
commit
98f2af3f46
7 changed files with 57 additions and 9 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue