Skip to content

Commit

Permalink
fix bug where element-id showed incorrectly in table
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Nov 6, 2023
1 parent 3e06f72 commit c6d06c7
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ export function DetailsPane({
value: `${vizItem.item.id}`,
type: 'String'
}
const allItemProperties = [idProperty, ...vizItem.item.propertyList].sort(
(a, b) => (a.key < b.key ? -1 : 1)
)
const elementIdProperty = {
key: '<elementId>',
value: `${vizItem.item.elementId}`,
type: 'String'
}
const allItemProperties = [
idProperty,
elementIdProperty,
...vizItem.item.propertyList
].sort((a, b) => (a.key < b.key ? -1 : 1))
const visibleItemProperties = allItemProperties.slice(0, maxPropertiesCount)

const handleMorePropertiesClick = (numMore: number) => {
Expand Down
2 changes: 2 additions & 0 deletions src/neo4j-arc/common/types/arcTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
*/
export type BasicNode = {
id: string
elementId: string
labels: string[]
properties: Record<string, string>
propertyTypes: Record<string, string>
}
export type BasicRelationship = {
id: string
elementId: string
startNodeId: string
endNodeId: string
type: string
Expand Down
2 changes: 2 additions & 0 deletions src/neo4j-arc/common/utils/driverUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const extractUniqueNodesAndRels = (
const nodes = Array.from(nodeMap.values()).map(item => {
return {
id: item.identity.toString(),
elementId: item.elementId,
labels: item.labels,
properties: mapObjectValues(item.properties, propertyToString),
propertyTypes: mapObjectValues(
Expand All @@ -142,6 +143,7 @@ export const extractUniqueNodesAndRels = (
.map(item => {
return {
id: item.identity.toString(),
elementId: item.elementId,
startNodeId: item.start.toString(),
endNodeId: item.end.toString(),
type: item.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ export function DefaultDetailsPane({
value: `${vizItem.item.id}`,
type: 'String'
}
const allItemProperties = [idProperty, ...vizItem.item.propertyList].sort(
(a, b) => (a.key < b.key ? -1 : 1)
)
const elementIdProperty = {
key: '<element-id>',
value: `${vizItem.item.elementId}`,
type: 'String'
}
const allItemProperties = [
idProperty,
elementIdProperty,
...vizItem.item.propertyList
].sort((a, b) => (a.key < b.key ? -1 : 1))
const visibleItemProperties = allItemProperties.slice(0, maxPropertiesCount)

const handleMorePropertiesClick = (numMore: number) => {
Expand Down
5 changes: 4 additions & 1 deletion src/neo4j-arc/graph-visualization/models/Node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export type NodeCaptionLine = {

export class NodeModel {
id: string
elementId: string
labels: string[]
propertyList: VizItemProperty[]
propertyMap: NodeProperties
Expand All @@ -55,7 +56,8 @@ export class NodeModel {
id: string,
labels: string[],
properties: NodeProperties,
propertyTypes: Record<string, string>
propertyTypes: Record<string, string>,
elementId: string
) {
this.id = id
this.labels = labels
Expand All @@ -76,6 +78,7 @@ export class NodeModel {
this.y = 0
this.hoverFixed = false
this.initialPositionCalculated = false
this.elementId = elementId
}

toJSON(): NodeProperties {
Expand Down
6 changes: 5 additions & 1 deletion src/neo4j-arc/graph-visualization/models/Relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { NodeModel } from './Node'
export type RelationshipCaptionLayout = 'internal' | 'external'
export class RelationshipModel {
id: string
elementId: string
propertyList: VizItemProperty[]
propertyMap: Record<string, string>
source: NodeModel
Expand All @@ -52,7 +53,8 @@ export class RelationshipModel {
target: NodeModel,
type: string,
properties: Record<string, string>,
propertyTypes: Record<string, string>
propertyTypes: Record<string, string>,
elementId: string
) {
this.id = id
this.source = source
Expand All @@ -73,6 +75,8 @@ export class RelationshipModel {
this.captionHeight = 0
this.captionLayout = 'internal'
this.centreDistance = 0

this.elementId = elementId
}

toJSON(): Record<string, string> {
Expand Down
4 changes: 2 additions & 2 deletions src/neo4j-arc/graph-visualization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type VizItem =

export type NodeItem = {
type: 'node'
item: Pick<NodeModel, 'id' | 'labels' | 'propertyList'>
item: Pick<NodeModel, 'id' | 'elementId' | 'labels' | 'propertyList'>
}

type ContextMenuItem = {
Expand All @@ -49,7 +49,7 @@ type StatusItem = {

export type RelationshipItem = {
type: 'relationship'
item: Pick<RelationshipModel, 'id' | 'type' | 'propertyList'>
item: Pick<RelationshipModel, 'id' | 'elementId' | 'type' | 'propertyList'>
}

type CanvasItem = {
Expand Down
6 changes: 4 additions & 2 deletions src/neo4j-arc/graph-visualization/utils/mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export function mapNodes(nodes: BasicNode[]): NodeModel[] {
node.id,
node.labels,
mapProperties(node.properties),
node.propertyTypes
node.propertyTypes,
node.elementId
)
)
}
Expand All @@ -64,7 +65,8 @@ export function mapRelationships(
target,
rel.type,
mapProperties(rel.properties),
rel.propertyTypes
rel.propertyTypes,
rel.elementId
)
})
}
Expand Down
11 changes: 9 additions & 2 deletions src/shared/services/bolt/boltMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export function extractNodesAndRelationshipsFromRecordsForOldVis(
const nodes = rawNodes.map(item => {
return {
id: item.identity.toString(),
elementId: item.elementId,
labels: item.labels,
properties: itemIntToString(item.properties, converters),
propertyTypes: Object.entries(item.properties).reduce(
Expand All @@ -274,6 +275,8 @@ export function extractNodesAndRelationshipsFromRecordsForOldVis(
relationships = relationships.map(item => {
return {
id: item.identity.toString(),
elementId: item.elementId,
// end node element ID?
startNodeId: item.start.toString(),
endNodeId: item.end.toString(),
type: item.type,
Expand Down Expand Up @@ -427,15 +430,19 @@ export const applyGraphTypes = (
return new types[className](
applyGraphTypes(tmpItem.identity, types),
tmpItem.labels,
applyGraphTypes(tmpItem.properties, types)
applyGraphTypes(tmpItem.properties, types),
tmpItem.elementId
)
case 'Relationship':
return new types[className](
applyGraphTypes(tmpItem.identity, types),
applyGraphTypes(item.start, types),
applyGraphTypes(item.end, types),
item.type,
applyGraphTypes(item.properties, types)
applyGraphTypes(item.properties, types),
tmpItem.elementId,
tmpItem.startNodeElementId,
tmpItem.endNodeElementId
)
case 'PathSegment':
return new types[className](
Expand Down

0 comments on commit c6d06c7

Please sign in to comment.