From c8050b91e55a0b2c06deff7248e4d2806bbedee0 Mon Sep 17 00:00:00 2001 From: goodmice Date: Tue, 23 Aug 2022 17:44:02 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=BD=D0=B0=D0=BB=D0=BE=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D1=82=D0=B5=D0=BB=D0=B5=D0=BC=D0=B5=D1=82=D1=80?= =?UTF-8?q?=D0=B8=D0=B9=20=D0=BF=D1=80=D0=B8=20=D1=81=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=20=D1=81=D0=BA=D0=B2=D0=B0=D0=B6=D0=B8=D0=BD=D1=8B=20*?= =?UTF-8?q?=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/factory.tsx | 29 +++++++++++++-------- src/pages/Telemetry/TelemetryView/index.jsx | 12 ++++++--- src/pages/Well.jsx | 4 ++- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/components/factory.tsx b/src/components/factory.tsx index 80ad3aa..66efdcf 100644 --- a/src/components/factory.tsx +++ b/src/components/factory.tsx @@ -53,7 +53,7 @@ export const copyToClipboard = (value: string, successText?: string, errorText?: } } -type asyncFunction = (...args: any) => Promise +type asyncFunction = (signal: AbortSignal, ...args: any) => Promise type InvokeOptions = { actionName?: string, @@ -75,23 +75,30 @@ const parseApiEror = (err: unknown, options?: InvokeOptions) => { } } -export const invokeWebApiWrapperAsync = async ( +export const invokeWebApiWrapperAsync = ( funcAsync: asyncFunction, setShowLoader?: Dispatch>, errorNotifyText?: FunctionalValue<(err: unknown) => ReactNode>, options?: InvokeOptions, ) => { + const controller = new AbortController() + const signal = controller.signal + setShowLoader?.(true) - try{ - await funcAsync() - } catch (ex) { - if(isDev()) - console.error(ex) - if (!parseApiEror(ex, options)) + funcAsync(signal) + .then((data) => { + if (data !== false) + setShowLoader?.(false) + }) + .catch((ex) => { + setShowLoader?.(false) + if(isDev()) + console.error(ex) + if (parseApiEror(ex, options)) return notify(getFunctionalValue(errorNotifyText)(ex), 'error', options?.well) - } finally { - setShowLoader?.(false) - } + }) + + return () => controller.abort() } export const download = async (url: string, fileName?: string) => { diff --git a/src/pages/Telemetry/TelemetryView/index.jsx b/src/pages/Telemetry/TelemetryView/index.jsx index c0c0242..3b37f3b 100755 --- a/src/pages/Telemetry/TelemetryView/index.jsx +++ b/src/pages/Telemetry/TelemetryView/index.jsx @@ -143,6 +143,7 @@ const TelemetryView = memo(() => { const [dataSpin, setDataSpin] = useState([]) const [chartInterval, setChartInterval] = useState(defaultPeriod) const [showLoader, setShowLoader] = useState(false) + const [isDataLoading, setIsDataLoading] = useState(false) const [flowChartData, setFlowChartData] = useState([]) const [rop, setRop] = useState(null) const [domain, setDomain] = useState({}) @@ -183,19 +184,23 @@ const TelemetryView = memo(() => { }, [spinSubject$]) useEffect(() => { - invokeWebApiWrapperAsync( - async () => { + const cancel = invokeWebApiWrapperAsync( + async (signal) => { + if (signal.aborted) return false const flowChart = await DrillFlowChartService.getByIdWell(well.id) const dataSaub = await TelemetryDataSaubService.getData(well.id, null, chartInterval) const dataSpin = await TelemetryDataSpinService.getData(well.id, null, chartInterval) + if (signal.aborted) return false setFlowChartData(flowChart ?? []) handleDataSaub(dataSaub) handleDataSpin(dataSpin) }, - null, + setIsDataLoading, `Не удалось получить данные`, { actionName: 'Получение данных по скважине', well } ) + + return () => cancel() }, [well, chartInterval, handleDataSpin, handleDataSaub]) useEffect(() => { @@ -282,6 +287,7 @@ const TelemetryView = memo(() => { { { actionName: 'Изменение данных скважины', well } ), [well]) + const wellContext = useMemo(() => [well, updateWell], [well, updateWell]) + return ( @@ -70,7 +72,7 @@ const Well = memo(() => { } /> - + From bd7c2842c584b02ecea72999e9ee34ed47002416 Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 12 Sep 2022 12:40:59 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=20?= =?UTF-8?q?=D0=BE=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B8=20=D0=BE=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D1=86=D0=B8=D0=B9=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B4?= =?UTF-8?q?=20=D0=B8=D0=BC=D0=BF=D0=BE=D1=80=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/WellOperations/ImportOperations.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/WellOperations/ImportOperations.jsx b/src/pages/WellOperations/ImportOperations.jsx index cc0062b..304be1a 100755 --- a/src/pages/WellOperations/ImportOperations.jsx +++ b/src/pages/WellOperations/ImportOperations.jsx @@ -6,7 +6,7 @@ import { ErrorFetch } from '@components/ErrorFetch' import { UploadForm } from '@components/UploadForm' const errorTextStyle = { color: 'red', fontWeight: 'bold' } -const uploadFormStyle = { marginTop: '24px' } +const uploadFormStyle = { marginTop: 24 } export const ImportOperations = memo(({ well: givenWell, onDone }) => { const [deleteBeforeImport, setDeleteBeforeImport] = useState(false) @@ -15,7 +15,7 @@ export const ImportOperations = memo(({ well: givenWell, onDone }) => { const [wellContext] = useWell() const well = useMemo(() => givenWell ?? wellContext, [givenWell, wellContext]) - const url = useMemo(() => `/api/well/${well.id}/wellOperations/import${deleteBeforeImport ? '/1' : '/0'}`, [well]) + const url = useMemo(() => `/api/well/${well.id}/wellOperations/import/${deleteBeforeImport ? 1 : 0}`, [well, deleteBeforeImport]) const onUploadSuccess = useCallback(() => { setErrorText('') From eb8cf1f1d425b238396567f4004f34f06c325c28 Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 12 Sep 2022 13:21:37 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20=D0=B8=20?= =?UTF-8?q?=D0=BB=D0=BE=D0=B3=D0=BE=D1=82=D0=B8=D0=BF=20=D0=B2=20=D1=88?= =?UTF-8?q?=D0=B0=D0=BF=D0=BA=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- src/images/Logo.tsx | 8 +++++--- src/images/dd_logo_white_opt.svg | 1 + src/styles/App.less | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 src/images/dd_logo_white_opt.svg diff --git a/public/index.html b/public/index.html index cd94b2e..492d903 100755 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,7 @@ - АСБ Vision + DDrilling diff --git a/src/images/Logo.tsx b/src/images/Logo.tsx index 88e8540..216a81b 100755 --- a/src/images/Logo.tsx +++ b/src/images/Logo.tsx @@ -1,9 +1,11 @@ import { memo } from 'react' -import logo from '@images/logo_32.png' +import { ReactComponent as AsbLogo } from '@images/dd_logo_white_opt.svg' -export const Logo = memo, HTMLImageElement>>((props) => ( - {'АСБ'} +export type LogoProps = React.SVGProps & { size?: number } + +export const Logo = memo(({ size = 200, ...props }) => ( + )) export default Logo diff --git a/src/images/dd_logo_white_opt.svg b/src/images/dd_logo_white_opt.svg new file mode 100644 index 0000000..d19dc00 --- /dev/null +++ b/src/images/dd_logo_white_opt.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/styles/App.less b/src/styles/App.less index cc55b30..0b8e681 100755 --- a/src/styles/App.less +++ b/src/styles/App.less @@ -74,7 +74,7 @@ html { .header .title{ flex-grow: 1; color: #fff; - padding-left: 450px; + padding-left: calc(100vw / 2 - 400px); } .header button{