From ad6abacf7f73e3dfdb12518f8adce410eb4ec334 Mon Sep 17 00:00:00 2001 From: Aurora Lahtela <24460436+AuroraLS3@users.noreply.github.com> Date: Sun, 4 Dec 2022 11:06:05 +0200 Subject: [PATCH] Fix issues of the exported pages - Fixed / opening "Redirecting.." view due to wrong whoAmI replacement - Fixed page not opening because sidebar contained undefined items (static site can't have everything) - Fixed some sidebar links being anchors instead of react-router links - Fixed network page not opening due to missing extensionData json - Fixed server page not opening due to missing extensionData and serverIdentifier json - Added visual icon to the page when it is exported rather than dynamic for my own sanity - Removed query page links from exported pages --- .../delivery/export/NetworkPageExporter.java | 4 +++- .../delivery/export/ServerPageExporter.java | 6 ++++- .../plan/settings/locale/lang/HtmlLang.java | 3 ++- .../src/components/navigation/Header.js | 3 ++- .../src/components/navigation/Sidebar.js | 23 +++++++++++-------- .../dashboard/src/hooks/navigationHook.js | 2 ++ .../src/service/authenticationService.js | 2 +- .../dashboard/src/views/layout/NetworkPage.js | 12 ++++++---- .../dashboard/src/views/layout/PlayersPage.js | 3 ++- .../dashboard/src/views/layout/ServerPage.js | 13 +++++++---- 10 files changed, 45 insertions(+), 26 deletions(-) diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java index 3745f5812..5a91674f6 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/NetworkPageExporter.java @@ -132,11 +132,13 @@ public class NetworkPageExporter extends FileExporter { "graph?type=hourlyUniqueAndNew", "graph?type=serverPie", "graph?type=joinAddressPie", + "graph?type=joinAddressByDay", "graph?type=activity", "graph?type=geolocation", "graph?type=uniqueAndNew", "network/pingTable", - "sessions" + "sessions", + "extensionData?server=" + serverUUID ); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ServerPageExporter.java b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ServerPageExporter.java index 82800a6da..0b232aba1 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ServerPageExporter.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/delivery/export/ServerPageExporter.java @@ -142,6 +142,7 @@ public class ServerPageExporter extends FileExporter { "playerVersus?server=" + serverUUID, "playerbaseOverview?server=" + serverUUID, "performanceOverview?server=" + serverUUID, + "graph?type=playersOnline&server=" + serverUUID, "graph?type=optimizedPerformance&server=" + serverUUID, "graph?type=aggregatedPing&server=" + serverUUID, "graph?type=worldPie&server=" + serverUUID, @@ -150,12 +151,15 @@ public class ServerPageExporter extends FileExporter { "graph?type=uniqueAndNew&server=" + serverUUID, "graph?type=hourlyUniqueAndNew&server=" + serverUUID, "graph?type=joinAddressPie&server=" + serverUUID, + "graph?type=joinAddressByDay&server=" + serverUUID, "graph?type=serverCalendar&server=" + serverUUID, "graph?type=punchCard&server=" + serverUUID, "players?server=" + serverUUID, "kills?server=" + serverUUID, "pingTable?server=" + serverUUID, - "sessions?server=" + serverUUID + "sessions?server=" + serverUUID, + "extensionData?server=" + serverUUID, + "serverIdentity?server=" + serverUUID ); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/HtmlLang.java b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/HtmlLang.java index 693e4d445..1dbde7865 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/HtmlLang.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/settings/locale/lang/HtmlLang.java @@ -306,7 +306,8 @@ public enum HtmlLang implements Lang { WARNING_NO_GAME_SERVERS("html.description.noGameServers", "Some data requires Plan to be installed on game servers."), WARNING_NO_GEOLOCATIONS("html.description.noGeolocations", "Geolocation gathering needs to be enabled in the config (Accept GeoLite2 EULA)."), - WARNING_NO_SPONGE_CHUNKS("html.description.noSpongeChunks", "Chunks unavailable on Sponge"); + WARNING_NO_SPONGE_CHUNKS("html.description.noSpongeChunks", "Chunks unavailable on Sponge"), + EXPORTED_TITLE("html.label.exported", "Data export time"); private final String key; private final String defaultValue; diff --git a/Plan/react/dashboard/src/components/navigation/Header.js b/Plan/react/dashboard/src/components/navigation/Header.js index cc875017b..d39cb2b70 100644 --- a/Plan/react/dashboard/src/components/navigation/Header.js +++ b/Plan/react/dashboard/src/components/navigation/Header.js @@ -1,7 +1,7 @@ import {useMetadata} from "../../hooks/metadataHook"; import {useAuth} from "../../hooks/authenticationHook"; import {FontAwesomeIcon as Fa} from "@fortawesome/react-fontawesome"; -import {faBars, faCog, faDoorOpen, faPalette, faSyncAlt} from "@fortawesome/free-solid-svg-icons"; +import {faBars, faClockRotateLeft, faCog, faDoorOpen, faPalette, faSyncAlt} from "@fortawesome/free-solid-svg-icons"; import DropdownMenu from "react-bootstrap-v5/lib/esm/DropdownMenu"; import DropdownItem from "react-bootstrap-v5/lib/esm/DropdownItem"; import {useTheme} from "../../hooks/themeHook"; @@ -58,6 +58,7 @@ const Header = ({page, tab, hideUpdater}) => { {!staticSite && } + {staticSite && } {' '} {lastUpdate.formatted} diff --git a/Plan/react/dashboard/src/components/navigation/Sidebar.js b/Plan/react/dashboard/src/components/navigation/Sidebar.js index 9d7341384..452a5df19 100644 --- a/Plan/react/dashboard/src/components/navigation/Sidebar.js +++ b/Plan/react/dashboard/src/components/navigation/Sidebar.js @@ -23,12 +23,12 @@ const Divider = ({showMargin}) => ( ) -const InnerItem = ({href, icon, name, nameShort, color}) => { +const InnerItem = ({href, icon, name, nameShort, color, external}) => { if (!href) { return () } - if (href.startsWith('/')) { + if (external) { return ( @@ -56,10 +56,11 @@ const Item = ({item, inner}) => { }, [pathname, href, setCurrentTab, name, external]) if (inner) { - return () + return () } - if (href.startsWith('/')) { + if (external) { return ( @@ -165,12 +166,14 @@ const SidebarCollapse = ({item, open, setOpen}) => { - {item.contents.map((content, i) => - )} + {item.contents + .filter(content => content !== undefined) + .map((content, i) => + )} diff --git a/Plan/react/dashboard/src/hooks/navigationHook.js b/Plan/react/dashboard/src/hooks/navigationHook.js index 17c1154d9..67e94ea4f 100644 --- a/Plan/react/dashboard/src/hooks/navigationHook.js +++ b/Plan/react/dashboard/src/hooks/navigationHook.js @@ -15,9 +15,11 @@ export const NavigationContextProvider = ({children}) => { const pathname = window.location.href; setItems(items); for (const item of items) { + if (!item) continue; if ('/' !== item.href && pathname.includes(item.href)) setCurrentTab(item.name); if (item.contents) { for (const subItem of item.contents) { + if (!subItem) continue; if ('/' !== subItem.href && pathname.includes(subItem.href)) setCurrentTab(subItem.name); } } diff --git a/Plan/react/dashboard/src/service/authenticationService.js b/Plan/react/dashboard/src/service/authenticationService.js index dca9ef148..2aee00c71 100644 --- a/Plan/react/dashboard/src/service/authenticationService.js +++ b/Plan/react/dashboard/src/service/authenticationService.js @@ -2,7 +2,7 @@ import {doGetRequest, doSomePostRequest, standard200option, staticSite} from "./ export const fetchWhoAmI = async () => { if (staticSite) { - return {authRequired: false, loggedIn: false} + return {data: {authRequired: false, loggedIn: false}, error: null}; } const url = '/v1/whoami'; return doGetRequest(url); diff --git a/Plan/react/dashboard/src/views/layout/NetworkPage.js b/Plan/react/dashboard/src/views/layout/NetworkPage.js index b6a10112a..29b03640a 100644 --- a/Plan/react/dashboard/src/views/layout/NetworkPage.js +++ b/Plan/react/dashboard/src/views/layout/NetworkPage.js @@ -95,11 +95,13 @@ const NetworkSidebar = () => { }).forEach(item => items.push(item)) } - items.push( - {}, - {name: 'html.label.links'}, - {name: 'html.label.query', icon: faSearch, href: "/query"} - ); + if (!staticSite) { + items.push( + {}, + {name: 'html.label.links'}, + {name: 'html.label.query', icon: faSearch, href: "/query"} + ); + } setSidebarItems(items); window.document.title = `Plan | Network`; diff --git a/Plan/react/dashboard/src/views/layout/PlayersPage.js b/Plan/react/dashboard/src/views/layout/PlayersPage.js index ada5dadd9..9886126d7 100644 --- a/Plan/react/dashboard/src/views/layout/PlayersPage.js +++ b/Plan/react/dashboard/src/views/layout/PlayersPage.js @@ -9,6 +9,7 @@ import Header from "../../components/navigation/Header"; import ColorSelectorModal from "../../components/modal/ColorSelectorModal"; import {useMetadata} from "../../hooks/metadataHook"; import ErrorPage from "./ErrorPage"; +import {staticSite} from "../../service/backendConfiguration"; const PlayersPage = () => { const {t, i18n} = useTranslation(); @@ -20,7 +21,7 @@ const PlayersPage = () => { const {currentTab, setCurrentTab} = useNavigation(); useEffect(() => { - const items = [ + const items = staticSite ? [] : [ {name: 'html.label.links'}, {name: 'html.label.query', icon: faSearch, href: "/query"}, ] diff --git a/Plan/react/dashboard/src/views/layout/ServerPage.js b/Plan/react/dashboard/src/views/layout/ServerPage.js index 414185ad2..e4abb05ff 100644 --- a/Plan/react/dashboard/src/views/layout/ServerPage.js +++ b/Plan/react/dashboard/src/views/layout/ServerPage.js @@ -29,6 +29,7 @@ import {useDataRequest} from "../../hooks/dataFetchHook"; import {fetchServerIdentity} from "../../service/serverService"; import {ServerExtensionContextProvider, useServerExtensionContext} from "../../hooks/serverExtensionDataContext"; import {iconTypeToFontAwesomeClass} from "../../util/icons"; +import {staticSite} from "../../service/backendConfiguration"; const ServerSidebar = () => { const {t, i18n} = useTranslation(); @@ -93,11 +94,13 @@ const ServerSidebar = () => { }).forEach(item => items.push(item)) } - items.push( - {}, - {name: 'html.label.links'}, - {name: 'html.label.query', icon: faSearch, href: "/query"} - ); + if (!staticSite) { + items.push( + {}, + {name: 'html.label.links'}, + {name: 'html.label.query', icon: faSearch, href: "/query"} + ); + } setSidebarItems(items); window.document.title = `Plan | Server Analysis`;