mirror of https://github.com/buster-so/buster.git
download params
This commit is contained in:
parent
a2c8d68258
commit
d9cde77d0f
|
@ -12,6 +12,8 @@ import type {
|
|||
GetMetricResponse,
|
||||
ListMetricsResponse,
|
||||
MetricDataResponse,
|
||||
MetricDownloadParams,
|
||||
MetricDownloadQueryParams,
|
||||
MetricDownloadResponse,
|
||||
ShareDeleteResponse,
|
||||
ShareUpdateResponse,
|
||||
|
@ -100,8 +102,11 @@ export const updateMetricShare = async ({
|
|||
};
|
||||
|
||||
// Download metric file
|
||||
export const downloadMetricFile = async (id: string): Promise<MetricDownloadResponse> => {
|
||||
export const downloadMetricFile = async ({
|
||||
id,
|
||||
...params
|
||||
}: MetricDownloadParams & MetricDownloadQueryParams): Promise<MetricDownloadResponse> => {
|
||||
return mainApiV2
|
||||
.get<MetricDownloadResponse>(`/metric_files/${id}/download`)
|
||||
.get<MetricDownloadResponse>(`/metric_files/${id}/download`, { params })
|
||||
.then((res) => res.data);
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ import { useDownloadMetricFile } from '@/api/buster_rest/metrics/getMetricQueryR
|
|||
import { Button } from '@/components/ui/buttons';
|
||||
import { CircleWarning, Download4 } from '@/components/ui/icons';
|
||||
import { Text } from '@/components/ui/typography';
|
||||
import { useGetReportParams } from '@/context/Reports/useGetReportParams';
|
||||
import { cn } from '@/lib/classMerge';
|
||||
|
||||
interface MetricDataTruncatedWarningProps {
|
||||
|
@ -41,7 +42,7 @@ export const MetricDataTruncatedWarning: React.FC<MetricDataTruncatedWarningProp
|
|||
</Text>
|
||||
</div>
|
||||
<Button
|
||||
onClick={() => handleDownload(metricId)}
|
||||
onClick={() => handleDownload({ id: metricId })}
|
||||
loading={isGettingFile}
|
||||
variant={hasError ? 'danger' : 'default'}
|
||||
className="ml-4"
|
||||
|
|
|
@ -179,7 +179,7 @@ export const useDownloadMetricDataCSV = ({
|
|||
onClick: async () => {
|
||||
const data = metricData?.data;
|
||||
if (data) {
|
||||
await handleDownload(metricId);
|
||||
await handleDownload({ id: metricId, report_file_id: cacheDataId });
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
|
|
@ -6,9 +6,12 @@ import { z } from 'zod';
|
|||
export const MetricDownloadParamsSchema = z.object({
|
||||
id: z.string().uuid('Metric ID must be a valid UUID'),
|
||||
});
|
||||
export const MetricDownloadQueryParamsSchema = z.object({
|
||||
report_file_id: z.string().uuid('Report file ID must be a valid UUID').optional(),
|
||||
});
|
||||
|
||||
export type MetricDownloadParams = z.infer<typeof MetricDownloadParamsSchema>;
|
||||
|
||||
export type MetricDownloadQueryParams = z.infer<typeof MetricDownloadQueryParamsSchema>;
|
||||
/**
|
||||
* Response for successful metric download
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue