From dd2315d53e0abe46f0db65ba811a29fdd526b473 Mon Sep 17 00:00:00 2001 From: goodmice Date: Fri, 29 Apr 2022 16:39:49 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D1=81=D0=BC=D0=B5=D1=82=D0=B8?= =?UTF-8?q?=D1=87=D0=B5=D1=81=D0=BA=D0=B8=D0=B5=20=D0=B8=D0=B7=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D1=83=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B5?= =?UTF-8?q?=D0=B3=D0=BE=20=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/MSE_and_torqueStab_info.txt | 9 ----- src/components/{Display.jsx => Display.tsx} | 40 +++++++++++++------ .../{ErrorFetch.js => ErrorFetch.ts} | 4 +- .../{UploadForm.jsx => UploadForm.tsx} | 21 ++++++++-- src/context/Context.js | 5 --- src/pages/Well.jsx | 3 -- 6 files changed, 47 insertions(+), 35 deletions(-) delete mode 100755 doc/MSE_and_torqueStab_info.txt rename src/components/{Display.jsx => Display.tsx} (65%) mode change 100755 => 100644 rename src/components/{ErrorFetch.js => ErrorFetch.ts} (66%) mode change 100755 => 100644 rename src/components/{UploadForm.jsx => UploadForm.tsx} (69%) mode change 100755 => 100644 delete mode 100755 src/context/Context.js diff --git a/doc/MSE_and_torqueStab_info.txt b/doc/MSE_and_torqueStab_info.txt deleted file mode 100755 index 7950584..0000000 --- a/doc/MSE_and_torqueStab_info.txt +++ /dev/null @@ -1,9 +0,0 @@ -# Вопрос Олегу: Какой бит и в каком регистре (или значение регистра) контроллера спинмастера сигнализирует что система спинмастер активана/работает? -Ответ: Такого бита нет, но можно понять если etap %MW1600: INT; не равен 6 и не равен 0 тогда система в работе - -# Вопрос Олегу: Какой бит и в каком регистре (или значение регистра) контроллера спинмастера сигнализирует что система стабилизации крутящего момента активна/работает? -Ответ: Такого бита по сути тоже нет но можно понять что -когда stik_sleep %MX2802.01: BOOL; =true -и -etap %MW1600: INT; =7 -тогда торк мастер работает \ No newline at end of file diff --git a/src/components/Display.jsx b/src/components/Display.tsx old mode 100755 new mode 100644 similarity index 65% rename from src/components/Display.jsx rename to src/components/Display.tsx index 77d1a1b..1ae6709 --- a/src/components/Display.jsx +++ b/src/components/Display.tsx @@ -1,19 +1,33 @@ import moment from 'moment' -import { useState, useEffect, memo } from 'react' +import { useState, useEffect, memo, ReactNode } from 'react' import {CaretUpOutlined, CaretDownOutlined, CaretRightOutlined} from '@ant-design/icons' import '@styles/display.css' -export const formatNumber = (value, format) => +export const formatNumber = (value?: unknown, format?: number) => Number.isInteger(format) && Number.isFinite(value) - ? (+value).toFixed(format) - : (+value).toPrecision(4) + ? Number(value).toFixed(format) + : Number(value).toPrecision(4) const iconStyle = { color:'#0008' } const displayValueStyle = { display: 'flex', flexGrow: 1 } -export const ValueDisplay = ({ prefix, value, suffix, isArrowVisible, format, enumeration }) => { - const [val, setVal] = useState('---') +export type ValueDisplayProps = { + prefix?: ReactNode + suffix?: ReactNode + format?: number | string + isArrowVisible?: boolean + enumeration?: Record + value: string +} + +export type DisplayProps = ValueDisplayProps & { + className?: string + label?: ReactNode +} + +export const ValueDisplay = memo(({ prefix, value, suffix, isArrowVisible, format, enumeration }) => { + const [val, setVal] = useState('---') const [arrowState, setArrowState] = useState({ preVal: NaN, preTimestamp: Date.now(), @@ -28,25 +42,25 @@ export const ValueDisplay = ({ prefix, value, suffix, isArrowVisible, format, en if (Number.isFinite(+value)) { if (isArrowVisible && (arrowState.preTimestamp + 1000 < Date.now())) { let direction = 0 - if (value > arrowState.preVal) + if (+value > arrowState.preVal) direction = 1 - if (value < arrowState.preVal) + if (+value < arrowState.preVal) direction = -1 setArrowState({ - preVal: value, + preVal: +value, preTimestamp: Date.now(), direction: direction, }) } - return formatNumber(value, format) + return formatNumber(value, Number(format)) } if (value.length > 4) { const valueDate = moment(value) if (valueDate.isValid()) - return valueDate.format(format) + return valueDate.format(String(format)) } return value @@ -74,9 +88,9 @@ export const ValueDisplay = ({ prefix, value, suffix, isArrowVisible, format, en {prefix} {val} {suffix}{arrow} ) -} +}) -export const Display = memo(({ className, label, ...other })=> ( +export const Display = memo(({ className, label, ...other })=> (
{label}
diff --git a/src/components/ErrorFetch.js b/src/components/ErrorFetch.ts old mode 100755 new mode 100644 similarity index 66% rename from src/components/ErrorFetch.js rename to src/components/ErrorFetch.ts index b4f2bed..68993f1 --- a/src/components/ErrorFetch.js +++ b/src/components/ErrorFetch.ts @@ -1,5 +1,7 @@ export class ErrorFetch extends Error { - constructor(status, message) { + public status: number + + constructor(status: number, message?: string) { super(message) this.name = 'ErrorFetch' this.status = status diff --git a/src/components/UploadForm.jsx b/src/components/UploadForm.tsx old mode 100755 new mode 100644 similarity index 69% rename from src/components/UploadForm.jsx rename to src/components/UploadForm.tsx index 2d0f244..3ec99a5 --- a/src/components/UploadForm.jsx +++ b/src/components/UploadForm.tsx @@ -1,22 +1,35 @@ import { memo, useCallback, useState } from 'react' import { Upload, Button } from 'antd' import { UploadOutlined } from '@ant-design/icons' +import { UploadFile } from 'antd/lib/upload/interface' import { upload } from './factory' import { ErrorFetch } from './ErrorFetch' -export const UploadForm = memo(({ url, disabled, accept, style, formData, onUploadStart, onUploadSuccess, onUploadComplete, onUploadError }) => { - const [fileList, setfileList] = useState([]) +export type UploadFormProps = { + url: string + disabled?: boolean + accept?: string + style?: CSSStyleSheet + formData: FormData + onUploadStart?: () => void + onUploadSuccess?: () => void + onUploadComplete?: () => void + onUploadError?: (error: unknown) => void +} + +export const UploadForm = memo(({ url, disabled, accept, style, formData, onUploadStart, onUploadSuccess, onUploadComplete, onUploadError }) => { + const [fileList, setfileList] = useState[]>([]) const handleFileSend = useCallback(async () => { onUploadStart?.() try { const formDataLocal = new FormData() - fileList.forEach((val) => formDataLocal.append('files', val.originFileObj)) + fileList.forEach((val) => formDataLocal.append('files', String(val.originFileObj))) if(formData) for(const propName in formData) - formDataLocal.append(propName, formData[propName]) + formDataLocal.append(propName, String(formData.get(propName))) const response = await upload(url, formDataLocal) if (!response.ok) { diff --git a/src/context/Context.js b/src/context/Context.js deleted file mode 100755 index ea1c502..0000000 --- a/src/context/Context.js +++ /dev/null @@ -1,5 +0,0 @@ -import {createContext} from 'react' - -const Context = createContext() - -export default Context \ No newline at end of file diff --git a/src/pages/Well.jsx b/src/pages/Well.jsx index 3f998f0..e8088c4 100755 --- a/src/pages/Well.jsx +++ b/src/pages/Well.jsx @@ -19,7 +19,6 @@ import Documents from './Documents' import Telemetry from './Telemetry' import WellOperations from './WellOperations' import DrillingProgram from './DrillingProgram' -import TelemetryAnalysis from './TelemetryAnalysis' import '@styles/index.css' @@ -38,7 +37,6 @@ export const Well = memo(() => { } title={'Рапорт'} /> } title={'Аналитика'} /> } title={'Операции по скважине'} /> - {/* } title={'Операции по телеметрии'} /> */} } title={'Документы'} /> } title={'Измерения'} /> } title={'Программа бурения'} /> @@ -52,7 +50,6 @@ export const Well = memo(() => { -