front #8

Merged
mfnefd merged 14 commits from front into dev 2024-12-25 23:49:21 +04:00
10 changed files with 277 additions and 12 deletions
Showing only changes of commit 3393c1be70 - Show all commits

25
.dockerignore Normal file
View File

@ -0,0 +1,25 @@
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
**/docker-compose*
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md

4
Dockerfile Normal file
View File

@ -0,0 +1,4 @@
FROM docker/whalesay:latest
LABEL Name=cucumber Version=0.0.1
RUN apt-get -y update && apt-get install -y fortunes
CMD ["sh", "-c", "/usr/games/fortune -a | cowsay"]

View File

@ -18,7 +18,9 @@
"antd": "^5.21.6",
"axios": "^1.7.7",
"react": "^18.3.1",
"react-avatar": "^5.0.3",
"react-dom": "^18.2.0",
"react-dropzone": "^14.3.5",
"react-router-dom": "^6.27.0",
"react-scripts": "^5.0.1",
"typescript": "^4.9.5",
@ -5250,6 +5252,14 @@
"node": ">= 4.0.0"
}
},
"node_modules/attr-accept": {
"version": "2.2.5",
"resolved": "https://registry.npmjs.org/attr-accept/-/attr-accept-2.2.5.tgz",
"integrity": "sha512-0bDNnY/u6pPwHDMoF0FieU354oBi0a8rD9FcsLwzcGWbc8KS8KPIi7y+s13OlVY+gMWc/9xEMUgNE6Qm8ZllYQ==",
"engines": {
"node": ">=4"
}
},
"node_modules/autoprefixer": {
"version": "10.4.20",
"resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-10.4.20.tgz",
@ -5917,6 +5927,14 @@
"node": ">=10"
}
},
"node_modules/charenc": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
"engines": {
"node": "*"
}
},
"node_modules/check-types": {
"version": "11.2.3",
"resolved": "https://registry.npmjs.org/check-types/-/check-types-11.2.3.tgz",
@ -6394,6 +6412,14 @@
"node": ">= 8"
}
},
"node_modules/crypt": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
"engines": {
"node": "*"
}
},
"node_modules/crypto-random-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz",
@ -8508,6 +8534,17 @@
"url": "https://opencollective.com/webpack"
}
},
"node_modules/file-selector": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/file-selector/-/file-selector-2.1.2.tgz",
"integrity": "sha512-QgXo+mXTe8ljeqUFaX3QVHc5osSItJ/Km+xpocx0aSqWGMSCf6qYs/VnzZgS864Pjn5iceMRFigeAV7AfTlaig==",
"dependencies": {
"tslib": "^2.7.0"
},
"engines": {
"node": ">= 12"
}
},
"node_modules/filelist": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.4.tgz",
@ -9788,6 +9825,11 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w=="
},
"node_modules/is-callable": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
@ -10041,6 +10083,11 @@
"node": ">=0.10.0"
}
},
"node_modules/is-retina": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/is-retina/-/is-retina-1.0.3.tgz",
"integrity": "sha512-/tCmbIETZwCd8uHWO+GvbRa7jxwHFHdfetHfiwoP0aN9UDf3prUJMtKn7iBFYipYhqY1bSTjur8hC/Dakt8eyw=="
},
"node_modules/is-root": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-root/-/is-root-2.1.0.tgz",
@ -11712,6 +11759,16 @@
"tmpl": "1.0.5"
}
},
"node_modules/md5": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
"dependencies": {
"charenc": "0.0.2",
"crypt": "0.0.2",
"is-buffer": "~1.1.6"
}
},
"node_modules/mdn-data": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.4.tgz",
@ -14813,6 +14870,21 @@
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
"license": "MIT"
},
"node_modules/react-avatar": {
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/react-avatar/-/react-avatar-5.0.3.tgz",
"integrity": "sha512-DNc+qkWH9QehSEZqHBhqpXWsPY+rU9W7kD68QFHfu8Atfsvx/3ML0DzAePgTUd96nCXQQ3KZMcC3LKYT8FiBIg==",
"dependencies": {
"is-retina": "^1.0.3",
"md5": "^2.0.0"
},
"peerDependencies": {
"@babel/runtime": ">=7",
"core-js-pure": ">=3",
"prop-types": "^15.0.0 || ^16.0.0",
"react": "^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/react-dev-utils": {
"version": "12.0.1",
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-12.0.1.tgz",
@ -14931,6 +15003,22 @@
"react": "^18.3.1"
}
},
"node_modules/react-dropzone": {
"version": "14.3.5",
"resolved": "https://registry.npmjs.org/react-dropzone/-/react-dropzone-14.3.5.tgz",
"integrity": "sha512-9nDUaEEpqZLOz5v5SUcFA0CjM4vq8YbqO0WRls+EYT7+DvxUdzDPKNCPLqGfj3YL9MsniCLCD4RFA6M95V6KMQ==",
"dependencies": {
"attr-accept": "^2.2.4",
"file-selector": "^2.1.0",
"prop-types": "^15.8.1"
},
"engines": {
"node": ">= 10.13"
},
"peerDependencies": {
"react": ">= 16.8 || 18.0.0"
}
},
"node_modules/react-error-overlay": {
"version": "6.0.11",
"resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz",

View File

@ -13,7 +13,9 @@
"antd": "^5.21.6",
"axios": "^1.7.7",
"react": "^18.3.1",
"react-avatar": "^5.0.3",
"react-dom": "^18.2.0",
"react-dropzone": "^14.3.5",
"react-router-dom": "^6.27.0",
"react-scripts": "^5.0.1",
"typescript": "^4.9.5",

View File

@ -4,7 +4,7 @@ import IFarm from '../models/IFarm';
import LoginRequest from '../Requests/LoginRequest';
import IRegisterRequest from '../Requests/RegisterRequest';
const API_BASE_URL = 'https://localhost:7113/api';
const API_BASE_URL = 'https://localhost:5124/api';
const getHeaders = (): { [key: string]: string } => {
return {

View File

@ -6,17 +6,19 @@ import {RegisterPage} from './pages/Register';
import {AppLayout} from './components/Layout';
import { ProfilePage } from './pages/Profile';
import { GreenHouseListPage } from './pages/GreenHouseListPage';
import { ReportPage } from './pages/ReportPage';
function App() {
return (
<div className="App">
<Routes>
<Route path="/" element={<AppLayout />}>
<Route index element={<Navigate to="/profile" />} />
<Route index element={<Navigate to="/report" />} />
<Route path="/login" element={<LoginPage />} />
<Route path="/register" element={<RegisterPage />} />
<Route path="/profile" element={<ProfilePage />} />
<Route path="/greenhouses" element={<GreenHouseListPage />} />
<Route path="/report" element={<ReportPage />} />
</Route>
</Routes>

View File

@ -1,7 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import Title from 'antd/es/typography/Title';
import { LoginOutlined, ProfileOutlined } from '@ant-design/icons';
import { HomeOutlined, LoginOutlined, ProfileOutlined } from '@ant-design/icons';
export function Header () {
return (
@ -15,7 +15,10 @@ export function Header () {
<Link to="/login"><LoginOutlined style={{ fontSize: '24px' }} className="text-white"/></Link>
</li>
<li>
<Link to="/register"><ProfileOutlined style={{ fontSize: '24px', marginRight: '20px'}} className="text-white"/></Link>
<Link to="/profile"><ProfileOutlined style={{ fontSize: '24px', marginRight: '20px'}} className="text-white"/></Link>
</li>
<li>
<Link to="/greenhouses"><HomeOutlined style={{ fontSize: '24px', marginRight: '20px'}} className="text-white"/> </Link>
</li>
</ul>
</nav>

View File

@ -56,8 +56,13 @@ export function GreenHouseListPage() {
},
{
title: 'Температура',
dataIndex: 'recommendedTemperature',
key: 'recommendedTemperature',
dataIndex: 'Temperature',
key: 'Temperature',
},
{
title: 'Процент влажности',
dataIndex: 'Humidity',
key: 'Humidity',
},
{
title: 'Режим полива',
@ -71,11 +76,25 @@ export function GreenHouseListPage() {
key: 'heatingMode',
render: (text: string) => text === 'Manual' ? 'Вручную' : 'Автоматически',
},
{
title: 'Статус вентиля',
dataIndex: 'ventilationStatus',
key: 'ventilationStatus',
render: (text: string) => text === 'Manual' ? 'Вручную' : 'Автоматически',
},
{
title: 'Статус нагревателя',
dataIndex: 'heatingStatus',
key: 'heatingStatus',
render: (text: string) => text === 'Manual' ? 'Вручную' : 'Автоматически',
},
{
title: 'Действия',
key: 'action',
render: (_: any, record: IGreenhouse) => (
<Space>
<Button>Начать полив</Button>
<Button>Начать нагрев</Button>
<Button onClick={() => handleDelete(record.id)}>Удалить</Button>
<Button onClick={() => handleModalOpen(record)}>Редактировать</Button>
</Space>
@ -106,7 +125,10 @@ export function GreenHouseListPage() {
<Form.Item name="name" label="Название" rules={[{ required: true }]}>
<Input />
</Form.Item>
<Form.Item name="recommendedTemperature" label="Температура">
<Form.Item name="Temperature" label="Температура">
<Input type="number" />
</Form.Item>
<Form.Item name="Humidity" label="Процент влажности">
<Input type="number" />
</Form.Item>
<Form.Item name="wateringMode" label="Режим полива">
@ -121,6 +143,18 @@ export function GreenHouseListPage() {
<Select.Option value="Auto">Автоматически</Select.Option>
</Select>
</Form.Item>
<Form.Item name="ventilationStatus" label="Статус вентиля">
<Select>
<Select.Option value="Manual">Вручную</Select.Option>
<Select.Option value="Auto">Автоматически</Select.Option>
</Select>
</Form.Item>
<Form.Item name="heatingStatus" label="Статус нагревателя">
<Select>
<Select.Option value="Manual">Вручную</Select.Option>
<Select.Option value="Auto">Автоматически</Select.Option>
</Select>
</Form.Item>
</Form>
</Modal>
</div>

View File

@ -1,15 +1,97 @@
import { Navigate } from "react-router-dom";
import { Link, Navigate } from "react-router-dom";
import { Form, Avatar, Button, Input, Typography } from "antd";
import { useId, useState } from "react";
import React from "react";
export function ProfilePage () {
const token = localStorage.getItem('token');
const [hidden, setHidden] = useState(true);
const [name, setName] = useState('Пользователь');
const [email, setEmail] = useState('user@gmail.com');
if (!token) {
return <Navigate to="/login" />;
const Title = () => <Typography.Title style={{ fontSize: '42px', fontWeight: 'bold', marginBottom: '40px', marginTop: '20px'}}>Ваш профиль</Typography.Title>;
const StyledText = ({ children }: { children: React.ReactNode }) => <Typography.Text strong style={{ fontSize: '24px', marginBottom: '20px' }}>{children}</Typography.Text>;
const StyledValue = ({ children }: { children: React.ReactNode }) => <Typography.Text style={{ fontSize: '24px', marginBottom: '20px' }}>{children}</Typography.Text>;
const User = {
id: 1,
name: name,
email: "user@gmail.com",
password: "12345",
}
function onFinish(name: string, email: string) {
setName(name);
setEmail(email);
}
function onLogout() {
localStorage.removeItem('token');
window.location.href = '/login';
}
return (
<div>
<h1 className="PCEtLSBpY29uNjY2LmNvbSAtIE1JTExJT05TIHZlY3RvciBJQ09OUyBGUkVFIC0tPjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iQ2FwYV8xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwM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TcuMjEyLDE1MC4wNTYsMjA2Ljc5MiwxMzkuNjM2LDE5My45MzksMTM5LjYzNnoiPjwvcGF0aD48L2c+PC9nPjwvc3ZnPg==">Profile</h1>
<div className="container mx-auto flex" style={{ flexDirection: 'column'}}>
<Title />
<div className="container mx-auto flex" style={{ maxWidth: '40%', marginTop: '100px', flexDirection: 'column'}}>
<div className="container mx-auto flex" style={{ flexDirection: 'column', justifyContent: 'left', alignItems: 'flex-start' }}>
<span style={{ marginLeft: '20px' }}>
<StyledText>Почта:</StyledText>
<StyledValue> {User.email}</StyledValue>
</span>
<span style={{ marginLeft: '20px' }}>
<StyledText>Имя пользователя:</StyledText>
<StyledValue> {User.name}</StyledValue>
</span>
<span style={{ marginLeft: '20px' }}>
<StyledText>Количество теплиц:</StyledText>
<StyledValue> 2</StyledValue>
<Link style={{ marginLeft: '10px', fontSize: '24px', textDecorationLine: 'underline', color: 'blue'}} to="/greenhouses">[Перейти]</Link>
</span>
</div>
<div className="container mx-auto flex" style={{ flexDirection: 'row', justifyContent: 'center', marginTop: '20px'}}>
<Button style={{ marginRight: '10px'}} onClick={() => setHidden(!hidden)}>{hidden ? 'Редактировать' : 'Закончить редактирование'} </Button>
<Button>Выйти</Button>
</div>
<Form style={{ marginTop: '20px', width: '70%' }} layout="vertical" hidden={hidden}>
<Form.Item style={{ width: '100%', justifySelf: 'end', textAlign: 'right' }} name="name" rules={[{ required: false }]}>
Новое имя пользователя: <Input style={{ width: '200px', marginLeft: '10px' }} placeholder={User.name}></Input>
</Form.Item>
<Form.Item style={{ width: '100%', justifySelf: 'end', textAlign: 'right' }} name="email" rules={[{ required: false }]}>
Новая почта: <Input style={{ width: '200px', marginLeft: '10px' }} placeholder={User.email}></Input>
</Form.Item>
<div style={{ textAlign: 'right' }}>
<Button htmlType="submit" onClick={() => onFinish(name, email)}>Сохранить изменения</Button>
</div>
</Form>
</div>
<div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '20px'}}>
<Button style={{ width: '160px', backgroundColor: 'red', color: 'white'}} onClick={onLogout}>Выйти из аккаунта</Button>
</div>
</div>
)
}
function async<T>(file: any, File: { new(fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File; prototype: File; }, url: any, string: any, arg4: any) {
throw new Error("Function not implemented.");
}

View File

@ -0,0 +1,25 @@
import Title from "antd/es/typography/Title";
export function ReportPage() {
return (
<div style={{ display: 'flex', flexDirection: 'column', marginTop: '200px', marginLeft: '550px' }}>
<Title style={{ marginBottom: '20px', fontSize: '42px', fontWeight: 'bold' }}>Отчеты по теплицам</Title>
<div style={{ marginTop: '20px', display: 'flex', flexDirection: 'row', justifyContent: 'space-between', width: '100%', maxWidth: '800px' }}>
<div style={{ flex: 1, marginRight: '20px' }}>
<h2>Температура</h2>
<img src="https://i.ibb.co/zhf8s0z/temperature-report.png" alt="temperature-report" />
</div>
<div style={{ flex: 1, marginLeft: '20px' }}>
<h2>Влажность</h2>
<img src="https://i.ibb.co/zhf8s0z/temperature-report.png" alt="humidity-report" />
</div>
<div style={{ flex: 1, marginLeft: '20px' }}>
<h2>Теплицы</h2>
<img src="https://i.ibb.co/zhf8s0z/temperature-report.png" alt="greenhouses-report" />
</div>
</div>
</div>
);
};
export default ReportPage;