-
-
-
+ {/* Сайдбар */}
+
-
-
+ {/* Вкладки */}
+ setActiveTab(id)}
+ onTabClick={setActiveTab}
onCloseTab={handleCloseTab}
/>
+
+ {/* Контент вкладки */}
- {renderTabContent()}
+
diff --git a/src/Components/Layout/SidebarMenu.jsx b/src/Components/Layout/SidebarMenu.jsx
old mode 100755
new mode 100644
index 651c2e7..60acb84
--- a/src/Components/Layout/SidebarMenu.jsx
+++ b/src/Components/Layout/SidebarMenu.jsx
@@ -1,86 +1,49 @@
-import React, { useState } from "react";
-import "../../Style/SidebarMenu.css";
-import { ThemeProvider, createTheme, CssBaseline, Button } from "@mui/material";
-import { getStatusColor } from "../TreeChart/dataUtils"; // Импортируем только нужную функцию
+import React from "react";
+import { Drawer, List } from "@mui/material";
+import MenuItem from "./SidebarMenuComponents/MenuItem";
+import SidebarFooter from "./SidebarMenuComponents/SidebarFooter";
-const MenuItem = ({ item, onSelectItem, sidebarWidth }) => {
- const [isOpen, setIsOpen] = useState(false);
- const hasChildren = Array.isArray(item.items) && item.items.length > 0;
- const statusColor = getStatusColor(item.status);
-
- const handleSingleClick = () => {
- if (hasChildren) {
- setIsOpen(!isOpen);
- } else {
- onSelectItem(item);
- }
- };
-
- const handleOpenParent = (e) => {
- e.stopPropagation();
- onSelectItem(item);
+const SidebarMenu = ({ data, onOpenTab, sidebarWidth, startResizing }) => {
+ const handleSelectItem = (id, title, children) => {
+ onOpenTab(id, title, children);
};
return (
-
-
- {/* Круглый индикатор статуса */}
-
- {/* Текст элемента меню */}
-
{item.title}
+
+
+ Меню
+
+
- {/* Иконки */}
- {hasChildren && (
-
- {/* Иконка для открытия родителя */}
-
- 📂
-
- {/* Иконка для разворачивания/сворачивания */}
-
- {isOpen ? "▲" : "▼"}
-
-
- )}
-
- {isOpen && hasChildren && (
-
- {item.items.map((child, index) => (
-
- ))}
-
- )}
-
+ {/* Ресайзер */}
+
+
+
+
);
};
-function SidebarMenu({ data, onOpenTab, sidebarWidth }) {
- const handleSelectItem = (item) => {
- onOpenTab(item.id, item.title);
- };
-
- return (
-
-
{/* Динамическая ширина */}
-
Меню
-
-
-
{/* Динамическая ширина */}
-
Помощь
- Настройка
-
-
- );
-}
-
-export default SidebarMenu;
\ No newline at end of file
+export default SidebarMenu;
diff --git a/src/Components/Layout/SidebarMenuComponents/MenuItem.jsx b/src/Components/Layout/SidebarMenuComponents/MenuItem.jsx
new file mode 100644
index 0000000..82f5f5d
--- /dev/null
+++ b/src/Components/Layout/SidebarMenuComponents/MenuItem.jsx
@@ -0,0 +1,55 @@
+import React from "react";
+import { Drawer, List, ListItem, ListItemIcon, ListItemText, Collapse } from "@mui/material";
+import { ExpandLess, ExpandMore, Folder, FolderOpen } from "@mui/icons-material";
+
+// Функция для сбора всех потомков
+const getAllChildren = (node) => {
+ let children = [];
+ if (node.items && node.items.length > 0) {
+ node.items.forEach((child) => {
+ children.push(child); // Добавляем текущий элемент
+ children = children.concat(getAllChildren(child)); // Рекурсивно добавляем потомков
+ });
+ }
+ return children;
+};
+
+const MenuItem = ({ item, onSelectItem }) => {
+ const [isOpen, setIsOpen] = React.useState(false);
+ const hasChildren = Array.isArray(item.items) && item.items.length > 0;
+
+ const handleToggle = () => {
+ setIsOpen(!isOpen);
+ };
+
+ const handleOpenTab = (e) => {
+ e.stopPropagation(); // Останавливаем всплытие события
+ const allChildren = getAllChildren(item); // Собираем всех потомков
+ onSelectItem(item.id, item.title, allChildren); // Передаем данные в родительский компонент
+ };
+
+ return (
+ <>
+
+
+
+ {hasChildren ? (isOpen ? : ) : }
+
+
+
+ {hasChildren && (isOpen ? : )}
+
+ {hasChildren && (
+
+
+ {item.items.map((child, index) => (
+
+ ))}
+
+
+ )}
+ >
+ );
+};
+
+export default MenuItem;
\ No newline at end of file
diff --git a/src/Components/Layout/SidebarMenuComponents/SidebarFooter.jsx b/src/Components/Layout/SidebarMenuComponents/SidebarFooter.jsx
new file mode 100644
index 0000000..ec62bda
--- /dev/null
+++ b/src/Components/Layout/SidebarMenuComponents/SidebarFooter.jsx
@@ -0,0 +1,17 @@
+import React from "react";
+import { List, ListItem, ListItemText } from "@mui/material";
+
+const SidebarFooter = ({ sidebarWidth }) => {
+ return (
+
+
+
+
+
+
+
+
+ );
+};
+
+export default SidebarFooter;
\ No newline at end of file
diff --git a/src/Components/UI/LoginModal.jsx b/src/Components/UI/LoginModal.jsx
index 7d77404..98405a8 100755
--- a/src/Components/UI/LoginModal.jsx
+++ b/src/Components/UI/LoginModal.jsx
@@ -1,18 +1,8 @@
import React, { useState } from "react";
import Modal from "./Modal";
import "../../Style/LoginModal.css";
-import Box from '@mui/material/Box';
-import IconButton from '@mui/material/IconButton';
-import Input from '@mui/material/Input';
-import FilledInput from '@mui/material/FilledInput';
-import OutlinedInput from '@mui/material/OutlinedInput';
-import InputLabel from '@mui/material/InputLabel';
-import InputAdornment from '@mui/material/InputAdornment';
-import FormHelperText from '@mui/material/FormHelperText';
-import FormControl from '@mui/material/FormControl';
import TextField from '@mui/material/TextField';
-
const LoginModal = ({ onLogin, onClose }) => {
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
@@ -21,13 +11,31 @@ const LoginModal = ({ onLogin, onClose }) => {
const handleClickShowPassword = () => setShowPassword((show) => !show);
- const handleSubmit = (e) => {
+ const handleSubmit = async (e) => {
e.preventDefault();
- if (username === "admin" && password === "admin") {
- onLogin(); // Успешная авторизация
- onClose(); // Закрыть модальное окно
- } else {
- setError("Неверный логин или пароль");
+
+ try {
+ // Отправляем данные на бэкенд
+ console.log("Отправляем данные:", { username, password });
+ const response = await fetch('http://192.168.2.39:3000/auth/login', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({ login: username, password }),
+ });
+
+ const data = await response.json();
+
+ if (data.success) {
+ onLogin(); // Успешная авторизация
+ onClose(); // Закрыть модальное окно
+ } else {
+ setError(data.message || "Неверный логин или пароль");
+ }
+ } catch (err) {
+ console.error('Ошибка при отправке запроса:', err);
+ setError("Ошибка при подключении к серверу");
}
};
@@ -35,77 +43,28 @@ const LoginModal = ({ onLogin, onClose }) => {
Авторизация