Migrate first parts of backups view to vue

This commit is contained in:
Johannes Zellner
2025-02-04 15:10:38 +01:00
parent 55939f6320
commit 776e65bc5e
10 changed files with 631 additions and 16 deletions
+12 -6
View File
@@ -36,6 +36,12 @@ async function onSelectLanguage(lang) {
// TODO dynamically change lange instead of reloading
}
async function refreshProfile() {
const [error, result] = await profileModel.get();
if (error) return console.error(error);
user.value = result;
}
// Profile edits
async function onChangeDisplayName(currentDisplayName) {
@@ -53,7 +59,7 @@ async function onChangeDisplayName(currentDisplayName) {
const error = await profileModel.setDisplayName(displayName);
if (error) return console.error('Failed to set displayName', error);
user.value = await profileModel.get();
await refreshProfile();
}
async function onChangeEmail(currentEmail) {
@@ -72,7 +78,7 @@ async function onChangeEmail(currentEmail) {
const error = await profileModel.setEmail(result[0], result[1]);
if (error) return console.error('Failed to set email', error);
user.value = await profileModel.get();
await refreshProfile();
}
async function onChangeFallbackEmail(currentFallbackEmail) {
@@ -91,7 +97,7 @@ async function onChangeFallbackEmail(currentFallbackEmail) {
const error = await profileModel.setFallbackEmail(result[0], result[1]);
if (error) return console.error('Failed to set fallback email', error);
user.value = await profileModel.get();
await refreshProfile();
}
const avatarFileInput = useTemplateRef('avatarFileInput');
@@ -173,7 +179,7 @@ async function onOpenTwoFASetupDialog() {
async function onTwoFAEnable() {
const [error] = await profileModel.enableTwoFA(twoFATotpToken.value);
if (error) return twoFAEnableError.value = error.body ? error.body.message : 'Internal error';
user.value = await profileModel.get();
await refreshProfile();
twoFADialog.value.close();
}
@@ -194,13 +200,13 @@ async function onTwoFADisable() {
const [error] = await profileModel.disableTwoFA(password);
if (error) return onTwoFADisable();
user.value = await profileModel.get();
await refreshProfile();
}
// Init
onMounted(async () => {
user.value = await profileModel.get();
await refreshProfile();
let [error, result] = await cloudronModel.languages();
languages.value = result.map(l => {