Skip to content

Commit

Permalink
[frontend] Fix search in Containers Correlation view (#8162)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archidoit authored Sep 19, 2024
1 parent 80b8312 commit cfc1f6f
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { hexToRGB } from '../../../../utils/Colors';
import { UserContext } from '../../../../utils/hooks/useAuth';
import EntitiesDetailsRightsBar from '../../../../utils/graph/EntitiesDetailsRightBar';
import withRouter from '../../../../utils/compat_router/withRouter';
import { isNotEmptyField } from '../../../../utils/utils';
import { getMainRepresentative, getSecondaryRepresentative } from '../../../../utils/defaultRepresentatives';

const PARAMETERS$ = new Subject().pipe(debounce(() => timer(2000)));
const POSITIONS$ = new Subject().pipe(debounce(() => timer(2000)));
Expand Down Expand Up @@ -810,26 +812,20 @@ class GroupingKnowledgeCorrelationComponent extends Component {
}

handleSearch(keyword) {
const filterAdjust = {
selectedTimeRangeInterval: this.state.selectedTimeRangeInterval,
markedBy: this.state.markedBy,
createdBy: this.state.createdBy,
stixCoreObjectsTypes: this.state.stixCoreObjectsTypes,
keyword,
};
this.setState(
{
selectedTimeRangeInterval: filterAdjust.selectedTimeRangeInterval,
graphData: buildCorrelationData(
this.graphObjects,
decodeGraphData(this.props.grouping.x_opencti_graph_data),
this.props.t,
filterAdjust,
'groupings',
),
},
() => this.saveParameters(false),
);
this.selectedLinks.clear();
this.selectedNodes.clear();
if (isNotEmptyField(keyword)) {
const filterByKeyword = (n) => keyword === ''
|| (getMainRepresentative(n) || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1
|| (getSecondaryRepresentative(n) || '')
.toLowerCase()
.indexOf(keyword.toLowerCase()) !== -1
|| (n.entity_type || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1;
this.state.graphData.nodes.map((n) => filterByKeyword(n) && this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size });
}
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import ReportKnowledgeGraphBar from './ReportKnowledgeGraphBar';
import { UserContext } from '../../../../utils/hooks/useAuth';
import EntitiesDetailsRightsBar from '../../../../utils/graph/EntitiesDetailsRightBar';
import withRouter from '../../../../utils/compat_router/withRouter';
import { isNotEmptyField } from '../../../../utils/utils';
import { getMainRepresentative, getSecondaryRepresentative } from '../../../../utils/defaultRepresentatives';

const PARAMETERS$ = new Subject().pipe(debounce(() => timer(2000)));
const POSITIONS$ = new Subject().pipe(debounce(() => timer(2000)));
Expand Down Expand Up @@ -803,25 +805,20 @@ class ReportKnowledgeCorrelationComponent extends Component {
}

handleSearch(keyword) {
const filterAdjust = {
selectedTimeRangeInterval: this.state.selectedTimeRangeInterval,
markedBy: this.state.markedBy,
createdBy: this.state.createdBy,
stixCoreObjectsTypes: this.state.stixCoreObjectsTypes,
keyword,
};
this.setState(
{
selectedTimeRangeInterval: filterAdjust.selectedTimeRangeInterval,
graphData: buildCorrelationData(
this.graphObjects,
decodeGraphData(this.props.report.x_opencti_graph_data),
this.props.t,
filterAdjust,
),
},
() => this.saveParameters(false),
);
this.selectedLinks.clear();
this.selectedNodes.clear();
if (isNotEmptyField(keyword)) {
const filterByKeyword = (n) => keyword === ''
|| (getMainRepresentative(n) || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1
|| (getSecondaryRepresentative(n) || '')
.toLowerCase()
.indexOf(keyword.toLowerCase()) !== -1
|| (n.entity_type || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1;
this.state.graphData.nodes.map((n) => filterByKeyword(n) && this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size });
}
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { UserContext } from '../../../../utils/hooks/useAuth';
import { caseIncidentMutationFieldPatch } from './CaseIncidentEditionOverview';
import { hexToRGB } from '../../../../utils/Colors';
import EntitiesDetailsRightsBar from '../../../../utils/graph/EntitiesDetailsRightBar';
import { isNotEmptyField } from '../../../../utils/utils';
import { getMainRepresentative, getSecondaryRepresentative } from '../../../../utils/defaultRepresentatives';

const PARAMETERS$ = new Subject().pipe(debounce(() => timer(2000)));
const POSITIONS$ = new Subject().pipe(debounce(() => timer(2000)));
Expand Down Expand Up @@ -810,25 +812,20 @@ class IncidentKnowledgeCorrelationComponent extends Component {
}

handleSearch(keyword) {
const filterAdjust = {
selectedTimeRangeInterval: this.state.selectedTimeRangeInterval,
markedBy: this.state.markedBy,
createdBy: this.state.createdBy,
stixCoreObjectsTypes: this.state.stixCoreObjectsTypes,
keyword,
};
this.setState(
{
selectedTimeRangeInterval: filterAdjust.selectedTimeRangeInterval,
graphData: buildCorrelationData(
this.graphObjects,
decodeGraphData(this.props.grouping.x_opencti_graph_data),
this.props.t,
filterAdjust,
),
},
() => this.saveParameters(false),
);
this.selectedLinks.clear();
this.selectedNodes.clear();
if (isNotEmptyField(keyword)) {
const filterByKeyword = (n) => keyword === ''
|| (getMainRepresentative(n) || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1
|| (getSecondaryRepresentative(n) || '')
.toLowerCase()
.indexOf(keyword.toLowerCase()) !== -1
|| (n.entity_type || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1;
this.state.graphData.nodes.map((n) => filterByKeyword(n) && this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size });
}
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { caseRfiMutationFieldPatch } from './CaseRfiEditionOverview';
import { UserContext } from '../../../../utils/hooks/useAuth';
import CaseRfiKnowledgeGraphBar from './CaseRfiKnowledgeGraphBar';
import EntitiesDetailsRightsBar from '../../../../utils/graph/EntitiesDetailsRightBar';
import { isNotEmptyField } from '../../../../utils/utils';
import { getMainRepresentative, getSecondaryRepresentative } from '../../../../utils/defaultRepresentatives';

const PARAMETERS$ = new Subject().pipe(debounce(() => timer(2000)));
const POSITIONS$ = new Subject().pipe(debounce(() => timer(2000)));
Expand Down Expand Up @@ -810,25 +812,20 @@ class CaseRfiKnowledgeCorrelationComponent extends Component {
}

handleSearch(keyword) {
const filterAdjust = {
selectedTimeRangeInterval: this.state.selectedTimeRangeInterval,
markedBy: this.state.markedBy,
createdBy: this.state.createdBy,
stixCoreObjectsTypes: this.state.stixCoreObjectsTypes,
keyword,
};
this.setState(
{
selectedTimeRangeInterval: filterAdjust.selectedTimeRangeInterval,
graphData: buildCorrelationData(
this.graphObjects,
decodeGraphData(this.props.grouping.x_opencti_graph_data),
this.props.t,
filterAdjust,
),
},
() => this.saveParameters(false),
);
this.selectedLinks.clear();
this.selectedNodes.clear();
if (isNotEmptyField(keyword)) {
const filterByKeyword = (n) => keyword === ''
|| (getMainRepresentative(n) || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1
|| (getSecondaryRepresentative(n) || '')
.toLowerCase()
.indexOf(keyword.toLowerCase()) !== -1
|| (n.entity_type || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1;
this.state.graphData.nodes.map((n) => filterByKeyword(n) && this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size });
}
}

render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import { caseRftMutationFieldPatch } from './CaseRftEditionOverview';
import { UserContext } from '../../../../utils/hooks/useAuth';
import CaseRftKnowledgeGraphBar from './CaseRftKnowledgeGraphBar';
import EntitiesDetailsRightsBar from '../../../../utils/graph/EntitiesDetailsRightBar';
import { isNotEmptyField } from '../../../../utils/utils';
import { getMainRepresentative, getSecondaryRepresentative } from '../../../../utils/defaultRepresentatives';

const PARAMETERS$ = new Subject().pipe(debounce(() => timer(2000)));
const POSITIONS$ = new Subject().pipe(debounce(() => timer(2000)));
Expand Down Expand Up @@ -811,25 +813,20 @@ class CaseRftKnowledgeCorrelationComponent extends Component {
}

handleSearch(keyword) {
const filterAdjust = {
selectedTimeRangeInterval: this.state.selectedTimeRangeInterval,
markedBy: this.state.markedBy,
createdBy: this.state.createdBy,
stixCoreObjectsTypes: this.state.stixCoreObjectsTypes,
keyword,
};
this.setState(
{
selectedTimeRangeInterval: filterAdjust.selectedTimeRangeInterval,
graphData: buildCorrelationData(
this.graphObjects,
decodeGraphData(this.props.grouping.x_opencti_graph_data),
this.props.t,
filterAdjust,
),
},
() => this.saveParameters(false),
);
this.selectedLinks.clear();
this.selectedNodes.clear();
if (isNotEmptyField(keyword)) {
const filterByKeyword = (n) => keyword === ''
|| (getMainRepresentative(n) || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1
|| (getSecondaryRepresentative(n) || '')
.toLowerCase()
.indexOf(keyword.toLowerCase()) !== -1
|| (n.entity_type || '').toLowerCase().indexOf(keyword.toLowerCase())
!== -1;
this.state.graphData.nodes.map((n) => filterByKeyword(n) && this.selectedNodes.add(n));
this.setState({ numberOfSelectedNodes: this.selectedNodes.size });
}
}

render() {
Expand Down

0 comments on commit cfc1f6f

Please sign in to comment.