From 05308cb95334cc208c11131a5228173952acbeec Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Sun, 14 May 2023 09:08:07 -0500 Subject: [PATCH] Update progress bars to be more interactive, fix multiplication by 100 bug and added completion percentage at the top --- src/App.css | 8 +++++ src/App.js | 101 ++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 94 insertions(+), 15 deletions(-) diff --git a/src/App.css b/src/App.css index 9138116..d3ffd06 100755 --- a/src/App.css +++ b/src/App.css @@ -40,6 +40,10 @@ background-color:rgba(0,80,200,0.4); } +.finalProduct{ + background-color:#152018; +} + .panel-body { background-color:black; } @@ -61,6 +65,10 @@ filter: brightness(0) invert(1); } +html{ + background-color: #212529; +} + @keyframes App-logo-spin { from { transform: rotate(0deg); diff --git a/src/App.js b/src/App.js index 991482f..153756f 100755 --- a/src/App.js +++ b/src/App.js @@ -25,7 +25,7 @@ const fuzzysort = require('fuzzysort') const parse = require('csv-parse/lib/sync') const axios = require('axios'); -const dataSplitters = [0,190,475,670] +const dataSplitters = [0,186,453,657] const BACKEND_URL = "https://projectdivar.com:4505" @@ -50,7 +50,7 @@ function Item(p){ }) } - return + return {item.name}/ {item.name} @@ -377,10 +377,15 @@ function App() { const [data3,setData3] = useState([]) const [data4,setData4] = useState([]) const [fileData,setFileData] = useState() + const [fileData2,setFileData2] = useState() const [update,setUpdate] = useState(true) const [succeeded,setSucceeded] = useState(0) const [failed,setFailed] = useState(0) const [total,setTotal] = useState(0) + const [craftsRatio,setCraftsRatio] = useState(0) + const [missingCraftsRatio,setMissingCraftsRatio] = useState(0) + const [inProgressRatio,setInProgressRatio] = useState(0) + const [missingProgressRatio,setMissingProgressRatio] = useState(0) const [completeRatio,setCompleteRatio] = useState(0) const [lastModified,setLastModified] = useState(new Date()) @@ -412,13 +417,33 @@ function App() { setData(data.data.slice(dataSplitters[0],dataSplitters[1])) setData2(data.data.slice(dataSplitters[1],dataSplitters[2])) setData3(data.data.slice(dataSplitters[2],dataSplitters[3])) - setData4(data.data.slice(dataSplitters[3],data.data.length)) - let items=0,tot=0 - for (var item of data.data){ - items+=item.obtained - tot+=item.required + let finalItems=data.data.slice(dataSplitters[0],dataSplitters[3]) + let tempFinalItems=data.data.slice(dataSplitters[3],data.data.length) + let itemsComplete=0,itemsInProgress=0,itemsCrafts=0,tot=0,totItemsInProgress=0,totCrafts=0 + for(var i=0;i0){ + itemsInProgress+=Number(item.obtained) + totItemsInProgress+=Number(item.required) + } + tot+=Number(item.required) } - setCompleteRatio(items/tot) + setMissingCraftsRatio(((totCrafts-itemsCrafts)/tot*100).toFixed(2)) + setMissingProgressRatio(((totItemsInProgress-itemsInProgress)/tot*100).toFixed(2)) + setCompleteRatio((itemsComplete/tot*100).toFixed(2)) + setInProgressRatio((itemsInProgress/tot*100).toFixed(2)) + setCraftsRatio((itemsCrafts/tot*100).toFixed(2)) }) } }) @@ -472,7 +497,7 @@ function App() { return ()=>clearInterval(interval) },[]) - const disabled=true + const disabled=false useEffect(()=>{ if (update) { @@ -482,13 +507,33 @@ function App() { setData(data.data.slice(dataSplitters[0],dataSplitters[1])) setData2(data.data.slice(dataSplitters[1],dataSplitters[2])) setData3(data.data.slice(dataSplitters[2],dataSplitters[3])) - setData4(data.data.slice(dataSplitters[3],data.data.length)) - let items=0,tot=0 - for (var item of data.data){ - items+=item.obtained - tot+=item.required + let finalItems=data.data.slice(dataSplitters[0],dataSplitters[3]) + let tempFinalItems=data.data.slice(dataSplitters[3],data.data.length) + let itemsComplete=0,itemsInProgress=0,itemsCrafts=0,tot=0,totItemsInProgress=0,totCrafts=0 + for(var i=0;i0){ + itemsInProgress+=Number(item.obtained) + totItemsInProgress+=Number(item.required) + } + tot+=Number(item.required) + } + setMissingCraftsRatio(((totCrafts-itemsCrafts)/tot*100).toFixed(2)) + setMissingProgressRatio(((totItemsInProgress-itemsInProgress)/tot*100).toFixed(2)) + setCompleteRatio((itemsComplete/tot*100).toFixed(2)) + setInProgressRatio((itemsInProgress/tot*100).toFixed(2)) + setCraftsRatio((itemsCrafts/tot*100).toFixed(2)) }) .catch((err)=>{ console.log(err.message) @@ -553,6 +598,22 @@ function App() { setTotal(d.length) },[fileData]) + useEffect(()=>{ + + const downloadData=(d,val,max)=>{ + if (val{ + setTimeout(downloadData(d,val+1,max),250) + }) + } + } + + var d = parse(fileData2,{columns:true,skip_empty_lines:true}) + console.log(d) + downloadData(d,0,d.length) + },[fileData2]) + function Importer(){ return @@ -597,9 +658,16 @@ function App() { nav==="main"? data.length>0? <> + +

{Number(completeRatio)+Number(inProgressRatio)+Number(craftsRatio)}% complete

+
+ + + + @@ -608,6 +676,9 @@ function App() { { if (f.currentTarget.value.length>2){ setMatchedItems(fuzzysort.go(f.currentTarget.value.trim().toLowerCase(), [...data,...data2,...data3,...data4], {key:'name'})) + } else + if (f.currentTarget.value.length==0){ + setMatchedItems([]) } }} /> {matchedItems.map((item)=>)}