Select Git revision

Saket Agrahari authored
App.tsx 6.87 KiB
import React, { ReactElement, useEffect } from "react";
import { createBrowserRouter, RouterProvider } from "react-router-dom";
import Landing from "./pages/Landing";
import ExternalPageNavBar from "./shared/ExternalPageNavBar";
import GeantFooter from "./components/global/GeantFooter";
import BudgetPage from "./pages/Budget";
import CompendiumData from "./pages/CompendiumData";
import FundingSourcePage from "./pages/FundingSource";
import ChargingStructurePage from "./pages/ChargingStructure";
import StaffGraph from "./pages/StaffGraph";
import StaffGraphAbsolute from "./pages/StaffGraphAbsolute";
import SubOrganisation from "./pages/SubOrganisation";
import ParentOrganisation from "./pages/ParentOrganisation";
import ECProjects from "./pages/ECProjects";
import Providers from "./Providers";
import PolicyPage from "./pages/Policy";
import TrafficVolumePage from "./pages/TrafficVolumePerNren";
import ConnectedInstitutionsURLs from "./pages/ConnectedInstitutionsURLs";
import ServicesPage from "./pages/Services";
import {ConnectivityCategory, ServiceCategory} from "./Schema";
import ConnectedUserPage from "./pages/ConnectedUser";
import FibreLightPage from "./pages/FibreLight";
import MonitoringToolsPage from "./pages/MonitoringTools";
import NetworkPertTeam from "./pages/NetworkPertTeam";
import PassiveMonitoringPage from "./pages/PaasiveMonitoring";
import NetworkAlienWavePage from "./pages/NetworkAlienWave";
import NetworkAlienWaveInternalPage from "./pages/NetworkAlienWaveInternal";
import OPsAutomationPage from "./pages/OPsAutomation";
import NetworkAutomationPage from "./pages/NetworkAutomation";
import NetworkTrafficUrlPage from "./pages/NetworkTrafficUrl";
import NetworkWeatherMapPage from "./pages/NetworkWeatherMap";
import NetworkMapUrlPage from "./pages/NetworkMapUrls";
import NetworkFunctionVirtualisationPage from "./pages/NetworkFunctionVirtualisation";
import NetworkCertificateProviderPage from "./pages/NetworkCertificateProvider";
import NetworkSiemVendorsPage from "./pages/NetworkSiemVendors";
import NetworkCapacityLargestLinkPage from "./pages/NetworkCapacityLargestLink";
import NetworkCapacityCoreIPPage from "./pages/NetworkCapacityCoreIP";
import NetworkNonRAndEPeerPage from "./pages/NetworkNonRAndEPeer";
const router = createBrowserRouter([
{ path: "/budget", element: <BudgetPage /> },
{ path: "/funding", element: <FundingSourcePage /> },
{ path: "/data/employment", element: <StaffGraph /> },
{ path: "/data/roles", element: <StaffGraph roles /> },
{ path: "/employee-count", element: <StaffGraphAbsolute /> },
{ path: "/charging", element: <ChargingStructurePage /> },
{ path: "/suborganisations", element: <SubOrganisation /> },
{ path: "/parentorganisation", element: <ParentOrganisation /> },
{ path: "/ec-projects", element: <ECProjects /> },
{ path: "/policy", element: <PolicyPage /> },
{ path: "/traffic-volume", element: <TrafficVolumePage /> },
{ path: "/data", element: <CompendiumData /> },
{ path: "/institutions-urls", element: <ConnectedInstitutionsURLs /> },
{ path: "/connected-proportion", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.ConnectedProportion.toString()} /> },
{ path: "/connectivity-level", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.ConnectivityLevel.toString()} /> },
{ path: "/connectivity-growth", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.ConnectivityGrowth.toString()} /> },
{ path: "/connection-carrier", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.ConnectionCarrier.toString()} /> },
{ path: "/connectivity-load", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.ConnectivityLoad.toString()} /> },
{ path: "/commercial-charging-level", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.CommercialChargingLevel.toString()} /> },
{ path: "/commercial-connectivity", element: <ConnectedUserPage connectivity_category={ConnectivityCategory.CommercialConnectivity.toString()} /> },
{ path: "/network-services", element: <ServicesPage category={ServiceCategory.network_services} /> },
{ path: "/isp-support-services", element: <ServicesPage category={ServiceCategory.isp_support} /> },
{ path: "/security-services", element: <ServicesPage category={ServiceCategory.security} /> },
{ path: "/identity-services", element: <ServicesPage category={ServiceCategory.identity} /> },
{ path: "/collaboration-services", element: <ServicesPage category={ServiceCategory.collaboration} /> },
{ path: "/multimedia-services", element: <ServicesPage category={ServiceCategory.multimedia} /> },
{ path: "/storage-and-hosting-services", element: <ServicesPage category={ServiceCategory.storage_and_hosting} /> },
{ path: "/professional-services", element: <ServicesPage category={ServiceCategory.professional_services} /> },
{ path: "/fibre-light", element: <FibreLightPage /> },
{ path: "/monitoring-tools", element: <MonitoringToolsPage /> },
{ path: "/pert-team", element: <NetworkPertTeam /> },
{ path: "/passive-monitoring", element: <PassiveMonitoringPage /> },
{ path: "/alien-wave", element: <NetworkAlienWavePage /> },
{ path: "/alien-wave-internal", element: <NetworkAlienWaveInternalPage /> },
{ path: "/ops-automation", element: <OPsAutomationPage /> },
{ path: "/network-automation", element: <NetworkAutomationPage /> },
{ path: "/traffic-stats", element: <NetworkTrafficUrlPage /> },
{ path: "/weather-map", element: <NetworkWeatherMapPage /> },
{ path: "/network-map", element: <NetworkMapUrlPage /> },
{ path: "/nfv", element: <NetworkFunctionVirtualisationPage /> },
{ path: "/certificate-provider", element: <NetworkCertificateProviderPage /> },
{ path: "/siem-vendors", element: <NetworkSiemVendorsPage /> },
{ path: "/capacity-largest-link", element: <NetworkCapacityLargestLinkPage /> },
{ path: "/capacity-core-ip", element: <NetworkCapacityCoreIPPage /> },
{ path: "/non-rne-peers", element: <NetworkNonRAndEPeerPage /> },
{ path: "*", element: <Landing /> },
]);
function App(): ReactElement {
const [isAdmin, setIsAdmin] = React.useState(false);
useEffect(() => {
// we have to do this because the user provider is not available before rendering other parts of the app
// so fetch the user and redirect if not admin as a temporary measure, until it's "generally available"
fetch('/api/user/').then(data => data.json()).then(user => {
setIsAdmin(user.permissions.admin)
if (!user.permissions.admin) {
window.location.replace('/survey')
} else {
console.log('Admin user, not redirecting')
}
}).catch(() => {
window.location.replace('/survey')
})
}, [])
if (!isAdmin) {
return <></>
}
return (
<div className="app">
<Providers>
<ExternalPageNavBar />
<RouterProvider router={router} />
</Providers>
<GeantFooter />
</div>
);
}
export default App;