-
Notifications
You must be signed in to change notification settings - Fork 946
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[frontend/backend] Public dashboard: phase 1 (create/delete public da…
…shboards and first widget) (#4903) Co-authored-by: Landry Trebon <landry.trebon@filigran.io>
- Loading branch information
Showing
64 changed files
with
2,671 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
opencti-platform/opencti-front/src/components/dashboard/WidgetAccessDenied.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { useFormatter } from '../i18n'; | ||
import useEnterpriseEdition from '../../utils/hooks/useEnterpriseEdition'; | ||
|
||
const WidgetAccessDenied = () => { | ||
const { t_i18n } = useFormatter(); | ||
const isEnterpriseEdition = useEnterpriseEdition(); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<span style={{ textAlign: 'center' }}> | ||
{!isEnterpriseEdition | ||
? t_i18n('This feature is only available in OpenCTI Enterprise Edition.') | ||
: t_i18n('You are not authorized to see this data.')} | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WidgetAccessDenied; |
60 changes: 60 additions & 0 deletions
60
opencti-platform/opencti-front/src/components/dashboard/WidgetContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Typography from '@mui/material/Typography'; | ||
import Paper from '@mui/material/Paper'; | ||
import React, { CSSProperties, ReactNode } from 'react'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
|
||
const useStyles = makeStyles({ | ||
paper: { | ||
minHeight: 110, | ||
height: '100%', | ||
margin: '4px 0 0 0', | ||
padding: '0 0 10px 0', | ||
borderRadius: 4, | ||
}, | ||
}); | ||
|
||
interface WidgetContainerProps { | ||
children: ReactNode | ||
height?: CSSProperties['height'] | ||
title: string | ||
variant: string | ||
withoutTitle?: boolean | ||
} | ||
|
||
const WidgetContainer = ({ | ||
children, | ||
height, | ||
title, | ||
variant, | ||
withoutTitle = false, | ||
}: WidgetContainerProps) => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<div style={{ height: height || '100%' }}> | ||
{!withoutTitle && ( | ||
<Typography | ||
variant="h4" | ||
gutterBottom={true} | ||
style={{ | ||
margin: variant !== 'inLine' ? '0 0 10px 0' : '-10px 0 10px -7px', | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
}} | ||
> | ||
{title} | ||
</Typography> | ||
)} | ||
{variant !== 'inLine' ? ( | ||
<Paper classes={{ root: classes.paper }} variant="outlined"> | ||
{children} | ||
</Paper> | ||
) : ( | ||
children | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default WidgetContainer; |
19 changes: 19 additions & 0 deletions
19
opencti-platform/opencti-front/src/components/dashboard/WidgetLoader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import CircularProgress from '@mui/material/CircularProgress'; | ||
import React from 'react'; | ||
|
||
const WidgetLoader = () => { | ||
return ( | ||
<div | ||
style={{ | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<CircularProgress size={40} thickness={2} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WidgetLoader; |
21 changes: 21 additions & 0 deletions
21
opencti-platform/opencti-front/src/components/dashboard/WidgetNoData.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { useFormatter } from '../i18n'; | ||
|
||
const WidgetNoData = () => { | ||
const { t_i18n } = useFormatter(); | ||
|
||
return ( | ||
<div | ||
style={{ | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
<p>{t_i18n('No entities of this type has been found.')}</p> | ||
</div> | ||
); | ||
}; | ||
|
||
export default WidgetNoData; |
27 changes: 27 additions & 0 deletions
27
opencti-platform/opencti-front/src/components/dashboard/WidgetNumber.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import ItemNumberDifference from '../ItemNumberDifference'; | ||
import { useFormatter } from '../i18n'; | ||
|
||
interface WidgetNumberProps { | ||
total: number | ||
value: number | ||
} | ||
|
||
const WidgetNumber = ({ total, value }: WidgetNumberProps) => { | ||
const { t_i18n, n } = useFormatter(); | ||
const difference = total - value; | ||
|
||
return ( | ||
<> | ||
<div style={{ float: 'left', fontSize: 40 }}> | ||
{n(total)} | ||
</div> | ||
<ItemNumberDifference | ||
difference={difference} | ||
description={t_i18n('24 hours')} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default WidgetNumber; |
Oops, something went wrong.