| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-container v-if="user"> | 
					
						
							|  |  |  |     <section class="d-flex flex-column align-center"> | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  |       <UserAvatar size="84" :user-id="$auth.user.id" /> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       <h2 class="headline">{{ $t('profile.welcome-user', [user.fullName]) }}</h2> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |       <p class="subtitle-1 mb-0"> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |        {{ $t('profile.description') }} | 
					
						
							|  |  |  |         <a href="https://hay-kot.github.io/mealie/" target="_blank"> {{ $t('general.learn-more') }} </a> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |       </p> | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |       <v-card v-if="$auth.user.canInvite" flat color="background" width="100%" max-width="600px"> | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  |         <v-card-actions class="d-flex justify-center"> | 
					
						
							|  |  |  |           <v-btn outlined rounded @click="getSignupLink()"> | 
					
						
							|  |  |  |             <v-icon left> | 
					
						
							|  |  |  |               {{ $globals.icons.createAlt }} | 
					
						
							|  |  |  |             </v-icon> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             {{ $t('profile.get-invite-link') }} | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  |           </v-btn> | 
					
						
							|  |  |  |         </v-card-actions> | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |         <div v-show="generatedLink !== ''"> | 
					
						
							|  |  |  |           <v-card-text> | 
					
						
							|  |  |  |             <p class="text-center pb-0"> | 
					
						
							|  |  |  |               {{ generatedLink }} | 
					
						
							|  |  |  |             </p> | 
					
						
							|  |  |  |             <v-text-field v-model="sendTo" :label="$t('user.email')" :rules="[validators.email]"> </v-text-field> | 
					
						
							|  |  |  |           </v-card-text> | 
					
						
							|  |  |  |           <v-card-actions class="py-0 align-center" style="gap: 4px"> | 
					
						
							|  |  |  |             <BaseButton cancel @click="generatedLink = ''"> {{ $t("general.close") }} </BaseButton> | 
					
						
							|  |  |  |             <v-spacer></v-spacer> | 
					
						
							|  |  |  |             <AppButtonCopy :icon="false" color="info" :copy-text="generatedLink" /> | 
					
						
							|  |  |  |             <BaseButton color="info" :disabled="!validEmail" :loading="loading" @click="sendInvite"> | 
					
						
							|  |  |  |               <template #icon> | 
					
						
							|  |  |  |                 {{ $globals.icons.email }} | 
					
						
							|  |  |  |               </template> | 
					
						
							|  |  |  |               {{ $t("user.email") }} | 
					
						
							|  |  |  |             </BaseButton> | 
					
						
							|  |  |  |           </v-card-actions> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  |       </v-card> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |     </section> | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |     <section class="my-3"> | 
					
						
							|  |  |  |       <div> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         <h3 class="headline">{{ $t('profile.account-summary') }}</h3> | 
					
						
							|  |  |  |         <p>{{ $t('profile.account-summary-description') }}</p> | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |       <v-row tag="section"> | 
					
						
							|  |  |  |         <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |           <v-card outlined> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             <v-card-title class="headline pb-0"> {{ $t('profile.group-statistics') }} </v-card-title> | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |             <v-card-text class="py-0"> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               {{ $t('profile.group-statistics-description') }} | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |             </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.breakpoint.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-col cols="12" sm="12" md="6" class="d-flex align-strart"> | 
					
						
							|  |  |  |           <v-card outlined> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             <v-card-title class="headline pb-0"> {{ $t('profile.storage-capacity') }} </v-card-title> | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |             <v-card-text class="py-0"> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               {{ $t('profile.storage-capacity-description') }} | 
					
						
							|  |  |  |               <strong> {{ $t('general.this-feature-is-currently-inactive') }}</strong> | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |             </v-card-text> | 
					
						
							|  |  |  |             <v-card-text> | 
					
						
							|  |  |  |               <v-progress-linear :value="storageUsedPercentage" color="accent" class="rounded" height="30"> | 
					
						
							|  |  |  |                 <template #default> | 
					
						
							|  |  |  |                   <strong> {{ storageText }} </strong> | 
					
						
							|  |  |  |                 </template> | 
					
						
							|  |  |  |               </v-progress-linear> | 
					
						
							|  |  |  |             </v-card-text> | 
					
						
							|  |  |  |           </v-card> | 
					
						
							|  |  |  |         </v-col> | 
					
						
							|  |  |  |       </v-row> | 
					
						
							|  |  |  |     </section> | 
					
						
							|  |  |  |     <v-divider class="my-7"></v-divider> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |     <section> | 
					
						
							|  |  |  |       <div> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         <h3 class="headline">{{ $t('profile.personal') }}</h3> | 
					
						
							|  |  |  |         <p>{{ $t('profile.personal-description') }}</p> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |       <v-row tag="section"> | 
					
						
							|  |  |  |         <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |           <UserProfileLinkCard | 
					
						
							|  |  |  |             :link="{ text: 'Manage User Profile', to: '/user/profile/edit' }" | 
					
						
							|  |  |  |             :image="require('~/static/svgs/manage-profile.svg')" | 
					
						
							|  |  |  |           > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             <template #title> {{ $t('profile.user-settings') }} </template> | 
					
						
							|  |  |  |             {{ $t('profile.user-settings-description') }} | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |           </UserProfileLinkCard> | 
					
						
							|  |  |  |         </v-col> | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |         <AdvancedOnly> | 
					
						
							|  |  |  |           <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |             <UserProfileLinkCard | 
					
						
							|  |  |  |               :link="{ text: 'Manage Your API Tokens', to: '/user/profile/api-tokens' }" | 
					
						
							|  |  |  |               :image="require('~/static/svgs/manage-api-tokens.svg')" | 
					
						
							|  |  |  |             > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               <template #title> {{ $t('settings.token.api-tokens') }} </template> | 
					
						
							|  |  |  |               {{ $t('profile.api-tokens-description') }} | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |             </UserProfileLinkCard> | 
					
						
							|  |  |  |           </v-col> | 
					
						
							|  |  |  |         </AdvancedOnly> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |       </v-row> | 
					
						
							|  |  |  |     </section> | 
					
						
							|  |  |  |     <v-divider class="my-7"></v-divider> | 
					
						
							|  |  |  |     <section> | 
					
						
							|  |  |  |       <div> | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         <h3 class="headline">{{ $t('group.group') }}</h3> | 
					
						
							|  |  |  |         <p>{{ $t('profile.group-description') }}</p> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |       </div> | 
					
						
							|  |  |  |       <v-row tag="section"> | 
					
						
							|  |  |  |         <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |           <UserProfileLinkCard | 
					
						
							| 
									
										
										
										
											2022-03-23 04:54:16 +01:00
										 |  |  |             :link="{ text: 'Group Settings', to: '/group' }" | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |             :image="require('~/static/svgs/manage-group-settings.svg')" | 
					
						
							|  |  |  |           > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             <template #title> {{ $t('profile.group-settings') }} </template> | 
					
						
							|  |  |  |             {{ $t('profile.group-settings-description') }} | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |           </UserProfileLinkCard> | 
					
						
							|  |  |  |         </v-col> | 
					
						
							|  |  |  |         <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |           <UserProfileLinkCard | 
					
						
							| 
									
										
										
										
											2022-03-23 04:54:16 +01:00
										 |  |  |             :link="{ text: 'Manage Cookbooks', to: '/group/cookbooks' }" | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |             :image="require('~/static/svgs/manage-cookbooks.svg')" | 
					
						
							|  |  |  |           > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             <template #title> {{ $t('sidebar.cookbooks') }} </template> | 
					
						
							|  |  |  |             {{ $t('profile.cookbooks-description') }} | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |           </UserProfileLinkCard> | 
					
						
							|  |  |  |         </v-col> | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |         <v-col v-if="user.canManage" cols="12" sm="12" md="6"> | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |           <UserProfileLinkCard | 
					
						
							| 
									
										
										
										
											2022-03-23 04:54:16 +01:00
										 |  |  |             :link="{ text: 'Manage Members', to: '/group/members' }" | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |             :image="require('~/static/svgs/manage-members.svg')" | 
					
						
							|  |  |  |           > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |             <template #title> {{ $t('profile.members') }} </template> | 
					
						
							|  |  |  |             {{ $t('profile.members-description') }} | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |           </UserProfileLinkCard> | 
					
						
							|  |  |  |         </v-col> | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |         <AdvancedOnly> | 
					
						
							|  |  |  |           <v-col v-if="user.advanced" cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |             <UserProfileLinkCard | 
					
						
							|  |  |  |               :link="{ text: 'Manage Webhooks', to: '/group/webhooks' }" | 
					
						
							|  |  |  |               :image="require('~/static/svgs/manage-webhooks.svg')" | 
					
						
							|  |  |  |             > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               <template #title> {{ $t('settings.webhooks.webhooks') }} </template> | 
					
						
							|  |  |  |               {{ $t('profile.webhooks-description') }} | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |             </UserProfileLinkCard> | 
					
						
							|  |  |  |           </v-col> | 
					
						
							|  |  |  |         </AdvancedOnly> | 
					
						
							|  |  |  |         <AdvancedOnly> | 
					
						
							|  |  |  |           <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |             <UserProfileLinkCard | 
					
						
							|  |  |  |               :link="{ text: 'Manage Notifiers', to: '/group/notifiers' }" | 
					
						
							|  |  |  |               :image="require('~/static/svgs/manage-notifiers.svg')" | 
					
						
							|  |  |  |             > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               <template #title> {{ $t('profile.notifiers') }} </template> | 
					
						
							|  |  |  |               {{ $t('profile.notifiers-description') }} | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |             </UserProfileLinkCard> | 
					
						
							|  |  |  |           </v-col> | 
					
						
							|  |  |  |         </AdvancedOnly> | 
					
						
							|  |  |  |         <AdvancedOnly> | 
					
						
							|  |  |  |           <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |             <UserProfileLinkCard | 
					
						
							|  |  |  |               :link="{ text: 'Manage Data', to: '/group/data/foods' }" | 
					
						
							|  |  |  |               :image="require('~/static/svgs/manage-recipes.svg')" | 
					
						
							|  |  |  |             > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               <template #title> {{ $t('profile.manage-data') }} </template> | 
					
						
							|  |  |  |               {{ $t('profile.manage-data-description') }} | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |             </UserProfileLinkCard> | 
					
						
							|  |  |  |           </v-col> | 
					
						
							|  |  |  |         </AdvancedOnly> | 
					
						
							|  |  |  |         <AdvancedOnly> | 
					
						
							|  |  |  |           <v-col cols="12" sm="12" md="6"> | 
					
						
							|  |  |  |             <UserProfileLinkCard | 
					
						
							|  |  |  |               :link="{ text: 'Manage Data Migrations', to: '/group/migrations' }" | 
					
						
							|  |  |  |               :image="require('~/static/svgs/manage-data-migrations.svg')" | 
					
						
							|  |  |  |             > | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |               <template #title>{{ $t('profile.data-migrations') }} </template> | 
					
						
							|  |  |  |               {{ $t('profile.data-migrations-description') }} | 
					
						
							| 
									
										
										
										
											2022-04-09 19:08:48 -08:00
										 |  |  |             </UserProfileLinkCard> | 
					
						
							|  |  |  |           </v-col> | 
					
						
							|  |  |  |         </AdvancedOnly> | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |       </v-row> | 
					
						
							|  |  |  |     </section> | 
					
						
							|  |  |  |   </v-container> | 
					
						
							|  |  |  | </template> | 
					
						
							| 
									
										
										
										
											2022-01-09 21:04:24 -09:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  | import { computed, defineComponent, useContext, ref, toRefs, reactive, useAsync } from "@nuxtjs/composition-api"; | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  | import UserProfileLinkCard from "@/components/Domain/User/UserProfileLinkCard.vue"; | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  | import { useUserApi } from "~/composables/api"; | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  | import { validators } from "~/composables/use-validators"; | 
					
						
							|  |  |  | import { alert } from "~/composables/use-toast"; | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  | import UserAvatar from "@/components/Domain/User/UserAvatar.vue"; | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  | import { useAsyncKey } from "~/composables/use-utils"; | 
					
						
							|  |  |  | import StatsCards from "~/components/global/StatsCards.vue"; | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  |   name: "UserProfile", | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |   components: { | 
					
						
							|  |  |  |     UserProfileLinkCard, | 
					
						
							| 
									
										
										
										
											2021-12-18 19:04:36 -09:00
										 |  |  |     UserAvatar, | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |     StatsCards, | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-10-18 19:41:41 -08:00
										 |  |  |   scrollToTop: true, | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |     const { $auth, i18n } = useContext(); | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     const user = computed(() => $auth.user); | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     const generatedLink = ref(""); | 
					
						
							|  |  |  |     const token = ref(""); | 
					
						
							| 
									
										
										
										
											2021-11-06 11:28:47 -08:00
										 |  |  |     const api = useUserApi(); | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  |     async function getSignupLink() { | 
					
						
							|  |  |  |       const { data } = await api.groups.createInvitation({ uses: 1 }); | 
					
						
							|  |  |  |       if (data) { | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |         token.value = data.token; | 
					
						
							| 
									
										
										
										
											2021-09-09 08:51:29 -08:00
										 |  |  |         generatedLink.value = constructLink(data.token); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function constructLink(token: string) { | 
					
						
							|  |  |  |       return `${window.location.origin}/register?token=${token}`; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     // =================================================
 | 
					
						
							|  |  |  |     // Email Invitation
 | 
					
						
							|  |  |  |     const state = reactive({ | 
					
						
							|  |  |  |       loading: false, | 
					
						
							|  |  |  |       sendTo: "", | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function sendInvite() { | 
					
						
							|  |  |  |       state.loading = true; | 
					
						
							|  |  |  |       const { data } = await api.email.sendInvitation({ | 
					
						
							|  |  |  |         email: state.sendTo, | 
					
						
							|  |  |  |         token: token.value, | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (data && data.success) { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         alert.success(i18n.tc("profile.email-sent")); | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |       } else { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |         alert.error(i18n.tc("profile.error-sending-email")); | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |       } | 
					
						
							|  |  |  |       state.loading = false; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const validEmail = computed(() => { | 
					
						
							|  |  |  |       if (state.sendTo === "") { | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       const valid = validators.email(state.sendTo); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Explicit bool check because validators.email sometimes returns a string
 | 
					
						
							|  |  |  |       if (valid === true) { | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return false; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |     const stats = useAsync(async () => { | 
					
						
							|  |  |  |       const { data } = await api.groups.statistics(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (data) { | 
					
						
							|  |  |  |         return data; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }, useAsyncKey()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const statsText: { [key: string]: string } = { | 
					
						
							| 
									
										
										
										
											2023-01-29 02:39:51 +01:00
										 |  |  |       totalRecipes: i18n.tc("general.recipes"), | 
					
						
							|  |  |  |       totalUsers: i18n.tc("user.users"), | 
					
						
							|  |  |  |       totalCategories: i18n.tc("sidebar.categories"), | 
					
						
							|  |  |  |       totalTags: i18n.tc("sidebar.tags"), | 
					
						
							|  |  |  |       totalTools: i18n.tc("tool.tools"), | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getStatsTitle(key: string) { | 
					
						
							|  |  |  |       return statsText[key] ?? "unknown"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const { $globals } = useContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const iconText: { [key: string]: string } = { | 
					
						
							|  |  |  |       totalUsers: $globals.icons.user, | 
					
						
							|  |  |  |       totalCategories: $globals.icons.tags, | 
					
						
							|  |  |  |       totalTags: $globals.icons.tags, | 
					
						
							|  |  |  |       totalTools: $globals.icons.potSteam, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getStatsIcon(key: string) { | 
					
						
							|  |  |  |       return iconText[key] ?? $globals.icons.primary; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const statsTo: { [key: string]: string } = { | 
					
						
							| 
									
										
										
										
											2023-02-26 20:20:26 +01:00
										 |  |  |       totalRecipes: "/", | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |       totalUsers: "/group/members", | 
					
						
							|  |  |  |       totalCategories: "/recipes/categories", | 
					
						
							|  |  |  |       totalTags: "/recipes/tags", | 
					
						
							|  |  |  |       totalTools: "/recipes/tools", | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getStatsTo(key: string) { | 
					
						
							|  |  |  |       return statsTo[key] ?? "unknown"; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const storage = useAsync(async () => { | 
					
						
							|  |  |  |       const { data } = await api.groups.storage(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (data) { | 
					
						
							|  |  |  |         return data; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     }, useAsyncKey()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const storageUsedPercentage = computed(() => { | 
					
						
							|  |  |  |       if (!storage.value) { | 
					
						
							|  |  |  |         return 0; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return (storage.value?.usedStorageBytes / storage.value?.totalStorageBytes) * 100 ?? 0; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const storageText = computed(() => { | 
					
						
							|  |  |  |       if (!storage.value) { | 
					
						
							|  |  |  |         return "Loading..."; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return `${storage.value.usedStorageStr} / ${storage.value.totalStorageStr}`; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |     return { | 
					
						
							| 
									
										
										
										
											2022-03-27 15:12:18 -08:00
										 |  |  |       storageText, | 
					
						
							|  |  |  |       storageUsedPercentage, | 
					
						
							|  |  |  |       getStatsTitle, | 
					
						
							|  |  |  |       getStatsIcon, | 
					
						
							|  |  |  |       getStatsTo, | 
					
						
							|  |  |  |       stats, | 
					
						
							| 
									
										
										
										
											2021-10-04 20:16:37 -08:00
										 |  |  |       user, | 
					
						
							|  |  |  |       constructLink, | 
					
						
							|  |  |  |       generatedLink, | 
					
						
							|  |  |  |       getSignupLink, | 
					
						
							|  |  |  |       sendInvite, | 
					
						
							|  |  |  |       validators, | 
					
						
							|  |  |  |       validEmail, | 
					
						
							|  |  |  |       ...toRefs(state), | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-10-07 09:39:47 -08:00
										 |  |  |   head() { | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       title: this.$t("settings.profile") as string, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-09-04 20:24:32 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> |