-
Notifications
You must be signed in to change notification settings - Fork 941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[backend/frontend] Implement full text search for documents (#1483) #4275
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
f215f90
[backend/frontend] Implement full text search for documents (#1483)
marieflorescontact c44d898
[backend] Create ManagerConfiguration module
marieflorescontact d0c7b80
[backend] Write ManagerConfiguration into cache
marieflorescontact 77d026f
[backend] Replace saveFileIndexStatus by saveManagerConfiguration
marieflorescontact 7d8d603
[backend] Change enabled condition
marieflorescontact 80da6be
[frontend] Start FileIndexingConfiguration component
marieflorescontact cfcbec6
[backend/frontend] Add warning on modules manager
marieflorescontact 19bb814
[frontend] Ui file indexing configuration
marieflorescontact 8216eed
[backend] Implement files metrics and fileListingForIndexing
marieflorescontact 9b4366b
[backend] update migration timestamp after rebase
marieflorescontact 43965fa
[frontend] fetch metrics
marieflorescontact 3d7f698
[frontend] FilIndexingConfiguration splitting
marieflorescontact 2107f66
[frontend] localization
marieflorescontact 85e6e48
[frontend] typo in requirements
marieflorescontact db539b1
[backend] Init ManagerConfiguration at plateform start
marieflorescontact ac196f6
[backend/frontend] Implement start and pause
marieflorescontact 8258136
[backend] Get indexed files metrics
marieflorescontact 55fd5cc
[backend] fix tests after adding ManagerConfiguration
SouadHadjiat 9ae1921
[backend] fix engine getStats to return stats for primary shards
SouadHadjiat 69b9284
[frontend] Display indexed files metrics
marieflorescontact b8ebd39
[frontend] Add default mimeTypes
marieflorescontact 961e0fd
[frontend] Renaming
marieflorescontact 97cf02f
[frontend] Add maxfileSize variable for filemetrics query and rename …
marieflorescontact 0953a82
[frontend] Refresh indexedFilesMetrics evry 5 sec
marieflorescontact 63153a9
[backend] filter files to index by excluded paths list
SouadHadjiat 7eb5192
[frontend] Refresh indexedFilesMetrics every 10 sec
marieflorescontact 4d3359a
[frontend] Add success message for indexing
marieflorescontact 6ab5427
[backend/frontend] exclude global files by default
SouadHadjiat c436a07
[backend] index files one by one
SouadHadjiat 44ae1cc
[backend] index by bulk with pause
SouadHadjiat ab9150c
[frontend] PR review refactoring
SouadHadjiat 09afd60
[frontend] add missing translations
SouadHadjiat c75ad18
[backend] add EE licence comment and add lock signal check
SouadHadjiat 851707d
[backend] set file index internal id based on file id
SouadHadjiat 77a0c22
[backend] PR review fix
SouadHadjiat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
opencti-platform/opencti-front/src/components/ItemEntityType.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,51 @@ | ||
import Chip from '@mui/material/Chip'; | ||
import React, { FunctionComponent } from 'react'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { hexToRGB, itemColor } from '../utils/Colors'; | ||
import { useFormatter } from './i18n'; | ||
|
||
const useStyles = makeStyles(() => ({ | ||
chip: { | ||
fontSize: 13, | ||
lineHeight: '12px', | ||
height: 20, | ||
textTransform: 'uppercase', | ||
borderRadius: '0', | ||
width: 120, | ||
}, | ||
chipInList: { | ||
fontSize: 12, | ||
height: 20, | ||
float: 'left', | ||
width: 120, | ||
textTransform: 'uppercase', | ||
borderRadius: '0', | ||
}, | ||
})); | ||
|
||
interface ItemEntityTypeProps { | ||
entityType: string; | ||
variant?: string; | ||
} | ||
|
||
const ItemEntityType: FunctionComponent<ItemEntityTypeProps> = ({ | ||
variant = 'inList', | ||
entityType, | ||
}) => { | ||
const classes = useStyles(); | ||
const { t } = useFormatter(); | ||
const style = variant === 'inList' ? classes.chipInList : classes.chip; | ||
return ( | ||
<Chip | ||
classes={{ root: style }} | ||
style={{ | ||
backgroundColor: hexToRGB(itemColor(entityType), 0.08), | ||
color: itemColor(entityType), | ||
border: `1px solid ${itemColor(entityType)}`, | ||
}} | ||
label={t(`entity_${entityType}`)} | ||
/> | ||
); | ||
}; | ||
|
||
export default ItemEntityType; |
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
135 changes: 135 additions & 0 deletions
135
opencti-platform/opencti-front/src/private/components/search/SearchIndexedFileLine.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,135 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
import { createFragmentContainer, graphql } from 'react-relay'; | ||
import ListItem from '@mui/material/ListItem'; | ||
import ListItemText from '@mui/material/ListItemText'; | ||
import makeStyles from '@mui/styles/makeStyles'; | ||
import { SearchIndexedFileLine_node$data } from '@components/search/__generated__/SearchIndexedFileLine_node.graphql'; | ||
import ListItemIcon from '@mui/material/ListItemIcon'; | ||
import { OpenInNewOutlined } from '@mui/icons-material'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import ListItemSecondaryAction from '@mui/material/ListItemSecondaryAction'; | ||
import Tooltip from '@mui/material/Tooltip'; | ||
import { DataColumns } from '../../../components/list_lines'; | ||
import { Theme } from '../../../components/Theme'; | ||
import { useFormatter } from '../../../components/i18n'; | ||
import ItemIcon from '../../../components/ItemIcon'; | ||
import { getFileUri } from '../../../utils/utils'; | ||
import { resolveLink } from '../../../utils/Entity'; | ||
import useGranted, { KNOWLEDGE_KNGETEXPORT, KNOWLEDGE_KNUPLOAD } from '../../../utils/hooks/useGranted'; | ||
|
||
const useStyles = makeStyles<Theme>((theme) => ({ | ||
item: { | ||
paddingLeft: 10, | ||
height: 50, | ||
}, | ||
itemIcon: { | ||
color: theme.palette.primary.main, | ||
}, | ||
bodyItem: { | ||
height: 20, | ||
fontSize: 13, | ||
float: 'left', | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
paddingRight: 10, | ||
}, | ||
})); | ||
|
||
interface SearchIndexedFileLineComponentProps { | ||
node: SearchIndexedFileLine_node$data; | ||
dataColumns: DataColumns; | ||
} | ||
|
||
const SearchIndexedFileLineComponent: FunctionComponent<SearchIndexedFileLineComponentProps> = ({ | ||
node, | ||
dataColumns, | ||
}) => { | ||
const classes = useStyles(); | ||
const { t } = useFormatter(); | ||
let entityLink = node.entity ? `${resolveLink(node.entity.entity_type)}/${node.entity.id}` : ''; | ||
const isGrantedToFiles = useGranted([KNOWLEDGE_KNUPLOAD, KNOWLEDGE_KNGETEXPORT]); | ||
if (entityLink && isGrantedToFiles) { | ||
entityLink = entityLink.concat('/files'); | ||
} | ||
return ( | ||
<ListItem | ||
classes={{ root: classes.item }} | ||
divider={true} | ||
button={true} | ||
component="a" | ||
href={getFileUri(node.file_id)} | ||
target="_blank" | ||
> | ||
<ListItemIcon classes={{ root: classes.itemIcon }}> | ||
<ItemIcon type="File" /> | ||
</ListItemIcon> | ||
<ListItemText | ||
primary={ | ||
<div> | ||
SouadHadjiat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{Object.values(dataColumns).map((value) => ( | ||
<div | ||
key={value.label} | ||
className={classes.bodyItem} | ||
style={{ width: value.width }} | ||
> | ||
{value.render?.(node)} | ||
</div> | ||
))} | ||
</div> | ||
} | ||
/> | ||
<ListItemSecondaryAction> | ||
{node.entity && entityLink && ( | ||
<Tooltip title={t('Open the entity overview in a separated tab')}> | ||
<IconButton | ||
component={Link} | ||
target="_blank" | ||
to={entityLink} | ||
size="medium" | ||
> | ||
<OpenInNewOutlined fontSize="medium" /> | ||
</IconButton> | ||
</Tooltip> | ||
)} | ||
</ListItemSecondaryAction> | ||
</ListItem> | ||
); | ||
}; | ||
|
||
const SearchIndexedFileLine = createFragmentContainer(SearchIndexedFileLineComponent, { | ||
node: graphql` | ||
fragment SearchIndexedFileLine_node on IndexedFile { | ||
id | ||
name | ||
uploaded_at | ||
file_id | ||
searchOccurrences | ||
entity { | ||
...on StixObject { | ||
id | ||
entity_type | ||
representative { | ||
main | ||
} | ||
} | ||
...on StixCoreObject { | ||
objectMarking { | ||
edges { | ||
node { | ||
id | ||
definition_type | ||
definition | ||
x_opencti_order | ||
x_opencti_color | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
}); | ||
|
||
export default SearchIndexedFileLine; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to use ListItemButton