ConfigProvider перенесен в App.

This commit is contained in:
Фролов 2021-08-17 13:01:13 +05:00
parent 2ae5e896ed
commit 73d59ae03d
7 changed files with 53 additions and 58 deletions

View File

@ -3,6 +3,8 @@ import {
BrowserRouter as Router,
Switch,
Route} from "react-router-dom"
import {ConfigProvider} from 'antd'
import locale from "antd/lib/locale/ru_RU"
import Login from './pages/Login'
import Main from './pages/Main'
import { OpenAPI } from './services/api'
@ -13,7 +15,8 @@ OpenAPI.TOKEN = localStorage['token']
export default function App() {
return (
<Router>
<ConfigProvider locale={locale}>
<Router>
<Switch>
<Route path="/login">
<Login />
@ -22,6 +25,7 @@ export default function App() {
<Main />
</PrivateRoute>
</Switch>
</Router>
)
</Router>
</ConfigProvider>
);
}

View File

@ -1,10 +1,9 @@
import { useParams } from "react-router-dom"
import { DatePicker, ConfigProvider } from 'antd';
import { DatePicker } from 'antd';
import notify from "../components/notify"
import { useState, useEffect } from 'react'
import { TelemetryAnalyticsService } from '../services/api'
import { ChartOperationTime } from './charts/ChartOperationTime'
import locale from "antd/lib/locale/ru_RU";
import LoaderPortal from '../components/LoaderPortal'
import moment from 'moment'
@ -46,12 +45,10 @@ export function AnalysisOperationTime() {
return (
<LoaderPortal show={loader}>
<ConfigProvider locale={locale}>
<RangePicker
showTime
onChange={onChangeRange}
/>
</ConfigProvider>
<RangePicker
showTime
onChange={onChangeRange}
/>
<ChartOperationTime
data={operationTimeData}
lines={lines}

View File

@ -3,7 +3,7 @@ import { UploadOutlined} from '@ant-design/icons'
import { useState } from 'react'
import { upload } from './factory'
export default function UploadFileForm({url, onUploadStart, onUploadComplete, onUploadError}) {
export default function UploadForm({url, onUploadStart, onUploadComplete, onUploadError}) {
const [isSubmitButtonEnabled, setSubmitButtonEnabled] = useState(false)
const [form] = Form.useForm();
@ -13,7 +13,7 @@ export default function UploadFileForm({url, onUploadStart, onUploadComplete, on
try {
const values = await form.validateFields();
const formData = new FormData()
values.documentFile.fileList.forEach((val) => {
values.file.fileList.forEach((val) => {
formData.append("files", val.originFileObj);
});
await upload(url, formData)

View File

@ -2,13 +2,11 @@ import { useRef, useLayoutEffect, useState, useEffect } from 'react'
import {
Button,
DatePicker,
ConfigProvider,
Row,
Col,
Tooltip} from 'antd'
import { useParams } from 'react-router-dom'
import { DataService } from '../services/api'
import locale from 'antd/lib/locale/ru_RU'
import {generateUUID} from '../services/UidGenerator'
import { ArchiveColumn } from '../components/ArchiveColumn'
import moment from 'moment'
@ -133,14 +131,12 @@ export default function Archive() {
+
</Button>
</Tooltip>
<ConfigProvider locale={locale}>
<RangePicker
showTime
allowClear={false}
onChange = {onChangeRange}
value = {rangeDate}
/>
</ConfigProvider>
<RangePicker
showTime
allowClear={false}
onChange = {onChangeRange}
value = {rangeDate}
/>
<LoaderPortal show={loader}>
<Row ref={chartsContainerRef}>
{charts}

View File

@ -1,10 +1,9 @@
import {useState, useEffect} from "react"
import {Table, DatePicker, Button, ConfigProvider} from 'antd'
import locale from "antd/lib/locale/ru_RU"
import {Table, DatePicker, Button, Form} from 'antd'
import moment from 'moment'
import { FileService } from '../../services/api'
import { updateFromWebApiWrapperAsync, download, makePaginationObject} from '../../components/factory'
import UploadFileForm from '../../components/UploadFileForm'
import UploadForm from '../../components/UploadForm'
import LoaderPortal from '../../components/LoaderPortal'
const pageSize = 12
@ -17,7 +16,7 @@ export default function DocumentsTemplate({idCategory, idWell}) {
const [files, setFiles] = useState([])
const [showLoader, setShowLoader] = useState(false)
const uploadUrl = `/api/well/${idWell}/files/`
const uploadUrl = `/api/well/${idWell}/files/?idCategory=${idCategory}`
const handleFileNameCLick = async (_, row) => {
updateFromWebApiWrapperAsync(async ()=>{
@ -83,20 +82,25 @@ export default function DocumentsTemplate({idCategory, idWell}) {
return (
<LoaderPortal show={showLoader}>
<UploadFileForm
url={uploadUrl}
onUploadStart={()=>setShowLoader(true)}
onUploadComplete={()=>setShowLoader(false)}
/>
<div className='filter-group'>
<h3 className='filter-group-heading'>Фильтр документов:</h3>
<ConfigProvider locale={locale}>
<RangePicker
showTime
onChange={setRange}
/>
</ConfigProvider>
</div>
<Form
layout="vertical">
<div className='d-flex'>
<Form.Item
label="Фильтр документов">
<RangePicker
showTime
onChange={setRange}/>
</Form.Item>
<Form.Item
label="Загрузка документов">
<UploadForm
url={uploadUrl}
onUploadStart={()=>setShowLoader(true)}
onUploadComplete={()=>setShowLoader(false)}/>
</Form.Item>
</div>
</Form>
<Table
columns={columns}
dataSource={files}

View File

@ -1,5 +1,4 @@
import {Table, Select, DatePicker, ConfigProvider, Input} from 'antd';
import locale from "antd/lib/locale/ru_RU";
import {Table, Select, DatePicker, Input} from 'antd';
import {useState, useEffect} from 'react'
import moment from 'moment'
@ -137,12 +136,10 @@ export default function Messages({idWell}) {
onChange={setCategories}>
{children}
</Select>
<ConfigProvider locale={locale}>
<RangePicker
showTime
onChange={onChangeRange}
/>
</ConfigProvider>
<RangePicker
showTime
onChange={onChangeRange}
/>
<Search
className="filter-selector"
placeholder="Фильтр сообщений по тексту"

View File

@ -1,10 +1,9 @@
import { Table, Select, DatePicker, ConfigProvider } from "antd";
import { Table, Select, DatePicker } from "antd";
import { TelemetryAnalyticsService } from "../services/api";
import { useState, useEffect } from "react";
import { useParams } from "react-router-dom";
import notify from "../components/notify";
import LoaderPortal from "../components/LoaderPortal";
import locale from "antd/lib/locale/ru_RU";
import moment from "moment";
import "../styles/message.css";
@ -138,13 +137,11 @@ export default function WellAnalysis() {
>
{children}
</Select>
<ConfigProvider locale={locale}>
<RangePicker
showTime
placeholder={["Дата начала операции", "Дата окончания операции"]}
onChange={onChangeRange}
/>
</ConfigProvider>
<RangePicker
showTime
placeholder={["Дата начала операции", "Дата окончания операции"]}
onChange={onChangeRange}
/>
</div>
<LoaderPortal show={loader}>
<Table