Skip to content

Commit

Permalink
StatsHouse UI: feature admin dash
Browse files Browse the repository at this point in the history
  • Loading branch information
vauweb committed Nov 4, 2024
1 parent 173febf commit a63d4e0
Show file tree
Hide file tree
Showing 9 changed files with 487 additions and 85 deletions.
90 changes: 70 additions & 20 deletions statshouse-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions statshouse-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@preact/signals-core": "^1.5.1",
"@preact/signals-react": "^2.0.0",
"@sindresorhus/fnv1a": "^2.0.1",
"@tanstack/react-query": "^5.59.16",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
"@testing-library/user-event": "^14.5.1",
Expand Down
127 changes: 66 additions & 61 deletions statshouse-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
// import { Admin } from './admin/Admin';
// import { ViewPage } from './view/ViewPage';
import { currentAccessInfo } from './common/access';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
// import { DashboardListView } from './view/DashboardListView';
// import { SettingsPage } from './view/Settings/SettingsPage';
// import { GroupPage } from './view/Settings/GroupPage';
Expand All @@ -28,72 +29,76 @@ const View2Page = React.lazy(() => import('./view2/ViewPage'));
const Core = React.lazy(() => import('./view2/Core'));
const yAxisSize = 54; // must be synced with .u-legend padding-left

const queryClient = new QueryClient();

function App() {
const ai = currentAccessInfo();
return (
<Routes>
<Route path="/" element={<Core />}>
<Route path="" element={<Navigate to="view" replace={true} />} />
<Route path="view" element={<View2Page />} />
<Route path="embed" element={<View2Page />} />
<Route path="settings/*" element={<SettingsPage adminMode={ai.admin} />}>
<Route path="group" element={<GroupPage />} />
<Route path="namespace" element={<NamespacePage />} />
</Route>
<Route
path="dash-list"
element={
<Suspense fallback={<div>Loading...</div>}>
<DashboardListView />
</Suspense>
}
/>
<Route
path="doc/faq"
element={
<Suspense fallback={<div>FAQ Loading...</div>}>
<FAQ yAxisSize={yAxisSize} />
</Suspense>
}
/>
<Route
path="admin/*"
element={
<Suspense fallback={<div>Loading...</div>}>
<Admin yAxisSize={yAxisSize} adminMode={ai.admin} />
</Suspense>
}
/>
<Route path="settings/*" element={<SettingsPage adminMode={ai.admin} />}>
<Route path="group" element={<GroupPage />} />
<Route path="namespace" element={<NamespacePage />} />
{/*<Route path="prometheus" element={<PrometheusPage />} />*/}
<QueryClientProvider client={queryClient}>
<Routes>
<Route path="/" element={<Core />}>
<Route path="" element={<Navigate to="view" replace={true} />} />
<Route path="view" element={<View2Page />} />
<Route path="embed" element={<View2Page />} />
<Route path="settings/*" element={<SettingsPage adminMode={ai.admin} />}>
<Route path="group" element={<GroupPage />} />
<Route path="namespace" element={<NamespacePage />} />
</Route>
<Route
path="dash-list"
element={
<Suspense fallback={<div>Loading...</div>}>
<DashboardListView />
</Suspense>
}
/>
<Route
path="doc/faq"
element={
<Suspense fallback={<div>FAQ Loading...</div>}>
<FAQ yAxisSize={yAxisSize} />
</Suspense>
}
/>
<Route
path="admin/*"
element={
<Suspense fallback={<div>Loading...</div>}>
<Admin yAxisSize={yAxisSize} adminMode={ai.admin} />
</Suspense>
}
/>
<Route path="settings/*" element={<SettingsPage adminMode={ai.admin} />}>
<Route path="group" element={<GroupPage />} />
<Route path="namespace" element={<NamespacePage />} />
{/*<Route path="prometheus" element={<PrometheusPage />} />*/}
</Route>
<Route path="*" element={<NotFound />} />
</Route>
<Route path="*" element={<NotFound />} />
</Route>
{/*<Route path="/" element={<Navigate to="view" replace={true} />} />*/}
{/*<Route path="embed" element={<ViewPage embed={true} yAxisSize={yAxisSize} />} />*/}
{/*<Route path="/" element={<NavbarApp />}>*/}
{/* <Route*/}
{/* path="doc/faq"*/}
{/* element={*/}
{/* <Suspense fallback={<div>FAQ Loading...</div>}>*/}
{/* <FAQ yAxisSize={yAxisSize} />*/}
{/* </Suspense>*/}
{/* }*/}
{/* />*/}
{/* <Route path="admin/*" element={<Admin yAxisSize={yAxisSize} adminMode={ai.admin} />} />*/}
{/* <Route path="settings/*" element={<SettingsPage adminMode={ai.admin} />}>*/}
{/* <Route path="group" element={<GroupPage />} />*/}
{/* <Route path="namespace" element={<NamespacePage />} />*/}
{/* /!*<Route path="prometheus" element={<PrometheusPage />} />*!/*/}
{/* </Route>*/}
{/*<Route path="/" element={<Navigate to="view" replace={true} />} />*/}
{/*<Route path="embed" element={<ViewPage embed={true} yAxisSize={yAxisSize} />} />*/}
{/*<Route path="/" element={<NavbarApp />}>*/}
{/* <Route*/}
{/* path="doc/faq"*/}
{/* element={*/}
{/* <Suspense fallback={<div>FAQ Loading...</div>}>*/}
{/* <FAQ yAxisSize={yAxisSize} />*/}
{/* </Suspense>*/}
{/* }*/}
{/* />*/}
{/* <Route path="admin/*" element={<Admin yAxisSize={yAxisSize} adminMode={ai.admin} />} />*/}
{/* <Route path="settings/*" element={<SettingsPage adminMode={ai.admin} />}>*/}
{/* <Route path="group" element={<GroupPage />} />*/}
{/* <Route path="namespace" element={<NamespacePage />} />*/}
{/* /!*<Route path="prometheus" element={<PrometheusPage />} />*!/*/}
{/* </Route>*/}

{/* <Route path="view" element={<ViewPage yAxisSize={yAxisSize} />} />*/}
{/* <Route path="dash-list" element={<DashboardListView />} />*/}
{/* <Route path="*" element={<NotFound />} />*/}
{/*</Route>*/}
</Routes>
{/* <Route path="view" element={<ViewPage yAxisSize={yAxisSize} />} />*/}
{/* <Route path="dash-list" element={<DashboardListView />} />*/}
{/* <Route path="*" element={<NotFound />} />*/}
{/*</Route>*/}
</Routes>
</QueryClientProvider>
);
}

Expand Down
2 changes: 2 additions & 0 deletions statshouse-ui/src/admin/Admin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as React from 'react';
import { FormPage } from './pages/FormPage';
import { CreatePage } from './pages/CreatePage';
import { Route, Routes } from 'react-router-dom';
import { AdminDashControl } from './AdminDashControl';

export function Admin(props: { yAxisSize: number; adminMode: boolean }) {
const { yAxisSize, adminMode } = props;
Expand All @@ -16,6 +17,7 @@ export function Admin(props: { yAxisSize: number; adminMode: boolean }) {
<Routes>
<Route path="create" element={<CreatePage yAxisSize={yAxisSize} />} />
<Route path="edit/:metricName" element={<FormPage adminMode={adminMode} yAxisSize={yAxisSize} />} />
<Route path="dash/" element={<AdminDashControl />} />
</Routes>
);
}
Expand Down
Loading

0 comments on commit a63d4e0

Please sign in to comment.