Merge backend branch and restore functionalities
This commit is contained in:
38
backendia/.gitignore
vendored
Normal file
38
backendia/.gitignore
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# Dependencies
|
||||||
|
node_modules/
|
||||||
|
dashboard/node_modules/
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
dashboard/.next/
|
||||||
|
dashboard/out/
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
# Database
|
||||||
|
backendia/uploads/data/database.sqlite
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite-journal
|
||||||
|
|
||||||
|
# Uploads and Exports (Ignore content but keep directories)
|
||||||
|
uploads/images/*
|
||||||
|
!uploads/images/.gitkeep
|
||||||
|
uploads/data/*
|
||||||
|
!uploads/data/.gitkeep
|
||||||
|
!uploads/data/database.sqlite
|
||||||
|
exports/*
|
||||||
|
!exports/.gitkeep
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# OS files
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
41
backendia/dashboard/.gitignore
vendored
Normal file
41
backendia/dashboard/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# env files (can opt-in for committing if needed)
|
||||||
|
.env*
|
||||||
|
|
||||||
|
# vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
5
backendia/dashboard/AGENTS.md
Normal file
5
backendia/dashboard/AGENTS.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<!-- BEGIN:nextjs-agent-rules -->
|
||||||
|
# This is NOT the Next.js you know
|
||||||
|
|
||||||
|
This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
|
||||||
|
<!-- END:nextjs-agent-rules -->
|
||||||
1
backendia/dashboard/CLAUDE.md
Normal file
1
backendia/dashboard/CLAUDE.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@AGENTS.md
|
||||||
36
backendia/dashboard/README.md
Normal file
36
backendia/dashboard/README.md
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app).
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
First, run the development server:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
# or
|
||||||
|
yarn dev
|
||||||
|
# or
|
||||||
|
pnpm dev
|
||||||
|
# or
|
||||||
|
bun dev
|
||||||
|
```
|
||||||
|
|
||||||
|
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||||
|
|
||||||
|
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file.
|
||||||
|
|
||||||
|
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
||||||
|
|
||||||
|
## Learn More
|
||||||
|
|
||||||
|
To learn more about Next.js, take a look at the following resources:
|
||||||
|
|
||||||
|
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||||
|
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||||
|
|
||||||
|
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
||||||
|
|
||||||
|
## Deploy on Vercel
|
||||||
|
|
||||||
|
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||||
|
|
||||||
|
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
||||||
18
backendia/dashboard/eslint.config.mjs
Normal file
18
backendia/dashboard/eslint.config.mjs
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { defineConfig, globalIgnores } from "eslint/config";
|
||||||
|
import nextVitals from "eslint-config-next/core-web-vitals";
|
||||||
|
import nextTs from "eslint-config-next/typescript";
|
||||||
|
|
||||||
|
const eslintConfig = defineConfig([
|
||||||
|
...nextVitals,
|
||||||
|
...nextTs,
|
||||||
|
// Override default ignores of eslint-config-next.
|
||||||
|
globalIgnores([
|
||||||
|
// Default ignores of eslint-config-next:
|
||||||
|
".next/**",
|
||||||
|
"out/**",
|
||||||
|
"build/**",
|
||||||
|
"next-env.d.ts",
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
|
||||||
|
export default eslintConfig;
|
||||||
17
backendia/dashboard/next.config.ts
Normal file
17
backendia/dashboard/next.config.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const nextConfig: NextConfig = {
|
||||||
|
/* config options here */
|
||||||
|
images: {
|
||||||
|
remotePatterns: [
|
||||||
|
{
|
||||||
|
protocol: 'http',
|
||||||
|
hostname: '127.0.0.1',
|
||||||
|
port: '3000',
|
||||||
|
pathname: '/uploads/**',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default nextConfig;
|
||||||
6616
backendia/dashboard/package-lock.json
generated
Normal file
6616
backendia/dashboard/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
29
backendia/dashboard/package.json
Normal file
29
backendia/dashboard/package.json
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "dashboard",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start",
|
||||||
|
"lint": "eslint"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"clsx": "^2.1.1",
|
||||||
|
"lucide-react": "^1.14.0",
|
||||||
|
"next": "16.2.4",
|
||||||
|
"react": "19.2.4",
|
||||||
|
"react-dom": "19.2.4",
|
||||||
|
"tailwind-merge": "^3.5.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tailwindcss/postcss": "^4",
|
||||||
|
"@types/node": "^20",
|
||||||
|
"@types/react": "^19",
|
||||||
|
"@types/react-dom": "^19",
|
||||||
|
"eslint": "^9",
|
||||||
|
"eslint-config-next": "16.2.4",
|
||||||
|
"tailwindcss": "^4",
|
||||||
|
"typescript": "^5"
|
||||||
|
}
|
||||||
|
}
|
||||||
7
backendia/dashboard/postcss.config.mjs
Normal file
7
backendia/dashboard/postcss.config.mjs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
const config = {
|
||||||
|
plugins: {
|
||||||
|
"@tailwindcss/postcss": {},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
1
backendia/dashboard/public/file.svg
Normal file
1
backendia/dashboard/public/file.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg fill="none" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 13.5V5.41a1 1 0 0 0-.3-.7L9.8.29A1 1 0 0 0 9.08 0H1.5v13.5A2.5 2.5 0 0 0 4 16h8a2.5 2.5 0 0 0 2.5-2.5m-1.5 0v-7H8v-5H3v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1M9.5 5V2.12L12.38 5zM5.13 5h-.62v1.25h2.12V5zm-.62 3h7.12v1.25H4.5zm.62 3h-.62v1.25h7.12V11z" clip-rule="evenodd" fill="#666" fill-rule="evenodd"/></svg>
|
||||||
|
After Width: | Height: | Size: 391 B |
1
backendia/dashboard/public/globe.svg
Normal file
1
backendia/dashboard/public/globe.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
||||||
|
After Width: | Height: | Size: 1.0 KiB |
1
backendia/dashboard/public/next.svg
Normal file
1
backendia/dashboard/public/next.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 394 80"><path fill="#000" d="M262 0h68.5v12.7h-27.2v66.6h-13.6V12.7H262V0ZM149 0v12.7H94v20.4h44.3v12.6H94v21h55v12.6H80.5V0h68.7zm34.3 0h-17.8l63.8 79.4h17.9l-32-39.7 32-39.6h-17.9l-23 28.6-23-28.6zm18.3 56.7-9-11-27.1 33.7h17.8l18.3-22.7z"/><path fill="#000" d="M81 79.3 17 0H0v79.3h13.6V17l50.2 62.3H81Zm252.6-.4c-1 0-1.8-.4-2.5-1s-1.1-1.6-1.1-2.6.3-1.8 1-2.5 1.6-1 2.6-1 1.8.3 2.5 1a3.4 3.4 0 0 1 .6 4.3 3.7 3.7 0 0 1-3 1.8zm23.2-33.5h6v23.3c0 2.1-.4 4-1.3 5.5a9.1 9.1 0 0 1-3.8 3.5c-1.6.8-3.5 1.3-5.7 1.3-2 0-3.7-.4-5.3-1s-2.8-1.8-3.7-3.2c-.9-1.3-1.4-3-1.4-5h6c.1.8.3 1.6.7 2.2s1 1.2 1.6 1.5c.7.4 1.5.5 2.4.5 1 0 1.8-.2 2.4-.6a4 4 0 0 0 1.6-1.8c.3-.8.5-1.8.5-3V45.5zm30.9 9.1a4.4 4.4 0 0 0-2-3.3 7.5 7.5 0 0 0-4.3-1.1c-1.3 0-2.4.2-3.3.5-.9.4-1.6 1-2 1.6a3.5 3.5 0 0 0-.3 4c.3.5.7.9 1.3 1.2l1.8 1 2 .5 3.2.8c1.3.3 2.5.7 3.7 1.2a13 13 0 0 1 3.2 1.8 8.1 8.1 0 0 1 3 6.5c0 2-.5 3.7-1.5 5.1a10 10 0 0 1-4.4 3.5c-1.8.8-4.1 1.2-6.8 1.2-2.6 0-4.9-.4-6.8-1.2-2-.8-3.4-2-4.5-3.5a10 10 0 0 1-1.7-5.6h6a5 5 0 0 0 3.5 4.6c1 .4 2.2.6 3.4.6 1.3 0 2.5-.2 3.5-.6 1-.4 1.8-1 2.4-1.7a4 4 0 0 0 .8-2.4c0-.9-.2-1.6-.7-2.2a11 11 0 0 0-2.1-1.4l-3.2-1-3.8-1c-2.8-.7-5-1.7-6.6-3.2a7.2 7.2 0 0 1-2.4-5.7 8 8 0 0 1 1.7-5 10 10 0 0 1 4.3-3.5c2-.8 4-1.2 6.4-1.2 2.3 0 4.4.4 6.2 1.2 1.8.8 3.2 2 4.3 3.4 1 1.4 1.5 3 1.5 5h-5.8z"/></svg>
|
||||||
|
After Width: | Height: | Size: 1.3 KiB |
1
backendia/dashboard/public/vercel.svg
Normal file
1
backendia/dashboard/public/vercel.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
||||||
|
After Width: | Height: | Size: 128 B |
1
backendia/dashboard/public/window.svg
Normal file
1
backendia/dashboard/public/window.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
||||||
|
After Width: | Height: | Size: 385 B |
104
backendia/dashboard/src/app/contributors/page.tsx
Normal file
104
backendia/dashboard/src/app/contributors/page.tsx
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
import { fetchApi } from "@/lib/api";
|
||||||
|
import { Users, Award, Camera, Clock } from "lucide-react";
|
||||||
|
|
||||||
|
interface Contributor {
|
||||||
|
wallet_hash: string;
|
||||||
|
photo_count: number;
|
||||||
|
last_upload: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function ContributorsPage() {
|
||||||
|
let contributors: Contributor[] = [];
|
||||||
|
try {
|
||||||
|
const response = await fetchApi('/api/contributors');
|
||||||
|
contributors = response.contributors;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching contributors:", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-8">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<h2 className="text-3xl font-bold tracking-tight">Top Contributeurs</h2>
|
||||||
|
<p className="text-slate-400">Classement des utilisateurs selon leur contribution à l'entraînement de l'IA.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 lg:grid-cols-4 gap-6">
|
||||||
|
{/* Stats Summary */}
|
||||||
|
<div className="lg:col-span-1 space-y-6">
|
||||||
|
<StatCard
|
||||||
|
title="Total Contributeurs"
|
||||||
|
value={contributors.length}
|
||||||
|
icon={<Users className="text-indigo-400" />}
|
||||||
|
/>
|
||||||
|
<StatCard
|
||||||
|
title="Total Photos"
|
||||||
|
value={contributors.reduce((acc, c) => acc + c.photo_count, 0)}
|
||||||
|
icon={<Camera className="text-emerald-400" />}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Table */}
|
||||||
|
<div className="lg:col-span-3 bg-slate-900 border border-slate-800 rounded-2xl overflow-hidden">
|
||||||
|
<table className="w-full text-left">
|
||||||
|
<thead className="bg-slate-950/50 border-b border-slate-800">
|
||||||
|
<tr>
|
||||||
|
<th className="px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-widest">Rang</th>
|
||||||
|
<th className="px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-widest">Wallet Hash</th>
|
||||||
|
<th className="px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-widest text-center">Photos</th>
|
||||||
|
<th className="px-6 py-4 text-xs font-bold text-slate-500 uppercase tracking-widest text-right">Dernier Upload</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody className="divide-y divide-slate-800">
|
||||||
|
{contributors.map((c, index) => (
|
||||||
|
<tr key={c.wallet_hash} className="hover:bg-slate-800/30 transition-colors">
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
{index < 3 ? (
|
||||||
|
<Award className={index === 0 ? "text-yellow-500" : index === 1 ? "text-slate-400" : "text-amber-700"} />
|
||||||
|
) : (
|
||||||
|
<span className="text-slate-500 font-mono w-6 text-center">#{index + 1}</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4">
|
||||||
|
<span className="font-mono text-xs text-slate-300">{c.wallet_hash}</span>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4 text-center">
|
||||||
|
<span className="px-2 py-1 bg-indigo-500/10 text-indigo-400 rounded-md text-xs font-bold border border-indigo-500/20">
|
||||||
|
{c.photo_count}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td className="px-6 py-4 text-right text-xs text-slate-400 flex items-center justify-end gap-2">
|
||||||
|
<Clock size={14} />
|
||||||
|
{new Date(c.last_upload).toLocaleString()}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
{contributors.length === 0 && (
|
||||||
|
<div className="py-24 text-center text-slate-500">
|
||||||
|
Aucun contributeur enregistré pour le moment.
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function StatCard({ title, value, icon }: any) {
|
||||||
|
return (
|
||||||
|
<div className="bg-slate-900 border border-slate-800 p-6 rounded-2xl flex items-center justify-between">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<p className="text-xs text-slate-500 font-bold uppercase tracking-widest">{title}</p>
|
||||||
|
<p className="text-3xl font-bold">{value}</p>
|
||||||
|
</div>
|
||||||
|
<div className="w-12 h-12 bg-slate-800 rounded-xl flex items-center justify-center shadow-inner">
|
||||||
|
{icon}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
BIN
backendia/dashboard/src/app/favicon.ico
Normal file
BIN
backendia/dashboard/src/app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
26
backendia/dashboard/src/app/globals.css
Normal file
26
backendia/dashboard/src/app/globals.css
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
@import "tailwindcss";
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--background: #ffffff;
|
||||||
|
--foreground: #171717;
|
||||||
|
}
|
||||||
|
|
||||||
|
@theme inline {
|
||||||
|
--color-background: var(--background);
|
||||||
|
--color-foreground: var(--foreground);
|
||||||
|
--font-sans: var(--font-geist-sans);
|
||||||
|
--font-mono: var(--font-geist-mono);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--background: #0a0a0a;
|
||||||
|
--foreground: #ededed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: var(--background);
|
||||||
|
color: var(--foreground);
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
67
backendia/dashboard/src/app/layout.tsx
Normal file
67
backendia/dashboard/src/app/layout.tsx
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import { Inter } from "next/font/google";
|
||||||
|
import "./globals.css";
|
||||||
|
import Link from "next/link";
|
||||||
|
import { LayoutDashboard, Users, Image as ImageIcon } from "lucide-react";
|
||||||
|
|
||||||
|
const inter = Inter({ subsets: ["latin"] });
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Bully IA Dashboard",
|
||||||
|
description: "Visualisation des données d'analyse de cibles",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) {
|
||||||
|
return (
|
||||||
|
<html lang="fr" className="dark">
|
||||||
|
<body className={`${inter.className} bg-slate-950 text-slate-50 min-h-screen flex`}>
|
||||||
|
{/* Sidebar */}
|
||||||
|
<aside className="w-64 border-r border-slate-800 bg-slate-900/50 p-6 flex flex-col gap-8">
|
||||||
|
<div className="flex items-center gap-3 px-2">
|
||||||
|
<div className="w-8 h-8 bg-indigo-600 rounded-lg flex items-center justify-center font-bold">B</div>
|
||||||
|
<h1 className="text-xl font-bold tracking-tight">Bully IA</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<nav className="flex flex-col gap-2">
|
||||||
|
<Link
|
||||||
|
href="/"
|
||||||
|
className="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-slate-800 transition-colors text-slate-300 hover:text-white"
|
||||||
|
>
|
||||||
|
<LayoutDashboard size={20} />
|
||||||
|
Tableau de bord
|
||||||
|
</Link>
|
||||||
|
<Link
|
||||||
|
href="/contributors"
|
||||||
|
className="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-slate-800 transition-colors text-slate-300 hover:text-white"
|
||||||
|
>
|
||||||
|
<Users size={20} />
|
||||||
|
Contributeurs
|
||||||
|
</Link>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div className="mt-auto pt-6 border-t border-slate-800">
|
||||||
|
<p className="text-xs text-slate-500 px-2">v1.0.0 Alpha</p>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
{/* Main Content */}
|
||||||
|
<main className="flex-1 flex flex-col">
|
||||||
|
<header className="h-16 border-b border-slate-800 flex items-center px-8 bg-slate-900/20">
|
||||||
|
<div className="flex items-center gap-2 text-sm text-slate-400">
|
||||||
|
<span>Admin</span>
|
||||||
|
<span>/</span>
|
||||||
|
<span className="text-slate-200">Dashboard</span>
|
||||||
|
</div>
|
||||||
|
</header>
|
||||||
|
<div className="flex-1 p-8 overflow-auto">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
105
backendia/dashboard/src/app/page.tsx
Normal file
105
backendia/dashboard/src/app/page.tsx
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
import { fetchApi, API_BASE_URL } from "@/lib/api";
|
||||||
|
import DatasetToolbar from "@/components/DatasetToolbar";
|
||||||
|
import { Calendar, User, Crosshair } from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
interface PlottingData {
|
||||||
|
session_id: string;
|
||||||
|
wallet_hash: string;
|
||||||
|
timestamp: string;
|
||||||
|
plotting: {
|
||||||
|
impacts: any[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PhotoData {
|
||||||
|
filename: string;
|
||||||
|
imageUrl: string;
|
||||||
|
data: PlottingData | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default async function DashboardPage() {
|
||||||
|
let photos: PhotoData[] = [];
|
||||||
|
try {
|
||||||
|
const response = await fetchApi('/api/all-data');
|
||||||
|
photos = response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching photos:", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-8">
|
||||||
|
<div className="flex flex-col md:flex-row md:items-end justify-between gap-4">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<h2 className="text-3xl font-bold tracking-tight">Galerie des Sessions</h2>
|
||||||
|
<p className="text-slate-400">Visualisez et gérez les données d'entraînement collectées.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DatasetToolbar />
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
|
||||||
|
{photos.map((photo) => (
|
||||||
|
<Link
|
||||||
|
key={photo.filename}
|
||||||
|
href={`/photo/${photo.filename}`}
|
||||||
|
className="group relative bg-slate-900 rounded-xl border border-slate-800 overflow-hidden hover:border-indigo-500/50 transition-all hover:shadow-2xl hover:shadow-indigo-500/10"
|
||||||
|
>
|
||||||
|
{/* Image Preview */}
|
||||||
|
<div className="aspect-[3/4] relative overflow-hidden bg-slate-800">
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
|
<img
|
||||||
|
src={`${API_BASE_URL}${photo.imageUrl}`}
|
||||||
|
alt={photo.filename}
|
||||||
|
className="w-full h-full object-cover group-hover:scale-105 transition-transform duration-500"
|
||||||
|
/>
|
||||||
|
<div className="absolute inset-0 bg-gradient-to-t from-slate-950 via-transparent to-transparent opacity-80" />
|
||||||
|
|
||||||
|
{/* Badge impacts */}
|
||||||
|
{photo.data?.plotting?.impacts && (
|
||||||
|
<div className="absolute top-3 right-3 bg-indigo-600/90 backdrop-blur-md px-2 py-1 rounded-md text-[10px] font-bold flex items-center gap-1">
|
||||||
|
<Crosshair size={12} />
|
||||||
|
{photo.data.plotting.impacts.length} IMPACTS
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Info */}
|
||||||
|
<div className="p-4 space-y-3">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<div className="flex items-center gap-2 text-xs text-slate-400">
|
||||||
|
<Calendar size={14} className="text-indigo-400" />
|
||||||
|
{photo.data ? new Date(photo.data.timestamp).toLocaleDateString() : 'Date inconnue'}
|
||||||
|
</div>
|
||||||
|
{photo.data ? (
|
||||||
|
<span className="text-[10px] bg-emerald-500/10 text-emerald-400 px-1.5 py-0.5 rounded border border-emerald-500/20 font-bold">DATA OK</span>
|
||||||
|
) : (
|
||||||
|
<span className="text-[10px] bg-rose-500/10 text-rose-400 px-1.5 py-0.5 rounded border border-rose-500/20 font-bold">NO DATA</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-2 text-xs text-slate-300 font-mono truncate">
|
||||||
|
<User size={14} className="text-indigo-400" />
|
||||||
|
{photo.data?.wallet_hash?.substring(0, 12) || 'Anonyme'}...
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="pt-2 border-t border-slate-800 flex justify-between items-center">
|
||||||
|
<span className="text-[10px] text-slate-500 uppercase tracking-widest font-bold">Session ID</span>
|
||||||
|
<span className="text-xs text-slate-300 font-mono truncate max-w-[120px]">
|
||||||
|
{photo.data?.session_id || 'N/A'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Link>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{photos.length === 0 && (
|
||||||
|
<div className="flex flex-col items-center justify-center py-24 text-slate-500 gap-4 border-2 border-dashed border-slate-800 rounded-3xl">
|
||||||
|
<Crosshair size={48} className="opacity-20" />
|
||||||
|
<p>Aucune session d'entraînement trouvée.</p>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
49
backendia/dashboard/src/app/photo/[id]/page.tsx
Normal file
49
backendia/dashboard/src/app/photo/[id]/page.tsx
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import { fetchApi, API_BASE_URL } from "@/lib/api";
|
||||||
|
import PhotoEditor from "@/components/PhotoEditor";
|
||||||
|
import { ChevronLeft, Download } from "lucide-react";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
export default async function PhotoDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
||||||
|
const { id: encodedId } = await params;
|
||||||
|
const id = decodeURIComponent(encodedId);
|
||||||
|
let photo = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetchApi('/api/all-data');
|
||||||
|
photo = response.data.find((p: any) => p.filename === id);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching photo detail:", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!photo) {
|
||||||
|
return <div className="p-12 text-center">Session non trouvée.</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="space-y-8">
|
||||||
|
{/* Header */}
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<Link
|
||||||
|
href="/"
|
||||||
|
className="flex items-center gap-2 text-slate-400 hover:text-white transition-colors"
|
||||||
|
>
|
||||||
|
<ChevronLeft size={20} />
|
||||||
|
Retour à la galerie
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<a
|
||||||
|
href={`${API_BASE_URL}/uploads/images/${id}`}
|
||||||
|
download
|
||||||
|
className="flex items-center gap-2 bg-slate-800 hover:bg-slate-700 px-4 py-2 rounded-lg text-sm font-medium transition-colors"
|
||||||
|
>
|
||||||
|
<Download size={18} />
|
||||||
|
Image Originale
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PhotoEditor initialPhoto={photo} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
98
backendia/dashboard/src/components/DatasetToolbar.tsx
Normal file
98
backendia/dashboard/src/components/DatasetToolbar.tsx
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import { Download, Archive, AlertTriangle, Check, RefreshCw } from "lucide-react";
|
||||||
|
import { API_BASE_URL } from "@/lib/api";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
|
export default function DatasetToolbar() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isExporting, setIsExporting] = useState(false);
|
||||||
|
const [isArchiving, setIsArchiving] = useState(false);
|
||||||
|
const [showArchiveConfirm, setShowArchiveConfirm] = useState(false);
|
||||||
|
|
||||||
|
const handleExport = async () => {
|
||||||
|
setIsExporting(true);
|
||||||
|
try {
|
||||||
|
// On ouvre simplement l'URL dans un nouvel onglet pour déclencher le téléchargement
|
||||||
|
window.open(`${API_BASE_URL}/api/export/zip`, '_blank');
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Export error:", error);
|
||||||
|
} finally {
|
||||||
|
setIsExporting(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleArchive = async () => {
|
||||||
|
setIsArchiving(true);
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_BASE_URL}/api/export/archive`, {
|
||||||
|
method: "POST"
|
||||||
|
});
|
||||||
|
if (response.ok) {
|
||||||
|
setShowArchiveConfirm(false);
|
||||||
|
router.refresh(); // Rafraîchir la galerie
|
||||||
|
} else {
|
||||||
|
alert("Erreur lors de l'archivage");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Archive error:", error);
|
||||||
|
alert("Erreur réseau");
|
||||||
|
} finally {
|
||||||
|
setIsArchiving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="bg-slate-900 border border-slate-800 rounded-2xl p-6 flex flex-col md:flex-row items-center justify-between gap-6 shadow-xl shadow-indigo-500/5">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<h3 className="font-bold text-lg flex items-center gap-2">
|
||||||
|
<RefreshCw size={20} className="text-indigo-400" />
|
||||||
|
Gestion du Dataset
|
||||||
|
</h3>
|
||||||
|
<p className="text-xs text-slate-500">Exportez vos sessions étiquetées en ZIP et archivez-les pour nettoyer la galerie.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<button
|
||||||
|
onClick={handleExport}
|
||||||
|
disabled={isExporting}
|
||||||
|
className="flex items-center gap-2 bg-indigo-600 hover:bg-indigo-500 disabled:opacity-50 px-5 py-2.5 rounded-xl text-sm font-bold transition-all hover:scale-105 active:scale-95 shadow-lg shadow-indigo-600/20"
|
||||||
|
>
|
||||||
|
<Download size={18} />
|
||||||
|
{isExporting ? "Préparation..." : "Télécharger ZIP"}
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{!showArchiveConfirm ? (
|
||||||
|
<button
|
||||||
|
onClick={() => setShowArchiveConfirm(true)}
|
||||||
|
className="flex items-center gap-2 bg-slate-800 hover:bg-slate-700 px-5 py-2.5 rounded-xl text-sm font-bold transition-all border border-slate-700"
|
||||||
|
>
|
||||||
|
<Archive size={18} />
|
||||||
|
Archiver les sessions
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
|
<div className="flex items-center gap-2 animate-in fade-in slide-in-from-right-4 duration-300">
|
||||||
|
<div className="flex items-center gap-2 px-4 py-2 bg-rose-500/10 border border-rose-500/20 rounded-xl text-rose-400 text-xs font-bold">
|
||||||
|
<AlertTriangle size={14} />
|
||||||
|
Vider la galerie ?
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={handleArchive}
|
||||||
|
disabled={isArchiving}
|
||||||
|
className="bg-rose-600 hover:bg-rose-500 p-2.5 rounded-xl transition-colors disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<Check size={18} className="text-white" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setShowArchiveConfirm(false)}
|
||||||
|
className="bg-slate-800 hover:bg-slate-700 p-2.5 rounded-xl transition-colors"
|
||||||
|
>
|
||||||
|
<Archive size={18} className="text-slate-400" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
226
backendia/dashboard/src/components/PhotoEditor.tsx
Normal file
226
backendia/dashboard/src/components/PhotoEditor.tsx
Normal file
@@ -0,0 +1,226 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useState } from "react";
|
||||||
|
import PhotoOverlay from "./PhotoOverlay";
|
||||||
|
import { Info, Calendar, User, Smartphone, Cpu, Save, Edit2, X, Trash2, Check, Tag } from "lucide-react";
|
||||||
|
import { API_BASE_URL } from "@/lib/api";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
|
interface PhotoEditorProps {
|
||||||
|
initialPhoto: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PREDEFINED_LABELS = ["bullet_hole", "tear", "miss", "rebound", "other"];
|
||||||
|
|
||||||
|
export default function PhotoEditor({ initialPhoto }: PhotoEditorProps) {
|
||||||
|
const router = useRouter();
|
||||||
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
const [photoData, setPhotoData] = useState(initialPhoto.data);
|
||||||
|
const [isSaving, setIsSaving] = useState(false);
|
||||||
|
|
||||||
|
const handleImpactsChange = (newImpacts: any[]) => {
|
||||||
|
setPhotoData({
|
||||||
|
...photoData,
|
||||||
|
plotting: {
|
||||||
|
...photoData.plotting,
|
||||||
|
impacts: newImpacts
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateLabel = (index: number, label: string) => {
|
||||||
|
const newImpacts = [...photoData.plotting.impacts];
|
||||||
|
newImpacts[index] = { ...newImpacts[index], label };
|
||||||
|
handleImpactsChange(newImpacts);
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateScore = (index: number, score: number) => {
|
||||||
|
const newImpacts = [...photoData.plotting.impacts];
|
||||||
|
newImpacts[index] = { ...newImpacts[index], score };
|
||||||
|
handleImpactsChange(newImpacts);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
setIsSaving(true);
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_BASE_URL}/api/data/${initialPhoto.filename}`, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify(photoData),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
setIsEditing(false);
|
||||||
|
router.refresh();
|
||||||
|
} else {
|
||||||
|
alert("Erreur lors de la sauvegarde");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Save error:", error);
|
||||||
|
alert("Erreur réseau");
|
||||||
|
} finally {
|
||||||
|
setIsSaving(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const impacts = photoData?.plotting?.impacts || [];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="grid grid-cols-1 xl:grid-cols-3 gap-8">
|
||||||
|
{/* Main View */}
|
||||||
|
<div className="xl:col-span-2 space-y-4">
|
||||||
|
<div className="flex items-center justify-between bg-slate-900/50 p-4 rounded-xl border border-slate-800">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<div className={`w-2 h-2 rounded-full ${isEditing ? 'bg-amber-500 animate-pulse' : 'bg-emerald-500'}`} />
|
||||||
|
<span className="text-sm font-medium">
|
||||||
|
{isEditing ? "Mode Édition Actif" : "Mode Visualisation"}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-2">
|
||||||
|
{isEditing ? (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
onClick={() => {
|
||||||
|
setPhotoData(initialPhoto.data);
|
||||||
|
setIsEditing(false);
|
||||||
|
}}
|
||||||
|
className="flex items-center gap-2 bg-slate-800 hover:bg-slate-700 px-4 py-2 rounded-lg text-sm font-medium transition-colors"
|
||||||
|
>
|
||||||
|
<X size={18} />
|
||||||
|
Annuler
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={handleSave}
|
||||||
|
disabled={isSaving}
|
||||||
|
className="flex items-center gap-2 bg-indigo-600 hover:bg-indigo-500 px-4 py-2 rounded-lg text-sm font-medium transition-colors disabled:opacity-50"
|
||||||
|
>
|
||||||
|
<Save size={18} />
|
||||||
|
{isSaving ? "Enregistrement..." : "Enregistrer"}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<button
|
||||||
|
onClick={() => setIsEditing(true)}
|
||||||
|
className="flex items-center gap-2 bg-indigo-600 hover:bg-indigo-500 px-4 py-2 rounded-lg text-sm font-medium transition-colors"
|
||||||
|
>
|
||||||
|
<Edit2 size={18} />
|
||||||
|
Modifier les points
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PhotoOverlay
|
||||||
|
imageUrl={`${API_BASE_URL}${initialPhoto.imageUrl}`}
|
||||||
|
impacts={impacts}
|
||||||
|
targetCorners={photoData?.plotting?.target_corners || []}
|
||||||
|
isEditing={isEditing}
|
||||||
|
onImpactsChange={handleImpactsChange}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Sidebar Info & Labeling */}
|
||||||
|
<div className="space-y-6">
|
||||||
|
{/* Labeling Section (Only if editing or has impacts) */}
|
||||||
|
<div className="bg-slate-900 border border-slate-800 rounded-2xl p-6 space-y-4">
|
||||||
|
<div className="flex items-center justify-between pb-4 border-b border-slate-800">
|
||||||
|
<div className="flex items-center gap-3">
|
||||||
|
<Tag className="text-indigo-400" size={20} />
|
||||||
|
<h3 className="font-bold text-lg">Étiquetage (Impacts)</h3>
|
||||||
|
</div>
|
||||||
|
<span className="bg-slate-800 text-slate-400 text-[10px] font-bold px-2 py-0.5 rounded">
|
||||||
|
{impacts.length} TOTAL
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-3 max-h-[400px] overflow-auto pr-2 custom-scrollbar">
|
||||||
|
{impacts.map((impact: any, index: number) => (
|
||||||
|
<div key={impact.id} className="bg-slate-950 p-3 rounded-xl border border-slate-800 space-y-3 group">
|
||||||
|
<div className="flex items-center justify-between">
|
||||||
|
<span className="text-[10px] font-bold text-slate-500 uppercase">Impact #{impact.id}</span>
|
||||||
|
{isEditing && (
|
||||||
|
<button
|
||||||
|
onClick={(e) => {
|
||||||
|
const newImpacts = impacts.filter((_: any, i: number) => i !== index);
|
||||||
|
handleImpactsChange(newImpacts);
|
||||||
|
}}
|
||||||
|
className="text-slate-600 hover:text-rose-500 transition-colors"
|
||||||
|
>
|
||||||
|
<Trash2 size={14} />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-2 gap-2">
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label className="text-[10px] text-slate-500 font-bold uppercase">Label</label>
|
||||||
|
{isEditing ? (
|
||||||
|
<select
|
||||||
|
value={impact.label}
|
||||||
|
onChange={(e) => updateLabel(index, e.target.value)}
|
||||||
|
className="w-full bg-slate-900 border border-slate-800 rounded px-2 py-1 text-xs outline-none focus:border-indigo-500"
|
||||||
|
>
|
||||||
|
{PREDEFINED_LABELS.map(l => <option key={l} value={l}>{l}</option>)}
|
||||||
|
</select>
|
||||||
|
) : (
|
||||||
|
<div className="text-xs text-indigo-300 font-medium">{impact.label}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
<div className="space-y-1">
|
||||||
|
<label className="text-[10px] text-slate-500 font-bold uppercase">Score</label>
|
||||||
|
{isEditing ? (
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
min="0"
|
||||||
|
max="10"
|
||||||
|
value={impact.score}
|
||||||
|
onChange={(e) => updateScore(index, parseInt(e.target.value) || 0)}
|
||||||
|
className="w-full bg-slate-900 border border-slate-800 rounded px-2 py-1 text-xs outline-none focus:border-indigo-500"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="text-xs text-emerald-400 font-bold">{impact.score}</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{impacts.length === 0 && (
|
||||||
|
<p className="text-center py-8 text-xs text-slate-500 italic">
|
||||||
|
Aucun impact détecté. {isEditing ? "Cliquez sur l'image pour en ajouter." : ""}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Metadata Card (Read Only) */}
|
||||||
|
<div className="bg-slate-900/50 border border-slate-800 rounded-2xl p-6 space-y-4 opacity-80">
|
||||||
|
<div className="flex items-center gap-3 pb-2 border-b border-slate-800">
|
||||||
|
<Info className="text-slate-400" size={18} />
|
||||||
|
<h3 className="font-bold text-sm text-slate-300">Métadonnées Session</h3>
|
||||||
|
</div>
|
||||||
|
<div className="space-y-3">
|
||||||
|
<InfoItem icon={<Calendar size={14} />} label="Date" value={photoData ? new Date(photoData.timestamp).toLocaleString() : 'Inconnue'} />
|
||||||
|
<InfoItem icon={<User size={14} />} label="Contributeur" value={photoData?.wallet_hash || 'Anonyme'} isMono />
|
||||||
|
<InfoItem icon={<Smartphone size={14} />} label="Appareil" value={photoData?.device_info?.model || 'Inconnu'} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function InfoItem({ icon, label, value, isMono = false }: any) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col gap-0.5">
|
||||||
|
<div className="flex items-center gap-1.5 text-[10px] text-slate-500 font-bold uppercase">
|
||||||
|
{icon}
|
||||||
|
{label}
|
||||||
|
</div>
|
||||||
|
<p className={`text-xs text-slate-300 ${isMono ? 'font-mono truncate' : ''}`}>
|
||||||
|
{value}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
183
backendia/dashboard/src/components/PhotoOverlay.tsx
Normal file
183
backendia/dashboard/src/components/PhotoOverlay.tsx
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useRef, useState } from "react";
|
||||||
|
|
||||||
|
interface Point {
|
||||||
|
norm_x: number;
|
||||||
|
norm_y: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Impact {
|
||||||
|
id: number;
|
||||||
|
label: string;
|
||||||
|
score: number;
|
||||||
|
coords: Point;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PhotoOverlayProps {
|
||||||
|
imageUrl: string;
|
||||||
|
impacts: Impact[];
|
||||||
|
targetCorners: Point[];
|
||||||
|
isEditing?: boolean;
|
||||||
|
onImpactsChange?: (impacts: Impact[]) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function PhotoOverlay({
|
||||||
|
imageUrl,
|
||||||
|
impacts,
|
||||||
|
targetCorners,
|
||||||
|
isEditing = false,
|
||||||
|
onImpactsChange
|
||||||
|
}: PhotoOverlayProps) {
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [dimensions, setDimensions] = useState({ width: 0, height: 0 });
|
||||||
|
const [dragIndex, setDragIndex] = useState<number | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const updateDimensions = () => {
|
||||||
|
if (containerRef.current) {
|
||||||
|
setDimensions({
|
||||||
|
width: containerRef.current.offsetWidth,
|
||||||
|
height: containerRef.current.offsetHeight,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateDimensions();
|
||||||
|
window.addEventListener("resize", updateDimensions);
|
||||||
|
return () => window.removeEventListener("resize", updateDimensions);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleImageClick = (e: React.MouseEvent) => {
|
||||||
|
if (!isEditing || !onImpactsChange || dragIndex !== null) return;
|
||||||
|
|
||||||
|
const rect = containerRef.current?.getBoundingClientRect();
|
||||||
|
if (!rect) return;
|
||||||
|
|
||||||
|
// Calculer les coordonnées normalisées
|
||||||
|
const x = (e.clientX - rect.left) / dimensions.width;
|
||||||
|
const y = (e.clientY - rect.top) / dimensions.height;
|
||||||
|
|
||||||
|
// Créer un nouvel impact
|
||||||
|
const newImpact: Impact = {
|
||||||
|
id: impacts.length > 0 ? Math.max(...impacts.map(i => i.id)) + 1 : 1,
|
||||||
|
label: "bullet_hole",
|
||||||
|
score: 10,
|
||||||
|
coords: { norm_x: x, norm_y: y }
|
||||||
|
};
|
||||||
|
|
||||||
|
onImpactsChange([...impacts, newImpact]);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMouseMove = (e: React.MouseEvent) => {
|
||||||
|
if (dragIndex === null || !onImpactsChange) return;
|
||||||
|
|
||||||
|
const rect = containerRef.current?.getBoundingClientRect();
|
||||||
|
if (!rect) return;
|
||||||
|
|
||||||
|
const x = (e.clientX - rect.left) / dimensions.width;
|
||||||
|
const y = (e.clientY - rect.top) / dimensions.height;
|
||||||
|
|
||||||
|
const newImpacts = [...impacts];
|
||||||
|
newImpacts[dragIndex] = {
|
||||||
|
...newImpacts[dragIndex],
|
||||||
|
coords: { norm_x: x, norm_y: y }
|
||||||
|
};
|
||||||
|
|
||||||
|
onImpactsChange(newImpacts);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteImpact = (e: React.MouseEvent, index: number) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (!isEditing || !onImpactsChange) return;
|
||||||
|
const newImpacts = impacts.filter((_, i) => i !== index);
|
||||||
|
onImpactsChange(newImpacts);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
ref={containerRef}
|
||||||
|
className={`relative w-full flex items-center justify-center bg-slate-900 rounded-2xl overflow-hidden border border-slate-800 shadow-2xl min-h-[400px] ${isEditing ? 'cursor-crosshair' : ''}`}
|
||||||
|
onClick={handleImageClick}
|
||||||
|
onMouseMove={handleMouseMove}
|
||||||
|
onMouseUp={() => setDragIndex(null)}
|
||||||
|
onMouseLeave={() => setDragIndex(null)}
|
||||||
|
>
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
|
<img
|
||||||
|
src={imageUrl}
|
||||||
|
alt="Target Analysis"
|
||||||
|
className="max-w-full max-h-[80vh] object-contain select-none"
|
||||||
|
draggable={false}
|
||||||
|
onLoad={(e) => {
|
||||||
|
const img = e.currentTarget;
|
||||||
|
setDimensions({ width: img.clientWidth, height: img.clientHeight });
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{dimensions.width > 0 && (
|
||||||
|
<svg
|
||||||
|
className="absolute pointer-events-none"
|
||||||
|
viewBox={`0 0 ${dimensions.width} ${dimensions.height}`}
|
||||||
|
style={{ width: dimensions.width, height: dimensions.height }}
|
||||||
|
>
|
||||||
|
{/* Draw Target Box if corners exist */}
|
||||||
|
{targetCorners && targetCorners.length === 4 && (
|
||||||
|
<polygon
|
||||||
|
points={targetCorners.map(c => `${c.norm_x * dimensions.width},${c.norm_y * dimensions.height}`).join(' ')}
|
||||||
|
fill="rgba(79, 70, 229, 0.15)"
|
||||||
|
stroke="#6366f1"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeDasharray="4 2"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Draw Impacts */}
|
||||||
|
{impacts.map((impact, index) => (
|
||||||
|
<g key={impact.id}>
|
||||||
|
{/* Glow effect */}
|
||||||
|
<circle
|
||||||
|
cx={impact.coords.norm_x * dimensions.width}
|
||||||
|
cy={impact.coords.norm_y * dimensions.height}
|
||||||
|
r={isEditing ? "12" : "8"}
|
||||||
|
fill={isEditing ? "rgba(244, 63, 94, 0.2)" : "rgba(244, 63, 94, 0.3)"}
|
||||||
|
className={isEditing ? 'pointer-events-auto cursor-move' : ''}
|
||||||
|
onMouseDown={(e) => {
|
||||||
|
if (!isEditing) return;
|
||||||
|
e.stopPropagation();
|
||||||
|
setDragIndex(index);
|
||||||
|
}}
|
||||||
|
onContextMenu={(e) => deleteImpact(e, index)}
|
||||||
|
/>
|
||||||
|
{/* Main circle */}
|
||||||
|
<circle
|
||||||
|
cx={impact.coords.norm_x * dimensions.width}
|
||||||
|
cy={impact.coords.norm_y * dimensions.height}
|
||||||
|
r="5"
|
||||||
|
fill="#f43f5e"
|
||||||
|
stroke="white"
|
||||||
|
strokeWidth="1.5"
|
||||||
|
/>
|
||||||
|
{/* Score text */}
|
||||||
|
<text
|
||||||
|
x={impact.coords.norm_x * dimensions.width}
|
||||||
|
y={impact.coords.norm_y * dimensions.height - 10}
|
||||||
|
className="text-[12px] font-bold fill-white text-center select-none"
|
||||||
|
textAnchor="middle"
|
||||||
|
style={{ textShadow: '0 0 4px rgba(0,0,0,0.9), 1px 1px 0 rgba(0,0,0,0.9)' }}
|
||||||
|
>
|
||||||
|
{impact.score}
|
||||||
|
</text>
|
||||||
|
</g>
|
||||||
|
))}
|
||||||
|
</svg>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isEditing && (
|
||||||
|
<div className="absolute bottom-4 right-4 bg-slate-950/80 backdrop-blur-md px-3 py-1.5 rounded-full text-[10px] font-bold text-indigo-400 border border-indigo-500/30">
|
||||||
|
MODE ÉDITION : CLIC POUR AJOUTER • DRAG POUR DÉPLACER • CLIC DROIT POUR SUPPRIMER
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
11
backendia/dashboard/src/lib/api.ts
Normal file
11
backendia/dashboard/src/lib/api.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
export const API_BASE_URL = 'http://127.0.0.1:3000';
|
||||||
|
|
||||||
|
export async function fetchApi(endpoint: string) {
|
||||||
|
const res = await fetch(`${API_BASE_URL}${endpoint}`, {
|
||||||
|
cache: 'no-store',
|
||||||
|
});
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Failed to fetch ${endpoint}`);
|
||||||
|
}
|
||||||
|
return res.json();
|
||||||
|
}
|
||||||
34
backendia/dashboard/tsconfig.json
Normal file
34
backendia/dashboard/tsconfig.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"incremental": true,
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts",
|
||||||
|
"**/*.mts"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
1
backendia/exports/.gitkeep
Normal file
1
backendia/exports/.gitkeep
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Keep directory structure
|
||||||
1682
backendia/package-lock.json
generated
Normal file
1682
backendia/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
22
backendia/package.json
Normal file
22
backendia/package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "backendia",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node server.js",
|
||||||
|
"dashboard": "cd dashboard && npm run dev -- -p 3001",
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"adm-zip": "^0.5.17",
|
||||||
|
"cors": "^2.8.6",
|
||||||
|
"dotenv": "^17.4.2",
|
||||||
|
"express": "^5.2.1",
|
||||||
|
"multer": "^2.1.1",
|
||||||
|
"sqlite3": "^6.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
346
backendia/server.js
Normal file
346
backendia/server.js
Normal file
@@ -0,0 +1,346 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const multer = require('multer');
|
||||||
|
const cors = require('cors');
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
const sqlite3 = require('sqlite3').verbose();
|
||||||
|
const AdmZip = require('adm-zip');
|
||||||
|
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const PORT = process.env.PORT || 3000;
|
||||||
|
|
||||||
|
// Middleware
|
||||||
|
app.use(cors());
|
||||||
|
app.use(express.json());
|
||||||
|
|
||||||
|
// Arborescence demandée
|
||||||
|
const uploadDir = path.join(__dirname, 'uploads');
|
||||||
|
const imagesDir = path.join(uploadDir, 'images');
|
||||||
|
const dataDir = path.join(uploadDir, 'data');
|
||||||
|
const exportsDir = path.join(__dirname, 'exports');
|
||||||
|
|
||||||
|
// S'assurer que les dossiers existent
|
||||||
|
[uploadDir, imagesDir, dataDir, exportsDir].forEach(dir => {
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialisation de la base de données SQLite
|
||||||
|
const dbPath = path.join(dataDir, 'database.sqlite');
|
||||||
|
const db = new sqlite3.Database(dbPath, (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Erreur de connexion à SQLite:', err.message);
|
||||||
|
} else {
|
||||||
|
console.log('Connecté à la base de données SQLite.');
|
||||||
|
db.run(`CREATE TABLE IF NOT EXISTS user_stats (
|
||||||
|
wallet_hash TEXT PRIMARY KEY,
|
||||||
|
photo_count INTEGER DEFAULT 0,
|
||||||
|
last_upload DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Configuration de multer pour le stockage des fichiers
|
||||||
|
const storage = multer.diskStorage({
|
||||||
|
destination: function (req, file, cb) {
|
||||||
|
cb(null, imagesDir); // Les photos vont dans uploads/images/
|
||||||
|
},
|
||||||
|
filename: function (req, file, cb) {
|
||||||
|
// Créer un nom de fichier unique tout en gardant l'extension originale
|
||||||
|
const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
|
||||||
|
const ext = path.extname(file.originalname);
|
||||||
|
cb(null, file.fieldname + '-' + uniqueSuffix + ext);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const upload = multer({
|
||||||
|
storage: storage,
|
||||||
|
limits: {
|
||||||
|
fileSize: 15 * 1024 * 1024 // Limite de taille: 15 MB
|
||||||
|
},
|
||||||
|
fileFilter: (req, file, cb) => {
|
||||||
|
const ext = path.extname(file.originalname).toLowerCase();
|
||||||
|
const allowedExts = ['.jpg', '.jpeg', '.png', '.gif', '.webp'];
|
||||||
|
|
||||||
|
// Accepter si c'est un mimetype image OU si l'extension est celle d'une image
|
||||||
|
if (file.mimetype.startsWith('image/') || allowedExts.includes(ext) || file.mimetype === 'application/octet-stream') {
|
||||||
|
cb(null, true);
|
||||||
|
} else {
|
||||||
|
console.error(`Fichier rejeté: mimetype=${file.mimetype}, extension=${ext}`);
|
||||||
|
cb(new Error('Seules les images sont autorisées !'), false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Routes de base
|
||||||
|
app.get('/api/health', (req, res) => {
|
||||||
|
res.json({ status: 'ok', message: 'Le serveur backend IA fonctionne' });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour l'upload de photo + données JSON
|
||||||
|
// Attend un form-data avec un champ nommé 'photo' et un champ texte 'plotting'
|
||||||
|
app.post('/api/upload', upload.single('photo'), (req, res) => {
|
||||||
|
try {
|
||||||
|
if (!req.file) {
|
||||||
|
return res.status(400).json({ error: 'Aucune photo fournie' });
|
||||||
|
}
|
||||||
|
|
||||||
|
let plottingData = {};
|
||||||
|
if (req.body.plotting) {
|
||||||
|
try {
|
||||||
|
plottingData = JSON.parse(req.body.plotting);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Erreur parsing JSON:", e);
|
||||||
|
return res.status(400).json({ error: 'Le champ plotting doit être un JSON valide' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nom de base sans l'extension
|
||||||
|
const baseFilename = path.parse(req.file.filename).name;
|
||||||
|
const jsonFilename = `${baseFilename}.json`;
|
||||||
|
const jsonFilePath = path.join(dataDir, jsonFilename);
|
||||||
|
|
||||||
|
// Sauvegarde du JSON dans uploads/data/
|
||||||
|
fs.writeFileSync(jsonFilePath, JSON.stringify(plottingData, null, 2));
|
||||||
|
|
||||||
|
// Mise à jour de la BDD si on a un wallet_hash
|
||||||
|
const walletHash = plottingData.wallet_hash;
|
||||||
|
if (walletHash) {
|
||||||
|
db.run(`
|
||||||
|
INSERT INTO user_stats (wallet_hash, photo_count, last_upload)
|
||||||
|
VALUES (?, 1, CURRENT_TIMESTAMP)
|
||||||
|
ON CONFLICT(wallet_hash) DO UPDATE SET
|
||||||
|
photo_count = photo_count + 1,
|
||||||
|
last_upload = CURRENT_TIMESTAMP
|
||||||
|
`, [walletHash], function(err) {
|
||||||
|
if (err) {
|
||||||
|
console.error("Erreur lors de la mise à jour des stats :", err);
|
||||||
|
} else {
|
||||||
|
console.log(`Stats mises à jour pour le wallet_hash ${walletHash.substring(0, 8)}...`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Données reçues et sauvegardées:`);
|
||||||
|
console.log(`- Image: uploads/images/${req.file.filename}`);
|
||||||
|
console.log(`- JSON : uploads/data/${jsonFilename}`);
|
||||||
|
|
||||||
|
res.status(200).json({
|
||||||
|
message: 'Photo et données uploadées avec succès',
|
||||||
|
file: {
|
||||||
|
filename: req.file.filename,
|
||||||
|
url: `/uploads/images/${req.file.filename}`,
|
||||||
|
size: req.file.size
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
filename: jsonFilename
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors de l\'upload:', error);
|
||||||
|
res.status(500).json({ error: 'Erreur interne du serveur lors de l\'upload' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour récupérer toutes les photos disponibles
|
||||||
|
app.get('/api/photos', (req, res) => {
|
||||||
|
try {
|
||||||
|
fs.readdir(imagesDir, (err, files) => {
|
||||||
|
if (err) {
|
||||||
|
return res.status(500).json({ error: 'Impossible de lire le dossier des photos' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const photos = files.map(file => ({
|
||||||
|
filename: file,
|
||||||
|
url: `/uploads/images/${file}`
|
||||||
|
}));
|
||||||
|
|
||||||
|
res.status(200).json({ photos });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur serveur' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour récupérer les statistiques d'un wallet_hash
|
||||||
|
app.get('/api/stats/:wallet_hash', (req, res) => {
|
||||||
|
const walletHash = req.params.wallet_hash;
|
||||||
|
|
||||||
|
db.get('SELECT photo_count, last_upload FROM user_stats WHERE wallet_hash = ?', [walletHash], (err, row) => {
|
||||||
|
if (err) {
|
||||||
|
return res.status(500).json({ error: 'Erreur lors de la lecture des statistiques' });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
res.json({ status: 'ok', stats: row });
|
||||||
|
} else {
|
||||||
|
res.json({ status: 'ok', stats: { photo_count: 0, last_upload: null } });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour récupérer TOUS les contributeurs
|
||||||
|
app.get('/api/contributors', (req, res) => {
|
||||||
|
db.all('SELECT * FROM user_stats ORDER BY photo_count DESC', [], (err, rows) => {
|
||||||
|
if (err) {
|
||||||
|
return res.status(500).json({ error: 'Erreur lors de la lecture des contributeurs' });
|
||||||
|
}
|
||||||
|
res.json({ contributors: rows });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour récupérer toutes les données (Photos + JSON)
|
||||||
|
app.get('/api/all-data', (req, res) => {
|
||||||
|
try {
|
||||||
|
fs.readdir(imagesDir, (err, files) => {
|
||||||
|
if (err) {
|
||||||
|
return res.status(500).json({ error: 'Impossible de lire le dossier des photos' });
|
||||||
|
}
|
||||||
|
|
||||||
|
const allData = files.map(file => {
|
||||||
|
const baseName = path.parse(file).name;
|
||||||
|
const jsonPath = path.join(dataDir, `${baseName}.json`);
|
||||||
|
let plotting = null;
|
||||||
|
|
||||||
|
if (fs.existsSync(jsonPath)) {
|
||||||
|
try {
|
||||||
|
plotting = JSON.parse(fs.readFileSync(jsonPath, 'utf8'));
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`Erreur lecture JSON pour ${file}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
filename: file,
|
||||||
|
imageUrl: `/uploads/images/${file}`,
|
||||||
|
data: plotting
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(200).json({ data: allData });
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
res.status(500).json({ error: 'Erreur serveur' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour mettre à jour les données JSON d'une session
|
||||||
|
app.put('/api/data/:filename', (req, res) => {
|
||||||
|
const filename = req.params.filename;
|
||||||
|
const baseName = path.parse(filename).name;
|
||||||
|
const jsonPath = path.join(dataDir, `${baseName}.json`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(jsonPath)) {
|
||||||
|
return res.status(404).json({ error: 'Fichier JSON non trouvé' });
|
||||||
|
}
|
||||||
|
|
||||||
|
// On écrase le fichier avec les nouvelles données reçues
|
||||||
|
const newData = req.body;
|
||||||
|
fs.writeFileSync(jsonPath, JSON.stringify(newData, null, 2));
|
||||||
|
|
||||||
|
console.log(`Données mises à jour pour : ${baseName}.json`);
|
||||||
|
res.status(200).json({ message: 'Données mises à jour avec succès' });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors de la mise à jour du JSON:', error);
|
||||||
|
res.status(500).json({ error: 'Erreur serveur lors de la mise à jour' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour exporter toutes les données en ZIP
|
||||||
|
app.get('/api/export/zip', (req, res) => {
|
||||||
|
try {
|
||||||
|
const zip = new AdmZip();
|
||||||
|
|
||||||
|
// Ajouter les dossiers au ZIP
|
||||||
|
if (fs.existsSync(imagesDir)) zip.addLocalFolder(imagesDir, 'images');
|
||||||
|
if (fs.existsSync(dataDir)) zip.addLocalFolder(dataDir, 'data');
|
||||||
|
|
||||||
|
const zipFilename = `dataset_export_${Date.now()}.zip`;
|
||||||
|
const zipPath = path.join(exportsDir, zipFilename);
|
||||||
|
|
||||||
|
// Sauvegarder sur le disque
|
||||||
|
zip.writeZip(zipPath);
|
||||||
|
|
||||||
|
// Envoyer le fichier au client
|
||||||
|
res.download(zipPath, zipFilename, (err) => {
|
||||||
|
if (err) console.error("Erreur lors de l'envoi du ZIP:", err);
|
||||||
|
// Optionnel: supprimer le ZIP local après envoi si vous voulez gagner de la place
|
||||||
|
// fs.unlinkSync(zipPath);
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors de la création du ZIP:', error);
|
||||||
|
res.status(500).json({ error: 'Erreur lors de la création de l\'archive' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Route pour archiver et vider les dossiers uploads
|
||||||
|
app.post('/api/export/archive', (req, res) => {
|
||||||
|
try {
|
||||||
|
const archiveName = `archive_${new Date().toISOString().replace(/[:.]/g, '-')}`;
|
||||||
|
const archivePath = path.join(exportsDir, archiveName);
|
||||||
|
|
||||||
|
if (!fs.existsSync(archivePath)) {
|
||||||
|
fs.mkdirSync(archivePath, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fonction pour déplacer les fichiers
|
||||||
|
const moveFiles = (source, destSubDir) => {
|
||||||
|
const dest = path.join(archivePath, destSubDir);
|
||||||
|
if (!fs.existsSync(dest)) fs.mkdirSync(dest, { recursive: true });
|
||||||
|
|
||||||
|
const files = fs.readdirSync(source);
|
||||||
|
files.forEach(file => {
|
||||||
|
// Ne pas déplacer la base de données sqlite
|
||||||
|
if (file === 'database.sqlite') return;
|
||||||
|
|
||||||
|
const oldPath = path.join(source, file);
|
||||||
|
const newPath = path.join(dest, file);
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.renameSync(oldPath, newPath);
|
||||||
|
} catch (e) {
|
||||||
|
// Fallback si renameSync échoue (ex: disque différent)
|
||||||
|
fs.copyFileSync(oldPath, newPath);
|
||||||
|
fs.unlinkSync(oldPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
moveFiles(imagesDir, 'images');
|
||||||
|
moveFiles(dataDir, 'data');
|
||||||
|
|
||||||
|
res.json({ message: 'Données archivées avec succès', archive: archiveName });
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erreur lors de l\'archivage:', error);
|
||||||
|
res.status(500).json({ error: 'Erreur lors de l\'archivage des données' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Servir les fichiers statiques (pour pouvoir accéder aux photos via URL)
|
||||||
|
app.use('/uploads/images', express.static(imagesDir));
|
||||||
|
|
||||||
|
// Gestion des erreurs
|
||||||
|
app.use((err, req, res, next) => {
|
||||||
|
if (err instanceof multer.MulterError) {
|
||||||
|
if (err.code === 'LIMIT_FILE_SIZE') {
|
||||||
|
return res.status(400).json({ error: 'Le fichier est trop volumineux (limite 15MB)' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.error(err.stack);
|
||||||
|
res.status(500).json({ error: err.message || 'Une erreur inattendue est survenue' });
|
||||||
|
});
|
||||||
|
|
||||||
|
// Démarrer le serveur
|
||||||
|
app.listen(PORT, () => {
|
||||||
|
console.log(`=================================`);
|
||||||
|
console.log(`Serveur Backend IA démarré`);
|
||||||
|
console.log(`Port: ${PORT}`);
|
||||||
|
console.log(`Dossiers:`);
|
||||||
|
console.log(` - Images: ${imagesDir}`);
|
||||||
|
console.log(` - Data : ${dataDir}`);
|
||||||
|
console.log(` - Export: ${exportsDir}`);
|
||||||
|
console.log(`=================================`);
|
||||||
|
});
|
||||||
BIN
backendia/uploads/data/database.sqlite
Normal file
BIN
backendia/uploads/data/database.sqlite
Normal file
Binary file not shown.
@@ -18,6 +18,7 @@ import '../../services/score_calculator_service.dart';
|
|||||||
import '../../services/grouping_analyzer_service.dart';
|
import '../../services/grouping_analyzer_service.dart';
|
||||||
import '../../services/distortion_correction_service.dart';
|
import '../../services/distortion_correction_service.dart';
|
||||||
import '../../services/opencv_target_service.dart';
|
import '../../services/opencv_target_service.dart';
|
||||||
|
import '../../services/ai_export_service.dart';
|
||||||
|
|
||||||
enum AnalysisState { initial, loading, success, error }
|
enum AnalysisState { initial, loading, success, error }
|
||||||
|
|
||||||
@@ -688,6 +689,42 @@ class AnalysisProvider extends ChangeNotifier {
|
|||||||
_groupingResult = _groupingAnalyzerService.analyzeGrouping(_shots);
|
_groupingResult = _groupingAnalyzerService.analyzeGrouping(_shots);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Exporte l'image et le json vers le backend IA
|
||||||
|
Future<bool> exportToAiBackend() async {
|
||||||
|
if (_imagePath == null || _targetType == null) {
|
||||||
|
_errorMessage = "Impossible d'exporter : image ou type de cible manquant.";
|
||||||
|
notifyListeners();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Identifiant de session temporaire si non sauvegardée
|
||||||
|
final sessionId = _shots.isNotEmpty && _shots.first.sessionId.isNotEmpty
|
||||||
|
? _shots.first.sessionId
|
||||||
|
: 'session_${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
|
||||||
|
final service = AiExportService(); // Local instanciation for simplicity
|
||||||
|
|
||||||
|
_state = AnalysisState.loading;
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
final success = await service.exportData(
|
||||||
|
imagePath: _imagePath!,
|
||||||
|
sessionId: sessionId,
|
||||||
|
targetType: _targetType!,
|
||||||
|
targetCenterX: _targetCenterX,
|
||||||
|
targetCenterY: _targetCenterY,
|
||||||
|
targetRadius: _targetRadius,
|
||||||
|
shots: _shots,
|
||||||
|
);
|
||||||
|
|
||||||
|
_state = AnalysisState.success;
|
||||||
|
if (!success) {
|
||||||
|
_errorMessage = "Échec de l'export vers le serveur IA.";
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
/// Save the session
|
/// Save the session
|
||||||
Future<Session> saveSession({String? notes}) async {
|
Future<Session> saveSession({String? notes}) async {
|
||||||
if (_imagePath == null || _targetType == null) {
|
if (_imagePath == null || _targetType == null) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import '../../data/repositories/session_repository.dart';
|
|||||||
import '../../services/target_detection_service.dart';
|
import '../../services/target_detection_service.dart';
|
||||||
import '../../services/score_calculator_service.dart';
|
import '../../services/score_calculator_service.dart';
|
||||||
import '../../services/grouping_analyzer_service.dart';
|
import '../../services/grouping_analyzer_service.dart';
|
||||||
|
import '../../services/wallet_identity_service.dart';
|
||||||
import 'analysis_provider.dart';
|
import 'analysis_provider.dart';
|
||||||
import 'widgets/target_overlay.dart';
|
import 'widgets/target_overlay.dart';
|
||||||
import 'widgets/target_calibration.dart';
|
import 'widgets/target_calibration.dart';
|
||||||
@@ -133,6 +134,47 @@ class _AnalysisScreenContentState extends State<_AnalysisScreenContent> {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
FutureBuilder<bool>(
|
||||||
|
future: WalletIdentityService().isUploadEnabled(),
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
final isEnabled = snapshot.data ?? false;
|
||||||
|
if (!isEnabled) return const SizedBox.shrink();
|
||||||
|
|
||||||
|
return IconButton(
|
||||||
|
icon: const Icon(Icons.cloud_upload),
|
||||||
|
onPressed: () async {
|
||||||
|
final provider = context.read<AnalysisProvider>();
|
||||||
|
if (provider.state != AnalysisState.success) return;
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Exportation en cours...')),
|
||||||
|
);
|
||||||
|
|
||||||
|
final success = await provider.exportToAiBackend();
|
||||||
|
|
||||||
|
if (context.mounted) {
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
if (success) {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Export réussi vers le backend IA !'),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(provider.errorMessage ?? 'Erreur d\'export'),
|
||||||
|
backgroundColor: AppTheme.errorColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
tooltip: 'Exporter pour IA',
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.help_outline),
|
icon: const Icon(Icons.help_outline),
|
||||||
onPressed: () => _showHelpDialog(context),
|
onPressed: () => _showHelpDialog(context),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import '../history/history_screen.dart';
|
|||||||
import '../statistics/statistics_screen.dart';
|
import '../statistics/statistics_screen.dart';
|
||||||
import 'package:fl_chart/fl_chart.dart';
|
import 'package:fl_chart/fl_chart.dart';
|
||||||
import '../../data/models/session.dart';
|
import '../../data/models/session.dart';
|
||||||
|
import '../settings/settings_screen.dart';
|
||||||
import 'widgets/stats_card.dart';
|
import 'widgets/stats_card.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatefulWidget {
|
class HomeScreen extends StatefulWidget {
|
||||||
@@ -65,6 +66,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
onPressed: () => _navigateToHistory(context),
|
onPressed: () => _navigateToHistory(context),
|
||||||
tooltip: 'Historique',
|
tooltip: 'Historique',
|
||||||
),
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.settings),
|
||||||
|
onPressed: () => _navigateToSettings(context),
|
||||||
|
tooltip: 'Paramètres',
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
body: RefreshIndicator(
|
body: RefreshIndicator(
|
||||||
@@ -310,4 +316,11 @@ class _HomeScreenState extends State<HomeScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _navigateToSettings(BuildContext context) {
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (_) => const SettingsScreen()),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
339
lib/features/settings/settings_screen.dart
Normal file
339
lib/features/settings/settings_screen.dart
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import '../../core/constants/app_constants.dart';
|
||||||
|
import '../../core/theme/app_theme.dart';
|
||||||
|
import '../../services/wallet_identity_service.dart';
|
||||||
|
|
||||||
|
class SettingsScreen extends StatefulWidget {
|
||||||
|
const SettingsScreen({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SettingsScreen> createState() => _SettingsScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SettingsScreenState extends State<SettingsScreen> {
|
||||||
|
final WalletIdentityService _walletService = WalletIdentityService();
|
||||||
|
String? _identityPhrase;
|
||||||
|
int? _photoCount;
|
||||||
|
bool _isLoadingStats = false;
|
||||||
|
bool _isUploadEnabled = false;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_loadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _loadIdentity() async {
|
||||||
|
final phrase = await _walletService.getIdentityPhrase();
|
||||||
|
final isEnabled = await _walletService.isUploadEnabled();
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_identityPhrase = phrase;
|
||||||
|
_isUploadEnabled = isEnabled;
|
||||||
|
});
|
||||||
|
_fetchStats(phrase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _fetchStats(String phrase) async {
|
||||||
|
setState(() => _isLoadingStats = true);
|
||||||
|
try {
|
||||||
|
final phraseBytes = utf8.encode(phrase);
|
||||||
|
final walletHash = sha256.convert(phraseBytes).toString();
|
||||||
|
|
||||||
|
// Utilise 10.0.2.2 pour l'émulateur Android, sinon localhost
|
||||||
|
final baseUrl = Theme.of(context).platform == TargetPlatform.android
|
||||||
|
? 'http://10.0.2.2:3000'
|
||||||
|
: 'http://localhost:3000';
|
||||||
|
|
||||||
|
final response = await http.get(Uri.parse('$baseUrl/api/stats/$walletHash'));
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final data = jsonDecode(response.body);
|
||||||
|
if (mounted) {
|
||||||
|
setState(() {
|
||||||
|
_photoCount = data['stats']['photo_count'] ?? 0;
|
||||||
|
_isLoadingStats = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (mounted) setState(() => _isLoadingStats = false);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Erreur lors du chargement des statistiques: $e');
|
||||||
|
if (mounted) setState(() => _isLoadingStats = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _copyToClipboard() {
|
||||||
|
if (_identityPhrase != null) {
|
||||||
|
Clipboard.setData(ClipboardData(text: _identityPhrase!));
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Identité copiée dans le presse-papiers'),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showIdentityDialog() {
|
||||||
|
if (_identityPhrase == null) return;
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Votre Identité Unique', textAlign: TextAlign.center),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
const Icon(Icons.security, size: 48, color: AppTheme.primaryColor),
|
||||||
|
const SizedBox(height: 16),
|
||||||
|
const Text(
|
||||||
|
'Cette phrase de 15 mots vous identifie de manière unique. Ne la partagez qu\'en cas de besoin.',
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 14, color: Colors.grey),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.grey.withAlpha(20),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: AppTheme.primaryColor.withAlpha(100)),
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
_identityPhrase!,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
letterSpacing: 0.5,
|
||||||
|
height: 1.5,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Fermer'),
|
||||||
|
),
|
||||||
|
ElevatedButton.icon(
|
||||||
|
icon: const Icon(Icons.copy, size: 18),
|
||||||
|
label: const Text('Copier'),
|
||||||
|
onPressed: () {
|
||||||
|
_copyToClipboard();
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showOptInDisclaimer(bool value) {
|
||||||
|
if (!value) {
|
||||||
|
// Si on désactive, pas besoin de disclaimer, on le fait direct.
|
||||||
|
_walletService.setUploadEnabled(false);
|
||||||
|
setState(() {
|
||||||
|
_isUploadEnabled = false;
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: const Text('Participer à l\'entraînement IA', textAlign: TextAlign.center),
|
||||||
|
content: const Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Icon(Icons.psychology, size: 48, color: AppTheme.primaryColor),
|
||||||
|
SizedBox(height: 16),
|
||||||
|
Text(
|
||||||
|
'En activant cette option, vous acceptez d\'envoyer vos photos de cibles à notre serveur sécurisé.',
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
'🔒 Anonymat Garanti : L\'envoi est totalement anonymisé. Votre identité est remplacée par un hash cryptographique incassable.',
|
||||||
|
style: TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
|
SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
'🎁 Avantages Futurs : Votre contribution (Hash de Wallet) sera comptabilisée. Lors de la sortie publique de notre IA, les participants actifs recevront des fonctionnalités premium ou des badges exclusifs en récompense !',
|
||||||
|
style: TextStyle(fontSize: 13),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: const Text('Refuser', style: TextStyle(color: Colors.grey)),
|
||||||
|
),
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(backgroundColor: AppTheme.primaryColor),
|
||||||
|
onPressed: () {
|
||||||
|
_walletService.setUploadEnabled(true);
|
||||||
|
setState(() {
|
||||||
|
_isUploadEnabled = true;
|
||||||
|
});
|
||||||
|
Navigator.pop(context);
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Merci pour votre contribution !'),
|
||||||
|
backgroundColor: AppTheme.successColor,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: const Text('J\'accepte', style: TextStyle(color: Colors.white)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Paramètres'),
|
||||||
|
),
|
||||||
|
body: ListView(
|
||||||
|
padding: const EdgeInsets.all(AppConstants.defaultPadding),
|
||||||
|
children: [
|
||||||
|
_buildSectionHeader('Identité'),
|
||||||
|
_buildSettingsTile(
|
||||||
|
context: context,
|
||||||
|
icon: Icons.fingerprint,
|
||||||
|
title: 'Identité Wallet',
|
||||||
|
subtitle: _identityPhrase != null ? 'Phrase de 15 mots générée' : 'Génération en cours...',
|
||||||
|
onTap: _showIdentityDialog,
|
||||||
|
),
|
||||||
|
_buildSettingsTile(
|
||||||
|
context: context,
|
||||||
|
icon: Icons.color_lens_outlined,
|
||||||
|
title: 'Apparence',
|
||||||
|
subtitle: 'Thème clair/sombre (à venir)',
|
||||||
|
onTap: () {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Fonctionnalité en développement')),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
_buildSectionHeader('Configuration Serveur IA'),
|
||||||
|
Card(
|
||||||
|
elevation: 0,
|
||||||
|
color: Colors.transparent,
|
||||||
|
margin: const EdgeInsets.only(bottom: 8.0),
|
||||||
|
child: SwitchListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
||||||
|
title: const Text('Participer à l\'entraînement IA', style: TextStyle(fontWeight: FontWeight.w500)),
|
||||||
|
subtitle: const Text('Aidez-nous à améliorer la détection tout en gagnant des avantages', style: TextStyle(fontSize: 12)),
|
||||||
|
secondary: const Icon(Icons.psychology, color: AppTheme.textPrimary),
|
||||||
|
value: _isUploadEnabled,
|
||||||
|
activeColor: AppTheme.primaryColor,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
side: BorderSide(color: Colors.grey.withAlpha(50), width: 1),
|
||||||
|
),
|
||||||
|
onChanged: _showOptInDisclaimer,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (_isUploadEnabled)
|
||||||
|
_buildSettingsTile(
|
||||||
|
context: context,
|
||||||
|
icon: Icons.cloud_outlined,
|
||||||
|
title: 'Adresse du Serveur IA',
|
||||||
|
subtitle: 'http://localhost:3000/api/upload',
|
||||||
|
onTap: () {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(content: Text('Changement d\'adresse à venir')),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
if (_isUploadEnabled)
|
||||||
|
_buildSettingsTile(
|
||||||
|
context: context,
|
||||||
|
icon: Icons.data_usage,
|
||||||
|
title: 'Photos Exportées',
|
||||||
|
subtitle: _isLoadingStats
|
||||||
|
? 'Chargement...'
|
||||||
|
: (_photoCount != null ? '$_photoCount photos envoyées à l\'IA' : 'Non disponible'),
|
||||||
|
onTap: () {
|
||||||
|
if (_identityPhrase != null) {
|
||||||
|
_fetchStats(_identityPhrase!);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
_buildSectionHeader('À propos'),
|
||||||
|
_buildSettingsTile(
|
||||||
|
context: context,
|
||||||
|
icon: Icons.info_outline,
|
||||||
|
title: 'Version de l\'application',
|
||||||
|
subtitle: '1.0.0',
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
_buildSettingsTile(
|
||||||
|
context: context,
|
||||||
|
icon: Icons.privacy_tip_outlined,
|
||||||
|
title: 'Politique de confidentialité',
|
||||||
|
onTap: () {},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSectionHeader(String title) {
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 4.0),
|
||||||
|
child: Text(
|
||||||
|
title,
|
||||||
|
style: const TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: AppTheme.primaryColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildSettingsTile({
|
||||||
|
required BuildContext context,
|
||||||
|
required IconData icon,
|
||||||
|
required String title,
|
||||||
|
String? subtitle,
|
||||||
|
required VoidCallback onTap,
|
||||||
|
}) {
|
||||||
|
return Card(
|
||||||
|
elevation: 0,
|
||||||
|
color: Colors.transparent,
|
||||||
|
margin: const EdgeInsets.only(bottom: 8.0),
|
||||||
|
child: ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
||||||
|
leading: Icon(icon, color: AppTheme.textPrimary),
|
||||||
|
title: Text(title, style: const TextStyle(fontWeight: FontWeight.w500)),
|
||||||
|
subtitle: subtitle != null ? Text(subtitle, style: const TextStyle(fontSize: 12)) : null,
|
||||||
|
trailing: const Icon(Icons.chevron_right, color: Colors.grey),
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(12.0),
|
||||||
|
side: BorderSide(color: Colors.grey.withAlpha(50), width: 1),
|
||||||
|
),
|
||||||
|
onTap: onTap,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
146
lib/services/ai_export_service.dart
Normal file
146
lib/services/ai_export_service.dart
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:io';
|
||||||
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
|
import '../data/models/shot.dart';
|
||||||
|
import '../data/models/target_type.dart';
|
||||||
|
import 'wallet_identity_service.dart';
|
||||||
|
|
||||||
|
class AiExportService {
|
||||||
|
// Utilise 10.0.2.2 pour l'émulateur Android, sinon localhost.
|
||||||
|
// Pour un appareil physique, il faudra utiliser l'IP locale du PC (ex: 192.168.1.X).
|
||||||
|
static String get _defaultApiUrl {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
return 'http://10.0.2.2:3000/api/upload';
|
||||||
|
}
|
||||||
|
return 'http://localhost:3000/api/upload';
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extrait les informations de l'appareil
|
||||||
|
Future<Map<String, dynamic>> _getDeviceInfo() async {
|
||||||
|
final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin();
|
||||||
|
Map<String, dynamic> deviceData = {'model': 'Unknown', 'os': 'Unknown'};
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
final androidInfo = await deviceInfoPlugin.androidInfo;
|
||||||
|
deviceData['model'] = '${androidInfo.brand} ${androidInfo.model}';
|
||||||
|
deviceData['os'] = 'Android ${androidInfo.version.release}';
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
final iosInfo = await deviceInfoPlugin.iosInfo;
|
||||||
|
deviceData['model'] = iosInfo.name;
|
||||||
|
deviceData['os'] = '${iosInfo.systemName} ${iosInfo.systemVersion}';
|
||||||
|
} else if (Platform.isWindows) {
|
||||||
|
final windowsInfo = await deviceInfoPlugin.windowsInfo;
|
||||||
|
deviceData['model'] = 'Windows PC';
|
||||||
|
deviceData['os'] = 'Windows ${windowsInfo.majorVersion}.${windowsInfo.minorVersion}';
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Erreur lors de la récupération des infos appareil: $e');
|
||||||
|
}
|
||||||
|
|
||||||
|
return deviceData;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Exporte l'image et les données de plotting vers le serveur
|
||||||
|
Future<bool> exportData({
|
||||||
|
required String imagePath,
|
||||||
|
required String sessionId,
|
||||||
|
required TargetType targetType,
|
||||||
|
required double targetCenterX,
|
||||||
|
required double targetCenterY,
|
||||||
|
required double targetRadius,
|
||||||
|
required List<Shot> shots,
|
||||||
|
String? apiUrl,
|
||||||
|
}) async {
|
||||||
|
try {
|
||||||
|
final url = Uri.parse(apiUrl ?? _defaultApiUrl);
|
||||||
|
final request = http.MultipartRequest('POST', url);
|
||||||
|
|
||||||
|
// 1. Prepare image
|
||||||
|
final file = File(imagePath);
|
||||||
|
if (!await file.exists()) {
|
||||||
|
throw Exception('Le fichier image n\'existe pas');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read image metadata (approximate dimensions since decoding image can be heavy)
|
||||||
|
// On the frontend we usually have aspectRatio, here we use generic values if not available.
|
||||||
|
final deviceData = await _getDeviceInfo();
|
||||||
|
|
||||||
|
// We approximate the target corners from center and radius
|
||||||
|
// radius is relative (0 to 1). We need image width/height to get pixels.
|
||||||
|
// But we can just pass relative corners as well, or a normalized bounding box.
|
||||||
|
// Let's create normalized corners (0 to 1).
|
||||||
|
final corners = [
|
||||||
|
{"norm_x": targetCenterX - targetRadius, "norm_y": targetCenterY - targetRadius},
|
||||||
|
{"norm_x": targetCenterX + targetRadius, "norm_y": targetCenterY - targetRadius},
|
||||||
|
{"norm_x": targetCenterX + targetRadius, "norm_y": targetCenterY + targetRadius},
|
||||||
|
{"norm_x": targetCenterX - targetRadius, "norm_y": targetCenterY + targetRadius},
|
||||||
|
];
|
||||||
|
|
||||||
|
// Format the impacts
|
||||||
|
final formattedImpacts = shots.asMap().entries.map((entry) {
|
||||||
|
final index = entry.key;
|
||||||
|
final shot = entry.value;
|
||||||
|
return {
|
||||||
|
"id": index + 1,
|
||||||
|
"label": "bullet_hole",
|
||||||
|
"score": shot.score,
|
||||||
|
"coords": {
|
||||||
|
"norm_x": shot.x,
|
||||||
|
"norm_y": shot.y
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
// Get and hash the wallet identity
|
||||||
|
final walletService = WalletIdentityService();
|
||||||
|
final phrase = await walletService.getIdentityPhrase();
|
||||||
|
final phraseBytes = utf8.encode(phrase);
|
||||||
|
final walletHash = sha256.convert(phraseBytes).toString();
|
||||||
|
|
||||||
|
// Build JSON payload
|
||||||
|
final plottingJson = {
|
||||||
|
"session_id": sessionId,
|
||||||
|
"wallet_hash": walletHash,
|
||||||
|
"timestamp": DateTime.now().toIso8601String(),
|
||||||
|
"device_info": deviceData,
|
||||||
|
"target_metadata": {
|
||||||
|
"type": targetType.name,
|
||||||
|
"distance_meters": 25, // Default/placeholder
|
||||||
|
"weapon": "Unknown", // Default/placeholder
|
||||||
|
// The backend could extract exact width/height from the image.
|
||||||
|
},
|
||||||
|
"plotting": {
|
||||||
|
"target_corners": corners,
|
||||||
|
"impacts": formattedImpacts
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add fields to request
|
||||||
|
request.fields['plotting'] = jsonEncode(plottingJson);
|
||||||
|
|
||||||
|
// Add file
|
||||||
|
request.files.add(
|
||||||
|
await http.MultipartFile.fromPath('photo', imagePath),
|
||||||
|
);
|
||||||
|
|
||||||
|
// Send request
|
||||||
|
final response = await request.send();
|
||||||
|
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
final responseData = await response.stream.bytesToString();
|
||||||
|
print('Export réussi: $responseData');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
final errorData = await response.stream.bytesToString();
|
||||||
|
print('Erreur d\'export: ${response.statusCode} - $errorData');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Exception lors de l\'export: $e');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
112
lib/services/wallet_identity_service.dart
Normal file
112
lib/services/wallet_identity_service.dart
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
import 'dart:math';
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:crypto/crypto.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
|
class WalletIdentityService {
|
||||||
|
static const String _prefsKey = 'wallet_identity_phrase';
|
||||||
|
static const String _uploadEnabledKey = 'is_ai_upload_enabled';
|
||||||
|
|
||||||
|
// A standard list of 256 words (8 bits of entropy per word)
|
||||||
|
static const List<String> _wordList = [
|
||||||
|
// ... same as before
|
||||||
|
'abandon', 'ability', 'able', 'about', 'above', 'absent', 'absorb', 'abstract', 'absurd', 'abuse',
|
||||||
|
'access', 'accident', 'account', 'accuse', 'achieve', 'acid', 'acoustic', 'acquire', 'across', 'act',
|
||||||
|
'action', 'actor', 'actress', 'actual', 'adapt', 'add', 'addict', 'address', 'adjust', 'admit',
|
||||||
|
'adult', 'advance', 'advice', 'aerobic', 'affair', 'afford', 'afraid', 'again', 'age', 'agent',
|
||||||
|
'agree', 'ahead', 'aim', 'air', 'airport', 'aisle', 'alarm', 'album', 'alcohol', 'alert',
|
||||||
|
'alien', 'all', 'alley', 'allow', 'almost', 'alone', 'alpha', 'already', 'also', 'alter',
|
||||||
|
'always', 'amateur', 'amazing', 'among', 'amount', 'amused', 'analyst', 'anchor', 'ancient', 'anger',
|
||||||
|
'angle', 'angry', 'animal', 'ankle', 'announce', 'annual', 'another', 'answer', 'antenna', 'antique',
|
||||||
|
'anxiety', 'any', 'apart', 'apology', 'appear', 'apple', 'approve', 'april', 'arch', 'arctic',
|
||||||
|
'area', 'arena', 'argue', 'arm', 'armed', 'armor', 'army', 'around', 'arrange', 'arrest',
|
||||||
|
'arrive', 'arrow', 'art', 'artefact', 'artist', 'artwork', 'ask', 'aspect', 'assault', 'asset',
|
||||||
|
'assist', 'assume', 'asthma', 'athlete', 'atom', 'attack', 'attend', 'attitude', 'attract', 'auction',
|
||||||
|
'audit', 'august', 'aunt', 'author', 'auto', 'autumn', 'average', 'avocado', 'avoid', 'awake',
|
||||||
|
'aware', 'away', 'awesome', 'awful', 'awkward', 'axis', 'baby', 'bachelor', 'bacon', 'badge',
|
||||||
|
'bag', 'balance', 'balcony', 'ball', 'bamboo', 'banana', 'banner', 'bar', 'barely', 'bargain',
|
||||||
|
'barrel', 'base', 'basic', 'basket', 'battle', 'beach', 'bean', 'beauty', 'because', 'become',
|
||||||
|
'beef', 'before', 'begin', 'behave', 'behind', 'believe', 'below', 'belt', 'bench', 'benefit',
|
||||||
|
'best', 'betray', 'better', 'between', 'beyond', 'bicycle', 'bid', 'bike', 'bind', 'biology',
|
||||||
|
'bird', 'birth', 'bitter', 'black', 'blade', 'blame', 'blanket', 'blast', 'bleak', 'bless',
|
||||||
|
'blind', 'blood', 'blossom', 'blouse', 'blue', 'blur', 'blush', 'board', 'boat', 'body',
|
||||||
|
'boil', 'bomb', 'bone', 'bonus', 'book', 'boost', 'border', 'boring', 'borrow', 'boss',
|
||||||
|
'bottom', 'bounce', 'box', 'boy', 'bracket', 'brain', 'brand', 'brass', 'brave', 'bread',
|
||||||
|
'breeze', 'brick', 'bridge', 'brief', 'bright', 'bring', 'brisk', 'broccoli', 'broken', 'bronze',
|
||||||
|
'broom', 'brother', 'brown', 'brush', 'bubble', 'buddy', 'budget', 'buffalo', 'build', 'bulb',
|
||||||
|
'bulk', 'bullet', 'bundle', 'bunker', 'burden', 'burger', 'burst', 'bus', 'business', 'butter'
|
||||||
|
];
|
||||||
|
|
||||||
|
/// Vérifie si l'utilisateur a accepté l'envoi de données à l'IA
|
||||||
|
Future<bool> isUploadEnabled() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
return prefs.getBool(_uploadEnabledKey) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Active ou désactive l'envoi de données
|
||||||
|
Future<void> setUploadEnabled(bool enabled) async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
await prefs.setBool(_uploadEnabledKey, enabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Gets the unique 15-word identity phrase
|
||||||
|
Future<String> getIdentityPhrase() async {
|
||||||
|
final prefs = await SharedPreferences.getInstance();
|
||||||
|
|
||||||
|
// Check if we already generated it
|
||||||
|
final existingPhrase = prefs.getString(_prefsKey);
|
||||||
|
if (existingPhrase != null && existingPhrase.isNotEmpty) {
|
||||||
|
return existingPhrase;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate new phrase based on device ID
|
||||||
|
final phrase = await _generatePhraseFromDevice();
|
||||||
|
|
||||||
|
// Save for future use
|
||||||
|
await prefs.setString(_prefsKey, phrase);
|
||||||
|
|
||||||
|
return phrase;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<String> _generatePhraseFromDevice() async {
|
||||||
|
final deviceInfo = DeviceInfoPlugin();
|
||||||
|
String deviceId = 'unknown_device_${DateTime.now().millisecondsSinceEpoch}';
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
final androidInfo = await deviceInfo.androidInfo;
|
||||||
|
deviceId = androidInfo.id; // Unique Android ID
|
||||||
|
} else if (Platform.isIOS) {
|
||||||
|
final iosInfo = await deviceInfo.iosInfo;
|
||||||
|
deviceId = iosInfo.identifierForVendor ?? deviceId;
|
||||||
|
} else if (Platform.isWindows) {
|
||||||
|
final windowsInfo = await deviceInfo.windowsInfo;
|
||||||
|
deviceId = windowsInfo.deviceId;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('Erreur lecture device ID: $e');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a salt to the device ID
|
||||||
|
final salt = 'bully_app_wallet_salt_v1';
|
||||||
|
final bytes = utf8.encode(deviceId + salt);
|
||||||
|
final digest = sha256.convert(bytes);
|
||||||
|
|
||||||
|
// Use the hash to seed a random number generator
|
||||||
|
// We take the first 4 bytes of the hash as the seed
|
||||||
|
final seedBytes = digest.bytes.sublist(0, 4);
|
||||||
|
final seed = (seedBytes[0] << 24) | (seedBytes[1] << 16) | (seedBytes[2] << 8) | seedBytes[3];
|
||||||
|
|
||||||
|
final random = Random(seed);
|
||||||
|
|
||||||
|
List<String> phraseWords = [];
|
||||||
|
for (int i = 0; i < 15; i++) {
|
||||||
|
final randomIndex = random.nextInt(_wordList.length);
|
||||||
|
phraseWords.add(_wordList[randomIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return phraseWords.join(' ');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,12 +7,12 @@ import Foundation
|
|||||||
|
|
||||||
import device_info_plus
|
import device_info_plus
|
||||||
import file_selector_macos
|
import file_selector_macos
|
||||||
import path_provider_foundation
|
import shared_preferences_foundation
|
||||||
import sqflite_darwin
|
import sqflite_darwin
|
||||||
|
|
||||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||||
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
|
||||||
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
|
||||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||||
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
|
||||||
}
|
}
|
||||||
|
|||||||
216
pubspec.lock
216
pubspec.lock
@@ -5,18 +5,26 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: archive
|
name: archive
|
||||||
sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
|
sha256: a96e8b390886ee8abb49b7bd3ac8df6f451c621619f52a26e815fdcf568959ff
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.7"
|
version: "4.0.9"
|
||||||
|
args:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: args
|
||||||
|
sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.7.0"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: async
|
name: async
|
||||||
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
|
sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.13.0"
|
version: "2.13.1"
|
||||||
boolean_selector:
|
boolean_selector:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -74,7 +82,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.3.5+2"
|
version: "0.3.5+2"
|
||||||
crypto:
|
crypto:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: crypto
|
name: crypto
|
||||||
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf
|
||||||
@@ -85,18 +93,18 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: cupertino_icons
|
name: cupertino_icons
|
||||||
sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
|
sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.8"
|
version: "1.0.9"
|
||||||
dartcv4:
|
dartcv4:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: dartcv4
|
name: dartcv4
|
||||||
sha256: "43dba49162662f3b6e3daf5a95d071429365e2f1ada67d412b851fc9be442e58"
|
sha256: "5764d13550055da3bb35ca28e6866b837579dfb4b594582b7a7753785ca5dfef"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.1+1"
|
version: "2.2.1+4"
|
||||||
device_info_plus:
|
device_info_plus:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -223,10 +231,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: flutter_plugin_android_lifecycle
|
name: flutter_plugin_android_lifecycle
|
||||||
sha256: ee8068e0e1cd16c4a82714119918efdeed33b3ba7772c54b5d094ab53f9b7fd1
|
sha256: "38d1c268de9097ff59cf0e844ac38759fc78f76836d37edad06fa21e182055a0"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.33"
|
version: "2.0.34"
|
||||||
flutter_test:
|
flutter_test:
|
||||||
dependency: "direct dev"
|
dependency: "direct dev"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -257,12 +265,12 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: hooks
|
name: hooks
|
||||||
sha256: "5d309c86e7ce34cd8e37aa71cb30cb652d3829b900ab145e4d9da564b31d59f7"
|
sha256: "025f060e86d2d4c3c47b56e33caf7f93bf9283340f26d23424ebcfccf34f621e"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.0.3"
|
||||||
http:
|
http:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: http
|
name: http
|
||||||
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
|
sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412"
|
||||||
@@ -281,26 +289,26 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: image
|
name: image
|
||||||
sha256: "492bd52f6c4fbb6ee41f781ff27765ce5f627910e1e0cbecfa3d9add5562604c"
|
sha256: f9881ff4998044947ec38d098bc7c8316ae1186fa786eddffdb867b9bc94dfce
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.7.2"
|
version: "4.8.0"
|
||||||
image_picker:
|
image_picker:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: image_picker
|
name: image_picker
|
||||||
sha256: "784210112be18ea55f69d7076e2c656a4e24949fa9e76429fe53af0c0f4fa320"
|
sha256: "91c025426c2881c551100bce834e201c835a170151545f58d17da5180ca7d9ac"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.1"
|
version: "1.2.2"
|
||||||
image_picker_android:
|
image_picker_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: image_picker_android
|
name: image_picker_android
|
||||||
sha256: "518a16108529fc18657a3e6dde4a043dc465d16596d20ab2abd49a4cac2e703d"
|
sha256: d5b3e1774af29c9ab00103afb0d4614070f924d2e0057ac867ec98800114793f
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.8.13+13"
|
version: "0.8.13+17"
|
||||||
image_picker_for_web:
|
image_picker_for_web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -357,6 +365,22 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.20.2"
|
version: "0.20.2"
|
||||||
|
jni:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: jni
|
||||||
|
sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
|
jni_flutter:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: jni_flutter
|
||||||
|
sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
leak_tracker:
|
leak_tracker:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -385,10 +409,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: lints
|
name: lints
|
||||||
sha256: a5e2b223cb7c9c8efdc663ef484fdd95bb243bff242ef5b13e26883547fce9a0
|
sha256: "12f842a479589fea194fe5c5a3095abc7be0c1f2ddfa9a0e76aed1dbd26a87df"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.0"
|
version: "6.1.0"
|
||||||
logging:
|
logging:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -433,18 +457,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: native_toolchain_c
|
name: native_toolchain_c
|
||||||
sha256: "89e83885ba09da5fdf2cdacc8002a712ca238c28b7f717910b34bcd27b0d03ac"
|
sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.17.4"
|
version: "0.17.6"
|
||||||
native_toolchain_cmake:
|
native_toolchain_cmake:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: native_toolchain_cmake
|
name: native_toolchain_cmake
|
||||||
sha256: fe40e8483183ced98e851e08a9cd2a547fd412cccab98277aa23f2377e43d66f
|
sha256: cd4865568c57f03c7ab1f138cc5032c5f77825d27083d6f5a3e9bbb3e8014a87
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.4"
|
version: "0.2.5"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -453,14 +477,30 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
objective_c:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: objective_c
|
||||||
|
sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "9.3.0"
|
||||||
opencv_dart:
|
opencv_dart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: opencv_dart
|
name: opencv_dart
|
||||||
sha256: c2b7cc614cad69c2857e9b684e3066af662a03fe7100f4dc9a630e81ad42103a
|
sha256: b50ea4788e6d61df6369874e0244445d98ef9210dbb90b8d3c1df198b4ee2333
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.1+1"
|
version: "2.2.1+4"
|
||||||
|
package_config:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: package_config
|
||||||
|
sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.0"
|
||||||
path:
|
path:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -481,18 +521,18 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_android
|
name: path_provider_android
|
||||||
sha256: f2c65e21139ce2c3dad46922be8272bb5963516045659e71bb16e151c93b580e
|
sha256: "69cbd515a62b94d32a7944f086b2f82b4ac40a1d45bebfc00813a430ab2dabcd"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.22"
|
version: "2.3.1"
|
||||||
path_provider_foundation:
|
path_provider_foundation:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: path_provider_foundation
|
name: path_provider_foundation
|
||||||
sha256: "6d13aece7b3f5c5a9731eaf553ff9dcbc2eff41087fd2df587fd0fed9a3eb0c4"
|
sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.1"
|
version: "2.6.0"
|
||||||
path_provider_linux:
|
path_provider_linux:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -569,10 +609,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: petitparser
|
name: petitparser
|
||||||
sha256: "1a97266a94f7350d30ae522c0af07890c70b8e62c71e8e3920d1db4d23c057d1"
|
sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.1"
|
version: "7.0.2"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -593,10 +633,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: posix
|
name: posix
|
||||||
sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
|
sha256: "185ef7606574f789b40f289c233efa52e96dead518aed988e040a10737febb07"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.3"
|
version: "6.5.0"
|
||||||
provider:
|
provider:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@@ -613,6 +653,70 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.2.0"
|
version: "2.2.0"
|
||||||
|
record_use:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: record_use
|
||||||
|
sha256: "2551bd8eecfe95d14ae75f6021ad0248be5c27f138c2ec12fcb52b500b3ba1ed"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.0"
|
||||||
|
shared_preferences:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: shared_preferences
|
||||||
|
sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.5"
|
||||||
|
shared_preferences_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_android
|
||||||
|
sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.23"
|
||||||
|
shared_preferences_foundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_foundation
|
||||||
|
sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.5.6"
|
||||||
|
shared_preferences_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_linux
|
||||||
|
sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
|
shared_preferences_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_platform_interface
|
||||||
|
sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.2"
|
||||||
|
shared_preferences_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_web
|
||||||
|
sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.3"
|
||||||
|
shared_preferences_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: shared_preferences_windows
|
||||||
|
sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -622,42 +726,42 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: source_span
|
name: source_span
|
||||||
sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
|
sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.10.1"
|
version: "1.10.2"
|
||||||
sqflite:
|
sqflite:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: sqflite
|
name: sqflite
|
||||||
sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03
|
sha256: "564cfed0746fe53140c23b70b308e045c3b31f17778f2f326ccb7d804ea0250a"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2"
|
version: "2.4.2+1"
|
||||||
sqflite_android:
|
sqflite_android:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: sqflite_android
|
name: sqflite_android
|
||||||
sha256: ecd684501ebc2ae9a83536e8b15731642b9570dc8623e0073d227d0ee2bfea88
|
sha256: "881e28efdcc9950fd8e9bb42713dcf1103e62a2e7168f23c9338d82db13dec40"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.2+2"
|
version: "2.4.2+3"
|
||||||
sqflite_common:
|
sqflite_common:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: sqflite_common
|
name: sqflite_common
|
||||||
sha256: "6ef422a4525ecc601db6c0a2233ff448c731307906e92cabc9ba292afaae16a6"
|
sha256: f8a08a13fb8f0f8c590df89d745000bed44a673ed94bac846739e1a016875c21
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.5.6"
|
version: "2.5.7"
|
||||||
sqflite_common_ffi:
|
sqflite_common_ffi:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: sqflite_common_ffi
|
name: sqflite_common_ffi
|
||||||
sha256: c59fcdc143839a77581f7a7c4de018e53682408903a0a0800b95ef2dc4033eff
|
sha256: cd0c7f7de39a08f2d54ef144d9058c46eca8461879aaa648025643455c1e5a20
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.4.0+2"
|
version: "2.4.0+3"
|
||||||
sqflite_darwin:
|
sqflite_darwin:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -678,10 +782,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: sqlite3
|
name: sqlite3
|
||||||
sha256: "00e5e65f8e9b556ed3d999ad310881c956ffb656ed96bea487a4c50ffdff6d14"
|
sha256: "56da3e13ed7d28a66f930aa2b2b29db6736a233f08283326e96321dd812030f5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.3.1"
|
||||||
stack_trace:
|
stack_trace:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -710,10 +814,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: synchronized
|
name: synchronized
|
||||||
sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0
|
sha256: "63896c27e81b28f8cb4e69ead0d3e8f03f1d1e5fc531a3e579cabed6a2c7c9e5"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.4.0"
|
version: "3.4.0+1"
|
||||||
term_glyph:
|
term_glyph:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -742,10 +846,10 @@ packages:
|
|||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: uuid
|
name: uuid
|
||||||
sha256: a11b666489b1954e01d992f3d601b1804a33937b5a8fe677bd26b8a9f96f96e8
|
sha256: "1fef9e8e11e2991bb773070d4656b7bd5d850967a2456cfc83cf47925ba79489"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.5.2"
|
version: "4.5.3"
|
||||||
vector_math:
|
vector_math:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -758,10 +862,10 @@ packages:
|
|||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: vm_service
|
name: vm_service
|
||||||
sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60"
|
sha256: "0016aef94fc66495ac78af5859181e3f3bf2026bd8eecc72b9565601e19ab360"
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "15.0.2"
|
version: "15.2.0"
|
||||||
web:
|
web:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -811,5 +915,5 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "3.1.3"
|
version: "3.1.3"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.10.0 <4.0.0"
|
dart: ">=3.11.0 <4.0.0"
|
||||||
flutter: ">=3.38.1"
|
flutter: ">=3.38.4"
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ dependencies:
|
|||||||
# Image processing for impact detection
|
# Image processing for impact detection
|
||||||
image: ^4.1.7
|
image: ^4.1.7
|
||||||
permission_handler: ^12.0.1
|
permission_handler: ^12.0.1
|
||||||
|
http: ^1.6.0
|
||||||
device_info_plus: ^13.1.0
|
device_info_plus: ^13.1.0
|
||||||
|
shared_preferences: ^2.5.5
|
||||||
|
crypto: ^3.0.7
|
||||||
|
|
||||||
# Machine Learning for YOLOv8
|
# Machine Learning for YOLOv8
|
||||||
# tflite_flutter: ^0.11.0
|
# tflite_flutter: ^0.11.0
|
||||||
|
|||||||
Reference in New Issue
Block a user