From 5755b41abc2415d5e0655879fa6c471b25d28ec2 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Mon, 4 Oct 2021 18:06:42 +0500 Subject: [PATCH 01/23] CF2-49: Main changes for new Measures table display --- src/pages/Measure/MeasureTable2.jsx | 73 +++++++++++++++++--------- src/pages/Measure/View.jsx | 47 +++++++++-------- src/pages/Measure/columnsMudDiagram.js | 42 ++++++--------- src/pages/Measure/index.jsx | 69 ++++++++++++++++++------ src/styles/index.css | 4 ++ src/styles/measure.css | 32 +++++++++++ 6 files changed, 176 insertions(+), 91 deletions(-) create mode 100644 src/styles/measure.css diff --git a/src/pages/Measure/MeasureTable2.jsx b/src/pages/Measure/MeasureTable2.jsx index 621e711..f543a2d 100644 --- a/src/pages/Measure/MeasureTable2.jsx +++ b/src/pages/Measure/MeasureTable2.jsx @@ -7,16 +7,17 @@ import { invokeWebApiWrapperAsync } from '../../components/factory' import { MeasureService } from '../../services/api' import { Editor } from './Editor' import TimelineItem from 'antd/lib/timeline/TimelineItem' -//import { View } from './View' +import { View } from './View' +import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable2 = ({idWell, idCategory, title, columns}) => { +export const MeasureTable2 = ({idWell, idCategory, title, columns, currentValues}) => { const [showLoader, setShowLoader] = useState(false) const [showEditor, setShowEditor] = useState(false) const [history, setHistory] = useState([]) - const update = () => invokeWebApiWrapperAsync(async()=>{ + const updateHistory = () => invokeWebApiWrapperAsync(async()=>{ const data = await MeasureService.getHisory(idWell, idCategory) const story = data?.map( i=> ({ id: i.id, @@ -27,23 +28,41 @@ export const MeasureTable2 = ({idWell, idCategory, title, columns}) => { setHistory(story??[]) } , setShowLoader - , "не удалось загрузить") + , `Не удалось загрузить последние данные по скважине ${idWell}`) - useEffect(update, [idWell, idCategory]) + useEffect(updateHistory, [idWell, idCategory]) - return -

{title}

-   - - - {history.map(item=>{item.timestamp})} - - {/* */} - + +   +

{title}

+   +
+
+ + {history.map((item, index)=> + setShowEditor(true)} + value={item} + > +

{item.timestamp}

+
)} +
+
+
+ +
+
+ { onCancel={() => setShowEditor(false)} width="95%" footer={null} - > - - -
+ > + +
+
+ } \ No newline at end of file diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index ca3e838..7c19ec3 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -9,30 +9,35 @@ export const View = ({columns, item}) => { const viewItems = columns.map( (column, i) => { const row = Math.floor(i / colsCount) + 1 const colb = i % colsCount + return <> - - {column.title} - - - - {column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]} - + {column.title} + + + {column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]} + }) - return - {viewItems} - + return <> + + {viewItems} + + } \ No newline at end of file diff --git a/src/pages/Measure/columnsMudDiagram.js b/src/pages/Measure/columnsMudDiagram.js index 5a82670..c759786 100644 --- a/src/pages/Measure/columnsMudDiagram.js +++ b/src/pages/Measure/columnsMudDiagram.js @@ -4,36 +4,24 @@ import {v, numericColumnOptions, textColumnOptions} from './columnsCommon' export const columnsMudDiagram = [ makeColumn(v('N пробы'), 'probeNumber', numericColumnOptions), makeColumn(v('Глубина отбора пробы'), 'probeExtractionDepth', numericColumnOptions), - { - title: 'Литология', - key: 'lithology', - children: [ - makeColumn(v('Песчаник (%)'), 'sandstone', numericColumnOptions), - makeColumn(v('Алевролит (%)'), 'siltstone', numericColumnOptions), - makeColumn(v('Аргиллит (%)'), 'argillit', numericColumnOptions), - makeColumn(v('Аргиллит бит. (%)'), 'brokenArgillit', numericColumnOptions), - makeColumn(v('Уголь (%)'), 'coal', numericColumnOptions), - makeColumn(v('Песок (%)'), 'sand', numericColumnOptions), - makeColumn(v('Глина (%)'), 'clay', numericColumnOptions), - makeColumn(v('Известняк (%)'), 'camstone', numericColumnOptions), - makeColumn(v('Цемент (%)'), 'cement', numericColumnOptions), - ] - }, + makeColumn(v('Песчаник (%)'), 'sandstone', numericColumnOptions), + makeColumn(v('Алевролит (%)'), 'siltstone', numericColumnOptions), + makeColumn(v('Аргиллит (%)'), 'argillit', numericColumnOptions), + makeColumn(v('Аргиллит бит. (%)'), 'brokenArgillit', numericColumnOptions), + makeColumn(v('Уголь (%)'), 'coal', numericColumnOptions), + makeColumn(v('Песок (%)'), 'sand', numericColumnOptions), + makeColumn(v('Глина (%)'), 'clay', numericColumnOptions), + makeColumn(v('Известняк (%)'), 'camstone', numericColumnOptions), + makeColumn(v('Цемент (%)'), 'cement', numericColumnOptions), makeColumn('Краткое описание', 'summary', textColumnOptions), makeColumn(v('ЛБА бурового раствора'), 'drillingMud', numericColumnOptions), makeColumn(v('ЛБА (шлама)'), 'sludge', numericColumnOptions), - { - title: 'Газопоказания', - key: 'gasIndications', - children: [ - makeColumn(v('Сумма УВ мах. (абс%)'), 'maxSum', numericColumnOptions), - makeColumn(v('С1 метан (отн%)'), 'methane', numericColumnOptions), - makeColumn(v('С2 этан (отн%)'), 'ethane', numericColumnOptions), - makeColumn(v('С3 пропан (отн%)'), 'propane', numericColumnOptions), - makeColumn(v('С4 бутан (отн%)'), 'butane', numericColumnOptions), - makeColumn(v('С5 пентан (отн%)'), 'pentane', numericColumnOptions), - ] - }, + makeColumn(v('Сумма УВ мах. (абс%)'), 'maxSum', numericColumnOptions), + makeColumn(v('С1 метан (отн%)'), 'methane', numericColumnOptions), + makeColumn(v('С2 этан (отн%)'), 'ethane', numericColumnOptions), + makeColumn(v('С3 пропан (отн%)'), 'propane', numericColumnOptions), + makeColumn(v('С4 бутан (отн%)'), 'butane', numericColumnOptions), + makeColumn(v('С5 пентан (отн%)'), 'pentane', numericColumnOptions), makeColumn(v('Мех. скорость'), 'mechanicalSpeed', numericColumnOptions), makeColumn('Предварительное заключение о насыщении по ГК', 'preliminaryConclusion', textColumnOptions), ] \ No newline at end of file diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index 105926c..129b78d 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -1,25 +1,60 @@ +import { useState, useEffect } from 'react' import { columnsMudDiagram} from './columnsMudDiagram' import { columnsDrillingFluid} from './columnsDrillingFluid' +import { invokeWebApiWrapperAsync } from '../../components/factory' +import { MeasureService } from '../../services/api' import { columnsNnb } from './columnsNnb' -import { MeasureTable } from './MeasureTable' -//import { MeasureTable2 } from './MeasureTable2' +import LoaderPortal from '../../components/LoaderPortal' +//import moment from 'moment' +//import { MeasureTable } from './MeasureTable' +import { MeasureTable2 } from './MeasureTable2' + +const format='YYYY.MM.DD HH:mm' export default function Measure({idWell}){ + const [showLoader, setShowLoader] = useState(false) + const [currentFluidValues, setCurrentFluidValues] = useState([]) + const [currentMudValues, setCurrentMudValues] = useState([]) + const [currentNnbValues, setCurrentNnbValues] = useState([]) + + const updateCurrentValues = () => invokeWebApiWrapperAsync(async()=>{ + const data = await MeasureService.getAllLast(idWell) + + const fluidValues = data?.find(value => value.idCategory === 1) + setCurrentFluidValues(fluidValues ?? []) + const mudValues = data?.find(value => value.idCategory === 2) + setCurrentMudValues(mudValues ?? []) + const nnbValues = data?.find(value => value.idCategory === 3) + setCurrentNnbValues(nnbValues ?? []) + } + ,setShowLoader + ,`Не удалось загрузить последние данные по скважине ${idWell}`) + + useEffect(updateCurrentValues, [idWell]) + return <> - - - + + + + + } \ No newline at end of file diff --git a/src/styles/index.css b/src/styles/index.css index ae77b2e..bf9acb7 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -19,6 +19,10 @@ body { display: none; } +.w-15 { + width: 15% +} + .w-100 { width: 100% } diff --git a/src/styles/measure.css b/src/styles/measure.css new file mode 100644 index 0000000..77824cc --- /dev/null +++ b/src/styles/measure.css @@ -0,0 +1,32 @@ +.measure-dates { + width: 15%; + overflow-y: scroll; +} + +.measure-button { + display: flex; + margin-top: 8px; + width: 95%; + height: 30px; + border: 1px solid black; + border-radius: 5px; +} + +.measure-button:hover { + cursor: pointer; +} + +.last-measure-button { + display: flex; + margin-top: 8px; + background-color: #DCDCDC; + width: 95%; + height: 30px; + border: 1px solid black; + border-radius: 5px; +} + +.last-measure-button:hover { + cursor: pointer; + background-color: #D3D3D3; +} \ No newline at end of file From fa78376c2ada021bc87495467ca461a1874c76a6 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Tue, 5 Oct 2021 14:57:56 +0500 Subject: [PATCH 02/23] CF2-49: Fixed Measures appearence. Added switch values by history. --- src/pages/Measure/MeasureTable2.jsx | 110 +++++++++++----------------- src/pages/Measure/View.jsx | 18 ++--- src/pages/Measure/index.jsx | 48 ++++++------ src/styles/index.css | 12 +++ src/styles/measure.css | 25 +------ 5 files changed, 91 insertions(+), 122 deletions(-) diff --git a/src/pages/Measure/MeasureTable2.jsx b/src/pages/Measure/MeasureTable2.jsx index f543a2d..5c6a04a 100644 --- a/src/pages/Measure/MeasureTable2.jsx +++ b/src/pages/Measure/MeasureTable2.jsx @@ -1,83 +1,59 @@ -import { useState, useEffect } from 'react' -import { Button, Modal, Timeline } from 'antd' +import { useState, useEffect } from "react" +import { Button, Timeline } from 'antd' import moment from 'moment' -import { HourglassOutlined } from '@ant-design/icons' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { MeasureService } from '../../services/api' -import { Editor } from './Editor' -import TimelineItem from 'antd/lib/timeline/TimelineItem' +import { ClockCircleOutlined } from '@ant-design/icons' import { View } from './View' +import '../../styles/index.css' import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable2 = ({idWell, idCategory, title, columns, currentValues}) => { - const [showLoader, setShowLoader] = useState(false) - const [showEditor, setShowEditor] = useState(false) - const [history, setHistory] = useState([]) +export const MeasureTable2 = ({title, columns, values}) => { + var defaultDisplay = values && values.length > 1 + ? values[values.length-1] + : [] - const updateHistory = () => invokeWebApiWrapperAsync(async()=>{ - const data = await MeasureService.getHisory(idWell, idCategory) - const story = data?.map( i=> ({ - id: i.id, - idWell: i.idWell, - idCategory: i.idCategory, - timestamp: moment.utc(i.timestamp).local().format(format), - ...i.data})) - setHistory(story??[]) - } - , setShowLoader - , `Не удалось загрузить последние данные по скважине ${idWell}`) + const [displayedValues, setDisplayedValues] = useState([]); - useEffect(updateHistory, [idWell, idCategory]) - - const lastHistoryIndex = history.length + useEffect(() => { + setDisplayedValues(defaultDisplay) + }, [defaultDisplay]) return <> - -   -

{title}

-   -
-
- - {history.map((item, index)=> - setShowEditor(true)} - value={item} - > -

{item.timestamp}

-
)} +   +

{title}

+   +
+
+
+ + + +
+
+ + {values.map((item, index) => + setDisplayedValues(values.find(el => el.id === item.id))} + dot={index === values.length - 1 + ? + : null} + value={moment.utc(item.timestamp).local().format(format)} + > + {moment.utc(item.timestamp).local().format(format)} + + )}
-
- -
- setShowEditor(false)} - onCancel={() => setShowEditor(false)} - width="95%" - footer={null} - > - + - - +
+
} \ No newline at end of file diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 7c19ec3..0c12887 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -12,23 +12,23 @@ export const View = ({columns, item}) => { return <> {column.title} {column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]} diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index 129b78d..39a0a68 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -9,23 +9,27 @@ import LoaderPortal from '../../components/LoaderPortal' //import { MeasureTable } from './MeasureTable' import { MeasureTable2 } from './MeasureTable2' -const format='YYYY.MM.DD HH:mm' - export default function Measure({idWell}){ const [showLoader, setShowLoader] = useState(false) - const [currentFluidValues, setCurrentFluidValues] = useState([]) - const [currentMudValues, setCurrentMudValues] = useState([]) - const [currentNnbValues, setCurrentNnbValues] = useState([]) + const [fluidValues, setFluidValues] = useState([]) + const [mudValues, setMudValues] = useState([]) + const [nnbValues, setNnbValues] = useState([]) const updateCurrentValues = () => invokeWebApiWrapperAsync(async()=>{ - const data = await MeasureService.getAllLast(idWell) + // const data = await MeasureService.getAllLast(idWell) - const fluidValues = data?.find(value => value.idCategory === 1) - setCurrentFluidValues(fluidValues ?? []) - const mudValues = data?.find(value => value.idCategory === 2) - setCurrentMudValues(mudValues ?? []) - const nnbValues = data?.find(value => value.idCategory === 3) - setCurrentNnbValues(nnbValues ?? []) + // const fluids = data?.filter(value => value.idCategory === 1) + // setFluidValues(fluids ?? []) + // const muds = data?.filter(value => value.idCategory === 2) + // setMudValues(muds ?? []) + // const nnbs = data?.filter(value => value.idCategory === 3) + // setNnbValues(nnbs ?? []) + const fluids = await MeasureService.getHisory(idWell, 1) + setFluidValues(fluids ?? []) + const muds = await MeasureService.getHisory(idWell, 2) + setMudValues(muds ?? []) + const nnbs = await MeasureService.getHisory(idWell, 3) + setNnbValues(nnbs ?? []) } ,setShowLoader ,`Не удалось загрузить последние данные по скважине ${idWell}`) @@ -35,25 +39,19 @@ export default function Measure({idWell}){ return <> - + diff --git a/src/styles/index.css b/src/styles/index.css index bf9acb7..b9c1613 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -11,6 +11,10 @@ body { display: flex; } +.fd-column { + flex-direction: column; +} + .d-inline { display: inline; } @@ -27,6 +31,10 @@ body { width: 100% } +.mt-8px { + margin-top: 8px; +} + .mt-20px { margin-top: 20px; } @@ -39,6 +47,10 @@ body { margin-left: 5px; } +.ml-10px { + margin-left: 10px; +} + .ml-30px { margin-left: 30px; } diff --git a/src/styles/measure.css b/src/styles/measure.css index 77824cc..433e713 100644 --- a/src/styles/measure.css +++ b/src/styles/measure.css @@ -1,32 +1,15 @@ .measure-dates { - width: 15%; overflow-y: scroll; } -.measure-button { - display: flex; - margin-top: 8px; - width: 95%; - height: 30px; - border: 1px solid black; - border-radius: 5px; -} - .measure-button:hover { cursor: pointer; } -.last-measure-button { - display: flex; +.mt-8px { margin-top: 8px; - background-color: #DCDCDC; - width: 95%; - height: 30px; - border: 1px solid black; - border-radius: 5px; } -.last-measure-button:hover { - cursor: pointer; - background-color: #D3D3D3; -} \ No newline at end of file +.ml-10px { + margin-left: 10px; +} From 1cda800f18f4edd6428d9668aab4dafba27c7595 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Tue, 5 Oct 2021 15:20:42 +0500 Subject: [PATCH 03/23] Api refresh --- src/services/api/models/MessageDto.ts | 1 + .../api/services/AdminTelemetryService.ts | 29 +++++++++++++++++++ src/services/api/services/FileService.ts | 2 +- src/services/api/services/MeasureService.ts | 2 +- src/services/api/services/TelemetryService.ts | 1 + .../api/services/WellOperationService.ts | 2 +- 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/services/api/models/MessageDto.ts b/src/services/api/models/MessageDto.ts index cfc6c95..1c5001b 100644 --- a/src/services/api/models/MessageDto.ts +++ b/src/services/api/models/MessageDto.ts @@ -6,6 +6,7 @@ export type MessageDto = { id?: number; date?: string; categoryId?: number; + wellDepth?: number; user?: string | null; message?: string | null; } \ No newline at end of file diff --git a/src/services/api/services/AdminTelemetryService.ts b/src/services/api/services/AdminTelemetryService.ts index a92eff4..18b0dd9 100644 --- a/src/services/api/services/AdminTelemetryService.ts +++ b/src/services/api/services/AdminTelemetryService.ts @@ -6,6 +6,35 @@ import { request as __request } from '../core/request'; export class AdminTelemetryService { + /** + * @returns any Success + * @throws ApiError + */ + public static async getRedundentRemoteUids(): Promise { + const result = await __request({ + method: 'GET', + path: `/reduntentUids`, + }); + return result.body; + } + + /** + * merge telemetries + * @param requestBody array of ids + * @returns any Success + * @throws ApiError + */ + public static async mergeTelemetries( +requestBody?: Array, +): Promise { + const result = await __request({ + method: 'POST', + path: `/merge`, + body: requestBody, + }); + return result.body; + } + /** * Получить страницу с записями в PaginationContainer * @param skip пропустить skip записей diff --git a/src/services/api/services/FileService.ts b/src/services/api/services/FileService.ts index 7d591b5..cd51ab2 100644 --- a/src/services/api/services/FileService.ts +++ b/src/services/api/services/FileService.ts @@ -51,7 +51,7 @@ companyName?: string, fileName?: string, begin?: string, end?: string, -skip: number = 0, +skip?: number, take: number = 32, ): Promise { const result = await __request({ diff --git a/src/services/api/services/MeasureService.ts b/src/services/api/services/MeasureService.ts index 9d086fb..b0d4c26 100644 --- a/src/services/api/services/MeasureService.ts +++ b/src/services/api/services/MeasureService.ts @@ -65,7 +65,7 @@ idCategory: number, ): Promise { const result = await __request({ method: 'GET', - path: `/api/well/${idWell}/measure/history/${idCategory}`, + path: `/api/well/${idWell}/measure/history`, }); return result.body; } diff --git a/src/services/api/services/TelemetryService.ts b/src/services/api/services/TelemetryService.ts index 5e0ca30..98b3bbc 100644 --- a/src/services/api/services/TelemetryService.ts +++ b/src/services/api/services/TelemetryService.ts @@ -30,6 +30,7 @@ requestBody?: TelemetryInfoDto, } /** + * @deprecated * Принимает данные от разных систем по скважине * @param uid Уникальный идентификатор отправителя * @param requestBody Данные diff --git a/src/services/api/services/WellOperationService.ts b/src/services/api/services/WellOperationService.ts index 3215e56..0fdbd49 100644 --- a/src/services/api/services/WellOperationService.ts +++ b/src/services/api/services/WellOperationService.ts @@ -48,7 +48,7 @@ begin?: string, end?: string, minDepth: number = -1.7976931348623157e+308, maxDepth: number = 1.7976931348623157e+308, -skip: number = 0, +skip?: number, take: number = 32, ): Promise { const result = await __request({ From 05b891b15f3608a7ed4bacbbf3864a1b8928e59d Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Tue, 5 Oct 2021 17:55:20 +0500 Subject: [PATCH 04/23] CF2-49: Added switch measure table state (normal/editing) --- src/pages/Measure/MeasureTable.jsx | 143 +++++++++++++++++--------- src/pages/Measure/MeasureTable2.jsx | 59 ----------- src/pages/Measure/MeasureTableOld.jsx | 54 ++++++++++ src/pages/Measure/View.jsx | 4 +- src/pages/Measure/index.jsx | 24 ++--- src/styles/index.css | 2 +- src/styles/measure.css | 23 ++++- 7 files changed, 184 insertions(+), 125 deletions(-) delete mode 100644 src/pages/Measure/MeasureTable2.jsx create mode 100644 src/pages/Measure/MeasureTableOld.jsx diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 7aab0f0..0eb8a55 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,54 +1,105 @@ -import { useState, useEffect } from 'react' -import { Table, Button, Modal } from 'antd' -import { HourglassOutlined } from '@ant-design/icons' -import LoaderPortal from '../../components/LoaderPortal' -import { invokeWebApiWrapperAsync } from '../../components/factory' -import { MeasureService } from '../../services/api' -import { Editor } from './Editor' +import { useState, useEffect } from "react" +import { Button, Timeline } from 'antd' +import moment from 'moment' +import { ExclamationCircleOutlined } from '@ant-design/icons' +import { View } from './View' +import '../../styles/index.css' +import '../../styles/measure.css' -export const MeasureTable = ({idWell, idCategory, title, columns}) => { - const [showLoader, setShowLoader] = useState(false) - const [showEditor, setShowEditor] = useState(false) - const [lastData, setLastData] = useState({}) +const format='YYYY.MM.DD HH:mm' - const update = ()=>invokeWebApiWrapperAsync(async()=>{ - const data = await MeasureService.getLast(idWell, idCategory) - setLastData(data) +export const MeasureTable = ({title, columns, values}) => { + var defaultDisplay = values && values.length + ? values[values.length-1] + : [] + + const [displayedValues, setDisplayedValues] = useState([]); + const [editingColumns, setEditingColumns] = useState(columns); + const [isTableEditing, setIsTableEditing] = useState(false); + + useEffect(() => { + setDisplayedValues(defaultDisplay) + }, [defaultDisplay]) + + useEffect(() => { + let switchableColumns = [] + if(isTableEditing) { + switchableColumns = columns.map(col => + ({ render: () => , + ...col + }) + ) + } else { + switchableColumns = columns.map(col => + ({ render: null, + ...col + }) + ) + } + + setEditingColumns(switchableColumns) + }, [isTableEditing]) + + const createButtons = (buttonNames, buttonContainerStyle, isEditing) => { + return
+ {buttonNames.map(name => + + )} +
} - , setShowLoader - , "не удалось загрузить") - useEffect(update, [idWell, idCategory]) + const crudButtons = +
+ + + +
- const timestamp = lastData ? new Date(lastData?.timestamp).toLocaleString() : '-' + const confirmButtons = +
+ + +
- return -

{title}

- Дата: {timestamp} + return <>   - - - setShowEditor(false)} - onCancel={() => setShowEditor(false)} - width="95%" - footer={null} - > - - - +

{title}

+   +
+
+
+ {isTableEditing + ? confirmButtons + : crudButtons + } +
+ +
+ + {values.map((item, index) => + setDisplayedValues(values.find(el => el.id === item.id))} + dot={item.id === displayedValues.id + ? + : null} + value={moment.utc(item.timestamp).local().format(format)} + > + {moment.utc(item.timestamp).local().format(format)} + + )} + +
+
+
+ +
+
+ } \ No newline at end of file diff --git a/src/pages/Measure/MeasureTable2.jsx b/src/pages/Measure/MeasureTable2.jsx deleted file mode 100644 index 5c6a04a..0000000 --- a/src/pages/Measure/MeasureTable2.jsx +++ /dev/null @@ -1,59 +0,0 @@ -import { useState, useEffect } from "react" -import { Button, Timeline } from 'antd' -import moment from 'moment' -import { ClockCircleOutlined } from '@ant-design/icons' -import { View } from './View' -import '../../styles/index.css' -import '../../styles/measure.css' - -const format='YYYY.MM.DD HH:mm' - -export const MeasureTable2 = ({title, columns, values}) => { - var defaultDisplay = values && values.length > 1 - ? values[values.length-1] - : [] - - const [displayedValues, setDisplayedValues] = useState([]); - - useEffect(() => { - setDisplayedValues(defaultDisplay) - }, [defaultDisplay]) - - return <> -   -

{title}

-   -
-
-
- - - -
-
- - {values.map((item, index) => - setDisplayedValues(values.find(el => el.id === item.id))} - dot={index === values.length - 1 - ? - : null} - value={moment.utc(item.timestamp).local().format(format)} - > - {moment.utc(item.timestamp).local().format(format)} - - )} - -
-
-
- -
-
- -} \ No newline at end of file diff --git a/src/pages/Measure/MeasureTableOld.jsx b/src/pages/Measure/MeasureTableOld.jsx new file mode 100644 index 0000000..7aab0f0 --- /dev/null +++ b/src/pages/Measure/MeasureTableOld.jsx @@ -0,0 +1,54 @@ +import { useState, useEffect } from 'react' +import { Table, Button, Modal } from 'antd' +import { HourglassOutlined } from '@ant-design/icons' +import LoaderPortal from '../../components/LoaderPortal' +import { invokeWebApiWrapperAsync } from '../../components/factory' +import { MeasureService } from '../../services/api' +import { Editor } from './Editor' + +export const MeasureTable = ({idWell, idCategory, title, columns}) => { + const [showLoader, setShowLoader] = useState(false) + const [showEditor, setShowEditor] = useState(false) + const [lastData, setLastData] = useState({}) + + const update = ()=>invokeWebApiWrapperAsync(async()=>{ + const data = await MeasureService.getLast(idWell, idCategory) + setLastData(data) + } + , setShowLoader + , "не удалось загрузить") + + useEffect(update, [idWell, idCategory]) + + const timestamp = lastData ? new Date(lastData?.timestamp).toLocaleString() : '-' + + return +

{title}

+ Дата: {timestamp} +   + +
+ setShowEditor(false)} + onCancel={() => setShowEditor(false)} + width="95%" + footer={null} + > + + + +} \ No newline at end of file diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 0c12887..abc8af8 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -15,6 +15,7 @@ export const View = ({columns, item}) => { row={row} col={colb*2 + 1} style={{background:'#00000005', + //width: '300px', border:'1px solid black' }} > @@ -23,7 +24,8 @@ export const View = ({columns, item}) => { invokeWebApiWrapperAsync(async()=>{ - // const data = await MeasureService.getAllLast(idWell) + const measures = await MeasureService.getHisory(idWell) - // const fluids = data?.filter(value => value.idCategory === 1) - // setFluidValues(fluids ?? []) - // const muds = data?.filter(value => value.idCategory === 2) - // setMudValues(muds ?? []) - // const nnbs = data?.filter(value => value.idCategory === 3) - // setNnbValues(nnbs ?? []) - const fluids = await MeasureService.getHisory(idWell, 1) + const fluids = measures.filter(el => el.idCategory === 1) setFluidValues(fluids ?? []) - const muds = await MeasureService.getHisory(idWell, 2) + const muds = measures.filter(el => el.idCategory === 2) setMudValues(muds ?? []) - const nnbs = await MeasureService.getHisory(idWell, 3) + const nnbs = measures.filter(el => el.idCategory === 3) setNnbValues(nnbs ?? []) } ,setShowLoader @@ -38,17 +30,17 @@ export default function Measure({idWell}){ return <> - - - Date: Wed, 6 Oct 2021 13:57:04 +0500 Subject: [PATCH 05/23] CF2-49: Added form in 'Measures' table --- src/pages/Measure/MeasureTable.jsx | 118 +++++++++++++++++++---------- src/pages/Measure/View.jsx | 66 ++++++++++------ src/styles/index.css | 4 + src/styles/measure.css | 4 + 4 files changed, 128 insertions(+), 64 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 0eb8a55..67b712a 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,8 +1,9 @@ -import { useState, useEffect } from "react" -import { Button, Timeline } from 'antd' +import { useState, useEffect } from 'react' +import { Button, Form, Timeline } from 'antd' import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' +import LoaderPortal from '../../components/LoaderPortal' import '../../styles/index.css' import '../../styles/measure.css' @@ -13,9 +14,58 @@ export const MeasureTable = ({title, columns, values}) => { ? values[values.length-1] : [] + const [showLoader, setShowLoader] = useState(false); const [displayedValues, setDisplayedValues] = useState([]); const [editingColumns, setEditingColumns] = useState(columns); const [isTableEditing, setIsTableEditing] = useState(false); + const [editingActionName, setEditingActionName] = useState(''); + + const [measuresForm] = Form.useForm(); + + const buttonsConfig = [ + {name:'Добавить', key:'add'}, + {name:'Редактировать', key:'edit'}, + {name:'Удалить', key:'delete'} + ] + + const createButtons = (config, onClickDelegate) => { + return ( +
+ {config.map(c => { + return ( + + ) + })} +
+ ) + } + + const crudButtons = createButtons(buttonsConfig, (e)=> { + setEditingActionName(e.target.innerText) + setIsTableEditing(true) + }) + + const confirmButtons = +
+

{editingActionName} данные?

+
+ + +
+
+ + const createEditingColumns = (cols, renderDelegate) => + cols.map(col => + ({ render: renderDelegate, + ...col + }) + ) useEffect(() => { setDisplayedValues(defaultDisplay) @@ -23,44 +73,26 @@ export const MeasureTable = ({title, columns, values}) => { useEffect(() => { let switchableColumns = [] - if(isTableEditing) { - switchableColumns = columns.map(col => - ({ render: () => , - ...col - }) - ) - } else { - switchableColumns = columns.map(col => - ({ render: null, - ...col - }) - ) - } + isTableEditing && editingActionName !== 'Удалить' + ? switchableColumns = createEditingColumns(columns, () => ) + : switchableColumns = createEditingColumns(columns, null) setEditingColumns(switchableColumns) }, [isTableEditing]) - const createButtons = (buttonNames, buttonContainerStyle, isEditing) => { - return
- {buttonNames.map(name => - - )} -
+ + let handleSubmitMeasuresForm = async (formData) => { + // if(isTableEditing) + // measuresForm.setFieldsValue({ + // ...displayedValues + // }); + + measuresForm.validateFields() + + setShowLoader(true) + setShowLoader(false) } - const crudButtons = -
- - - -
- - const confirmButtons = -
- - -
- return <>  

{title}

@@ -85,8 +117,7 @@ export const MeasureTable = ({title, columns, values}) => { onClick={() => setDisplayedValues(values.find(el => el.id === item.id))} dot={item.id === displayedValues.id ? - : null} - value={moment.utc(item.timestamp).local().format(format)} + : null} > {moment.utc(item.timestamp).local().format(format)} @@ -95,10 +126,17 @@ export const MeasureTable = ({title, columns, values}) => {
- + +
+ + +
diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index abc8af8..419caad 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -1,5 +1,22 @@ -import { Empty } from 'antd'; +import { Empty, Form } from 'antd'; import {Grid, GridItem} from '../../components/Grid' +import '../../styles/index.css' + +const renderSwitchableColumn = (column, itm) => { + if(column.render) { + return ( + + {column.render(itm[column.dataIndex])} + + ) + } + + return

{itm[column.dataIndex]}

+} export const View = ({columns, item}) => { if (!item || !columns?.length) @@ -11,29 +28,30 @@ export const View = ({columns, item}) => { const colb = i % colsCount return <> - - {column.title} - - - {column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]} - + + {column.title} + + + + {renderSwitchableColumn(column, item)} + }) diff --git a/src/styles/index.css b/src/styles/index.css index f64b70c..16aee1c 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -31,6 +31,10 @@ body { width: 100% } +.m-0 { + margin: 0; +} + .mt-8px { margin-top: 8px; } diff --git a/src/styles/measure.css b/src/styles/measure.css index 94d5be1..37ce2ac 100644 --- a/src/styles/measure.css +++ b/src/styles/measure.css @@ -25,6 +25,10 @@ cursor: pointer; } +.m-5px-auto { + margin: 5px auto; +} + .mt-12px { margin-top: 12px; } From 9973009c65de88bf06af63102b659ebd92a43f31 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Wed, 6 Oct 2021 15:31:55 +0500 Subject: [PATCH 06/23] CF2-49: Added 'Insert' and 'Delete' actions --- src/pages/Measure/MeasureTable.jsx | 31 ++++++++++++++++++++++++++---- src/pages/Measure/index.jsx | 12 +++++++++++- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 67b712a..e1337d7 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -4,12 +4,13 @@ import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' import LoaderPortal from '../../components/LoaderPortal' +import { MeasureService } from '../../services/api' import '../../styles/index.css' import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable = ({title, columns, values}) => { +export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasuresDelegate}) => { var defaultDisplay = values && values.length ? values[values.length-1] : [] @@ -55,7 +56,20 @@ export const MeasureTable = ({title, columns, values}) => {

{editingActionName} данные?

- +
@@ -78,7 +92,7 @@ export const MeasureTable = ({title, columns, values}) => { : switchableColumns = createEditingColumns(columns, null) setEditingColumns(switchableColumns) - }, [isTableEditing]) + }, [isTableEditing, columns, editingActionName]) let handleSubmitMeasuresForm = async (formData) => { @@ -86,10 +100,19 @@ export const MeasureTable = ({title, columns, values}) => { // measuresForm.setFieldsValue({ // ...displayedValues // }); - measuresForm.validateFields() + const measureParams = { + idWell: idWell, + idCategory: idCategory, + timestamp: new Date().toISOString(), + data: formData + } + setShowLoader(true) + await MeasureService.insert(idWell, measureParams) + setIsTableEditing(false) + updateMeasuresDelegate() setShowLoader(false) } diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index a1d66a4..6f5a20c 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -12,6 +12,7 @@ export default function Measure({idWell}){ const [fluidValues, setFluidValues] = useState([]) const [mudValues, setMudValues] = useState([]) const [nnbValues, setNnbValues] = useState([]) + const [isMeasuresUpdating, setIsMeasuresUpdating] = useState(false) const updateCurrentValues = () => invokeWebApiWrapperAsync(async()=>{ const measures = await MeasureService.getHisory(idWell) @@ -26,24 +27,33 @@ export default function Measure({idWell}){ ,setShowLoader ,`Не удалось загрузить последние данные по скважине ${idWell}`) - useEffect(updateCurrentValues, [idWell]) + useEffect(updateCurrentValues, [idWell, isMeasuresUpdating]) return <> setIsMeasuresUpdating(true)} /> setIsMeasuresUpdating(true)} /> setIsMeasuresUpdating(true)} /> From c6bdb278579c2d5cedc8a6d1aae01ad9ae548686 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Wed, 6 Oct 2021 16:06:07 +0500 Subject: [PATCH 07/23] CF2-49: Fixed selecting of default values to display --- src/pages/Measure/MeasureTable.jsx | 67 +++++++++++++++++------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index e1337d7..eb4714c 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -10,12 +10,10 @@ import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasuresDelegate}) => { - var defaultDisplay = values && values.length - ? values[values.length-1] - : [] +export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasures}) => { const [showLoader, setShowLoader] = useState(false); + const [selectedTimeLineId, setSelectedTimeLineId] = useState(0) const [displayedValues, setDisplayedValues] = useState([]); const [editingColumns, setEditingColumns] = useState(columns); const [isTableEditing, setIsTableEditing] = useState(false); @@ -23,6 +21,36 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update const [measuresForm] = Form.useForm(); + const createEditingColumns = (cols, renderDelegate) => + cols.map(col => + ({ render: renderDelegate, + ...col + }) + ) + + useEffect(() => { + let valuesToDisplay = [] + + if(selectedTimeLineId === 0) { + valuesToDisplay = values.length + ? values[values.length-1] + : [] + } else { + valuesToDisplay = values.find(el => el.id === selectedTimeLineId) + } + + setDisplayedValues(valuesToDisplay) + }, [selectedTimeLineId, values]) + + useEffect(() => { + let switchableColumns = [] + isTableEditing && editingActionName !== 'Удалить' + ? switchableColumns = createEditingColumns(columns, () => ) + : switchableColumns = createEditingColumns(columns, null) + + setEditingColumns(switchableColumns) + }, [isTableEditing, columns, editingActionName]) + const buttonsConfig = [ {name:'Добавить', key:'add'}, {name:'Редактировать', key:'edit'}, @@ -60,7 +88,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update if(editingActionName === 'Удалить'){ setShowLoader(true) await MeasureService.markAsDelete(idWell, displayedValues.id) - updateMeasuresDelegate() + updateMeasures() setShowLoader(false) setIsTableEditing(false) } else { @@ -73,27 +101,6 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update - - const createEditingColumns = (cols, renderDelegate) => - cols.map(col => - ({ render: renderDelegate, - ...col - }) - ) - - useEffect(() => { - setDisplayedValues(defaultDisplay) - }, [defaultDisplay]) - - useEffect(() => { - let switchableColumns = [] - isTableEditing && editingActionName !== 'Удалить' - ? switchableColumns = createEditingColumns(columns, () => ) - : switchableColumns = createEditingColumns(columns, null) - - setEditingColumns(switchableColumns) - }, [isTableEditing, columns, editingActionName]) - let handleSubmitMeasuresForm = async (formData) => { // if(isTableEditing) @@ -112,7 +119,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update setShowLoader(true) await MeasureService.insert(idWell, measureParams) setIsTableEditing(false) - updateMeasuresDelegate() + updateMeasures() setShowLoader(false) } @@ -137,8 +144,8 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update className={index === values.length-1 ? 'last-measure-button' : 'measure-button'} - onClick={() => setDisplayedValues(values.find(el => el.id === item.id))} - dot={item.id === displayedValues.id + onClick={() => setSelectedTimeLineId(item.id)} + dot={item?.id === displayedValues?.id ? : null} > @@ -155,7 +162,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update onFinish={handleSubmitMeasuresForm} > From d562b910cadf028af89e5a4d72dbaa721ed2f515 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Thu, 7 Oct 2021 10:48:26 +0500 Subject: [PATCH 08/23] CF2-49: Added values to table inputs while 'Measures' table update --- src/pages/Measure/MeasureTable.jsx | 26 ++++++++++++++------------ src/pages/Measure/View.jsx | 9 ++------- src/styles/measure.css | 4 ++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index eb4714c..5cb1c45 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,5 +1,5 @@ import { useState, useEffect } from 'react' -import { Button, Form, Timeline } from 'antd' +import { Button, Form, Input, Timeline } from 'antd' import moment from 'moment' import { ExclamationCircleOutlined } from '@ant-design/icons' import { View } from './View' @@ -44,12 +44,18 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update useEffect(() => { let switchableColumns = [] + isTableEditing && editingActionName !== 'Удалить' - ? switchableColumns = createEditingColumns(columns, () => ) + ? switchableColumns = createEditingColumns(columns, () => ) : switchableColumns = createEditingColumns(columns, null) + if(editingActionName === 'Редактировать') + measuresForm.setFieldsValue(displayedValues.data); + else if(editingActionName === 'Добавить') + measuresForm.resetFields() + setEditingColumns(switchableColumns) - }, [isTableEditing, columns, editingActionName]) + }, [isTableEditing, columns, editingActionName, displayedValues.data, measuresForm]) const buttonsConfig = [ {name:'Добавить', key:'add'}, @@ -60,14 +66,14 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update const createButtons = (config, onClickDelegate) => { return (
- {config.map(c => { + {config.map(conf => { return ( ) })} @@ -75,7 +81,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update ) } - const crudButtons = createButtons(buttonsConfig, (e)=> { + const crudButtons = createButtons(buttonsConfig, (e) => { setEditingActionName(e.target.innerText) setIsTableEditing(true) }) @@ -103,10 +109,6 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update
let handleSubmitMeasuresForm = async (formData) => { - // if(isTableEditing) - // measuresForm.setFieldsValue({ - // ...displayedValues - // }); measuresForm.validateFields() const measureParams = { @@ -162,7 +164,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update onFinish={handleSubmitMeasuresForm} > diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 419caad..16a9c80 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -31,10 +31,7 @@ export const View = ({columns, item}) => { {column.title} @@ -42,9 +39,7 @@ export const View = ({columns, item}) => { Date: Thu, 7 Oct 2021 11:52:52 +0500 Subject: [PATCH 09/23] CF2-49: Added default values for 'Measure' table --- src/pages/Measure/MeasureTable.jsx | 9 +++-- ...sDrillingFluid.js => drillingFluidData.js} | 38 +++++++++++++++++++ src/pages/Measure/index.jsx | 15 +++++--- ...columnsMudDiagram.js => mudDiagramData.js} | 34 ++++++++++++++++- .../Measure/{columnsNnb.js => nnbData.js} | 29 +++++++++++++- 5 files changed, 114 insertions(+), 11 deletions(-) rename src/pages/Measure/{columnsDrillingFluid.js => drillingFluidData.js} (75%) rename src/pages/Measure/{columnsMudDiagram.js => mudDiagramData.js} (75%) rename src/pages/Measure/{columnsNnb.js => nnbData.js} (77%) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 5cb1c45..9ce6710 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -10,7 +10,7 @@ import '../../styles/measure.css' const format='YYYY.MM.DD HH:mm' -export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasures}) => { +export const MeasureTable = ({idWell, idCategory, title, columns, values, updateMeasuresFunc}) => { const [showLoader, setShowLoader] = useState(false); const [selectedTimeLineId, setSelectedTimeLineId] = useState(0) @@ -72,6 +72,9 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update key={conf.key} className='w-100' onClick={onClickDelegate} + disabled={conf.key !== 'add' && displayedValues.isDefaultData + ? true + : false} > {conf.name} @@ -94,7 +97,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update if(editingActionName === 'Удалить'){ setShowLoader(true) await MeasureService.markAsDelete(idWell, displayedValues.id) - updateMeasures() + updateMeasuresFunc() setShowLoader(false) setIsTableEditing(false) } else { @@ -121,7 +124,7 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update setShowLoader(true) await MeasureService.insert(idWell, measureParams) setIsTableEditing(false) - updateMeasures() + updateMeasuresFunc() setShowLoader(false) } diff --git a/src/pages/Measure/columnsDrillingFluid.js b/src/pages/Measure/drillingFluidData.js similarity index 75% rename from src/pages/Measure/columnsDrillingFluid.js rename to src/pages/Measure/drillingFluidData.js index 41dc820..520e2c4 100644 --- a/src/pages/Measure/columnsDrillingFluid.js +++ b/src/pages/Measure/drillingFluidData.js @@ -31,3 +31,41 @@ export const columnsDrillingFluid = [ makeColumn(v("Смазка, %"), "grease",numericColumnOptions), makeColumn(v("Карбонат кальция, кг/м³"), "calciumCarbonate",numericColumnOptions), ]; + +export const drillingFluidDefaultData = { + idWell: 0, + key: 'drillingFluidDefaultData', + idCategory: 0, + timestamp: new Date().toISOString(), + isDefaultData: true, + data: { + "name": 0, + "temperature": 0, + "density": 0, + "conditionalViscosity": 0, + "r300": 0, + "r600": 0, + "r3r6": 0, + "dnsDpa": 0, + "plasticViscocity": 0, + "snsDpa": 0, + "r3r649С": 0, + "dns49Cdpa": 0, + "plasticViscocity49c": 0, + "sns49Cdpa": 0, + "mbt": 0, + "sand": 0, + "filtering": 0, + "crust": 0, + "ktk": 0, + "ph": 0, + "hardness": 0, + "chlorides": 0, + "pf": 0, + "mf": 0, + "pm": 0, + "fluidSolidPhase": 0, + "grease": 0, + "calciumCarbonate": 0 + } +} diff --git a/src/pages/Measure/index.jsx b/src/pages/Measure/index.jsx index 6f5a20c..b96e1fb 100644 --- a/src/pages/Measure/index.jsx +++ b/src/pages/Measure/index.jsx @@ -1,9 +1,12 @@ import { useState, useEffect } from 'react' -import { columnsMudDiagram} from './columnsMudDiagram' -import { columnsDrillingFluid} from './columnsDrillingFluid' +import { columnsMudDiagram} from './mudDiagramData' +import { mudDiagramDefaultData} from './mudDiagramData' +import { columnsDrillingFluid} from './drillingFluidData' +import { drillingFluidDefaultData} from './drillingFluidData' +import { columnsNnb } from './nnbData' +import { nnbDefaultData } from './nnbData' import { invokeWebApiWrapperAsync } from '../../components/factory' import { MeasureService } from '../../services/api' -import { columnsNnb } from './columnsNnb' import LoaderPortal from '../../components/LoaderPortal' import { MeasureTable } from './MeasureTable' @@ -18,11 +21,11 @@ export default function Measure({idWell}){ const measures = await MeasureService.getHisory(idWell) const fluids = measures.filter(el => el.idCategory === 1) - setFluidValues(fluids ?? []) + setFluidValues(fluids.length ? fluids : [drillingFluidDefaultData]) const muds = measures.filter(el => el.idCategory === 2) - setMudValues(muds ?? []) + setMudValues(muds.length ? muds : [mudDiagramDefaultData]) const nnbs = measures.filter(el => el.idCategory === 3) - setNnbValues(nnbs ?? []) + setNnbValues(nnbs.length ? nnbs : [nnbDefaultData]) } ,setShowLoader ,`Не удалось загрузить последние данные по скважине ${idWell}`) diff --git a/src/pages/Measure/columnsMudDiagram.js b/src/pages/Measure/mudDiagramData.js similarity index 75% rename from src/pages/Measure/columnsMudDiagram.js rename to src/pages/Measure/mudDiagramData.js index c759786..fd2b830 100644 --- a/src/pages/Measure/columnsMudDiagram.js +++ b/src/pages/Measure/mudDiagramData.js @@ -24,4 +24,36 @@ export const columnsMudDiagram = [ makeColumn(v('С5 пентан (отн%)'), 'pentane', numericColumnOptions), makeColumn(v('Мех. скорость'), 'mechanicalSpeed', numericColumnOptions), makeColumn('Предварительное заключение о насыщении по ГК', 'preliminaryConclusion', textColumnOptions), -] \ No newline at end of file +] + +export const mudDiagramDefaultData = { + idWell: 0, + key: 'mudDiagramDefaultData', + idCategory: 0, + timestamp: new Date().toISOString(), + isDefaultData: true, + data: { + "probeNumber": 0, + "probeExtractionDepth": 0, + "sandstone": 0, + "siltstone": 0, + "argillit": 0, + "brokenArgillit": 0, + "coal": 0, + "sand": 0, + "clay": 0, + "camstone": 0, + "cement": 0, + "summary": '-', + "drillingMud": 0, + "sludge": 0, + "maxSum": 0, + "methane": 0, + "ethane": 0, + "propane": 0, + "butane": 0, + "pentane": 0, + "mechanicalSpeed": 0, + "preliminaryConclusion": '-' + } +} \ No newline at end of file diff --git a/src/pages/Measure/columnsNnb.js b/src/pages/Measure/nnbData.js similarity index 77% rename from src/pages/Measure/columnsNnb.js rename to src/pages/Measure/nnbData.js index f309328..628da25 100644 --- a/src/pages/Measure/columnsNnb.js +++ b/src/pages/Measure/nnbData.js @@ -19,4 +19,31 @@ export const columnsNnb = [ makeColumn(v('Комментарий'), 'comment', numericColumnOptions), makeColumn(v('Разница вертикальных глубин\nмежду планом и фактом'), 'depthPlanFactDifference', numericColumnOptions), makeColumn(v('Расстояние в пространстве\nмежду планом и фактом'), 'distancePlanFactDifference', numericColumnOptions), -]; \ No newline at end of file +]; + +export const nnbDefaultData = { + idWell: 0, + key: 'nnbDefaultData', + idCategory: 0, + timestamp: new Date().toISOString(), + isDefaultData: true, + data: { + "depth": 0, + "zenithAngle": 0, + "magneticAzimuth": 0, + "trueAzimuth": 0, + "directAzimuth": 0, + "verticalDepth": 0, + "absoluteMark": 0, + "localNorthOffset": 0, + "localEastOffset": 0, + "outFallOffset": 0, + "offsetAzimuth": 0, + "areaIntensity": '-', + "offsetStopAngle": 0, + "zenithIntensity": 0, + "comment": '-', + "depthPlanFactDifference": 0, + "distancePlanFactDifference": 0 + } +} \ No newline at end of file From 61049d6b8b19164738dda635425b938cf22c1b48 Mon Sep 17 00:00:00 2001 From: KharchenkoVV Date: Thu, 7 Oct 2021 15:05:59 +0500 Subject: [PATCH 10/23] CF2-49: Fixed 'Measures' table in editing view --- src/pages/Measure/MeasureTable.jsx | 45 ++++++++++++++++++++---------- src/pages/Measure/View.jsx | 10 +++++-- src/pages/Measure/columnsCommon.js | 8 +++++- src/pages/Measure/index.jsx | 10 +++++-- src/styles/measure.css | 13 +++------ 5 files changed, 56 insertions(+), 30 deletions(-) diff --git a/src/pages/Measure/MeasureTable.jsx b/src/pages/Measure/MeasureTable.jsx index 9ce6710..103ada1 100644 --- a/src/pages/Measure/MeasureTable.jsx +++ b/src/pages/Measure/MeasureTable.jsx @@ -1,7 +1,7 @@ import { useState, useEffect } from 'react' import { Button, Form, Input, Timeline } from 'antd' import moment from 'moment' -import { ExclamationCircleOutlined } from '@ant-design/icons' +import { CheckSquareOutlined } from '@ant-design/icons' import { View } from './View' import LoaderPortal from '../../components/LoaderPortal' import { MeasureService } from '../../services/api' @@ -22,10 +22,10 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update const [measuresForm] = Form.useForm(); const createEditingColumns = (cols, renderDelegate) => - cols.map(col => - ({ render: renderDelegate, - ...col - }) + cols.map(col => + ({ render: renderDelegate, + ...col + }) ) useEffect(() => { @@ -93,7 +93,10 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update

{editingActionName} данные?

- - +
@@ -122,7 +131,15 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update } setShowLoader(true) - await MeasureService.insert(idWell, measureParams) + + if(editingActionName === 'Добавить') { + await MeasureService.insert(idWell, measureParams) + } else if (editingActionName === 'Редактировать') { + measureParams.id = displayedValues.id + measureParams.timestamp = displayedValues.timestamp + await MeasureService.update(idWell, measureParams) + } + setIsTableEditing(false) updateMeasuresFunc() setShowLoader(false) @@ -145,16 +162,16 @@ export const MeasureTable = ({idWell, idCategory, title, columns, values, update {values.map((item, index) => setSelectedTimeLineId(item.id)} dot={item?.id === displayedValues?.id - ? + ? : null} > - {moment.utc(item.timestamp).local().format(format)} + + {moment.utc(item.timestamp).local().format(format)} + )} diff --git a/src/pages/Measure/View.jsx b/src/pages/Measure/View.jsx index 16a9c80..0763514 100644 --- a/src/pages/Measure/View.jsx +++ b/src/pages/Measure/View.jsx @@ -6,6 +6,7 @@ const renderSwitchableColumn = (column, itm) => { if(column.render) { return ( { ) } - return

{itm[column.dataIndex]}

+ return

{itm[column.dataIndex]}

} export const View = ({columns, item}) => { if (!item || !columns?.length) - return + return const colsCount = 3 const viewItems = columns.map( (column, i) => { @@ -29,6 +30,7 @@ export const View = ({columns, item}) => { return <> { {renderSwitchableColumn(column, item)} diff --git a/src/pages/Measure/columnsCommon.js b/src/pages/Measure/columnsCommon.js index 7d458b5..5e7a616 100644 --- a/src/pages/Measure/columnsCommon.js +++ b/src/pages/Measure/columnsCommon.js @@ -42,4 +42,10 @@ export const numericColumnOptions = { export const textColumnOptions = { editable:true, input: