|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import './App.css'; |
|
|
|
|
import 'bootstrap/dist/css/bootstrap.min.css'; |
|
|
|
|
|
|
|
|
|
import { useState,useEffect } from 'react'; |
|
|
|
|
import { useState,useEffect,Fragment } from 'react'; |
|
|
|
|
|
|
|
|
|
import Container from 'react-bootstrap/Container'; |
|
|
|
|
import Row from 'react-bootstrap/Row'; |
|
|
|
@ -14,15 +14,18 @@ import ToastContainer from 'react-bootstrap/ToastContainer' |
|
|
|
|
import Toast from 'react-bootstrap/Toast' |
|
|
|
|
import Nav from 'react-bootstrap/Nav' |
|
|
|
|
import Spinner from 'react-bootstrap/Spinner'; |
|
|
|
|
import Form from 'react-bootstrap/Form'; |
|
|
|
|
|
|
|
|
|
import { FaCheckCircle } from 'react-icons/fa'; |
|
|
|
|
import { IoCheckmarkCircleOutline,IoCloseCircleSharp,IoAlertCircleOutline } from 'react-icons/io5'; |
|
|
|
|
|
|
|
|
|
const fuzzysort = require('fuzzysort') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const parse = require('csv-parse/lib/sync') |
|
|
|
|
const axios = require('axios'); |
|
|
|
|
|
|
|
|
|
const dataSplitters = [0,128,225,363] |
|
|
|
|
const dataSplitters = [0,190,475,670] |
|
|
|
|
|
|
|
|
|
const BACKEND_URL = "https://projectdivar.com:4505" |
|
|
|
|
|
|
|
|
@ -31,28 +34,8 @@ const NOTIFICATIONTIMEOUT = 300 //In seconds |
|
|
|
|
const progress1 = new Audio(process.env.PUBLIC_URL+"/progress1.mp3") |
|
|
|
|
const progress2 = new Audio(process.env.PUBLIC_URL+"/progress2.mp3") |
|
|
|
|
|
|
|
|
|
function ItemGroup(p) { |
|
|
|
|
const { data } = p |
|
|
|
|
const { contributor } = p |
|
|
|
|
const [displayData,setDisplayData] = useState([]) |
|
|
|
|
const [lockout,setLockout] = useState(false) |
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
setDisplayData([...data].sort((a,b)=>{ |
|
|
|
|
if (b.required===b.obtained&&a.required!==a.obtained) {return -1} |
|
|
|
|
if (b.required===b.obtained&&a.required===a.obtained) {return a.id-b.id} |
|
|
|
|
if (b.required!==b.obtained&&a.required!==a.obtained) {return a.id-b.id} |
|
|
|
|
return 0 |
|
|
|
|
})) |
|
|
|
|
},[data]) |
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
displayData.forEach((item)=>{ |
|
|
|
|
if (document.getElementById("field_"+item.id)) { |
|
|
|
|
document.getElementById("field_"+item.id).value=item.obtained |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
},[displayData]) |
|
|
|
|
function Item(p){ |
|
|
|
|
const {item,setLockout,contributor,lockout} = p |
|
|
|
|
|
|
|
|
|
function updateItem(item,target,contributor) { |
|
|
|
|
var correctedVal=Math.min(item.required,target.value); |
|
|
|
@ -67,10 +50,7 @@ function ItemGroup(p) { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return <Accordion.Item className="bg-dark" eventKey={p.akey}> |
|
|
|
|
<Accordion.Header className="panel-body bg-dark">{p.name}</Accordion.Header> |
|
|
|
|
<Accordion.Body className="panel-body"> |
|
|
|
|
{displayData.map((item,i,arr)=><Row key={item.id} className={"pb-1 pt-1 text-light"+(Number(item.obtained)===0?" notStarted":Number(item.obtained)===Number(item.required)?" completed":" inProgress")}> |
|
|
|
|
return <Row className={"pb-1 pt-1 text-light"+(Number(item.obtained)===0?" notStarted":Number(item.obtained)===Number(item.required)?" completed":" inProgress")}> |
|
|
|
|
<Col> |
|
|
|
|
<img src={"https://xivapi.com"+item.icon} alt={item.name}/> {item.name} |
|
|
|
|
</Col> |
|
|
|
@ -88,7 +68,36 @@ function ItemGroup(p) { |
|
|
|
|
<Col> |
|
|
|
|
<a style={{position:"relative",top:"8px"}} className="text-muted" href={"https://garlandtools.org/db/#item/"+item.itemid} target="tools">View Item Info</a> |
|
|
|
|
</Col> |
|
|
|
|
</Row>)} |
|
|
|
|
</Row> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function ItemGroup(p) { |
|
|
|
|
const { data } = p |
|
|
|
|
const { contributor } = p |
|
|
|
|
const [displayData,setDisplayData] = useState([]) |
|
|
|
|
const [lockout,setLockout] = useState(false) |
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
setDisplayData([...data].sort((a,b)=>{ |
|
|
|
|
if (b.required===b.obtained&&a.required!==a.obtained) {return -1} |
|
|
|
|
if (b.required===b.obtained&&a.required===a.obtained) {return a.id-b.id} |
|
|
|
|
if (b.required!==b.obtained&&a.required!==a.obtained) {return a.id-b.id} |
|
|
|
|
return 0 |
|
|
|
|
})) |
|
|
|
|
},[data]) |
|
|
|
|
|
|
|
|
|
useEffect(()=>{ |
|
|
|
|
displayData.forEach((item)=>{ |
|
|
|
|
if (document.getElementById("field_"+item.id)) { |
|
|
|
|
document.getElementById("field_"+item.id).value=item.obtained |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
},[displayData]) |
|
|
|
|
|
|
|
|
|
return <Accordion.Item className="bg-dark" eventKey={p.akey}> |
|
|
|
|
<Accordion.Header className="panel-body bg-dark">{p.name}</Accordion.Header> |
|
|
|
|
<Accordion.Body className="panel-body"> |
|
|
|
|
{displayData.map((item,i,arr)=><Item key={item.id} item={item} setLockout={setLockout} lockout={lockout} contributor={contributor}></Item>)} |
|
|
|
|
</Accordion.Body> |
|
|
|
|
</Accordion.Item> |
|
|
|
|
} |
|
|
|
@ -211,6 +220,7 @@ function ListApp(p){ |
|
|
|
|
let currentPage=1 |
|
|
|
|
let recipeData=[] |
|
|
|
|
setChecking(true) |
|
|
|
|
setGroceryList([]) |
|
|
|
|
axios.get(encodeURI(filter)) |
|
|
|
|
.then(async(resp)=>{ |
|
|
|
|
let data=resp.data |
|
|
|
@ -293,7 +303,7 @@ function ListApp(p){ |
|
|
|
|
function Item(p){ |
|
|
|
|
const {it} = p |
|
|
|
|
return it.amt>0&&<Row className="text-white"> |
|
|
|
|
<Col><img src={"https://xivapi.com"+it.icon}></img>{it.slot?"["+Math.floor(it.slot/35+1)+"]":""} {it.name} x{it.amt} {it.hq?"(HQ)":""}</Col> |
|
|
|
|
<Col><img src={"https://xivapi.com"+it.icon}></img>{Number.isInteger(it.slot)?"["+Math.floor(it.slot/35+1)+"]":""} {it.name} x{it.amt} {it.hq?"(HQ)":""}</Col> |
|
|
|
|
</Row> |
|
|
|
|
} |
|
|
|
|
function RetainerDisplay(p){ |
|
|
|
@ -326,18 +336,21 @@ function ListApp(p){ |
|
|
|
|
<Col xs={3}> |
|
|
|
|
<Button onKeyDown={(k)=>{if (k.key==='Enter') {submitForm()}}} disabled={checking} onClick={()=>{submitForm()}}>{checking?<Spinner animation="border"></Spinner>:"Compose"}</Button> |
|
|
|
|
</Col> |
|
|
|
|
<Col xs={1}> |
|
|
|
|
|
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|
<Row><span>A</span></Row> |
|
|
|
|
{groceryList.map((list,i)=>{ |
|
|
|
|
if (list.length>0){ |
|
|
|
|
return <> |
|
|
|
|
return <Fragment key={i}> |
|
|
|
|
<Row className="text-white"><Col>{(i===9)?<h4 style={{"color":"#AA0000"}}>Not Found:</h4>:<h4>From {retainerNames[i]}:</h4>}</Col></Row> |
|
|
|
|
<Row className="text-white"><Col> |
|
|
|
|
<ul> |
|
|
|
|
{list.map((item,j)=><li><Item it={item} key={j}></Item></li>)} |
|
|
|
|
{list.map((item,j)=><li key={j}><Item it={item}></Item></li>)} |
|
|
|
|
</ul> |
|
|
|
|
</Col></Row> |
|
|
|
|
</> |
|
|
|
|
</Fragment> |
|
|
|
|
} |
|
|
|
|
})} |
|
|
|
|
<Row><span>Inventories</span></Row> |
|
|
|
@ -368,6 +381,7 @@ function App() { |
|
|
|
|
const [succeeded,setSucceeded] = useState(0) |
|
|
|
|
const [failed,setFailed] = useState(0) |
|
|
|
|
const [total,setTotal] = useState(0) |
|
|
|
|
const [completeRatio,setCompleteRatio] = useState(0) |
|
|
|
|
const [lastModified,setLastModified] = useState(new Date()) |
|
|
|
|
|
|
|
|
|
const [contributor,setContributor] = useState("") |
|
|
|
@ -377,6 +391,10 @@ function App() { |
|
|
|
|
|
|
|
|
|
const [transferItems,setTransferItems] = useState([]) |
|
|
|
|
|
|
|
|
|
const [matchedItems,setMatchedItems] = useState([]) |
|
|
|
|
|
|
|
|
|
const [lockout,setLockout] = useState(false) |
|
|
|
|
|
|
|
|
|
function LZ(digits,numb) { |
|
|
|
|
return "0".repeat(digits-String(numb).length)+numb |
|
|
|
|
} |
|
|
|
@ -395,6 +413,12 @@ function App() { |
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
setCompleteRatio(items/tot) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
@ -410,13 +434,13 @@ function App() { |
|
|
|
|
var largestNotificationID = -1 |
|
|
|
|
var dataCheck=true |
|
|
|
|
const interval = setInterval(()=>{ |
|
|
|
|
if (dataCheck) { |
|
|
|
|
if (dataCheck&&nav==="main") { |
|
|
|
|
dataCheck=false |
|
|
|
|
notificationLastUpdate = new Date(new Date()-(NOTIFICATIONTIMEOUT*1000)) |
|
|
|
|
axios.get(BACKEND_URL+"/getNotifications?date="+encodeURIComponent(LZ(4,notificationLastUpdate.getUTCFullYear())+"-"+LZ(2,notificationLastUpdate.getUTCMonth()+1)+"-"+LZ(2,notificationLastUpdate.getUTCDate())+" "+LZ(2,notificationLastUpdate.getUTCHours())+":"+LZ(2,notificationLastUpdate.getUTCMinutes())+":"+LZ(2,notificationLastUpdate.getUTCSeconds())+"."+LZ(3,notificationLastUpdate.getUTCMilliseconds())+"+00")) |
|
|
|
|
.then((data)=>{ |
|
|
|
|
if (data.data.length>0) { |
|
|
|
|
console.log("New notification array: "+JSON.stringify(data.data)) |
|
|
|
|
//console.log("New notification array: "+JSON.stringify(data.data))
|
|
|
|
|
setNotifications(data.data) |
|
|
|
|
var completion=false |
|
|
|
|
var largestID = -1 |
|
|
|
@ -459,6 +483,12 @@ function App() { |
|
|
|
|
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 |
|
|
|
|
} |
|
|
|
|
setCompleteRatio(items/tot) |
|
|
|
|
}) |
|
|
|
|
.catch((err)=>{ |
|
|
|
|
console.log(err.message) |
|
|
|
@ -521,7 +551,29 @@ function App() { |
|
|
|
|
console.log(d) |
|
|
|
|
downloadData(d,0,d.length) |
|
|
|
|
setTotal(d.length) |
|
|
|
|
},[fileData,failed,succeeded]) |
|
|
|
|
},[fileData]) |
|
|
|
|
|
|
|
|
|
function Importer(){ |
|
|
|
|
return <Row> |
|
|
|
|
<Col> |
|
|
|
|
{total===0?<caption><label className="buttonLabel" for="uploads">Import List</label><input onChange={(f)=>{ |
|
|
|
|
const reader = new FileReader() |
|
|
|
|
reader.onload=(ev)=>{ |
|
|
|
|
setFileData(ev.target.result) |
|
|
|
|
} |
|
|
|
|
reader.readAsText(f.target.files[0]) |
|
|
|
|
}} style={{opacity:0}} id="uploads" type="file" accept=".txt,.csv"/></caption>: |
|
|
|
|
<> |
|
|
|
|
<ProgressBar> |
|
|
|
|
<ProgressBar animated striped variant="success" now={Math.round(succeeded/total)*100} /> |
|
|
|
|
<ProgressBar animated striped variant="danger" now={Math.round(failed/total)*100} /> |
|
|
|
|
</ProgressBar> |
|
|
|
|
<div className="text-center">{Math.round(((failed+succeeded)/total)*100)+"%"}</div> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Container className="bg-dark" fluid> |
|
|
|
@ -545,35 +597,31 @@ function App() { |
|
|
|
|
nav==="main"? |
|
|
|
|
data.length>0? |
|
|
|
|
<> |
|
|
|
|
<Row> |
|
|
|
|
<ProgressBar className="bg-dark text-white"> |
|
|
|
|
<ProgressBar animated striped variant="success" label={`${completeRatio}%`} now={completeRatio} /> |
|
|
|
|
</ProgressBar> |
|
|
|
|
</Row> |
|
|
|
|
<Row> |
|
|
|
|
<Form> |
|
|
|
|
<Form.Group className="mb-3" controlId="formBasicEmail"> |
|
|
|
|
<Form.Control className="bg-dark text-white" type="text" placeholder="Search Item" onChange={(f)=>{ |
|
|
|
|
if (f.currentTarget.value.length>2){ |
|
|
|
|
setMatchedItems(fuzzysort.go(f.currentTarget.value.trim().toLowerCase(), [...data,...data2,...data3,...data4], {key:'name'})) |
|
|
|
|
} |
|
|
|
|
}} /> |
|
|
|
|
{matchedItems.map((item)=><Item key={item.obj.id} item={item.obj} setLockout={setLockout} lockout={lockout} contributor={contributor}></Item>)} |
|
|
|
|
</Form.Group> |
|
|
|
|
</Form> |
|
|
|
|
</Row> |
|
|
|
|
<Accordion className="bg-dark" defaultActiveKey="0"> |
|
|
|
|
<ItemGroup name="Gathering Items" contributor={contributor} akey="0" data={data} lastModified={lastModified} setLastModified={setLastModified} setData={setData} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
|
<ItemGroup name="Other Items" contributor={contributor} akey="1" data={data2} lastModified={lastModified} setLastModified={setLastModified} setData={setData2} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
|
<ItemGroup name="Pre-crafting" contributor={contributor} akey="2" data={data3} lastModified={lastModified} setLastModified={setLastModified} setData={setData3} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
|
<ItemGroup name="Crafting Items" contributor={contributor} akey="3" data={data4} lastModified={lastModified} setLastModified={setLastModified} setData={setData4} setData1={setData} setData2={setData2} setData3={setData3} setData4={setData4}/> |
|
|
|
|
</Accordion> |
|
|
|
|
</>: |
|
|
|
|
!disabled&& |
|
|
|
|
<Row> |
|
|
|
|
<Col> |
|
|
|
|
{total===0?<caption><label className="buttonLabel" for="uploads">Import List</label><input onChange={(f)=>{ |
|
|
|
|
const reader = new FileReader() |
|
|
|
|
reader.onload=(ev)=>{ |
|
|
|
|
setFileData(ev.target.result) |
|
|
|
|
} |
|
|
|
|
reader.readAsText(f.target.files[0]) |
|
|
|
|
}} style={{opacity:0}} id="uploads" type="file" accept=".txt,.csv"/></caption>: |
|
|
|
|
<> |
|
|
|
|
<ProgressBar> |
|
|
|
|
<ProgressBar animated striped variant="success" now={Math.round(succeeded/total)*100} /> |
|
|
|
|
<ProgressBar animated striped variant="danger" now={Math.round(failed/total)*100} /> |
|
|
|
|
</ProgressBar> |
|
|
|
|
<div className="text-center">{Math.round(((failed+succeeded)/total)*100)+"%"}</div> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
</Col> |
|
|
|
|
</Row> |
|
|
|
|
: |
|
|
|
|
nav==="list"?<ListApp transferItems={transferItems}></ListApp>: |
|
|
|
|
</>:<Importer></Importer> |
|
|
|
|
:nav==="list"?<ListApp transferItems={transferItems}></ListApp>: |
|
|
|
|
<></> |
|
|
|
|
} |
|
|
|
|
<div style={{pointerEvents:"none",position:"fixed",top:"0px",left:"0px",width:"100%",height:"100%"}}> |
|
|
|
|