TelemetryView и ActiveMessage переписаны в асинхронную функцию

This commit is contained in:
Alexey 2021-07-29 16:24:01 +05:00
parent c5abb21e6d
commit 93b7196236
3 changed files with 40 additions and 24 deletions

View File

@ -53,16 +53,20 @@ export default function ActiveMessagesOnline({idWell}) {
}
useEffect(() => {
const update = async () => {
setLoader(true)
MessageService.getMessage(idWell)
.then(handleReceiveMessages)
.catch((ex) => {
try {
const messages = await MessageService.getMessage(idWell)
handleReceiveMessages(messages)
}
catch (ex) {
notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error')
console.log(ex)
})
.finally(()=>setLoader(false))
}
setLoader(false)
return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages)
}
update()
}, [idWell])
return (<LoaderPortal show={loader}>

View File

@ -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)

View File

@ -20,7 +20,15 @@ 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 },
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(() => {
const update = async () => {
setLoader(true)
DataService.getData(id)
.then(handleReceiveDataSaub)
.catch((ex) => {
notify(`Не удалось загрузить данные по скважине "${id}"`, 'error')
try {
const data = await DataService.getData(id)
handleReceiveDataSaub(data)
} catch (ex) {
notify(`Не удалось получить данные по скважине "${id}"`, 'error')
console.log(ex)
})
.finally(()=>setLoader(false))
}
setLoader(false)
return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub)
}
update()
}, [id])
useEffect(() => {
@ -188,7 +199,8 @@ export default function TelemetryView(props) {
<Row>
{paramsGroups.map((group, index) =>
<Col span={colSpan} className='border_small' key={group.label}>
<Column data={saubData} lineGroup={group} interval={chartInterval} showBorder = {saubData[saubData.length - 1]?.drillingBy === index}/>
<Column data={saubData} lineGroup={group} interval={chartInterval}
showBorder={saubData[saubData.length - 1]?.drillingBy === index}/>
</Col>)}
</Row>
</Col>