37 lines
1.3 KiB
Vue
37 lines
1.3 KiB
Vue
<script setup lang="ts">
|
|
import { Download } from "@lucide/vue";
|
|
|
|
import { Button } from "@/components/ui/button";
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuTrigger,
|
|
} from "@/components/ui/dropdown-menu";
|
|
import { api } from "@/lib/api";
|
|
import { exportFilterParams, type AuditQuery } from "./audit";
|
|
|
|
/** Export is a navigation, not a fetch: the server owns the filename through
|
|
* Content-Disposition. The window is resolved when the operator picks a
|
|
* format, so the export covers everything visible now rather than at render.
|
|
* A new tab keeps a failed export's response visible instead of saving the
|
|
* error text as a file. */
|
|
const props = defineProps<{ query: AuditQuery }>();
|
|
|
|
function open(format: "csv" | "json"): void {
|
|
window.open(api.auditExportURL(format, exportFilterParams(props.query)), "_blank", "noopener");
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger as-child>
|
|
<Button variant="outline" size="sm"><Download data-icon="inline-start" />Export</Button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent align="end">
|
|
<DropdownMenuItem @select="open('csv')">CSV</DropdownMenuItem>
|
|
<DropdownMenuItem @select="open('json')">JSON</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
</template>
|