Initial commit
This commit is contained in:
23
svar-gantt-app/.gitignore
vendored
Normal file
23
svar-gantt-app/.gitignore
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
node_modules
|
||||||
|
|
||||||
|
# Output
|
||||||
|
.output
|
||||||
|
.vercel
|
||||||
|
.netlify
|
||||||
|
.wrangler
|
||||||
|
/.svelte-kit
|
||||||
|
/build
|
||||||
|
|
||||||
|
# OS
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# Env
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
!.env.test
|
||||||
|
|
||||||
|
# Vite
|
||||||
|
vite.config.js.timestamp-*
|
||||||
|
vite.config.ts.timestamp-*
|
||||||
1
svar-gantt-app/.npmrc
Normal file
1
svar-gantt-app/.npmrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
engine-strict=true
|
||||||
22
svar-gantt-app/Dockerfile
Normal file
22
svar-gantt-app/Dockerfile
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Étape 1: Build
|
||||||
|
FROM node:20 AS build
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Étape 2: Runtime (production)
|
||||||
|
FROM node:20
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY --from=build /app ./
|
||||||
|
RUN npm install --omit=dev
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
CMD ["node", "build"]
|
||||||
38
svar-gantt-app/README.md
Normal file
38
svar-gantt-app/README.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# sv
|
||||||
|
|
||||||
|
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
||||||
|
|
||||||
|
## Creating a project
|
||||||
|
|
||||||
|
If you're seeing this, you've probably already done this step. Congrats!
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# create a new project in the current directory
|
||||||
|
npx sv create
|
||||||
|
|
||||||
|
# create a new project in my-app
|
||||||
|
npx sv create my-app
|
||||||
|
```
|
||||||
|
|
||||||
|
## Developing
|
||||||
|
|
||||||
|
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
|
||||||
|
# or start the server and open the app in a new browser tab
|
||||||
|
npm run dev -- --open
|
||||||
|
```
|
||||||
|
|
||||||
|
## Building
|
||||||
|
|
||||||
|
To create a production version of your app:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
You can preview the production build with `npm run preview`.
|
||||||
|
|
||||||
|
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
||||||
BIN
svar-gantt-app/data.db
Normal file
BIN
svar-gantt-app/data.db
Normal file
Binary file not shown.
10
svar-gantt-app/docker-compose.yml
Normal file
10
svar-gantt-app/docker-compose.yml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
version: '3.8'
|
||||||
|
|
||||||
|
services:
|
||||||
|
gantt-app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "5173:3000"
|
||||||
|
volumes:
|
||||||
|
- ./gantt.db:/app/gantt.db # persistance locale du fichier SQLite
|
||||||
|
restart: unless-stopped
|
||||||
BIN
svar-gantt-app/gantt.db
Normal file
BIN
svar-gantt-app/gantt.db
Normal file
Binary file not shown.
2361
svar-gantt-app/package-lock.json
generated
Normal file
2361
svar-gantt-app/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
35
svar-gantt-app/package.json
Normal file
35
svar-gantt-app/package.json
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "svar-gantt-app",
|
||||||
|
"private": true,
|
||||||
|
"version": "0.0.1",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite dev",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"prepare": "svelte-kit sync || echo ''",
|
||||||
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
|
"init-db": "node scripts/init-db.js"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@sveltejs/adapter-auto": "^6.0.0",
|
||||||
|
"@sveltejs/kit": "^2.22.0",
|
||||||
|
"@sveltejs/vite-plugin-svelte": "^6.0.0",
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
|
"@types/node": "^24.0.13",
|
||||||
|
"@types/papaparse": "^5.3.16",
|
||||||
|
"svelte": "^5.0.0",
|
||||||
|
"svelte-check": "^4.0.0",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"typescript": "^5.8.3",
|
||||||
|
"vite": "^7.0.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"better-sqlite3": "^12.2.0",
|
||||||
|
"kysely": "^0.28.2",
|
||||||
|
"papaparse": "^5.5.3",
|
||||||
|
"wx-gantt": "github:svar-widgets/gantt",
|
||||||
|
"wx-svelte-gantt": "^2.1.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
35
svar-gantt-app/scripts/init-db.ts
Normal file
35
svar-gantt-app/scripts/init-db.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// scripts/init-db.ts
|
||||||
|
import Database from 'better-sqlite3';
|
||||||
|
import { mkdirSync, existsSync } from 'fs';
|
||||||
|
|
||||||
|
if (!existsSync('data')) {
|
||||||
|
mkdirSync('data');
|
||||||
|
}
|
||||||
|
|
||||||
|
const db = new Database('data.db');
|
||||||
|
|
||||||
|
db.exec(`
|
||||||
|
DROP TABLE IF EXISTS tasks;
|
||||||
|
DROP TABLE IF EXISTS links;
|
||||||
|
|
||||||
|
CREATE TABLE tasks (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
text TEXT NOT NULL,
|
||||||
|
start TEXT NOT NULL,
|
||||||
|
end TEXT NOT NULL,
|
||||||
|
duration INTEGER,
|
||||||
|
progress INTEGER,
|
||||||
|
type TEXT,
|
||||||
|
parent INTEGER,
|
||||||
|
lazy BOOLEAN DEFAULT 0 -- ✅ Ajout ici
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE links (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
source INTEGER,
|
||||||
|
target INTEGER,
|
||||||
|
type TEXT
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
|
||||||
|
console.log('✅ Base de données initialisée avec succès.');
|
||||||
13
svar-gantt-app/src/app.d.ts
vendored
Normal file
13
svar-gantt-app/src/app.d.ts
vendored
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||||
|
// for information about these interfaces
|
||||||
|
declare global {
|
||||||
|
namespace App {
|
||||||
|
// interface Error {}
|
||||||
|
// interface Locals {}
|
||||||
|
// interface PageData {}
|
||||||
|
// interface PageState {}
|
||||||
|
// interface Platform {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export {};
|
||||||
12
svar-gantt-app/src/app.html
Normal file
12
svar-gantt-app/src/app.html
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<link rel="icon" href="%sveltekit.assets%/favicon.svg" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
%sveltekit.head%
|
||||||
|
</head>
|
||||||
|
<body data-sveltekit-preload-data="hover">
|
||||||
|
<div style="display: contents">%sveltekit.body%</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
32
svar-gantt-app/src/lib/GanttClientOnly.svelte
Normal file
32
svar-gantt-app/src/lib/GanttClientOnly.svelte
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<script>
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import { Gantt, Willow } from "wx-svelte-gantt";
|
||||||
|
|
||||||
|
export let tasks = [];
|
||||||
|
export let links = [];
|
||||||
|
export let scales = [];
|
||||||
|
|
||||||
|
let mounted = false;
|
||||||
|
onMount(() => (mounted = true));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if mounted}
|
||||||
|
<div class="gantt-wrapper">
|
||||||
|
<Willow>
|
||||||
|
<Gantt {tasks} {links} {scales} />
|
||||||
|
</Willow>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<p>Chargement du Gantt…</p>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.gantt-wrapper {
|
||||||
|
background: white;
|
||||||
|
padding: 1rem;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||||
|
min-height: 600px;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
4
svar-gantt-app/src/lib/db.ts
Normal file
4
svar-gantt-app/src/lib/db.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import Database from 'better-sqlite3';
|
||||||
|
|
||||||
|
// Ouvre la base de données. Le fichier doit être à la racine du projet.
|
||||||
|
export const db = new Database('gantt.db');
|
||||||
8
svar-gantt-app/src/lib/db/database.js
Normal file
8
svar-gantt-app/src/lib/db/database.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Kysely, SqliteDialect } from 'kysely'
|
||||||
|
import Database from 'better-sqlite3'
|
||||||
|
|
||||||
|
export const db = new Kysely({
|
||||||
|
dialect: new SqliteDialect({
|
||||||
|
database: new Database('data.db')
|
||||||
|
})
|
||||||
|
})
|
||||||
10
svar-gantt-app/src/lib/db/schema.js
Normal file
10
svar-gantt-app/src/lib/db/schema.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export const schema = {
|
||||||
|
tasks: {
|
||||||
|
id: 'string',
|
||||||
|
name: 'string',
|
||||||
|
estimation: 'number',
|
||||||
|
sprint: 'string',
|
||||||
|
status: 'string',
|
||||||
|
remaining: 'number'
|
||||||
|
}
|
||||||
|
}
|
||||||
7
svar-gantt-app/src/lib/server/db.ts
Normal file
7
svar-gantt-app/src/lib/server/db.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import Database from 'better-sqlite3';
|
||||||
|
import { resolve } from 'path';
|
||||||
|
|
||||||
|
// 📁 chemin absolu vers la BDD SQLite
|
||||||
|
const db = new Database(resolve('data.db'));
|
||||||
|
|
||||||
|
export default db;
|
||||||
108
svar-gantt-app/src/routes/+layout.svelte
Normal file
108
svar-gantt-app/src/routes/+layout.svelte
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<script>
|
||||||
|
import { page } from '$app/stores';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
|
$: current = $page.url.pathname;
|
||||||
|
|
||||||
|
function resetData() {
|
||||||
|
localStorage.removeItem("gantt-tasks");
|
||||||
|
localStorage.removeItem("gantt-links");
|
||||||
|
|
||||||
|
// Recharge la page proprement après un petit délai
|
||||||
|
setTimeout(() => {
|
||||||
|
location.reload();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="app">
|
||||||
|
<aside class="sidebar">
|
||||||
|
<div class="menu-toggle">
|
||||||
|
☰
|
||||||
|
</div>
|
||||||
|
<h1>📊</h1>
|
||||||
|
<nav>
|
||||||
|
<a href="/" class:selected={current === "/"} title="Accueil">🏠</a>
|
||||||
|
<a href="/gantt" class:selected={current === "/gantt"} title="Gantt">📅</a>
|
||||||
|
<a href="/import" class:selected={current === "/import"} title="Importer">📂</a>
|
||||||
|
<a href="/config" class:selected={current === "/config"} title="Config">⚙️</a>
|
||||||
|
</nav>
|
||||||
|
<button class="reset-btn" on:click={resetData} title="Réinitialiser les données">
|
||||||
|
🔁
|
||||||
|
</button>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<main class="content">
|
||||||
|
<slot />
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.app {
|
||||||
|
display: flex;
|
||||||
|
min-height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
width: 60px;
|
||||||
|
background-color: #2d2d2d;
|
||||||
|
color: white;
|
||||||
|
padding: 10px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-toggle {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav {
|
||||||
|
flex-grow: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav a {
|
||||||
|
color: white;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
nav a.selected,
|
||||||
|
nav a:hover {
|
||||||
|
background-color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-btn {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
font-size: 1.3rem;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: auto;
|
||||||
|
padding: 6px;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.reset-btn:hover {
|
||||||
|
background-color: #444;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
flex-grow: 1;
|
||||||
|
padding: 2rem;
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
3
svar-gantt-app/src/routes/+page.svelte
Normal file
3
svar-gantt-app/src/routes/+page.svelte
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
<h1>Bienvenue 👋</h1>
|
||||||
|
<p>Utilisez le menu à gauche pour naviguer dans l'application.</p>
|
||||||
50
svar-gantt-app/src/routes/api/tasks/+server.ts
Normal file
50
svar-gantt-app/src/routes/api/tasks/+server.ts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import db from '$lib/server/db';
|
||||||
|
import { json } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const tasks = db.prepare('SELECT * FROM tasks').all();
|
||||||
|
const links = db.prepare('SELECT * FROM links').all();
|
||||||
|
return json({ tasks, links });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST({ request }) {
|
||||||
|
try {
|
||||||
|
const { tasks, links } = await request.json();
|
||||||
|
|
||||||
|
const insertTask = db.prepare(`
|
||||||
|
INSERT INTO tasks (id, text, start, end, duration, progress, type, parent, lazy)
|
||||||
|
VALUES (@id, @text, @start, @end, @duration, @progress, @type, @parent, @lazy)
|
||||||
|
`);
|
||||||
|
|
||||||
|
const insertLink = db.prepare(`
|
||||||
|
INSERT INTO links (id, source, target, type)
|
||||||
|
VALUES (@id, @source, @target, @type)
|
||||||
|
`);
|
||||||
|
|
||||||
|
const taskTx = db.transaction((all) => {
|
||||||
|
db.prepare('DELETE FROM tasks').run();
|
||||||
|
db.prepare('DELETE FROM links').run();
|
||||||
|
|
||||||
|
for (const task of all.tasks) {
|
||||||
|
insertTask.run({
|
||||||
|
...task,
|
||||||
|
start: typeof task.start === 'object' ? new Date(task.start).toISOString() : task.start,
|
||||||
|
end: typeof task.end === 'object' ? new Date(task.end).toISOString() : task.end,
|
||||||
|
lazy: task.lazy ? 1 : 0, // ⚠️ SQLite ne supporte pas le type boolean natif
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (const link of all.links) {
|
||||||
|
insertLink.run(link);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
taskTx({ tasks, links });
|
||||||
|
|
||||||
|
return json({ ok: true });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur POST /api/tasks:', error);
|
||||||
|
return new Response('Erreur interne', { status: 500 });
|
||||||
|
}
|
||||||
|
}
|
||||||
57
svar-gantt-app/src/routes/boilerplate/+page.svelte
Normal file
57
svar-gantt-app/src/routes/boilerplate/+page.svelte
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
<script>
|
||||||
|
import { Gantt, Willow } from "wx-svelte-gantt";
|
||||||
|
import "wx-svelte-gantt/theme/index.css";
|
||||||
|
|
||||||
|
const tasks = [
|
||||||
|
{
|
||||||
|
id: 20,
|
||||||
|
text: "New Task",
|
||||||
|
start: new Date(2024, 5, 11),
|
||||||
|
end: new Date(2024, 6, 12),
|
||||||
|
duration: 1,
|
||||||
|
progress: 2,
|
||||||
|
type: "task",
|
||||||
|
lazy: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 47,
|
||||||
|
text: "[1] Master project",
|
||||||
|
start: new Date(2024, 5, 12),
|
||||||
|
end: new Date(2024, 7, 12),
|
||||||
|
duration: 8,
|
||||||
|
progress: 0,
|
||||||
|
parent: 0,
|
||||||
|
type: "summary",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 22,
|
||||||
|
text: "Task",
|
||||||
|
start: new Date(2024, 7, 11),
|
||||||
|
end: new Date(2024, 8, 12),
|
||||||
|
duration: 8,
|
||||||
|
progress: 0,
|
||||||
|
parent: 47,
|
||||||
|
type: "task",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 21,
|
||||||
|
text: "New Task 2",
|
||||||
|
start: new Date(2024, 7, 10),
|
||||||
|
end: new Date(2024, 8, 12),
|
||||||
|
duration: 3,
|
||||||
|
progress: 0,
|
||||||
|
type: "task",
|
||||||
|
lazy: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const links = [{ id: 1, source: 20, target: 21, type: "e2e" }];
|
||||||
|
|
||||||
|
const scales = [
|
||||||
|
{ unit: "month", step: 1, format: "MMMM yyy" },
|
||||||
|
{ unit: "day", step: 1, format: "d" },
|
||||||
|
];
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Gantt {tasks} {links} {scales} theme={Willow} />
|
||||||
2
svar-gantt-app/src/routes/config/+page.svelte
Normal file
2
svar-gantt-app/src/routes/config/+page.svelte
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<h2>Configuration</h2>
|
||||||
|
<p>Page pour les paramètres futurs.</p>
|
||||||
26
svar-gantt-app/src/routes/gantt/+page.svelte
Normal file
26
svar-gantt-app/src/routes/gantt/+page.svelte
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
import { Gantt, Willow } from 'wx-svelte-gantt';
|
||||||
|
|
||||||
|
let tasks = [];
|
||||||
|
let links = [];
|
||||||
|
const scales = [
|
||||||
|
{ unit: 'month', step: 1, format: 'MMMM yyyy' },
|
||||||
|
{ unit: 'day', step: 1, format: 'd' }
|
||||||
|
];
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const res = await fetch('/api/tasks');
|
||||||
|
if (res.ok) {
|
||||||
|
const { tasks: loadedTasks, links: loadedLinks } = await res.json();
|
||||||
|
tasks = loadedTasks;
|
||||||
|
links = loadedLinks;
|
||||||
|
} else {
|
||||||
|
console.error('Erreur de chargement des données depuis la base.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Willow>
|
||||||
|
<Gantt {tasks} {links} {scales} />
|
||||||
|
</Willow>
|
||||||
63
svar-gantt-app/src/routes/import/+page.svelte
Normal file
63
svar-gantt-app/src/routes/import/+page.svelte
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
import Papa from 'papaparse';
|
||||||
|
|
||||||
|
let preview = '';
|
||||||
|
let importé = false;
|
||||||
|
|
||||||
|
async function handleFile(event: Event) {
|
||||||
|
const file = (event.target as HTMLInputElement).files?.[0];
|
||||||
|
if (!file) return;
|
||||||
|
|
||||||
|
const text = await file.text();
|
||||||
|
preview = text;
|
||||||
|
|
||||||
|
const parsed = Papa.parse(text, {
|
||||||
|
header: true,
|
||||||
|
skipEmptyLines: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const tasks = parsed.data.map((entry: any, index: number) => {
|
||||||
|
const today = new Date();
|
||||||
|
const start = new Date(today.getTime() + index * 86400000); // un jour de décalage par tâche
|
||||||
|
const end = new Date(start.getTime() + 86400000); // tâche dure 1 jour par défaut
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: index + 1,
|
||||||
|
text: entry['Nom Ticket'],
|
||||||
|
start: start.toISOString().split('T')[0], // ⬅️ Converti en string
|
||||||
|
end: end.toISOString().split('T')[0], // ⬅️ Converti en string
|
||||||
|
duration: Number(entry['Estimation (j)']) || 1,
|
||||||
|
progress: Number(entry['RAF']) || 0,
|
||||||
|
type: 'task',
|
||||||
|
parent: null,
|
||||||
|
lazy: false
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
const response = await fetch('/api/tasks', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ tasks, links: [] })
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
importé = true;
|
||||||
|
} else {
|
||||||
|
alert("Erreur lors de l'import.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function allerAuGantt() {
|
||||||
|
goto('/gantt');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h2>Importer un fichier CSV</h2>
|
||||||
|
<input type="file" accept=".csv" on:change={handleFile} />
|
||||||
|
|
||||||
|
{#if preview}
|
||||||
|
<h3>Prévisualisation</h3>
|
||||||
|
<pre>{preview}</pre>
|
||||||
|
<button on:click={allerAuGantt}>Voir le Gantt</button>
|
||||||
|
{/if}
|
||||||
8
svar-gantt-app/src/src/lib/db/database.js
Normal file
8
svar-gantt-app/src/src/lib/db/database.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { Kysely, SqliteDialect } from 'kysely'
|
||||||
|
import Database from 'better-sqlite3'
|
||||||
|
|
||||||
|
export const db = new Kysely({
|
||||||
|
dialect: new SqliteDialect({
|
||||||
|
database: new Database('data.db')
|
||||||
|
})
|
||||||
|
})
|
||||||
10
svar-gantt-app/src/src/lib/db/schema.js
Normal file
10
svar-gantt-app/src/src/lib/db/schema.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export const schema = {
|
||||||
|
tasks: {
|
||||||
|
id: 'string',
|
||||||
|
name: 'string',
|
||||||
|
estimation: 'number',
|
||||||
|
sprint: 'string',
|
||||||
|
status: 'string',
|
||||||
|
remaining: 'number'
|
||||||
|
}
|
||||||
|
}
|
||||||
36
svar-gantt-app/src/src/routes/api/tasks/+server.js
Normal file
36
svar-gantt-app/src/src/routes/api/tasks/+server.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import { db } from '$lib/db/database'
|
||||||
|
|
||||||
|
await db.schema
|
||||||
|
.createTable('tasks')
|
||||||
|
.ifNotExists()
|
||||||
|
.addColumn('id', 'text', col => col.primaryKey())
|
||||||
|
.addColumn('name', 'text')
|
||||||
|
.addColumn('estimation', 'integer')
|
||||||
|
.addColumn('sprint', 'text')
|
||||||
|
.addColumn('status', 'text')
|
||||||
|
.addColumn('remaining', 'integer')
|
||||||
|
.execute()
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const tasks = await db.selectFrom('tasks').selectAll().execute()
|
||||||
|
return new Response(JSON.stringify(tasks))
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function POST({ request }) {
|
||||||
|
const data = await request.json()
|
||||||
|
|
||||||
|
await db.deleteFrom('tasks').execute()
|
||||||
|
|
||||||
|
for (const task of data) {
|
||||||
|
await db.insertInto('tasks').values({
|
||||||
|
id: task.id,
|
||||||
|
name: task.name,
|
||||||
|
estimation: task.estimation,
|
||||||
|
sprint: task.sprint,
|
||||||
|
status: task.status,
|
||||||
|
remaining: task.remaining
|
||||||
|
}).execute()
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Response(JSON.stringify({ ok: true }))
|
||||||
|
}
|
||||||
1
svar-gantt-app/static/favicon.svg
Normal file
1
svar-gantt-app/static/favicon.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="107" height="128" viewBox="0 0 107 128"><title>svelte-logo</title><path d="M94.157 22.819c-10.4-14.885-30.94-19.297-45.792-9.835L22.282 29.608A29.92 29.92 0 0 0 8.764 49.65a31.5 31.5 0 0 0 3.108 20.231 30 30 0 0 0-4.477 11.183 31.9 31.9 0 0 0 5.448 24.116c10.402 14.887 30.942 19.297 45.791 9.835l26.083-16.624A29.92 29.92 0 0 0 98.235 78.35a31.53 31.53 0 0 0-3.105-20.232 30 30 0 0 0 4.474-11.182 31.88 31.88 0 0 0-5.447-24.116" style="fill:#ff3e00"/><path d="M45.817 106.582a20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.503 18 18 0 0 1 .624-2.435l.49-1.498 1.337.981a33.6 33.6 0 0 0 10.203 5.098l.97.294-.09.968a5.85 5.85 0 0 0 1.052 3.878 6.24 6.24 0 0 0 6.695 2.485 5.8 5.8 0 0 0 1.603-.704L69.27 76.28a5.43 5.43 0 0 0 2.45-3.631 5.8 5.8 0 0 0-.987-4.371 6.24 6.24 0 0 0-6.698-2.487 5.7 5.7 0 0 0-1.6.704l-9.953 6.345a19 19 0 0 1-5.296 2.326 20.72 20.72 0 0 1-22.237-8.243 19.17 19.17 0 0 1-3.277-14.502 17.99 17.99 0 0 1 8.13-12.052l26.081-16.623a19 19 0 0 1 5.3-2.329 20.72 20.72 0 0 1 22.237 8.243 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-.624 2.435l-.49 1.498-1.337-.98a33.6 33.6 0 0 0-10.203-5.1l-.97-.294.09-.968a5.86 5.86 0 0 0-1.052-3.878 6.24 6.24 0 0 0-6.696-2.485 5.8 5.8 0 0 0-1.602.704L37.73 51.72a5.42 5.42 0 0 0-2.449 3.63 5.79 5.79 0 0 0 .986 4.372 6.24 6.24 0 0 0 6.698 2.486 5.8 5.8 0 0 0 1.602-.704l9.952-6.342a19 19 0 0 1 5.295-2.328 20.72 20.72 0 0 1 22.237 8.242 19.17 19.17 0 0 1 3.277 14.503 18 18 0 0 1-8.13 12.053l-26.081 16.622a19 19 0 0 1-5.3 2.328" style="fill:#fff"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.5 KiB |
18
svar-gantt-app/svelte.config.js
Normal file
18
svar-gantt-app/svelte.config.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import adapter from '@sveltejs/adapter-auto';
|
||||||
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
|
||||||
|
|
||||||
|
/** @type {import('@sveltejs/kit').Config} */
|
||||||
|
const config = {
|
||||||
|
// Consult https://svelte.dev/docs/kit/integrations
|
||||||
|
// for more information about preprocessors
|
||||||
|
preprocess: vitePreprocess(),
|
||||||
|
|
||||||
|
kit: {
|
||||||
|
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
||||||
|
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
||||||
|
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
||||||
|
adapter: adapter()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
19
svar-gantt-app/tsconfig.json
Normal file
19
svar-gantt-app/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"extends": "./.svelte-kit/tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"strict": true,
|
||||||
|
"moduleResolution": "bundler"
|
||||||
|
}
|
||||||
|
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
||||||
|
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
||||||
|
//
|
||||||
|
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||||
|
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||||
|
}
|
||||||
6
svar-gantt-app/vite.config.ts
Normal file
6
svar-gantt-app/vite.config.ts
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import { sveltekit } from '@sveltejs/kit/vite';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [sveltekit()]
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user