frontend #1

Merged
d3m0k1d merged 13 commits from frontend into backend 2026-04-03 22:47:30 +00:00
49 changed files with 7830 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
.qwen
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+14
View File
@@ -0,0 +1,14 @@
{
"permissions": {
"allow": [
"Bash(yarn *)",
"Bash(npx *)",
"Bash(npm run *)",
"Bash(type *)",
"Bash(dir)",
"Bash(move *)",
"Bash(findstr *)"
]
},
"$version": 3
}
+73
View File
@@ -0,0 +1,73 @@
# React + TypeScript + Vite
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) 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:
```js
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...
},
},
])
```
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
View 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,
},
},
])
+13
View File
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>frontend</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
+43
View File
@@ -0,0 +1,43 @@
{
"name": "HellreigN",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"lint": "eslint .",
"preview": "vite preview"
},
"dependencies": {
"@codemirror/lang-sql": "^6.10.0",
"@tailwindcss/vite": "^4.2.2",
"@uiw/react-codemirror": "^4.25.8",
"axios": "^1.13.6",
"framer-motion": "^12.38.0",
"primeicons": "^7.0.0",
"primereact": "^10.9.7",
"react": "^19.2.4",
"react-dom": "^19.2.4",
"react-icons": "^5.6.0",
"react-router-dom": "^7.13.1",
"recharts": "^3.8.0",
"tailwind": "^4.0.0",
"tailwindcss": "^4.2.2",
"zustand": "^5.0.12"
},
"devDependencies": {
"@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"
}
}
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.3 KiB

+24
View 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

+16
View File
@@ -0,0 +1,16 @@
import "@/shared/styles/index.css";
import "primereact/resources/themes/lara-light-cyan/theme.css";
import "primereact/resources/primereact.min.css";
import "primeicons/primeicons.css";
import { PrimeReactProvider } from "primereact/api";
import { Routing } from "./providers/routing/routing";
function App() {
return (
<PrimeReactProvider>
<Routing />
</PrimeReactProvider>
);
}
export default App;
@@ -0,0 +1,12 @@
import { useAuthStore } from "@/store/auth/auth.store";
import { Navigate } from "react-router-dom";
export const ProtectedRoute = ({ children }: { children: React.ReactNode }) => {
const { isAuthenticated } = useAuthStore();
if (!isAuthenticated) {
return <Navigate to="/auth" replace />;
}
return <>{children}</>;
};
@@ -0,0 +1,32 @@
import { Suspense } from "react";
import { Routes as ReactRoutes, Route, Navigate } from "react-router-dom";
import { HomePage } from "@/pages/home.page";
import { ThemesPage } from "@/pages/themes.page";
import { AuthPage } from "@/pages/auth.page";
import { RegisterPage } from "@/pages/register.page";
import { AddAgentsPage } from "@/pages/add-agents.page";
import { DefaultLayout } from "@/shared/layouts/DefaultLayout";
export const Routing = () => {
return (
<Suspense
fallback={
<div className="flex items-center justify-center min-h-screen">
Загрузка...
</div>
}
>
<ReactRoutes>
<Route element={<DefaultLayout />}>
<Route path="/" element={<HomePage />} />
<Route path="/auth" element={<AuthPage />} />
<Route path="/register" element={<RegisterPage />} />
<Route path="/themes" element={<ThemesPage />} />
<Route path="/add-agents" element={<AddAgentsPage />} />
<Route path="*" element={<Navigate to="/" replace />} />
</Route>
</ReactRoutes>
</Suspense>
);
};
+12
View File
@@ -0,0 +1,12 @@
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router";
import { ThemeInitialProvider } from "./modules/theme-changer";
import App from "./app/App";
createRoot(document.getElementById("root")!).render(
<BrowserRouter>
<ThemeInitialProvider>
<App />
</ThemeInitialProvider>
</BrowserRouter>,
);
@@ -0,0 +1,27 @@
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const DeployType = {
Docker: "docker",
Binary: "binary",
Deploy: "deploy",
} as const;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const AuthMethod = {
Key: "key",
Password: "password",
} as const;
export interface ExtraField {
key: string;
value: string;
}
export interface SSHAgentConfig {
user: string;
ip: string;
authMethod: string;
sshKey?: string;
password?: string;
extraFields: ExtraField[];
deployType: string;
}
@@ -0,0 +1,496 @@
import React from "react";
import {
FiServer,
FiGlobe,
FiKey,
FiLock,
FiPlus,
FiTrash2,
FiSettings,
} from "react-icons/fi";
import { SiDocker } from "react-icons/si";
import { FiPackage, FiUploadCloud } from "react-icons/fi";
type DeployType = "docker" | "binary" | "deploy";
type AuthMethod = "key" | "password";
interface ExtraField {
key: string;
value: string;
}
export interface SSHAgentConfig {
user: string;
ip: string;
authMethod: AuthMethod;
sshKey?: string;
password?: string;
extraFields: ExtraField[];
deployType: DeployType;
}
interface SSHAgentFormProps {
index: number;
config: SSHAgentConfig;
onChange: (index: number, config: SSHAgentConfig) => void;
onRemove: (index: number) => void;
canRemove: boolean;
}
const DEPLOY_OPTIONS: {
value: DeployType;
label: string;
icon: React.ReactNode;
}[] = [
{ value: "docker", label: "Docker", icon: <SiDocker /> },
{ value: "binary", label: "Binary", icon: <FiPackage /> },
];
const inputBaseStyle: React.CSSProperties = {
width: "100%",
padding: "10px 12px",
border: "1px solid var(--border)",
borderRadius: "8px",
backgroundColor: "var(--input-bg)",
color: "var(--text-primary)",
fontSize: "14px",
transition: "border-color 0.2s, box-shadow 0.2s",
};
const labelStyle: React.CSSProperties = {
display: "block",
marginBottom: "8px",
color: "var(--text-secondary)",
fontSize: "14px",
fontWeight: 500,
};
export const SSHAgentForm: React.FC<SSHAgentFormProps> = ({
index,
config,
onChange,
onRemove,
canRemove,
}) => {
const handleChange = (field: keyof SSHAgentConfig, value: unknown) => {
onChange(index, { ...config, [field]: value });
};
const handleExtraFieldChange = (
fieldIndex: number,
field: keyof ExtraField,
value: string,
) => {
const newExtraFields = [...config.extraFields];
newExtraFields[fieldIndex] = {
...newExtraFields[fieldIndex],
[field]: value,
};
handleChange("extraFields", newExtraFields);
};
const addExtraField = () => {
handleChange("extraFields", [
...config.extraFields,
{ key: "", value: "" },
]);
};
const removeExtraField = (fieldIndex: number) => {
const newExtraFields = config.extraFields.filter(
(_, i) => i !== fieldIndex,
);
handleChange("extraFields", newExtraFields);
};
const handleFocus = (
e: React.FocusEvent<
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
>,
) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px var(--border-focus)30`;
};
const handleBlur = (
e: React.FocusEvent<
HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement
>,
) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
};
return (
<div
className="rounded-2xl shadow-lg border"
style={{
backgroundColor: "var(--card-bg)",
borderColor: "var(--border)",
padding: "24px",
marginBottom: "20px",
}}
>
{/* Header */}
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: "24px",
paddingBottom: "16px",
borderBottom: "1px solid var(--border)",
}}
>
<div style={{ display: "flex", alignItems: "center", gap: "12px" }}>
<div
className="w-10 h-10 rounded-lg flex items-center justify-center"
style={{ backgroundColor: "var(--bg-secondary)" }}
>
<FiServer style={{ color: "var(--accent)", fontSize: "20px" }} />
</div>
<h3
style={{
margin: 0,
color: "var(--text-primary)",
fontSize: "18px",
fontWeight: 600,
}}
>
SSH сервер #{index + 1}
</h3>
</div>
{canRemove && (
<button
type="button"
onClick={() => onRemove(index)}
className="flex items-center gap-2 px-4 py-2 rounded-lg transition-all"
style={{
background: "var(--error-bg)",
color: "var(--error-text)",
border: "1px solid var(--error-border)",
cursor: "pointer",
fontSize: "14px",
fontWeight: 500,
}}
onMouseEnter={(e) => {
e.currentTarget.style.background = "var(--error-text)";
e.currentTarget.style.color = "#fff";
}}
onMouseLeave={(e) => {
e.currentTarget.style.background = "var(--error-bg)";
e.currentTarget.style.color = "var(--error-text)";
}}
>
<FiTrash2 size={14} />
Удалить
</button>
)}
</div>
<div style={{ display: "grid", gap: "20px" }}>
{/* User и IP */}
<div
style={{
display: "grid",
gridTemplateColumns: "1fr 1fr",
gap: "16px",
}}
>
<div>
<label style={labelStyle}>
<span
style={{ display: "flex", alignItems: "center", gap: "6px" }}
>
<FiServer size={14} />
Пользователь *
</span>
</label>
<input
type="text"
value={config.user}
onChange={(e) => handleChange("user", e.target.value)}
required
style={inputBaseStyle}
onFocus={handleFocus}
onBlur={handleBlur}
placeholder="username"
/>
</div>
<div>
<label style={labelStyle}>
<span
style={{ display: "flex", alignItems: "center", gap: "6px" }}
>
<FiGlobe size={14} />
IP адрес *
</span>
</label>
<input
type="text"
value={config.ip}
onChange={(e) => handleChange("ip", e.target.value)}
required
style={inputBaseStyle}
onFocus={handleFocus}
onBlur={handleBlur}
placeholder="192.168.1.1"
/>
</div>
</div>
{/* Метод аутентификации */}
<div>
<label style={labelStyle}>
<span style={{ display: "flex", alignItems: "center", gap: "6px" }}>
<FiKey size={14} />
Метод аутентификации *
</span>
</label>
<div style={{ display: "flex", gap: "8px" }}>
{(["key", "password"] as const).map((method) => (
<button
key={method}
type="button"
onClick={() => handleChange("authMethod", method)}
className="flex-1 py-2.5 px-4 rounded-lg border transition-all font-medium"
style={{
backgroundColor:
config.authMethod === method
? "var(--accent)"
: "var(--input-bg)",
color:
config.authMethod === method
? "var(--accent-text)"
: "var(--text-primary)",
borderColor:
config.authMethod === method
? "var(--accent)"
: "var(--border)",
cursor: "pointer",
fontSize: "14px",
}}
>
{method === "key" ? "SSH ключ" : "Пароль"}
</button>
))}
</div>
</div>
{/* SSH Key или Password */}
{config.authMethod === "key" ? (
<div>
<label style={labelStyle}>
<span
style={{ display: "flex", alignItems: "center", gap: "6px" }}
>
<FiKey size={14} />
SSH ключ *
</span>
</label>
<textarea
value={config.sshKey || ""}
onChange={(e) => handleChange("sshKey", e.target.value)}
required
rows={4}
style={{
...inputBaseStyle,
fontFamily: "ui-monospace, SFMono-Regular, monospace",
resize: "vertical",
}}
onFocus={handleFocus}
onBlur={handleBlur}
placeholder="-----BEGIN OPENSSH PRIVATE KEY-----"
/>
</div>
) : (
<div>
<label style={labelStyle}>
<span
style={{ display: "flex", alignItems: "center", gap: "6px" }}
>
<FiLock size={14} />
Пароль *
</span>
</label>
<input
type="password"
value={config.password || ""}
onChange={(e) => handleChange("password", e.target.value)}
required
style={inputBaseStyle}
onFocus={handleFocus}
onBlur={handleBlur}
placeholder="••••••••"
/>
</div>
)}
{/* Дополнительные поля */}
<div>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: "12px",
}}
>
<label style={{ ...labelStyle, marginBottom: 0 }}>
<span
style={{ display: "flex", alignItems: "center", gap: "6px" }}
>
<FiSettings size={14} />
Дополнительные параметры
</span>
</label>
<button
type="button"
onClick={addExtraField}
className="flex items-center gap-2 px-3 py-1.5 rounded-lg transition-all"
style={{
background: "var(--accent)",
color: "var(--accent-text)",
border: "none",
cursor: "pointer",
fontSize: "13px",
fontWeight: 500,
}}
onMouseEnter={(e) => {
e.currentTarget.style.opacity = "0.85";
}}
onMouseLeave={(e) => {
e.currentTarget.style.opacity = "1";
}}
>
<FiPlus size={14} />
Добавить
</button>
</div>
{config.extraFields.length === 0 && (
<div
className="text-center py-6 rounded-lg border border-dashed"
style={{
color: "var(--text-muted)",
borderColor: "var(--border)",
}}
>
<FiSettings
size={20}
style={{ margin: "0 auto 8px", opacity: 0.5 }}
/>
<p style={{ margin: 0, fontSize: "13px" }}>
Нет дополнительных параметров
</p>
</div>
)}
{config.extraFields.map((extra, fieldIndex) => (
<div
key={fieldIndex}
style={{
display: "grid",
gridTemplateColumns: "1fr 1fr auto",
gap: "8px",
marginBottom: "8px",
}}
>
<input
type="text"
value={extra.key}
onChange={(e) =>
handleExtraFieldChange(fieldIndex, "key", e.target.value)
}
style={inputBaseStyle}
onFocus={handleFocus}
onBlur={handleBlur}
placeholder="Параметр"
/>
<input
type="text"
value={extra.value}
onChange={(e) =>
handleExtraFieldChange(fieldIndex, "value", e.target.value)
}
style={inputBaseStyle}
onFocus={handleFocus}
onBlur={handleBlur}
placeholder="Значение"
/>
<button
type="button"
onClick={() => removeExtraField(fieldIndex)}
className="flex items-center justify-center rounded-lg border transition-all"
style={{
background: "var(--error-bg)",
color: "var(--error-text)",
borderColor: "var(--error-border)",
cursor: "pointer",
fontSize: "18px",
padding: "8px 12px",
}}
onMouseEnter={(e) => {
e.currentTarget.style.background = "var(--error-text)";
e.currentTarget.style.color = "#fff";
}}
onMouseLeave={(e) => {
e.currentTarget.style.background = "var(--error-bg)";
e.currentTarget.style.color = "var(--error-text)";
}}
>
×
</button>
</div>
))}
</div>
{/* Тип развертывания */}
<div>
<label style={labelStyle}>
<span style={{ display: "flex", alignItems: "center", gap: "6px" }}>
<FiUploadCloud size={16} />
Тип развертывания *
</span>
</label>
<div
style={{
display: "grid",
gridTemplateColumns: "1fr 1fr 1fr",
gap: "8px",
}}
>
{DEPLOY_OPTIONS.map((option) => (
<button
key={option.value}
type="button"
onClick={() => handleChange("deployType", option.value)}
className="flex items-center justify-center gap-2 py-3 px-4 rounded-lg border transition-all font-medium"
style={{
backgroundColor:
config.deployType === option.value
? "var(--accent)"
: "var(--input-bg)",
color:
config.deployType === option.value
? "var(--accent-text)"
: "var(--text-primary)",
borderColor:
config.deployType === option.value
? "var(--accent)"
: "var(--border)",
cursor: "pointer",
fontSize: "14px",
}}
>
<span style={{ fontSize: "18px" }}>{option.icon}</span>
{option.label}
</button>
))}
</div>
</div>
</div>
</div>
);
};
@@ -0,0 +1,91 @@
import { create } from "zustand";
import { persist } from "zustand/middleware";
import { apiClient } from "@/shared/api/axios.instance";
import type {
AuthState,
LoginCredentials,
RegisterData,
User,
LoginResponse,
} from "../types/auth.types";
const login = async (credentials: LoginCredentials): Promise<LoginResponse> => {
const response = await apiClient.post<LoginResponse>(
"/auth/login",
credentials,
);
return response.data;
};
const register = async (data: RegisterData): Promise<LoginResponse> => {
const response = await apiClient.post<LoginResponse>("/auth/register", {
login: data.login,
password: data.password,
name: data.firstName,
last_name: data.lastName,
});
return response.data;
};
const mapResponseToUser = (response: LoginResponse): User => ({
login: response.login,
name: response.name,
last_name: response.last_name,
permission_admin: response.permission_admin,
permission_manage_agent: response.permission_manage_agent,
permission_view: response.permission_view,
});
export const useAuthStore = create<AuthState>()(
persist(
(set) => ({
user: null,
token: null,
isLoading: false,
error: null,
login: async (credentials: LoginCredentials) => {
set({ isLoading: true, error: null });
try {
const response = await login(credentials);
const user = mapResponseToUser(response);
set({ user, token: response.token, isLoading: false });
} catch (error) {
set({
error: error instanceof Error ? error.message : "Login failed",
isLoading: false,
});
throw error;
}
},
register: async (data: RegisterData) => {
set({ isLoading: true, error: null });
try {
const response = await register(data);
const user = mapResponseToUser(response);
set({ user, token: response.token, isLoading: false });
} catch (error) {
set({
error:
error instanceof Error ? error.message : "Registration failed",
isLoading: false,
});
throw error;
}
},
logout: () => {
set({ user: null, token: null, error: null });
},
clearError: () => {
set({ error: null });
},
}),
{
name: "auth-storage",
partialize: (state) => ({ token: state.token, user: state.user }),
},
),
);
@@ -0,0 +1,43 @@
export interface LoginCredentials {
login: string;
password: string;
}
export interface RegisterData {
login: string;
password: string;
firstName: string;
lastName: string;
}
export interface LoginResponse {
name: string;
login: string;
last_name: string;
permission_admin: boolean;
permission_manage_agent: boolean;
permission_view: boolean;
token: string;
}
export interface User {
login: string;
name: string;
last_name: string;
permission_admin: boolean;
permission_manage_agent: boolean;
permission_view: boolean;
}
export interface AuthState {
user: User | null;
token: string | null;
isLoading: boolean;
error: string | null;
login: (credentials: LoginCredentials) => Promise<void>;
register: (data: RegisterData) => Promise<void>;
logout: () => void;
clearError: () => void;
}
export type Theme = "light" | "dark";
@@ -0,0 +1,35 @@
import type { Theme } from "@/modules/auth/types/auth.types";
import { create } from "zustand";
import { persist } from "zustand/middleware";
import { applyTheme, getSavedTheme, getCurrentTheme } from "@/modules/theme-changer/utils/apply.theme";
interface ThemeState {
theme: Theme;
toggleTheme: () => void;
setTheme: (theme: Theme) => void;
}
export const useThemeStore = create<ThemeState>()(
persist(
(set, get) => ({
theme: "dark" as Theme,
toggleTheme: () => {
const currentTheme = getCurrentTheme();
const newThemeType = currentTheme === "dark" || currentTheme === "nightowl" || currentTheme === "sunset" || currentTheme === "forest" || currentTheme === "ocean" || currentTheme === "coffee"
? "light"
: "dark";
// Переключаемся между light и dark базовыми темами
const newTheme = newThemeType === "dark" ? "dark" : "light";
applyTheme(newTheme);
set({ theme: newTheme as Theme });
},
setTheme: (theme: Theme) => {
applyTheme(theme);
set({ theme });
},
}),
{
name: "theme-storage",
},
),
);
@@ -0,0 +1,57 @@
import React, { useState, useEffect } from "react";
import { FiSun, FiMoon } from "react-icons/fi";
import { getCurrentTheme, toggleDarkLight, getSavedTheme } from "../../theme-changer/utils/apply.theme";
import { themes } from "../../theme-changer/config/theme.config";
export const ThemeToggle: React.FC = () => {
const [currentTheme, setCurrentTheme] = useState<string>(() => getSavedTheme());
const currentThemeData = themes.find((t) => t.id === currentTheme);
const isDark = currentThemeData?.type === "dark";
const handleClick = () => {
const newTheme = toggleDarkLight();
setCurrentTheme(newTheme);
};
// Инициализация при монтировании
useEffect(() => {
const saved = getSavedTheme();
const current = getCurrentTheme() || saved;
setCurrentTheme(current);
}, []);
// Слушаем изменения темы из других компонентов
useEffect(() => {
const handleThemeChange = (e: Event) => {
const event = e as CustomEvent;
setCurrentTheme(event.detail.theme);
};
window.addEventListener("themechange", handleThemeChange);
return () => window.removeEventListener("themechange", handleThemeChange);
}, []);
return (
<button
onClick={handleClick}
className="p-2 rounded-lg transition-colors duration-200"
style={{
backgroundColor: "var(--bg-secondary)",
}}
onMouseEnter={(e) => {
e.currentTarget.style.backgroundColor = "var(--bg-tertiary)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "var(--bg-secondary)";
}}
aria-label="Переключить тему"
title={isDark ? "Переключить на светлую тему" : "Переключить на тёмную тему"}
>
{isDark ? (
<FiSun className="w-5 h-5" style={{ color: "var(--accent)" }} />
) : (
<FiMoon className="w-5 h-5" style={{ color: "var(--text-secondary)" }} />
)}
</button>
);
};
@@ -0,0 +1,106 @@
export const themes = [
{
id: "light",
name: "Светлая",
description: "Чистая светлая тема",
type: "light",
colors: {
primary: "#4f46e5",
background: "#ffffff",
surface: "#f8fafc",
text: "#1f2937",
border: "#e5e7eb",
},
},
{
id: "dark",
name: "Темная",
description: "Элегантная темная тема",
type: "dark",
colors: {
primary: "#6366f1",
background: "#0f172a",
surface: "#1e293b",
text: "#f1f5f9",
border: "#334155",
},
},
{
id: "nightowl",
name: "Night Owl",
description: "Тема вдохновленная редактором кода",
type: "dark",
colors: {
primary: "#7dd3fc",
background: "#011627",
surface: "#011e3c",
text: "#d6deeb",
border: "#1d3b53",
},
},
{
id: "sunset",
name: "Закат",
description: "Теплые оранжевые тона",
type: "dark",
colors: {
primary: "#f97316",
background: "#1c1917",
surface: "#292524",
text: "#fafaf9",
border: "#57534e",
},
},
{
id: "forest",
name: "Лес",
description: "Успокаивающая зеленая тема",
type: "dark",
colors: {
primary: "#22c55e",
background: "#052e16",
surface: "#14532d",
text: "#f0fdf4",
border: "#166534",
},
},
{
id: "ocean",
name: "Океан",
description: "Глубокие синие тона",
type: "dark",
colors: {
primary: "#06b6d4",
background: "#164e63",
surface: "#0e7490",
text: "#f0fdfd",
border: "#0891b2",
},
},
{
id: "lavender",
name: "Лаванда",
description: "Нежная фиолетовая тема",
type: "light",
colors: {
primary: "#a855f7",
background: "#faf5ff",
surface: "#f3e8ff",
text: "#581c87",
border: "#e9d5ff",
},
},
{
id: "coffee",
name: "Кофе",
description: "Уютная коричневая тема",
type: "dark",
colors: {
primary: "#d97706",
background: "#292524",
surface: "#44403c",
text: "#f5f5f4",
border: "#57534e",
},
},
];
@@ -0,0 +1,2 @@
export { ThemeInitialProvider } from "./provider/theme.initial.provider";
export { ThemeChanger } from "./ui/theme.changer";
@@ -0,0 +1,13 @@
import { useLayoutEffect } from "react";
import { applyTheme, initializeTheme } from "../utils/apply.theme";
export const ThemeInitialProvider: React.FC<{ children: React.ReactNode }> = ({
children,
}) => {
useLayoutEffect(() => {
const theme = initializeTheme();
applyTheme(theme);
}, []);
return children;
};
@@ -0,0 +1,13 @@
export interface ITheme {
id: string;
name: string;
description: string;
type: string;
colors: {
primary: string;
background: string;
surface: string;
text: string;
border: string;
};
}
@@ -0,0 +1,78 @@
import type { ITheme } from "../../types/theme.type";
interface IProps {
theme: ITheme;
isSelected: boolean;
onSelect: (id: string) => void;
}
export const ThemeCard: React.FC<IProps> = ({
theme,
isSelected,
onSelect,
}) => {
const { id, name, description } = theme;
return (
<button
onClick={() => onSelect(id)}
className={`relative p-4 rounded-xl border-2 transition-all duration-200 hover:scale-105 hover:shadow-large w-full text-left ${
isSelected
? "border-accent ring-2 ring-accent ring-opacity-50"
: "border-primary hover:border-secondary"
} bg-secondary`}
>
<div
className={`absolute -top-2 -right-2 w-6 h-6 rounded-full flex items-center justify-center transition-all ${
isSelected
? "scale-100 opacity-100 accent-primary"
: "scale-0 opacity-0"
}`}
>
<svg
className="w-3 h-3 text-white"
fill="currentColor"
viewBox="0 0 20 20"
>
<path
fillRule="evenodd"
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"
clipRule="evenodd"
/>
</svg>
</div>
<div className="space-y-3">
<div
className="h-20 rounded-lg border-2 p-2 space-y-1 bg-primary border-primary"
data-theme={id}
>
<div className="flex items-center gap-1">
<div className="w-3 h-3 rounded-full accent-primary" />
<div className="h-1 flex-1 rounded bg-secondary" />
</div>
<div className="space-y-1">
<div
className="h-1 rounded accent-primary"
style={{ width: "70%" }}
/>
<div
className="h-1 rounded bg-secondary"
style={{ width: "40%" }}
/>
<div
className="h-1 rounded bg-secondary"
style={{ width: "60%" }}
/>
</div>
</div>
<div className="space-y-1">
<h3 className="font-semibold text-sm text-primary">{name}</h3>
<p className="text-xs text-secondary">{description}</p>
</div>
</div>
</button>
);
};
@@ -0,0 +1,48 @@
import type { ITheme } from "../types/theme.type";
import { applyTheme } from "../utils/apply.theme";
import { ThemeCard } from "./components/theme.card";
import { themes as baseThemes } from "../config/theme.config";
interface IProps {
themes?: ITheme[];
label: string;
currentTheme?: string;
setTheme?: (id: string) => void;
}
export const ThemeChanger: React.FC<IProps> = ({
themes = baseThemes,
label,
currentTheme,
setTheme,
}) => {
const onSelectTheme = (theme: string) => {
applyTheme(theme);
setTheme?.(theme);
};
return (
<div className="">
<h4 className="text-sm font-medium text-secondary mb-3 flex items-center gap-2">
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path
fillRule="evenodd"
d="M10 2a1 1 0 011 1v1a1 1 0 11-2 0V3a1 1 0 011-1zm4 8a4 4 0 11-8 0 4 4 0 018 0zm-.464 4.95l.707.707a1 1 0 001.414-1.414l-.707-.707a1 1 0 00-1.414 1.414zm2.12-10.607a1 1 0 010 1.414l-.706.707a1 1 0 11-1.414-1.414l.707-.707a1 1 0 011.414 0zM17 11a1 1 0 100-2h-1a1 1 0 100 2h1zm-7 4a1 1 0 011 1v1a1 1 0 11-2 0v-1a1 1 0 011-1zM5.05 6.464A1 1 0 106.465 5.05l-.708-.707a1 1 0 00-1.414 1.414l.707.707zm1.414 8.486l-.707.707a1 1 0 01-1.414-1.414l.707-.707a1 1 0 011.414 1.414zM4 11a1 1 0 100-2H3a1 1 0 000 2h1z"
clipRule="evenodd"
/>
</svg>
{label}
</h4>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4">
{themes.map((theme) => (
<ThemeCard
key={theme.id}
theme={theme}
isSelected={currentTheme === theme.id}
onSelect={onSelectTheme}
/>
))}
</div>
</div>
);
};
@@ -0,0 +1,105 @@
import { themes } from "../config/theme.config";
export const applyTheme = (themeId: string) => {
const theme = themes.find((t) => t.id === themeId);
const root = document.documentElement;
if (theme) {
try {
root.setAttribute("data-theme", themeId);
localStorage.setItem("theme", themeId);
localStorage.setItem("theme-type", theme.type);
window.dispatchEvent(
new CustomEvent("themechange", {
detail: { theme: themeId, type: theme.type },
}),
);
} catch (error) {
console.error("❌ Error applying theme:", error);
}
} else {
console.warn(`⚠️ Theme not found: ${themeId}, falling back to light theme`);
applyTheme("light");
}
};
export const getSavedTheme = () => {
try {
return localStorage.getItem("theme") || "light";
} catch (error) {
console.error("Error reading theme from localStorage:", error);
return "light";
}
};
export const initializeTheme = () => {
const savedTheme = getSavedTheme();
const themeExists = themes.some((t) => t.id === savedTheme);
const themeToApply = themeExists ? savedTheme : "light";
applyTheme(themeToApply);
return themeToApply;
};
export const getCurrentTheme = () => {
return document.documentElement.getAttribute("data-theme") || "light";
};
export const getCurrentThemeType = () => {
const currentTheme = getCurrentTheme();
const theme = themes.find((t) => t.id === currentTheme);
return theme ? theme.type : "light";
};
export const toggleDarkLight = () => {
const currentTheme = getCurrentTheme();
const currentThemeData = themes.find((t) => t.id === currentTheme);
if (currentThemeData) {
const oppositeThemes = themes.filter(
(t) => t.type !== currentThemeData.type,
);
if (oppositeThemes.length > 0) {
applyTheme(oppositeThemes[0].id);
return oppositeThemes[0].id;
}
}
const newTheme = currentTheme === "light" ? "dark" : "light";
applyTheme(newTheme);
return newTheme;
};
export const getNextTheme = () => {
const currentTheme = getCurrentTheme();
const currentIndex = themes.findIndex((t) => t.id === currentTheme);
const nextIndex = (currentIndex + 1) % themes.length;
return themes[nextIndex].id;
};
export const applySystemTheme = () => {
if (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
) {
applyTheme("dark");
} else {
applyTheme("light");
}
};
export const watchSystemTheme = () => {
if (window.matchMedia) {
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", (e) => {
if (e.matches) {
applyTheme("dark");
} else {
applyTheme("light");
}
});
}
};
+224
View File
@@ -0,0 +1,224 @@
import React, { useState } from "react";
import { SSHAgentForm } from "../modules/agent/ui/SSHAgentForm";
import { FiPlusCircle, FiSend } from "react-icons/fi";
interface SSHAgentConfig {
user: string;
ip: string;
authMethod: string;
sshKey?: string;
password?: string;
extraFields: { key: string; value: string }[];
deployType: string;
}
const createEmptyAgentConfig = (): SSHAgentConfig => ({
user: "",
ip: "",
authMethod: "key",
sshKey: "",
password: "",
extraFields: [],
deployType: "docker",
});
export const AddAgentsPage: React.FC = () => {
const [agents, setAgents] = useState<SSHAgentConfig[]>([
createEmptyAgentConfig(),
]);
const [isSubmitting, setIsSubmitting] = useState(false);
const [submitMessage, setSubmitMessage] = useState<string | null>(null);
const [submitError, setSubmitError] = useState<string | null>(null);
const handleAgentChange = (index: number, config: SSHAgentConfig) => {
const newAgents = [...agents];
newAgents[index] = config;
setAgents(newAgents);
};
const handleAgentRemove = (index: number) => {
const newAgents = agents.filter((_, i) => i !== index);
setAgents(newAgents);
};
const handleAddAgent = () => {
setAgents([...agents, createEmptyAgentConfig()]);
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
// Валидация
const isValid = agents.every((agent) => {
if (!agent.user || !agent.ip) return false;
if (agent.authMethod === "key" && !agent.sshKey) return false;
if (agent.authMethod === "password" && !agent.password) return false;
return true;
});
if (!isValid) {
setSubmitError("Пожалуйста, заполните все обязательные поля");
return;
}
setIsSubmitting(true);
setSubmitMessage(null);
setSubmitError(null);
try {
// TODO: Реальный API вызов для развертывания агентов
console.log("Deploying agents:", agents);
// Имитация задержки API
await new Promise((resolve) => setTimeout(resolve, 1500));
setSubmitMessage(
`Успешно отправлено ${agents.length} сервер(ов) на развертывание`,
);
setAgents([createEmptyAgentConfig()]);
} catch (error) {
setSubmitError("Ошибка при развертывании на серверах");
} finally {
setIsSubmitting(false);
}
};
return (
<div
className="min-h-screen py-8 px-4"
style={{ backgroundColor: "var(--bg-primary)" }}
>
<div style={{ maxWidth: "900px", margin: "0 auto" }}>
{/* Header */}
<div className="mb-8">
<div className="flex items-center gap-4 mb-4">
<div
className="w-14 h-14 rounded-xl flex items-center justify-center"
style={{ backgroundColor: "var(--bg-secondary)" }}
>
<FiSend className="w-7 h-7" style={{ color: "var(--accent)" }} />
</div>
<div>
<h1
className="text-3xl font-bold mb-1"
style={{ color: "var(--text-primary)" }}
>
Развертывание агентов по SSH
</h1>
<p style={{ color: "var(--text-secondary)", fontSize: "16px" }}>
Настройте SSH-серверы и разверните агенты
</p>
</div>
</div>
</div>
<form onSubmit={handleSubmit}>
{/* Agent Forms */}
<div className="space-y-5">
{agents.map((agent, index) => (
<SSHAgentForm
key={index}
index={index}
config={agent}
onChange={handleAgentChange}
onRemove={handleAgentRemove}
canRemove={agents.length > 1}
/>
))}
</div>
{/* Add Agent Button */}
<button
type="button"
onClick={handleAddAgent}
className="w-full flex items-center justify-center gap-2 py-3.5 px-4 rounded-xl border-2 border-dashed transition-all mb-6 font-medium"
style={{
borderColor: "var(--border)",
backgroundColor: "transparent",
color: "var(--accent)",
fontSize: "15px",
cursor: "pointer",
}}
onMouseEnter={(e) => {
e.currentTarget.style.borderColor = "var(--accent)";
e.currentTarget.style.backgroundColor = "var(--accent)10";
}}
onMouseLeave={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.backgroundColor = "transparent";
}}
>
<FiPlusCircle size={18} />
Добавить ещё один сервер
</button>
{/* Messages */}
{submitMessage && (
<div
className="mb-6 p-4 rounded-lg border text-sm"
style={{
backgroundColor: "var(--success-bg)",
borderColor: "var(--success-border)",
color: "var(--success-text)",
}}
>
{submitMessage}
</div>
)}
{submitError && (
<div
className="mb-6 p-4 rounded-lg border text-sm"
style={{
backgroundColor: "var(--error-bg)",
borderColor: "var(--error-border)",
color: "var(--error-text)",
}}
>
{submitError}
</div>
)}
{/* Submit Button */}
<button
type="submit"
disabled={isSubmitting}
className="w-full flex items-center justify-center gap-2 px-4 py-3.5 rounded-xl transition-all disabled:opacity-50 disabled:cursor-not-allowed font-medium text-base"
style={{
backgroundColor: isSubmitting
? "var(--bg-secondary)"
: "var(--button-primary)",
color: "var(--button-primary-text)",
boxShadow: isSubmitting
? "none"
: "0 4px 14px var(--shadow-color)",
}}
onMouseEnter={(e) => {
if (!isSubmitting) {
e.currentTarget.style.backgroundColor =
"var(--button-primary-hover)";
}
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = isSubmitting
? "var(--bg-secondary)"
: "var(--button-primary)";
}}
>
{isSubmitting ? (
<>
<div className="w-5 h-5 border-2 border-current border-t-transparent rounded-full animate-spin" />
Подключение к серверам...
</>
) : (
<>
<FiSend size={18} />
Развернуть на {agents.length} сервер(ах)
</>
)}
</button>
</form>
</div>
</div>
);
};
+216
View File
@@ -0,0 +1,216 @@
import React, { useState, useEffect } from "react";
import { useNavigate, Link } from "react-router-dom";
import { FiUser, FiLock, FiLogIn } from "react-icons/fi";
import { useAuthStore } from "@/modules/auth/store/useAuthStore";
export const AuthPage: React.FC = () => {
const navigate = useNavigate();
const { login, isLoading, error, clearError, token } = useAuthStore();
const [formData, setFormData] = useState({
login: "",
password: "",
});
useEffect(() => {
if (token) {
navigate("/");
}
}, [token, navigate]);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
try {
await login(formData);
navigate("/");
} catch (err) {
// Error is handled by store
}
};
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setFormData({
...formData,
[e.target.name]: e.target.value,
});
if (error) clearError();
};
return (
<div
className="min-h-screen flex items-center justify-center p-4"
style={{ backgroundColor: "var(--bg-primary)" }}
>
<div className="w-full max-w-md">
{/* Card */}
<div
className="rounded-2xl shadow-2xl p-8 border"
style={{
backgroundColor: "var(--card-bg)",
borderColor: "var(--border)",
boxShadow: "0 20px 60px var(--shadow-color)",
}}
>
{/* Header */}
<div className="text-center mb-8">
<div
className="w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center"
style={{ backgroundColor: "var(--bg-secondary)" }}
>
<FiUser className="w-8 h-8" style={{ color: "var(--accent)" }} />
</div>
<h1
className="text-3xl font-bold mb-2"
style={{ color: "var(--text-primary)" }}
>
С возвращением!
</h1>
<p style={{ color: "var(--text-secondary)" }}>
Войдите в свой аккаунт
</p>
</div>
{/* Error Message */}
{error && (
<div
className="mb-6 p-4 rounded-lg border text-sm"
style={{
backgroundColor: "var(--error-bg)",
borderColor: "var(--error-border)",
color: "var(--error-text)",
}}
>
{error}
</div>
)}
{/* Form */}
<form onSubmit={handleSubmit} className="space-y-5">
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Логин
</label>
<div className="relative">
<FiUser
className="absolute left-3 top-1/2 transform -translate-y-1/2"
style={{ color: "var(--text-muted)" }}
/>
<input
type="text"
name="login"
value={formData.login}
onChange={handleChange}
required
className="w-full pl-10 pr-3 py-2.5 rounded-lg border focus:outline-none focus:ring-2 transition-all"
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Введите ваш логин"
/>
</div>
</div>
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Пароль
</label>
<div className="relative">
<FiLock
className="absolute left-3 top-1/2 transform -translate-y-1/2"
style={{ color: "var(--text-muted)" }}
/>
<input
type="password"
name="password"
value={formData.password}
onChange={handleChange}
required
className="w-full pl-10 pr-3 py-2.5 rounded-lg border focus:outline-none focus:ring-2 transition-all"
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Введите ваш пароль"
/>
</div>
</div>
<button
type="submit"
disabled={isLoading}
className="w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-medium"
style={{
backgroundColor: "var(--button-primary)",
color: "var(--button-primary-text)",
}}
onMouseEnter={(e) => {
if (!isLoading) {
e.currentTarget.style.backgroundColor = "var(--button-primary-hover)";
}
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "var(--button-primary)";
}}
>
{isLoading ? (
<>
<div className="w-5 h-5 border-2 border-current border-t-transparent rounded-full animate-spin" />
Вход...
</>
) : (
<>
<FiLogIn />
Войти
</>
)}
</button>
</form>
{/* Footer */}
<div className="mt-6 text-center">
<p className="text-sm" style={{ color: "var(--text-secondary)" }}>
Нет аккаунта?{" "}
<Link
to="/register"
className="font-medium hover:underline transition-colors"
style={{ color: "var(--link)" }}
onMouseEnter={(e) => {
e.currentTarget.style.color = "var(--link-hover)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.color = "var(--link)";
}}
>
Зарегистрироваться
</Link>
</p>
</div>
</div>
</div>
</div>
);
};
+11
View File
@@ -0,0 +1,11 @@
import { useState } from "react";
export const HomePage = () => {
const [test, setTest] = useState();
return (
<div>
<h1>Home page</h1>
</div>
);
};
+358
View File
@@ -0,0 +1,358 @@
import React, { useState, useEffect } from "react";
import { useNavigate, Link } from "react-router-dom";
import { FiUser, FiLock, FiUserPlus } from "react-icons/fi";
import { useAuthStore } from "@/modules/auth/store/useAuthStore";
export const RegisterPage: React.FC = () => {
const navigate = useNavigate();
const { register, isLoading, error, clearError, token } = useAuthStore();
const [formData, setFormData] = useState({
login: "",
password: "",
confirmPassword: "",
firstName: "",
lastName: "",
});
const [passwordError, setPasswordError] = useState<string | null>(null);
useEffect(() => {
if (token) {
navigate("/");
}
}, [token, navigate]);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (formData.password !== formData.confirmPassword) {
setPasswordError("Пароли не совпадают");
return;
}
setPasswordError(null);
try {
await register({
login: formData.login,
password: formData.password,
firstName: formData.firstName,
lastName: formData.lastName,
});
navigate("/");
} catch (err) {
// Error is handled by store
}
};
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
setFormData({
...formData,
[e.target.name]: e.target.value,
});
if (error) clearError();
if (passwordError) setPasswordError(null);
};
const inputStyles = `
w-full pl-10 pr-3 py-2.5 rounded-lg border focus:outline-none focus:ring-2 transition-all
`;
const simpleInputStyles = `
w-full px-3 py-2.5 rounded-lg border focus:outline-none focus:ring-2 transition-all
`;
return (
<div
className="min-h-screen flex items-center justify-center p-4"
style={{ backgroundColor: "var(--bg-primary)" }}
>
<div className="w-full max-w-md">
{/* Card */}
<div
className="rounded-2xl shadow-2xl p-8 border"
style={{
backgroundColor: "var(--card-bg)",
borderColor: "var(--border)",
boxShadow: "0 20px 60px var(--shadow-color)",
}}
>
{/* Header */}
<div className="text-center mb-8">
<div
className="w-16 h-16 mx-auto mb-4 rounded-full flex items-center justify-center"
style={{ backgroundColor: "var(--bg-secondary)" }}
>
<FiUserPlus className="w-8 h-8" style={{ color: "var(--accent)" }} />
</div>
<h1
className="text-3xl font-bold mb-2"
style={{ color: "var(--text-primary)" }}
>
Создать аккаунт
</h1>
<p style={{ color: "var(--text-secondary)" }}>
Зарегистрируйтесь, чтобы начать
</p>
</div>
{/* Error Message */}
{error && (
<div
className="mb-6 p-4 rounded-lg border text-sm"
style={{
backgroundColor: "var(--error-bg)",
borderColor: "var(--error-border)",
color: "var(--error-text)",
}}
>
{error}
</div>
)}
{/* Form */}
<form onSubmit={handleSubmit} className="space-y-4">
{/* Name Fields */}
<div className="grid grid-cols-2 gap-4">
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Имя
</label>
<input
type="text"
name="firstName"
value={formData.firstName}
onChange={handleChange}
required
className={simpleInputStyles}
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Иван"
/>
</div>
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Фамилия
</label>
<input
type="text"
name="lastName"
value={formData.lastName}
onChange={handleChange}
required
className={simpleInputStyles}
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Иванов"
/>
</div>
</div>
{/* Login */}
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Логин
</label>
<div className="relative">
<FiUser
className="absolute left-3 top-1/2 transform -translate-y-1/2"
style={{ color: "var(--text-muted)" }}
/>
<input
type="text"
name="login"
value={formData.login}
onChange={handleChange}
required
className={inputStyles}
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Придумайте логин"
/>
</div>
</div>
{/* Password */}
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Пароль
</label>
<div className="relative">
<FiLock
className="absolute left-3 top-1/2 transform -translate-y-1/2"
style={{ color: "var(--text-muted)" }}
/>
<input
type="password"
name="password"
value={formData.password}
onChange={handleChange}
required
className={inputStyles}
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Придумайте пароль"
/>
</div>
</div>
{/* Confirm Password */}
<div>
<label
className="block text-sm font-medium mb-2"
style={{ color: "var(--text-secondary)" }}
>
Подтвердите пароль
</label>
<div className="relative">
<FiLock
className="absolute left-3 top-1/2 transform -translate-y-1/2"
style={{ color: "var(--text-muted)" }}
/>
<input
type="password"
name="confirmPassword"
value={formData.confirmPassword}
onChange={handleChange}
required
className={inputStyles}
style={{
backgroundColor: "var(--input-bg)",
borderColor: "var(--border)",
color: "var(--text-primary)",
}}
onFocus={(e) => {
e.currentTarget.style.borderColor = "var(--border-focus)";
e.currentTarget.style.boxShadow = `0 0 0 3px ${e.currentTarget.style.borderColor}20`;
}}
onBlur={(e) => {
e.currentTarget.style.borderColor = "var(--border)";
e.currentTarget.style.boxShadow = "none";
}}
placeholder="Повторите пароль"
/>
</div>
{passwordError && (
<p
className="mt-2 text-sm flex items-center gap-1"
style={{ color: "var(--error-text)" }}
>
<svg className="w-4 h-4" fill="currentColor" viewBox="0 0 20 20">
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
</svg>
{passwordError}
</p>
)}
</div>
<button
type="submit"
disabled={isLoading}
className="w-full flex items-center justify-center gap-2 px-4 py-2.5 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-medium"
style={{
backgroundColor: "var(--button-primary)",
color: "var(--button-primary-text)",
}}
onMouseEnter={(e) => {
if (!isLoading) {
e.currentTarget.style.backgroundColor = "var(--button-primary-hover)";
}
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "var(--button-primary)";
}}
>
{isLoading ? (
<>
<div className="w-5 h-5 border-2 border-current border-t-transparent rounded-full animate-spin" />
Регистрация...
</>
) : (
<>
<FiUserPlus />
Зарегистрироваться
</>
)}
</button>
</form>
{/* Footer */}
<div className="mt-6 text-center">
<p className="text-sm" style={{ color: "var(--text-secondary)" }}>
Уже есть аккаунт?{" "}
<Link
to="/auth"
className="font-medium hover:underline transition-colors"
style={{ color: "var(--link)" }}
onMouseEnter={(e) => {
e.currentTarget.style.color = "var(--link-hover)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.color = "var(--link)";
}}
>
Войти
</Link>
</p>
</div>
</div>
</div>
</div>
);
};
+9
View File
@@ -0,0 +1,9 @@
import { ThemeChanger } from "@/modules/theme-changer";
export const ThemesPage = () => {
return (
<div>
<ThemeChanger label="Выбор тем приложения" />
</div>
);
};
+37
View File
@@ -0,0 +1,37 @@
import { apiClient } from "./axios.instance";
import type { AxiosResponse } from "axios";
export interface ApiResponse<T = any> {
data: T;
message: string;
success: boolean;
}
class ApiService {
async get<T>(url: string, config?: any): Promise<T> {
const response: AxiosResponse<T> = await apiClient.get(url, config);
return response.data;
}
async post<T, D = any>(url: string, data?: D, config?: any): Promise<T> {
const response: AxiosResponse<T> = await apiClient.post(url, data, config);
return response.data;
}
async put<T, D = any>(url: string, data?: D, config?: any): Promise<T> {
const response: AxiosResponse<T> = await apiClient.put(url, data, config);
return response.data;
}
async patch<T, D = any>(url: string, data?: D, config?: any): Promise<T> {
const response: AxiosResponse<T> = await apiClient.patch(url, data, config);
return response.data;
}
async delete<T>(url: string, config?: any): Promise<T> {
const response: AxiosResponse<T> = await apiClient.delete(url, config);
return response.data;
}
}
export const apiService = new ApiService();
+77
View File
@@ -0,0 +1,77 @@
import axios, {
type AxiosInstance,
type AxiosResponse,
type AxiosError,
type InternalAxiosRequestConfig,
} from "axios";
export interface ApiResponse<T = any> {
data: T;
message?: string;
status: number;
}
class ApiClient {
private axiosInstance: AxiosInstance;
constructor() {
this.axiosInstance = axios.create({
baseURL: "http://194.113.106.59:8080/api/v1",
timeout: 10000,
headers: {
"Content-Type": "application/json",
},
validateStatus: (status) => {
return status >= 200 && status < 500;
},
});
this.setupInterceptors();
}
private setupInterceptors(): void {
this.axiosInstance.interceptors.request.use(
(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig => {
// Получаем токен из localStorage
const authStorage = localStorage.getItem("auth-storage");
if (authStorage) {
try {
const parsed = JSON.parse(authStorage);
const token = parsed.state?.token;
if (token) {
config.headers.Authorization = `Bearer ${token}`;
}
} catch (e) {
console.error("[Auth] Failed to parse auth storage:", e);
}
}
return config;
},
(error: AxiosError): Promise<AxiosError> => {
console.error("[Request Error]", error);
return Promise.reject(error);
},
);
this.axiosInstance.interceptors.response.use(
(response: AxiosResponse): AxiosResponse => {
console.log(`[Response] ${response.status} ${response.config.url}`);
return response;
},
async (error: AxiosError): Promise<any> => {
if (error.response?.status === 401) {
window.location.href = "/auth";
return Promise.reject(error);
}
return Promise.reject(error);
},
);
}
public getInstance(): AxiosInstance {
return this.axiosInstance;
}
}
export const apiClient = new ApiClient().getInstance();
+32
View File
@@ -0,0 +1,32 @@
import { useState, useCallback } from "react";
export function useApi() {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const request = useCallback(
async <T>(apiCall: () => Promise<T>): Promise<T | undefined> => {
setIsLoading(true);
setError(null);
try {
const result = await apiCall();
return result;
} catch (err: any) {
const errorMessage =
err.response?.data?.message || err.message || "Произошла ошибка";
setError(errorMessage);
return undefined;
} finally {
setIsLoading(false);
}
},
[],
);
return {
isLoading,
error,
request,
};
}
+2
View File
@@ -0,0 +1,2 @@
export { apiClient } from "./axios.instance";
export { useApi } from "./hooks/use.api";
@@ -0,0 +1,136 @@
// shared/api/websocket.service.ts
import { useAgentStore } from "@/components/layout/sidebar/store/agent.store";
import { useWebSocket, type LogMessage } from "@/shared/hooks/useWebSocket";
import { useEffect, useRef, useCallback, useMemo } from "react";
interface WebSocketServiceProps {
onLogMessage?: (message: LogMessage) => void;
}
export const useWebSocketService = ({
onLogMessage,
}: WebSocketServiceProps = {}) => {
const { agents } = useAgentStore();
const lastFilterRef = useRef<{ hosts: string[]; services: string[] }>({
hosts: [],
services: [],
});
// Токен для аутентификации
const TOKEN =
"H0AB91gb7427xswom0xalJHq7Ked0tLt6F0gOyqw5yMWPDrroOcX8CjPXeD8uzsU";
// Получаем выбранные агенты и сервисы синхронно
const getSelectedServices = useCallback(() => {
const selectedServices: string[] = [];
const selectedHosts: string[] = [];
agents.forEach((agent) => {
agent.services.forEach((service) => {
if (service.isSelected) {
selectedServices.push(service.name);
selectedHosts.push(agent.token);
}
});
});
return { hosts: selectedHosts, services: selectedServices };
}, [agents]);
// Формируем URL синхронно
const wsUrl = useMemo(() => {
const { hosts, services } = getSelectedServices();
const params = new URLSearchParams();
if (hosts.length === 0 && services.length === 0) {
params.append("all", "true");
} else {
hosts.forEach((host) => {
params.append("hosts", host);
});
services.forEach((service) => {
params.append("services", service);
});
}
const queryString = params.toString();
const url = `${import.meta.env.VITE_WS_URL}/ws?${queryString}`;
console.log("Generated WebSocket URL:", url);
return url;
}, [getSelectedServices]);
const {
isConnected,
isAuthenticated,
lastMessage,
error,
reconnect,
connect: wsConnect,
disconnect: wsDisconnect,
updateFilter,
} = useWebSocket({
url: wsUrl,
token: TOKEN,
autoConnect: false, // Отключаем авто-подключение, будем управлять вручную
reconnectInterval: 3000,
maxReconnectAttempts: 10,
});
// Функция для подключения
const connect = useCallback(() => {
if (!isManualPausedRef.current) {
wsConnect();
}
}, [wsConnect]);
// Функция для отключения
const disconnect = useCallback(() => {
wsDisconnect();
}, [wsDisconnect]);
// Реф для отслеживания ручной паузы
const isManualPausedRef = useRef(false);
// Принудительно переподключаемся при изменении URL, если не на паузе
useEffect(() => {
if (wsUrl && !isManualPausedRef.current) {
console.log("URL changed, reconnecting...");
setTimeout(() => {
reconnect();
}, 100);
}
}, [wsUrl, reconnect]);
// Обновляем фильтр при изменении выбранных сервисов
useEffect(() => {
const { hosts, services } = getSelectedServices();
const currentFilter = { hosts, services };
const hasChanged =
JSON.stringify(currentFilter) !== JSON.stringify(lastFilterRef.current);
if (hasChanged && isConnected && !isManualPausedRef.current) {
console.log("Updating filter:", currentFilter);
updateFilter(hosts, services);
lastFilterRef.current = currentFilter;
}
}, [agents, isConnected, updateFilter, getSelectedServices]);
// Передаем сообщения в callback
useEffect(() => {
if (lastMessage && onLogMessage) {
onLogMessage(lastMessage);
}
}, [lastMessage, onLogMessage]);
return {
isConnected: isConnected && isAuthenticated,
isAuthenticated,
error,
selectedCount: getSelectedServices().services.length,
connect,
disconnect,
};
};
Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

+1
View File
@@ -0,0 +1 @@
<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="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>

After

Width:  |  Height:  |  Size: 4.0 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.5 KiB

+265
View File
@@ -0,0 +1,265 @@
// shared/hooks/useWebSocket.ts
import { useEffect, useRef, useState, useCallback } from "react";
export interface LogMessage {
timestamp: string;
service: string;
level: "log" | "info" | "success" | "warn" | "error";
message: string;
host: string;
attributes?: Record<string, any>;
}
interface WebSocketOptions {
url: string;
token?: string;
autoConnect?: boolean;
reconnectInterval?: number;
maxReconnectAttempts?: number;
}
export const useWebSocket = (options: WebSocketOptions) => {
const {
url,
token,
autoConnect = true,
reconnectInterval = 3000,
maxReconnectAttempts = 5,
} = options;
const [isConnected, setIsConnected] = useState(false);
const [isAuthenticated, setIsAuthenticated] = useState(false);
const [lastMessage, setLastMessage] = useState<LogMessage | null>(null);
const [error, setError] = useState<string | null>(null);
const wsRef = useRef<WebSocket | null>(null);
const reconnectAttemptsRef = useRef(0);
const reconnectTimeoutRef = useRef<any>(null);
const urlRef = useRef<string>(url);
const tokenRef = useRef<string | undefined>(token);
const authTimeoutRef = useRef<any>(null);
const disconnect = useCallback(() => {
if (reconnectTimeoutRef.current) {
clearTimeout(reconnectTimeoutRef.current);
reconnectTimeoutRef.current = null;
}
if (authTimeoutRef.current) {
clearTimeout(authTimeoutRef.current);
authTimeoutRef.current = null;
}
if (wsRef.current) {
const ws = wsRef.current;
wsRef.current = null;
if (
ws.readyState === WebSocket.OPEN ||
ws.readyState === WebSocket.CONNECTING
) {
ws.close(1000, "Disconnecting");
}
}
setIsConnected(false);
setIsAuthenticated(false);
}, []);
const sendAuth = useCallback(() => {
if (
wsRef.current &&
wsRef.current.readyState === WebSocket.OPEN &&
tokenRef.current
) {
const authMessage = {
type: "auth",
payload: {
token: tokenRef.current,
},
};
console.log("Sending auth message...");
wsRef.current.send(JSON.stringify(authMessage));
// Set timeout for auth response
authTimeoutRef.current = setTimeout(() => {
if (!isAuthenticated) {
console.error("Auth timeout");
setError("Authentication timeout");
disconnect();
}
}, 5000);
}
}, [isAuthenticated, disconnect]);
const connect = useCallback(() => {
// Если URL изменился, пересоздаем соединение
if (urlRef.current !== url) {
console.log("URL changed, forcing new connection");
disconnect();
urlRef.current = url;
tokenRef.current = token;
}
// Если уже есть открытое соединение, не создаем новое
if (wsRef.current && wsRef.current.readyState === WebSocket.OPEN) {
console.log("WebSocket already connected");
return;
}
try {
console.log("Connecting to WebSocket:", url);
wsRef.current = new WebSocket(url);
wsRef.current.onopen = () => {
console.log("WebSocket connected, sending auth...");
setIsConnected(true);
setError(null);
reconnectAttemptsRef.current = 0;
// Send authentication immediately after connection
sendAuth();
};
wsRef.current.onmessage = (event) => {
try {
const data = JSON.parse(event.data);
console.log("WebSocket message received:", data);
// Check if it's an auth response
if (data.type === "auth") {
if (data.success) {
console.log("Authentication successful");
setIsAuthenticated(true);
setError(null);
if (authTimeoutRef.current) {
clearTimeout(authTimeoutRef.current);
}
} else {
console.error("Authentication failed:", data.error);
setError(data.error || "Authentication failed");
setIsAuthenticated(false);
disconnect();
}
} else {
// Regular log message
setLastMessage(data);
}
} catch (err) {
console.error("Failed to parse WebSocket message:", err);
}
};
wsRef.current.onerror = (event) => {
console.error("WebSocket error:", event);
setError("Connection error");
};
wsRef.current.onclose = (event) => {
console.log(
"WebSocket disconnected, code:",
event.code,
"reason:",
event.reason,
);
setIsConnected(false);
setIsAuthenticated(false);
// Если URL изменился, не переподключаемся автоматически
if (urlRef.current !== url) {
console.log("URL changed, will reconnect manually");
return;
}
// Не переподключаемся при нормальном закрытии
if (event.code === 1000) {
console.log("Normal closure, not reconnecting");
return;
}
// Attempt reconnection
if (
reconnectAttemptsRef.current < maxReconnectAttempts &&
tokenRef.current
) {
console.log(`Reconnecting in ${reconnectInterval}ms...`);
reconnectTimeoutRef.current = setTimeout(() => {
reconnectAttemptsRef.current++;
connect();
}, reconnectInterval);
} else if (reconnectAttemptsRef.current >= maxReconnectAttempts) {
setError("Max reconnection attempts reached");
}
};
} catch (err) {
setError(err instanceof Error ? err.message : "Failed to connect");
}
}, [
url,
token,
reconnectInterval,
maxReconnectAttempts,
disconnect,
sendAuth,
]);
const reconnect = useCallback(() => {
console.log("Manual reconnect triggered");
disconnect();
setTimeout(() => {
connect();
}, 100);
}, [disconnect, connect]);
const sendMessage = useCallback(
(data: any) => {
if (
wsRef.current &&
wsRef.current.readyState === WebSocket.OPEN &&
isAuthenticated
) {
wsRef.current.send(JSON.stringify(data));
return true;
} else {
console.warn("WebSocket is not authenticated or not connected");
return false;
}
},
[isAuthenticated],
);
const updateFilter = useCallback(
(hosts: string[], services: string[]) => {
const message = {
type: "filter",
payload: { hosts, services },
};
console.log("Sending filter update:", message);
sendMessage(message);
},
[sendMessage],
);
// Подключаемся при монтировании и при изменении URL или токена
useEffect(() => {
if (autoConnect && url && token) {
connect();
}
return () => {
disconnect();
};
}, [autoConnect, connect, disconnect, url, token]);
return {
isConnected: isConnected && isAuthenticated,
isAuthenticated,
lastMessage,
error,
connect,
disconnect,
reconnect,
sendMessage,
updateFilter,
};
};
@@ -0,0 +1,90 @@
import { useAuthStore } from "@/modules/auth/store/useAuthStore";
import { ThemeToggle } from "@/modules/theme-bw/ui/ThemeToggle";
import React from "react";
import { Outlet, useNavigate } from "react-router-dom";
interface DefaultLayoutProps {
children?: React.ReactNode;
}
export const DefaultLayout: React.FC<DefaultLayoutProps> = ({ children }) => {
const { user, logout } = useAuthStore();
const navigate = useNavigate();
const handleLogout = () => {
logout();
navigate("/auth");
};
return (
<div className="min-h-screen flex flex-col" style={{ backgroundColor: "var(--bg-primary)", color: "var(--text-primary)" }}>
{/* Header */}
<header
className="border-b sticky top-0 z-50"
style={{
backgroundColor: "var(--header-bg)",
borderColor: "var(--border)",
}}
>
<div className="container mx-auto px-4 py-3">
<div className="flex justify-between items-center">
{/* Logo */}
<div
className="text-xl font-bold cursor-pointer hover:opacity-80 transition-opacity"
style={{ color: "var(--text-primary)" }}
onClick={() => navigate("/")}
>
HellreigN
</div>
{/* Right side */}
<div className="flex items-center gap-3">
<ThemeToggle />
{user && (
<div className="flex items-center gap-3">
<span className="text-sm" style={{ color: "var(--text-secondary)" }}>
{user.firstName} {user.lastName}
</span>
<button
onClick={handleLogout}
className="px-3 py-1.5 text-sm rounded-lg transition-colors font-medium"
style={{
backgroundColor: "var(--button-danger)",
color: "var(--button-danger-text)",
}}
onMouseEnter={(e) => {
e.currentTarget.style.backgroundColor = "var(--button-danger-hover)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = "var(--button-danger)";
}}
>
Выйти
</button>
</div>
)}
</div>
</div>
</div>
</header>
{/* Main content */}
<main className="flex-1">{children || <Outlet />}</main>
{/* Footer */}
<footer
className="border-t py-4 mt-auto"
style={{
backgroundColor: "var(--bg-secondary)",
borderColor: "var(--border)",
}}
>
<div className="container mx-auto px-4">
<p className="text-center text-sm" style={{ color: "var(--text-muted)" }}>
© 2026 HellreigN. Все права защищены.
</p>
</div>
</footer>
</div>
);
};
+4
View File
@@ -0,0 +1,4 @@
@import "tailwindcss";
@import "./normalize.css";
@import "./root.css";
@import "./themes.css";
+365
View File
@@ -0,0 +1,365 @@
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
html {
line-height: 1.15;
/* 1 */
-webkit-text-size-adjust: 100%;
/* 2 */
}
/* Sections
========================================================================== */
/**
* Remove the margin in all browsers.
*/
body {
overflow-x: hidden;
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/**
* Correct the font size and margin on `h1` elements within `section` and
* `article` contexts in Chrome, Firefox, and Safari.
*/
h1 {
font-size: 2em;
}
/* Grouping content
========================================================================== */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box;
/* 1 */
height: 0;
/* 1 */
overflow: visible;
/* 2 */
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/* Text-level semantics
========================================================================== */
/**
* Remove the gray background on active links in IE 10.
*/
/* a {
background-color: transparent;
} */
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none;
/* 1 */
text-decoration: underline;
/* 2 */
text-decoration: underline dotted;
/* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Embedded content
========================================================================== */
/**
* Remove the border on images inside links in IE 10.
*/
img {
border-style: none;
}
/* Forms
========================================================================== */
/**
* 1. Change the font styles in all browsers.
* 2. Remove the margin in Firefox and Safari.
*/
/**
* Show the overflow in IE.
* 1. Show the overflow in Edge.
*/
button,
input {
/* 1 */
overflow: visible;
outline: none;
}
/**
* Remove the inheritance of text transform in Edge, Firefox, and IE.
* 1. Remove the inheritance of text transform in Firefox.
*/
button,
select {
/* 1 */
text-transform: none;
}
/**
* Correct the inability to style clickable types in iOS and Safari.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
/**
* Remove the inner border and padding in Firefox.
*/
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
border-style: none;
padding: 0;
}
/**
* Restore the focus styles unset by the previous rule.
*/
button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring {
outline: 1px dotted ButtonText;
}
/**
* Correct the padding in Firefox.
*/
fieldset {
padding: 0.35em 0.75em 0.625em;
}
/**
* 1. Correct the text wrapping in Edge and IE.
* 2. Correct the color inheritance from `fieldset` elements in IE.
* 3. Remove the padding so developers are not caught out when they zero out
* `fieldset` elements in all browsers.
*/
legend {
box-sizing: border-box;
/* 1 */
color: inherit;
/* 2 */
display: table;
/* 1 */
max-width: 100%;
/* 1 */
padding: 0;
/* 3 */
white-space: normal;
/* 1 */
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* 1. Add the correct box sizing in IE 10.
* 2. Remove the padding in IE 10.
*/
[type="checkbox"],
[type="radio"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* 1. Correct the odd appearance in Chrome and Safari.
* 2. Correct the outline style in Safari.
*/
[type="search"] {
-webkit-appearance: textfield;
/* 1 */
outline-offset: -2px;
/* 2 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
-webkit-appearance: button;
/* 1 */
font: inherit;
/* 2 */
}
/* Interactive
========================================================================== */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/* Misc
========================================================================== */
/**
* Add the correct display in IE 10+.
*/
template {
display: none;
}
/**
* Add the correct display in IE 10.
*/
[hidden] {
display: none;
}
+307
View File
@@ -0,0 +1,307 @@
/* Дополнительные стили для PrimeReact с вашей темой */
.p-tabmenu .p-tabmenuitem .p-menuitem-link {
color: var(--text-secondary);
transition: all 0.2s ease;
}
.p-tabmenu .p-tabmenuitem .p-menuitem-link:not(.p-disabled):hover {
color: var(--text-primary);
background-color: var(--bg-tertiary);
}
.p-tabmenu .p-tabmenuitem.p-highlight .p-menuitem-link {
color: var(--accent-primary);
border-color: var(--accent-primary);
}
.p-menubar {
background-color: var(--bg-secondary);
border: none;
border-radius: 0;
}
.p-menubar .p-menuitem-link {
color: var(--text-secondary);
}
.p-menubar .p-menuitem-link:hover {
background-color: var(--bg-tertiary);
color: var(--text-primary);
}
.p-button.p-button-text {
color: var(--text-secondary);
}
.p-button.p-button-text:hover {
color: var(--text-primary);
background-color: var(--bg-tertiary);
}
/* ==================== Стили для скроллов ==================== */
/* WebKit браузеры (Chrome, Safari, Edge, Opera) */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 4px;
}
::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 4px;
transition: background 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
::-webkit-scrollbar-corner {
background: var(--bg-tertiary);
}
/* Firefox */
* {
scrollbar-width: thin;
scrollbar-color: var(--border-secondary) var(--bg-tertiary);
}
/* Для элементов с прокруткой (кастомные классы) */
.custom-scrollbar {
scrollbar-width: thin;
scrollbar-color: var(--border-secondary) var(--bg-tertiary);
}
.custom-scrollbar::-webkit-scrollbar {
width: 8px;
height: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 4px;
transition: background 0.2s ease;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Для горизонтальных скроллов */
.horizontal-scrollbar {
overflow-x: auto;
}
.horizontal-scrollbar::-webkit-scrollbar {
height: 6px;
}
/* Для очень тонких скроллов (например, в таблицах) */
.thin-scrollbar::-webkit-scrollbar {
width: 4px;
height: 4px;
}
.thin-scrollbar::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 2px;
}
.thin-scrollbar::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 2px;
}
.thin-scrollbar::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Для темных тем - дополнительная стилизация */
[data-theme="dark"] ::-webkit-scrollbar-track,
[data-theme="nightowl"] ::-webkit-scrollbar-track,
[data-theme="sunset"] ::-webkit-scrollbar-track,
[data-theme="forest"] ::-webkit-scrollbar-track,
[data-theme="ocean"] ::-webkit-scrollbar-track,
[data-theme="coffee"] ::-webkit-scrollbar-track,
[data-theme="midnight"] ::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.05);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb,
[data-theme="nightowl"] ::-webkit-scrollbar-thumb,
[data-theme="sunset"] ::-webkit-scrollbar-thumb,
[data-theme="forest"] ::-webkit-scrollbar-thumb,
[data-theme="ocean"] ::-webkit-scrollbar-thumb,
[data-theme="coffee"] ::-webkit-scrollbar-thumb,
[data-theme="midnight"] ::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.2);
}
[data-theme="dark"] ::-webkit-scrollbar-thumb:hover,
[data-theme="nightowl"] ::-webkit-scrollbar-thumb:hover,
[data-theme="sunset"] ::-webkit-scrollbar-thumb:hover,
[data-theme="forest"] ::-webkit-scrollbar-thumb:hover,
[data-theme="ocean"] ::-webkit-scrollbar-thumb:hover,
[data-theme="coffee"] ::-webkit-scrollbar-thumb:hover,
[data-theme="midnight"] ::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Для светлых тем - более контрастные скроллы */
[data-theme="light"] ::-webkit-scrollbar-track {
background: #f1f5f9;
}
[data-theme="light"] ::-webkit-scrollbar-thumb {
background: #cbd5e1;
}
[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Для лавандовой темы */
[data-theme="lavender"] ::-webkit-scrollbar-track {
background: #e9d5ff;
}
[data-theme="lavender"] ::-webkit-scrollbar-thumb {
background: #c084fc;
}
[data-theme="lavender"] ::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Для розовой темы */
[data-theme="rose"] ::-webkit-scrollbar-track {
background: #fecdd3;
}
[data-theme="rose"] ::-webkit-scrollbar-thumb {
background: #fb7185;
}
[data-theme="rose"] ::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Стили для скролла в текстовых полях и textarea */
textarea::-webkit-scrollbar {
width: 6px;
}
textarea::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 3px;
}
textarea::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 3px;
}
textarea::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Стили для скролла в выпадающих списках PrimeReact */
.p-dropdown-panel .p-dropdown-items-wrapper::-webkit-scrollbar {
width: 6px;
}
.p-dropdown-panel .p-dropdown-items-wrapper::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 3px;
}
.p-dropdown-panel .p-dropdown-items-wrapper::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 3px;
}
.p-dropdown-panel .p-dropdown-items-wrapper::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Стили для скролла в таблицах */
.p-datatable-wrapper::-webkit-scrollbar {
height: 8px;
width: 8px;
}
.p-datatable-wrapper::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 4px;
}
.p-datatable-wrapper::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 4px;
}
.p-datatable-wrapper::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Стили для скролла в модальных окнах */
.p-dialog .p-dialog-content::-webkit-scrollbar {
width: 6px;
}
.p-dialog .p-dialog-content::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 3px;
}
.p-dialog .p-dialog-content::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 3px;
}
.p-dialog .p-dialog-content::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
/* Стили для скролла в меню */
.p-menu .p-menu-list::-webkit-scrollbar {
width: 6px;
}
.p-menu .p-menu-list::-webkit-scrollbar-track {
background: var(--bg-tertiary);
border-radius: 3px;
}
.p-menu .p-menu-list::-webkit-scrollbar-thumb {
background: var(--border-secondary);
border-radius: 3px;
}
.p-menu .p-menu-list::-webkit-scrollbar-thumb:hover {
background: var(--accent-primary);
}
@keyframes pulse {
0%,
100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
.animate-pulse {
animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
+267
View File
@@ -0,0 +1,267 @@
@import "tailwindcss";
/* Tailwind dark mode через data-theme атрибут */
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
/* Кастомные утилиты */
@layer utilities {
.transition-theme {
transition-property: background-color, border-color, color, fill, stroke;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 200ms;
}
}
/* ===========================
БАЗОВЫЕ ТЕМЫ (Light/Dark)
=========================== */
/* Светлая тема (по умолчанию) */
:root,
[data-theme="light"] {
--bg-primary: #ffffff;
--bg-secondary: #f8fafc;
--bg-tertiary: #f1f5f9;
--text-primary: #0f172a;
--text-secondary: #475569;
--text-muted: #94a3b8;
--border: #e2e8f0;
--border-focus: #94a3b8;
--card-bg: #ffffff;
--input-bg: #ffffff;
--header-bg: #ffffff;
--button-primary: #0f172a;
--button-primary-text: #ffffff;
--button-primary-hover: #1e293b;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #dc2626;
--error-bg: #fef2f2;
--error-border: #fecaca;
--error-text: #dc2626;
--shadow-color: rgba(0, 0, 0, 0.1);
--accent: #6366f1;
--accent-hover: #4f46e5;
--link: #0f172a;
--link-hover: #475569;
}
/* Темная тема */
[data-theme="dark"] {
--bg-primary: #0f172a;
--bg-secondary: #1e293b;
--bg-tertiary: #334155;
--text-primary: #f8fafc;
--text-secondary: #cbd5e1;
--text-muted: #64748b;
--border: #334155;
--border-focus: #64748b;
--card-bg: #1e293b;
--input-bg: #1e293b;
--header-bg: #0f172a;
--button-primary: #f8fafc;
--button-primary-text: #0f172a;
--button-primary-hover: #e2e8f0;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #f87171;
--error-bg: rgba(239, 68, 68, 0.1);
--error-border: rgba(239, 68, 68, 0.3);
--error-text: #fca5a5;
--shadow-color: rgba(0, 0, 0, 0.3);
--accent: #818cf8;
--accent-hover: #a5b4fc;
--link: #f8fafc;
--link-hover: #cbd5e1;
}
/* ===========================
ЦВЕТНЫЕ ТЕМЫ
=========================== */
/* Night Owl */
[data-theme="nightowl"] {
--bg-primary: #011627;
--bg-secondary: #011e3c;
--bg-tertiary: #0d2f4f;
--text-primary: #d6deeb;
--text-secondary: #8892b0;
--text-muted: #4a5568;
--border: #1d3b53;
--border-focus: #7dd3fc;
--card-bg: #011e3c;
--input-bg: #011e3c;
--header-bg: #011627;
--button-primary: #7dd3fc;
--button-primary-text: #011627;
--button-primary-hover: #bae6fd;
--button-danger: #f87171;
--button-danger-text: #ffffff;
--button-danger-hover: #fca5a5;
--error-bg: rgba(248, 113, 113, 0.1);
--error-border: rgba(248, 113, 113, 0.3);
--error-text: #fca5a5;
--shadow-color: rgba(0, 0, 0, 0.4);
--accent: #7dd3fc;
--accent-hover: #bae6fd;
--link: #7dd3fc;
--link-hover: #bae6fd;
}
/* Sunset */
[data-theme="sunset"] {
--bg-primary: #1c1917;
--bg-secondary: #292524;
--bg-tertiary: #44403c;
--text-primary: #fafaf9;
--text-secondary: #d6d3d1;
--text-muted: #78716c;
--border: #57534e;
--border-focus: #f97316;
--card-bg: #292524;
--input-bg: #292524;
--header-bg: #1c1917;
--button-primary: #f97316;
--button-primary-text: #1c1917;
--button-primary-hover: #fb923c;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #f87171;
--error-bg: rgba(239, 68, 68, 0.1);
--error-border: rgba(239, 68, 68, 0.3);
--error-text: #fca5a5;
--shadow-color: rgba(0, 0, 0, 0.4);
--accent: #f97316;
--accent-hover: #fb923c;
--link: #f97316;
--link-hover: #fb923c;
}
/* Forest */
[data-theme="forest"] {
--bg-primary: #052e16;
--bg-secondary: #14532d;
--bg-tertiary: #166534;
--text-primary: #f0fdf4;
--text-secondary: #bbf7d0;
--text-muted: #4ade80;
--border: #166534;
--border-focus: #22c55e;
--card-bg: #14532d;
--input-bg: #14532d;
--header-bg: #052e16;
--button-primary: #22c55e;
--button-primary-text: #052e16;
--button-primary-hover: #4ade80;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #f87171;
--error-bg: rgba(239, 68, 68, 0.1);
--error-border: rgba(239, 68, 68, 0.3);
--error-text: #fca5a5;
--shadow-color: rgba(0, 0, 0, 0.4);
--accent: #22c55e;
--accent-hover: #4ade80;
--link: #22c55e;
--link-hover: #4ade80;
}
/* Ocean */
[data-theme="ocean"] {
--bg-primary: #164e63;
--bg-secondary: #0e7490;
--bg-tertiary: #0891b2;
--text-primary: #f0fdfd;
--text-secondary: #a5f3fc;
--text-muted: #22d3ee;
--border: #0891b2;
--border-focus: #06b6d4;
--card-bg: #0e7490;
--input-bg: #0e7490;
--header-bg: #164e63;
--button-primary: #06b6d4;
--button-primary-text: #164e63;
--button-primary-hover: #22d3ee;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #f87171;
--error-bg: rgba(239, 68, 68, 0.1);
--error-border: rgba(239, 68, 68, 0.3);
--error-text: #fca5a5;
--shadow-color: rgba(0, 0, 0, 0.4);
--accent: #06b6d4;
--accent-hover: #22d3ee;
--link: #06b6d4;
--link-hover: #22d3ee;
}
/* Lavender */
[data-theme="lavender"] {
--bg-primary: #faf5ff;
--bg-secondary: #f3e8ff;
--bg-tertiary: #e9d5ff;
--text-primary: #581c87;
--text-secondary: #7e22ce;
--text-muted: #a855f7;
--border: #e9d5ff;
--border-focus: #a855f7;
--card-bg: #f3e8ff;
--input-bg: #f3e8ff;
--header-bg: #faf5ff;
--button-primary: #a855f7;
--button-primary-text: #faf5ff;
--button-primary-hover: #c084fc;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #f87171;
--error-bg: rgba(239, 68, 68, 0.1);
--error-border: rgba(239, 68, 68, 0.3);
--error-text: #dc2626;
--shadow-color: rgba(88, 28, 135, 0.1);
--accent: #a855f7;
--accent-hover: #c084fc;
--link: #7e22ce;
--link-hover: #a855f7;
}
/* Coffee */
[data-theme="coffee"] {
--bg-primary: #292524;
--bg-secondary: #44403c;
--bg-tertiary: #57534e;
--text-primary: #f5f5f4;
--text-secondary: #d6d3d1;
--text-muted: #a8a29e;
--border: #57534e;
--border-focus: #d97706;
--card-bg: #44403c;
--input-bg: #44403c;
--header-bg: #292524;
--button-primary: #d97706;
--button-primary-text: #292524;
--button-primary-hover: #fbbf24;
--button-danger: #ef4444;
--button-danger-text: #ffffff;
--button-danger-hover: #f87171;
--error-bg: rgba(239, 68, 68, 0.1);
--error-border: rgba(239, 68, 68, 0.3);
--error-text: #fca5a5;
--shadow-color: rgba(0, 0, 0, 0.4);
--accent: #d97706;
--accent-hover: #fbbf24;
--link: #d97706;
--link-hover: #fbbf24;
}
/* ===========================
БАЗОВЫЕ СТИЛИ
=========================== */
body {
background-color: var(--bg-primary);
color: var(--text-primary);
transition:
background-color 0.3s ease,
color 0.3s ease,
border-color 0.3s ease;
}
+45
View File
@@ -0,0 +1,45 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
"target": "ES2023",
"useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext",
"types": ["vite/client"],
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"],
"@/components/*": ["src/components/*"],
"@/store/*": ["src/store/*"],
"@/services/*": ["src/services/*"],
"@/styles/*": ["src/styles/*"],
"@/pages/*": ["src/pages/*"],
"@/types/*": ["src/components/layout/sidebar/types/*"],
"@/lib/*": ["src/lib/*"]
},
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"erasableSyntaxOnly": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedSideEffectImports": true
},
"include": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.d.ts",
"env.d.ts",
"src/modules/workaspace/terminal/hooks"
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"files": [],
"references": [
{ "path": "./tsconfig.app.json" },
{ "path": "./tsconfig.node.json" }
]
}
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
"target": "ES2023",
"lib": ["ES2023"],
"module": "ESNext",
"types": ["node"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"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"]
}
+13
View File
@@ -0,0 +1,13 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";
import tailwindcss from "@tailwindcss/vite";
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "src"),
},
},
});
+3935
View File
File diff suppressed because it is too large Load Diff