From 5be33abb030b35f6c0729fc052f6a33780077f72 Mon Sep 17 00:00:00 2001 From: tristan Date: Mon, 9 Feb 2026 20:49:47 +0100 Subject: [PATCH] fix : correction de l'impression des absences + ajout d'un favicon --- config/packages/nelmio_cors.yaml | 2 +- frontend/composables/useApi.ts | 11 +++++++++-- frontend/composables/usePdfPrinter.ts | 13 +++++++------ frontend/pages/login.vue | 1 - frontend/public/favicon.ico | Bin 4286 -> 1150 bytes src/State/AbsencePrintProvider.php | 6 +++++- 6 files changed, 22 insertions(+), 11 deletions(-) diff --git a/config/packages/nelmio_cors.yaml b/config/packages/nelmio_cors.yaml index 7b20162..2717d60 100644 --- a/config/packages/nelmio_cors.yaml +++ b/config/packages/nelmio_cors.yaml @@ -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 diff --git a/frontend/composables/useApi.ts b/frontend/composables/useApi.ts index fda5e47..94f57ec 100644 --- a/frontend/composables/useApi.ts +++ b/frontend/composables/useApi.ts @@ -4,9 +4,14 @@ import { useAuthStore } from '~/stores/auth' export type AnyObject = Record +export type BlobResponse = { + data: Blob + headers: Headers +} + export type ApiClient = { get(url: string, query?: AnyObject, options?: ApiFetchOptions<'json'>): Promise - getBlob(url: string, query?: AnyObject, options?: ApiFetchOptions<'blob'>): Promise + getBlob(url: string, query?: AnyObject, options?: ApiFetchOptions<'blob'>): Promise post(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise put(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise patch(url: string, body?: AnyObject, options?: ApiFetchOptions<'json'>): Promise @@ -165,7 +170,9 @@ export const useApi = (): ApiClient => { return request('GET', url, { ...options, query }) }, getBlob(url: string, query: AnyObject = {}, options: ApiFetchOptions<'blob'> = {}) { - return client(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(url: string, body: AnyObject = {}, options: ApiFetchOptions<'json'> = {}) { return request('POST', url, { ...options, body }) diff --git a/frontend/composables/usePdfPrinter.ts b/frontend/composables/usePdfPrinter.ts index 7d68179..b60666d 100644 --- a/frontend/composables/usePdfPrinter.ts +++ b/frontend/composables/usePdfPrinter.ts @@ -4,16 +4,17 @@ export const usePdfPrinter = () => { const api = useApi() const printPdf = async (url: string): Promise => { - 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; diff --git a/frontend/pages/login.vue b/frontend/pages/login.vue index 0b57285..f2e0c37 100644 --- a/frontend/pages/login.vue +++ b/frontend/pages/login.vue @@ -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('/') diff --git a/frontend/public/favicon.ico b/frontend/public/favicon.ico index 18993ad91cfd43e03b074dd0b5cc3f37ab38e49c..0c9b311439cb1ff5b21637fe6e12b3708795408e 100644 GIT binary patch literal 1150 zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x#lFaYI*xgi+LMijK#Y zrw4K-TpdXN5)ZBap)M}`Gtd0j(3}42mci`bXG3$_L=n0f7Y@a46C+3rpZ+;^a{uERw>X;C9LfZ#Jvg;fv)^3m;$|m> z|4Uk`<-z*X5$-oOHf9BhfdI(V1{_o3= z+zL{+3(5UyX=y0>=b7_allek=~NJ3rM$`~R*C z*95-)|93!gdna|8^_xokUm9%rc7BA@O(gvwX)plkpXqJ%Z>pQ_|K-jq{}UV>1bTKp z)zIsGyB4HiwynaanLfsUr@89<$En}T@c$fd{l62!-7Z2*WnfV1cy~}i!GU96OKIbD z7tQ}OJPmN_p8?dr*iztM=;WLCb0ir}?%9~+c4CI7Ay)lsJhgtW@H70syE?NO zq}F`Nk6k8>mtA?{cIUXxcv=n;J2t)3Y@vhV|D#DR|Gl&nBtT*?kftYBA1KG)H3{Nw zaJu3SUD56~^K~Iq4LBc0$nrEtC<(U4#>Rr<_V`BzhQkF63 zOGiREbCw`xmFozJ^aNatJY>w+g ze6a2@u~m#^BZm@8wco9#Crlli0uLb^3E$t2-WIc^#(?t)*@`UpuofJ(Uyh@F>b3Ph z$D^m8Xq~pTkGJ4Q`Q2)te3mgkWYZ^Ijq|hkiP^9`De={bQQ%heZC$QU2UpP(-tbl8 zPWD2abEew;oat@w`uP3J^YpsgT%~jT(Dk%oU}sa$7|n6hBjDj`+I;RX(>)%lm_7N{+B7Mu%H?422lE%MBJH!!YTN2oT7xr>>N-8OF$C&qU^ z>vLsa{$0X%q1fjOe3P1mCv#lN{xQ4_*HCSAZjTb1`}mlc+9rl8$B3OP%VT@mch_~G z7Y+4b{r>9e=M+7vSI;BgB?ryZDY4m>&wcHSn81VH1N~`0gvwH{ z8dv#hG|OK`>1;j7tM#B)Z7zDN?{6=dUal}$esetPaper('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',