mirror of
https://github.com/Ai-hack-MAGNUM-OPUS/frontend.git
synced 2024-11-25 02:53:49 +03:00
add score
This commit is contained in:
parent
12900998c8
commit
0a3bf71358
|
@ -6,15 +6,15 @@ import 'antd/dist/antd.css';
|
||||||
|
|
||||||
interface ErrorViewerIE{
|
interface ErrorViewerIE{
|
||||||
errText:string;
|
errText:string;
|
||||||
paragraph: string[];
|
paragraph: [number, string][];
|
||||||
variants?: string[];
|
variants?: string[];
|
||||||
num: number;
|
num: number;
|
||||||
correct:boolean
|
correct:boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{
|
export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
console.log(props.paragraph)
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div className={styles.viewer}>
|
<div className={styles.viewer}>
|
||||||
|
@ -41,8 +41,9 @@ export const ErrorViewer : React.FC<ErrorViewerIE> = (props) =>{
|
||||||
{
|
{
|
||||||
props.paragraph.map(
|
props.paragraph.map(
|
||||||
(value, index)=><div className={styles.paragraph}>
|
(value, index)=><div className={styles.paragraph}>
|
||||||
<div>№{index+1}</div>
|
<div><strong>№{index+1}</strong></div>
|
||||||
<div className={styles.paragraph}>{value}</div>
|
<div className={styles.paragraph}>{value[0]}</div>
|
||||||
|
<div><strong>Score:{value[1]}</strong></div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React, { useState } from "react";
|
||||||
import { Button, message, Upload } from "antd"
|
import { Button, message, Upload } from "antd"
|
||||||
import Icon, { UploadOutlined } from '@ant-design/icons';
|
import Icon, { UploadOutlined } from '@ant-design/icons';
|
||||||
import 'antd/dist/antd.css';
|
import 'antd/dist/antd.css';
|
||||||
|
import { host } from "../../pages/api/consts";
|
||||||
|
|
||||||
|
|
||||||
interface FileUploaderIE{
|
interface FileUploaderIE{
|
||||||
|
@ -12,7 +13,7 @@ export const FileUploader:React.FC<FileUploaderIE> = (data) =>{
|
||||||
|
|
||||||
const props = {
|
const props = {
|
||||||
name: 'file',
|
name: 'file',
|
||||||
action: 'http://192.168.9.152:8000/api/docx/',
|
action: host + '/api/site/docx/',
|
||||||
headers: {
|
headers: {
|
||||||
authorization: 'authorization-text',
|
authorization: 'authorization-text',
|
||||||
},
|
},
|
||||||
|
|
89
pages/files.tsx
Normal file
89
pages/files.tsx
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
import type { NextPage } from 'next'
|
||||||
|
import Head from 'next/head'
|
||||||
|
import { ErrorViewer } from '../Components/ErrorViewer'
|
||||||
|
import { FileUploader } from '../Components/FileUploader'
|
||||||
|
import { Header } from '../Components/header'
|
||||||
|
import styles from '../styles/Home.module.css'
|
||||||
|
import 'antd/dist/antd.css';
|
||||||
|
import { ItemSelect, SelectItemIE } from '../Components/ItemSelect'
|
||||||
|
import { useState } from 'react'
|
||||||
|
import { get } from './api/fetch'
|
||||||
|
import { host } from './api/consts'
|
||||||
|
import { PulseLoader } from 'react-spinners'
|
||||||
|
import axios from 'axios'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const Home: NextPage = () => {
|
||||||
|
|
||||||
|
let files = JSON.parse(localStorage.getItem("files") as string)
|
||||||
|
const [file, setFile] = useState(files[0].uuid)
|
||||||
|
const [data,setData] = useState("")
|
||||||
|
let i = 1;
|
||||||
|
let cards = new Array<JSX.Element>()
|
||||||
|
|
||||||
|
const getData = () =>{
|
||||||
|
if (data == ""){
|
||||||
|
axios.get(host+"/api/site/docx/" + file).then(res => {
|
||||||
|
setData(res.data)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const onFileChange = (newFile:any) =>{
|
||||||
|
setData("")
|
||||||
|
axios.get(host+"/api/site/docx/" + newFile).then(res => {
|
||||||
|
setData(res.data)
|
||||||
|
})
|
||||||
|
setFile(newFile)
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(getData, 2000);
|
||||||
|
if (data != ""){
|
||||||
|
for(var name in data as any) {
|
||||||
|
cards.push(
|
||||||
|
<ErrorViewer
|
||||||
|
num={i}
|
||||||
|
paragraph={(data as any)[name][0]==undefined? [["Выявлено отсутсвие данного модуля"]]:(data as any)[name]}
|
||||||
|
errText={name}
|
||||||
|
correct={(data as any)[name][0]==undefined? false:true}
|
||||||
|
></ErrorViewer>
|
||||||
|
)
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let select = new Array<SelectItemIE>()
|
||||||
|
files.forEach((value : any) => {
|
||||||
|
select.push(
|
||||||
|
{
|
||||||
|
name: value.file.slice(48, value.uuid.lenght),
|
||||||
|
value: value.uuid
|
||||||
|
} as SelectItemIE
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.container}>
|
||||||
|
<Head>
|
||||||
|
<title>Загрузите файл</title>
|
||||||
|
<meta name="description" content="Generated by create next app" />
|
||||||
|
<link rel="icon" href="/favicon.ico" />
|
||||||
|
</Head>
|
||||||
|
<main className={styles.main}>
|
||||||
|
<Header></Header>
|
||||||
|
|
||||||
|
<div className={styles.selector}>
|
||||||
|
<ItemSelect
|
||||||
|
onChange={(val)=>onFileChange(val as any)}
|
||||||
|
items={select}
|
||||||
|
></ItemSelect>
|
||||||
|
</div>
|
||||||
|
<div className={styles.pagination}>
|
||||||
|
{data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards}
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Home
|
|
@ -20,12 +20,13 @@ const History: NextPage = () => {
|
||||||
const [data, setData] = useState("")
|
const [data, setData] = useState("")
|
||||||
let router = useRouter()
|
let router = useRouter()
|
||||||
if (data == ""){
|
if (data == ""){
|
||||||
axios.get(host+"/api/docx").then(res => {
|
axios.get(host+"/api/site/docx/").then(res => {
|
||||||
setData(res.data)
|
setData(res.data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (data != ""){
|
if (data != ""){
|
||||||
(data as any).forEach((value:any) => {
|
(data as any).forEach((value:any) => {
|
||||||
|
localStorage.setItem(value.uuid, value.file)
|
||||||
files.push(
|
files.push(
|
||||||
<div className={styles.fileCard} onClick={()=>router.push("/view/" + value.uuid)}>
|
<div className={styles.fileCard} onClick={()=>router.push("/view/" + value.uuid)}>
|
||||||
{value.file.slice(48, value.file.lenght)}
|
{value.file.slice(48, value.file.lenght)}
|
||||||
|
|
|
@ -7,83 +7,36 @@ import styles from '../styles/Home.module.css'
|
||||||
import 'antd/dist/antd.css';
|
import 'antd/dist/antd.css';
|
||||||
import { ItemSelect, SelectItemIE } from '../Components/ItemSelect'
|
import { ItemSelect, SelectItemIE } from '../Components/ItemSelect'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { get } from './api/fetch'
|
import { useRouter } from 'next/router'
|
||||||
import { host } from './api/consts'
|
|
||||||
import { PulseLoader } from 'react-spinners'
|
|
||||||
import axios from 'axios'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const Home: NextPage = () => {
|
const Upload: NextPage = () => {
|
||||||
|
const [files, setFiles] = useState(new Array())
|
||||||
|
let router = useRouter()
|
||||||
|
|
||||||
let files = JSON.parse(localStorage.getItem("files") as string)
|
const onNext = () =>{
|
||||||
const [file, setFile] = useState(files[0].uuid)
|
localStorage.setItem("files", JSON.stringify(files))
|
||||||
const [data,setData] = useState("")
|
router.push("/files")
|
||||||
let i = 1;
|
|
||||||
let cards = new Array<JSX.Element>()
|
|
||||||
|
|
||||||
const getData = () =>{
|
|
||||||
if (data == ""){
|
|
||||||
axios.get(host+"/api/docx/" + file).then(res => {
|
|
||||||
setData(res.data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const onFileChange = (newFile:any) =>{
|
|
||||||
setData("")
|
|
||||||
axios.get(host+"/api/docx/" + newFile).then(res => {
|
|
||||||
setData(res.data)
|
|
||||||
})
|
|
||||||
setFile(newFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(getData, 2000);
|
|
||||||
if (data != ""){
|
|
||||||
for(var name in data as any) {
|
|
||||||
cards.push(
|
|
||||||
<ErrorViewer
|
|
||||||
num={i}
|
|
||||||
paragraph={(data as any)[name][0]==undefined? ["Выявлено отсутсвие данного модуля"]:(data as any)[name]}
|
|
||||||
errText={name}
|
|
||||||
correct={(data as any)[name][0]==undefined? false:true}
|
|
||||||
></ErrorViewer>
|
|
||||||
)
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let select = new Array<SelectItemIE>()
|
|
||||||
files.forEach((value : any) => {
|
|
||||||
select.push(
|
|
||||||
{
|
|
||||||
name: value.file.slice(48, value.uuid.lenght),
|
|
||||||
value: value.uuid
|
|
||||||
} as SelectItemIE
|
|
||||||
)
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<Head>
|
<Head>
|
||||||
<title>Загрузите файл</title>
|
<title>Create Next App</title>
|
||||||
<meta name="description" content="Generated by create next app" />
|
<meta name="description" content="Generated by create next app" />
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<link rel="icon" href="/favicon.ico" />
|
||||||
</Head>
|
</Head>
|
||||||
<main className={styles.main}>
|
<main className={styles.main}>
|
||||||
<Header></Header>
|
<Header></Header>
|
||||||
|
<div className={styles.upload}>
|
||||||
|
<FileUploader onResponse={(file)=>setFiles([...files, file])}></FileUploader>
|
||||||
|
<div className={styles.btn} onClick={()=>onNext()}>Далее</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className={styles.selector}>
|
|
||||||
<ItemSelect
|
|
||||||
onChange={(val)=>onFileChange(val as any)}
|
|
||||||
items={select}
|
|
||||||
></ItemSelect>
|
|
||||||
</div>
|
|
||||||
<div className={styles.pagination}>
|
|
||||||
{data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards}
|
|
||||||
</div>
|
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Home
|
export default Upload
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
import type { NextPage } from 'next'
|
|
||||||
import Head from 'next/head'
|
|
||||||
import { ErrorViewer } from '../Components/ErrorViewer'
|
|
||||||
import { FileUploader } from '../Components/FileUploader'
|
|
||||||
import { Header } from '../Components/header'
|
|
||||||
import styles from '../styles/Home.module.css'
|
|
||||||
import 'antd/dist/antd.css';
|
|
||||||
import { ItemSelect, SelectItemIE } from '../Components/ItemSelect'
|
|
||||||
import { useState } from 'react'
|
|
||||||
import { useRouter } from 'next/router'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const Upload: NextPage = () => {
|
|
||||||
const [files, setFiles] = useState(new Array())
|
|
||||||
let router = useRouter()
|
|
||||||
|
|
||||||
const onNext = () =>{
|
|
||||||
localStorage.setItem("files", JSON.stringify(files))
|
|
||||||
router.push("/")
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className={styles.container}>
|
|
||||||
<Head>
|
|
||||||
<title>Create Next App</title>
|
|
||||||
<meta name="description" content="Generated by create next app" />
|
|
||||||
<link rel="icon" href="/favicon.ico" />
|
|
||||||
</Head>
|
|
||||||
<main className={styles.main}>
|
|
||||||
<Header></Header>
|
|
||||||
<div className={styles.upload}>
|
|
||||||
<FileUploader onResponse={(file)=>setFiles([...files, file])}></FileUploader>
|
|
||||||
<div className={styles.btn} onClick={()=>onNext()}>Далее</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Upload
|
|
|
@ -24,7 +24,7 @@ const View: NextPage = () => {
|
||||||
|
|
||||||
const getData = () =>{
|
const getData = () =>{
|
||||||
if (data == ""){
|
if (data == ""){
|
||||||
axios.get(host+"/api/docx/" + uuid).then(res => {
|
axios.get(host+"/api/site/docx/" + uuid).then(res => {
|
||||||
setData(res.data)
|
setData(res.data)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ const View: NextPage = () => {
|
||||||
cards.push(
|
cards.push(
|
||||||
<ErrorViewer
|
<ErrorViewer
|
||||||
num={i}
|
num={i}
|
||||||
paragraph={(data as any)[name][0]==undefined? ["Выявлено отсутсвие данного модуля"]:(data as any)[name]}
|
paragraph={(data as any)[name][0]==undefined? [["Выявлено отсутсвие данного модуля"]]:(data as any)[name]}
|
||||||
errText={name}
|
errText={name}
|
||||||
correct={(data as any)[name][0]==undefined? false:true}
|
correct={(data as any)[name][0]==undefined? false:true}
|
||||||
></ErrorViewer>
|
></ErrorViewer>
|
||||||
|
@ -56,6 +56,14 @@ const View: NextPage = () => {
|
||||||
<Header></Header>
|
<Header></Header>
|
||||||
|
|
||||||
<div className={styles.uploader}>
|
<div className={styles.uploader}>
|
||||||
|
<div>
|
||||||
|
<div onClick={()=>router.back()}>
|
||||||
|
<img style={{transform:"rotate(90deg)", cursor:"pointer"}}src="/images/arrow.svg"></img>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{localStorage.getItem(uuid)?.slice(48,localStorage.getItem(uuid)?.length)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards}
|
{data == ""? <PulseLoader color={"#13377D"}></PulseLoader>:cards}
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user