Skip to content
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

fix: topology interactive 1223 #686

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions ui/src/pages/insightDetail/components/topologyMap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import transferImg from '@/assets/transfer.png'
import { ICON_MAP } from '@/utils/images'

import styles from './style.module.less'

interface NodeConfig extends ModelConfig {
data?: {
name?: string
Expand Down Expand Up @@ -151,6 +150,8 @@ type IProps = {
clusterOptions?: string[]
}

let graph: IAbstractGraph | null = null

const TopologyMap = ({
onTopologyNodeClick,
topologyData,
Expand All @@ -164,7 +165,6 @@ const TopologyMap = ({
const { t } = useTranslation()
const ref = useRef(null)
const graphRef = useRef<any>()
let graph: IAbstractGraph | null = null
const location = useLocation()
const { from, type, query } = queryString.parse(location?.search)
const navigate = useNavigate()
Expand All @@ -178,7 +178,6 @@ const TopologyMap = ({

function handleMouseEnter(evt) {
graph.setItemState(evt.item, 'hoverState', true)
// graph.setItemState(evt.item, 'hoverState', true)
const bbox = evt.item.getBBox()
const point = graph.getCanvasByPoint(bbox.centerX, bbox.minY)
if (bbox) {
Expand Down Expand Up @@ -227,20 +226,6 @@ const TopologyMap = ({
name: 'node-container',
})

// Add background
group.addShape('rect', {
attrs: {
x: 0,
y: 0,
width: nodeWidth,
height: 48,
radius: 6,
fill: isHighLight ? '#f0f5ff' : '#ffffff',
opacity: 0.8,
},
name: 'node-background',
})

// Add side accent
group.addShape('rect', {
attrs: {
Expand Down Expand Up @@ -428,7 +413,6 @@ const TopologyMap = ({
const height = container?.scrollHeight || 400
const toolbar = new G6.ToolBar()
if (!graph && container) {
// eslint-disable-next-line
graphRef.current = graph = new G6.Graph({
container,
width,
Expand Down Expand Up @@ -475,7 +459,6 @@ const TopologyMap = ({
shadowOffsetY: 2,
cursor: 'pointer',
},
draggable: true,
},
defaultEdge: {
type: 'running-edge',
Expand Down Expand Up @@ -507,7 +490,6 @@ const TopologyMap = ({
},
nodeStateStyles: {
selected: {
// fill: '#e6f4ff',
stroke: '#1677ff',
shadowColor: 'rgba(22,119,255,0.12)',
fill: '#f0f5ff',
Expand Down Expand Up @@ -562,14 +544,6 @@ const TopologyMap = ({
}
}
}
return () => {
try {
if (graph) {
graph.destroy()
graphRef.current = null
}
} catch (error) {}
}
// eslint-disable-next-line
}, [topologyData, tableName])

Expand Down
4 changes: 3 additions & 1 deletion ui/src/pages/insightDetail/resource/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,9 @@ const ClusterDetail = () => {
}, [from, key, cluster, kind, namespace, name, i18n?.language])

function onTopologyNodeClick(node: any) {
const { resourceGroup } = node || {}
const {
data: { resourceGroup },
} = node || {}
const paramsObj = {
apiVersion: resourceGroup?.apiVersion,
cluster: resourceGroup?.cluster,
Expand Down
Loading