From 93b7196236bc013198450b7e5fe0c77b13eb080d Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 16:24:01 +0500 Subject: [PATCH] =?UTF-8?q?TelemetryView=20=D0=B8=20ActiveMessage=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D1=8B=20=D0=B2?= =?UTF-8?q?=20=D0=B0=D1=81=D0=B8=D0=BD=D1=85=D1=80=D0=BE=D0=BD=D0=BD=D1=83?= =?UTF-8?q?=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) => - + )}