From 7c1fe357544ed9a4604b7b5aada72dc68dfc28dd Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Wed, 23 Oct 2024 14:33:02 +0200 Subject: [PATCH] add export buttons for aggregated export and pdf export --- .../Api/V1/TimeEntryController.php | 2 + .../Reporting/ReportingExportButton.vue | 50 ++++++ resources/js/Pages/Reporting.vue | 45 +---- resources/js/Pages/ReportingDetailed.vue | 26 +++ .../packages/api/src/openapi.json.client.ts | 164 ++++++++++++++++++ resources/js/types/reporting.d.ts | 1 + 6 files changed, 251 insertions(+), 37 deletions(-) create mode 100644 resources/js/Components/Common/Reporting/ReportingExportButton.vue create mode 100644 resources/js/types/reporting.d.ts diff --git a/app/Http/Controllers/Api/V1/TimeEntryController.php b/app/Http/Controllers/Api/V1/TimeEntryController.php index 019deb95..6efc30b3 100644 --- a/app/Http/Controllers/Api/V1/TimeEntryController.php +++ b/app/Http/Controllers/Api/V1/TimeEntryController.php @@ -273,7 +273,9 @@ class TimeEntryController extends Controller /** * Export aggregated time entries in organization * + * @operationId exportAggregatedTimeEntries * @throws AuthorizationException + * */ public function aggregateExport(Organization $organization, TimeEntryAggregateExportRequest $request): JsonResponse { diff --git a/resources/js/Components/Common/Reporting/ReportingExportButton.vue b/resources/js/Components/Common/Reporting/ReportingExportButton.vue new file mode 100644 index 00000000..cc92e030 --- /dev/null +++ b/resources/js/Components/Common/Reporting/ReportingExportButton.vue @@ -0,0 +1,50 @@ + + + + + diff --git a/resources/js/Pages/Reporting.vue b/resources/js/Pages/Reporting.vue index aec899de..28d8d14b 100644 --- a/resources/js/Pages/Reporting.vue +++ b/resources/js/Pages/Reporting.vue @@ -8,7 +8,6 @@ import { UserGroupIcon, CheckCircleIcon, TagIcon, - ArrowDownTrayIcon, } from '@heroicons/vue/20/solid'; import DateRangePicker from '@/packages/ui/src/Input/DateRangePicker.vue'; import ReportingChart from '@/Components/Common/Reporting/ReportingChart.vue'; @@ -45,9 +44,9 @@ import { useSessionStorage, useStorage } from '@vueuse/core'; import TabBar from '@/Components/Common/TabBar/TabBar.vue'; import TabBarItem from '@/Components/Common/TabBar/TabBarItem.vue'; import { router } from '@inertiajs/vue3'; -import { SecondaryButton } from '@/packages/ui/src'; -import Dropdown from '@/packages/ui/src/Input/Dropdown.vue'; import { useNotificationsStore } from '@/utils/notification'; +import ReportingExportButton from '@/Components/Common/Reporting/ReportingExportButton.vue'; +import type { ExportFormat } from '@/types/reporting'; const { handleApiRequestNotifications } = useNotificationsStore(); const startDate = useSessionStorage( @@ -160,19 +159,19 @@ async function createTag(tag: string) { return await useTagsStore().createTag(tag); } -type ExportFormat = 'xlsx' | 'csv' | 'ods'; - async function downloadExport(format: ExportFormat) { const organizationId = getCurrentOrganizationId(); if (organizationId) { const response = await handleApiRequestNotifications( () => - api.exportTimeEntries({ + api.exportAggregatedTimeEntries({ params: { organization: organizationId, }, queries: { ...getFilterAttributes(), + group: group.value, + sub_group: subGroup.value, format: format, }, }), @@ -203,38 +202,10 @@ async function downloadExport(format: ExportFormat) { > - - - - + -
+
+ api.exportTimeEntries({ + params: { + organization: organizationId, + }, + queries: { + ...getFilterAttributes(), + format: format, + }, + }), + 'Export successful', + 'Export failed' + ); + window.open(response.download_url, '_self')?.focus(); + } +}