ydb-embedded-ui 20.5.0 → 21.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -0
- package/dist/components/AutoRefreshControl/i18n/index.d.ts +1 -1
- package/dist/components/CriticalActionDialog/CriticalActionDialog.js +10 -6
- package/dist/components/CriticalActionDialog/CriticalActionDialog.js.map +1 -1
- package/dist/components/CriticalActionDialog/i18n/en.json +1 -2
- package/dist/components/CriticalActionDialog/i18n/index.d.ts +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +2 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/FullNodeViewer/i18n/index.d.ts +1 -1
- package/dist/components/Graph/BlockComponents/ConnectionBlockComponent.d.ts +7 -0
- package/dist/components/Graph/BlockComponents/ConnectionBlockComponent.js +30 -0
- package/dist/components/Graph/BlockComponents/ConnectionBlockComponent.js.map +1 -0
- package/dist/components/Graph/BlockComponents/QueryBlockComponent.d.ts +5 -0
- package/dist/components/Graph/BlockComponents/QueryBlockComponent.js +5 -0
- package/dist/components/Graph/BlockComponents/QueryBlockComponent.js.map +1 -0
- package/dist/components/Graph/BlockComponents/ResultBlockComponent.d.ts +7 -0
- package/dist/components/Graph/BlockComponents/ResultBlockComponent.js +5 -0
- package/dist/components/Graph/BlockComponents/ResultBlockComponent.js.map +1 -0
- package/dist/components/Graph/BlockComponents/StageBlockComponent.d.ts +7 -0
- package/dist/components/Graph/BlockComponents/StageBlockComponent.js +17 -0
- package/dist/components/Graph/BlockComponents/StageBlockComponent.js.map +1 -0
- package/dist/components/Graph/FullViewportBackground.d.ts +2 -0
- package/dist/components/Graph/FullViewportBackground.js +67 -0
- package/dist/components/Graph/FullViewportBackground.js.map +1 -0
- package/dist/components/Graph/GraphControls.d.ts +6 -0
- package/dist/components/Graph/GraphControls.js +24 -0
- package/dist/components/Graph/GraphControls.js.map +1 -0
- package/dist/components/Graph/GravityGraph.d.ts +9 -0
- package/dist/components/Graph/GravityGraph.js +122 -0
- package/dist/components/Graph/GravityGraph.js.map +1 -0
- package/dist/components/Graph/GravityGraph.scss +131 -0
- package/dist/components/Graph/NonSelectableConnection.d.ts +9 -0
- package/dist/components/Graph/NonSelectableConnection.js +16 -0
- package/dist/components/Graph/NonSelectableConnection.js.map +1 -0
- package/dist/components/Graph/TooltipComponent.d.ts +8 -0
- package/dist/components/Graph/TooltipComponent.js +63 -0
- package/dist/components/Graph/TooltipComponent.js.map +1 -0
- package/dist/components/Graph/colorsConfig.d.ts +19 -0
- package/dist/components/Graph/colorsConfig.js +20 -0
- package/dist/components/Graph/colorsConfig.js.map +1 -0
- package/dist/components/Graph/i18n/en.json +5 -0
- package/dist/components/Graph/i18n/index.d.ts +2 -0
- package/dist/components/Graph/i18n/index.js +5 -0
- package/dist/components/Graph/i18n/index.js.map +1 -0
- package/dist/components/Graph/runTreeLayout.d.ts +12 -0
- package/dist/components/Graph/runTreeLayout.js +75 -0
- package/dist/components/Graph/runTreeLayout.js.map +1 -0
- package/dist/components/Graph/treeLayout.d.ts +2 -0
- package/dist/components/Graph/treeLayout.js +284 -0
- package/dist/components/Graph/treeLayout.js.map +1 -0
- package/dist/components/Graph/types.d.ts +52 -0
- package/dist/components/Graph/types.js +2 -0
- package/dist/components/Graph/types.js.map +1 -0
- package/dist/components/Graph/utils.d.ts +6 -0
- package/dist/components/Graph/utils.js +88 -0
- package/dist/components/Graph/utils.js.map +1 -0
- package/dist/components/PDiskInfo/i18n/index.d.ts +1 -1
- package/dist/components/VDiskInfo/i18n/index.d.ts +1 -1
- package/dist/containers/Clusters/constants.d.ts +1 -1
- package/dist/containers/Header/HeaderActionsMenu.js +19 -3
- package/dist/containers/Header/HeaderActionsMenu.js.map +1 -1
- package/dist/containers/Header/hooks/useSharedDatabasePath.d.ts +4 -1
- package/dist/containers/Header/hooks/useSharedDatabasePath.js +14 -10
- package/dist/containers/Header/hooks/useSharedDatabasePath.js.map +1 -1
- package/dist/containers/Header/i18n/en.json +1 -0
- package/dist/containers/Header/i18n/index.d.ts +1 -1
- package/dist/containers/Nodes/i18n/index.d.ts +1 -1
- package/dist/containers/Operations/columns.js +2 -2
- package/dist/containers/Operations/columns.js.map +1 -1
- package/dist/containers/Operations/constants.d.ts +1 -1
- package/dist/containers/Operations/i18n/en.json +2 -2
- package/dist/containers/PDiskPage/DecommissionButton/DecommissionButton.js +1 -1
- package/dist/containers/PDiskPage/DecommissionButton/DecommissionButton.js.map +1 -1
- package/dist/containers/PDiskPage/PDiskPage.js +1 -1
- package/dist/containers/PDiskPage/PDiskPage.js.map +1 -1
- package/dist/containers/PDiskPage/i18n/en.json +3 -3
- package/dist/containers/Storage/PDisks/PDisks.js +1 -1
- package/dist/containers/Storage/PDisks/PDisks.js.map +1 -1
- package/dist/containers/Tablet/components/TabletControls/TabletControls.js +1 -1
- package/dist/containers/Tablet/components/TabletControls/TabletControls.js.map +1 -1
- package/dist/containers/Tablet/i18n/en.json +3 -3
- package/dist/containers/Tablets/TabletsTable.js +1 -1
- package/dist/containers/Tablets/TabletsTable.js.map +1 -1
- package/dist/containers/Tablets/i18n/en.json +1 -1
- package/dist/containers/Tenant/Diagnostics/Overview/TransferInfo/Credentials.d.ts +1 -1
- package/dist/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/HealthcheckPreview.js +3 -1
- package/dist/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/HealthcheckPreview.js.map +1 -1
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +2 -2
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js.map +1 -1
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/useTenantStorageNewData.d.ts +2 -2
- package/dist/containers/Tenant/Healthcheck/components/HealthcheckDrawer.js +10 -2
- package/dist/containers/Tenant/Healthcheck/components/HealthcheckDrawer.js.map +1 -1
- package/dist/containers/Tenant/Query/QueryResult/components/Graph/Graph.js +9 -4
- package/dist/containers/Tenant/Query/QueryResult/components/Graph/Graph.js.map +1 -1
- package/dist/containers/Tenant/Query/QueryResult/components/Graph/Graph.scss +2 -0
- package/dist/containers/Tenant/TenantNavigation/useTenantNavigation.d.ts +1 -1
- package/dist/graphLayout.worker.d.ts +1 -0
- package/dist/graphLayout.worker.js +17 -0
- package/dist/graphLayout.worker.js.map +1 -0
- package/dist/lib.d.ts +1 -1
- package/dist/lib.js.map +1 -1
- package/dist/store/reducers/query/parsers/preparePlanData.js.map +1 -1
- package/dist/store/reducers/query/types.d.ts +38 -1
- package/dist/store/reducers/settings/utils.d.ts +2 -2
- package/dist/store/reducers/storage/utils.js +3 -3
- package/dist/store/reducers/storage/utils.js.map +1 -1
- package/dist/uiFactory/types.d.ts +9 -0
- package/dist/uiFactory/uiFactory.js +5 -2
- package/dist/uiFactory/uiFactory.js.map +1 -1
- package/dist/utils/disks/helpers.d.ts +2 -2
- package/dist/utils/hooks/useChangedQuerySettings.d.ts +2 -2
- package/dist/utils/hooks/useLastQueryExecutionSettings.d.ts +2 -2
- package/dist/utils/hooks/useQueryExecutionSettings.d.ts +2 -2
- package/dist/utils/prepareQueryExplain.d.ts +1 -2
- package/dist/utils/prepareQueryExplain.js +10 -2
- package/dist/utils/prepareQueryExplain.js.map +1 -1
- package/dist/utils/query.d.ts +1 -1
- package/package.json +3 -3
- package/src/components/CriticalActionDialog/CriticalActionDialog.tsx +12 -25
- package/src/components/CriticalActionDialog/i18n/en.json +1 -2
- package/src/components/DropdownMenu/DropdownMenu.tsx +3 -2
- package/src/components/Graph/BlockComponents/ConnectionBlockComponent.tsx +49 -0
- package/src/components/Graph/BlockComponents/QueryBlockComponent.tsx +7 -0
- package/src/components/Graph/BlockComponents/ResultBlockComponent.tsx +10 -0
- package/src/components/Graph/BlockComponents/StageBlockComponent.tsx +35 -0
- package/src/components/Graph/FullViewportBackground.ts +122 -0
- package/src/components/Graph/GraphControls.tsx +49 -0
- package/src/components/Graph/GravityGraph.scss +131 -0
- package/src/components/Graph/GravityGraph.tsx +174 -0
- package/src/components/Graph/NonSelectableConnection.tsx +14 -0
- package/src/components/Graph/TooltipComponent.tsx +114 -0
- package/src/components/Graph/colorsConfig.ts +21 -0
- package/src/components/Graph/i18n/en.json +5 -0
- package/src/components/Graph/i18n/index.ts +7 -0
- package/src/components/Graph/runTreeLayout.ts +105 -0
- package/src/components/Graph/treeLayout.ts +378 -0
- package/src/components/Graph/types.ts +56 -0
- package/src/components/Graph/utils.ts +112 -0
- package/src/containers/Header/HeaderActionsMenu.tsx +22 -2
- package/src/containers/Header/hooks/useSharedDatabasePath.ts +33 -26
- package/src/containers/Header/i18n/en.json +1 -0
- package/src/containers/Operations/columns.tsx +4 -0
- package/src/containers/Operations/i18n/en.json +2 -2
- package/src/containers/PDiskPage/DecommissionButton/DecommissionButton.tsx +2 -0
- package/src/containers/PDiskPage/PDiskPage.tsx +3 -1
- package/src/containers/PDiskPage/i18n/en.json +3 -3
- package/src/containers/Storage/PDisks/PDisks.tsx +1 -1
- package/src/containers/Tablet/components/TabletControls/TabletControls.tsx +7 -1
- package/src/containers/Tablet/i18n/en.json +3 -3
- package/src/containers/Tablets/TabletsTable.tsx +3 -1
- package/src/containers/Tablets/i18n/en.json +1 -1
- package/src/containers/Tenant/Diagnostics/TenantOverview/Healthcheck/HealthcheckPreview.tsx +3 -1
- package/src/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx +2 -2
- package/src/containers/Tenant/Healthcheck/components/HealthcheckDrawer.tsx +16 -1
- package/src/containers/Tenant/Query/QueryResult/components/Graph/Graph.scss +2 -0
- package/src/containers/Tenant/Query/QueryResult/components/Graph/Graph.tsx +13 -7
- package/src/graphLayout.worker.ts +21 -0
- package/src/lib.ts +1 -0
- package/src/store/reducers/query/parsers/preparePlanData.ts +1 -3
- package/src/store/reducers/query/types.ts +42 -2
- package/src/store/reducers/storage/utils.ts +3 -3
- package/src/uiFactory/types.ts +10 -0
- package/src/uiFactory/uiFactory.ts +12 -2
- package/src/utils/prepareQueryExplain.ts +13 -5
- package/dist/components/Graph/Graph.d.ts +0 -12
- package/dist/components/Graph/Graph.js +0 -44
- package/dist/components/Graph/Graph.js.map +0 -1
- package/dist/components/Graph/colors.d.ts +0 -10
- package/dist/components/Graph/colors.js +0 -53
- package/dist/components/Graph/colors.js.map +0 -1
- package/src/components/Graph/Graph.tsx +0 -70
- package/src/components/Graph/colors.ts +0 -75
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { getTopology, getYdbPlanNodeShape } from '@gravity-ui/paranoid';
|
|
4
|
-
import { getGraphColorsFromElement, prepareGraphOptions } from './colors';
|
|
5
|
-
export function Graph(props) {
|
|
6
|
-
const containerRef = React.useRef(null);
|
|
7
|
-
const containerId = React.useId();
|
|
8
|
-
const { data, opts, shapes } = props;
|
|
9
|
-
React.useEffect(() => {
|
|
10
|
-
const graphRoot = containerRef.current;
|
|
11
|
-
if (!graphRoot) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
graphRoot.innerHTML = '';
|
|
15
|
-
// set width and height to screen size to make a canvas bigger then the container
|
|
16
|
-
graphRoot.style.setProperty('width', '100vw');
|
|
17
|
-
graphRoot.style.setProperty('height', '100vh');
|
|
18
|
-
const graphColors = getGraphColorsFromElement(graphRoot);
|
|
19
|
-
const topology = getTopology(graphRoot.id, data, prepareGraphOptions(opts, graphColors), shapes);
|
|
20
|
-
topology.render();
|
|
21
|
-
graphRoot.style.setProperty('width', '100%');
|
|
22
|
-
graphRoot.style.setProperty('height', '100%');
|
|
23
|
-
return () => {
|
|
24
|
-
topology.destroy();
|
|
25
|
-
};
|
|
26
|
-
}, [data, opts, shapes]);
|
|
27
|
-
return _jsx("div", { id: containerId, ref: containerRef, style: { overflow: 'auto' } });
|
|
28
|
-
}
|
|
29
|
-
const renderExplainNode = (node) => {
|
|
30
|
-
const parts = node.name.split('|');
|
|
31
|
-
return parts.length > 1 ? parts[1] : node.name;
|
|
32
|
-
};
|
|
33
|
-
const schemaOptions = {
|
|
34
|
-
renderNodeTitle: renderExplainNode,
|
|
35
|
-
textOverflow: 'normal',
|
|
36
|
-
initialZoomFitsCanvas: true,
|
|
37
|
-
};
|
|
38
|
-
const schemaShapes = {
|
|
39
|
-
node: getYdbPlanNodeShape,
|
|
40
|
-
};
|
|
41
|
-
export function YDBGraph(props) {
|
|
42
|
-
return _jsx(Graph, { ...props, opts: schemaOptions, shapes: schemaShapes });
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=Graph.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.js","sourceRoot":"","sources":["../../../src/components/Graph/Graph.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,sBAAsB,CAAC;AAGtE,OAAO,EAAC,yBAAyB,EAAE,mBAAmB,EAAC,MAAM,UAAU,CAAC;AAQxE,MAAM,UAAU,KAAK,CAAI,KAAoB;IACzC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAAiB,IAAI,CAAC,CAAC;IACxD,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAElC,MAAM,EAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,GAAG,KAAK,CAAC;IAEnC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,MAAM,SAAS,GAAG,YAAY,CAAC,OAAO,CAAC;QACvC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,OAAO,SAAS,CAAC;QACrB,CAAC;QAED,SAAS,CAAC,SAAS,GAAG,EAAE,CAAC;QACzB,iFAAiF;QACjF,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC9C,SAAS,CAAC,KAAK,CAAC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AK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,GAAI,CAAC;AAC9E,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Colors, Options } from '@gravity-ui/paranoid';
|
|
2
|
-
type CssVariableReader = (name: string) => string;
|
|
3
|
-
export interface GraphColors extends Colors {
|
|
4
|
-
getCommonColor(name: string): string;
|
|
5
|
-
}
|
|
6
|
-
export declare function normalizeCssColor(color: string): string;
|
|
7
|
-
export declare function getGraphColors(readCssVariable?: CssVariableReader): GraphColors;
|
|
8
|
-
export declare function getGraphColorsFromElement(element: Element): GraphColors;
|
|
9
|
-
export declare function prepareGraphOptions(options?: Options, graphColors?: GraphColors): Options;
|
|
10
|
-
export {};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { colord } from 'colord';
|
|
2
|
-
const GRAPH_COLOR_VARIABLES = {
|
|
3
|
-
success: '--g-color-text-positive',
|
|
4
|
-
error: '--g-color-text-danger',
|
|
5
|
-
warning: '--g-color-text-warning',
|
|
6
|
-
errorBackground: '--g-color-base-danger-light',
|
|
7
|
-
warningBackground: '--g-color-base-warning-light',
|
|
8
|
-
mute: '--g-color-line-generic',
|
|
9
|
-
stroke: '--g-color-text-hint',
|
|
10
|
-
fill: '--g-color-base-generic-ultralight',
|
|
11
|
-
nodeFill: '--g-color-base-float',
|
|
12
|
-
nodeShadow: '--g-color-sfx-shadow',
|
|
13
|
-
titleColor: '--g-color-text-primary',
|
|
14
|
-
textColor: '--g-color-text-complementary',
|
|
15
|
-
buttonBorderColor: '--g-color-line-generic',
|
|
16
|
-
groupBorderColor: '--g-color-base-info-light-hover',
|
|
17
|
-
groupFill: '--g-color-base-info-light',
|
|
18
|
-
titleHoverColor: '--g-color-text-link-hover',
|
|
19
|
-
nodeHover: '--g-color-base-float-hover',
|
|
20
|
-
specialHover: '--g-color-line-brand',
|
|
21
|
-
};
|
|
22
|
-
export function normalizeCssColor(color) {
|
|
23
|
-
const value = color.trim();
|
|
24
|
-
const normalizedColor = colord(value);
|
|
25
|
-
return normalizedColor.isValid() ? normalizedColor.toRgbString() : value;
|
|
26
|
-
}
|
|
27
|
-
function getDefaultCssVariableReader() {
|
|
28
|
-
const styles = getComputedStyle(document.body);
|
|
29
|
-
return (name) => styles.getPropertyValue(name);
|
|
30
|
-
}
|
|
31
|
-
export function getGraphColors(readCssVariable = getDefaultCssVariableReader()) {
|
|
32
|
-
const colors = Object.fromEntries(Object.entries(GRAPH_COLOR_VARIABLES)
|
|
33
|
-
.map(([key, variable]) => [key, normalizeCssColor(readCssVariable(variable))])
|
|
34
|
-
.filter(([, value]) => value));
|
|
35
|
-
return {
|
|
36
|
-
...colors,
|
|
37
|
-
getCommonColor: (name) => normalizeCssColor(readCssVariable(`--g-color-${name}`)),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export function getGraphColorsFromElement(element) {
|
|
41
|
-
const styles = getComputedStyle(element);
|
|
42
|
-
return getGraphColors((name) => styles.getPropertyValue(name));
|
|
43
|
-
}
|
|
44
|
-
export function prepareGraphOptions(options, graphColors = getGraphColors()) {
|
|
45
|
-
return {
|
|
46
|
-
...options,
|
|
47
|
-
colors: {
|
|
48
|
-
...graphColors,
|
|
49
|
-
...options === null || options === void 0 ? void 0 : options.colors,
|
|
50
|
-
},
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=colors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","sourceRoot":"","sources":["../../../src/components/Graph/colors.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,MAAM,EAAC,MAAM,QAAQ,CAAC;AAQ9B,MAAM,qBAAqB,GAAG;IAC1B,OAAO,EAAE,yBAAyB;IAClC,KAAK,EAAE,uBAAuB;IAC9B,OAAO,EAAE,wBAAwB;IACjC,eAAe,EAAE,6BAA6B;IAC9C,iBAAiB,EAAE,8BAA8B;IACjD,IAAI,EAAE,wBAAwB;IAC9B,MA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,EAAE,EAAE,CAAC,iBAAiB,CAAC,eAAe,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;KACpF,CAAC;AACN,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACtD,MAAM,MAAM,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IACzC,OAAO,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAC/B,OAAiB,EACjB,cAA2B,cAAc,EAAE;IAE3C,OAAO;QACH,GAAG,OAAO;QACV,MAAM,EAAE;YACJ,GAAG,WAAW;YACd,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM;SACrB;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {getTopology, getYdbPlanNodeShape} from '@gravity-ui/paranoid';
|
|
4
|
-
import type {Data, GraphNode, Options, Shapes} from '@gravity-ui/paranoid';
|
|
5
|
-
|
|
6
|
-
import {getGraphColorsFromElement, prepareGraphOptions} from './colors';
|
|
7
|
-
|
|
8
|
-
interface GraphProps<T> {
|
|
9
|
-
data: Data<T>;
|
|
10
|
-
opts?: Options;
|
|
11
|
-
shapes?: Shapes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function Graph<T>(props: GraphProps<T>) {
|
|
15
|
-
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
16
|
-
const containerId = React.useId();
|
|
17
|
-
|
|
18
|
-
const {data, opts, shapes} = props;
|
|
19
|
-
|
|
20
|
-
React.useEffect(() => {
|
|
21
|
-
const graphRoot = containerRef.current;
|
|
22
|
-
if (!graphRoot) {
|
|
23
|
-
return undefined;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
graphRoot.innerHTML = '';
|
|
27
|
-
// set width and height to screen size to make a canvas bigger then the container
|
|
28
|
-
graphRoot.style.setProperty('width', '100vw');
|
|
29
|
-
graphRoot.style.setProperty('height', '100vh');
|
|
30
|
-
|
|
31
|
-
const graphColors = getGraphColorsFromElement(graphRoot);
|
|
32
|
-
const topology = getTopology(
|
|
33
|
-
graphRoot.id,
|
|
34
|
-
data,
|
|
35
|
-
prepareGraphOptions(opts, graphColors),
|
|
36
|
-
shapes,
|
|
37
|
-
);
|
|
38
|
-
topology.render();
|
|
39
|
-
graphRoot.style.setProperty('width', '100%');
|
|
40
|
-
graphRoot.style.setProperty('height', '100%');
|
|
41
|
-
return () => {
|
|
42
|
-
topology.destroy();
|
|
43
|
-
};
|
|
44
|
-
}, [data, opts, shapes]);
|
|
45
|
-
|
|
46
|
-
return <div id={containerId} ref={containerRef} style={{overflow: 'auto'}} />;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const renderExplainNode = (node: GraphNode): string => {
|
|
50
|
-
const parts = node.name.split('|');
|
|
51
|
-
return parts.length > 1 ? parts[1] : node.name;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const schemaOptions: Options = {
|
|
55
|
-
renderNodeTitle: renderExplainNode,
|
|
56
|
-
textOverflow: 'normal' as const,
|
|
57
|
-
initialZoomFitsCanvas: true,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const schemaShapes = {
|
|
61
|
-
node: getYdbPlanNodeShape,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
interface YDBGraphProps<T> {
|
|
65
|
-
data: Data<T>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function YDBGraph<T>(props: YDBGraphProps<T>) {
|
|
69
|
-
return <Graph<T> {...props} opts={schemaOptions} shapes={schemaShapes} />;
|
|
70
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type {Colors, Options} from '@gravity-ui/paranoid';
|
|
2
|
-
import {colord} from 'colord';
|
|
3
|
-
|
|
4
|
-
type CssVariableReader = (name: string) => string;
|
|
5
|
-
|
|
6
|
-
export interface GraphColors extends Colors {
|
|
7
|
-
getCommonColor(name: string): string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const GRAPH_COLOR_VARIABLES = {
|
|
11
|
-
success: '--g-color-text-positive',
|
|
12
|
-
error: '--g-color-text-danger',
|
|
13
|
-
warning: '--g-color-text-warning',
|
|
14
|
-
errorBackground: '--g-color-base-danger-light',
|
|
15
|
-
warningBackground: '--g-color-base-warning-light',
|
|
16
|
-
mute: '--g-color-line-generic',
|
|
17
|
-
stroke: '--g-color-text-hint',
|
|
18
|
-
fill: '--g-color-base-generic-ultralight',
|
|
19
|
-
nodeFill: '--g-color-base-float',
|
|
20
|
-
nodeShadow: '--g-color-sfx-shadow',
|
|
21
|
-
titleColor: '--g-color-text-primary',
|
|
22
|
-
textColor: '--g-color-text-complementary',
|
|
23
|
-
buttonBorderColor: '--g-color-line-generic',
|
|
24
|
-
groupBorderColor: '--g-color-base-info-light-hover',
|
|
25
|
-
groupFill: '--g-color-base-info-light',
|
|
26
|
-
titleHoverColor: '--g-color-text-link-hover',
|
|
27
|
-
nodeHover: '--g-color-base-float-hover',
|
|
28
|
-
specialHover: '--g-color-line-brand',
|
|
29
|
-
} satisfies Record<keyof Colors, string>;
|
|
30
|
-
|
|
31
|
-
export function normalizeCssColor(color: string) {
|
|
32
|
-
const value = color.trim();
|
|
33
|
-
const normalizedColor = colord(value);
|
|
34
|
-
|
|
35
|
-
return normalizedColor.isValid() ? normalizedColor.toRgbString() : value;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getDefaultCssVariableReader(): CssVariableReader {
|
|
39
|
-
const styles = getComputedStyle(document.body);
|
|
40
|
-
|
|
41
|
-
return (name) => styles.getPropertyValue(name);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function getGraphColors(
|
|
45
|
-
readCssVariable: CssVariableReader = getDefaultCssVariableReader(),
|
|
46
|
-
): GraphColors {
|
|
47
|
-
const colors = Object.fromEntries(
|
|
48
|
-
Object.entries(GRAPH_COLOR_VARIABLES)
|
|
49
|
-
.map(([key, variable]) => [key, normalizeCssColor(readCssVariable(variable))])
|
|
50
|
-
.filter(([, value]) => value),
|
|
51
|
-
) as Colors;
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
...colors,
|
|
55
|
-
getCommonColor: (name) => normalizeCssColor(readCssVariable(`--g-color-${name}`)),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function getGraphColorsFromElement(element: Element): GraphColors {
|
|
60
|
-
const styles = getComputedStyle(element);
|
|
61
|
-
return getGraphColors((name) => styles.getPropertyValue(name));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function prepareGraphOptions(
|
|
65
|
-
options?: Options,
|
|
66
|
-
graphColors: GraphColors = getGraphColors(),
|
|
67
|
-
): Options {
|
|
68
|
-
return {
|
|
69
|
-
...options,
|
|
70
|
-
colors: {
|
|
71
|
-
...graphColors,
|
|
72
|
-
...options?.colors,
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|