From 4ddf3da42d352bf58f390c3fed98c3c3492d5ab5 Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Wed, 25 Aug 2021 19:48:25 +0900 Subject: [PATCH 1/2] Add in routes for saving/identifying builds. --- src/App.js | 48 ++++++++++++++++++++++++++++++++++++++++-------- src/TestPanel.js | 29 +++++++++++++++++++++++++++-- 2 files changed, 67 insertions(+), 10 deletions(-) diff --git a/src/App.js b/src/App.js index af55dfa..138a554 100644 --- a/src/App.js +++ b/src/App.js @@ -12,7 +12,8 @@ import { HashRouter, Switch, Route, - useHistory + useHistory, + useParams } from "react-router-dom"; import { HashLink as Link } from 'react-router-hash-link'; @@ -809,7 +810,9 @@ function App() { const [LOGGEDINUSER,setLOGGEDINUSER] = useState("") const [LOGGEDINHASH,setLOGGEDINHASH] = useState("") - const [BUILDID,setBUILDID] = useState(undefined) + + const PANELPATHWBUILD = process.env.PUBLIC_URL+"/test/:BUILDID" + const PANELPATH = process.env.PUBLIC_URL+"/test" function GetData(table,row,col,id){ if (row===undefined) {row=''} @@ -857,12 +860,43 @@ function App() { - - - {"Test - "+APP_TITLE} - + + + + + diff --git a/src/TestPanel.js b/src/TestPanel.js index f2917ba..d4c953c 100644 --- a/src/TestPanel.js +++ b/src/TestPanel.js @@ -4,6 +4,9 @@ import { DisplayIcon } from './DEFAULTS'; import { ExpandTooltip } from './components/ExpandTooltip'; import { SkillTree } from './skilltree/skillTree'; import axios from 'axios'; +import Helmet from 'react-helmet' + +import { useLocation,useHistory,useParams,matchPath } from 'react-router'; //Helper variables for Weapon selector with structure: [weapon_type,weapon,potential,potential_tooltip,weapon_existence_data] const WEAPON_WEAPONTYPE=0;const WEAPON_WEAPON=1;const WEAPON_POTENTIAL=2;const WEAPON_POTENTIAL_TOOLTIP=3;const WEAPON_EXISTENCE_DATA=4; @@ -288,7 +291,12 @@ function SkillTreeContainer(p){ function TestPanel(p) { -const { GetData,LOGGEDINUSER,BUILDID,BACKENDURL,setBUILDID } = p + +let { BUILDID } = useParams() +let history = useHistory(); +let location = useLocation(); + +const { GetData,LOGGEDINUSER,BACKENDURL,APP_TITLE } = p const [bpGraphMax,setbpGraphMax] = useState(1000) const [hpGraphMax,sethpGraphMax] = useState(1000) @@ -350,10 +358,19 @@ function SaveData() { class2:subclassName, data:JSON.stringify(saveObj),}) .then((data)=>{ - setBUILDID(data.data.id) + const match=matchPath(location.pathname,{ + path:p.path, + exact:true, + strict:false + }) + history.push(match.path.replace("/:BUILDID","")+"/"+data.data.id) }) } +function LoadData() { + +} + function rarityCheck(v) { return v!==undefined?v.rarity!==undefined?" r"+v.rarity:"":"" } @@ -389,9 +406,17 @@ useEffect(()=>{ setSkillPointData(pointsDataArr) },[className,GetData]) +useEffect(()=>{ + console.log(BUILDID) +},[BUILDID]) + //console.log(p.GetData("class",p.className,"icon")) return (<> + + + {"Test - "+APP_TITLE+(BUILDID?" Build #"+BUILDID:"")} +
From a7c34fdb00f1e9752330dc2b8555e95ffc2c526f Mon Sep 17 00:00:00 2001 From: Joshua Sigona Date: Wed, 25 Aug 2021 19:54:11 +0900 Subject: [PATCH 2/2] Include user password support. --- src/App.js | 2 ++ src/TestPanel.js | 15 +++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/App.js b/src/App.js index 138a554..39f2d03 100644 --- a/src/App.js +++ b/src/App.js @@ -889,6 +889,7 @@ function App() { statDisplayAtk={statDisplayAtk} GetData={GetData} LOGGEDINUSER={LOGGEDINUSER} + LOGGEDINHASH={LOGGEDINHASH} BACKENDURL={GetBackendURL(BACKENDURL)} /> @@ -921,6 +922,7 @@ function App() { statDisplayAtk={statDisplayAtk} GetData={GetData} LOGGEDINUSER={LOGGEDINUSER} + LOGGEDINHASH={LOGGEDINHASH} BACKENDURL={GetBackendURL(BACKENDURL)} /> diff --git a/src/TestPanel.js b/src/TestPanel.js index 3362711..15b4803 100644 --- a/src/TestPanel.js +++ b/src/TestPanel.js @@ -296,7 +296,7 @@ let { BUILDID } = useParams() let history = useHistory(); let location = useLocation(); -const { GetData,LOGGEDINUSER,BACKENDURL,APP_TITLE } = p +const { GetData,LOGGEDINUSER,LOGGEDINHASH,BACKENDURL,APP_TITLE } = p const [bpGraphMax,setbpGraphMax] = useState(1000) const [hpGraphMax,sethpGraphMax] = useState(1000) @@ -333,10 +333,6 @@ const [classNameSetter,setClassNameSetter] = useState(0) const [points,setPoints] = useState([]) const [skillPointData,setSkillPointData] = useState([]) -useEffect(()=>{ - console.log(skillPointData) -},[skillPointData]) - function SaveData() { var saveObj = { level:level, @@ -352,6 +348,7 @@ function SaveData() { axios.post(BACKENDURL+"/submitBuild",{ id:BUILDID, username:LOGGEDINUSER, + pass:LOGGEDINHASH, creator:author, build_name:buildName, class1:className, @@ -367,8 +364,10 @@ function SaveData() { }) } -function LoadData() { - +function LoadData(build) { + if (build) { + + } } function rarityCheck(v) { @@ -407,7 +406,7 @@ useEffect(()=>{ },[className,GetData]) useEffect(()=>{ - console.log(BUILDID) + LoadData(BUILDID) },[BUILDID]) //console.log(p.GetData("class",p.className,"icon"))