diff --git a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsHorizontalBars.jsx b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsHorizontalBars.jsx index d92324efbbd3..f1fe3aa6a6d2 100644 --- a/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsHorizontalBars.jsx +++ b/opencti-platform/opencti-front/src/private/components/common/stix_core_objects/StixCoreObjectsHorizontalBars.jsx @@ -25,363 +25,191 @@ const useStyles = makeStyles(() => ({ })); const stixCoreObjectsHorizontalBarsDistributionQuery = graphql` - query StixCoreObjectsHorizontalBarsDistributionQuery( - $objectId: [String] - $relationship_type: [String] - $toTypes: [String] - $field: String! - $startDate: DateTime - $endDate: DateTime - $dateAttribute: String - $operation: StatsOperation! - $limit: Int - $order: String - $types: [String] - $filters: FilterGroup - $search: String - $subDistributionRelationshipType: [String] - $subDistributionToTypes: [String] - $subDistributionField: String! - $subDistributionStartDate: DateTime - $subDistributionEndDate: DateTime - $subDistributionDateAttribute: String - $subDistributionOperation: StatsOperation! - $subDistributionLimit: Int - $subDistributionOrder: String - $subDistributionTypes: [String] - $subDistributionFilters: FilterGroup - $subDistributionSearch: String - ) { - stixCoreObjectsDistribution( - objectId: $objectId - relationship_type: $relationship_type - toTypes: $toTypes - field: $field - startDate: $startDate - endDate: $endDate - dateAttribute: $dateAttribute - operation: $operation - limit: $limit - order: $order - types: $types - filters: $filters - search: $search + query StixCoreObjectsHorizontalBarsDistributionQuery( + $objectId: [String] + $relationship_type: [String] + $toTypes: [String] + $field: String! + $startDate: DateTime + $endDate: DateTime + $dateAttribute: String + $operation: StatsOperation! + $limit: Int + $order: String + $types: [String] + $filters: FilterGroup + $search: String ) { - label - value - entity { - ... on BasicObject { - entity_type - id - } - ... on BasicRelationship { - entity_type - id - } - ... on StixCoreObject { - stixCoreObjectsDistribution( - relationship_type: $subDistributionRelationshipType - toTypes: $subDistributionToTypes - field: $subDistributionField - startDate: $subDistributionStartDate - endDate: $subDistributionEndDate - dateAttribute: $subDistributionDateAttribute - operation: $subDistributionOperation - limit: $subDistributionLimit - order: $subDistributionOrder - types: $subDistributionTypes - filters: $subDistributionFilters - search: $subDistributionSearch - ) { + stixCoreObjectsDistribution( + objectId: $objectId + relationship_type: $relationship_type + toTypes: $toTypes + field: $field + startDate: $startDate + endDate: $endDate + dateAttribute: $dateAttribute + operation: $operation + limit: $limit + order: $order + types: $types + filters: $filters + search: $search + ) { label value entity { - ... on BasicObject { - entity_type - id - } - ... on AttackPattern { - name - description - } - ... on Campaign { - name - description - } - ... on CourseOfAction { - name - description - } - ... on Individual { - name - description - } - ... on Organization { - name - description - } - ... on Sector { - name - description - } - ... on System { - name - description - } - ... on Indicator { - name - description - } - ... on Infrastructure { - name - description - } - ... on IntrusionSet { - name - description - } - ... on Position { - name - description - } - ... on City { - name - description - } - ... on Country { - name - description - } - ... on Region { - name - description - } - ... on Malware { - name - description - } - ... on MalwareAnalysis { - result_name - } - ... on ThreatActor { - name - description - } - ... on Tool { - name - description - } - ... on Vulnerability { - name - description - } - ... on Incident { - name - description - } - ... on Event { - name - description - } - ... on Channel { - name - description - } - ... on Narrative { - name - description - } - ... on Language { - name - } - ... on DataComponent { - name - description - } - ... on DataSource { - name - description - } - ... on Case { - name - description - } - ... on StixCyberObservable { - observable_value - } - ... on MarkingDefinition { - definition_type - definition - } - ... on Report { - name - } - ... on Grouping { - name - } - ... on Note { - attribute_abstract - content - } - ... on Opinion { - opinion - } - ... on Label { - value - } - ... on Status { - template { - name - color + ... on BasicObject { + entity_type + id + } + ... on BasicRelationship { + entity_type + id + } + ... on AttackPattern { + name + description + } + ... on Campaign { + name + description + } + ... on CourseOfAction { + name + description + } + ... on Individual { + name + description + } + ... on Organization { + name + description + } + ... on Sector { + name + description + } + ... on System { + name + description + } + ... on Indicator { + name + description + } + ... on Infrastructure { + name + description + } + ... on IntrusionSet { + name + description + } + ... on Position { + name + description + } + ... on City { + name + description + } + ... on AdministrativeArea { + name + description + } + ... on Country { + name + description + } + ... on Region { + name + description + } + ... on Malware { + name + description + } + ... on MalwareAnalysis { + result_name + } + ... on ThreatActor { + name + description + } + ... on Tool { + name + description + } + ... on Vulnerability { + name + description + } + ... on Incident { + name + description + } + ... on Event { + name + description + } + ... on Channel { + name + description + } + ... on Narrative { + name + description + } + ... on Language { + name + } + ... on DataComponent { + name + } + ... on DataSource { + name + } + ... on Case { + name + } + ... on StixCyberObservable { + observable_value + } + ... on MarkingDefinition { + definition_type + definition + x_opencti_color + } + ... on Creator { + name + } + ... on Report { + name + } + ... on Grouping { + name + } + ... on Note { + attribute_abstract + content + } + ... on Opinion { + opinion + } + ... on Label { + value + color + } + ... on Status { + template { + name + color + } } - } } - } - } - ... on AttackPattern { - name - description - } - ... on Campaign { - name - description - } - ... on CourseOfAction { - name - description - } - ... on Individual { - name - description - } - ... on Organization { - name - description - } - ... on Sector { - name - description - } - ... on System { - name - description - } - ... on Indicator { - name - description - } - ... on Infrastructure { - name - description - } - ... on IntrusionSet { - name - description - } - ... on Position { - name - description - } - ... on City { - name - description - } - ... on AdministrativeArea { - name - description - } - ... on Country { - name - description - } - ... on Region { - name - description - } - ... on Malware { - name - description - } - ... on MalwareAnalysis { - result_name - } - ... on ThreatActor { - name - description - } - ... on Tool { - name - description - } - ... on Vulnerability { - name - description - } - ... on Incident { - name - description - } - ... on Event { - name - description - } - ... on Channel { - name - description - } - ... on Narrative { - name - description - } - ... on Language { - name - } - ... on DataComponent { - name - } - ... on DataSource { - name - } - ... on Case { - name - } - ... on StixCyberObservable { - observable_value - } - ... on MarkingDefinition { - definition_type - definition - x_opencti_color - } - ... on Creator { - name - } - ... on Report { - name - } - ... on Grouping { - name - } - ... on Note { - attribute_abstract - content - } - ... on Opinion { - opinion - } - ... on Label { - value - color - } - ... on Status { - template { - name - color - } } - } } - } `; const StixCoreObjectsHorizontalBars = ({ @@ -402,9 +230,6 @@ const StixCoreObjectsHorizontalBars = ({ const selection = dataSelection[0]; const dataSelectionTypes = ['Stix-Core-Object']; const { filters, dataSelectionElementId, dataSelectionToTypes } = buildFiltersAndOptionsForWidgets(selection.filters); - const subSelection = dataSelection[1]; - const subSelectionDataSelectionTypes = ['Stix-Core-Object']; - const { filters: subSelectionFilters, dataSelectionToTypes: subSelectionDataSelectionToTypes } = buildFiltersAndOptionsForWidgets(subSelection.filters); return ( 0 - ? selection.date_attribute - : 'created_at', + selection.date_attribute && selection.date_attribute.length > 0 + ? selection.date_attribute + : 'created_at', filters, limit: selection.number ?? 10, - subDistributionToTypes: subSelectionDataSelectionToTypes, - subDistributionField: subSelection.attribute, - subDistributionStartDate: startDate, - subDistributionEndDate: endDate, - subDistributionDateAttribute: - subSelection.date_attribute - && subSelection.date_attribute.length > 0 - ? subSelection.date_attribute - : 'created_at', - subDistributionOperation: 'count', - subDistributionLimit: subSelection.number ?? 10, - subDistributionTypes: subSelectionDataSelectionTypes, - subDistributionFilters: subSelectionFilters, }} render={({ props }) => { if ( props - && props.stixCoreObjectsDistribution - && props.stixCoreObjectsDistribution.length > 0 + && props.stixCoreObjectsDistribution + && props.stixCoreObjectsDistribution.length > 0 ) { const data = props.stixCoreObjectsDistribution.map((n) => { let color = selection.attribute.endsWith('_id') @@ -453,24 +265,24 @@ const StixCoreObjectsHorizontalBars = ({ } if (n.entity?.x_opencti_color) { color = theme.palette.mode === 'light' - && n.entity.x_opencti_color === '#ffffff' + && n.entity.x_opencti_color === '#ffffff' ? '#000000' : n.entity.x_opencti_color; } if (n.entity?.template?.color) { color = theme.palette.mode === 'light' - && n.entity.template.color === '#ffffff' + && n.entity.template.color === '#ffffff' ? '#000000' : n.entity.template.color; } return { x: - // eslint-disable-next-line no-nested-ternary - selection.attribute.endsWith('_id') - ? defaultValue(n.entity) - : selection.attribute === 'entity_type' - ? t_i18n(`entity_${n.label}`) - : n.label, + // eslint-disable-next-line no-nested-ternary + selection.attribute.endsWith('_id') + ? defaultValue(n.entity) + : selection.attribute === 'entity_type' + ? t_i18n(`entity_${n.label}`) + : n.label, y: n.value, fillColor: color, };