vanya lox

This commit is contained in:
wow22831 2024-09-21 21:30:05 +07:00
parent 2b91b6e8ee
commit 2c53d32322
12 changed files with 391 additions and 21 deletions

59
package-lock.json generated
View File

@ -11,6 +11,7 @@
"@testing-library/jest-dom": "^5.17.0", "@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"primereact": "^10.8.3",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
@ -4751,6 +4752,15 @@
"@types/react": "*" "@types/react": "*"
} }
}, },
"node_modules/@types/react-transition-group": {
"version": "4.4.11",
"resolved": "https://registry.npmjs.org/@types/react-transition-group/-/react-transition-group-4.4.11.tgz",
"integrity": "sha512-RM05tAniPZ5DZPzzNFP+DmrcOdD0efDUxMy3145oljWSl3x9ZV5vhme98gTxFrj2lhXvmGNnUiuDyJgY9IKkNA==",
"license": "MIT",
"dependencies": {
"@types/react": "*"
}
},
"node_modules/@types/resolve": { "node_modules/@types/resolve": {
"version": "1.17.1", "version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
@ -7605,6 +7615,16 @@
"utila": "~0.4" "utila": "~0.4"
} }
}, },
"node_modules/dom-helpers": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/dom-helpers/-/dom-helpers-5.2.1.tgz",
"integrity": "sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.8.7",
"csstype": "^3.0.2"
}
},
"node_modules/dom-serializer": { "node_modules/dom-serializer": {
"version": "1.4.1", "version": "1.4.1",
"resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz",
@ -15762,6 +15782,29 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1" "url": "https://github.com/chalk/ansi-styles?sponsor=1"
} }
}, },
"node_modules/primereact": {
"version": "10.8.3",
"resolved": "https://registry.npmjs.org/primereact/-/primereact-10.8.3.tgz",
"integrity": "sha512-LYa7DL1TDmWWrPCeh3CMsx89LXgcf4+rYhJ6YiA7z164WsdzJK388Bp1Qdv5cfpyL/Nm0eIWxIApxwWBv8kwuA==",
"license": "MIT",
"dependencies": {
"@types/react-transition-group": "^4.4.1",
"react-transition-group": "^4.4.1"
},
"engines": {
"node": ">=14.0.0"
},
"peerDependencies": {
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
}
},
"node_modules/process-nextick-args": { "node_modules/process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@ -16288,6 +16331,22 @@
} }
} }
}, },
"node_modules/react-transition-group": {
"version": "4.4.5",
"resolved": "https://registry.npmjs.org/react-transition-group/-/react-transition-group-4.4.5.tgz",
"integrity": "sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==",
"license": "BSD-3-Clause",
"dependencies": {
"@babel/runtime": "^7.5.5",
"dom-helpers": "^5.0.1",
"loose-envify": "^1.4.0",
"prop-types": "^15.6.2"
},
"peerDependencies": {
"react": ">=16.6.0",
"react-dom": ">=16.6.0"
}
},
"node_modules/read-cache": { "node_modules/read-cache": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",

View File

@ -6,6 +6,7 @@
"@testing-library/jest-dom": "^5.17.0", "@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0", "@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0", "@testing-library/user-event": "^13.5.0",
"primereact": "^10.8.3",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -1,25 +1,23 @@
import logo from './logo.svg'; import React, { useState } from 'react';
import './App.css'; import DeviceGroups from "./components/DeviceGroups"
import Devices from "./components/Devices"
import Sidebar from "./components/Sidebar"
const App = () => {
const [activeTab, setActiveTab] = useState('map'); // По умолчанию активная вкладка "Карта"
function App() {
return ( return (
<div className="App"> <div style={{ display: 'flex' }}>
<header className="App-header"> <Sidebar onSelectTab={setActiveTab} activeTab={activeTab} /> {/* Передаем активную вкладку */}
<img src={logo} className="App-logo" alt="logo" /> <div style={{ padding: '20px', flex: 1 }}>
<p> {activeTab === 'map' && <div>Карта в реальном времени</div>}
Edit <code>src/App.js</code> and save to reload. {activeTab === 'connection' && <div>Подключение</div>}
</p> {activeTab === 'account' && <div>Аккаунт пользователя</div>}
<a {activeTab === 'groups' && <DeviceGroups />} {/* Группы устройств */}
className="App-link" {activeTab === 'devices' && <Devices />} {/* Устройства */}
href="https://reactjs.org" </div>
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div> </div>
); );
} };
export default App; export default App;

49
src/DeviceGroups.css Normal file
View File

@ -0,0 +1,49 @@
.device-groups {
padding: 20px;
}
.device-groups h2 {
margin-bottom: 20px;
}
.group-creation {
margin-bottom: 20px;
}
.group-creation input {
padding: 5px;
margin-right: 10px;
}
.group-creation button {
padding: 5px 10px;
}
ul {
list-style-type: none;
padding: 0;
}
li {
margin-bottom: 20px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}
.active {
background-color: #e8f5e9;
}
.inactive {
background-color: #ffebee;
}
li div {
margin-bottom: 10px;
}
li button {
margin-right: 10px;
}

39
src/Devices.css Normal file
View File

@ -0,0 +1,39 @@
.devices {
padding: 20px;
}
.devices h2 {
margin-bottom: 20px;
}
.devices table {
width: 100%;
border-collapse: collapse;
}
.devices table, .devices th, .devices td {
border: 1px solid #ddd;
}
.devices th, .devices td {
padding: 8px;
text-align: left;
}
.devices th {
background-color: #34495e;
color: white;
}
.devices tr:hover {
background-color: #f1f1f1;
}
.buttons {
margin-top: 20px;
}
.buttons button {
margin-right: 10px;
}

52
src/Sidebar.css Normal file
View File

@ -0,0 +1,52 @@
.sidebar {
width: 250px;
height: 100vh;
background-color: #2c3e50;
color: white;
padding: 20px;
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
}
.sidebar h2 {
font-size: 24px;
margin-bottom: 20px;
}
.sidebar ul {
list-style-type: none;
padding: 0;
}
.sidebar li {
margin: 15px 0;
cursor: pointer;
}
.sidebar li:hover {
background-color: #34495e;
padding: 10px;
border-radius: 5px;
}
.sidebar ul {
list-style-type: none;
padding: 0;
}
.sidebar li {
margin: 15px 0;
cursor: pointer;
padding: 10px;
border-radius: 5px;
transition: background-color 0.3s;
}
.sidebar li:hover {
background-color: #34495e;
}
.sidebar li.active {
background-color: #2980b9;
color: white;
}

View File

@ -0,0 +1,88 @@
import React, { useState } from 'react';
import '../DeviceGroups.css';
const DeviceGroups = () => {
const [groups, setGroups] = useState([]);
const [selectedGroup, setSelectedGroup] = useState(null);
const [newGroupName, setNewGroupName] = useState('');
const createGroup = () => {
if (newGroupName) {
const newGroup = {
name: newGroupName,
devices: [],
active: true,
};
setGroups([...groups, newGroup]);
setNewGroupName('');
}
};
const deleteGroup = (groupName) => {
setGroups(groups.filter(group => group.name !== groupName));
};
const toggleGroupStatus = (groupName) => {
setGroups(groups.map(group =>
group.name === groupName ? { ...group, active: !group.active } : group
));
};
const addDeviceToGroup = (groupName, device) => {
setGroups(groups.map(group =>
group.name === groupName ? { ...group, devices: [...group.devices, device] } : group
));
};
const removeDeviceFromGroup = (groupName, device) => {
setGroups(groups.map(group =>
group.name === groupName ? { ...group, devices: group.devices.filter(d => d !== device) } : group
));
};
return (
<div className="device-groups">
<h2>Группы устройств</h2>
<div className="group-creation">
<input
type="text"
value={newGroupName}
onChange={(e) => setNewGroupName(e.target.value)}
placeholder="Название новой группы"
/>
<button onClick={createGroup}>Создать группу</button>
</div>
<ul>
{groups.map(group => (
<li key={group.name} className={group.active ? 'active' : 'inactive'}>
<div>
<span>{group.name}</span>
<button onClick={() => deleteGroup(group.name)}>Удалить</button>
<button onClick={() => toggleGroupStatus(group.name)}>
{group.active ? 'Деактивировать' : 'Активировать'}
</button>
</div>
<div>
<h4>Устройства в группе:</h4>
<ul>
{group.devices.map((device, index) => (
<li key={index}>
{device} <button onClick={() => removeDeviceFromGroup(group.name, device)}>Удалить</button>
</li>
))}
</ul>
<button onClick={() => addDeviceToGroup(group.name, 'Новое устройство')}>
Добавить устройство
</button>
</div>
</li>
))}
</ul>
</div>
);
};
export default DeviceGroups;

56
src/components/Devices.js Normal file
View File

@ -0,0 +1,56 @@
import React, { useState } from 'react';
import '../Devices.css';
const Devices = () => {
const [devices, setDevices] = useState([]);
const [selectedDevice, setSelectedDevice] = useState(null);
const addDevice = () => {
// Логика добавления устройства
};
const removeDevice = () => {
// Логика удаления выбранного устройства
};
const editDevice = () => {
// Логика редактирования устройства
};
const generateQR = () => {
// Логика генерации QR-кода
};
return (
<div className="devices">
<h2>Устройства</h2>
<table>
<thead>
<tr>
<th>Название</th>
<th>Статус</th>
<th>Действия</th>
</tr>
</thead>
<tbody>
{devices.map((device, index) => (
<tr key={index} onClick={() => setSelectedDevice(device)}>
<td>{device.name}</td>
<td>{device.status}</td>
<td>
<button onClick={editDevice}>Редактировать</button>
</td>
</tr>
))}
</tbody>
</table>
<div className="buttons">
<button onClick={addDevice}>Добавить</button>
<button onClick={removeDevice} disabled={!selectedDevice}>Удалить выбранное</button>
<button onClick={generateQR}>Генерация QR</button>
</div>
</div>
);
};
export default Devices;

29
src/components/Sidebar.js Normal file
View File

@ -0,0 +1,29 @@
import React from 'react';
import '../Sidebar.css';
const Sidebar = ({ onSelectTab, activeTab }) => {
return (
<div className="sidebar">
<h2>Меню</h2>
<ul>
<li className={activeTab === 'map' ? 'active' : ''} onClick={() => onSelectTab('map')}>
Карта в реальном времени
</li>
<li className={activeTab === 'connection' ? 'active' : ''} onClick={() => onSelectTab('connection')}>
Подключение
</li>
<li className={activeTab === 'account' ? 'active' : ''} onClick={() => onSelectTab('account')}>
Аккаунт пользователя
</li>
<li className={activeTab === 'groups' ? 'active' : ''} onClick={() => onSelectTab('groups')}>
Группы устройств
</li>
<li className={activeTab === 'devices' ? 'active' : ''} onClick={() => onSelectTab('devices')}>
Устройства
</li>
</ul>
</div>
);
};
export default Sidebar;

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3"><g fill="#61DAFB"><path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/><circle cx="420.9" cy="296.5" r="45.7"/><path d="M520.5 78.1z"/></g></svg>

Before

Width:  |  Height:  |  Size: 2.6 KiB