Skip to content
Snippets Groups Projects
Select Git revision
  • 2ad9f18fbeb5e73cde2f1709c957ca7b07ab11c8
  • develop default
  • master protected
  • feature/frontend-tests
  • 0.98
  • 0.97
  • 0.96
  • 0.95
  • 0.94
  • 0.93
  • 0.92
  • 0.91
  • 0.90
  • 0.89
  • 0.88
  • 0.87
  • 0.86
  • 0.85
  • 0.84
  • 0.83
  • 0.82
  • 0.81
  • 0.80
  • 0.79
24 results

App.tsx

Blame
  • App.tsx 5.76 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";
    
    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: "*", 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;