mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-06-03 05:35:02 -04:00
* Activate more linting rules from eslint and typescript * Properly add VForm as type information * Fix usage of native types * Fix more linting issues * Rename vuetify types file, add VTooltip * Fix some more typing problems * Use composition API for more components * Convert RecipeRating * Convert RecipeNutrition * Convert more components to composition API * Fix globals plugin for type checking * Add missing icon types * Fix vuetify types in Nuxt context * Use composition API for RecipeActionMenu * Convert error.vue to composition API * Convert RecipeContextMenu to composition API * Use more composition API and type checking in recipe/create * Convert AppButtonUpload to composition API * Fix some type checking in RecipeContextMenu * Remove unused components BaseAutoForm and BaseColorPicker * Convert RecipeCategoryTagDialog to composition API * Convert RecipeCardSection to composition API * Convert RecipeCategoryTagSelector to composition API * Properly import vuetify type definitions * Convert BaseButton to composition API * Convert AutoForm to composition API * Remove unused requests API file * Remove static routes from recipe API * Fix more type errors * Convert AppHeader to composition API, fixing some search bar focus problems * Convert RecipeDialogSearch to composition API * Update API types from pydantic models, handle undefined values * Improve more typing problems * Add types to other plugins * Properly type the CRUD API access * Fix typing of static image routes * Fix more typing stuff * Fix some more typing problems * Turn off more rules
184 lines
6.5 KiB
Vue
184 lines
6.5 KiB
Vue
<template>
|
|
<v-container class="narrow-container">
|
|
<BasePageTitle divider>
|
|
<template #header>
|
|
<div class="d-flex flex-column align-center justify-center">
|
|
<UserAvatar size="96" :user-id="$auth.user.id" />
|
|
<AppButtonUpload
|
|
class="my-1"
|
|
file-name="profile"
|
|
accept="image/*"
|
|
:url="`/api/users/${$auth.user.id}/image`"
|
|
@uploaded="$auth.fetchUser()"
|
|
/>
|
|
</div>
|
|
</template>
|
|
<template #title> Your Profile Settings </template>
|
|
</BasePageTitle>
|
|
|
|
<section class="mt-5">
|
|
<ToggleState tag="article">
|
|
<template #activator="{ toggle, state }">
|
|
<v-btn v-if="!state" color="info" class="mt-2 mb-n3" @click="toggle">
|
|
<v-icon left>{{ $globals.icons.lock }}</v-icon>
|
|
{{ $t("settings.change-password") }}
|
|
</v-btn>
|
|
<v-btn v-else color="info" class="mt-2 mb-n3" @click="toggle">
|
|
<v-icon left>{{ $globals.icons.user }}</v-icon>
|
|
{{ $t("settings.profile") }}
|
|
</v-btn>
|
|
</template>
|
|
<template #default="{ state }">
|
|
<v-slide-x-transition leave-absolute hide-on-leave>
|
|
<div v-if="!state" key="personal-info">
|
|
<BaseCardSectionTitle class="mt-10" title="Personal Information"> </BaseCardSectionTitle>
|
|
<v-card tag="article" outlined>
|
|
<v-card-text class="pb-0">
|
|
<v-form ref="userUpdate">
|
|
<v-text-field v-model="userCopy.username" :label="$t('user.username')" required validate-on-blur>
|
|
</v-text-field>
|
|
<v-text-field v-model="userCopy.fullName" :label="$t('user.full-name')" required validate-on-blur>
|
|
</v-text-field>
|
|
<v-text-field v-model="userCopy.email" :label="$t('user.email')" validate-on-blur required>
|
|
</v-text-field>
|
|
</v-form>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<BaseButton update @click="updateUser" />
|
|
</v-card-actions>
|
|
</v-card>
|
|
</div>
|
|
<div v-if="state" key="change-password">
|
|
<BaseCardSectionTitle class="mt-10" :title="$t('settings.change-password')"> </BaseCardSectionTitle>
|
|
<v-card outlined>
|
|
<v-card-text class="pb-0">
|
|
<v-form ref="passChange">
|
|
<v-text-field
|
|
v-model="password.current"
|
|
:prepend-icon="$globals.icons.lock"
|
|
:label="$t('user.current-password')"
|
|
validate-on-blur
|
|
:type="showPassword ? 'text' : 'password'"
|
|
@click:append="showPassword.current = !showPassword.current"
|
|
></v-text-field>
|
|
<v-text-field
|
|
v-model="password.newOne"
|
|
:prepend-icon="$globals.icons.lock"
|
|
:label="$t('user.new-password')"
|
|
:type="showPassword ? 'text' : 'password'"
|
|
@click:append="showPassword.newOne = !showPassword.newOne"
|
|
></v-text-field>
|
|
<v-text-field
|
|
v-model="password.newTwo"
|
|
:prepend-icon="$globals.icons.lock"
|
|
:label="$t('user.confirm-password')"
|
|
:rules="[password.newOne === password.newTwo || $t('user.password-must-match')]"
|
|
validate-on-blur
|
|
:type="showPassword ? 'text' : 'password'"
|
|
@click:append="showPassword.newTwo = !showPassword.newTwo"
|
|
></v-text-field>
|
|
</v-form>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer></v-spacer>
|
|
<BaseButton update @click="updatePassword" />
|
|
</v-card-actions>
|
|
</v-card>
|
|
</div>
|
|
</v-slide-x-transition>
|
|
</template>
|
|
</ToggleState>
|
|
</section>
|
|
<section>
|
|
<BaseCardSectionTitle class="mt-10" title="Preferences"> </BaseCardSectionTitle>
|
|
<v-checkbox
|
|
v-model="userCopy.advanced"
|
|
class="mt-n4"
|
|
label="Show advanced features (API Keys, Webhooks, and Data Management)"
|
|
@change="updateUser"
|
|
></v-checkbox>
|
|
<div class="d-flex flex-wrap justify-center mt-5">
|
|
<v-btn outlined class="rounded-xl my-1 mx-1" to="/user/profile" nuxt exact>
|
|
<v-icon left>
|
|
{{ $globals.icons.backArrow }}
|
|
</v-icon>
|
|
Back to Profile
|
|
</v-btn>
|
|
<v-btn outlined class="rounded-xl my-1 mx-1" to="/user/group"> Looking for Privacy Settings? </v-btn>
|
|
</div>
|
|
</section>
|
|
</v-container>
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
import { ref, reactive, defineComponent, computed, useContext, watch } from "@nuxtjs/composition-api";
|
|
import { useUserApi } from "~/composables/api";
|
|
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
|
import { VForm } from "~/types/vuetify";
|
|
|
|
export default defineComponent({
|
|
components: {
|
|
UserAvatar,
|
|
},
|
|
setup() {
|
|
const nuxtContext = useContext();
|
|
const user = computed(() => nuxtContext.$auth.user);
|
|
|
|
watch(user, () => {
|
|
userCopy.value = { ...user.value };
|
|
});
|
|
|
|
const userCopy = ref({ ...user.value });
|
|
|
|
const api = useUserApi();
|
|
|
|
const domUpdatePassword = ref<VForm | null>(null);
|
|
const password = reactive({
|
|
current: "",
|
|
newOne: "",
|
|
newTwo: "",
|
|
});
|
|
|
|
async function updateUser() {
|
|
// @ts-ignore
|
|
const { response } = await api.users.updateOne(userCopy.value.id, userCopy.value);
|
|
if (response?.status === 200) {
|
|
nuxtContext.$auth.fetchUser();
|
|
}
|
|
}
|
|
|
|
async function updatePassword() {
|
|
if (!userCopy.value?.id) {
|
|
return;
|
|
}
|
|
// @ts-ignore
|
|
const { response } = await api.users.changePassword(userCopy.value.id, {
|
|
currentPassword: password.current,
|
|
newPassword: password.newOne,
|
|
});
|
|
|
|
if (response?.status === 200) {
|
|
console.log("Password Changed");
|
|
}
|
|
}
|
|
|
|
return { updateUser, updatePassword, userCopy, password, domUpdatePassword };
|
|
},
|
|
data() {
|
|
return {
|
|
hideImage: false,
|
|
passwordLoading: false,
|
|
showPassword: false,
|
|
loading: false,
|
|
};
|
|
},
|
|
head() {
|
|
return {
|
|
title: this.$t("settings.profile") as string,
|
|
};
|
|
},
|
|
});
|
|
</script>
|
|
|