diff --git a/src/components/charts/ChartDepthToInterval.jsx b/src/components/charts/ChartTelemetryDepthToInterval.jsx similarity index 95% rename from src/components/charts/ChartDepthToInterval.jsx rename to src/components/charts/ChartTelemetryDepthToInterval.jsx index 218ce1b..eb12469 100644 --- a/src/components/charts/ChartDepthToInterval.jsx +++ b/src/components/charts/ChartTelemetryDepthToInterval.jsx @@ -22,7 +22,7 @@ const defaultOptions = { } } -export const ChartDepthToInterval = ({ depthToIntervalData }) => { +export const ChartTelemetryDepthToInterval = ({ depthToIntervalData }) => { const chartRef = useRef(null) const [chart, setChart] = useState() diff --git a/src/components/charts/ChartTelemetryOperationsSummary.jsx b/src/components/charts/ChartTelemetryOperationsSummary.jsx new file mode 100644 index 0000000..73f86f7 --- /dev/null +++ b/src/components/charts/ChartTelemetryOperationsSummary.jsx @@ -0,0 +1,64 @@ +import { useEffect, useRef, useState } from 'react' +import { Chart, registerables } from 'chart.js'; + +Chart.register(...registerables); + +const defaultOptions = { + responsive: true, + aspectRatio: 2.8 +} + +const secondsToTimeString = (seconds) => { + if(seconds < 60) + return seconds + ' сек.' + else if (seconds < 3600) + return Math.floor(3600 / seconds) + ' мин.' + (3600 % seconds).toFixed(2) + ' сек.' +} + +export const ChartTelemetryOperationsSummary = ({ operationsData }) => { + const chartRef = useRef(null) + const [chart, setChart] = useState() + + useEffect(() => { + + const namesData = operationsData?.map(el => el.operationName) ?? ['Нет операций'] + const durationsData = operationsData?.map(el => el.duration) ?? [1] + + let chartPartsColors = [ + '#54a60c', '#0ca68a', '#0c8aa6', '#0c57a6', '#0c33a6', + '#6f10d5', '#d510a1', '#f1bc41', '#c5f141', '#41f196', + '#41cbf1', '#4196f1', '#bf41f1', '#41f1c5', '#cbf141', + '#f1ce41', '#f17f41', '#f14141', '#34b40e', '#420eb4' + ] + + let data = { + labels: namesData, + datasets: [ + { + label: 'Скорость проходки за интервал', + data: durationsData, + borderColor: chartPartsColors, + backgroundColor: chartPartsColors, + } + ] + } + + let thisOptions = {} + Object.assign(thisOptions, defaultOptions) + + if ((chartRef.current) && (!chart)) { + let newChart = new Chart(chartRef.current, { + type: 'doughnut', + options: thisOptions, + data: data + }) + setChart(newChart) + } else { + chart.data = data + chart.options = thisOptions + chart.update() + } + }, [chart, operationsData]) + + return () +} \ No newline at end of file diff --git a/src/pages/TelemetryAnalysis/OperationsSummary.jsx b/src/pages/TelemetryAnalysis/OperationsSummary.jsx deleted file mode 100644 index a4b57d6..0000000 --- a/src/pages/TelemetryAnalysis/OperationsSummary.jsx +++ /dev/null @@ -1,6 +0,0 @@ - - -export default function OperationsSummary({idWell}){ - - return (<>123) -} \ No newline at end of file diff --git a/src/pages/TelemetryAnalysis/OperationsToInterval.jsx b/src/pages/TelemetryAnalysis/OperationsToInterval.jsx deleted file mode 100644 index 22815d4..0000000 --- a/src/pages/TelemetryAnalysis/OperationsToInterval.jsx +++ /dev/null @@ -1,6 +0,0 @@ - - -export default function OperationsToInterval({idWell}){ - - return (<>123) -} \ No newline at end of file diff --git a/src/pages/TelemetryAnalysis/TelemetryAnalysisDepthToInterval.jsx b/src/pages/TelemetryAnalysis/TelemetryAnalysisDepthToInterval.jsx index 27f68a1..56ce1e8 100644 --- a/src/pages/TelemetryAnalysis/TelemetryAnalysisDepthToInterval.jsx +++ b/src/pages/TelemetryAnalysis/TelemetryAnalysisDepthToInterval.jsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react' import { TelemetryAnalyticsService } from '../../services/api' import { invokeWebApiWrapperAsync } from '../../components/factory' -import { ChartDepthToInterval } from '../../components/charts/ChartDepthToInterval' +import { ChartTelemetryDepthToInterval } from '../../components/charts/ChartTelemetryDepthToInterval' import { Select } from 'antd' import LoaderPortal from '../../components/LoaderPortal' @@ -49,7 +49,7 @@ export default function TelemetryAnalysisDepthToInterval({idWell}) { > {children} - diff --git a/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx b/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx new file mode 100644 index 0000000..64c4863 --- /dev/null +++ b/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsSummary.jsx @@ -0,0 +1,70 @@ +import { ChartTelemetryOperationsSummary } from '../../components/charts/ChartTelemetryOperationsSummary' +import { useState, useEffect } from 'react' +import moment from "moment" +import { invokeWebApiWrapperAsync } from '../../components/factory' +import { TelemetryAnalyticsService } from '../../services/api' +import { Form, DatePicker } from "antd" +import LoaderPortal from '../../components/LoaderPortal' + +const { RangePicker } = DatePicker + +export default function TelemetryAnalysisOperationsSummary({idWell}){ + const [avilableDatesRange, setAviableDatesRange] = useState([moment(),moment()]) + const [filterDateRange, setFilterDateRange] = useState([moment().subtract(1, "days"),moment()]) + const [operationsData, setOperationsData] = useState([]) + const [loader, setLoader] = useState(false) + + const disabledDate = (current) => + current < avilableDatesRange[0] || current > avilableDatesRange[1] + + useEffect(() => invokeWebApiWrapperAsync(async() => { + const datesRange = await TelemetryAnalyticsService.getOperationsDateRange(idWell) + setAviableDatesRange(datesRange) + }), [idWell]) + + useEffect(() => { + setLoader(true) + invokeWebApiWrapperAsync( + async () => { + const operationsSummaryData = await TelemetryAnalyticsService.getOperationsSummary(idWell, + filterDateRange[0].toISOString(), filterDateRange[1].toISOString()) + + setOperationsData(operationsSummaryData) + }, + setLoader, + `Не удалось получить данные для анализа операций по скважине "${idWell}"`) + }, [idWell, filterDateRange]) + + return ( + +
+
+
+ + { + setFilterDateRange(dates) + }} + showTime + /> + +
+
+
+ +
+ ) +} \ No newline at end of file diff --git a/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsToInterval.jsx b/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsToInterval.jsx new file mode 100644 index 0000000..cb5d16e --- /dev/null +++ b/src/pages/TelemetryAnalysis/TelemetryAnalysisOperationsToInterval.jsx @@ -0,0 +1,6 @@ + + +export default function TelemetryAnalysisOperationsToInterval({idWell}){ + + return (<>123) +} \ No newline at end of file diff --git a/src/pages/TelemetryAnalysis/index.jsx b/src/pages/TelemetryAnalysis/index.jsx index eca3d81..7d07a6e 100644 --- a/src/pages/TelemetryAnalysis/index.jsx +++ b/src/pages/TelemetryAnalysis/index.jsx @@ -1,8 +1,8 @@ import {Layout, Menu} from "antd"; import {Switch, Link, Route, useParams} from "react-router-dom"; import { FolderOutlined } from "@ant-design/icons"; -import OperationsSummary from "./OperationsSummary"; -import OperationsToInterval from "./OperationsToInterval"; +import TelemetryAnalysisOperationsSummary from "./TelemetryAnalysisOperationsSummary"; +import TelemetryAnalysisOperationsToInterval from "./TelemetryAnalysisOperationsToInterval"; import TelemetryAnalysisDepthToDay from './TelemetryAnalysisDepthToDay' import TelemetryAnalysisDepthToInterval from './TelemetryAnalysisDepthToInterval' @@ -41,10 +41,10 @@ export default function TelemetryAnalysis({idWell}) { - + - +