From dbfaadaf78ca2e90a541be7ea94418b3d7a5b1b0 Mon Sep 17 00:00:00 2001 From: Alexey Date: Wed, 28 Jul 2021 17:29:20 +0500 Subject: [PATCH 1/8] =?UTF-8?q?=D0=A1=D0=BE=20=D1=81=D1=82=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D1=8B=20TelemetryView=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BD=D0=B5=D1=81=D0=BD=D1=8B=20=D1=81=D0=BE=D0=BE=D0=B1?= =?UTF-8?q?=D1=89=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=BA=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ActiveMessagesOnline.jsx | 83 +++++++++++++++++ src/components/Column.jsx | 45 +++++++++ src/pages/TelemetryView.jsx | 116 ++---------------------- 3 files changed, 134 insertions(+), 110 deletions(-) create mode 100644 src/components/ActiveMessagesOnline.jsx create mode 100644 src/components/Column.jsx diff --git a/src/components/ActiveMessagesOnline.jsx b/src/components/ActiveMessagesOnline.jsx new file mode 100644 index 0000000..fb7a818 --- /dev/null +++ b/src/components/ActiveMessagesOnline.jsx @@ -0,0 +1,83 @@ +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" + +// Словарь категорий для строк таблицы +const categoryDictionary = { + 1: {title: 'Важное'}, + 2: {title: 'Предупреждение'}, + 3: {title: 'Информация'}, +} + +// Конфигурация таблицы +const columns = [ + { + title: 'Дата', + dataIndex: 'date', + render: (item) => moment(item).format('DD MMM YYYY, HH:MM:ss'), + sorter: (a, b) => new Date(b.date) - new Date(a.date), + sortDirections: ['descend', 'ascend'], + }, + { + title: 'Категория', + dataIndex: 'categoryId', + render: (_, item) => categoryDictionary[item.categoryId].title, + style: (_, item) => categoryDictionary[item.categoryId].style, + sorter: (a, b) => a.categoryId - b.categoryId, + sortDirections: ['descend', 'ascend'], + }, + { + title: 'Сообщение', + dataIndex: 'message', + onFilter: (value, record) => record.name.indexOf(value) === 0, + }, + { + title: 'Пользователь', + dataIndex: 'user', + }, +]; + +export default function ActiveMessagesOnline({idWell}) { + const [messages, setMessages] = useState([]) + const [loader, setLoader] = useState(false) + + const handleReceiveMessages = (messages) => { + if (messages) { + setMessages(messages.items.splice(0, 4)) + } + } + + useEffect(() => { + setLoader(true) + let promiseMessages = MessageService.getMessage(idWell) + .then(handleReceiveMessages) + .catch((ex) => { + notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error') + console.log(ex) + }) + + Promise.all([promiseMessages]).then(()=>setLoader(false)) + let unSubscribeMessagesHub = Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) + return () => { + unSubscribeMessagesHub() + } + }, [idWell]) + + return ( + `event_message_${record.categoryId} event_message`} + className={'message_table'} + size={'small'} + pagination={false} + rowKey={(record) => record.id} + /> + ) +} \ No newline at end of file diff --git a/src/components/Column.jsx b/src/components/Column.jsx new file mode 100644 index 0000000..19e5af3 --- /dev/null +++ b/src/components/Column.jsx @@ -0,0 +1,45 @@ +import {Display} from "./Display"; +import {ChartTimeOnline} from "./charts/ChartTimeOnline"; +import {ChartTimeOnlineFooter} from "./ChartTimeOnlineFooter"; + +export const Column = ({lineGroup, data, interval, showBorder}) => { + let lines = [lineGroup.linePv] + + if (lineGroup.lineSp) + lines.push(lineGroup.lineSp) + + if (lineGroup.lineOther) + lines.push(lineGroup.lineOther) + + if (lineGroup.lineAvg) + lines.push(lineGroup.lineAvg) + + if (lineGroup.lineMax) + lines.push(lineGroup.lineMax) + + let dataLast = null + let pv = null + if (data?.length > 0) { + dataLast = data[data.length - 1]; + if (lineGroup.linePv) + pv = dataLast[lineGroup.linePv?.xAccessorName] + } + + return ( + <> +
+ +
+ + + ) +} \ No newline at end of file diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView.jsx index e53d613..4423bd5 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView.jsx @@ -1,18 +1,16 @@ import {useState, useEffect} from 'react' import {useParams} from 'react-router-dom' import {Row, Col, Select, Table} from 'antd' -import {ChartTimeOnline} from '../components/charts/ChartTimeOnline' import LoaderPortal from '../components/LoaderPortal' -import {ChartTimeOnlineFooter} from '../components/ChartTimeOnlineFooter' +import { Column } from '../components/Column' import {CustomColumn} from '../components/CustomColumn' import {UserOfWells} from '../components/UserOfWells' -import {ModeDisplay} from '../components/ModeDisplay' -import {Display} from '../components/Display' -import moment from 'moment' import {Subscribe} from '../services/signalr' -import {DataService, MessageService} from '../services/api' +import {DataService} from '../services/api' import '../styles/message.css' import notify from "../components/notify" +import {ModeDisplay} from "../components/ModeDisplay" +import ActiveMessagesOnline from '../components/ActiveMessagesOnline' const {Option} = Select @@ -114,83 +112,6 @@ const rotorTorqueGroup = { const paramsGroups = [blockHeightGroup, blockSpeedGroup, pressureGroup, axialLoadGroup, hookWeightGroup, rotorTorqueGroup] -export const Column = ({lineGroup, data, interval, showBorder}) => { - let lines = [lineGroup.linePv] - - if (lineGroup.lineSp) - lines.push(lineGroup.lineSp) - - if (lineGroup.lineOther) - lines.push(lineGroup.lineOther) - - if (lineGroup.lineAvg) - lines.push(lineGroup.lineAvg) - - if (lineGroup.lineMax) - lines.push(lineGroup.lineMax) - - let dataLast = null - let pv = null - if (data?.length > 0) { - dataLast = data[data.length - 1]; - if (lineGroup.linePv) - pv = dataLast[lineGroup.linePv?.xAccessorName] - } - - return ( - <> -
- -
- - - ) -} - -// Словарь категорий для строк таблицы -const categoryDictionary = { - 1: {title: 'Важное'}, - 2: {title: 'Предупреждение'}, - 3: {title: 'Информация'}, -} - -// Конфигурация таблицы -const columns = [ - { - title: 'Дата', - dataIndex: 'date', - render: (item) => moment(item).format('DD MMM YYYY, HH:MM:ss'), - sorter: (a, b) => new Date(b.date) - new Date(a.date), - sortDirections: ['descend', 'ascend'], - }, - { - title: 'Категория', - dataIndex: 'categoryId', - render: (_, item) => categoryDictionary[item.categoryId].title, - style: (_, item) => categoryDictionary[item.categoryId].style, - sorter: (a, b) => a.categoryId - b.categoryId, - sortDirections: ['descend', 'ascend'], - }, - { - title: 'Сообщение', - dataIndex: 'message', - onFilter: (value, record) => record.name.indexOf(value) === 0, - }, - { - title: 'Пользователь', - dataIndex: 'user', - }, -]; - const timePeriodCollection = [ {value: '60', label: '1 минута'}, {value: '300', label: '5 минут'}, @@ -208,7 +129,6 @@ export default function TelemetryView(props) { let {id} = useParams() const [saubData, setSaubData] = useState([]) const [chartInterval, setChartInterval] = useState(defaultChartInterval) - const [messages, setMessages] = useState([]) const [loader, setLoader] = useState(false) @@ -220,12 +140,6 @@ export default function TelemetryView(props) { } } - const handleReceiveMessages = (messages) => { - if (messages) { - setMessages(messages.items.splice(0, 4)) - } - } - useEffect(() => { setLoader(true) let promiseData = DataService.getData(id) @@ -235,20 +149,11 @@ export default function TelemetryView(props) { console.log(ex) }) - let promiseMessages = MessageService.getMessage(id) - .then(handleReceiveMessages) - .catch((ex) => { - notify(`Не удалось загрузить сообщения по скважине "${id}"`, 'error') - console.log(ex) - }) - - Promise.all([promiseData, promiseMessages]).then(()=>setLoader(false)) + Promise.all([promiseData]).then(()=>setLoader(false)) let unSubscribeDataSaubHub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) - let unSubscribeMessagesHub = Subscribe('hubs/telemetry','ReceiveMessages', `well_${id}`, handleReceiveMessages) return () => { unSubscribeDataSaubHub() - unSubscribeMessagesHub() } }, [id]); @@ -292,15 +197,6 @@ export default function TelemetryView(props) { -
`event_message_${record.categoryId} event_message`} - className={'message_table'} - size={'small'} - pagination={false} - rowKey={(record) => record.id} - /> + ) } \ No newline at end of file From 611244edeeafb41fc0dab0a46c938f4b6cfb3a7c 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, 29 Jul 2021 11:22:25 +0500 Subject: [PATCH 2/8] Add components factory --- src/components/factory.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/components/factory.js diff --git a/src/components/factory.js b/src/components/factory.js new file mode 100644 index 0000000..06269a0 --- /dev/null +++ b/src/components/factory.js @@ -0,0 +1,26 @@ +export const makeColumn = (title, key, other) => ({ + title: title, + key: key, + dataIndex: key, + ...other, +}); + +export const makeColumnsPlanFact = (title, keyPlan, keyFact, gruopOther) => +{ + let keyPlanLocal = keyPlan + let keyFactLocal = keyFact + + if(!keyFact){ + keyPlanLocal = keyPlan + 'Plan' + keyFactLocal = keyPlan + 'Fact' + } + + return { + title: title, + ...gruopOther, + children: [ + makeColumn('план', keyPlanLocal), + makeColumn('факт', keyFactLocal), + ] + } +} \ No newline at end of file From a799904c5ef4a5518da33d71be92c83cb0b4e794 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, 29 Jul 2021 11:38:09 +0500 Subject: [PATCH 3/8] Add components factory --- src/components/{factory.js => factory.ts} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/components/{factory.js => factory.ts} (63%) diff --git a/src/components/factory.js b/src/components/factory.ts similarity index 63% rename from src/components/factory.js rename to src/components/factory.ts index 06269a0..c4a2baf 100644 --- a/src/components/factory.js +++ b/src/components/factory.ts @@ -1,14 +1,14 @@ -export const makeColumn = (title, key, other) => ({ +export const makeColumn = (title:string, key:string, other?:any) => ({ title: title, key: key, dataIndex: key, ...other, }); -export const makeColumnsPlanFact = (title, keyPlan, keyFact, gruopOther) => +export const makeColumnsPlanFact = (title:string, keyPlan:string, keyFact?:string, gruopOther?:any) => { let keyPlanLocal = keyPlan - let keyFactLocal = keyFact + let keyFactLocal = keyFact ?? '' if(!keyFact){ keyPlanLocal = keyPlan + 'Plan' From a07e46ce6c020c1a63140866000694f9cc9c28f1 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 15:15:09 +0500 Subject: [PATCH 4/8] =?UTF-8?q?=D1=83=D0=B1=D1=80=D0=B0=D0=BB=20=D1=82?= =?UTF-8?q?=D0=BE=D1=87=D0=BA=D1=83=20=D1=81=20=D0=B7=D0=B0=D0=BF=D1=8F?= =?UTF-8?q?=D1=82=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/factory.ts | 2 +- src/pages/TelemetryView.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/factory.ts b/src/components/factory.ts index c4a2baf..413f525 100644 --- a/src/components/factory.ts +++ b/src/components/factory.ts @@ -3,7 +3,7 @@ export const makeColumn = (title:string, key:string, other?:any) => ({ key: key, dataIndex: key, ...other, -}); +}) export const makeColumnsPlanFact = (title:string, keyPlan:string, keyFact?:string, gruopOther?:any) => { diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView.jsx index 4423bd5..193916a 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView.jsx @@ -1,6 +1,6 @@ import {useState, useEffect} from 'react' import {useParams} from 'react-router-dom' -import {Row, Col, Select, Table} from 'antd' +import {Row, Col, Select} from 'antd' import LoaderPortal from '../components/LoaderPortal' import { Column } from '../components/Column' import {CustomColumn} from '../components/CustomColumn' From 0ddbc659aff166a1b004d1a1e9616d7ec5c1f384 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 15:17:54 +0500 Subject: [PATCH 5/8] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=80=D1=84=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/factory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/factory.ts b/src/components/factory.ts index 413f525..e53dbaa 100644 --- a/src/components/factory.ts +++ b/src/components/factory.ts @@ -5,7 +5,7 @@ export const makeColumn = (title:string, key:string, other?:any) => ({ ...other, }) -export const makeColumnsPlanFact = (title:string, keyPlan:string, keyFact?:string, gruopOther?:any) => +export const makeColumnsPlanFact = (title:string, keyPlan:string, keyFact?:string, groupOther?:any) => { let keyPlanLocal = keyPlan let keyFactLocal = keyFact ?? '' @@ -17,7 +17,7 @@ export const makeColumnsPlanFact = (title:string, keyPlan:string, keyFact?:strin return { title: title, - ...gruopOther, + ...groupOther, children: [ makeColumn('план', keyPlanLocal), makeColumn('факт', keyFactLocal), From e350c4e4cd58054380c278604d4912e326e10f6d Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 15:23:22 +0500 Subject: [PATCH 6/8] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BE=D1=80=D1=84=D0=BE=D0=B3=D1=80=D0=B0?= =?UTF-8?q?=D1=84=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B0=D1=8F=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Well.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/Well.jsx b/src/pages/Well.jsx index 60184b6..4928fe1 100644 --- a/src/pages/Well.jsx +++ b/src/pages/Well.jsx @@ -8,6 +8,7 @@ import Analysis from "../pages/Analysis"; import WellAnalysis from "../pages/WellAnalysis"; import TelemetryView from "../pages/TelemetryView"; import WellStat from "./WellStat"; +import MenuDocuments from "../components/MenuDocuments"; const { Content } = Layout From c5abb21e6d548fdec2e8e5f8c7c038e4e5455372 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 15:46:59 +0500 Subject: [PATCH 7/8] =?UTF-8?q?setLoader(false)=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D1=91=D0=BD=20=D0=B2=20=D0=B2=D1=8B=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=20=D1=83=20=D0=BF=D1=80=D0=BE=D0=BC=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20ActiveMessage=20=D0=B8=20Telemetr?= =?UTF-8?q?yView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ActiveMessagesOnline.jsx | 9 +++------ src/pages/TelemetryView.jsx | 14 +++++--------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/ActiveMessagesOnline.jsx b/src/components/ActiveMessagesOnline.jsx index fb7a818..768ba34 100644 --- a/src/components/ActiveMessagesOnline.jsx +++ b/src/components/ActiveMessagesOnline.jsx @@ -54,18 +54,15 @@ export default function ActiveMessagesOnline({idWell}) { useEffect(() => { setLoader(true) - let promiseMessages = MessageService.getMessage(idWell) + MessageService.getMessage(idWell) .then(handleReceiveMessages) .catch((ex) => { notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error') console.log(ex) }) + .finally(()=>setLoader(false)) - Promise.all([promiseMessages]).then(()=>setLoader(false)) - let unSubscribeMessagesHub = Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) - return () => { - unSubscribeMessagesHub() - } + return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) }, [idWell]) return ( diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView.jsx index 193916a..bccc918 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView.jsx @@ -142,20 +142,16 @@ export default function TelemetryView(props) { useEffect(() => { setLoader(true) - let promiseData = DataService.getData(id) + DataService.getData(id) .then(handleReceiveDataSaub) .catch((ex) => { notify(`Не удалось загрузить данные по скважине "${id}"`, 'error') console.log(ex) }) + .finally(()=>setLoader(false)) - Promise.all([promiseData]).then(()=>setLoader(false)) - - let unSubscribeDataSaubHub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) - return () => { - unSubscribeDataSaubHub() - } - }, [id]); + return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) + }, [id]) useEffect(() => { setLoader(true) @@ -163,7 +159,7 @@ export default function TelemetryView(props) { .then(handleReceiveDataSaub) .catch(error => console.error(error)) .finally(()=>setLoader(false)) - }, [id, chartInterval]); + }, [id, chartInterval]) const colSpan = 24 / (paramsGroups.length) From 93b7196236bc013198450b7e5fe0c77b13eb080d Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 16:24:01 +0500 Subject: [PATCH 8/8] =?UTF-8?q?TelemetryView=20=D0=B8=20ActiveMessage=20?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=B2=20=D0=B0=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=BD?= =?UTF-8?q?=D1=83=D1=8E=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ActiveMessagesOnline.jsx | 20 ++++++++----- src/pages/Deposit.jsx | 4 +-- src/pages/TelemetryView.jsx | 40 ++++++++++++++++--------- 3 files changed, 40 insertions(+), 24 deletions(-) diff --git a/src/components/ActiveMessagesOnline.jsx b/src/components/ActiveMessagesOnline.jsx index 768ba34..6b33a61 100644 --- a/src/components/ActiveMessagesOnline.jsx +++ b/src/components/ActiveMessagesOnline.jsx @@ -53,16 +53,20 @@ export default function ActiveMessagesOnline({idWell}) { } useEffect(() => { - setLoader(true) - MessageService.getMessage(idWell) - .then(handleReceiveMessages) - .catch((ex) => { + const update = async () => { + setLoader(true) + try { + const messages = await MessageService.getMessage(idWell) + handleReceiveMessages(messages) + } + catch (ex) { notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error') console.log(ex) - }) - .finally(()=>setLoader(false)) - - return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) + } + setLoader(false) + return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) + } + update() }, [idWell]) return ( diff --git a/src/pages/Deposit.jsx b/src/pages/Deposit.jsx index 26818fb..d79b3e2 100644 --- a/src/pages/Deposit.jsx +++ b/src/pages/Deposit.jsx @@ -31,7 +31,7 @@ export default function Deposit() { const [showLoader, setShowLoader] = useState(false) useEffect(()=>{ - const updateClusters = async()=>{ + const update = async()=>{ setShowLoader(true) try{ const data = await ClusterService.getClusters() @@ -43,7 +43,7 @@ export default function Deposit() { } setShowLoader(false) } - updateClusters() + update() }, []) const viewParams = calcViewParams(clustersData) diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView.jsx index bccc918..0492c36 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView.jsx @@ -2,7 +2,7 @@ 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 {Column} from '../components/Column' import {CustomColumn} from '../components/CustomColumn' import {UserOfWells} from '../components/UserOfWells' import {Subscribe} from '../services/signalr' @@ -19,8 +19,16 @@ const dash = [7, 3] const blockHeightGroup = { label: "Высота блока", yDisplay: false, - linePv: { label: "blockPosition", units: 'м', xAccessorName: "blockPosition", yAccessorName: "date", color: '#333' }, - lineOther: { label: "wellDepth", units: 'м', xAccessorName: "wellDepth", yAccessorName: "date", color: '#333', showLine: false, xConstValue:30 }, + linePv: {label: "blockPosition", units: 'м', xAccessorName: "blockPosition", yAccessorName: "date", color: '#333'}, + lineOther: { + label: "wellDepth", + units: 'м', + xAccessorName: "wellDepth", + yAccessorName: "date", + color: '#333', + showLine: false, + xConstValue: 30 + }, } const blockSpeedGroup = { @@ -141,16 +149,19 @@ export default function TelemetryView(props) { } useEffect(() => { - setLoader(true) - DataService.getData(id) - .then(handleReceiveDataSaub) - .catch((ex) => { - notify(`Не удалось загрузить данные по скважине "${id}"`, 'error') + const update = async () => { + setLoader(true) + try { + const data = await DataService.getData(id) + handleReceiveDataSaub(data) + } catch (ex) { + notify(`Не удалось получить данные по скважине "${id}"`, 'error') console.log(ex) - }) - .finally(()=>setLoader(false)) - - return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) + } + setLoader(false) + return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) + } + update() }, [id]) useEffect(() => { @@ -158,7 +169,7 @@ export default function TelemetryView(props) { DataService.getData(id, null, chartInterval) .then(handleReceiveDataSaub) .catch(error => console.error(error)) - .finally(()=>setLoader(false)) + .finally(() => setLoader(false)) }, [id, chartInterval]) const colSpan = 24 / (paramsGroups.length) @@ -188,7 +199,8 @@ export default function TelemetryView(props) { {paramsGroups.map((group, index) => - + )}