| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  | <template> | 
					
						
							|  |  |  |   <v-data-table | 
					
						
							|  |  |  |     item-key="id" | 
					
						
							|  |  |  |     :headers="headers" | 
					
						
							|  |  |  |     :items="exports" | 
					
						
							|  |  |  |     :items-per-page="15" | 
					
						
							|  |  |  |     class="elevation-0" | 
					
						
							|  |  |  |     @click:row="downloadData" | 
					
						
							|  |  |  |   > | 
					
						
							|  |  |  |     <template #item.expires="{ item }"> | 
					
						
							|  |  |  |       {{ getTimeToExpire(item.expires) }} | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |     <template #item.actions="{ item }"> | 
					
						
							|  |  |  |       <BaseButton download small :download-url="`/api/recipes/bulk-actions/export/download?path=${item.path}`"> | 
					
						
							|  |  |  |       </BaseButton> | 
					
						
							|  |  |  |     </template> | 
					
						
							|  |  |  |   </v-data-table> | 
					
						
							|  |  |  | </template> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <script lang="ts"> | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  | import { defineComponent, useContext } from "@nuxtjs/composition-api"; | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  | import { parseISO, formatDistanceToNow } from "date-fns"; | 
					
						
							| 
									
										
										
										
											2022-05-21 21:22:02 +02:00
										 |  |  | import { GroupDataExport } from "~/types/api-types/group"; | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  | export default defineComponent({ | 
					
						
							|  |  |  |   props: { | 
					
						
							|  |  |  |     exports: { | 
					
						
							|  |  |  |       type: Array as () => GroupDataExport[], | 
					
						
							|  |  |  |       required: true, | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   setup() { | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |     const { i18n } = useContext(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |     const headers = [ | 
					
						
							| 
									
										
										
										
											2022-08-10 07:12:45 +02:00
										 |  |  |       { text: i18n.t("export.export"), value: "name" }, | 
					
						
							|  |  |  |       { text: i18n.t("export.file-name"), value: "filename" }, | 
					
						
							|  |  |  |       { text: i18n.t("export.size"), value: "size" }, | 
					
						
							|  |  |  |       { text: i18n.t("export.link-expires"), value: "expires" }, | 
					
						
							| 
									
										
										
										
											2021-12-04 14:18:46 -09:00
										 |  |  |       { text: "", value: "actions" }, | 
					
						
							|  |  |  |     ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function getTimeToExpire(timeString: string) { | 
					
						
							|  |  |  |       const expiresAt = parseISO(timeString); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return formatDistanceToNow(expiresAt, { | 
					
						
							|  |  |  |         addSuffix: false, | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     function downloadData(_: any) { | 
					
						
							|  |  |  |       console.log("Downloading data..."); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return { | 
					
						
							|  |  |  |       downloadData, | 
					
						
							|  |  |  |       headers, | 
					
						
							|  |  |  |       getTimeToExpire, | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  | }); | 
					
						
							|  |  |  | </script> |