From a9a572d57f1f3abca523dedf098e5cea4f1f2117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BB=D0=BE=D0=B2?= Date: Thu, 12 Aug 2021 17:47:16 +0500 Subject: [PATCH] grouping TelemetryView components --- src/components/Display.jsx | 12 +++--- src/components/EditableTable.jsx | 2 +- src/components/UserOfWells.jsx | 22 ---------- src/pages/Smbo.jsx | 2 +- .../TelemetryView}/ActiveMessagesOnline.jsx | 16 ++++---- .../TelemetryView}/ChartTimeOnlineFooter.jsx | 2 +- .../TelemetryView}/Column.jsx | 4 +- .../TelemetryView}/CustomColumn.jsx | 4 +- src/pages/TelemetryView/UserOfWells.jsx | 9 ++++ .../index.jsx} | 41 ++++++++++--------- src/pages/Well.jsx | 12 +++--- 11 files changed, 59 insertions(+), 67 deletions(-) delete mode 100644 src/components/UserOfWells.jsx rename src/{components => pages/TelemetryView}/ActiveMessagesOnline.jsx (87%) rename src/{components => pages/TelemetryView}/ChartTimeOnlineFooter.jsx (95%) rename src/{components => pages/TelemetryView}/Column.jsx (89%) rename src/{components => pages/TelemetryView}/CustomColumn.jsx (92%) create mode 100644 src/pages/TelemetryView/UserOfWells.jsx rename src/pages/{TelemetryView.jsx => TelemetryView/index.jsx} (86%) diff --git a/src/components/Display.jsx b/src/components/Display.jsx index 6ba5862..8576b5c 100644 --- a/src/components/Display.jsx +++ b/src/components/Display.jsx @@ -16,7 +16,7 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) => }) useEffect(()=>{ - if(value === undefined || value === null){ + if(value === undefined || value === null || value === '-' || value === '--'){ setVal('---') return } @@ -41,10 +41,12 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) => return } - let valueDate = moment(value) - if(valueDate.isValid()){ - setVal(valueDate.format(format)) - return + if(value.length > 4){ + let valueDate = moment(value) + if(valueDate.isValid()){ + setVal(valueDate.format(format)) + return + } } setVal(value) diff --git a/src/components/EditableTable.jsx b/src/components/EditableTable.jsx index 2062a63..cddc42f 100644 --- a/src/components/EditableTable.jsx +++ b/src/components/EditableTable.jsx @@ -77,7 +77,7 @@ export const EditableTable = ({ ...form.initialValues, key:newRowKeyValue } - const newData = [...data, newRow] + const newData = [newRow, ...data] setData(newData) edit(newRow) } diff --git a/src/components/UserOfWells.jsx b/src/components/UserOfWells.jsx deleted file mode 100644 index 97324d9..0000000 --- a/src/components/UserOfWells.jsx +++ /dev/null @@ -1,22 +0,0 @@ -import { Display } from './Display' - -export const UserOfWells = ({ data }) => { - const dataLast = data[data.length - 1] - - const lines = [ - { label: 'Пользователь', accessorName: 'user' }, - ] - - if (dataLast) - lines.forEach(line => line.value = dataLast[line.accessorName] ?? '-') - else - lines.forEach(line => line.value = '-') - - return (<> - {lines.map(line => )} - ) -} \ No newline at end of file diff --git a/src/pages/Smbo.jsx b/src/pages/Smbo.jsx index 120bd3e..dd101f0 100644 --- a/src/pages/Smbo.jsx +++ b/src/pages/Smbo.jsx @@ -1,7 +1,7 @@ import SmboPlate from '../components/SmboPlate' import '../styles/smbo.css' import EquipmentDetails from '../components/modalWindows/EquipmentDetails' -import ActiveMessagesOnline from "../components/ActiveMessagesOnline" +import ActiveMessagesOnline from "./TelemetryView/ActiveMessagesOnline" // import RigPlan from "../images/smbo/RigPlan2.png" const platesData = [ diff --git a/src/components/ActiveMessagesOnline.jsx b/src/pages/TelemetryView/ActiveMessagesOnline.jsx similarity index 87% rename from src/components/ActiveMessagesOnline.jsx rename to src/pages/TelemetryView/ActiveMessagesOnline.jsx index 6b33a61..aff20eb 100644 --- a/src/components/ActiveMessagesOnline.jsx +++ b/src/pages/TelemetryView/ActiveMessagesOnline.jsx @@ -1,11 +1,13 @@ import {useState, useEffect} from 'react' -import {MessageService} from '../services/api' -import {Subscribe} from '../services/signalr' -import moment from 'moment' -import notify from "../components/notify" -import '../styles/message.css' import {Table} from "antd"; -import LoaderPortal from "./LoaderPortal" +import moment from 'moment' + +import LoaderPortal from '../../components/LoaderPortal' +import notify from "../../components/notify" + +import {Subscribe} from '../../services/signalr' +import {MessageService} from '../../services/api' +import '../../styles/message.css' // Словарь категорий для строк таблицы const categoryDictionary = { @@ -56,7 +58,7 @@ export default function ActiveMessagesOnline({idWell}) { const update = async () => { setLoader(true) try { - const messages = await MessageService.getMessage(idWell) + const messages = await MessageService.getMessages(idWell, 0, 4) handleReceiveMessages(messages) } catch (ex) { diff --git a/src/components/ChartTimeOnlineFooter.jsx b/src/pages/TelemetryView/ChartTimeOnlineFooter.jsx similarity index 95% rename from src/components/ChartTimeOnlineFooter.jsx rename to src/pages/TelemetryView/ChartTimeOnlineFooter.jsx index 674caeb..e85b765 100644 --- a/src/components/ChartTimeOnlineFooter.jsx +++ b/src/pages/TelemetryView/ChartTimeOnlineFooter.jsx @@ -1,4 +1,4 @@ -import {ValueDisplay} from './Display' +import {ValueDisplay} from '../../components/Display' import {ControlOutlined} from '@ant-design/icons' import {Popover} from 'antd' diff --git a/src/components/Column.jsx b/src/pages/TelemetryView/Column.jsx similarity index 89% rename from src/components/Column.jsx rename to src/pages/TelemetryView/Column.jsx index 19e5af3..2aa9f6e 100644 --- a/src/components/Column.jsx +++ b/src/pages/TelemetryView/Column.jsx @@ -1,5 +1,5 @@ -import {Display} from "./Display"; -import {ChartTimeOnline} from "./charts/ChartTimeOnline"; +import {Display} from "../../components/Display"; +import {ChartTimeOnline} from "../../components/charts/ChartTimeOnline"; import {ChartTimeOnlineFooter} from "./ChartTimeOnlineFooter"; export const Column = ({lineGroup, data, interval, showBorder}) => { diff --git a/src/components/CustomColumn.jsx b/src/pages/TelemetryView/CustomColumn.jsx similarity index 92% rename from src/components/CustomColumn.jsx rename to src/pages/TelemetryView/CustomColumn.jsx index 597a2a5..0b49bd2 100644 --- a/src/components/CustomColumn.jsx +++ b/src/pages/TelemetryView/CustomColumn.jsx @@ -1,5 +1,5 @@ -import {Display} from './Display' -import RigMnemo from '../components/RigMnemo' +import {Display} from '../../components/Display' +import RigMnemo from '../../components/RigMnemo' const params = [ {label:'Рот., об/мин', accessorName:'rotorSpeed', isArrowVisible:true}, diff --git a/src/pages/TelemetryView/UserOfWells.jsx b/src/pages/TelemetryView/UserOfWells.jsx new file mode 100644 index 0000000..144c8e9 --- /dev/null +++ b/src/pages/TelemetryView/UserOfWells.jsx @@ -0,0 +1,9 @@ +import { Display } from '../../components/Display' + +export const UserOfWells = ({ data }) => { + const dataLast = data[data.length - 1] + + return +} \ No newline at end of file diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView/index.jsx similarity index 86% rename from src/pages/TelemetryView.jsx rename to src/pages/TelemetryView/index.jsx index 0492c36..ecea287 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView/index.jsx @@ -1,16 +1,18 @@ import {useState, useEffect} from 'react' -import {useParams} from 'react-router-dom' import {Row, Col, Select} from 'antd' -import LoaderPortal from '../components/LoaderPortal' -import {Column} from '../components/Column' -import {CustomColumn} from '../components/CustomColumn' -import {UserOfWells} from '../components/UserOfWells' -import {Subscribe} from '../services/signalr' -import {DataService} from '../services/api' -import '../styles/message.css' -import notify from "../components/notify" -import {ModeDisplay} from "../components/ModeDisplay" -import ActiveMessagesOnline from '../components/ActiveMessagesOnline' + +import {Column} from './Column' +import {CustomColumn} from './CustomColumn' +import ActiveMessagesOnline from './ActiveMessagesOnline' + +import LoaderPortal from '../../components/LoaderPortal' +import {UserOfWells} from './UserOfWells' +import {Subscribe} from '../../services/signalr' +import {DataService} from '../../services/api' +import {ModeDisplay} from "../../components/ModeDisplay" +import notify from "../../components/notify" + +import '../../styles/message.css' const {Option} = Select @@ -133,8 +135,7 @@ const timePeriodCollection = [ const defaultChartInterval = '600' -export default function TelemetryView(props) { - let {id} = useParams() +export default function TelemetryView({idWell}) { const [saubData, setSaubData] = useState([]) const [chartInterval, setChartInterval] = useState(defaultChartInterval) @@ -152,25 +153,25 @@ export default function TelemetryView(props) { const update = async () => { setLoader(true) try { - const data = await DataService.getData(id) + const data = await DataService.getData(idWell) handleReceiveDataSaub(data) } catch (ex) { - notify(`Не удалось получить данные по скважине "${id}"`, 'error') + notify(`Не удалось получить данные по скважине "${idWell}"`, 'error') console.log(ex) } setLoader(false) - return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) + return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleReceiveDataSaub) } update() - }, [id]) + }, [idWell]) useEffect(() => { setLoader(true) - DataService.getData(id, null, chartInterval) + DataService.getData(idWell, null, chartInterval) .then(handleReceiveDataSaub) .catch(error => console.error(error)) .finally(() => setLoader(false)) - }, [id, chartInterval]) + }, [idWell, chartInterval]) const colSpan = 24 / (paramsGroups.length) @@ -205,6 +206,6 @@ export default function TelemetryView(props) { - + ) } \ No newline at end of file diff --git a/src/pages/Well.jsx b/src/pages/Well.jsx index 588fb09..05f622d 100644 --- a/src/pages/Well.jsx +++ b/src/pages/Well.jsx @@ -6,7 +6,7 @@ import Messages from "../pages/Messages"; import Report from "../pages/Report"; import Analysis from "../pages/Analysis"; import WellAnalysis from "../pages/WellAnalysis"; -import TelemetryView from "../pages/TelemetryView"; +import TelemetryView from "./TelemetryView"; import MenuDocuments from "../components/MenuDocuments"; import WellStat from "./WellStat" import Smbo from "./Smbo" @@ -14,8 +14,8 @@ import Smbo from "./Smbo" const { Content } = Layout export default function Well() { - let { id } = useParams() - const rootPath = `/well/${id}` + let { id: idWell } = useParams() + const rootPath = `/well/${idWell}` const {SubMenu} = Menu @@ -87,7 +87,7 @@ export default function Well() { - + @@ -99,13 +99,13 @@ export default function Well() { - + - +