| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  | // TODO: Possibly add confirmation dialog? I'm not sure that it's really requried for events...
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-07-31 14:45:28 -08:00
										 |  |  | <template> | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  |   <v-container class="mt-10"> | 
					
						
							| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  |     <v-row v-if="statistics"> | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  |       <v-col cols="12" sm="12" md="4"> | 
					
						
							|  |  |  |         <BaseStatCard :icon="$globals.icons.primary"> | 
					
						
							|  |  |  |           <template #after-heading> | 
					
						
							|  |  |  |             <div class="ml-auto text-right"> | 
					
						
							|  |  |  |               <h2 class="body-3 grey--text font-weight-light"> | 
					
						
							|  |  |  |                 {{ $t("general.recipes") }} | 
					
						
							|  |  |  |               </h2> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |               <h3 class="display-2 font-weight-light text--primary"> | 
					
						
							|  |  |  |                 <small> {{ statistics.totalRecipes }}</small> | 
					
						
							|  |  |  |               </h3> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |           <template #actions> | 
					
						
							|  |  |  |             <div class="d-flex row py-2 justify-end"> | 
					
						
							|  |  |  |               <v-btn class="ma-1" small color="primary" to="/admin/toolbox/organize"> | 
					
						
							|  |  |  |                 <v-icon left> {{ $globals.icons.tags }} </v-icon> | 
					
						
							|  |  |  |                 {{ $tc("tag.untagged-count", [statistics.untaggedRecipes]) }} | 
					
						
							|  |  |  |               </v-btn> | 
					
						
							|  |  |  |               <v-btn class="ma-1" small color="primary" to="/admin/toolbox/organize"> | 
					
						
							|  |  |  |                 <v-icon left> {{ $globals.icons.tags }} </v-icon> | 
					
						
							|  |  |  |                 {{ $tc("category.uncategorized-count", [statistics.uncategorizedRecipes]) }} | 
					
						
							|  |  |  |               </v-btn> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |         </BaseStatCard> | 
					
						
							|  |  |  |       </v-col> | 
					
						
							|  |  |  |       <v-col cols="12" sm="12" md="4"> | 
					
						
							|  |  |  |         <BaseStatCard :icon="$globals.icons.user"> | 
					
						
							|  |  |  |           <template #after-heading> | 
					
						
							|  |  |  |             <div class="ml-auto text-right"> | 
					
						
							|  |  |  |               <h2 class="body-3 grey--text font-weight-light"> | 
					
						
							|  |  |  |                 {{ $t("user.users") }} | 
					
						
							|  |  |  |               </h2> | 
					
						
							|  |  |  |               <h3 class="display-2 font-weight-light text--primary"> | 
					
						
							|  |  |  |                 <small> {{ statistics.totalUsers }}</small> | 
					
						
							|  |  |  |               </h3> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |           <template #actions> | 
					
						
							|  |  |  |             <div class="ml-auto"> | 
					
						
							|  |  |  |               <v-btn color="primary" small to="/admin/manage-users/all-users"> | 
					
						
							|  |  |  |                 <v-icon left>{{ $globals.icons.user }}</v-icon> | 
					
						
							|  |  |  |                 {{ $t("user.manage-users") }} | 
					
						
							|  |  |  |               </v-btn> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |         </BaseStatCard> | 
					
						
							|  |  |  |       </v-col> | 
					
						
							|  |  |  |       <v-col cols="12" sm="12" md="4"> | 
					
						
							|  |  |  |         <BaseStatCard :icon="$globals.icons.group"> | 
					
						
							|  |  |  |           <template #after-heading> | 
					
						
							|  |  |  |             <div class="ml-auto text-right"> | 
					
						
							|  |  |  |               <h2 class="body-3 grey--text font-weight-light"> | 
					
						
							|  |  |  |                 {{ $t("group.groups") }} | 
					
						
							|  |  |  |               </h2> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |               <h3 class="display-2 font-weight-light text--primary"> | 
					
						
							|  |  |  |                 <small> {{ statistics.totalGroups }}</small> | 
					
						
							|  |  |  |               </h3> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |           <template #actions> | 
					
						
							|  |  |  |             <div class="ml-auto"> | 
					
						
							|  |  |  |               <v-btn color="primary" small to="/admin/manage-users/all-groups"> | 
					
						
							|  |  |  |                 <v-icon left>{{ $globals.icons.group }}</v-icon> | 
					
						
							|  |  |  |                 {{ $t("group.manage-groups") }} | 
					
						
							|  |  |  |               </v-btn> | 
					
						
							|  |  |  |             </div> | 
					
						
							|  |  |  |           </template> | 
					
						
							|  |  |  |         </BaseStatCard> | 
					
						
							|  |  |  |       </v-col> | 
					
						
							|  |  |  |     </v-row> | 
					
						
							|  |  |  |     <v-row class="mt-10" align-content="stretch"> | 
					
						
							|  |  |  |       <v-col cols="12" sm="12" lg="6"> | 
					
						
							| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  |         <AdminEventViewer | 
					
						
							|  |  |  |           v-if="events" | 
					
						
							|  |  |  |           :events="events.events" | 
					
						
							|  |  |  |           :total="events.total" | 
					
						
							|  |  |  |           @delete-all="deleteEvents" | 
					
						
							|  |  |  |           @delete-item="deleteEvent" | 
					
						
							|  |  |  |         /> | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  |       </v-col> | 
					
						
							|  |  |  |       <v-col cols="12" sm="12" lg="6"> | 
					
						
							| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  |         <AdminBackupViewer v-if="backups" :available-backups="backups.imports" :templates="backups.templates" /> | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  |       </v-col> | 
					
						
							|  |  |  |     </v-row> | 
					
						
							|  |  |  |   </v-container> | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  | import { defineComponent, useAsync } from "@nuxtjs/composition-api"; | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  | import AdminEventViewer from "@/components/Domain/Admin/AdminEventViewer.vue"; | 
					
						
							|  |  |  | import AdminBackupViewer from "@/components/Domain/Admin/AdminBackupViewer.vue"; | 
					
						
							| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  | import { useApiSingleton } from "~/composables/use-api"; | 
					
						
							|  |  |  | import { useBackups } from "~/composables/use-backups"; | 
					
						
							|  |  |  | import { useAsyncKey } from "~/composables/use-utils"; | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | export default defineComponent({ | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  |   components: { AdminEventViewer, AdminBackupViewer }, | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  |   layout: "admin", | 
					
						
							|  |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2021-08-07 15:12:25 -08:00
										 |  |  |     const api = useApiSingleton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getStatistics() { | 
					
						
							|  |  |  |       const statistics = useAsync(async () => { | 
					
						
							|  |  |  |         const { data } = await api.debug.getAppStatistics(); | 
					
						
							|  |  |  |         return data; | 
					
						
							|  |  |  |       }, useAsyncKey()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return statistics; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getEvents() { | 
					
						
							|  |  |  |       const events = useAsync(async () => { | 
					
						
							|  |  |  |         const { data } = await api.events.getEvents(); | 
					
						
							|  |  |  |         return data; | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |       return events; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function refreshEvents() { | 
					
						
							|  |  |  |       const { data } = await api.events.getEvents(); | 
					
						
							|  |  |  |       events.value = data; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function deleteEvent(id: number) { | 
					
						
							|  |  |  |       const { response } = await api.events.deleteEvent(id); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (response && response.status === 200) { | 
					
						
							|  |  |  |         refreshEvents(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     async function deleteEvents() { | 
					
						
							|  |  |  |       const { response } = await api.events.deleteEvents(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       if (response && response.status === 200) { | 
					
						
							|  |  |  |         events.value = { events: [], total: 0 }; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     const { backups } = useBackups(); | 
					
						
							|  |  |  |     const events = getEvents(); | 
					
						
							|  |  |  |     const statistics = getStatistics(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { statistics, events, deleteEvents, deleteEvent, backups }; | 
					
						
							| 
									
										
										
										
											2021-08-06 16:28:12 -08:00
										 |  |  |   }, | 
					
						
							| 
									
										
										
										
											2021-08-01 19:24:47 -08:00
										 |  |  | }); | 
					
						
							|  |  |  | </script> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <style scoped> | 
					
						
							|  |  |  | </style> |