forked from ddrilling/asb_cloud_front
hotfix. CF2-75, CF2-76. Дубликация кода обработчиков устранена
This commit is contained in:
parent
f3c42568dc
commit
4c24bdf226
@ -179,25 +179,14 @@ export default function TelemetryView({idWell}) {
|
||||
|
||||
const options = timePeriodCollection.map((line) => <Option key={line.value}>{line.label}</Option>)
|
||||
|
||||
const handleDataSaub = (data) => {
|
||||
if (data) {
|
||||
const handleData = (state) => (data) => {
|
||||
if (data && state) {
|
||||
data.forEach((_, idx) => {
|
||||
if (data[idx].rotorSpeed < 1)
|
||||
data[idx].rotorSpeed = 0;
|
||||
data[idx].blockSpeed = Math.abs(data[idx].blockSpeed)
|
||||
})
|
||||
setDataSaub(data)
|
||||
}
|
||||
}
|
||||
|
||||
const handleDataSpin = (data) => {
|
||||
if (data) {
|
||||
data.forEach((_, idx) => {
|
||||
if (data[idx].rotorSpeed < 1)
|
||||
data[idx].rotorSpeed = 0;
|
||||
data[idx].blockSpeed = Math.abs(data[idx].blockSpeed)
|
||||
})
|
||||
setDataSpin(data)
|
||||
state(data)
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,14 +195,14 @@ export default function TelemetryView({idWell}) {
|
||||
async () => {
|
||||
const dataSaub = await TelemetryDataSaubService.getData(idWell, null, chartInterval)
|
||||
const dataSpin = await TelemetryDataSpinService.getData(idWell, null, chartInterval)
|
||||
handleDataSaub(dataSaub)
|
||||
handleDataSpin(dataSpin)
|
||||
handleData(setDataSaub)(dataSaub)
|
||||
handleData(setDataSpin)(dataSpin)
|
||||
},
|
||||
setShowLoader,
|
||||
`Не удалось получить данные по скважине "${idWell}"`,
|
||||
)
|
||||
const unsubscribeSaub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleDataSaub)
|
||||
const unsubscribeSpin = Subscribe('hubs/telemetry', 'ReceiveDataSpin', `well_${idWell}`, handleDataSpin)
|
||||
const unsubscribeSaub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleData(setDataSaub))
|
||||
const unsubscribeSpin = Subscribe('hubs/telemetry', 'ReceiveDataSpin', `well_${idWell}`, handleData(setDataSpin))
|
||||
return () => {
|
||||
unsubscribeSaub()
|
||||
unsubscribeSpin()
|
||||
|
Loading…
Reference in New Issue
Block a user