fix bugs and deploy

This commit is contained in:
Firesieht 2022-08-28 11:05:58 +03:00
parent 9b907cbb0d
commit 301ca255d0
6 changed files with 32 additions and 21 deletions

View File

@ -25,26 +25,23 @@ const Home: NextPage = () => {
let i = 1; let i = 1;
let cards = new Array<JSX.Element>() let cards = new Array<JSX.Element>()
let correctClasses = 0 let correctClasses = 0
let select = new Array<SelectItemIE>()
const getData = () =>{ const getData = () =>{
let localFiles = JSON.parse(localStorage == undefined? "":localStorage.getItem("files") as string) let localFiles = JSON.parse(localStorage == undefined? "":localStorage.getItem("files") as string)
setFiles(localFiles) setFiles(localFiles)
setFile(localFiles[0]) setFile(localFiles[0])
if (data == ""){ if (data == ""){
axios.get(host+"/api/site/docx/" + (localFiles[0] as any).uuid).then(res => { axios.get(host+"/api/site/state/" + (localFiles[0] as any).uuid).then(res => {
setData(res.data) if (res.data.paragraphs_processed > 0){
setTimeout(getData, 1000);
}
else{
axios.get(host+"/api/site/docx/" + (localFiles[0] as any).uuid).then(res => {
setData(res.data)
})
}
}) })
} }
files.forEach((value : any) => {
select.push(
{
name: value.file.slice(48, value.uuid.lenght),
value: value
} as SelectItemIE
)
});
} }
const onFileChange = (newFile:any) =>{ const onFileChange = (newFile:any) =>{
setData("") setData("")
@ -53,8 +50,9 @@ const getData = () =>{
}) })
setFile(newFile) setFile(newFile)
} }
if (data == ""){
setTimeout(getData, 2000); setTimeout(getData, 2000);
}
if (data != ""){ if (data != ""){
for(var name in data as any) { for(var name in data as any) {
if ((data as any)[name].correct){correctClasses++} if ((data as any)[name].correct){correctClasses++}
@ -88,11 +86,17 @@ const getData = () =>{
<main className={styles.main}> <main className={styles.main}>
<Header></Header> <Header></Header>
<div className={styles.selector}> <div className={styles.selector}>{
<ItemSelect files.length == 0? "" : <ItemSelect
onChange={(val)=>onFileChange(val as any)} onChange={(val)=>onFileChange(val as any)}
items={select} items={files.map((value:any)=> ({
></ItemSelect> name: value.file.slice(60, value.uuid.lenght),
value: value
} as SelectItemIE)
)}
></ItemSelect>
}
</div> </div>
<div className={styles.pagination}> <div className={styles.pagination}>
<div className={styles.tools}> <div className={styles.tools}>

View File

@ -29,7 +29,7 @@ const History: NextPage = () => {
localStorage.setItem(value.uuid, value.file) 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(60, 88)}
</div> </div>
) )
}); });

View File

@ -17,7 +17,13 @@ const Upload: NextPage = () => {
const onNext = () =>{ const onNext = () =>{
localStorage.setItem("files", JSON.stringify(files)) localStorage.setItem("files", JSON.stringify(files))
router.push("/files") if (files.length > 0){
router.push("/files")
}
else{
alert("Загрузите файлы, потом все заработает")
}
} }
return ( return (

View File

@ -24,6 +24,7 @@ const View: NextPage = () => {
const [text, setText] = useState("") const [text, setText] = useState("")
const getData = () =>{ const getData = () =>{
if (data == ""){ if (data == ""){
axios.get(host+"/api/site/docx/" + uuid).then(res => { axios.get(host+"/api/site/docx/" + uuid).then(res => {
setData(res.data) setData(res.data)
}) })

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 130 KiB