Compare commits
10 Commits
1b06b9d323
...
0.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
900c6a6bdc | ||
|
|
1777382349 | ||
|
|
5c47d20a6e | ||
|
|
591691fb9b | ||
|
|
c89fbf085b | ||
|
|
5000a83159 | ||
|
|
41e91b6731 | ||
|
|
d6850fb2cb | ||
|
|
eb08d76bf2 | ||
|
|
d2c8591ddb |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
|
auto-imports.d.ts
|
||||||
|
components.d.ts
|
||||||
|
*.zip
|
||||||
|
|
||||||
# Logs
|
# Logs
|
||||||
logs
|
logs
|
||||||
*.log
|
*.log
|
||||||
|
|||||||
24
README.md
24
README.md
@@ -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)
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "@tsconfig/node22/tsconfig.json",
|
|
||||||
"include": ["./**/*"]
|
|
||||||
}
|
|
||||||
@@ -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!');
|
|
||||||
})
|
|
||||||
@@ -1,31 +1,23 @@
|
|||||||
import { globalIgnores } from 'eslint/config'
|
import { globalIgnores } from "eslint/config";
|
||||||
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
import {
|
||||||
import pluginVue from 'eslint-plugin-vue'
|
defineConfigWithVueTs,
|
||||||
import pluginVitest from '@vitest/eslint-plugin'
|
vueTsConfigs,
|
||||||
import pluginPlaywright from 'eslint-plugin-playwright'
|
} from "@vue/eslint-config-typescript";
|
||||||
import pluginOxlint from 'eslint-plugin-oxlint'
|
import pluginVue from "eslint-plugin-vue";
|
||||||
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
|
import pluginOxlint from "eslint-plugin-oxlint";
|
||||||
|
import skipFormatting from "@vue/eslint-config-prettier/skip-formatting";
|
||||||
|
|
||||||
export default defineConfigWithVueTs(
|
export default defineConfigWithVueTs(
|
||||||
{
|
{
|
||||||
name: 'app/files-to-lint',
|
name: "app/files-to-lint",
|
||||||
files: ['**/*.{ts,mts,tsx,vue}'],
|
files: ["**/*.{ts,mts,tsx,vue}"],
|
||||||
},
|
},
|
||||||
|
|
||||||
globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
globalIgnores(["**/dist/**", "**/dist-ssr/**"]),
|
||||||
|
|
||||||
pluginVue.configs['flat/essential'],
|
pluginVue.configs["flat/essential"],
|
||||||
vueTsConfigs.recommended,
|
vueTsConfigs.recommended,
|
||||||
|
|
||||||
{
|
...pluginOxlint.configs["flat/recommended"],
|
||||||
...pluginVitest.configs.recommended,
|
|
||||||
files: ['src/**/__tests__/*'],
|
|
||||||
},
|
|
||||||
|
|
||||||
{
|
|
||||||
...pluginPlaywright.configs['flat/recommended'],
|
|
||||||
files: ['e2e/**/*.{test,spec}.{js,ts,jsx,tsx}'],
|
|
||||||
},
|
|
||||||
...pluginOxlint.configs['flat/recommended'],
|
|
||||||
skipFormatting,
|
skipFormatting,
|
||||||
)
|
);
|
||||||
|
|||||||
14
index.html
14
index.html
@@ -1,13 +1,13 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="">
|
<html lang="fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Vite App</title>
|
<title>APHP Gestime Exporter</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app" class="isolate"></div>
|
||||||
<script type="module" src="/src/main.ts"></script>
|
<script type="module" src="/src/main.ts"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
63
package.json
63
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gestime-aphp-export",
|
"name": "aphp-gestime-exporter",
|
||||||
"version": "0.0.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -8,49 +8,44 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "run-s type-check build-only copy:manifest",
|
"build": "run-s type-check build-only copy:public",
|
||||||
"copy:manifest": "cp public/manifest.json dist/",
|
"copy:public": "cp public/* dist/",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"test:unit": "vitest",
|
|
||||||
"test:e2e": "playwright test",
|
|
||||||
"build-only": "vite build",
|
"build-only": "vite build",
|
||||||
"type-check": "vue-tsc --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:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
|
||||||
"lint:eslint": "eslint . --fix --cache",
|
"lint:eslint": "eslint . --fix --cache",
|
||||||
"lint": "run-s lint:*",
|
"lint": "run-s lint:*",
|
||||||
"format": "prettier --write src/"
|
"format": "prettier --write src/"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"pinia": "^3.0.3",
|
"@nuxt/ui": "4.1.0",
|
||||||
"ts-ics": "^2.4.0",
|
"@unhead/vue": "2.0.19",
|
||||||
"vue": "^3.5.22"
|
"tailwindcss": "4.1.16",
|
||||||
|
"ts-ics": "2.4.0",
|
||||||
|
"vue": "3.5.22",
|
||||||
|
"vue-router": "4.6.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@playwright/test": "^1.56.1",
|
"@prettier/plugin-oxc": "0.0.4",
|
||||||
"@prettier/plugin-oxc": "^0.0.4",
|
"@tsconfig/node22": "22.0.2",
|
||||||
"@tsconfig/node22": "^22.0.2",
|
"@types/chrome": "0.1.27",
|
||||||
"@types/chrome": "^0.1.27",
|
"@types/node": "22.18.11",
|
||||||
"@types/jsdom": "^27.0.0",
|
"@vitejs/plugin-vue": "6.0.1",
|
||||||
"@types/node": "^22.18.11",
|
"@vue/eslint-config-prettier": "10.2.0",
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vue/eslint-config-typescript": "14.6.0",
|
||||||
"@vitest/eslint-plugin": "^1.3.23",
|
"@vue/tsconfig": "0.8.1",
|
||||||
"@vue/eslint-config-prettier": "^10.2.0",
|
"eslint": "9.37.0",
|
||||||
"@vue/eslint-config-typescript": "^14.6.0",
|
"eslint-plugin-oxlint": "1.23.0",
|
||||||
"@vue/test-utils": "^2.4.6",
|
"eslint-plugin-vue": "10.5.0",
|
||||||
"@vue/tsconfig": "^0.8.1",
|
"jiti": "2.6.1",
|
||||||
"eslint": "^9.37.0",
|
"npm-run-all2": "8.0.4",
|
||||||
"eslint-plugin-oxlint": "~1.23.0",
|
"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": "3.6.2",
|
"prettier": "3.6.2",
|
||||||
"typescript": "~5.9.0",
|
"typescript": "5.9.0",
|
||||||
"vite": "^7.1.11",
|
"vite": "7.1.11",
|
||||||
"vite-plugin-vue-devtools": "^8.0.3",
|
"vite-plugin-vue-devtools": "8.0.3",
|
||||||
"vitest": "^3.2.4",
|
"vue-tsc": "3.1.1"
|
||||||
"vue-tsc": "^3.1.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
3119
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,3 @@
|
|||||||
onlyBuiltDependencies:
|
onlyBuiltDependencies:
|
||||||
- esbuild
|
- esbuild
|
||||||
|
- vue-demi
|
||||||
|
|||||||
BIN
public/icon128.png
Normal file
BIN
public/icon128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
BIN
public/icon48.png
Normal file
BIN
public/icon48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.3 KiB |
@@ -1,10 +1,15 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "gestime.aphp.fr exporter",
|
"name": "APHP Gestime Exporter",
|
||||||
"version": "1.0.0",
|
"version": "0.1.0",
|
||||||
"description": "TBD",
|
"description": "Exportez votre planning de travail Gestime vers un fichier calendrier ICS",
|
||||||
"action": {
|
"action": {
|
||||||
"default_popup": "index.html"
|
"default_popup": "index.html",
|
||||||
|
"default_popup_width": 450
|
||||||
|
},
|
||||||
|
"icons": {
|
||||||
|
"48": "icon48.png",
|
||||||
|
"128": "icon128.png"
|
||||||
},
|
},
|
||||||
"permissions": ["activeTab", "scripting"],
|
"permissions": ["activeTab", "scripting"],
|
||||||
"host_permissions": ["http://gestime.aphp.fr/*"]
|
"host_permissions": ["http://gestime.aphp.fr/*"]
|
||||||
|
|||||||
171
src/App.vue
171
src/App.vue
@@ -1,104 +1,113 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { extractData } from "@/utils/data";
|
import { ref } from "vue";
|
||||||
import { generateIcsCalendar } from "ts-ics";
|
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 downloadCalendar = async () => {
|
||||||
const calendar = await extractData();
|
error.value = null;
|
||||||
if (!calendar) {
|
|
||||||
// TODO: report error
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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 icsContent = generateIcsCalendar(calendar.data);
|
||||||
|
|
||||||
const blob = new Blob([icsContent], { type: "text/calendar;charset=utf-8" });
|
// create blob from ics content then download
|
||||||
const url = URL.createObjectURL(blob);
|
const blob = new Blob([icsContent], {
|
||||||
try {
|
type: "text/calendar;charset=utf-8",
|
||||||
|
});
|
||||||
|
downloadUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.href = url;
|
link.href = downloadUrl;
|
||||||
link.download = calendar.name;
|
link.download = calendar.name;
|
||||||
link.click();
|
link.click();
|
||||||
|
} catch (err: unknown) {
|
||||||
|
error.value = err instanceof Error ? err.message : String(err);
|
||||||
} finally {
|
} finally {
|
||||||
URL.revokeObjectURL(url);
|
if (downloadUrl) URL.revokeObjectURL(downloadUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="app">
|
<UApp>
|
||||||
<h1>Gestime APHP Export</h1>
|
<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">
|
<div class="flex items-center gap-2">
|
||||||
<button @click="downloadCalendar">Download calendar</button>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<div class="space-y-4">
|
||||||
.app {
|
<div v-if="onPlanningPage" class="space-y-2">
|
||||||
padding: 16px;
|
<UButton
|
||||||
min-width: 400px;
|
loading-auto
|
||||||
max-width: 600px;
|
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 {
|
<UButton
|
||||||
font-size: 20px;
|
v-else
|
||||||
margin-bottom: 16px;
|
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 {
|
<UButton
|
||||||
margin-bottom: 24px;
|
label="Importer dans Google Calendar"
|
||||||
}
|
icon="i-lucide-external-link"
|
||||||
|
size="lg"
|
||||||
button {
|
block
|
||||||
background-color: #4caf50;
|
color="secondary"
|
||||||
color: white;
|
variant="subtle"
|
||||||
padding: 10px 20px;
|
to="https://calendar.google.com/calendar/u/0/r/settings/export"
|
||||||
border: none;
|
target="_blank"
|
||||||
border-radius: 4px;
|
/>
|
||||||
cursor: pointer;
|
</div>
|
||||||
font-size: 14px;
|
</UCard>
|
||||||
margin-right: 8px;
|
</UApp>
|
||||||
}
|
</template>
|
||||||
|
|
||||||
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>
|
|
||||||
|
|||||||
@@ -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
2
src/assets/main.css
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
|
@import "@nuxt/ui";
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
import "./assets/main.css";
|
||||||
|
|
||||||
import { createApp } from "vue";
|
import { createApp } from "vue";
|
||||||
import { createPinia } from "pinia";
|
import ui from "@nuxt/ui/vue-plugin";
|
||||||
import App from "./App.vue";
|
import App from "./App.vue";
|
||||||
|
|
||||||
const app = createApp(App);
|
const app = createApp(App);
|
||||||
|
|
||||||
app.use(createPinia());
|
app.use(ui);
|
||||||
|
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import type { IcsCalendar, IcsEvent } from "ts-ics";
|
import type { IcsCalendar, IcsEvent } from "ts-ics";
|
||||||
|
import { isPlanningUrl } from "./url";
|
||||||
|
|
||||||
type WorkEvent = {
|
type WorkEvent = {
|
||||||
day: number;
|
day: number;
|
||||||
@@ -12,7 +13,7 @@ const makeIcsEvent = (
|
|||||||
month: number;
|
month: number;
|
||||||
} & WorkEvent,
|
} & WorkEvent,
|
||||||
): IcsEvent => ({
|
): 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",
|
summary: "Travail",
|
||||||
stamp: { date: new Date() },
|
stamp: { date: new Date() },
|
||||||
start: {
|
start: {
|
||||||
@@ -47,31 +48,16 @@ const makeIcsCalendar = (events: IcsEvent[]): IcsCalendar => ({
|
|||||||
events,
|
events,
|
||||||
});
|
});
|
||||||
|
|
||||||
export async function extractData(): Promise<{
|
const dataExtractor = () => {
|
||||||
name: string;
|
// extract year and month
|
||||||
data: IcsCalendar;
|
const monthSelect = document.getElementById(
|
||||||
} | null> {
|
"select-pagemois",
|
||||||
try {
|
) as HTMLSelectElement;
|
||||||
const [tab] = await chrome.tabs.query({
|
const yearSelect = document.getElementById(
|
||||||
active: true,
|
"select-pagean",
|
||||||
currentWindow: true,
|
) as HTMLSelectElement;
|
||||||
});
|
|
||||||
if (!tab?.id) {
|
|
||||||
console.error("No active tab found");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const urlMatch = tab.url?.match(/\/(\d{2})-(\d{4})$/);
|
// extract events
|
||||||
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: () => {
|
|
||||||
const trs = document.querySelectorAll("#clearfix-individuel table tr");
|
const trs = document.querySelectorAll("#clearfix-individuel table tr");
|
||||||
|
|
||||||
const events: WorkEvent[] = [];
|
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 {
|
return {
|
||||||
name: `gestime-${urlMatch[1]}-${urlMatch[2]}.ics`,
|
name: `gestime-${year}-${month}.ics`,
|
||||||
data: makeIcsCalendar(
|
data: makeIcsCalendar(
|
||||||
eventsQuery.result.map((event) =>
|
events.map((event) => makeIcsEvent({ year, month, ...event })),
|
||||||
makeIcsEvent({ year, month, ...event }),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch {
|
||||||
console.error("Error getting elements data:", error);
|
throw new Error(
|
||||||
return null;
|
"Impossible d'extraires les données, contactez `hello@pihkaal.me`",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/utils/url.ts
Normal file
10
src/utils/url.ts
Normal 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")
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,7 +1,13 @@
|
|||||||
{
|
{
|
||||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
"include": [
|
||||||
"exclude": ["src/**/__tests__/*"],
|
"env.d.ts",
|
||||||
|
"src/**/*",
|
||||||
|
"src/**/*.vue",
|
||||||
|
"auto-imports.d.ts",
|
||||||
|
"components.d.ts"
|
||||||
|
],
|
||||||
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||||
|
|
||||||
|
|||||||
@@ -6,9 +6,6 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "./tsconfig.app.json"
|
"path": "./tsconfig.app.json"
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.vitest.json"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
{
|
{
|
||||||
"extends": "@tsconfig/node22/tsconfig.json",
|
"extends": "@tsconfig/node22/tsconfig.json",
|
||||||
"include": [
|
"include": ["vite.config.*", "eslint.config.*"],
|
||||||
"vite.config.*",
|
|
||||||
"vitest.config.*",
|
|
||||||
"playwright.config.*",
|
|
||||||
"eslint.config.*"
|
|
||||||
],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||||
|
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
"moduleResolution": "Bundler",
|
"moduleResolution": "Bundler",
|
||||||
"types": ["node"]
|
"types": ["node"],
|
||||||
|
|
||||||
|
"paths": {
|
||||||
|
"#build/ui": ["./node_modules/.nuxt-ui/ui"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,9 +3,10 @@ import { fileURLToPath, URL } from "node:url";
|
|||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import vueDevTools from "vite-plugin-vue-devtools";
|
import vueDevTools from "vite-plugin-vue-devtools";
|
||||||
|
import ui from "@nuxt/ui/vite";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [vue(), vueDevTools()],
|
plugins: [vue(), vueDevTools(), ui()],
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||||
|
|||||||
@@ -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)),
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user