fix : correction de l'impression des absences + ajout d'un favicon
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
All checks were successful
Auto Tag Develop / tag (push) Successful in 5s
This commit is contained in:
@@ -5,7 +5,7 @@ nelmio_cors:
|
||||
allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']
|
||||
allow_headers: ['Content-Type', 'Authorization']
|
||||
allow_credentials: true
|
||||
expose_headers: ['Link']
|
||||
expose_headers: ['Link', 'Content-Disposition']
|
||||
max_age: 3600
|
||||
paths:
|
||||
'^/': null
|
||||
|
||||
@@ -4,9 +4,14 @@ import { useAuthStore } from '~/stores/auth'
|
||||
|
||||
export type AnyObject = Record<string, unknown>
|
||||
|
||||
export type BlobResponse = {
|
||||
data: Blob
|
||||
headers: Headers
|
||||
}
|
||||
|
||||
export type ApiClient = {
|
||||
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>
|
||||
put<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 })
|
||||
},
|
||||
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'> = {}) {
|
||||
return request<T>('POST', url, { ...options, body })
|
||||
|
||||
@@ -4,16 +4,17 @@ export const usePdfPrinter = () => {
|
||||
const api = useApi()
|
||||
|
||||
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'
|
||||
? blob
|
||||
: new Blob([blob], { type: 'application/pdf' });
|
||||
const pdfBlob = res.data.type === 'application/pdf'
|
||||
? res.data
|
||||
: new Blob([res.data], { type: 'application/pdf' });
|
||||
|
||||
const blobUrl = URL.createObjectURL(pdfBlob);
|
||||
|
||||
const filename = `test.pdf`;
|
||||
|
||||
const a = document.createElement('a');
|
||||
a.href = blobUrl;
|
||||
a.download = filename;
|
||||
|
||||
@@ -63,7 +63,6 @@ const handleSubmit = async () => {
|
||||
|
||||
isSubmitting.value = true
|
||||
try {
|
||||
console.log(useRuntimeConfig().public.apiBase)
|
||||
await auth.login(username.value, password.value)
|
||||
|
||||
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->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, [
|
||||
'Content-Type' => 'application/pdf',
|
||||
|
||||
Reference in New Issue
Block a user