grouping TelemetryView components

This commit is contained in:
Фролов 2021-08-12 17:47:16 +05:00
parent e391e6a470
commit a9a572d57f
11 changed files with 59 additions and 67 deletions

View File

@ -16,7 +16,7 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
}) })
useEffect(()=>{ useEffect(()=>{
if(value === undefined || value === null){ if(value === undefined || value === null || value === '-' || value === '--'){
setVal('---') setVal('---')
return return
} }
@ -41,10 +41,12 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
return return
} }
let valueDate = moment(value) if(value.length > 4){
if(valueDate.isValid()){ let valueDate = moment(value)
setVal(valueDate.format(format)) if(valueDate.isValid()){
return setVal(valueDate.format(format))
return
}
} }
setVal(value) setVal(value)

View File

@ -77,7 +77,7 @@ export const EditableTable = ({
...form.initialValues, ...form.initialValues,
key:newRowKeyValue key:newRowKeyValue
} }
const newData = [...data, newRow] const newData = [newRow, ...data]
setData(newData) setData(newData)
edit(newRow) edit(newRow)
} }

View File

@ -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 => <Display className='border_small display_flex_container user_card'
key={line.label}
label={line.label}
value={line.value}
suffix={line.units} />)}
</>)
}

View File

@ -1,7 +1,7 @@
import SmboPlate from '../components/SmboPlate' import SmboPlate from '../components/SmboPlate'
import '../styles/smbo.css' import '../styles/smbo.css'
import EquipmentDetails from '../components/modalWindows/EquipmentDetails' import EquipmentDetails from '../components/modalWindows/EquipmentDetails'
import ActiveMessagesOnline from "../components/ActiveMessagesOnline" import ActiveMessagesOnline from "./TelemetryView/ActiveMessagesOnline"
// import RigPlan from "../images/smbo/RigPlan2.png" // import RigPlan from "../images/smbo/RigPlan2.png"
const platesData = [ const platesData = [

View File

@ -1,11 +1,13 @@
import {useState, useEffect} from 'react' 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 {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 = { const categoryDictionary = {
@ -56,7 +58,7 @@ export default function ActiveMessagesOnline({idWell}) {
const update = async () => { const update = async () => {
setLoader(true) setLoader(true)
try { try {
const messages = await MessageService.getMessage(idWell) const messages = await MessageService.getMessages(idWell, 0, 4)
handleReceiveMessages(messages) handleReceiveMessages(messages)
} }
catch (ex) { catch (ex) {

View File

@ -1,4 +1,4 @@
import {ValueDisplay} from './Display' import {ValueDisplay} from '../../components/Display'
import {ControlOutlined} from '@ant-design/icons' import {ControlOutlined} from '@ant-design/icons'
import {Popover} from 'antd' import {Popover} from 'antd'

View File

@ -1,5 +1,5 @@
import {Display} from "./Display"; import {Display} from "../../components/Display";
import {ChartTimeOnline} from "./charts/ChartTimeOnline"; import {ChartTimeOnline} from "../../components/charts/ChartTimeOnline";
import {ChartTimeOnlineFooter} from "./ChartTimeOnlineFooter"; import {ChartTimeOnlineFooter} from "./ChartTimeOnlineFooter";
export const Column = ({lineGroup, data, interval, showBorder}) => { export const Column = ({lineGroup, data, interval, showBorder}) => {

View File

@ -1,5 +1,5 @@
import {Display} from './Display' import {Display} from '../../components/Display'
import RigMnemo from '../components/RigMnemo' import RigMnemo from '../../components/RigMnemo'
const params = [ const params = [
{label:'Рот., об/мин', accessorName:'rotorSpeed', isArrowVisible:true}, {label:'Рот., об/мин', accessorName:'rotorSpeed', isArrowVisible:true},

View File

@ -0,0 +1,9 @@
import { Display } from '../../components/Display'
export const UserOfWells = ({ data }) => {
const dataLast = data[data.length - 1]
return <Display className='border_small display_flex_container user_card'
label='Пользователь'
value={dataLast?.user}/>
}

View File

@ -1,16 +1,18 @@
import {useState, useEffect} from 'react' import {useState, useEffect} from 'react'
import {useParams} from 'react-router-dom'
import {Row, Col, Select} from 'antd' import {Row, Col, Select} from 'antd'
import LoaderPortal from '../components/LoaderPortal'
import {Column} from '../components/Column' import {Column} from './Column'
import {CustomColumn} from '../components/CustomColumn' import {CustomColumn} from './CustomColumn'
import {UserOfWells} from '../components/UserOfWells' import ActiveMessagesOnline from './ActiveMessagesOnline'
import {Subscribe} from '../services/signalr'
import {DataService} from '../services/api' import LoaderPortal from '../../components/LoaderPortal'
import '../styles/message.css' import {UserOfWells} from './UserOfWells'
import notify from "../components/notify" import {Subscribe} from '../../services/signalr'
import {ModeDisplay} from "../components/ModeDisplay" import {DataService} from '../../services/api'
import ActiveMessagesOnline from '../components/ActiveMessagesOnline' import {ModeDisplay} from "../../components/ModeDisplay"
import notify from "../../components/notify"
import '../../styles/message.css'
const {Option} = Select const {Option} = Select
@ -133,8 +135,7 @@ const timePeriodCollection = [
const defaultChartInterval = '600' const defaultChartInterval = '600'
export default function TelemetryView(props) { export default function TelemetryView({idWell}) {
let {id} = useParams()
const [saubData, setSaubData] = useState([]) const [saubData, setSaubData] = useState([])
const [chartInterval, setChartInterval] = useState(defaultChartInterval) const [chartInterval, setChartInterval] = useState(defaultChartInterval)
@ -152,25 +153,25 @@ export default function TelemetryView(props) {
const update = async () => { const update = async () => {
setLoader(true) setLoader(true)
try { try {
const data = await DataService.getData(id) const data = await DataService.getData(idWell)
handleReceiveDataSaub(data) handleReceiveDataSaub(data)
} catch (ex) { } catch (ex) {
notify(`Не удалось получить данные по скважине "${id}"`, 'error') notify(`Не удалось получить данные по скважине "${idWell}"`, 'error')
console.log(ex) console.log(ex)
} }
setLoader(false) setLoader(false)
return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleReceiveDataSaub)
} }
update() update()
}, [id]) }, [idWell])
useEffect(() => { useEffect(() => {
setLoader(true) setLoader(true)
DataService.getData(id, null, chartInterval) DataService.getData(idWell, null, chartInterval)
.then(handleReceiveDataSaub) .then(handleReceiveDataSaub)
.catch(error => console.error(error)) .catch(error => console.error(error))
.finally(() => setLoader(false)) .finally(() => setLoader(false))
}, [id, chartInterval]) }, [idWell, chartInterval])
const colSpan = 24 / (paramsGroups.length) const colSpan = 24 / (paramsGroups.length)
@ -205,6 +206,6 @@ export default function TelemetryView(props) {
</Row> </Row>
</Col> </Col>
</Row> </Row>
<ActiveMessagesOnline idWell={id}/> <ActiveMessagesOnline idWell={idWell}/>
</LoaderPortal>) </LoaderPortal>)
} }

View File

@ -6,7 +6,7 @@ import Messages from "../pages/Messages";
import Report from "../pages/Report"; import Report from "../pages/Report";
import Analysis from "../pages/Analysis"; import Analysis from "../pages/Analysis";
import WellAnalysis from "../pages/WellAnalysis"; import WellAnalysis from "../pages/WellAnalysis";
import TelemetryView from "../pages/TelemetryView"; import TelemetryView from "./TelemetryView";
import MenuDocuments from "../components/MenuDocuments"; import MenuDocuments from "../components/MenuDocuments";
import WellStat from "./WellStat" import WellStat from "./WellStat"
import Smbo from "./Smbo" import Smbo from "./Smbo"
@ -14,8 +14,8 @@ import Smbo from "./Smbo"
const { Content } = Layout const { Content } = Layout
export default function Well() { export default function Well() {
let { id } = useParams() let { id: idWell } = useParams()
const rootPath = `/well/${id}` const rootPath = `/well/${idWell}`
const {SubMenu} = Menu const {SubMenu} = Menu
@ -87,7 +87,7 @@ export default function Well() {
<Content className="site-layout-background"> <Content className="site-layout-background">
<Switch> <Switch>
<Route path="/well/:id/stat"> <Route path="/well/:id/stat">
<WellStat idWell={id}/> <WellStat idWell={idWell}/>
</Route> </Route>
<Route path="/well/:id/archive"> <Route path="/well/:id/archive">
<Archive/> <Archive/>
@ -99,13 +99,13 @@ export default function Well() {
<Report/> <Report/>
</Route> </Route>
<Route path="/well/:id/analysis"> <Route path="/well/:id/analysis">
<Analysis idWell={id}/> <Analysis idWell={idWell}/>
</Route> </Route>
<Route path="/well/:id/wellAnalysis"> <Route path="/well/:id/wellAnalysis">
<WellAnalysis/> <WellAnalysis/>
</Route> </Route>
<Route path="/well/:id/telemetry"> <Route path="/well/:id/telemetry">
<TelemetryView/> <TelemetryView idWell={idWell}/>
</Route> </Route>
<Route path="/well/:id/documents"> <Route path="/well/:id/documents">
<MenuDocuments/> <MenuDocuments/>