Compare commits

...

10 Commits

Author SHA1 Message Date
Pihkaal
900c6a6bdc chore: update version 2025-11-05 19:13:58 +01:00
Pihkaal
1777382349 feat: zip extension and update reaedme 2025-11-05 19:11:07 +01:00
Pihkaal
5c47d20a6e feat: improve README 2025-11-05 19:01:57 +01:00
Pihkaal
591691fb9b chore: fixed package versions 2025-11-05 18:52:58 +01:00
Pihkaal
c89fbf085b chore: remove unused packages 2025-11-05 18:50:45 +01:00
Pihkaal
5000a83159 feat: add icons 2025-11-05 18:43:45 +01:00
Pihkaal
41e91b6731 feat: rename project to aphp-gestime-exporter, and translate texts to french 2025-11-05 18:29:09 +01:00
Pihkaal
d6850fb2cb feat: load year and month from page, and provide link to planning 2025-11-05 18:15:51 +01:00
Pihkaal
eb08d76bf2 feat: improve UI/UX 2025-11-05 17:36:31 +01:00
Pihkaal
d2c8591ddb feat: nuxt ui setup 2025-11-05 16:14:59 +01:00
25 changed files with 2328 additions and 1462 deletions

4
.gitignore vendored
View File

@@ -1,3 +1,7 @@
auto-imports.d.ts
components.d.ts
*.zip
# Logs
logs
*.log

View File

@@ -1 +1,23 @@
# gestime-aphp-export
# APHP Gestime Exporter
Planning exporter for [APHP Gestime](https://gestime.aphp.fr). Export your planning in ICS file to be able to import it anywere.
## How to Install
1. Download a [release](https://github.com/pihkaal/aphp-gestime-exporter/releases)
2. Extract the files (unzip the downloaded archive)
3. Load the extension ([Tutorial](https://www.youtube.com/watch?v=NH5CPm9pyts))
1. Go to `chrome://extensions`
2. Enable `Developer mode`
3. Click `Load unpacked`
4. Choose the folder where you extracted the files
5. Done! Additionally, you can pin the extension (click on the puzzle icon in the browser toolbar)
> [!WARNING]
> Do not move the folder were you extracted the extension, otherwhise it will stop working.
> This limitation is due to the extension not being published to the Chrome Webstore.
## References
- [APHP Logo](https://www.facebook.com/photo/?fbid=1057890036443767&set=a.589369969962445)

View File

@@ -1,4 +0,0 @@
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": ["./**/*"]
}

View File

@@ -1,8 +0,0 @@
import { test, expect } from '@playwright/test';
// See here how to get started:
// https://playwright.dev/docs/intro
test('visits the app root url', async ({ page }) => {
await page.goto('/');
await expect(page.locator('h1')).toHaveText('You did it!');
})

View File

@@ -1,31 +1,23 @@
import { globalIgnores } from 'eslint/config'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import pluginVitest from '@vitest/eslint-plugin'
import pluginPlaywright from 'eslint-plugin-playwright'
import pluginOxlint from 'eslint-plugin-oxlint'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import { globalIgnores } from "eslint/config";
import {
defineConfigWithVueTs,
vueTsConfigs,
} from "@vue/eslint-config-typescript";
import pluginVue from "eslint-plugin-vue";
import pluginOxlint from "eslint-plugin-oxlint";
import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
export default defineConfigWithVueTs(
{
name: 'app/files-to-lint',
files: ['**/*.{ts,mts,tsx,vue}'],
name: "app/files-to-lint",
files: ["**/*.{ts,mts,tsx,vue}"],
},
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
globalIgnores(["**/dist/**", "**/dist-ssr/**"]),
pluginVue.configs['flat/essential'],
pluginVue.configs["flat/essential"],
vueTsConfigs.recommended,
{
...pluginVitest.configs.recommended,
files: ['src/**/__tests__/*'],
},
{
...pluginPlaywright.configs['flat/recommended'],
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
},
...pluginOxlint.configs['flat/recommended'],
...pluginOxlint.configs["flat/recommended"],
skipFormatting,
)
);

View File

@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html lang="">
<!doctype html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vite App</title>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>APHP Gestime Exporter</title>
</head>
<body>
<div id="app"></div>
<div id="app" class="isolate"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>

View File

@@ -1,6 +1,6 @@
{
"name": "gestime-aphp-export",
"version": "0.0.0",
"name": "aphp-gestime-exporter",
"version": "0.1.0",
"private": true,
"type": "module",
"engines": {
@@ -8,49 +8,44 @@
},
"scripts": {
"dev": "vite",
"build": "run-s type-check build-only copy:manifest",
"copy:manifest": "cp public/manifest.json dist/",
"build": "run-s type-check build-only copy:public",
"copy:public": "cp public/* dist/",
"preview": "vite preview",
"test:unit": "vitest",
"test:e2e": "playwright test",
"build-only": "vite build",
"type-check": "vue-tsc --build",
"zip": "pnpm build && cp -r dist aphp-gestime-exporter && zip -r aphp-gestime-exporter.zip aphp-gestime-exporter && rm -rf aphp-gestime-exporter/",
"lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
"lint:eslint": "eslint . --fix --cache",
"lint": "run-s lint:*",
"format": "prettier --write src/"
},
"dependencies": {
"pinia": "^3.0.3",
"ts-ics": "^2.4.0",
"vue": "^3.5.22"
"@nuxt/ui": "4.1.0",
"@unhead/vue": "2.0.19",
"tailwindcss": "4.1.16",
"ts-ics": "2.4.0",
"vue": "3.5.22",
"vue-router": "4.6.3"
},
"devDependencies": {
"@playwright/test": "^1.56.1",
"@prettier/plugin-oxc": "^0.0.4",
"@tsconfig/node22": "^22.0.2",
"@types/chrome": "^0.1.27",
"@types/jsdom": "^27.0.0",
"@types/node": "^22.18.11",
"@vitejs/plugin-vue": "^6.0.1",
"@vitest/eslint-plugin": "^1.3.23",
"@vue/eslint-config-prettier": "^10.2.0",
"@vue/eslint-config-typescript": "^14.6.0",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.8.1",
"eslint": "^9.37.0",
"eslint-plugin-oxlint": "~1.23.0",
"eslint-plugin-playwright": "^2.2.2",
"eslint-plugin-vue": "~10.5.0",
"jiti": "^2.6.1",
"jsdom": "^27.0.1",
"npm-run-all2": "^8.0.4",
"oxlint": "~1.23.0",
"@prettier/plugin-oxc": "0.0.4",
"@tsconfig/node22": "22.0.2",
"@types/chrome": "0.1.27",
"@types/node": "22.18.11",
"@vitejs/plugin-vue": "6.0.1",
"@vue/eslint-config-prettier": "10.2.0",
"@vue/eslint-config-typescript": "14.6.0",
"@vue/tsconfig": "0.8.1",
"eslint": "9.37.0",
"eslint-plugin-oxlint": "1.23.0",
"eslint-plugin-vue": "10.5.0",
"jiti": "2.6.1",
"npm-run-all2": "8.0.4",
"oxlint": "1.23.0",
"prettier": "3.6.2",
"typescript": "~5.9.0",
"vite": "^7.1.11",
"vite-plugin-vue-devtools": "^8.0.3",
"vitest": "^3.2.4",
"vue-tsc": "^3.1.1"
"typescript": "5.9.0",
"vite": "7.1.11",
"vite-plugin-vue-devtools": "8.0.3",
"vue-tsc": "3.1.1"
}
}

View File

@@ -1,110 +0,0 @@
import process from 'node:process'
import { defineConfig, devices } from '@playwright/test'
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './e2e',
/* Maximum time one test can run for. */
timeout: 30 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 5000,
},
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.CI ? 'http://localhost:4173' : 'http://localhost:5173',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
/* Only on CI systems run the tests headless */
headless: !!process.env.CI,
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
},
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// },
// },
// {
// name: 'Mobile Safari',
// use: {
// ...devices['iPhone 12'],
// },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: {
// channel: 'msedge',
// },
// },
// {
// name: 'Google Chrome',
// use: {
// channel: 'chrome',
// },
// },
],
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
// outputDir: 'test-results/',
/* Run your local dev server before starting the tests */
webServer: {
/**
* Use the dev server by default for faster feedback loop.
* Use the preview server on CI for more realistic testing.
* Playwright will re-use the local server if there is already a dev-server running.
*/
command: process.env.CI ? 'npm run preview' : 'npm run dev',
port: process.env.CI ? 4173 : 5173,
reuseExistingServer: !process.env.CI,
},
})

3119
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,2 +1,3 @@
onlyBuiltDependencies:
- esbuild
- vue-demi

BIN
public/icon128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

BIN
public/icon48.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@@ -1,10 +1,15 @@
{
"manifest_version": 3,
"name": "gestime.aphp.fr exporter",
"version": "1.0.0",
"description": "TBD",
"name": "APHP Gestime Exporter",
"version": "0.1.0",
"description": "Exportez votre planning de travail Gestime vers un fichier calendrier ICS",
"action": {
"default_popup": "index.html"
"default_popup": "index.html",
"default_popup_width": 450
},
"icons": {
"48": "icon48.png",
"128": "icon128.png"
},
"permissions": ["activeTab", "scripting"],
"host_permissions": ["http://gestime.aphp.fr/*"]

View File

@@ -1,104 +1,113 @@
<script setup lang="ts">
import { extractData } from "@/utils/data";
import { ref } from "vue";
import { generateIcsCalendar } from "ts-ics";
import { extractData } from "@/utils/data";
import { isPlanningUrl } from "@/utils/url";
import { onMounted } from "vue";
const error = ref<string | null>(null);
const onPlanningPage = ref(false);
onMounted(async () => (onPlanningPage.value = await isPlanningUrl()));
const downloadCalendar = async () => {
const calendar = await extractData();
if (!calendar) {
// TODO: report error
return;
}
error.value = null;
await new Promise((resolve) =>
setTimeout(resolve, 1000 + Math.random() * 500),
);
let downloadUrl: string | null = null;
try {
// extract data and convert to ics
const calendar = await extractData();
const icsContent = generateIcsCalendar(calendar.data);
const blob = new Blob([icsContent], { type: "text/calendar;charset=utf-8" });
const url = URL.createObjectURL(blob);
try {
// create blob from ics content then download
const blob = new Blob([icsContent], {
type: "text/calendar;charset=utf-8",
});
downloadUrl = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.href = downloadUrl;
link.download = calendar.name;
link.click();
} catch (err: unknown) {
error.value = err instanceof Error ? err.message : String(err);
} finally {
URL.revokeObjectURL(url);
if (downloadUrl) URL.revokeObjectURL(downloadUrl);
}
};
</script>
<template>
<div class="app">
<h1>Gestime APHP Export</h1>
<UApp>
<UCard class="w-[450px] rounded-none">
<template #header>
<div class="flex items-center justify-between">
<h1 class="text-xl font-bold text-gray-900 dark:text-white">
APHP Gestime Exporter
</h1>
<div class="query-section">
<button @click="downloadCalendar">Download calendar</button>
<div class="flex items-center gap-2">
<UButton
icon="i-lucide-github"
to="https://github.com/pihkaal/aphp-gestime-exporter"
target="_blank"
color="neutral"
variant="ghost"
size="md"
/>
<UColorModeButton size="md" />
</div>
</div>
</template>
<style scoped>
.app {
padding: 16px;
min-width: 400px;
max-width: 600px;
}
<div class="space-y-4">
<div v-if="onPlanningPage" class="space-y-2">
<UButton
loading-auto
label="Télécharger le planning"
icon="i-lucide-download"
size="lg"
block
color="secondary"
variant="subtle"
@click="downloadCalendar"
/>
<UAlert
v-if="error"
color="error"
icon="i-lucide-circle-x"
:title="error"
/>
</div>
h1 {
font-size: 20px;
margin-bottom: 16px;
}
<UButton
v-else
label="Aller à mon planning"
icon="i-lucide-calendar"
size="lg"
block
color="secondary"
variant="subtle"
to="https://gestime.aphp.fr/planning/agent"
target="_blank"
/>
.query-section {
margin-bottom: 24px;
}
button {
background-color: #4caf50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
margin-right: 8px;
}
button:hover:not(:disabled) {
background-color: #45a049;
}
button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
.url-info {
margin-top: 12px;
padding: 8px;
background-color: #f0f0f0;
border-radius: 4px;
font-size: 12px;
word-break: break-all;
}
.result {
margin-top: 12px;
padding: 12px;
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 4px;
max-height: 300px;
overflow-y: auto;
}
.result pre {
margin: 0;
font-size: 12px;
white-space: pre-wrap;
word-break: break-word;
}
hr {
margin: 24px 0;
border: none;
border-top: 1px solid #ddd;
}
</style>
<UButton
label="Importer dans Google Calendar"
icon="i-lucide-external-link"
size="lg"
block
color="secondary"
variant="subtle"
to="https://calendar.google.com/calendar/u/0/r/settings/export"
target="_blank"
/>
</div>
</UCard>
</UApp>
</template>

View File

@@ -1,11 +0,0 @@
import { describe, it, expect } from "vitest";
import { mount } from "@vue/test-utils";
import App from "../App.vue";
describe("App", () => {
it("mounts renders properly", () => {
const wrapper = mount(App);
expect(wrapper.text()).toContain("You did it!");
});
});

2
src/assets/main.css Normal file
View File

@@ -0,0 +1,2 @@
@import "tailwindcss";
@import "@nuxt/ui";

View File

@@ -1,9 +1,11 @@
import "./assets/main.css";
import { createApp } from "vue";
import { createPinia } from "pinia";
import ui from "@nuxt/ui/vue-plugin";
import App from "./App.vue";
const app = createApp(App);
app.use(createPinia());
app.use(ui);
app.mount("#app");

View File

@@ -1,4 +1,5 @@
import type { IcsCalendar, IcsEvent } from "ts-ics";
import { isPlanningUrl } from "./url";
type WorkEvent = {
day: number;
@@ -12,7 +13,7 @@ const makeIcsEvent = (
month: number;
} & WorkEvent,
): IcsEvent => ({
uid: `${data.year}-${data.month}-${data.day}-work@gestime-aphp-export`,
uid: `${data.year}-${data.month}-${data.day}-work@aphp-gestime-exporter`,
summary: "Travail",
stamp: { date: new Date() },
start: {
@@ -47,31 +48,16 @@ const makeIcsCalendar = (events: IcsEvent[]): IcsCalendar => ({
events,
});
export async function extractData(): Promise<{
name: string;
data: IcsCalendar;
} | null> {
try {
const [tab] = await chrome.tabs.query({
active: true,
currentWindow: true,
});
if (!tab?.id) {
console.error("No active tab found");
return null;
}
const dataExtractor = () => {
// extract year and month
const monthSelect = document.getElementById(
"select-pagemois",
) as HTMLSelectElement;
const yearSelect = document.getElementById(
"select-pagean",
) as HTMLSelectElement;
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: () => {
// extract events
const trs = document.querySelectorAll("#clearfix-individuel table tr");
const events: WorkEvent[] = [];
@@ -102,21 +88,43 @@ export async function extractData(): Promise<{
});
}
return events;
},
return {
month: parseInt(monthSelect.value),
year: parseInt(yearSelect.value),
events,
};
};
export async function extractData(): Promise<{
name: string;
data: IcsCalendar;
}> {
const [tab] = await chrome.tabs.query({
active: true,
currentWindow: true,
});
if (!eventsQuery?.result) return null;
if (!tab?.id || !(await isPlanningUrl())) {
throw new Error("URL incorrecte");
}
try {
const [query] = await chrome.scripting.executeScript({
target: { tabId: tab.id },
func: dataExtractor,
});
if (!query?.result) throw undefined;
const { year, month, events } = query.result;
return {
name: `gestime-${urlMatch[1]}-${urlMatch[2]}.ics`,
name: `gestime-${year}-${month}.ics`,
data: makeIcsCalendar(
eventsQuery.result.map((event) =>
makeIcsEvent({ year, month, ...event }),
),
events.map((event) => makeIcsEvent({ year, month, ...event })),
),
};
} 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`",
);
}
}

10
src/utils/url.ts Normal file
View File

@@ -0,0 +1,10 @@
export const isPlanningUrl = async () => {
const [tab] = await chrome.tabs.query({
active: true,
currentWindow: true,
});
return (
tab?.url !== undefined &&
tab.url.startsWith("https://gestime.aphp.fr/planning/agent")
);
};

View File

@@ -1,7 +1,13 @@
{
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"include": [
"env.d.ts",
"src/**/*",
"src/**/*.vue",
"auto-imports.d.ts",
"components.d.ts"
],
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",

View File

@@ -6,9 +6,6 @@
},
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.vitest.json"
}
]
}

View File

@@ -1,17 +1,16 @@
{
"extends": "@tsconfig/node22/tsconfig.json",
"include": [
"vite.config.*",
"vitest.config.*",
"playwright.config.*",
"eslint.config.*"
],
"include": ["vite.config.*", "eslint.config.*"],
"compilerOptions": {
"noEmit": true,
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": ["node"]
"types": ["node"],
"paths": {
"#build/ui": ["./node_modules/.nuxt-ui/ui"]
}
}
}

View File

@@ -1,11 +0,0 @@
{
"extends": "./tsconfig.app.json",
"include": ["src/**/__tests__/*", "env.d.ts"],
"exclude": [],
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
"lib": [],
"types": ["node", "jsdom"]
}
}

View File

@@ -3,9 +3,10 @@ import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueDevTools from "vite-plugin-vue-devtools";
import ui from "@nuxt/ui/vite";
export default defineConfig({
plugins: [vue(), vueDevTools()],
plugins: [vue(), vueDevTools(), ui()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),

View File

@@ -1,14 +0,0 @@
import { fileURLToPath } from 'node:url'
import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
import viteConfig from './vite.config'
export default mergeConfig(
viteConfig,
defineConfig({
test: {
environment: 'jsdom',
exclude: [...configDefaults.exclude, 'e2e/**'],
root: fileURLToPath(new URL('./', import.meta.url)),
},
}),
)