fixed bug with logistics

This commit is contained in:
GotthardG
2024-12-11 10:10:43 +01:00
parent 5488df4318
commit 9160339961
14 changed files with 4497 additions and 5 deletions

View File

@ -167,3 +167,14 @@ class SampleEvent(Base):
timestamp = Column(DateTime, default=datetime.utcnow) timestamp = Column(DateTime, default=datetime.utcnow)
sample = relationship("Sample", back_populates="events") sample = relationship("Sample", back_populates="events")
#class PuckEvent(Base):
# __tablename__ = "sample_events"
#
# id = Column(Integer, primary_key=True, index=True)
# puck_id = Column(Integer, ForeignKey('puck.id'))
# tell_position = Column(String(255), nullable=True)
# event_type = Column(String(255), index=True)
# timestamp = Column(DateTime, default=datetime.utcnow)
#
# sample = relationship("Sample", back_populates="events")

View File

@ -290,7 +290,7 @@ class LogisticsEventCreate(BaseModel):
transaction_type: str transaction_type: str
class SlotSchema(BaseModel): class SlotSchema(BaseModel):
id: str id: int
qr_code: str qr_code: str
label: str label: str
qr_base: Optional[str] qr_base: Optional[str]

View File

@ -1,2 +0,0 @@
VITE_OPENAPI_BASE_DEV=https://127.0.0.1:8000
VITE_OPENAPI_BASE_TEST=https://mx-aare-test.psi.ch:8000

View File

@ -2,7 +2,6 @@ import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react'; import react from '@vitejs/plugin-react';
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
// Charge les variables du .env correspondant au mode
const env = loadEnv(mode, process.cwd(), ''); const env = loadEnv(mode, process.cwd(), '');
console.log(`Active mode: ${mode}`); console.log(`Active mode: ${mode}`);

50
logistics/README.md Normal file
View File

@ -0,0 +1,50 @@
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## Expanding the ESLint configuration
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
- Configure the top-level `parserOptions` property like this:
```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:
```js
// eslint.config.js
import react from 'eslint-plugin-react'
export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
})
```

View File

@ -0,0 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
export default tseslint.config(
{ ignores: ['dist'] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
},
)

4280
logistics/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

42
logistics/package.json Normal file
View File

@ -0,0 +1,42 @@
{
"name": "my-vite-project",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"lint": "eslint .",
"preview": "vite preview",
"start-dev": "vite --mode dev",
"start-test": "vite --mode test"
},
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^6.1.6",
"@mui/material": "^6.1.6",
"@vitejs/plugin-react": "^4.3.3",
"date-fns": "^4.1.0",
"moment": "^2.30.1",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-qr-code": "^2.0.15",
"react-qr-scanner": "^1.0.0-alpha.11",
"styled-components": "^6.1.13"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/node": "^22.10.1",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^9.13.0",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-react-refresh": "^0.4.14",
"globals": "^15.11.0",
"typescript": "~5.6.2",
"typescript-eslint": "^8.11.0",
"vite": "^5.4.11"
}
}

View File

@ -91,7 +91,8 @@ const LogisticsView: React.FC = () => {
// Reference to the audio element // Reference to the audio element
const audioRef = useRef<HTMLAudioElement | null>(null); const audioRef = useRef<HTMLAudioElement | null>(null);
OpenAPI.BASE = 'https://localhost:8000'; OpenAPI.BASE = import.meta.env.VITE_OPENAPI_BASE || 'https://127.0.0.1:8000';
console.log('OpenAPI Base URL:', OpenAPI.BASE);
const fetchDewarsAndSlots = async () => { const fetchDewarsAndSlots = async () => {
try { try {

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["src"]
}

11
logistics/tsconfig.json Normal file
View File

@ -0,0 +1,11 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
],
"include": [
"src",
"react-qr-reader.d.ts"
]
}

View File

@ -0,0 +1,24 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2022",
"lib": ["ES2023"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": ["vite.config.ts"]
}

View File

@ -0,0 +1 @@
{"root":["./src/app.tsx","./src/main.tsx","./src/react-qr-reader.d.ts","./src/vite-env.d.ts","./src/components/modal.tsx","./src/components/scannermodal.tsx","./src/components/slots.tsx","./src/components/storage.tsx","./src/pages/logisticsview.tsx"],"errors":true,"version":"5.6.3"}

21
logistics/vite.config.ts Normal file
View File

@ -0,0 +1,21 @@
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
console.log(`Active mode: ${mode}`);
console.log('Environment variable loaded:', env);
return {
plugins: [react()],
server: {
https: {
key: env.VITE_SSL_KEY_PATH,
cert: env.VITE_SSL_CERT_PATH,
},
host: true,
port: 3000,
},
};
});