mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-10 23:15:34 -04:00
chore: Nuxt 4 upgrade (#7426)
This commit is contained in:
170
frontend/app/pages/user/profile/api-tokens.vue
Normal file
170
frontend/app/pages/user/profile/api-tokens.vue
Normal file
@@ -0,0 +1,170 @@
|
||||
<template>
|
||||
<v-container class="narrow-container">
|
||||
<BasePageTitle divider>
|
||||
<template #header>
|
||||
<v-img
|
||||
width="100%"
|
||||
max-height="200px"
|
||||
max-width="200px"
|
||||
src="/svgs/manage-api-tokens.svg"
|
||||
/>
|
||||
</template>
|
||||
<template #title>
|
||||
{{ $t("settings.token.api-tokens") }}
|
||||
</template>
|
||||
{{ $t('settings.token.you-have-token-count', user.tokens!.length) }}
|
||||
</BasePageTitle>
|
||||
<section class="d-flex justify-center">
|
||||
<v-card
|
||||
class="mt-4 pa-4"
|
||||
width="100%"
|
||||
flat
|
||||
>
|
||||
<v-card-title class="px-0">
|
||||
{{ $t("settings.token.create-an-api-token") }}
|
||||
</v-card-title>
|
||||
<v-card-text class="px-0">
|
||||
<v-form
|
||||
ref="domNewTokenForm"
|
||||
@submit.prevent
|
||||
>
|
||||
<v-text-field
|
||||
v-model="name"
|
||||
:label="$t('settings.token.token-name')"
|
||||
/>
|
||||
</v-form>
|
||||
|
||||
<template v-if="createdToken != ''">
|
||||
<v-textarea
|
||||
v-model="createdToken"
|
||||
class="mb-0 pb-0"
|
||||
:label="$t('settings.token.api-token')"
|
||||
readonly
|
||||
rows="3"
|
||||
/>
|
||||
<p>
|
||||
{{
|
||||
$t(
|
||||
"settings.token.copy-this-token-for-use-with-an-external-application-this-token-will-not-be-viewable-again",
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
</template>
|
||||
</v-card-text>
|
||||
<v-card-actions class="px-0">
|
||||
<BaseButton
|
||||
v-if="createdToken"
|
||||
cancel
|
||||
@click="resetCreate()"
|
||||
>
|
||||
{{ $t('general.close') }}
|
||||
</BaseButton>
|
||||
<v-spacer />
|
||||
<AppButtonCopy
|
||||
v-if="createdToken"
|
||||
:icon="false"
|
||||
color="info"
|
||||
:copy-text="createdToken"
|
||||
/>
|
||||
<BaseButton
|
||||
v-else
|
||||
key="generate-button"
|
||||
:disabled="name == ''"
|
||||
@click="createToken(name)"
|
||||
>
|
||||
{{ $t('settings.token.generate') }}
|
||||
</BaseButton>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</section>
|
||||
<BaseCardSectionTitle
|
||||
class="mt-10"
|
||||
:title="$t('settings.token.active-tokens')"
|
||||
/>
|
||||
<section class="d-flex flex-column">
|
||||
<v-list>
|
||||
<div
|
||||
v-for="(token, index) in user.tokens"
|
||||
:key="index"
|
||||
>
|
||||
<v-list-item>
|
||||
<v-list-item-title>
|
||||
{{ token.name }}
|
||||
</v-list-item-title>
|
||||
<v-list-item-subtitle>
|
||||
{{ $t('general.created-on-date', [$d(new Date(token.createdAt!))]) }}
|
||||
</v-list-item-subtitle>
|
||||
<template #append>
|
||||
<BaseButton
|
||||
delete
|
||||
small
|
||||
@click="deleteToken(token.id)"
|
||||
/>
|
||||
</template>
|
||||
</v-list-item>
|
||||
<v-divider class="mx-2 my-2" />
|
||||
</div>
|
||||
</v-list>
|
||||
</section>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import type { VForm } from "~/types/auto-forms";
|
||||
|
||||
definePageMeta({
|
||||
middleware: ["advanced-only"],
|
||||
});
|
||||
|
||||
const i18n = useI18n();
|
||||
const auth = useMealieAuth();
|
||||
|
||||
useSeoMeta({
|
||||
title: i18n.t("settings.token.api-tokens"),
|
||||
});
|
||||
|
||||
const user = computed(() => {
|
||||
return auth.user.value;
|
||||
});
|
||||
|
||||
const api = useUserApi();
|
||||
|
||||
const domNewTokenForm = ref<VForm | null>(null);
|
||||
|
||||
const createdToken = ref("");
|
||||
const name = ref("");
|
||||
const loading = ref(false);
|
||||
|
||||
function resetCreate() {
|
||||
createdToken.value = "";
|
||||
loading.value = false;
|
||||
name.value = "";
|
||||
auth.refresh();
|
||||
}
|
||||
|
||||
async function createToken(name: string) {
|
||||
if (loading.value) {
|
||||
resetCreate();
|
||||
return;
|
||||
}
|
||||
|
||||
loading.value = true;
|
||||
|
||||
if (!domNewTokenForm?.value?.validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { data } = await api.users.createAPIToken({ name });
|
||||
|
||||
if (data) {
|
||||
createdToken.value = data.token;
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteToken(id: number) {
|
||||
const { data } = await api.users.deleteAPIToken(id);
|
||||
auth.refresh();
|
||||
return data;
|
||||
}
|
||||
</script>
|
||||
297
frontend/app/pages/user/profile/edit.vue
Normal file
297
frontend/app/pages/user/profile/edit.vue
Normal file
@@ -0,0 +1,297 @@
|
||||
<template>
|
||||
<v-container class="narrow-container">
|
||||
<BasePageTitle divider>
|
||||
<template #header>
|
||||
<div class="d-flex flex-column align-center justify-center">
|
||||
<UserAvatar
|
||||
:tooltip="false"
|
||||
size="96"
|
||||
:user-id="userCopy.id!"
|
||||
/>
|
||||
<AppButtonUpload
|
||||
class="my-1"
|
||||
file-name="profile"
|
||||
accept="image/*"
|
||||
:url="`/api/users/${userCopy.id}/image`"
|
||||
@uploaded="auth.refresh()"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #title>
|
||||
{{ $t("profile.user-settings") }}
|
||||
</template>
|
||||
</BasePageTitle>
|
||||
|
||||
<section class="mt-5">
|
||||
<ToggleState tag="article">
|
||||
<template #activator="{ toggle, modelValue: toggleState }">
|
||||
<v-btn
|
||||
v-if="!toggleState && $appInfo.allowPasswordLogin"
|
||||
color="info"
|
||||
class="mt-2 mb-n3"
|
||||
@click="toggle"
|
||||
>
|
||||
<v-icon start>
|
||||
{{ $globals.icons.lock }}
|
||||
</v-icon>
|
||||
{{ $t("settings.change-password") }}
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-else-if="$appInfo.allowPasswordLogin"
|
||||
color="info"
|
||||
class="mt-2 mb-n3"
|
||||
@click="toggle"
|
||||
>
|
||||
<v-icon start>
|
||||
{{ $globals.icons.user }}
|
||||
</v-icon>
|
||||
{{ $t("settings.profile") }}
|
||||
</v-btn>
|
||||
</template>
|
||||
<template #default="{ modelValue: toggleState }">
|
||||
<v-slide-x-transition
|
||||
leave-absolute
|
||||
hide-on-leave
|
||||
>
|
||||
<div
|
||||
v-if="!toggleState"
|
||||
key="personal-info"
|
||||
>
|
||||
<BaseCardSectionTitle
|
||||
class="mt-10"
|
||||
:title="$t('profile.personal-information')"
|
||||
/>
|
||||
<v-card
|
||||
tag="article"
|
||||
variant="outlined"
|
||||
style="border-color: lightgrey;"
|
||||
>
|
||||
<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"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="userCopy.fullName"
|
||||
:label="$t('user.full-name')"
|
||||
required
|
||||
validate-on="blur"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="userCopy.email"
|
||||
:label="$t('user.email')"
|
||||
validate-on="blur"
|
||||
required
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
/>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<BaseButton
|
||||
update
|
||||
@click="updateUser"
|
||||
/>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
key="change-password"
|
||||
>
|
||||
<BaseCardSectionTitle
|
||||
class="mt-10"
|
||||
:title="$t('settings.change-password')"
|
||||
/>
|
||||
<v-card variant="outlined" style="border-color: lightgrey;">
|
||||
<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'"
|
||||
:append-icon="showPassword ? $globals.icons.eye : $globals.icons.eyeOff"
|
||||
:rules="[validators.minLength(1)]"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
@click:append="showPassword = !showPassword"
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="password.newOne"
|
||||
:prepend-icon="$globals.icons.lock"
|
||||
:label="$t('user.new-password')"
|
||||
:type="showPassword ? 'text' : 'password'"
|
||||
:append-icon="showPassword ? $globals.icons.eye : $globals.icons.eyeOff"
|
||||
:rules="[validators.minLength(8)]"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
@click:append="showPassword = !showPassword"
|
||||
/>
|
||||
<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'"
|
||||
:append-icon="showPassword ? $globals.icons.eye : $globals.icons.eyeOff"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
@click:append="showPassword = !showPassword"
|
||||
/>
|
||||
<UserPasswordStrength v-model="password.newOne" />
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer />
|
||||
<BaseButton
|
||||
update
|
||||
:disabled="!passwordsMatch || password.current.length < 0"
|
||||
@click="updatePassword"
|
||||
/>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</div>
|
||||
</v-slide-x-transition>
|
||||
</template>
|
||||
</ToggleState>
|
||||
</section>
|
||||
<section>
|
||||
<BaseCardSectionTitle
|
||||
class="mt-10"
|
||||
:title="$t('profile.preferences')"
|
||||
/>
|
||||
<v-card variant="outlined" style="border-color: lightgrey;">
|
||||
<v-card-text>
|
||||
<v-combobox
|
||||
v-model="selectedDefaultActivity"
|
||||
:label="$t('user.default-activity')"
|
||||
:items="activityOptions"
|
||||
:hint="$t('user.default-activity-hint')"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
validate-on="blur"
|
||||
persistent-hint
|
||||
/>
|
||||
<v-checkbox
|
||||
v-model="userCopy.advanced"
|
||||
:label="$t('profile.show-advanced-description')"
|
||||
color="primary"
|
||||
@change="updateUser"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<nuxt-link
|
||||
class="mt-5 d-flex flex-column justify-center text-center"
|
||||
:to="`/group`"
|
||||
> {{
|
||||
$t('profile.looking-for-privacy-settings') }} </nuxt-link>
|
||||
<div class="d-flex flex-wrap justify-center mt-5">
|
||||
<v-btn
|
||||
variant="outlined"
|
||||
class="rounded-xl my-1 mx-1"
|
||||
:to="`/user/profile`"
|
||||
nuxt
|
||||
exact
|
||||
>
|
||||
<v-icon start>
|
||||
{{ $globals.icons.backArrow }}
|
||||
</v-icon>
|
||||
{{ $t('profile.back-to-profile') }}
|
||||
</v-btn>
|
||||
</div>
|
||||
</section>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import UserAvatar from "~/components/Domain/User/UserAvatar.vue";
|
||||
import UserPasswordStrength from "~/components/Domain/User/UserPasswordStrength.vue";
|
||||
import { validators } from "~/composables/use-validators";
|
||||
import { useUserActivityPreferences } from "~/composables/use-users/preferences";
|
||||
import useDefaultActivity from "~/composables/use-default-activity";
|
||||
import { ActivityKey } from "~/lib/api/types/activity";
|
||||
import type { UserBase } from "~/lib/api/types/user";
|
||||
|
||||
const i18n = useI18n();
|
||||
const auth = useMealieAuth();
|
||||
const { getDefaultActivityLabels, getActivityLabel, getActivityKey } = useDefaultActivity();
|
||||
const user = computed(() => auth.user.value);
|
||||
|
||||
useSeoMeta({
|
||||
title: i18n.t("settings.profile"),
|
||||
});
|
||||
|
||||
const activityPreferences = useUserActivityPreferences();
|
||||
const activityOptions = getDefaultActivityLabels(i18n);
|
||||
const selectedDefaultActivity = ref(getActivityLabel(i18n, activityPreferences.value.defaultActivity));
|
||||
watch(selectedDefaultActivity, () => {
|
||||
activityPreferences.value.defaultActivity = getActivityKey(i18n, selectedDefaultActivity.value) ?? ActivityKey.RECIPES;
|
||||
});
|
||||
|
||||
const userCopy = ref({ ...user.value });
|
||||
watch(user, () => {
|
||||
userCopy.value = { ...user.value };
|
||||
});
|
||||
|
||||
const api = useUserApi();
|
||||
const showPassword = ref(false);
|
||||
const password = reactive({
|
||||
current: "",
|
||||
newOne: "",
|
||||
newTwo: "",
|
||||
});
|
||||
|
||||
const passwordsMatch = computed(() => password.newOne === password.newTwo && password.newOne.length > 0);
|
||||
|
||||
async function updateUser() {
|
||||
const userData = userCopy.value;
|
||||
if (!userData?.id || !userData.email) return;
|
||||
|
||||
const updatePayload: UserBase = {
|
||||
id: userData.id,
|
||||
username: userData.username,
|
||||
fullName: userData.fullName,
|
||||
email: userData.email,
|
||||
authMethod: userData.authMethod,
|
||||
admin: userData.admin,
|
||||
group: userData.group,
|
||||
household: userData.household,
|
||||
advanced: userData.advanced,
|
||||
canInvite: userData.canInvite,
|
||||
canManage: userData.canManage,
|
||||
canManageHousehold: userData.canManageHousehold,
|
||||
canOrganize: userData.canOrganize,
|
||||
};
|
||||
|
||||
const { response } = await api.users.updateOne(userData.id, updatePayload);
|
||||
if (response?.status === 200) {
|
||||
auth.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePassword() {
|
||||
if (!userCopy.value?.id) {
|
||||
return;
|
||||
}
|
||||
const { response } = await api.users.changePassword({
|
||||
currentPassword: password.current,
|
||||
newPassword: password.newOne,
|
||||
});
|
||||
|
||||
if (response?.status === 200) {
|
||||
console.log("Password Changed");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
363
frontend/app/pages/user/profile/index.vue
Normal file
363
frontend/app/pages/user/profile/index.vue
Normal file
@@ -0,0 +1,363 @@
|
||||
<template>
|
||||
<v-container v-if="user" class="mb-8">
|
||||
<section class="d-flex flex-column align-center mt-4">
|
||||
<UserAvatar
|
||||
:tooltip="false"
|
||||
size="96"
|
||||
:user-id="user.id"
|
||||
/>
|
||||
|
||||
<h2 class="text-h4 text-center">
|
||||
{{ $t('profile.welcome-user', [user.fullName]) }}
|
||||
</h2>
|
||||
<p class="subtitle-1 mb-0 text-center">
|
||||
{{ $t('profile.description') }}
|
||||
</p>
|
||||
<v-card
|
||||
flat
|
||||
color="transparent"
|
||||
width="100%"
|
||||
max-width="600px"
|
||||
>
|
||||
<v-card-actions class="d-flex justify-center my-4">
|
||||
<v-btn
|
||||
v-if="user.canInvite"
|
||||
variant="outlined"
|
||||
rounded
|
||||
:prepend-icon="$globals.icons.createAlt"
|
||||
:text="$t('profile.get-invite-link')"
|
||||
@click="inviteDialog = true"
|
||||
/>
|
||||
</v-card-actions>
|
||||
<UserInviteDialog v-model="inviteDialog" />
|
||||
</v-card>
|
||||
</section>
|
||||
<section class="my-3">
|
||||
<div>
|
||||
<h3 class="text-h5">
|
||||
{{ $t('profile.account-summary') }}
|
||||
</h3>
|
||||
<p>{{ $t('profile.account-summary-description') }}</p>
|
||||
</div>
|
||||
<v-row tag="section">
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="12"
|
||||
>
|
||||
<v-card variant="outlined" style="border-color: lightgray;" class="mt-4">
|
||||
<v-card-title class="text-h6 pb-0">
|
||||
{{ $t('profile.household-statistics') }}
|
||||
</v-card-title>
|
||||
<v-card-text class="py-0">
|
||||
{{ $t('profile.household-statistics-description') }}
|
||||
</v-card-text>
|
||||
<v-card-text
|
||||
class="d-flex flex-wrap justify-center align-center"
|
||||
style="gap: 0.8rem"
|
||||
>
|
||||
<StatsCards
|
||||
v-for="(value, key) in stats"
|
||||
:key="`${key}-${value}`"
|
||||
:min-width="$vuetify.display.xs ? '100%' : '158'"
|
||||
:icon="getStatsIcon(key)"
|
||||
:to="getStatsTo(key)"
|
||||
>
|
||||
<template #title>
|
||||
{{ getStatsTitle(key) }}
|
||||
</template>
|
||||
<template #value>
|
||||
{{ value }}
|
||||
</template>
|
||||
</StatsCards>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</section>
|
||||
<v-divider class="my-7" />
|
||||
<section>
|
||||
<div>
|
||||
<h3 class="text-h6">
|
||||
{{ $t('profile.personal') }}
|
||||
</h3>
|
||||
<p>{{ $t('profile.personal-description') }}</p>
|
||||
</div>
|
||||
<v-row tag="section">
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-user-profile'), to: `/user/profile/edit` }"
|
||||
image="/svgs/manage-profile.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.user-settings') }}
|
||||
</template>
|
||||
{{ $t('profile.user-settings-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
<AdvancedOnly>
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-your-api-tokens'), to: `/user/profile/api-tokens` }"
|
||||
image="/svgs/manage-api-tokens.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('settings.token.api-tokens') }}
|
||||
</template>
|
||||
{{ $t('profile.api-tokens-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
</AdvancedOnly>
|
||||
</v-row>
|
||||
</section>
|
||||
<v-divider class="my-7" />
|
||||
<section>
|
||||
<div>
|
||||
<h3 class="text-h6">
|
||||
{{ $t('household.household') }}
|
||||
</h3>
|
||||
<p>{{ $t('profile.household-description') }}</p>
|
||||
</div>
|
||||
<v-row tag="section">
|
||||
<v-col
|
||||
v-if="user.canManageHousehold"
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.household-settings'), to: `/household` }"
|
||||
image="/svgs/manage-group-settings.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.household-settings') }}
|
||||
</template>
|
||||
{{ $t('profile.household-settings-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-cookbooks'), to: `/g/${groupSlug}/cookbooks` }"
|
||||
image="/svgs/manage-cookbooks.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('sidebar.cookbooks') }}
|
||||
</template>
|
||||
{{ $t('profile.cookbooks-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
<v-col
|
||||
v-if="user.canManage"
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-members'), to: `/household/members` }"
|
||||
image="/svgs/manage-members.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.members') }}
|
||||
</template>
|
||||
{{ $t('profile.members-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
<AdvancedOnly>
|
||||
<v-col
|
||||
v-if="user.advanced"
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-webhooks'), to: `/household/webhooks` }"
|
||||
image="/svgs/manage-webhooks.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('settings.webhooks.webhooks') }}
|
||||
</template>
|
||||
{{ $t('profile.webhooks-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
</AdvancedOnly>
|
||||
<AdvancedOnly>
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-notifiers'), to: `/household/notifiers` }"
|
||||
image="/svgs/manage-notifiers.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.notifiers') }}
|
||||
</template>
|
||||
{{ $t('profile.notifiers-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
</AdvancedOnly>
|
||||
</v-row>
|
||||
</section>
|
||||
<v-divider class="my-7" />
|
||||
<section v-if="user.canManage || user.canOrganize || user.advanced">
|
||||
<div>
|
||||
<h3 class="text-h6">
|
||||
{{ $t('group.group') }}
|
||||
</h3>
|
||||
<p>{{ $t('profile.group-description') }}</p>
|
||||
</div>
|
||||
<v-row tag="section">
|
||||
<v-col
|
||||
v-if="user.canManage"
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.group-settings'), to: `/group` }"
|
||||
image="/svgs/manage-group-settings.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.group-settings') }}
|
||||
</template>
|
||||
{{ $t('profile.group-settings-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
<v-col
|
||||
v-if="user.canOrganize"
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-data'), to: `/group/data/foods` }"
|
||||
image="/svgs/manage-recipes.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.manage-data') }}
|
||||
</template>
|
||||
{{ $t('profile.manage-data-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
<AdvancedOnly>
|
||||
<v-col
|
||||
cols="12"
|
||||
sm="12"
|
||||
md="6"
|
||||
>
|
||||
<UserProfileLinkCard
|
||||
:link="{ text: $t('profile.manage-data-migrations'), to: `/group/migrations` }"
|
||||
image="/svgs/manage-data-migrations.svg"
|
||||
>
|
||||
<template #title>
|
||||
{{ $t('profile.data-migrations') }}
|
||||
</template>
|
||||
{{ $t('profile.data-migrations-description') }}
|
||||
</UserProfileLinkCard>
|
||||
</v-col>
|
||||
</AdvancedOnly>
|
||||
</v-row>
|
||||
</section>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import UserProfileLinkCard from "@/components/Domain/User/UserProfileLinkCard.vue";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import UserAvatar from "@/components/Domain/User/UserAvatar.vue";
|
||||
import { useAsyncKey } from "~/composables/use-utils";
|
||||
import StatsCards from "~/components/global/StatsCards.vue";
|
||||
import type { UserOut } from "~/lib/api/types/user";
|
||||
import UserInviteDialog from "~/components/Domain/User/UserInviteDialog.vue";
|
||||
|
||||
definePageMeta({
|
||||
name: "UserProfile",
|
||||
scrollToTop: true,
|
||||
});
|
||||
|
||||
const i18n = useI18n();
|
||||
const auth = useMealieAuth();
|
||||
const { $appInfo } = useNuxtApp();
|
||||
const route = useRoute();
|
||||
const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
|
||||
|
||||
useSeoMeta({
|
||||
title: i18n.t("settings.profile"),
|
||||
});
|
||||
|
||||
const user = computed<UserOut | null>(() => {
|
||||
const authUser = auth.user.value;
|
||||
if (!authUser) return null;
|
||||
|
||||
// Override canInvite if password login is disabled
|
||||
const canInvite = !$appInfo.allowPasswordLogin ? false : authUser.canInvite;
|
||||
|
||||
return {
|
||||
...authUser,
|
||||
canInvite,
|
||||
};
|
||||
});
|
||||
|
||||
const inviteDialog = ref(false);
|
||||
const api = useUserApi();
|
||||
|
||||
const { data: stats } = useAsyncData(useAsyncKey(), async () => {
|
||||
const { data } = await api.households.statistics();
|
||||
|
||||
if (data) {
|
||||
return data;
|
||||
}
|
||||
});
|
||||
|
||||
const statsText: { [key: string]: string } = {
|
||||
totalRecipes: i18n.t("general.recipes"),
|
||||
totalUsers: i18n.t("user.users"),
|
||||
totalCategories: i18n.t("sidebar.categories"),
|
||||
totalTags: i18n.t("sidebar.tags"),
|
||||
totalTools: i18n.t("tool.tools"),
|
||||
};
|
||||
|
||||
function getStatsTitle(key: string) {
|
||||
return statsText[key] ?? "unknown";
|
||||
}
|
||||
|
||||
const { $globals } = useNuxtApp();
|
||||
|
||||
const iconText: { [key: string]: string } = {
|
||||
totalUsers: $globals.icons.user,
|
||||
totalCategories: $globals.icons.categories,
|
||||
totalTags: $globals.icons.tags,
|
||||
totalTools: $globals.icons.potSteam,
|
||||
};
|
||||
|
||||
function getStatsIcon(key: string) {
|
||||
return iconText[key] ?? $globals.icons.primary;
|
||||
}
|
||||
|
||||
const statsTo = computed<{ [key: string]: string }>(() => {
|
||||
return {
|
||||
totalRecipes: `/g/${groupSlug.value}/`,
|
||||
totalUsers: "/household/members",
|
||||
totalCategories: `/g/${groupSlug.value}/recipes/categories`,
|
||||
totalTags: `/g/${groupSlug.value}/recipes/tags`,
|
||||
totalTools: `/g/${groupSlug.value}/recipes/tools`,
|
||||
};
|
||||
});
|
||||
|
||||
function getStatsTo(key: string) {
|
||||
return statsTo.value[key] ?? "unknown";
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user