From eb08d76bf2d0d17f7f84be705731b9e83d99af60 Mon Sep 17 00:00:00 2001 From: Pihkaal Date: Wed, 5 Nov 2025 17:36:31 +0100 Subject: [PATCH] feat: improve UI/UX --- public/manifest.json | 5 ++- src/App.vue | 92 +++++++++++++++++++++++++++++++++++--------- src/utils/data.ts | 43 ++++++++++----------- 3 files changed, 98 insertions(+), 42 deletions(-) diff --git a/public/manifest.json b/public/manifest.json index dff52d5..4f8f172 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -2,9 +2,10 @@ "manifest_version": 3, "name": "gestime.aphp.fr exporter", "version": "1.0.0", - "description": "TBD", + "description": "Export your Gestime work schedule to an ICS calendar file", "action": { - "default_popup": "index.html" + "default_popup": "index.html", + "default_popup_width": 450 }, "permissions": ["activeTab", "scripting"], "host_permissions": ["http://gestime.aphp.fr/*"] diff --git a/src/App.vue b/src/App.vue index c072db8..1457877 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,39 +1,95 @@ diff --git a/src/utils/data.ts b/src/utils/data.ts index 5b76dfc..93c1587 100644 --- a/src/utils/data.ts +++ b/src/utils/data.ts @@ -50,25 +50,23 @@ const makeIcsCalendar = (events: IcsEvent[]): IcsCalendar => ({ export async function extractData(): Promise<{ name: string; data: IcsCalendar; -} | null> { +}> { + const [tab] = await chrome.tabs.query({ + active: true, + currentWindow: true, + }); + if (!tab?.id) { + throw new Error("URL incorrecte"); + } + + const urlMatch = tab.url?.match(/\/(\d{2})-(\d{4})$/); + if (!urlMatch) { + throw new Error("URL incorrecte"); + } + const year = parseInt(urlMatch[2]!); + const month = parseInt(urlMatch[1]!); + try { - const [tab] = await chrome.tabs.query({ - active: true, - currentWindow: true, - }); - if (!tab?.id) { - console.error("No active tab found"); - return null; - } - - const urlMatch = tab.url?.match(/\/(\d{2})-(\d{4})$/); - if (!urlMatch) { - console.error("Could not extract month and year from URL"); - return null; - } - const year = parseInt(urlMatch[2]!); - const month = parseInt(urlMatch[1]!); - const [eventsQuery] = await chrome.scripting.executeScript({ target: { tabId: tab.id }, func: () => { @@ -105,7 +103,7 @@ export async function extractData(): Promise<{ return events; }, }); - if (!eventsQuery?.result) return null; + if (!eventsQuery?.result) throw undefined; return { name: `gestime-${urlMatch[1]}-${urlMatch[2]}.ics`, @@ -115,8 +113,9 @@ export async function extractData(): Promise<{ ), ), }; - } catch (error) { - console.error("Error getting elements data:", error); - return null; + } catch { + throw new Error( + "Impossible d'extraires les données, contactez `hello@pihkaal.me`", + ); } }