From eef1a5e81ee4a9a3b1ee45b9481cf73171c2d244 Mon Sep 17 00:00:00 2001 From: Andrei Kuchuk Date: Sat, 21 Sep 2024 22:56:38 +0400 Subject: [PATCH] fix ts errors for profiler call-stat-board --- .../profiler/lib/cytoscape/inicialize.ts | 25 ++----- src/entities/profiler/lib/cytoscape/types.ts | 23 ------ src/entities/profiler/types.ts | 11 +-- .../profiler/ui/call-graph/call-graph.vue | 8 ++- .../profiler/ui/flame-graph/flame-graph.vue | 71 ++++++++++++++----- src/entities/profiler/ui/index.ts | 1 - .../ui/profiler-page/profiler-page.vue | 67 ++--------------- .../profiler/ui/render-graph/render-graph.vue | 31 ++++---- 8 files changed, 81 insertions(+), 156 deletions(-) delete mode 100644 src/entities/profiler/lib/cytoscape/types.ts diff --git a/src/entities/profiler/lib/cytoscape/inicialize.ts b/src/entities/profiler/lib/cytoscape/inicialize.ts index da0e7937..fa56637a 100644 --- a/src/entities/profiler/lib/cytoscape/inicialize.ts +++ b/src/entities/profiler/lib/cytoscape/inicialize.ts @@ -1,34 +1,17 @@ -import cytoscape from 'cytoscape'; -import type { Core as Cytoscape, ElementsDefinition, EventObjectNode, NodeSingular, Stylesheet } from "cytoscape"; +import cytoscape, {type NodeDataDefinition} from 'cytoscape'; +import type { Core as Cytoscape, ElementsDefinition, EventObjectNode, Stylesheet } from "cytoscape"; import dagre, { type DagreLayoutOptions } from "cytoscape-dagre"; -import type {ProfilerEdge} from "../../types"; import { cytoscapeStyles } from "./config"; type TInitializeProps = { elements: ElementsDefinition, container: HTMLElement, - onNodeHover: (edge?: ProfilerEdge, event?: MouseEvent) => void, + onNodeHover: (data?: NodeDataDefinition, event?: MouseEvent) => void, } type TInitialize = (data: TInitializeProps) => () => void; -const formatProfilerEdge = (node?: NodeSingular): ProfilerEdge | undefined => { - if (!node) { - return undefined; - } - - const data = node.data(); - - return { - id: data.id, - parent: data.name, - caller: data.caller, - callee: data.callee, - cost: data.cost, - } -} - const initialize: TInitialize = ({ elements, container, @@ -51,7 +34,7 @@ const initialize: TInitialize = ({ }); cy.on("mouseover", "node", (event: EventObjectNode) => { - onNodeHover(formatProfilerEdge(event.target), event.originalEvent); + onNodeHover(event.target.data(), event.originalEvent); }); cy.on("mouseout", "node", () => { diff --git a/src/entities/profiler/lib/cytoscape/types.ts b/src/entities/profiler/lib/cytoscape/types.ts deleted file mode 100644 index d42d2aba..00000000 --- a/src/entities/profiler/lib/cytoscape/types.ts +++ /dev/null @@ -1,23 +0,0 @@ -import type { ProfilerCost } from "../../types"; - -export type TNode = { - data: { - id: string, - parent: string | null, - name: string, - cost?: ProfilerCost, - color?: string, - textColor?: string, - } -} - -export type TEdge = { - data: { - id?: string, - source: string, - target: string, - label?: string, - color?: string, - weight?: number, - } -} diff --git a/src/entities/profiler/types.ts b/src/entities/profiler/types.ts index 91f3a477..b187236b 100644 --- a/src/entities/profiler/types.ts +++ b/src/entities/profiler/types.ts @@ -24,14 +24,6 @@ export interface ProfilerCost { excl_ct: number, } -export interface ProfilerEdge { - id: string, - parent: string | null, - caller: string | null, - callee: string, - cost: StatsBase -} - export interface Profiler { tags: { [key: string]: string | null | number @@ -72,4 +64,5 @@ export interface ProfileFlameChart { type: "task" | string } -export type CallStackHoverData = ProfilerEdge & { position: { x: number; y: number } } + +export type CallStackHoverData = { title: string, cost: Partial} diff --git a/src/entities/profiler/ui/call-graph/call-graph.vue b/src/entities/profiler/ui/call-graph/call-graph.vue index 083d8b03..b3984104 100644 --- a/src/entities/profiler/ui/call-graph/call-graph.vue +++ b/src/entities/profiler/ui/call-graph/call-graph.vue @@ -2,7 +2,7 @@ import type { ElementsDefinition } from 'cytoscape' import { ref, computed, onMounted, watchEffect } from 'vue' import { type EventId, GraphTypes } from '@/shared/types' -import { IconSvg } from '@/shared/ui' +import { IconSvg, type StatBoardCost } from '@/shared/ui' import { useProfiler } from '../../lib' import type { ProfilerCallGraph } from '../../types' import { CallStatBoard } from '../call-stat-board' @@ -83,7 +83,11 @@ const percentLabel = computed(() => (metric.value === GraphTypes.CALLS ? 'Min ca :height="graphHeight" > diff --git a/src/entities/profiler/ui/flame-graph/flame-graph.vue b/src/entities/profiler/ui/flame-graph/flame-graph.vue index d94e49e0..070ff18a 100644 --- a/src/entities/profiler/ui/flame-graph/flame-graph.vue +++ b/src/entities/profiler/ui/flame-graph/flame-graph.vue @@ -1,28 +1,52 @@ @@ -97,6 +118,14 @@ onBeforeUnmount(() => {
+ + @@ -114,4 +143,8 @@ onBeforeUnmount(() => { .flame-graph__canvas { @apply w-full h-full bg-white pt-3; } + +.profiler-page__hover-edge { + @apply absolute z-10 h-auto; +} diff --git a/src/entities/profiler/ui/index.ts b/src/entities/profiler/ui/index.ts index cd6e0d9d..e921ff7d 100644 --- a/src/entities/profiler/ui/index.ts +++ b/src/entities/profiler/ui/index.ts @@ -1,3 +1,2 @@ export * from './preview-card' -export * from './render-graph' export * from './profiler-page' diff --git a/src/entities/profiler/ui/profiler-page/profiler-page.vue b/src/entities/profiler/ui/profiler-page/profiler-page.vue index 37e34b1f..51a5c29f 100644 --- a/src/entities/profiler/ui/profiler-page/profiler-page.vue +++ b/src/entities/profiler/ui/profiler-page/profiler-page.vue @@ -1,10 +1,9 @@