(llm-first): context budget, validation, and eval harness, orchestration general-prompt
This commit is contained in:
@@ -1,7 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
.git
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
npm-debug.log*
|
||||
@@ -2,4 +2,3 @@ VITE_API_URL=http://localhost:3000
|
||||
VITE_KEYCLOAK_URL=https://sso.greact.ru
|
||||
VITE_KEYCLOAK_REALM=toir
|
||||
VITE_KEYCLOAK_CLIENT_ID=toir-frontend
|
||||
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: { browser: true, es2020: true },
|
||||
extends: [
|
||||
'eslint:recommended',
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:react-hooks/recommended',
|
||||
],
|
||||
ignorePatterns: ['dist', '.eslintrc.cjs'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
plugins: ['react-refresh'],
|
||||
rules: {
|
||||
'react-refresh/only-export-components': [
|
||||
'warn',
|
||||
{ allowConstantExport: true },
|
||||
],
|
||||
},
|
||||
}
|
||||
28
client/.gitignore
vendored
28
client/.gitignore
vendored
@@ -1,32 +1,22 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Build
|
||||
dist/
|
||||
dist-ssr/
|
||||
|
||||
# Environment
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
*.local
|
||||
|
||||
# Logs
|
||||
logs/
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# OS files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
node_modules
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Editor / IDE
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
.idea/
|
||||
.idea
|
||||
.DS_Store
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
FROM node:20-alpine AS build
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
RUN npm ci
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG VITE_API_URL
|
||||
ARG VITE_KEYCLOAK_URL
|
||||
ARG VITE_KEYCLOAK_REALM
|
||||
ARG VITE_KEYCLOAK_CLIENT_ID
|
||||
|
||||
ENV VITE_API_URL=$VITE_API_URL
|
||||
ENV VITE_KEYCLOAK_URL=$VITE_KEYCLOAK_URL
|
||||
ENV VITE_KEYCLOAK_REALM=$VITE_KEYCLOAK_REALM
|
||||
ENV VITE_KEYCLOAK_CLIENT_ID=$VITE_KEYCLOAK_CLIENT_ID
|
||||
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:1.27-alpine AS runtime
|
||||
|
||||
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
|
||||
EXPOSE 80
|
||||
@@ -4,27 +4,70 @@ This template provides a minimal setup to get React working in Vite with HMR and
|
||||
|
||||
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
|
||||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
|
||||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
|
||||
|
||||
## React Compiler
|
||||
|
||||
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
||||
|
||||
## 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:
|
||||
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
||||
|
||||
```js
|
||||
export default {
|
||||
// other rules...
|
||||
parserOptions: {
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
project: ['./tsconfig.json', './tsconfig.node.json'],
|
||||
tsconfigRootDir: __dirname,
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
|
||||
// Remove tseslint.configs.recommended and replace with this
|
||||
tseslint.configs.recommendedTypeChecked,
|
||||
// Alternatively, use this for stricter rules
|
||||
tseslint.configs.strictTypeChecked,
|
||||
// Optionally, add this for stylistic rules
|
||||
tseslint.configs.stylisticTypeChecked,
|
||||
|
||||
// Other configs...
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
}
|
||||
])
|
||||
```
|
||||
|
||||
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
||||
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
||||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
||||
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
||||
|
||||
```js
|
||||
// eslint.config.js
|
||||
import reactX from 'eslint-plugin-react-x'
|
||||
import reactDom from 'eslint-plugin-react-dom'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
// Other configs...
|
||||
// Enable lint rules for React
|
||||
reactX.configs['recommended-typescript'],
|
||||
// Enable lint rules for React DOM
|
||||
reactDom.configs.recommended,
|
||||
],
|
||||
languageOptions: {
|
||||
parserOptions: {
|
||||
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
||||
tsconfigRootDir: import.meta.dirname,
|
||||
},
|
||||
// other options...
|
||||
},
|
||||
},
|
||||
])
|
||||
```
|
||||
|
||||
23
client/eslint.config.js
Normal file
23
client/eslint.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
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'
|
||||
import { defineConfig, globalIgnores } from 'eslint/config'
|
||||
|
||||
export default defineConfig([
|
||||
globalIgnores(['dist']),
|
||||
{
|
||||
files: ['**/*.{ts,tsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
ecmaVersion: 2020,
|
||||
globals: globals.browser,
|
||||
},
|
||||
},
|
||||
])
|
||||
@@ -2,9 +2,9 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Vite + React + TS</title>
|
||||
<title>client</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
proxy_pass http://toir-server:3000/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location = /healthz {
|
||||
access_log off;
|
||||
add_header Content-Type text/plain;
|
||||
return 200 'ok';
|
||||
}
|
||||
}
|
||||
2911
client/package-lock.json
generated
2911
client/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -6,29 +6,31 @@
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
||||
"lint": "eslint .",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.14.0",
|
||||
"@emotion/styled": "^11.14.1",
|
||||
"@mui/material": "^7.3.9",
|
||||
"@mui/icons-material": "^7.3.5",
|
||||
"@mui/material": "^7.3.5",
|
||||
"keycloak-js": "^26.2.3",
|
||||
"ra-data-simple-rest": "^5.14.4",
|
||||
"react": "^18.2.0",
|
||||
"react-admin": "^5.14.4",
|
||||
"react-dom": "^18.2.0"
|
||||
"react": "^19.2.4",
|
||||
"react-admin": "^5.14.5",
|
||||
"react-dom": "^19.2.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.2.55",
|
||||
"@types/react-dom": "^18.2.19",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"eslint": "^8.56.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.5",
|
||||
"typescript": "^5.2.2",
|
||||
"vite": "^5.1.0"
|
||||
"@eslint/js": "^9.39.4",
|
||||
"@types/node": "^24.12.0",
|
||||
"@types/react": "^19.2.14",
|
||||
"@types/react-dom": "^19.2.3",
|
||||
"@vitejs/plugin-react": "^6.0.1",
|
||||
"eslint": "^9.39.4",
|
||||
"eslint-plugin-react-hooks": "^7.0.1",
|
||||
"eslint-plugin-react-refresh": "^0.5.2",
|
||||
"globals": "^17.4.0",
|
||||
"typescript": "~5.9.3",
|
||||
"typescript-eslint": "^8.57.0",
|
||||
"vite": "^8.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
1
client/public/favicon.svg
Normal file
1
client/public/favicon.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 9.3 KiB |
24
client/public/icons.svg
Normal file
24
client/public/icons.svg
Normal file
@@ -0,0 +1,24 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<symbol id="bluesky-icon" viewBox="0 0 16 17">
|
||||
<g clip-path="url(#bluesky-clip)"><path fill="#08060d" d="M7.75 7.735c-.693-1.348-2.58-3.86-4.334-5.097-1.68-1.187-2.32-.981-2.74-.79C.188 2.065.1 2.812.1 3.251s.241 3.602.398 4.13c.52 1.744 2.367 2.333 4.07 2.145-2.495.37-4.71 1.278-1.805 4.512 3.196 3.309 4.38-.71 4.987-2.746.608 2.036 1.307 5.91 4.93 2.746 2.72-2.746.747-4.143-1.747-4.512 1.702.189 3.55-.4 4.07-2.145.156-.528.397-3.691.397-4.13s-.088-1.186-.575-1.406c-.42-.19-1.06-.395-2.741.79-1.755 1.24-3.64 3.752-4.334 5.099"/></g>
|
||||
<defs><clipPath id="bluesky-clip"><path fill="#fff" d="M.1.85h15.3v15.3H.1z"/></clipPath></defs>
|
||||
</symbol>
|
||||
<symbol id="discord-icon" viewBox="0 0 20 19">
|
||||
<path fill="#08060d" d="M16.224 3.768a14.5 14.5 0 0 0-3.67-1.153c-.158.286-.343.67-.47.976a13.5 13.5 0 0 0-4.067 0c-.128-.306-.317-.69-.476-.976A14.4 14.4 0 0 0 3.868 3.77C1.546 7.28.916 10.703 1.231 14.077a14.7 14.7 0 0 0 4.5 2.306q.545-.748.965-1.587a9.5 9.5 0 0 1-1.518-.74q.191-.14.372-.293c2.927 1.369 6.107 1.369 8.999 0q.183.152.372.294-.723.437-1.52.74.418.838.963 1.588a14.6 14.6 0 0 0 4.504-2.308c.37-3.911-.63-7.302-2.644-10.309m-9.13 8.234c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.894 0 1.614.82 1.599 1.82.001 1-.705 1.82-1.6 1.82m5.91 0c-.878 0-1.599-.82-1.599-1.82 0-.998.705-1.82 1.6-1.82.893 0 1.614.82 1.599 1.82 0 1-.706 1.82-1.6 1.82"/>
|
||||
</symbol>
|
||||
<symbol id="documentation-icon" viewBox="0 0 21 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="m15.5 13.333 1.533 1.322c.645.555.967.833.967 1.178s-.322.623-.967 1.179L15.5 18.333m-3.333-5-1.534 1.322c-.644.555-.966.833-.966 1.178s.322.623.966 1.179l1.534 1.321"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M17.167 10.836v-4.32c0-1.41 0-2.117-.224-2.68-.359-.906-1.118-1.621-2.08-1.96-.599-.21-1.349-.21-2.848-.21-2.623 0-3.935 0-4.983.369-1.684.591-3.013 1.842-3.641 3.428C3 6.449 3 7.684 3 10.154v2.122c0 2.558 0 3.838.706 4.726q.306.383.713.671c.76.536 1.79.64 3.581.66"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M3 10a2.78 2.78 0 0 1 2.778-2.778c.555 0 1.209.097 1.748-.047.48-.129.854-.503.982-.982.145-.54.048-1.194.048-1.749a2.78 2.78 0 0 1 2.777-2.777"/>
|
||||
</symbol>
|
||||
<symbol id="github-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M9.356 1.85C5.05 1.85 1.57 5.356 1.57 9.694a7.84 7.84 0 0 0 5.324 7.44c.387.079.528-.168.528-.376 0-.182-.013-.805-.013-1.454-2.165.467-2.616-.935-2.616-.935-.349-.91-.864-1.143-.864-1.143-.71-.48.051-.48.051-.48.787.051 1.2.805 1.2.805.695 1.194 1.817.857 2.268.649.064-.507.27-.857.49-1.052-1.728-.182-3.545-.857-3.545-3.87 0-.857.31-1.558.8-2.104-.078-.195-.349-1 .077-2.078 0 0 .657-.208 2.14.805a7.5 7.5 0 0 1 1.946-.26c.657 0 1.328.092 1.946.26 1.483-1.013 2.14-.805 2.14-.805.426 1.078.155 1.883.078 2.078.502.546.799 1.247.799 2.104 0 3.013-1.818 3.675-3.558 3.87.284.247.528.714.528 1.454 0 1.052-.012 1.896-.012 2.156 0 .208.142.455.528.377a7.84 7.84 0 0 0 5.324-7.441c.013-4.338-3.48-7.844-7.773-7.844" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
<symbol id="social-icon" viewBox="0 0 20 20">
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M12.5 6.667a4.167 4.167 0 1 0-8.334 0 4.167 4.167 0 0 0 8.334 0"/>
|
||||
<path fill="none" stroke="#aa3bff" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.35" d="M2.5 16.667a5.833 5.833 0 0 1 8.75-5.053m3.837.474.513 1.035c.07.144.257.282.414.309l.93.155c.596.1.736.536.307.965l-.723.73a.64.64 0 0 0-.152.531l.207.903c.164.715-.213.991-.84.618l-.872-.52a.63.63 0 0 0-.577 0l-.872.52c-.624.373-1.003.094-.84-.618l.207-.903a.64.64 0 0 0-.152-.532l-.723-.729c-.426-.43-.289-.864.306-.964l.93-.156a.64.64 0 0 0 .412-.31l.513-1.034c.28-.562.735-.562 1.012 0"/>
|
||||
</symbol>
|
||||
<symbol id="x-icon" viewBox="0 0 19 19">
|
||||
<path fill="#08060d" fill-rule="evenodd" d="M1.893 1.98c.052.072 1.245 1.769 2.653 3.77l2.892 4.114c.183.261.333.48.333.486s-.068.089-.152.183l-.522.593-.765.867-3.597 4.087c-.375.426-.734.834-.798.905a1 1 0 0 0-.118.148c0 .01.236.017.664.017h.663l.729-.83c.4-.457.796-.906.879-.999a692 692 0 0 0 1.794-2.038c.034-.037.301-.34.594-.675l.551-.624.345-.392a7 7 0 0 1 .34-.374c.006 0 .93 1.306 2.052 2.903l2.084 2.965.045.063h2.275c1.87 0 2.273-.003 2.266-.021-.008-.02-1.098-1.572-3.894-5.547-2.013-2.862-2.28-3.246-2.273-3.266.008-.019.282-.332 2.085-2.38l2-2.274 1.567-1.782c.022-.028-.016-.03-.65-.03h-.674l-.3.342a871 871 0 0 1-1.782 2.025c-.067.075-.405.458-.75.852a100 100 0 0 1-.803.91c-.148.172-.299.344-.99 1.127-.304.343-.32.358-.345.327-.015-.019-.904-1.282-1.976-2.808L6.365 1.85H1.8zm1.782.91 8.078 11.294c.772 1.08 1.413 1.973 1.425 1.984.016.017.241.02 1.05.017l1.03-.004-2.694-3.766L7.796 5.75 5.722 2.852l-1.039-.004-1.039-.004z" clip-rule="evenodd"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.9 KiB |
@@ -1 +0,0 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
||||
|
Before Width: | Height: | Size: 1.5 KiB |
184
client/src/App.css
Normal file
184
client/src/App.css
Normal file
@@ -0,0 +1,184 @@
|
||||
.counter {
|
||||
font-size: 16px;
|
||||
padding: 5px 10px;
|
||||
border-radius: 5px;
|
||||
color: var(--accent);
|
||||
background: var(--accent-bg);
|
||||
border: 2px solid transparent;
|
||||
transition: border-color 0.3s;
|
||||
margin-bottom: 24px;
|
||||
|
||||
&:hover {
|
||||
border-color: var(--accent-border);
|
||||
}
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.hero {
|
||||
position: relative;
|
||||
|
||||
.base,
|
||||
.framework,
|
||||
.vite {
|
||||
inset-inline: 0;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.base {
|
||||
width: 170px;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.framework,
|
||||
.vite {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.framework {
|
||||
z-index: 1;
|
||||
top: 34px;
|
||||
height: 28px;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(44deg) rotateY(39deg)
|
||||
scale(1.4);
|
||||
}
|
||||
|
||||
.vite {
|
||||
z-index: 0;
|
||||
top: 107px;
|
||||
height: 26px;
|
||||
width: auto;
|
||||
transform: perspective(2000px) rotateZ(300deg) rotateX(40deg) rotateY(39deg)
|
||||
scale(0.8);
|
||||
}
|
||||
}
|
||||
|
||||
#center {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 25px;
|
||||
place-content: center;
|
||||
place-items: center;
|
||||
flex-grow: 1;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
padding: 32px 20px 24px;
|
||||
gap: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps {
|
||||
display: flex;
|
||||
border-top: 1px solid var(--border);
|
||||
text-align: left;
|
||||
|
||||
& > div {
|
||||
flex: 1 1 0;
|
||||
padding: 32px;
|
||||
@media (max-width: 1024px) {
|
||||
padding: 24px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
margin-bottom: 16px;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
flex-direction: column;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
#docs {
|
||||
border-right: 1px solid var(--border);
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
border-right: none;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
}
|
||||
|
||||
#next-steps ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin: 32px 0 0;
|
||||
|
||||
.logo {
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--text-h);
|
||||
font-size: 16px;
|
||||
border-radius: 6px;
|
||||
background: var(--social-bg);
|
||||
display: flex;
|
||||
padding: 6px 12px;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
text-decoration: none;
|
||||
transition: box-shadow 0.3s;
|
||||
|
||||
&:hover {
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
.button-icon {
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
margin-top: 20px;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
|
||||
li {
|
||||
flex: 1 1 calc(50% - 8px);
|
||||
}
|
||||
|
||||
a {
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#spacer {
|
||||
height: 88px;
|
||||
border-top: 1px solid var(--border);
|
||||
@media (max-width: 1024px) {
|
||||
height: 48px;
|
||||
}
|
||||
}
|
||||
|
||||
.ticks {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
||||
&::before,
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: -4.5px;
|
||||
border: 5px solid transparent;
|
||||
}
|
||||
|
||||
&::before {
|
||||
left: 0;
|
||||
border-left-color: var(--border);
|
||||
}
|
||||
&::after {
|
||||
right: 0;
|
||||
border-right-color: var(--border);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +1,70 @@
|
||||
import { Admin, Resource } from 'react-admin';
|
||||
import dataProvider from './dataProvider';
|
||||
import authProvider from './auth/authProvider';
|
||||
import { Admin, Resource } from "react-admin";
|
||||
import { authProvider } from "./auth/authProvider";
|
||||
import { dataProvider } from "./dataProvider";
|
||||
import { CategoryResourceCreate } from "./resources/category-resource/CategoryResourceCreate";
|
||||
import { CategoryResourceEdit } from "./resources/category-resource/CategoryResourceEdit";
|
||||
import { CategoryResourceList } from "./resources/category-resource/CategoryResourceList";
|
||||
import { CategoryResourceShow } from "./resources/category-resource/CategoryResourceShow";
|
||||
import { EmployeeCreate } from "./resources/employee/EmployeeCreate";
|
||||
import { EmployeeEdit } from "./resources/employee/EmployeeEdit";
|
||||
import { EmployeeList } from "./resources/employee/EmployeeList";
|
||||
import { EmployeeShow } from "./resources/employee/EmployeeShow";
|
||||
import { EquipmentCreate } from "./resources/equipment/EquipmentCreate";
|
||||
import { EquipmentEdit } from "./resources/equipment/EquipmentEdit";
|
||||
import { EquipmentList } from "./resources/equipment/EquipmentList";
|
||||
import { EquipmentShow } from "./resources/equipment/EquipmentShow";
|
||||
import { PartCreate } from "./resources/part/PartCreate";
|
||||
import { PartEdit } from "./resources/part/PartEdit";
|
||||
import { PartList } from "./resources/part/PartList";
|
||||
import { PartShow } from "./resources/part/PartShow";
|
||||
import { PriceListCreate } from "./resources/price-list/PriceListCreate";
|
||||
import { PriceListEdit } from "./resources/price-list/PriceListEdit";
|
||||
import { PriceListList } from "./resources/price-list/PriceListList";
|
||||
import { PriceListShow } from "./resources/price-list/PriceListShow";
|
||||
import "./App.css";
|
||||
|
||||
import { EquipmentTypeList } from './resources/equipment-type/EquipmentTypeList';
|
||||
import { EquipmentTypeCreate } from './resources/equipment-type/EquipmentTypeCreate';
|
||||
import { EquipmentTypeEdit } from './resources/equipment-type/EquipmentTypeEdit';
|
||||
import { EquipmentTypeShow } from './resources/equipment-type/EquipmentTypeShow';
|
||||
|
||||
import { EquipmentList } from './resources/equipment/EquipmentList';
|
||||
import { EquipmentCreate } from './resources/equipment/EquipmentCreate';
|
||||
import { EquipmentEdit } from './resources/equipment/EquipmentEdit';
|
||||
import { EquipmentShow } from './resources/equipment/EquipmentShow';
|
||||
|
||||
import { RepairOrderList } from './resources/repair-order/RepairOrderList';
|
||||
import { RepairOrderCreate } from './resources/repair-order/RepairOrderCreate';
|
||||
import { RepairOrderEdit } from './resources/repair-order/RepairOrderEdit';
|
||||
import { RepairOrderShow } from './resources/repair-order/RepairOrderShow';
|
||||
|
||||
const App = () => (
|
||||
<Admin dataProvider={dataProvider} authProvider={authProvider} requireAuth>
|
||||
<Resource
|
||||
name="equipment-types"
|
||||
options={{ label: 'Виды оборудования' }}
|
||||
list={EquipmentTypeList}
|
||||
create={EquipmentTypeCreate}
|
||||
edit={EquipmentTypeEdit}
|
||||
show={EquipmentTypeShow}
|
||||
/>
|
||||
<Resource
|
||||
name="equipment"
|
||||
options={{ label: 'Оборудование' }}
|
||||
list={EquipmentList}
|
||||
create={EquipmentCreate}
|
||||
edit={EquipmentEdit}
|
||||
show={EquipmentShow}
|
||||
/>
|
||||
<Resource
|
||||
name="repair-orders"
|
||||
options={{ label: 'Заявки на ремонт' }}
|
||||
list={RepairOrderList}
|
||||
create={RepairOrderCreate}
|
||||
edit={RepairOrderEdit}
|
||||
show={RepairOrderShow}
|
||||
/>
|
||||
</Admin>
|
||||
);
|
||||
|
||||
export default App;
|
||||
export default function App() {
|
||||
return (
|
||||
<Admin
|
||||
dataProvider={dataProvider}
|
||||
authProvider={authProvider}
|
||||
disableTelemetry
|
||||
>
|
||||
<Resource
|
||||
name="equipment"
|
||||
list={EquipmentList}
|
||||
create={EquipmentCreate}
|
||||
edit={EquipmentEdit}
|
||||
show={EquipmentShow}
|
||||
/>
|
||||
<Resource
|
||||
name="employees"
|
||||
list={EmployeeList}
|
||||
create={EmployeeCreate}
|
||||
edit={EmployeeEdit}
|
||||
show={EmployeeShow}
|
||||
/>
|
||||
<Resource
|
||||
name="parts"
|
||||
list={PartList}
|
||||
create={PartCreate}
|
||||
edit={PartEdit}
|
||||
show={PartShow}
|
||||
/>
|
||||
<Resource
|
||||
name="category-resources"
|
||||
list={CategoryResourceList}
|
||||
create={CategoryResourceCreate}
|
||||
edit={CategoryResourceEdit}
|
||||
show={CategoryResourceShow}
|
||||
/>
|
||||
<Resource
|
||||
name="price-list"
|
||||
list={PriceListList}
|
||||
create={PriceListCreate}
|
||||
edit={PriceListEdit}
|
||||
show={PriceListShow}
|
||||
/>
|
||||
</Admin>
|
||||
);
|
||||
}
|
||||
|
||||
BIN
client/src/assets/hero.png
Normal file
BIN
client/src/assets/hero.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
1
client/src/assets/vite.svg
Normal file
1
client/src/assets/vite.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 8.5 KiB |
@@ -1,45 +1,44 @@
|
||||
import { AuthProvider } from 'react-admin';
|
||||
import {
|
||||
forceReauthentication,
|
||||
getIdentity,
|
||||
getRealmRoles,
|
||||
getValidAccessToken,
|
||||
initKeycloak,
|
||||
logoutFromKeycloak,
|
||||
} from './keycloak';
|
||||
import type { AuthProvider } from 'react-admin';
|
||||
import { getKeycloak, initKeycloak } from './keycloak';
|
||||
|
||||
const authProvider: AuthProvider = {
|
||||
export const authProvider: AuthProvider = {
|
||||
login: async () => {
|
||||
await initKeycloak();
|
||||
await getKeycloak().login();
|
||||
},
|
||||
|
||||
logout: async () => {
|
||||
await logoutFromKeycloak();
|
||||
await getKeycloak().logout({ redirectUri: window.location.origin });
|
||||
},
|
||||
|
||||
checkAuth: async () => {
|
||||
await getValidAccessToken();
|
||||
await initKeycloak();
|
||||
if (!getKeycloak().authenticated) {
|
||||
await getKeycloak().login();
|
||||
}
|
||||
},
|
||||
|
||||
checkError: async (error) => {
|
||||
const status = error?.status;
|
||||
|
||||
const status = error?.status ?? error?.response?.status;
|
||||
if (status === 401) {
|
||||
await forceReauthentication();
|
||||
getKeycloak().clearToken();
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
if (status === 403) {
|
||||
return Promise.resolve();
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
},
|
||||
|
||||
getIdentity: async () => getIdentity(),
|
||||
|
||||
getPermissions: async () => getRealmRoles(),
|
||||
getIdentity: async () => {
|
||||
await initKeycloak();
|
||||
const tokenParsed = getKeycloak().tokenParsed as Record<string, unknown> | undefined;
|
||||
return {
|
||||
id: String(tokenParsed?.sub ?? 'anonymous'),
|
||||
fullName: typeof tokenParsed?.name === 'string' ? tokenParsed.name : (typeof tokenParsed?.preferred_username === 'string' ? tokenParsed.preferred_username : 'User'),
|
||||
avatar: undefined,
|
||||
};
|
||||
},
|
||||
getPermissions: async () => {
|
||||
await initKeycloak();
|
||||
const tokenParsed = getKeycloak().tokenParsed as { realm_access?: { roles?: unknown } } | undefined;
|
||||
const roles = tokenParsed?.realm_access?.roles;
|
||||
return Array.isArray(roles) ? roles.filter((role): role is string => typeof role === 'string') : [];
|
||||
},
|
||||
};
|
||||
|
||||
export default authProvider;
|
||||
|
||||
|
||||
@@ -1,96 +1,43 @@
|
||||
import Keycloak, { KeycloakTokenParsed } from 'keycloak-js';
|
||||
import Keycloak from 'keycloak-js';
|
||||
import { env } from '../config/env';
|
||||
|
||||
interface RealmAccessTokenParsed extends KeycloakTokenParsed {
|
||||
realm_access?: {
|
||||
roles: string[];
|
||||
};
|
||||
}
|
||||
|
||||
const keycloak = new Keycloak({
|
||||
url: env.keycloakUrl,
|
||||
realm: env.keycloakRealm,
|
||||
clientId: env.keycloakClientId,
|
||||
});
|
||||
|
||||
let keycloakInitPromise: Promise<void> | null = null;
|
||||
let refreshInFlight: Promise<void> | null = null;
|
||||
let initPromise: Promise<boolean> | null = null;
|
||||
let refreshPromise: Promise<string | null> | null = null;
|
||||
|
||||
export async function initKeycloak(): Promise<boolean> {
|
||||
if (!initPromise) {
|
||||
initPromise = keycloak.init({
|
||||
onLoad: 'login-required',
|
||||
pkceMethod: 'S256',
|
||||
checkLoginIframe: false,
|
||||
});
|
||||
}
|
||||
|
||||
return initPromise;
|
||||
}
|
||||
|
||||
export async function getAccessToken(): Promise<string | null> {
|
||||
await initKeycloak();
|
||||
if (!keycloak.authenticated) return null;
|
||||
|
||||
if (!refreshPromise) {
|
||||
refreshPromise = keycloak
|
||||
.updateToken(30)
|
||||
.then(() => keycloak.token ?? null)
|
||||
.finally(() => {
|
||||
refreshPromise = null;
|
||||
});
|
||||
}
|
||||
|
||||
return refreshPromise;
|
||||
}
|
||||
|
||||
export function getKeycloak() {
|
||||
return keycloak;
|
||||
}
|
||||
|
||||
export async function initKeycloak() {
|
||||
if (!keycloakInitPromise) {
|
||||
keycloakInitPromise = keycloak
|
||||
.init({
|
||||
onLoad: 'login-required',
|
||||
pkceMethod: 'S256',
|
||||
checkLoginIframe: false,
|
||||
})
|
||||
.then((authenticated) => {
|
||||
if (!authenticated) {
|
||||
return keycloak.login({ redirectUri: window.location.href });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
await keycloakInitPromise;
|
||||
}
|
||||
|
||||
async function refreshAccessToken(minValiditySeconds = 30) {
|
||||
if (!refreshInFlight) {
|
||||
refreshInFlight = keycloak
|
||||
.updateToken(minValiditySeconds)
|
||||
.then(() => undefined)
|
||||
.finally(() => {
|
||||
refreshInFlight = null;
|
||||
});
|
||||
}
|
||||
|
||||
await refreshInFlight;
|
||||
}
|
||||
|
||||
export async function getValidAccessToken(minValiditySeconds = 30): Promise<string> {
|
||||
await initKeycloak();
|
||||
|
||||
if (!keycloak.authenticated) {
|
||||
await keycloak.login({ redirectUri: window.location.href });
|
||||
throw new Error('User is not authenticated');
|
||||
}
|
||||
|
||||
await refreshAccessToken(minValiditySeconds);
|
||||
|
||||
if (!keycloak.token) {
|
||||
throw new Error('Missing access token');
|
||||
}
|
||||
|
||||
return keycloak.token;
|
||||
}
|
||||
|
||||
export async function forceReauthentication() {
|
||||
keycloak.clearToken();
|
||||
await keycloak.login({ redirectUri: window.location.href });
|
||||
}
|
||||
|
||||
export async function logoutFromKeycloak() {
|
||||
await keycloak.logout({ redirectUri: window.location.origin });
|
||||
}
|
||||
|
||||
export function getRealmRoles(): string[] {
|
||||
const parsed = keycloak.tokenParsed as RealmAccessTokenParsed | undefined;
|
||||
const roles = parsed?.realm_access?.roles;
|
||||
return Array.isArray(roles) ? roles : [];
|
||||
}
|
||||
|
||||
export function getIdentity() {
|
||||
const parsed = keycloak.tokenParsed as RealmAccessTokenParsed | undefined;
|
||||
const id = parsed?.sub ?? 'unknown';
|
||||
const fullName =
|
||||
parsed?.name ??
|
||||
parsed?.preferred_username ??
|
||||
parsed?.email ??
|
||||
'Unknown User';
|
||||
|
||||
return { id, fullName };
|
||||
}
|
||||
|
||||
@@ -1,24 +1,6 @@
|
||||
const REQUIRED_ENV_KEYS = [
|
||||
'VITE_API_URL',
|
||||
'VITE_KEYCLOAK_URL',
|
||||
'VITE_KEYCLOAK_REALM',
|
||||
'VITE_KEYCLOAK_CLIENT_ID',
|
||||
] as const;
|
||||
|
||||
type RequiredEnvKey = (typeof REQUIRED_ENV_KEYS)[number];
|
||||
|
||||
function readRequiredEnv(key: RequiredEnvKey): string {
|
||||
const value = import.meta.env[key];
|
||||
if (!value || !value.trim()) {
|
||||
throw new Error(`Missing required environment variable: ${key}`);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
export const env = {
|
||||
apiUrl: readRequiredEnv('VITE_API_URL'),
|
||||
keycloakUrl: readRequiredEnv('VITE_KEYCLOAK_URL'),
|
||||
keycloakRealm: readRequiredEnv('VITE_KEYCLOAK_REALM'),
|
||||
keycloakClientId: readRequiredEnv('VITE_KEYCLOAK_CLIENT_ID'),
|
||||
} as const;
|
||||
|
||||
apiUrl: import.meta.env.VITE_API_URL ?? 'http://localhost:3000',
|
||||
keycloakUrl: import.meta.env.VITE_KEYCLOAK_URL ?? 'https://sso.greact.ru',
|
||||
keycloakRealm: import.meta.env.VITE_KEYCLOAK_REALM ?? 'toir',
|
||||
keycloakClientId: import.meta.env.VITE_KEYCLOAK_CLIENT_ID ?? 'toir-frontend',
|
||||
};
|
||||
|
||||
@@ -1,146 +1,174 @@
|
||||
import { DataProvider, fetchUtils } from 'react-admin';
|
||||
import { getValidAccessToken } from './auth/keycloak';
|
||||
import { env } from './config/env';
|
||||
import type { DataProvider } from "react-admin";
|
||||
import { env } from "./config/env";
|
||||
import { getAccessToken } from "./auth/keycloak";
|
||||
|
||||
const apiUrl = env.apiUrl;
|
||||
async function fetchJson(
|
||||
url: string,
|
||||
options: RequestInit = {},
|
||||
): Promise<{ json: any; headers: Headers; status: number }> {
|
||||
const headers = new Headers(
|
||||
options.headers ?? { Accept: "application/json" },
|
||||
);
|
||||
const token = await getAccessToken();
|
||||
if (token) {
|
||||
headers.set('Authorization', `Bearer ${token}`);
|
||||
}
|
||||
if (!headers.has("Content-Type") && options.body) {
|
||||
headers.set("Content-Type", "application/json");
|
||||
}
|
||||
|
||||
const httpClient = async (url: string, options: fetchUtils.Options = {}) => {
|
||||
const token = await getValidAccessToken();
|
||||
const headers = new Headers(options.headers ?? { Accept: 'application/json' });
|
||||
headers.set('Authorization', `Bearer ${token}`);
|
||||
|
||||
return fetchUtils.fetchJson(url, {
|
||||
...options,
|
||||
headers,
|
||||
});
|
||||
};
|
||||
|
||||
function buildQueryString(query: Record<string, unknown>) {
|
||||
const search = new URLSearchParams();
|
||||
Object.entries(query).forEach(([key, val]) => {
|
||||
if (val === undefined || val === null || val === '') return;
|
||||
if (Array.isArray(val)) {
|
||||
val.forEach((v) => {
|
||||
if (v === undefined || v === null || v === '') return;
|
||||
search.append(key, String(v));
|
||||
});
|
||||
return;
|
||||
const response = await fetch(url, { ...options, headers });
|
||||
if (!response.ok) {
|
||||
const error = new Error(
|
||||
"Request failed with status " + response.status,
|
||||
) as Error & { status?: number; body?: unknown };
|
||||
error.status = response.status;
|
||||
try {
|
||||
error.body = await response.json();
|
||||
} catch {
|
||||
error.body = null;
|
||||
}
|
||||
search.set(key, String(val));
|
||||
});
|
||||
return search.toString();
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (response.status === 204) {
|
||||
return { json: null, headers: response.headers, status: response.status };
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
return { json, headers: response.headers, status: response.status };
|
||||
}
|
||||
|
||||
const dataProvider: DataProvider = {
|
||||
function appendSearchParam(
|
||||
searchParams: URLSearchParams,
|
||||
key: string,
|
||||
value: unknown,
|
||||
): void {
|
||||
if (Array.isArray(value)) {
|
||||
value.forEach((entry) => appendSearchParam(searchParams, key, entry));
|
||||
return;
|
||||
}
|
||||
if (value === undefined || value === null || value === "") {
|
||||
return;
|
||||
}
|
||||
searchParams.append(key, String(value));
|
||||
}
|
||||
|
||||
function buildListUrl(resource: string, params: any): string {
|
||||
const resourcePath = resource === "equipment" ? "equipments" : resource;
|
||||
const searchParams = new URLSearchParams();
|
||||
searchParams.set(
|
||||
"_start",
|
||||
String((params.pagination.page - 1) * params.pagination.perPage),
|
||||
);
|
||||
searchParams.set(
|
||||
"_end",
|
||||
String(params.pagination.page * params.pagination.perPage),
|
||||
);
|
||||
searchParams.set("_sort", params.sort.field);
|
||||
searchParams.set("_order", params.sort.order);
|
||||
Object.entries(params.filter ?? {}).forEach(([key, value]) => {
|
||||
appendSearchParam(searchParams, key, value);
|
||||
});
|
||||
const queryString = searchParams.toString();
|
||||
return (
|
||||
env.apiUrl + "/" + resourcePath + (queryString ? "?" + queryString : "")
|
||||
);
|
||||
}
|
||||
|
||||
export const dataProvider: DataProvider = {
|
||||
getList: async (resource, params) => {
|
||||
const { page, perPage } = params.pagination!;
|
||||
const { field, order } = params.sort!;
|
||||
const start = (page - 1) * perPage;
|
||||
const end = page * perPage;
|
||||
|
||||
const query: Record<string, unknown> = {
|
||||
_start: start,
|
||||
_end: end,
|
||||
_sort: field,
|
||||
_order: order,
|
||||
...(params.filter ?? {}),
|
||||
};
|
||||
|
||||
const queryString = buildQueryString(query);
|
||||
const url = `${apiUrl}/${resource}?${queryString}`;
|
||||
const { json, headers } = await httpClient(url);
|
||||
|
||||
const contentRange = headers.get('Content-Range');
|
||||
if (resource === "price-list") {
|
||||
const { json } = await fetchJson(env.apiUrl + "/price-list");
|
||||
return { data: [json], total: 1 };
|
||||
}
|
||||
const { json, headers } = await fetchJson(buildListUrl(resource, params));
|
||||
const contentRange = headers.get("Content-Range");
|
||||
const total = contentRange
|
||||
? parseInt(contentRange.split('/').pop() || '0', 10)
|
||||
: json.length;
|
||||
|
||||
return { data: json, total };
|
||||
? Number(
|
||||
contentRange.split("/").pop() ??
|
||||
(Array.isArray(json) ? json.length : 0),
|
||||
)
|
||||
: Array.isArray(json)
|
||||
? json.length
|
||||
: 0;
|
||||
return { data: Array.isArray(json) ? json : [], total };
|
||||
},
|
||||
|
||||
getOne: async (resource, params) => {
|
||||
const { json } = await httpClient(`${apiUrl}/${resource}/${params.id}`);
|
||||
const resourcePath = resource === "equipment" ? "equipments" : resource;
|
||||
const url =
|
||||
resource === "price-list"
|
||||
? env.apiUrl + "/price-list"
|
||||
: env.apiUrl + "/" + resourcePath + "/" + params.id;
|
||||
const { json } = await fetchJson(url);
|
||||
return { data: json };
|
||||
},
|
||||
|
||||
getMany: async (resource, params) => {
|
||||
const query = params.ids.map((id) => `id=${id}`).join('&');
|
||||
const { json } = await httpClient(`${apiUrl}/${resource}?${query}`);
|
||||
return { data: json };
|
||||
if (resource === "price-list") {
|
||||
const { json } = await fetchJson(env.apiUrl + "/price-list");
|
||||
return { data: params.ids.includes("price-list") ? [json] : [] };
|
||||
}
|
||||
const records = await Promise.all(
|
||||
params.ids.map((id) =>
|
||||
dataProvider.getOne(resource, { id, meta: params.meta } as any),
|
||||
),
|
||||
);
|
||||
return { data: records.map((result) => result.data) };
|
||||
},
|
||||
|
||||
getManyReference: async (resource, params) => {
|
||||
const { page, perPage } = params.pagination!;
|
||||
const { field, order } = params.sort!;
|
||||
const start = (page - 1) * perPage;
|
||||
const end = page * perPage;
|
||||
|
||||
const query: Record<string, unknown> = {
|
||||
_start: start,
|
||||
_end: end,
|
||||
_sort: field,
|
||||
_order: order,
|
||||
[params.target]: params.id,
|
||||
...(params.filter ?? {}),
|
||||
};
|
||||
|
||||
const queryString = buildQueryString(query);
|
||||
const url = `${apiUrl}/${resource}?${queryString}`;
|
||||
const { json, headers } = await httpClient(url);
|
||||
|
||||
const contentRange = headers.get('Content-Range');
|
||||
const total = contentRange
|
||||
? parseInt(contentRange.split('/').pop() || '0', 10)
|
||||
: json.length;
|
||||
|
||||
return { data: json, total };
|
||||
},
|
||||
|
||||
getManyReference: async (resource, params) =>
|
||||
dataProvider.getList(resource, {
|
||||
pagination: params.pagination,
|
||||
sort: params.sort,
|
||||
filter: { ...(params.filter ?? {}), [params.target]: params.id },
|
||||
meta: params.meta,
|
||||
} as any),
|
||||
create: async (resource, params) => {
|
||||
const { json } = await httpClient(`${apiUrl}/${resource}`, {
|
||||
method: 'POST',
|
||||
const resourcePath = resource === "equipment" ? "equipments" : resource;
|
||||
const { json } = await fetchJson(env.apiUrl + "/" + resourcePath, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(params.data),
|
||||
});
|
||||
return { data: json };
|
||||
},
|
||||
|
||||
update: async (resource, params) => {
|
||||
const { json } = await httpClient(`${apiUrl}/${resource}/${params.id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(params.data),
|
||||
});
|
||||
const resourcePath = resource === "equipment" ? "equipments" : resource;
|
||||
const { json } = await fetchJson(
|
||||
env.apiUrl + "/" + resourcePath + "/" + params.id,
|
||||
{ method: "PATCH", body: JSON.stringify(params.data) },
|
||||
);
|
||||
return { data: json };
|
||||
},
|
||||
|
||||
updateMany: async (resource, params) => {
|
||||
const responses = await Promise.all(
|
||||
const results = await Promise.all(
|
||||
params.ids.map((id) =>
|
||||
httpClient(`${apiUrl}/${resource}/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(params.data),
|
||||
})
|
||||
)
|
||||
dataProvider.update(resource, {
|
||||
id,
|
||||
data: params.data,
|
||||
previousData: {},
|
||||
meta: params.meta,
|
||||
} as any),
|
||||
),
|
||||
);
|
||||
return { data: responses.map(({ json }) => json.id) };
|
||||
return { data: results.map((result) => result.data.id) };
|
||||
},
|
||||
|
||||
delete: async (resource, params) => {
|
||||
const { json } = await httpClient(`${apiUrl}/${resource}/${params.id}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
return { data: json };
|
||||
},
|
||||
|
||||
deleteMany: async (resource, params) => {
|
||||
const responses = await Promise.all(
|
||||
params.ids.map((id) =>
|
||||
httpClient(`${apiUrl}/${resource}/${id}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
)
|
||||
const resourcePath = resource === "equipment" ? "equipments" : resource;
|
||||
const { json } = await fetchJson(
|
||||
env.apiUrl + "/" + resourcePath + "/" + params.id,
|
||||
{ method: "DELETE" },
|
||||
);
|
||||
return { data: responses.map(({ json }) => json.id) };
|
||||
return { data: json ?? { id: params.id } };
|
||||
},
|
||||
deleteMany: async (resource, params) => {
|
||||
const results = await Promise.all(
|
||||
params.ids.map((id) =>
|
||||
dataProvider.delete(resource, {
|
||||
id,
|
||||
previousData: {},
|
||||
meta: params.meta,
|
||||
} as any),
|
||||
),
|
||||
);
|
||||
return { data: results.map((result) => result.data.id) };
|
||||
},
|
||||
};
|
||||
|
||||
export default dataProvider;
|
||||
|
||||
110
client/src/index.css
Normal file
110
client/src/index.css
Normal file
@@ -0,0 +1,110 @@
|
||||
:root {
|
||||
--text: #6b6375;
|
||||
--text-h: #08060d;
|
||||
--bg: #fff;
|
||||
--border: #e5e4e7;
|
||||
--code-bg: #f4f3ec;
|
||||
--accent: #aa3bff;
|
||||
--accent-bg: rgba(170, 59, 255, 0.1);
|
||||
--accent-border: rgba(170, 59, 255, 0.5);
|
||||
--social-bg: rgba(244, 243, 236, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.1) 0 10px 15px -3px, rgba(0, 0, 0, 0.05) 0 4px 6px -2px;
|
||||
|
||||
--sans: system-ui, "Segoe UI", Roboto, sans-serif;
|
||||
--heading: system-ui, "Segoe UI", Roboto, sans-serif;
|
||||
--mono: ui-monospace, Consolas, monospace;
|
||||
|
||||
font: 18px/145% var(--sans);
|
||||
letter-spacing: 0.18px;
|
||||
color-scheme: light dark;
|
||||
color: var(--text);
|
||||
background: var(--bg);
|
||||
font-synthesis: none;
|
||||
text-rendering: optimizeLegibility;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--text: #9ca3af;
|
||||
--text-h: #f3f4f6;
|
||||
--bg: #16171d;
|
||||
--border: #2e303a;
|
||||
--code-bg: #1f2028;
|
||||
--accent: #c084fc;
|
||||
--accent-bg: rgba(192, 132, 252, 0.15);
|
||||
--accent-border: rgba(192, 132, 252, 0.5);
|
||||
--social-bg: rgba(47, 48, 58, 0.5);
|
||||
--shadow:
|
||||
rgba(0, 0, 0, 0.4) 0 10px 15px -3px, rgba(0, 0, 0, 0.25) 0 4px 6px -2px;
|
||||
}
|
||||
|
||||
#social .button-icon {
|
||||
filter: invert(1) brightness(2);
|
||||
}
|
||||
}
|
||||
|
||||
#root {
|
||||
max-width: 100%;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
border-inline: 1px solid var(--border);
|
||||
min-height: 100svh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
font-family: var(--heading);
|
||||
font-weight: 500;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 56px;
|
||||
letter-spacing: -1.68px;
|
||||
margin: 32px 0;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 36px;
|
||||
margin: 20px 0;
|
||||
}
|
||||
}
|
||||
h2 {
|
||||
font-size: 24px;
|
||||
line-height: 118%;
|
||||
letter-spacing: -0.24px;
|
||||
margin: 0 0 8px;
|
||||
@media (max-width: 1024px) {
|
||||
font-size: 20px;
|
||||
}
|
||||
}
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
code,
|
||||
.counter {
|
||||
font-family: var(--mono);
|
||||
display: inline-flex;
|
||||
border-radius: 4px;
|
||||
color: var(--text-h);
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 15px;
|
||||
line-height: 135%;
|
||||
padding: 4px 8px;
|
||||
background: var(--code-bg);
|
||||
}
|
||||
@@ -1,26 +1,16 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { StrictMode } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import './index.css';
|
||||
import App from './App';
|
||||
import { initKeycloak } from './auth/keycloak';
|
||||
|
||||
const root = ReactDOM.createRoot(document.getElementById('root')!);
|
||||
|
||||
async function bootstrap() {
|
||||
await initKeycloak();
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
</StrictMode>,
|
||||
);
|
||||
}
|
||||
|
||||
bootstrap().catch((error) => {
|
||||
console.error('Failed to initialize authentication', error);
|
||||
|
||||
root.render(
|
||||
<React.StrictMode>
|
||||
<div>Authentication initialization failed. Check your environment variables.</div>
|
||||
</React.StrictMode>,
|
||||
);
|
||||
});
|
||||
void bootstrap();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
AutocompleteInput,
|
||||
Create,
|
||||
ReferenceInput,
|
||||
SimpleForm,
|
||||
} from "react-admin";
|
||||
import { employeeOptionText, partOptionText } from "../shared/enums";
|
||||
export const CategoryResourceCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<ReferenceInput source="partId" reference="parts">
|
||||
<AutocompleteInput
|
||||
optionText={partOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>
|
||||
<ReferenceInput source="employeeCode" reference="employees">
|
||||
<AutocompleteInput
|
||||
optionText={employeeOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
AutocompleteInput,
|
||||
Edit,
|
||||
ReferenceInput,
|
||||
SimpleForm,
|
||||
} from "react-admin";
|
||||
import { employeeOptionText, partOptionText } from "../shared/enums";
|
||||
export const CategoryResourceEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<ReferenceInput source="partId" reference="parts">
|
||||
<AutocompleteInput
|
||||
optionText={partOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>
|
||||
<ReferenceInput source="employeeCode" reference="employees">
|
||||
<AutocompleteInput
|
||||
optionText={employeeOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
AutocompleteInput,
|
||||
CreateButton,
|
||||
Datagrid,
|
||||
FilterButton,
|
||||
List,
|
||||
ReferenceField,
|
||||
ReferenceInput,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
} from "react-admin";
|
||||
import { employeeOptionText, partOptionText } from "../shared/enums";
|
||||
const categoryResourceFilters = [
|
||||
<TextInput key="q" source="q" label="Search" alwaysOn />,
|
||||
<ReferenceInput key="partId" source="partId" reference="parts">
|
||||
<AutocompleteInput
|
||||
optionText={partOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>,
|
||||
<ReferenceInput
|
||||
key="employeeCode"
|
||||
source="employeeCode"
|
||||
reference="employees"
|
||||
>
|
||||
<AutocompleteInput
|
||||
optionText={employeeOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>,
|
||||
];
|
||||
export const CategoryResourceList = () => (
|
||||
<List
|
||||
filters={categoryResourceFilters}
|
||||
actions={
|
||||
<TopToolbar>
|
||||
<FilterButton />
|
||||
<CreateButton />
|
||||
</TopToolbar>
|
||||
}
|
||||
>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="id" />
|
||||
<ReferenceField source="partId" reference="parts" link="show">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
<ReferenceField source="employeeCode" reference="employees" link="show">
|
||||
<TextField source="fullName" />
|
||||
</ReferenceField>
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
@@ -0,0 +1,14 @@
|
||||
import { ReferenceField, Show, SimpleShowLayout, TextField } from "react-admin";
|
||||
export const CategoryResourceShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="id" />
|
||||
<ReferenceField source="partId" reference="parts" link="show">
|
||||
<TextField source="name" />
|
||||
</ReferenceField>
|
||||
<ReferenceField source="employeeCode" reference="employees" link="show">
|
||||
<TextField source="fullName" />
|
||||
</ReferenceField>
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
28
client/src/resources/employee/EmployeeCreate.tsx
Normal file
28
client/src/resources/employee/EmployeeCreate.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import {
|
||||
AutocompleteInput,
|
||||
Create,
|
||||
NumberInput,
|
||||
ReferenceInput,
|
||||
SelectInput,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
} from "react-admin";
|
||||
import { employeeOptionText, roleChoices } from "../shared/enums";
|
||||
export const EmployeeCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="code" required />
|
||||
<TextInput source="fullName" required />
|
||||
<SelectInput source="role" choices={roleChoices} required />
|
||||
<TextInput source="position" required />
|
||||
<ReferenceInput source="boss" reference="employees">
|
||||
<AutocompleteInput
|
||||
optionText={employeeOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>
|
||||
<NumberInput source="price" />
|
||||
<NumberInput source="phoneNumber" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
27
client/src/resources/employee/EmployeeEdit.tsx
Normal file
27
client/src/resources/employee/EmployeeEdit.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import {
|
||||
AutocompleteInput,
|
||||
Edit,
|
||||
NumberInput,
|
||||
ReferenceInput,
|
||||
SelectInput,
|
||||
SimpleForm,
|
||||
TextInput,
|
||||
} from "react-admin";
|
||||
import { employeeOptionText, roleChoices } from "../shared/enums";
|
||||
export const EmployeeEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="fullName" />
|
||||
<SelectInput source="role" choices={roleChoices} />
|
||||
<TextInput source="position" />
|
||||
<ReferenceInput source="boss" reference="employees">
|
||||
<AutocompleteInput
|
||||
optionText={employeeOptionText}
|
||||
filterToQuery={(searchText) => ({ q: searchText })}
|
||||
/>
|
||||
</ReferenceInput>
|
||||
<NumberInput source="price" />
|
||||
<NumberInput source="phoneNumber" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
38
client/src/resources/employee/EmployeeList.tsx
Normal file
38
client/src/resources/employee/EmployeeList.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import {
|
||||
Datagrid,
|
||||
List,
|
||||
ReferenceField,
|
||||
SelectArrayInput,
|
||||
SelectField,
|
||||
TextField,
|
||||
TextInput,
|
||||
} from "react-admin";
|
||||
import { ResourceListActions } from "../shared/ListActions";
|
||||
import { roleChoices } from "../shared/enums";
|
||||
const employeeFilters = [
|
||||
<TextInput key="q" source="q" label="Search" alwaysOn />,
|
||||
<SelectArrayInput
|
||||
key="role"
|
||||
source="role"
|
||||
label="Role"
|
||||
choices={roleChoices}
|
||||
/>,
|
||||
<TextInput key="position" source="position" label="Position" />,
|
||||
];
|
||||
export const EmployeeList = () => (
|
||||
<List
|
||||
filters={employeeFilters}
|
||||
actions={<ResourceListActions filters={employeeFilters} />}
|
||||
>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="code" />
|
||||
<TextField source="fullName" />
|
||||
<SelectField source="role" choices={roleChoices} />
|
||||
<TextField source="position" />
|
||||
<ReferenceField source="bossCode" reference="employees" link="show">
|
||||
<TextField source="fullName" />
|
||||
</ReferenceField>
|
||||
<TextField source="phoneNumber" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
22
client/src/resources/employee/EmployeeShow.tsx
Normal file
22
client/src/resources/employee/EmployeeShow.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import {
|
||||
ReferenceField,
|
||||
SelectField,
|
||||
Show,
|
||||
SimpleShowLayout,
|
||||
TextField,
|
||||
} from "react-admin";
|
||||
import { roleChoices } from "../shared/enums";
|
||||
export const EmployeeShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="code" />
|
||||
<TextField source="fullName" />
|
||||
<SelectField source="role" choices={roleChoices} />
|
||||
<TextField source="position" />
|
||||
<ReferenceField source="bossCode" reference="employees" link="show">
|
||||
<TextField source="fullName" />
|
||||
</ReferenceField>
|
||||
<TextField source="phoneNumber" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Create, SimpleForm, TextInput, NumberInput } from 'react-admin';
|
||||
|
||||
|
||||
export const EquipmentTypeCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="code" label="Код вида оборудования" isRequired />
|
||||
<TextInput source="name" label="Наименование вида" isRequired />
|
||||
<TextInput source="manufacturer" label="Производитель" />
|
||||
<NumberInput source="maintenanceIntervalHours" label="Периодичность ТО, моточасов" />
|
||||
<NumberInput source="overhaulIntervalHours" label="Периодичность КР, моточасов" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Edit, SimpleForm, TextInput, NumberInput } from 'react-admin';
|
||||
|
||||
|
||||
export const EquipmentTypeEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="code" label="Код вида оборудования" disabled />
|
||||
<TextInput source="name" label="Наименование вида" isRequired />
|
||||
<TextInput source="manufacturer" label="Производитель" />
|
||||
<NumberInput source="maintenanceIntervalHours" label="Периодичность ТО, моточасов" />
|
||||
<NumberInput source="overhaulIntervalHours" label="Периодичность КР, моточасов" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
@@ -1,38 +0,0 @@
|
||||
import {
|
||||
List,
|
||||
Datagrid,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
FilterButton,
|
||||
CreateButton,
|
||||
ExportButton,
|
||||
NumberField
|
||||
} from 'react-admin';
|
||||
|
||||
|
||||
const equipmentTypeFilters = [
|
||||
<TextInput key="q" source="q" label="Поиск" alwaysOn />,
|
||||
<TextInput key="name" source="name" label="Наименование вида" />,
|
||||
<TextInput key="manufacturer" source="manufacturer" label="Производитель" />
|
||||
];
|
||||
|
||||
const EquipmentTypeListActions = () => (
|
||||
<TopToolbar>
|
||||
<FilterButton filters={equipmentTypeFilters} />
|
||||
<CreateButton />
|
||||
<ExportButton />
|
||||
</TopToolbar>
|
||||
);
|
||||
|
||||
export const EquipmentTypeList = () => (
|
||||
<List actions={<EquipmentTypeListActions />} filters={equipmentTypeFilters} sort={{ field: 'code', order: 'ASC' }}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="code" label="Код вида оборудования" />
|
||||
<TextField source="name" label="Наименование вида" />
|
||||
<TextField source="manufacturer" label="Производитель" />
|
||||
<NumberField source="maintenanceIntervalHours" label="Периодичность ТО, моточасов" />
|
||||
<NumberField source="overhaulIntervalHours" label="Периодичность КР, моточасов" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Show, SimpleShowLayout, TextField, NumberField } from 'react-admin';
|
||||
|
||||
export const EquipmentTypeShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="code" label="Код вида оборудования" />
|
||||
<TextField source="name" label="Наименование вида" />
|
||||
<TextField source="manufacturer" label="Производитель" />
|
||||
<NumberField source="maintenanceIntervalHours" label="Периодичность ТО, моточасов" />
|
||||
<NumberField source="overhaulIntervalHours" label="Периодичность КР, моточасов" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
@@ -1,28 +1,44 @@
|
||||
import { Create, SimpleForm, TextInput, NumberInput, DateInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
import {
|
||||
Create,
|
||||
DateInput,
|
||||
NumberInput,
|
||||
SelectInput,
|
||||
SimpleForm,
|
||||
} from "react-admin";
|
||||
import {
|
||||
equipmentStatusChoices,
|
||||
equipmentTypeChoices,
|
||||
laborOperationChoices,
|
||||
periodicityChoices,
|
||||
} from "../shared/enums";
|
||||
import { PlainInput } from "../shared/inputs";
|
||||
|
||||
export const EquipmentCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="inventoryNumber" label="Инвентарный номер" isRequired />
|
||||
<TextInput source="serialNumber" label="Заводской (серийный) номер" />
|
||||
<TextInput source="name" label="Наименование единицы оборудования" isRequired />
|
||||
<ReferenceInput source="equipmentTypeCode" reference="equipment-types">
|
||||
<AutocompleteInput label="Вид оборудования" optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="status" label="Текущий статус" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<TextInput source="location" label="Место эксплуатации / скважина / куст" />
|
||||
<DateInput source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberInput source="totalEngineHours" label="Общая наработка, моточасов" />
|
||||
<NumberInput source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта, моточасов" />
|
||||
<DateInput source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextInput source="notes" label="Примечания" />
|
||||
<PlainInput source="name" required />
|
||||
<PlainInput source="serialNumber" required />
|
||||
<PlainInput source="inventoryNumber" required />
|
||||
<SelectInput
|
||||
source="equipmentType"
|
||||
choices={equipmentTypeChoices}
|
||||
required
|
||||
/>
|
||||
<DateInput source="dateOfInspection" />
|
||||
<SelectInput
|
||||
source="periodicityTO"
|
||||
choices={periodicityChoices}
|
||||
required
|
||||
/>
|
||||
<PlainInput source="location" />
|
||||
<SelectInput source="status" choices={equipmentStatusChoices} required />
|
||||
<DateInput source="commissionedAt" />
|
||||
<NumberInput source="totalEngineHours" />
|
||||
<NumberInput source="engineHoursSinceLastRepair" />
|
||||
<DateInput source="lastRepairAt" />
|
||||
<PlainInput source="notes" multiline />
|
||||
<SelectInput source="workAsPartOf" choices={laborOperationChoices} />
|
||||
<NumberInput source="fuelConsumed" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
|
||||
@@ -1,29 +1,36 @@
|
||||
import { Edit, SimpleForm, TextInput, NumberInput, DateInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
import {
|
||||
DateInput,
|
||||
Edit,
|
||||
NumberInput,
|
||||
SelectInput,
|
||||
SimpleForm,
|
||||
} from "react-admin";
|
||||
import {
|
||||
equipmentStatusChoices,
|
||||
equipmentTypeChoices,
|
||||
laborOperationChoices,
|
||||
periodicityChoices,
|
||||
} from "../shared/enums";
|
||||
import { PlainInput } from "../shared/inputs";
|
||||
|
||||
export const EquipmentEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="id" label="id" disabled />
|
||||
<TextInput source="inventoryNumber" label="Инвентарный номер" isRequired />
|
||||
<TextInput source="serialNumber" label="Заводской (серийный) номер" />
|
||||
<TextInput source="name" label="Наименование единицы оборудования" isRequired />
|
||||
<ReferenceInput source="equipmentTypeCode" reference="equipment-types">
|
||||
<AutocompleteInput label="Вид оборудования" optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="status" label="Текущий статус" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<TextInput source="location" label="Место эксплуатации / скважина / куст" />
|
||||
<DateInput source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberInput source="totalEngineHours" label="Общая наработка, моточасов" />
|
||||
<NumberInput source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта, моточасов" />
|
||||
<DateInput source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextInput source="notes" label="Примечания" />
|
||||
<PlainInput source="name" />
|
||||
<PlainInput source="serialNumber" />
|
||||
<PlainInput source="inventoryNumber" />
|
||||
<SelectInput source="equipmentType" choices={equipmentTypeChoices} />
|
||||
<DateInput source="dateOfInspection" />
|
||||
<SelectInput source="periodicityTO" choices={periodicityChoices} />
|
||||
<PlainInput source="location" />
|
||||
<SelectInput source="status" choices={equipmentStatusChoices} />
|
||||
<DateInput source="commissionedAt" />
|
||||
<NumberInput source="totalEngineHours" />
|
||||
<NumberInput source="engineHoursSinceLastRepair" />
|
||||
<DateInput source="lastRepairAt" />
|
||||
<PlainInput source="notes" multiline />
|
||||
<SelectInput source="workAsPartOf" choices={laborOperationChoices} />
|
||||
<NumberInput source="fuelConsumed" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
|
||||
@@ -1,66 +1,78 @@
|
||||
import {
|
||||
List,
|
||||
CreateButton,
|
||||
Datagrid,
|
||||
DateField,
|
||||
FilterButton,
|
||||
List,
|
||||
NumberField,
|
||||
SelectArrayInput,
|
||||
SelectField,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
FilterButton,
|
||||
CreateButton,
|
||||
ExportButton,
|
||||
NumberField,
|
||||
DateField,
|
||||
SelectField,
|
||||
ReferenceField,
|
||||
SelectArrayInput,
|
||||
ReferenceInput,
|
||||
AutocompleteInput
|
||||
} from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
} from "react-admin";
|
||||
import {
|
||||
equipmentStatusChoices,
|
||||
equipmentTypeChoices,
|
||||
laborOperationChoices,
|
||||
periodicityChoices,
|
||||
} from "../shared/enums";
|
||||
|
||||
const equipmentFilters = [
|
||||
<TextInput key="q" source="q" label="Поиск" alwaysOn />,
|
||||
<TextInput key="inventoryNumber" source="inventoryNumber" label="Инвентарный номер" />,
|
||||
<TextInput key="serialNumber" source="serialNumber" label="Заводской (серийный) номер" />,
|
||||
<TextInput key="name" source="name" label="Наименование единицы оборудования" />,
|
||||
<ReferenceInput key="equipmentTypeCode" source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования">
|
||||
<AutocompleteInput optionText={(record) => record.code ? `${record.code} — ${record.name ?? record.code}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>,
|
||||
<SelectArrayInput key="status" source="status" label="Текущий статус" choices={statusChoices} />,
|
||||
<TextInput key="location" source="location" label="Место эксплуатации / скважина / куст" />,
|
||||
<TextInput key="notes" source="notes" label="Примечания" />
|
||||
<TextInput key="q" source="q" label="Search" alwaysOn />,
|
||||
<TextInput
|
||||
key="inventoryNumber"
|
||||
source="inventoryNumber"
|
||||
label="Inventory number"
|
||||
/>,
|
||||
<TextInput key="serialNumber" source="serialNumber" label="Serial number" />,
|
||||
<TextInput key="name" source="name" label="Name" />,
|
||||
<SelectArrayInput
|
||||
key="equipmentType"
|
||||
source="equipmentType"
|
||||
label="Type"
|
||||
choices={equipmentTypeChoices}
|
||||
/>,
|
||||
<SelectArrayInput
|
||||
key="periodicityTO"
|
||||
source="periodicityTO"
|
||||
label="Periodicity"
|
||||
choices={periodicityChoices}
|
||||
/>,
|
||||
<SelectArrayInput
|
||||
key="status"
|
||||
source="status"
|
||||
label="Status"
|
||||
choices={equipmentStatusChoices}
|
||||
/>,
|
||||
<TextInput key="location" source="location" label="Location" />,
|
||||
<SelectArrayInput
|
||||
key="workAsPartOf"
|
||||
source="workAsPartOf"
|
||||
label="Operation"
|
||||
choices={laborOperationChoices}
|
||||
/>,
|
||||
];
|
||||
|
||||
const EquipmentListActions = () => (
|
||||
<TopToolbar>
|
||||
<FilterButton filters={equipmentFilters} />
|
||||
<CreateButton />
|
||||
<ExportButton />
|
||||
</TopToolbar>
|
||||
);
|
||||
|
||||
export const EquipmentList = () => (
|
||||
<List actions={<EquipmentListActions />} filters={equipmentFilters} sort={{ field: 'inventoryNumber', order: 'ASC' }}>
|
||||
<List
|
||||
filters={equipmentFilters}
|
||||
actions={
|
||||
<TopToolbar>
|
||||
<FilterButton />
|
||||
<CreateButton />
|
||||
</TopToolbar>
|
||||
}
|
||||
>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="inventoryNumber" label="Инвентарный номер" />
|
||||
<TextField source="serialNumber" label="Заводской (серийный) номер" />
|
||||
<TextField source="name" label="Наименование единицы оборудования" />
|
||||
<ReferenceField source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования" link="show">
|
||||
<TextField source="code" />
|
||||
</ReferenceField>
|
||||
<SelectField source="status" label="Текущий статус" choices={statusChoices} />
|
||||
<TextField source="location" label="Место эксплуатации / скважина / куст" />
|
||||
<DateField source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberField source="totalEngineHours" label="Общая наработка, моточасов" />
|
||||
<NumberField source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта, моточасов" />
|
||||
<DateField source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextField source="notes" label="Примечания" />
|
||||
<TextField source="inventoryNumber" />
|
||||
<TextField source="name" />
|
||||
<TextField source="serialNumber" />
|
||||
<SelectField source="equipmentType" choices={equipmentTypeChoices} />
|
||||
<SelectField source="status" choices={equipmentStatusChoices} />
|
||||
<DateField source="dateOfInspection" />
|
||||
<NumberField source="totalEngineHours" />
|
||||
<TextField source="location" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
|
||||
@@ -1,28 +1,35 @@
|
||||
import { Show, SimpleShowLayout, TextField, NumberField, DateField, SelectField, ReferenceField } from 'react-admin';
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Active', name: 'В эксплуатации' },
|
||||
{ id: 'Repair', name: 'В ремонте' },
|
||||
{ id: 'Reserve', name: 'В резерве' },
|
||||
{ id: 'WriteOff', name: 'Списано' },
|
||||
];
|
||||
import {
|
||||
DateField,
|
||||
NumberField,
|
||||
SelectField,
|
||||
Show,
|
||||
SimpleShowLayout,
|
||||
TextField,
|
||||
} from "react-admin";
|
||||
import {
|
||||
equipmentStatusChoices,
|
||||
equipmentTypeChoices,
|
||||
laborOperationChoices,
|
||||
periodicityChoices,
|
||||
} from "../shared/enums";
|
||||
export const EquipmentShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="inventoryNumber" label="Инвентарный номер" />
|
||||
<TextField source="serialNumber" label="Заводской (серийный) номер" />
|
||||
<TextField source="name" label="Наименование единицы оборудования" />
|
||||
<ReferenceField source="equipmentTypeCode" reference="equipment-types" label="Вид оборудования" link="show">
|
||||
<TextField source="code" />
|
||||
</ReferenceField>
|
||||
<SelectField source="status" label="Текущий статус" choices={statusChoices} />
|
||||
<TextField source="location" label="Место эксплуатации / скважина / куст" />
|
||||
<DateField source="commissionedAt" label="Дата ввода в эксплуатацию" />
|
||||
<NumberField source="totalEngineHours" label="Общая наработка, моточасов" />
|
||||
<NumberField source="engineHoursSinceLastRepair" label="Наработка с последнего ремонта, моточасов" />
|
||||
<DateField source="lastRepairAt" label="Дата последнего ремонта" />
|
||||
<TextField source="notes" label="Примечания" />
|
||||
<TextField source="inventoryNumber" />
|
||||
<TextField source="name" />
|
||||
<TextField source="serialNumber" />
|
||||
<SelectField source="equipmentType" choices={equipmentTypeChoices} />
|
||||
<DateField source="dateOfInspection" />
|
||||
<SelectField source="periodicityTO" choices={periodicityChoices} />
|
||||
<TextField source="location" />
|
||||
<SelectField source="status" choices={equipmentStatusChoices} />
|
||||
<DateField source="commissionedAt" />
|
||||
<NumberField source="totalEngineHours" />
|
||||
<NumberField source="engineHoursSinceLastRepair" />
|
||||
<DateField source="lastRepairAt" />
|
||||
<TextField source="notes" />
|
||||
<SelectField source="workAsPartOf" choices={laborOperationChoices} />
|
||||
<NumberField source="fuelConsumed" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
|
||||
15
client/src/resources/part/PartCreate.tsx
Normal file
15
client/src/resources/part/PartCreate.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Create, NumberInput, SelectInput, SimpleForm } from "react-admin";
|
||||
import { categoryPartChoices } from "../shared/enums";
|
||||
import { PlainInput } from "../shared/inputs";
|
||||
|
||||
export const PartCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<PlainInput source="name" required />
|
||||
<SelectInput source="categories" choices={categoryPartChoices} />
|
||||
<NumberInput source="price" />
|
||||
<PlainInput source="description" multiline />
|
||||
<PlainInput source="serialNumber" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
15
client/src/resources/part/PartEdit.tsx
Normal file
15
client/src/resources/part/PartEdit.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Edit, NumberInput, SelectInput, SimpleForm } from "react-admin";
|
||||
import { categoryPartChoices } from "../shared/enums";
|
||||
import { PlainInput } from "../shared/inputs";
|
||||
|
||||
export const PartEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<PlainInput source="name" />
|
||||
<SelectInput source="categories" choices={categoryPartChoices} />
|
||||
<NumberInput source="price" />
|
||||
<PlainInput source="description" multiline />
|
||||
<PlainInput source="serialNumber" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
34
client/src/resources/part/PartList.tsx
Normal file
34
client/src/resources/part/PartList.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
Datagrid,
|
||||
List,
|
||||
NumberField,
|
||||
SelectArrayInput,
|
||||
SelectField,
|
||||
TextField,
|
||||
TextInput,
|
||||
} from "react-admin";
|
||||
import { ResourceListActions } from "../shared/ListActions";
|
||||
import { categoryPartChoices } from "../shared/enums";
|
||||
const partFilters = [
|
||||
<TextInput key="q" source="q" label="Search" alwaysOn />,
|
||||
<SelectArrayInput
|
||||
key="categories"
|
||||
source="categories"
|
||||
label="Category"
|
||||
choices={categoryPartChoices}
|
||||
/>,
|
||||
<TextInput key="serialNumber" source="serialNumber" label="Serial number" />,
|
||||
];
|
||||
export const PartList = () => (
|
||||
<List
|
||||
filters={partFilters}
|
||||
actions={<ResourceListActions filters={partFilters} />}
|
||||
>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="name" />
|
||||
<SelectField source="categories" choices={categoryPartChoices} />
|
||||
<NumberField source="price" />
|
||||
<TextField source="serialNumber" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
19
client/src/resources/part/PartShow.tsx
Normal file
19
client/src/resources/part/PartShow.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import {
|
||||
NumberField,
|
||||
SelectField,
|
||||
Show,
|
||||
SimpleShowLayout,
|
||||
TextField,
|
||||
} from "react-admin";
|
||||
import { categoryPartChoices } from "../shared/enums";
|
||||
export const PartShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="name" />
|
||||
<SelectField source="categories" choices={categoryPartChoices} />
|
||||
<NumberField source="price" />
|
||||
<TextField source="description" />
|
||||
<TextField source="serialNumber" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
9
client/src/resources/price-list/PriceListCreate.tsx
Normal file
9
client/src/resources/price-list/PriceListCreate.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Create, NumberInput, SimpleForm } from "react-admin";
|
||||
export const PriceListCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm toolbar={false}>
|
||||
<NumberInput source="costOfWorkingHours" disabled />
|
||||
<NumberInput source="partPrice" disabled />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
9
client/src/resources/price-list/PriceListEdit.tsx
Normal file
9
client/src/resources/price-list/PriceListEdit.tsx
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Edit, NumberInput, SimpleForm } from "react-admin";
|
||||
export const PriceListEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm toolbar={false}>
|
||||
<NumberInput source="costOfWorkingHours" disabled />
|
||||
<NumberInput source="partPrice" disabled />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
20
client/src/resources/price-list/PriceListList.tsx
Normal file
20
client/src/resources/price-list/PriceListList.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Datagrid, List, NumberField, TextField, TextInput } from "react-admin";
|
||||
import { ResourceListActions } from "../shared/ListActions";
|
||||
const priceListFilters = [
|
||||
<TextInput key="q" source="q" label="Search" alwaysOn />,
|
||||
];
|
||||
export const PriceListList = () => (
|
||||
<List
|
||||
filters={priceListFilters}
|
||||
actions={
|
||||
<ResourceListActions filters={priceListFilters} hasCreate={false} />
|
||||
}
|
||||
perPage={1}
|
||||
>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="id" />
|
||||
<NumberField source="costOfWorkingHours" />
|
||||
<NumberField source="partPrice" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
10
client/src/resources/price-list/PriceListShow.tsx
Normal file
10
client/src/resources/price-list/PriceListShow.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NumberField, Show, SimpleShowLayout, TextField } from "react-admin";
|
||||
export const PriceListShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="id" />
|
||||
<NumberField source="costOfWorkingHours" />
|
||||
<NumberField source="partPrice" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
@@ -1,38 +0,0 @@
|
||||
import { Create, SimpleForm, TextInput, NumberInput, DateInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
];
|
||||
|
||||
export const RepairOrderCreate = () => (
|
||||
<Create>
|
||||
<SimpleForm>
|
||||
<TextInput source="number" label="Номер заявки" isRequired />
|
||||
<ReferenceInput source="equipmentId" reference="equipment">
|
||||
<AutocompleteInput label="Оборудование" optionText={(record) => record.inventoryNumber ? `${record.inventoryNumber} — ${record.name ?? record.inventoryNumber}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="repairKind" label="Вид ремонта" choices={repairKindChoices} emptyText="Не выбрано" />
|
||||
<SelectInput source="status" label="Статус" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<DateInput source="plannedAt" label="Плановая дата начала" />
|
||||
<DateInput source="startedAt" label="Фактическая дата начала" />
|
||||
<DateInput source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextInput source="contractor" label="Подрядная организация (если внешний ремонт)" />
|
||||
<NumberInput source="engineHoursAtRepair" label="Наработка на момент ремонта, моточасов" />
|
||||
<TextInput source="description" label="Описание работ / дефекта" />
|
||||
<TextInput source="notes" label="Примечания" />
|
||||
</SimpleForm>
|
||||
</Create>
|
||||
);
|
||||
@@ -1,39 +0,0 @@
|
||||
import { Edit, SimpleForm, TextInput, NumberInput, DateInput, SelectInput, ReferenceInput, AutocompleteInput } from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
];
|
||||
|
||||
export const RepairOrderEdit = () => (
|
||||
<Edit>
|
||||
<SimpleForm>
|
||||
<TextInput source="id" label="id" disabled />
|
||||
<TextInput source="number" label="Номер заявки" isRequired />
|
||||
<ReferenceInput source="equipmentId" reference="equipment">
|
||||
<AutocompleteInput label="Оборудование" optionText={(record) => record.inventoryNumber ? `${record.inventoryNumber} — ${record.name ?? record.inventoryNumber}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>
|
||||
<SelectInput source="repairKind" label="Вид ремонта" choices={repairKindChoices} emptyText="Не выбрано" />
|
||||
<SelectInput source="status" label="Статус" choices={statusChoices} emptyText="Не выбрано" />
|
||||
<DateInput source="plannedAt" label="Плановая дата начала" />
|
||||
<DateInput source="startedAt" label="Фактическая дата начала" />
|
||||
<DateInput source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextInput source="contractor" label="Подрядная организация (если внешний ремонт)" />
|
||||
<NumberInput source="engineHoursAtRepair" label="Наработка на момент ремонта, моточасов" />
|
||||
<TextInput source="description" label="Описание работ / дефекта" />
|
||||
<TextInput source="notes" label="Примечания" />
|
||||
</SimpleForm>
|
||||
</Edit>
|
||||
);
|
||||
@@ -1,77 +0,0 @@
|
||||
import {
|
||||
List,
|
||||
Datagrid,
|
||||
TextField,
|
||||
TextInput,
|
||||
TopToolbar,
|
||||
FilterButton,
|
||||
CreateButton,
|
||||
ExportButton,
|
||||
NumberField,
|
||||
DateField,
|
||||
SelectField,
|
||||
ReferenceField,
|
||||
SelectArrayInput,
|
||||
SelectInput,
|
||||
ReferenceInput,
|
||||
AutocompleteInput
|
||||
} from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
];
|
||||
|
||||
const repairOrderFilters = [
|
||||
<TextInput key="q" source="q" label="Поиск" alwaysOn />,
|
||||
<TextInput key="number" source="number" label="Номер заявки" />,
|
||||
<ReferenceInput key="equipmentId" source="equipmentId" reference="equipment" label="Оборудование">
|
||||
<AutocompleteInput optionText={(record) => record.inventoryNumber ? `${record.inventoryNumber} — ${record.name ?? record.inventoryNumber}` : (record.name ?? record.id)} filterToQuery={(searchText) => ({ q: searchText })} />
|
||||
</ReferenceInput>,
|
||||
<SelectInput key="repairKind" source="repairKind" label="Вид ремонта" choices={repairKindChoices} emptyText="Все" />,
|
||||
<SelectArrayInput key="status" source="status" label="Статус" choices={statusChoices} />,
|
||||
<TextInput key="contractor" source="contractor" label="Подрядная организация (если внешний ремонт)" />,
|
||||
<TextInput key="description" source="description" label="Описание работ / дефекта" />,
|
||||
<TextInput key="notes" source="notes" label="Примечания" />
|
||||
];
|
||||
|
||||
const RepairOrderListActions = () => (
|
||||
<TopToolbar>
|
||||
<FilterButton filters={repairOrderFilters} />
|
||||
<CreateButton />
|
||||
<ExportButton />
|
||||
</TopToolbar>
|
||||
);
|
||||
|
||||
export const RepairOrderList = () => (
|
||||
<List actions={<RepairOrderListActions />} filters={repairOrderFilters} sort={{ field: 'number', order: 'ASC' }}>
|
||||
<Datagrid rowClick="show">
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="number" label="Номер заявки" />
|
||||
<ReferenceField source="equipmentId" reference="equipment" label="Оборудование" link="show">
|
||||
<TextField source="inventoryNumber" />
|
||||
</ReferenceField>
|
||||
<SelectField source="repairKind" label="Вид ремонта" choices={repairKindChoices} />
|
||||
<SelectField source="status" label="Статус" choices={statusChoices} />
|
||||
<DateField source="plannedAt" label="Плановая дата начала" />
|
||||
<DateField source="startedAt" label="Фактическая дата начала" />
|
||||
<DateField source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextField source="contractor" label="Подрядная организация (если внешний ремонт)" />
|
||||
<NumberField source="engineHoursAtRepair" label="Наработка на момент ремонта, моточасов" />
|
||||
<TextField source="description" label="Описание работ / дефекта" />
|
||||
<TextField source="notes" label="Примечания" />
|
||||
</Datagrid>
|
||||
</List>
|
||||
);
|
||||
@@ -1,38 +0,0 @@
|
||||
import { Show, SimpleShowLayout, TextField, NumberField, DateField, SelectField, ReferenceField } from 'react-admin';
|
||||
|
||||
const repairKindChoices = [
|
||||
{ id: 'TO', name: 'Техническое обслуживание' },
|
||||
{ id: 'TR', name: 'Текущий ремонт' },
|
||||
{ id: 'TRE', name: 'Текущий расширенный ремонт' },
|
||||
{ id: 'KR', name: 'Капитальный ремонт' },
|
||||
{ id: 'AR', name: 'Аварийный ремонт' },
|
||||
{ id: 'MP', name: 'Метрологическая поверка' },
|
||||
];
|
||||
|
||||
const statusChoices = [
|
||||
{ id: 'Draft', name: 'Черновик' },
|
||||
{ id: 'Approved', name: 'Утверждена' },
|
||||
{ id: 'InWork', name: 'В работе' },
|
||||
{ id: 'Done', name: 'Выполнена' },
|
||||
{ id: 'Cancelled', name: 'Отменена' },
|
||||
];
|
||||
export const RepairOrderShow = () => (
|
||||
<Show>
|
||||
<SimpleShowLayout>
|
||||
<TextField source="id" label="id" />
|
||||
<TextField source="number" label="Номер заявки" />
|
||||
<ReferenceField source="equipmentId" reference="equipment" label="Оборудование" link="show">
|
||||
<TextField source="inventoryNumber" />
|
||||
</ReferenceField>
|
||||
<SelectField source="repairKind" label="Вид ремонта" choices={repairKindChoices} />
|
||||
<SelectField source="status" label="Статус" choices={statusChoices} />
|
||||
<DateField source="plannedAt" label="Плановая дата начала" />
|
||||
<DateField source="startedAt" label="Фактическая дата начала" />
|
||||
<DateField source="completedAt" label="Фактическая дата завершения" />
|
||||
<TextField source="contractor" label="Подрядная организация (если внешний ремонт)" />
|
||||
<NumberField source="engineHoursAtRepair" label="Наработка на момент ремонта, моточасов" />
|
||||
<TextField source="description" label="Описание работ / дефекта" />
|
||||
<TextField source="notes" label="Примечания" />
|
||||
</SimpleShowLayout>
|
||||
</Show>
|
||||
);
|
||||
17
client/src/resources/shared/ListActions.tsx
Normal file
17
client/src/resources/shared/ListActions.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { ReactElement } from "react";
|
||||
import { CreateButton, FilterButton, TopToolbar } from "react-admin";
|
||||
|
||||
interface ListActionsProps {
|
||||
filters?: ReactElement[];
|
||||
hasCreate?: boolean;
|
||||
}
|
||||
|
||||
export const ResourceListActions = ({
|
||||
filters,
|
||||
hasCreate = true,
|
||||
}: ListActionsProps) => (
|
||||
<TopToolbar>
|
||||
{filters ? <FilterButton filters={filters} /> : null}
|
||||
{hasCreate ? <CreateButton /> : null}
|
||||
</TopToolbar>
|
||||
);
|
||||
66
client/src/resources/shared/enums.ts
Normal file
66
client/src/resources/shared/enums.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
export const equipmentStatusChoices = [
|
||||
"Active",
|
||||
"Repair",
|
||||
"Reserve",
|
||||
"WriteOff",
|
||||
].map((value) => ({ id: value, name: value }));
|
||||
export const laborOperationChoices = ["Manual", "MachineManual", "Machine"].map(
|
||||
(value) => ({ id: value, name: value }),
|
||||
);
|
||||
export const periodicityChoices = [
|
||||
"Ежедневное",
|
||||
"Еженедельное",
|
||||
"Ежемесячное",
|
||||
"Полугодовое",
|
||||
"Годовое",
|
||||
].map((value) => ({ id: value, name: value }));
|
||||
export const roleChoices = ["Исполнитель", "Подписант", "Пользователь"].map(
|
||||
(value) => ({ id: value, name: value }),
|
||||
);
|
||||
export const categoryPartChoices = [
|
||||
"Расходник",
|
||||
"Запчасть",
|
||||
"Инструмент",
|
||||
"Спецодежда",
|
||||
].map((value) => ({ id: value, name: value }));
|
||||
export const equipmentTypeChoices = [
|
||||
"Производственное",
|
||||
"Энергетическое",
|
||||
"Насосное",
|
||||
"Компрессорное",
|
||||
].map((value) => ({ id: value, name: value }));
|
||||
|
||||
export const equipmentOptionText = (
|
||||
record?: Record<string, unknown> | null,
|
||||
): string => {
|
||||
if (!record) return "";
|
||||
const inventoryNumber =
|
||||
typeof record.inventoryNumber === "string" ? record.inventoryNumber : "";
|
||||
const name = typeof record.name === "string" ? record.name : inventoryNumber;
|
||||
return inventoryNumber
|
||||
? inventoryNumber + " — " + (name || inventoryNumber)
|
||||
: typeof record.name === "string"
|
||||
? record.name
|
||||
: String(record.id ?? "");
|
||||
};
|
||||
|
||||
export const employeeOptionText = (
|
||||
record?: Record<string, unknown> | null,
|
||||
): string => {
|
||||
if (!record) return "";
|
||||
if (typeof record.code === "string") {
|
||||
const fallback =
|
||||
typeof record.fullName === "string" ? record.fullName : record.code;
|
||||
return record.code + " — " + fallback;
|
||||
}
|
||||
if (typeof record.fullName === "string") return record.fullName;
|
||||
return String(record.id ?? "");
|
||||
};
|
||||
|
||||
export const partOptionText = (
|
||||
record?: Record<string, unknown> | null,
|
||||
): string => {
|
||||
if (!record) return "";
|
||||
if (typeof record.name === "string") return record.name;
|
||||
return String(record.id ?? "");
|
||||
};
|
||||
3
client/src/resources/shared/inputs.tsx
Normal file
3
client/src/resources/shared/inputs.tsx
Normal file
@@ -0,0 +1,3 @@
|
||||
import { TextInput } from "react-admin";
|
||||
|
||||
export const PlainInput = TextInput;
|
||||
11
client/src/vite-env.d.ts
vendored
11
client/src/vite-env.d.ts
vendored
@@ -1,12 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
|
||||
interface ImportMetaEnv {
|
||||
readonly VITE_API_URL: string;
|
||||
readonly VITE_KEYCLOAK_URL: string;
|
||||
readonly VITE_KEYCLOAK_REALM: string;
|
||||
readonly VITE_KEYCLOAK_CLIENT_ID: string;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
28
client/tsconfig.app.json
Normal file
28
client/tsconfig.app.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2023",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2023", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"types": ["vite/client"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,25 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true
|
||||
},
|
||||
"include": ["src"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"skipLibCheck": true,
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2023",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"types": ["node"],
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "bundler",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true
|
||||
"allowImportingTsExtensions": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"erasableSyntaxOnly": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user