Added tab control in admin UI when clicking tabs

This commit is contained in:
frikky
2021-12-30 17:15:27 +01:00
parent 63c5c34f03
commit ed0c6250d6
+25 -19
View File
@@ -86,7 +86,7 @@ const MenuProps = {
const Admin = (props) => { const Admin = (props) => {
const { globalUrl, userdata } = props; const { globalUrl, userdata, serverside} = props;
var upload = ""; var upload = "";
var to_be_copied = ""; var to_be_copied = "";
@@ -1357,12 +1357,12 @@ const Admin = (props) => {
3: "files", 3: "files",
4: "schedules", 4: "schedules",
5: "environments", 5: "environments",
6: "categories", 6: "suborgs",
}; };
const setConfig = (event, newValue) => { const setConfig = (event, inputValue) => {
//console.log("Value: ", newValue) const newValue = parseInt(inputValue)
setCurTab(parseInt(newValue)); setCurTab(newValue)
if (newValue === 1) { if (newValue === 1) {
document.title = "Shuffle - admin - users"; document.title = "Shuffle - admin - users";
getUsers(); getUsers();
@@ -1385,18 +1385,13 @@ const Admin = (props) => {
document.title = "Shuffle - admin"; document.title = "Shuffle - admin";
} }
console.log("NEWVALUE: ", newValue)
if (newValue === 6) { if (newValue === 6) {
console.log("Should get apps for categories."); console.log("Should get apps for categories.");
} }
//var theURL = window.location.pathname props.history.push(`/admin?tab=${views[newValue]}`)
//FIXME: Add url edits
//var theURL = window.location
//theURL.replace(`/${views[curTab]}`, `/${views[newValue]}`)
//window.history.pushState({"html":response.html,"pageTitle":response.pageTitle},"", urlPath);
//console.log(newpath)
//window.location.pathame = newpath
setModalUser({}); setModalUser({});
}; };
@@ -1408,13 +1403,24 @@ const Admin = (props) => {
getUsers(); getUsers();
} else { } else {
getSettings(); getSettings();
} }
if (props.match.params.key !== undefined) { if (serverside !== true && window.location.search !== undefined && window.location.search !== null) {
//const tmpitem = views[props.match.params.key] const urlSearchParams = new URLSearchParams(window.location.search)
setConfig("", props.match.params.key); const params = Object.fromEntries(urlSearchParams.entries())
} const foundTab = params["tab"]
} if (foundTab !== null && foundTab !== undefined) {
for (var key in Object.keys(views)) {
const value = views[key]
console.log(key, value)
if (value === foundTab) {
setConfig("", key)
break
}
}
}
}
}
if ( if (
selectedOrganization.id === undefined && selectedOrganization.id === undefined &&