|
@@ -52,13 +52,17 @@ import { VizPage } from './pages/VizPage';
|
|
|
import { useVizSlice } from './pages/VizPage/slice';
|
|
|
import { initChartPreviewData } from './pages/VizPage/slice/thunks';
|
|
|
import { useMainSlice } from './slice';
|
|
|
-import { selectOrgId } from './slice/selectors';
|
|
|
+import {selectOrgId} from './slice/selectors';
|
|
|
+import {
|
|
|
+ selectLoggedInUser,
|
|
|
+} from 'app/slice/selectors';
|
|
|
import {
|
|
|
getDataProviders,
|
|
|
getLoggedInUserPermissions,
|
|
|
getUserSettings,
|
|
|
} from './slice/thunks';
|
|
|
import { MainPageRouteParams } from './types';
|
|
|
+import Watermark from 'antd-watermark';
|
|
|
|
|
|
export function MainPage() {
|
|
|
useAppSlice();
|
|
@@ -69,6 +73,8 @@ export function MainPage() {
|
|
|
const organizationMatch = useRouteMatch<MainPageRouteParams>(
|
|
|
'/organizations/:orgId',
|
|
|
);
|
|
|
+ const loggedInUser = useSelector(selectLoggedInUser)
|
|
|
+ console.log(loggedInUser)
|
|
|
const orgId = useSelector(selectOrgId);
|
|
|
const history = useHistory();
|
|
|
// loaded first time
|
|
@@ -109,153 +115,162 @@ export function MainPage() {
|
|
|
[dispatch, history],
|
|
|
);
|
|
|
|
|
|
+ const wmContent = ()=>{
|
|
|
+ const name = loggedInUser?.name
|
|
|
+ const username = loggedInUser?.username
|
|
|
+ return `${name} ${username}`
|
|
|
+ }
|
|
|
+
|
|
|
return (
|
|
|
<AppContainer>
|
|
|
- <Background />
|
|
|
- <Navbar />
|
|
|
- {orgId && (
|
|
|
- <Switch>
|
|
|
- <Route path="/" exact>
|
|
|
- <Redirect to={`/organizations/${orgId}`} />
|
|
|
- </Route>
|
|
|
- <Route path="/confirminvite" component={ConfirmInvitePage} />
|
|
|
- <Route path="/organizations/:orgId" exact>
|
|
|
- <Redirect
|
|
|
- to={`/organizations/${organizationMatch?.params.orgId}/vizs`}
|
|
|
+ <Watermark content={wmContent()} style={{width:'100%',display:'flex'}} font={{fontSize:22,color:'rgba(0,0,0,0.05)'}} gap={[150, 150]}>
|
|
|
+ <Background />
|
|
|
+ <Navbar />
|
|
|
+
|
|
|
+ {orgId && (
|
|
|
+ <Switch>
|
|
|
+ <Route path="/" exact>
|
|
|
+ <Redirect to={`/organizations/${orgId}`} />
|
|
|
+ </Route>
|
|
|
+ <Route path="/confirminvite" component={ConfirmInvitePage} />
|
|
|
+ <Route path="/organizations/:orgId" exact>
|
|
|
+ <Redirect
|
|
|
+ to={`/organizations/${organizationMatch?.params.orgId}/vizs`}
|
|
|
+ />
|
|
|
+ </Route>
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/vizs/chartEditor"
|
|
|
+ render={res => {
|
|
|
+ const hisSearch = new URLSearchParams(res.location.search);
|
|
|
+ const hisState = {
|
|
|
+ dataChartId: hisSearch.get('dataChartId') || '',
|
|
|
+ chartType: hisSearch.get('chartType') || 'dataChart',
|
|
|
+ container: hisSearch.get('container') || 'dataChart',
|
|
|
+ defaultViewId: hisSearch.get('defaultViewId') || '',
|
|
|
+ } as ChartEditorBaseProps;
|
|
|
+ return (
|
|
|
+ <AccessRoute module={ResourceTypes.Viz}>
|
|
|
+ <ChartEditor
|
|
|
+ dataChartId={hisState.dataChartId}
|
|
|
+ orgId={orgId}
|
|
|
+ chartType={hisState.chartType}
|
|
|
+ container={hisState.container}
|
|
|
+ defaultViewId={hisState.defaultViewId}
|
|
|
+ onClose={() => history.go(-1)}
|
|
|
+ onSaveInDataChart={onSaveInDataChart}
|
|
|
+ />
|
|
|
+ </AccessRoute>
|
|
|
+ );
|
|
|
+ }}
|
|
|
/>
|
|
|
- </Route>
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/vizs/chartEditor"
|
|
|
- render={res => {
|
|
|
- const hisSearch = new URLSearchParams(res.location.search);
|
|
|
- const hisState = {
|
|
|
- dataChartId: hisSearch.get('dataChartId') || '',
|
|
|
- chartType: hisSearch.get('chartType') || 'dataChart',
|
|
|
- container: hisSearch.get('container') || 'dataChart',
|
|
|
- defaultViewId: hisSearch.get('defaultViewId') || '',
|
|
|
- } as ChartEditorBaseProps;
|
|
|
- return (
|
|
|
+
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/vizs/storyPlayer/:storyId"
|
|
|
+ render={() => <StoryPlayer />}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/vizs/storyEditor/:storyId"
|
|
|
+ render={() => <StoryEditor />}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/vizs/:vizId?"
|
|
|
+ render={() => (
|
|
|
<AccessRoute module={ResourceTypes.Viz}>
|
|
|
- <ChartEditor
|
|
|
- dataChartId={hisState.dataChartId}
|
|
|
- orgId={orgId}
|
|
|
- chartType={hisState.chartType}
|
|
|
- container={hisState.container}
|
|
|
- defaultViewId={hisState.defaultViewId}
|
|
|
- onClose={() => history.go(-1)}
|
|
|
- onSaveInDataChart={onSaveInDataChart}
|
|
|
- />
|
|
|
+ <VizPage />
|
|
|
</AccessRoute>
|
|
|
- );
|
|
|
- }}
|
|
|
- />
|
|
|
-
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/vizs/storyPlayer/:storyId"
|
|
|
- render={() => <StoryPlayer />}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/vizs/storyEditor/:storyId"
|
|
|
- render={() => <StoryEditor />}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/vizs/:vizId?"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Viz}>
|
|
|
- <VizPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/views/:viewId?"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.View}>
|
|
|
- <ViewPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/sources"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Source}>
|
|
|
- <SourcePage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/schedules"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Schedule}>
|
|
|
- <SchedulePage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/members"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.User}>
|
|
|
- <MemberPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/roles"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.User}>
|
|
|
- <MemberPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route path="/organizations/:orgId/permissions" exact>
|
|
|
- <Redirect
|
|
|
- to={`/organizations/${organizationMatch?.params.orgId}/permissions/subject`}
|
|
|
+ )}
|
|
|
/>
|
|
|
- </Route>
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/views/:viewId?"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.View}>
|
|
|
+ <ViewPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/sources"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Source}>
|
|
|
+ <SourcePage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/schedules"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Schedule}>
|
|
|
+ <SchedulePage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/members"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.User}>
|
|
|
+ <MemberPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/roles"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.User}>
|
|
|
+ <MemberPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route path="/organizations/:orgId/permissions" exact>
|
|
|
+ <Redirect
|
|
|
+ to={`/organizations/${organizationMatch?.params.orgId}/permissions/subject`}
|
|
|
+ />
|
|
|
+ </Route>
|
|
|
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/departments"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Department}>
|
|
|
- <DepartmentPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/departments"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Department}>
|
|
|
+ <DepartmentPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/permissions/:viewpoint"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Manager}>
|
|
|
- <PermissionPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/variables"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Manager}>
|
|
|
- <VariablePage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/orgSettings"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Manager}>
|
|
|
- <OrgSettingPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route
|
|
|
- path="/organizations/:orgId/resourceMigration"
|
|
|
- render={() => (
|
|
|
- <AccessRoute module={ResourceTypes.Manager}>
|
|
|
- <ResourceMigrationPage />
|
|
|
- </AccessRoute>
|
|
|
- )}
|
|
|
- />
|
|
|
- <Route path="*" component={NotFoundPage} />
|
|
|
- </Switch>
|
|
|
- )}
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/permissions/:viewpoint"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Manager}>
|
|
|
+ <PermissionPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/variables"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Manager}>
|
|
|
+ <VariablePage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/orgSettings"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Manager}>
|
|
|
+ <OrgSettingPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route
|
|
|
+ path="/organizations/:orgId/resourceMigration"
|
|
|
+ render={() => (
|
|
|
+ <AccessRoute module={ResourceTypes.Manager}>
|
|
|
+ <ResourceMigrationPage />
|
|
|
+ </AccessRoute>
|
|
|
+ )}
|
|
|
+ />
|
|
|
+ <Route path="*" component={NotFoundPage} />
|
|
|
+ </Switch>
|
|
|
+ )}
|
|
|
+ </Watermark>
|
|
|
</AppContainer>
|
|
|
);
|
|
|
}
|