Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cf00e6ef3 | ||
| 5be33abb03 |
@@ -5,7 +5,7 @@ nelmio_cors:
|
|||||||
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
|
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
|
||||||
allow_headers: ['Content-Type', 'Authorization']
|
allow_headers: ['Content-Type', 'Authorization']
|
||||||
allow_credentials: true
|
allow_credentials: true
|
||||||
expose_headers: ['Link']
|
expose_headers: ['Link', 'Content-Disposition']
|
||||||
max_age: 3600
|
max_age: 3600
|
||||||
paths:
|
paths:
|
||||||
'^/': null
|
'^/': null
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
parameters:
|
parameters:
|
||||||
app.version: '0.1.2'
|
app.version: '0.1.3'
|
||||||
|
|||||||
@@ -4,9 +4,14 @@ import { useAuthStore } from '~/stores/auth'
|
|||||||
|
|
||||||
export type AnyObject = Record<string, unknown>
|
export type AnyObject = Record<string, unknown>
|
||||||
|
|
||||||
|
export type BlobResponse = {
|
||||||
|
data: Blob
|
||||||
|
headers: Headers
|
||||||
|
}
|
||||||
|
|
||||||
export type ApiClient = {
|
export type ApiClient = {
|
||||||
get<T>(url: string, query?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
get<T>(url: string, query?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
||||||
getBlob(url: string, query?: AnyObject, options?: ApiFetchOptions<'blob'>): Promise<Blob>
|
getBlob(url: string, query?: AnyObject, options?: ApiFetchOptions<'blob'>): Promise<BlobResponse>
|
||||||
post<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
post<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
||||||
put<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
put<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
||||||
patch<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
patch<T>(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise<T>
|
||||||
@@ -165,7 +170,9 @@ export const useApi = (): ApiClient => {
|
|||||||
return request<T>('GET', url, { ...options, query })
|
return request<T>('GET', url, { ...options, query })
|
||||||
},
|
},
|
||||||
getBlob(url: string, query: AnyObject = {}, options: ApiFetchOptions<'blob'> = {}) {
|
getBlob(url: string, query: AnyObject = {}, options: ApiFetchOptions<'blob'> = {}) {
|
||||||
return client<Blob>(url, { ...options, method: 'GET', query, responseType: 'blob' })
|
return client
|
||||||
|
.raw(url, { ...options, method: 'GET', query, responseType: 'blob' })
|
||||||
|
.then((res) => ({ data: res._data as Blob, headers: res.headers }))
|
||||||
},
|
},
|
||||||
post<T>(url: string, body: AnyObject = {}, options: ApiFetchOptions<'json'> = {}) {
|
post<T>(url: string, body: AnyObject = {}, options: ApiFetchOptions<'json'> = {}) {
|
||||||
return request<T>('POST', url, { ...options, body })
|
return request<T>('POST', url, { ...options, body })
|
||||||
|
|||||||
@@ -4,16 +4,17 @@ export const usePdfPrinter = () => {
|
|||||||
const api = useApi()
|
const api = useApi()
|
||||||
|
|
||||||
const printPdf = async (url: string): Promise<void> => {
|
const printPdf = async (url: string): Promise<void> => {
|
||||||
const blob = await api.getBlob(url);
|
const res = await api.getBlob(url);
|
||||||
|
const disposition = res.headers.get('content-disposition') || '';
|
||||||
|
const match = disposition.match(/filename="(.+?)"/i);
|
||||||
|
const filename = match?.[1] ?? 'document.pdf';
|
||||||
|
|
||||||
const pdfBlob = blob.type === 'application/pdf'
|
const pdfBlob = res.data.type === 'application/pdf'
|
||||||
? blob
|
? res.data
|
||||||
: new Blob([blob], { type: 'application/pdf' });
|
: new Blob([res.data], { type: 'application/pdf' });
|
||||||
|
|
||||||
const blobUrl = URL.createObjectURL(pdfBlob);
|
const blobUrl = URL.createObjectURL(pdfBlob);
|
||||||
|
|
||||||
const filename = `test.pdf`;
|
|
||||||
|
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.href = blobUrl;
|
a.href = blobUrl;
|
||||||
a.download = filename;
|
a.download = filename;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ const handleSubmit = async () => {
|
|||||||
|
|
||||||
isSubmitting.value = true
|
isSubmitting.value = true
|
||||||
try {
|
try {
|
||||||
console.log(useRuntimeConfig().public.apiBase)
|
|
||||||
await auth.login(username.value, password.value)
|
await auth.login(username.value, password.value)
|
||||||
|
|
||||||
await router.push('/')
|
await router.push('/')
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 1.1 KiB |
@@ -78,7 +78,11 @@ class AbsencePrintProvider implements ProviderInterface
|
|||||||
$dompdf->setPaper('A3', 'landscape');
|
$dompdf->setPaper('A3', 'landscape');
|
||||||
$dompdf->render();
|
$dompdf->render();
|
||||||
|
|
||||||
$filename = 'test';
|
$filename = sprintf(
|
||||||
|
'absences_du_%s_au_%s.pdf',
|
||||||
|
$fromDate->format('d-m-Y'),
|
||||||
|
$toDate->format('d-m-Y')
|
||||||
|
);
|
||||||
|
|
||||||
return new Response($dompdf->output(), Response::HTTP_OK, [
|
return new Response($dompdf->output(), Response::HTTP_OK, [
|
||||||
'Content-Type' => 'application/pdf',
|
'Content-Type' => 'application/pdf',
|
||||||
|
|||||||
Reference in New Issue
Block a user