ydb-embedded-ui 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +28 -0
  3. package/dist/HOCS/WithSearch/WithSearch.js +26 -0
  4. package/dist/HOCS/index.js +1 -0
  5. package/dist/assets/icons/bug.svg +1 -0
  6. package/dist/assets/icons/close.svg +1 -0
  7. package/dist/assets/icons/control-menu-button.svg +1 -0
  8. package/dist/assets/icons/databases.svg +3 -0
  9. package/dist/assets/icons/dots.svg +1 -0
  10. package/dist/assets/icons/server.svg +1 -0
  11. package/dist/assets/icons/settings-with-dot.svg +1 -0
  12. package/dist/assets/icons/settings.svg +1 -0
  13. package/dist/assets/icons/signIn.svg +1 -0
  14. package/dist/assets/icons/signOut.svg +1 -0
  15. package/dist/assets/icons/star.svg +1 -0
  16. package/dist/assets/icons/storage.svg +1 -0
  17. package/dist/assets/icons/support.svg +1 -0
  18. package/dist/assets/icons/user-check.svg +1 -0
  19. package/dist/assets/icons/user-secret.svg +1 -0
  20. package/dist/assets/icons/ydb.svg +4 -0
  21. package/dist/components/AsideNavigation/AsideHeader.scss +148 -0
  22. package/dist/components/AsideNavigation/AsideHeader.tsx +388 -0
  23. package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.scss +82 -0
  24. package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.tsx +138 -0
  25. package/dist/components/AsideNavigation/AsideHeaderFooterSlot/AsideHeaderFooterSlot.tsx +33 -0
  26. package/dist/components/AsideNavigation/AsideHeaderFooterSlot/SlotsContext.tsx +49 -0
  27. package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.scss +16 -0
  28. package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.tsx +37 -0
  29. package/dist/components/AsideNavigation/CompositeBar/CompositeBar.scss +108 -0
  30. package/dist/components/AsideNavigation/CompositeBar/CompositeBar.tsx +282 -0
  31. package/dist/components/AsideNavigation/Content/Content.tsx +35 -0
  32. package/dist/components/AsideNavigation/Drawer/Drawer.scss +76 -0
  33. package/dist/components/AsideNavigation/Drawer/Drawer.tsx +134 -0
  34. package/dist/components/AsideNavigation/Drawer/index.ts +1 -0
  35. package/dist/components/AsideNavigation/Logo/Logo.scss +44 -0
  36. package/dist/components/AsideNavigation/Logo/Logo.tsx +82 -0
  37. package/dist/components/AsideNavigation/Settings/README.md +92 -0
  38. package/dist/components/AsideNavigation/Settings/Settings.scss +113 -0
  39. package/dist/components/AsideNavigation/Settings/Settings.tsx +270 -0
  40. package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.scss +70 -0
  41. package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.tsx +141 -0
  42. package/dist/components/AsideNavigation/Settings/SettingsSearch/SettingsSearch.tsx +57 -0
  43. package/dist/components/AsideNavigation/Settings/collect-settings.ts +156 -0
  44. package/dist/components/AsideNavigation/Settings/filter-settings.ts +38 -0
  45. package/dist/components/AsideNavigation/Settings/helpers.ts +39 -0
  46. package/dist/components/AsideNavigation/Settings/i18n/en.json +5 -0
  47. package/dist/components/AsideNavigation/Settings/i18n/index.ts +11 -0
  48. package/dist/components/AsideNavigation/Settings/i18n/ru.json +5 -0
  49. package/dist/components/AsideNavigation/Settings/index.ts +1 -0
  50. package/dist/components/AsideNavigation/constants.ts +28 -0
  51. package/dist/components/AsideNavigation/helpers.ts +34 -0
  52. package/dist/components/AsideNavigation/i18n/en.json +4 -0
  53. package/dist/components/AsideNavigation/i18n/index.ts +11 -0
  54. package/dist/components/AsideNavigation/i18n/ru.json +4 -0
  55. package/dist/components/AsideNavigation/icons.ts +32 -0
  56. package/dist/components/AsideNavigation/types.ts +23 -0
  57. package/dist/components/Breadcrumbs/Breadcrumbs.js +25 -0
  58. package/dist/components/Breadcrumbs/Breadcrumbs.scss +4 -0
  59. package/dist/components/ClusterInfo/ClusterInfo.scss +65 -0
  60. package/dist/components/ClusterInfo/ClusterInfo.tsx +157 -0
  61. package/dist/components/Collapse/Collapse.js +84 -0
  62. package/dist/components/Collapse/Collapse.scss +70 -0
  63. package/dist/components/CriticalActionDialog/CriticalActionDialog.js +53 -0
  64. package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +31 -0
  65. package/dist/components/EmptyState/EmptyState.js +48 -0
  66. package/dist/components/EmptyState/EmptyState.scss +70 -0
  67. package/dist/components/EntityStatus/EntityStatus.js +96 -0
  68. package/dist/components/EntityStatus/EntityStatus.scss +81 -0
  69. package/dist/components/FullGroupViewer/FullGroupViewer.js +149 -0
  70. package/dist/components/FullGroupViewer/FullGroupViewer.scss +32 -0
  71. package/dist/components/FullNodeViewer/FullNodeViewer.js +108 -0
  72. package/dist/components/FullNodeViewer/FullNodeViewer.scss +78 -0
  73. package/dist/components/GroupTreeViewer/GroupTreeViewer.js +86 -0
  74. package/dist/components/GroupTreeViewer/GroupTreeViewer.scss +17 -0
  75. package/dist/components/GroupViewer/GroupViewer.js +100 -0
  76. package/dist/components/GroupViewer/GroupViewer.scss +41 -0
  77. package/dist/components/Hotkey/Hotkey.js +102 -0
  78. package/dist/components/Icon/Icon.js +26 -0
  79. package/dist/components/InfoViewer/InfoViewer.js +47 -0
  80. package/dist/components/InfoViewer/InfoViewer.scss +48 -0
  81. package/dist/components/InternalLink/InternalLink.js +15 -0
  82. package/dist/components/NodesViewer/NodesViewer.js +183 -0
  83. package/dist/components/NodesViewer/NodesViewer.scss +66 -0
  84. package/dist/components/PDiskViewer/PDiskViewer.js +80 -0
  85. package/dist/components/PDiskViewer/PDiskViewer.scss +40 -0
  86. package/dist/components/Pagination/Pagination.js +63 -0
  87. package/dist/components/Pagination/Pagination.scss +25 -0
  88. package/dist/components/PoolBar/PoolBar.js +52 -0
  89. package/dist/components/PoolBar/PoolBar.scss +40 -0
  90. package/dist/components/PoolUsage/PoolUsage.js +54 -0
  91. package/dist/components/PoolUsage/PoolUsage.scss +65 -0
  92. package/dist/components/PoolsGraph/PoolsGraph.js +33 -0
  93. package/dist/components/PoolsGraph/PoolsGraph.scss +3 -0
  94. package/dist/components/ProblemFilter/ProblemFilter.js +24 -0
  95. package/dist/components/ProgressViewer/ProgressViewer.js +92 -0
  96. package/dist/components/ProgressViewer/ProgressViewer.scss +84 -0
  97. package/dist/components/SplitPane/SplitPane.js +368 -0
  98. package/dist/components/SplitPane/SplitPane.scss +107 -0
  99. package/dist/components/SplitPane/index.js +3 -0
  100. package/dist/components/Tablet/Tablet.js +61 -0
  101. package/dist/components/Tablet/Tablet.scss +49 -0
  102. package/dist/components/TabletsStatistic/TabletsStatistic.js +58 -0
  103. package/dist/components/TabletsStatistic/TabletsStatistic.scss +41 -0
  104. package/dist/components/TabletsViewer/TabletsViewer.js +44 -0
  105. package/dist/components/TabletsViewer/TabletsViewer.scss +37 -0
  106. package/dist/components/Tag/Tag.js +14 -0
  107. package/dist/components/Tag/Tag.scss +17 -0
  108. package/dist/components/Tags/Tags.js +36 -0
  109. package/dist/components/Tags/Tags.scss +5 -0
  110. package/dist/components/TenantOverview/TenantOverview.js +148 -0
  111. package/dist/components/TenantOverview/TenantOverview.scss +75 -0
  112. package/dist/components/TreeView/TreeView.js +60 -0
  113. package/dist/components/TreeView/TreeView.scss +30 -0
  114. package/dist/components/TruncatedQuery/TruncatedQuery.js +26 -0
  115. package/dist/components/TruncatedQuery/TruncatedQuery.scss +12 -0
  116. package/dist/containers/App/App.js +67 -0
  117. package/dist/containers/App/App.scss +154 -0
  118. package/dist/containers/App/Content.js +109 -0
  119. package/dist/containers/App/TipPopup/TipPopup.js +66 -0
  120. package/dist/containers/App/TipPopup/TipPopup.scss +42 -0
  121. package/dist/containers/AppIcons/AppIcons.js +477 -0
  122. package/dist/containers/AsideNavigation/AsideNavigation.scss +43 -0
  123. package/dist/containers/AsideNavigation/AsideNavigation.tsx +228 -0
  124. package/dist/containers/Authentication/Authentication.scss +37 -0
  125. package/dist/containers/Authentication/Authentication.tsx +89 -0
  126. package/dist/containers/Cluster/Cluster.js +168 -0
  127. package/dist/containers/Cluster/Cluster.scss +52 -0
  128. package/dist/containers/Group/Group.js +97 -0
  129. package/dist/containers/Group/Group.scss +6 -0
  130. package/dist/containers/Header/Header.js +88 -0
  131. package/dist/containers/Header/Header.scss +72 -0
  132. package/dist/containers/Header/Host/Host.js +66 -0
  133. package/dist/containers/Header/Host/Host.scss +43 -0
  134. package/dist/containers/Heatmap/Heatmap.js +246 -0
  135. package/dist/containers/Heatmap/Heatmap.scss +94 -0
  136. package/dist/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js +167 -0
  137. package/dist/containers/Heatmap/Histogram/Histogram.js +108 -0
  138. package/dist/containers/Heatmap/Histogram/Histogram.scss +49 -0
  139. package/dist/containers/Heatmap/util.js +110 -0
  140. package/dist/containers/Node/Node.js +184 -0
  141. package/dist/containers/Node/Node.scss +34 -0
  142. package/dist/containers/Node/NodePages.js +13 -0
  143. package/dist/containers/Nodes/Nodes.js +193 -0
  144. package/dist/containers/Nodes/Nodes.scss +50 -0
  145. package/dist/containers/Pdisk/Pdisk.js +159 -0
  146. package/dist/containers/Pdisk/Pdisk.scss +40 -0
  147. package/dist/containers/Pool/Pool.js +169 -0
  148. package/dist/containers/Pool/Pool.scss +32 -0
  149. package/dist/containers/ReduxTooltip/ReduxTooltip.js +108 -0
  150. package/dist/containers/ReduxTooltip/ReduxTooltip.scss +67 -0
  151. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +81 -0
  152. package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.tsx +56 -0
  153. package/dist/containers/StorageV2/Pdisk/Pdisk.scss +32 -0
  154. package/dist/containers/StorageV2/Pdisk/Pdisk.tsx +167 -0
  155. package/dist/containers/StorageV2/Storage.js +249 -0
  156. package/dist/containers/StorageV2/Storage.scss +57 -0
  157. package/dist/containers/StorageV2/StorageFilter/StorageFilter.js +39 -0
  158. package/dist/containers/StorageV2/StorageGroups/StorageGroups.scss +26 -0
  159. package/dist/containers/StorageV2/StorageGroups/StorageGroups.tsx +234 -0
  160. package/dist/containers/StorageV2/StorageNodes/StorageNodes.scss +30 -0
  161. package/dist/containers/StorageV2/StorageNodes/StorageNodes.tsx +135 -0
  162. package/dist/containers/StorageV2/Vdisk/Vdisk.js +250 -0
  163. package/dist/containers/StorageV2/Vdisk/Vdisk.scss +32 -0
  164. package/dist/containers/Tablet/Tablet.js +453 -0
  165. package/dist/containers/Tablet/Tablet.scss +88 -0
  166. package/dist/containers/Tablets/Tablets.js +306 -0
  167. package/dist/containers/Tablets/Tablets.scss +77 -0
  168. package/dist/containers/TabletsFilters/TabletsFilters.js +412 -0
  169. package/dist/containers/TabletsFilters/TabletsFilters.scss +104 -0
  170. package/dist/containers/Tenant/Acl/Acl.js +149 -0
  171. package/dist/containers/Tenant/Acl/Acl.scss +34 -0
  172. package/dist/containers/Tenant/Compute/Compute.js +110 -0
  173. package/dist/containers/Tenant/Compute/Compute.scss +6 -0
  174. package/dist/containers/Tenant/Describe/Describe.js +81 -0
  175. package/dist/containers/Tenant/Describe/Describe.scss +25 -0
  176. package/dist/containers/Tenant/Healthcheck/Healthcheck.js +116 -0
  177. package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +64 -0
  178. package/dist/containers/Tenant/Healthcheck/IssuesViewer/IssueViewer.scss +164 -0
  179. package/dist/containers/Tenant/Healthcheck/IssuesViewer/IssuesViewer.js +185 -0
  180. package/dist/containers/Tenant/Network/Network.js +341 -0
  181. package/dist/containers/Tenant/Network/Network.scss +145 -0
  182. package/dist/containers/Tenant/Network/NodeNetwork/NodeNetwork.js +71 -0
  183. package/dist/containers/Tenant/Network/NodeNetwork/NodeNetwork.scss +52 -0
  184. package/dist/containers/Tenant/Preview/Preview.js +169 -0
  185. package/dist/containers/Tenant/Preview/Preview.scss +20 -0
  186. package/dist/containers/Tenant/QueryEditor/QueryEditor.js +649 -0
  187. package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +71 -0
  188. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +168 -0
  189. package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.scss +42 -0
  190. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +58 -0
  191. package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.scss +24 -0
  192. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +171 -0
  193. package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss +51 -0
  194. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.js +156 -0
  195. package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.scss +82 -0
  196. package/dist/containers/Tenant/Schema/HotKeys/HotKeys.js +149 -0
  197. package/dist/containers/Tenant/Schema/HotKeys/HotKeys.scss +48 -0
  198. package/dist/containers/Tenant/Schema/Info/Info.js +84 -0
  199. package/dist/containers/Tenant/Schema/Info/Info.scss +3 -0
  200. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +67 -0
  201. package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss +21 -0
  202. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +439 -0
  203. package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +90 -0
  204. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.js +150 -0
  205. package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.scss +41 -0
  206. package/dist/containers/Tenant/Schema/SchemaPages.js +56 -0
  207. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.js +115 -0
  208. package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.scss +13 -0
  209. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +63 -0
  210. package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.scss +28 -0
  211. package/dist/containers/Tenant/Tenant.js +199 -0
  212. package/dist/containers/Tenant/Tenant.scss +94 -0
  213. package/dist/containers/Tenant/TenantPages.js +35 -0
  214. package/dist/containers/Tenant/TopQueries/TopQueries.js +184 -0
  215. package/dist/containers/Tenant/TopQueries/TopQueries.scss +53 -0
  216. package/dist/containers/Tenant/TopShards/TopShards.js +171 -0
  217. package/dist/containers/Tenant/TopShards/TopShards.scss +23 -0
  218. package/dist/containers/Tenants/Tenants.js +375 -0
  219. package/dist/containers/Tenants/Tenants.scss +73 -0
  220. package/dist/containers/UserSettings/UserSettings.tsx +57 -0
  221. package/dist/containers/Vdisk/Vdisk.js +160 -0
  222. package/dist/containers/Vdisk/Vdisk.scss +40 -0
  223. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.js +528 -0
  224. package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.scss +60 -0
  225. package/dist/contexts/HistoryContext.ts +6 -0
  226. package/dist/index.css +11 -0
  227. package/dist/index.js +28 -0
  228. package/dist/index.test.js +5 -0
  229. package/dist/react-app-env.d.ts +1 -0
  230. package/dist/reportWebVitals.js +13 -0
  231. package/dist/routes.js +40 -0
  232. package/dist/services/api.js +224 -0
  233. package/dist/setupTests.js +5 -0
  234. package/dist/store/index.js +61 -0
  235. package/dist/store/reducers/authentication.js +77 -0
  236. package/dist/store/reducers/cluster.js +52 -0
  237. package/dist/store/reducers/clusterInfo.js +48 -0
  238. package/dist/store/reducers/clusterNodes.js +70 -0
  239. package/dist/store/reducers/describe.js +45 -0
  240. package/dist/store/reducers/executeQuery.js +158 -0
  241. package/dist/store/reducers/executeTopQueries.js +69 -0
  242. package/dist/store/reducers/explainQuery.js +174 -0
  243. package/dist/store/reducers/group.js +49 -0
  244. package/dist/store/reducers/healthcheckInfo.js +45 -0
  245. package/dist/store/reducers/heatmap.js +105 -0
  246. package/dist/store/reducers/host.js +44 -0
  247. package/dist/store/reducers/hotKeys.js +57 -0
  248. package/dist/store/reducers/index.js +78 -0
  249. package/dist/store/reducers/network.js +45 -0
  250. package/dist/store/reducers/node.js +42 -0
  251. package/dist/store/reducers/nodes.js +58 -0
  252. package/dist/store/reducers/olapStats.js +74 -0
  253. package/dist/store/reducers/pdisk.js +51 -0
  254. package/dist/store/reducers/pool.js +42 -0
  255. package/dist/store/reducers/preview.js +73 -0
  256. package/dist/store/reducers/schema.js +95 -0
  257. package/dist/store/reducers/schemaAcl.js +44 -0
  258. package/dist/store/reducers/settings.js +76 -0
  259. package/dist/store/reducers/shardsWorkload.js +75 -0
  260. package/dist/store/reducers/storage.js +280 -0
  261. package/dist/store/reducers/tablet.js +94 -0
  262. package/dist/store/reducers/tablets.js +90 -0
  263. package/dist/store/reducers/tabletsFilters.js +126 -0
  264. package/dist/store/reducers/tenant.js +76 -0
  265. package/dist/store/reducers/tenants.js +61 -0
  266. package/dist/store/reducers/tooltip.js +64 -0
  267. package/dist/store/reducers/vdisk.js +49 -0
  268. package/dist/store/state-url-mapping.js +133 -0
  269. package/dist/store/utils.js +55 -0
  270. package/dist/styles/mixins.scss +254 -0
  271. package/dist/styles/react-treeview.scss +45 -0
  272. package/dist/types/assets.d.ts +12 -0
  273. package/dist/types/react-list.d.ts +4 -0
  274. package/dist/types/window.d.ts +33 -0
  275. package/dist/utils/actionsConstants.js +4 -0
  276. package/dist/utils/constants.js +126 -0
  277. package/dist/utils/getNodesColumns.js +156 -0
  278. package/dist/utils/i18n/i18n.ts +7 -0
  279. package/dist/utils/i18n/index.ts +1 -0
  280. package/dist/utils/index.js +136 -0
  281. package/dist/utils/monaco.js +69 -0
  282. package/dist/utils/prepareQueryExplain.ts +101 -0
  283. package/dist/utils/tooltip.js +197 -0
  284. package/dist/utils/utils.js +75 -0
  285. package/package.json +89 -0
@@ -0,0 +1,167 @@
1
+ import {useEffect, useLayoutEffect, useRef, useState} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cn from 'bem-cn-lite';
4
+ import _ from 'lodash';
5
+
6
+ import {basename as appBasename} from '../../../store/index';
7
+ import routes, {createHref} from '../../../routes';
8
+
9
+ const b = cn('heatmap');
10
+ const defaultDimensions = {width: 0, height: 0};
11
+
12
+ const TABLET_SIZE = 10;
13
+ const TABLET_PADDING = 2;
14
+
15
+ export const HeatmapCanvas = (props) => {
16
+ const [dimensions, setDimensions] = useState(defaultDimensions);
17
+ const {tablets} = props;
18
+ const canvasRef = useRef(null);
19
+ const containerRef = useRef(null);
20
+
21
+ function drawTablet(ctx) {
22
+ return (tablet, index) => {
23
+ const {columnsCount} = dimensions;
24
+ const rectX = (index % columnsCount) * (TABLET_SIZE + TABLET_PADDING);
25
+ const rectY = Math.floor(index / columnsCount) * (TABLET_SIZE + TABLET_PADDING);
26
+
27
+ ctx.fillStyle = tablet.color || 'gray';
28
+ ctx.fillRect(rectX, rectY, TABLET_SIZE, TABLET_SIZE);
29
+ };
30
+ }
31
+
32
+ useEffect(() => {
33
+ const canvas = canvasRef.current;
34
+ const ctx = canvas.getContext('2d');
35
+
36
+ ctx.clearRect(0, 0, canvas.offsetWidth, canvas.offsetHeight);
37
+ tablets.map(drawTablet(ctx));
38
+ });
39
+
40
+ useLayoutEffect(() => {
41
+ const container = containerRef.current;
42
+
43
+ if (container) {
44
+ const width = container.offsetWidth - 15;
45
+ const columnsCount = Math.floor(width / (TABLET_SIZE + TABLET_PADDING));
46
+ const rowsCount = Math.ceil(tablets.length / columnsCount);
47
+ const height = rowsCount * (TABLET_SIZE + TABLET_PADDING);
48
+
49
+ setDimensions({
50
+ width,
51
+ height,
52
+ columnsCount,
53
+ rowsCount,
54
+ });
55
+ }
56
+ }, []);
57
+
58
+ const getOffsetTop = () => {
59
+ let element = canvasRef.current;
60
+ let offsetTop = 0;
61
+ while (element) {
62
+ offsetTop += element.offsetTop;
63
+ element = element.offsetParent;
64
+ }
65
+ return offsetTop;
66
+ };
67
+
68
+ const getOffsetLeft = () => {
69
+ let element = canvasRef.current;
70
+ let offsetLeft = 0;
71
+ while (element) {
72
+ offsetLeft += element.offsetLeft;
73
+ element = element.offsetParent;
74
+ }
75
+ return offsetLeft;
76
+ };
77
+
78
+ const getTabletIndex = (x, y) => {
79
+ const {columnsCount} = dimensions;
80
+ const colStep = TABLET_SIZE + TABLET_PADDING;
81
+ const rowStep = TABLET_SIZE + TABLET_PADDING;
82
+
83
+ const xCol = Math.floor(x / colStep);
84
+ const yRow = Math.floor(y / rowStep);
85
+ const index = columnsCount * yRow + xCol;
86
+
87
+ return index;
88
+ };
89
+ const generateTabletExternalLink = (tablet) => {
90
+ const {TabletId: id} = tablet;
91
+ const hostname = window.location.hostname;
92
+ const path = createHref(routes.tablet, {id});
93
+ const protocol = 'https://';
94
+ const href = [hostname, appBasename, path]
95
+ .map((item) => (item.startsWith('/') ? item.slice(1) : item))
96
+ .filter(Boolean)
97
+ .join('/');
98
+
99
+ return `${protocol}${href}`;
100
+ };
101
+ const _onCanvasClick = (e) => {
102
+ const parent = props.parentRef.current;
103
+ const x = e.clientX - getOffsetLeft() + parent.scrollLeft;
104
+ const y = e.clientY - getOffsetTop() + parent.scrollTop;
105
+
106
+ const tabletIndex = getTabletIndex(x, y);
107
+ const tablet = tablets[tabletIndex];
108
+
109
+ if (tablet) {
110
+ window.open(generateTabletExternalLink(tablet), '_blank');
111
+ }
112
+ };
113
+ const _onCanvasMouseLeave = () => {
114
+ // Таймаут нужен для того, чтобы точно скрыть тултип. В методе _onCanvasMouseMove используется throttle.
115
+ // И это может вызвать функцию отрисовки тултипа уже после фактического покидания области канваса. Для этого
116
+ // в таймауте используем задержку больше, чем время задержки в throttle.
117
+ setTimeout(() => {
118
+ props.hideTooltip();
119
+ }, 40);
120
+ };
121
+ const _onCanvasMouseMove = _.throttle((x, y) => {
122
+ //this is needed to force ReduxPopup rerender
123
+ const event = new CustomEvent('scroll');
124
+ window.dispatchEvent(event);
125
+ const parent = props.parentRef.current;
126
+ const xPos = x - getOffsetLeft() + parent.scrollLeft;
127
+ const yPos = y - getOffsetTop() + parent.scrollTop;
128
+
129
+ const tabletIndex = getTabletIndex(xPos, yPos);
130
+ const tablet = tablets[tabletIndex];
131
+ if (tablet) {
132
+ const additionalData = {
133
+ name: tablet.currentMetric,
134
+ value: tablet.formattedValue,
135
+ };
136
+ props.showTooltip(undefined, tablet, 'tablet', additionalData, {
137
+ left: x - 20,
138
+ top: y - 20,
139
+ });
140
+ } else {
141
+ props.hideTooltip();
142
+ }
143
+ }, 20);
144
+
145
+ return (
146
+ <div
147
+ ref={containerRef}
148
+ className={b('canvas-container')}
149
+ onMouseLeave={_onCanvasMouseLeave}
150
+ >
151
+ <canvas
152
+ ref={canvasRef}
153
+ width={dimensions.width}
154
+ height={dimensions.height}
155
+ onClick={_onCanvasClick}
156
+ onMouseMove={(e) => _onCanvasMouseMove(e.clientX, e.clientY)}
157
+ />
158
+ </div>
159
+ );
160
+ };
161
+
162
+ HeatmapCanvas.propTypes = {
163
+ tablets: PropTypes.array,
164
+ parentRef: PropTypes.node,
165
+ showTooltip: PropTypes.func,
166
+ hideTooltip: PropTypes.func,
167
+ };
@@ -0,0 +1,108 @@
1
+ import {useRef} from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cn from 'bem-cn-lite';
4
+
5
+ import {getColorRange, getCurrentMetricLimits} from '../util';
6
+ import {formatNumber} from '../../../utils';
7
+
8
+ import './Histogram.scss';
9
+
10
+ const b = cn('histogram');
11
+
12
+ const HistogramBar = (props) => {
13
+ const barRef = useRef();
14
+ const {data = {}, maxCount} = props;
15
+ const {count, leftBound, rightBound, color} = data;
16
+ const height = (count / maxCount) * 100;
17
+
18
+ const _onHistogramItemEnter = () => {
19
+ const ref = barRef.current;
20
+
21
+ props.showTooltip(
22
+ ref,
23
+ {
24
+ count,
25
+ leftBound,
26
+ rightBound,
27
+ },
28
+ 'histogram',
29
+ );
30
+ };
31
+
32
+ return (
33
+ <div
34
+ ref={barRef}
35
+ className={b('item')}
36
+ style={{backgroundColor: color, height: `${height}%`}}
37
+ onMouseEnter={_onHistogramItemEnter}
38
+ onMouseLeave={props.hideTooltip}
39
+ />
40
+ );
41
+ };
42
+ HistogramBar.propTypes = {
43
+ data: PropTypes.object,
44
+ maxCount: PropTypes.number,
45
+ showTooltip: PropTypes.func,
46
+ hideTooltip: PropTypes.func,
47
+ };
48
+
49
+ export const Histogram = (props) => {
50
+ const {tablets, currentMetric} = props;
51
+ const {min, max} = getCurrentMetricLimits(currentMetric, tablets);
52
+
53
+ const histogramColorRange = getColorRange(50);
54
+ const step = (max - min) / 50;
55
+ const histogramRange = histogramColorRange.map((item, index) => {
56
+ return {
57
+ color: item,
58
+ count: 0,
59
+ leftBound: formatNumber(min + index * step),
60
+ rightBound: formatNumber(min + (index + 1) * step),
61
+ };
62
+ });
63
+ let maxCount = 0;
64
+ tablets.forEach((tablet) => {
65
+ const value = currentMetric && Number(tablet.metrics[currentMetric]);
66
+ const bucketIndex = Math.floor(value / step);
67
+ const nextCountValue = histogramRange[bucketIndex]?.count + 1;
68
+
69
+ if (nextCountValue > maxCount) {
70
+ maxCount = nextCountValue;
71
+ }
72
+
73
+ histogramRange[bucketIndex] = {
74
+ ...histogramRange[bucketIndex],
75
+ count: nextCountValue,
76
+ };
77
+ });
78
+
79
+ const renderHistogramItem = (item, index) => {
80
+ return (
81
+ <HistogramBar
82
+ key={index}
83
+ data={item}
84
+ maxCount={maxCount}
85
+ showTooltip={props.showTooltip}
86
+ hideTooltip={props.hideTooltip}
87
+ />
88
+ );
89
+ };
90
+
91
+ return (
92
+ <div className={b()}>
93
+ <div className={b('chart')}>
94
+ {Boolean(max) && histogramRange.map(renderHistogramItem)}
95
+ <div className={b('x-min')}>{formatNumber(min)}</div>
96
+ <div className={b('x-max')}>{formatNumber(max)}</div>
97
+ <div className={b('y-min')}>0</div>
98
+ <div className={b('y-max')}>{formatNumber(maxCount)}</div>
99
+ </div>
100
+ </div>
101
+ );
102
+ };
103
+ Histogram.propTypes = {
104
+ tablets: PropTypes.array,
105
+ currentMetric: PropTypes.string,
106
+ showTooltip: PropTypes.func,
107
+ hideTooltip: PropTypes.func,
108
+ };
@@ -0,0 +1,49 @@
1
+ .histogram {
2
+ display: flex;
3
+ flex: 1 1 auto;
4
+
5
+ &__chart {
6
+ position: relative;
7
+ display: flex;
8
+ align-items: baseline;
9
+ width: 800px;
10
+ height: 300px;
11
+ border-bottom: 1px solid var(--yc-color-base-generic);
12
+ border-left: 1px solid var(--yc-color-base-generic);
13
+ margin-left: 50px;
14
+ margin-top: 30px;
15
+ }
16
+ &__x-min {
17
+ color: var(--yc-color-text-secondary);
18
+ position: absolute;
19
+ bottom: -25px;
20
+ left: -3px;
21
+ }
22
+ &__x-max {
23
+ color: var(--yc-color-text-secondary);
24
+ position: absolute;
25
+ bottom: -25px;
26
+ right: 0;
27
+ }
28
+ &__y-min {
29
+ color: var(--yc-color-text-secondary);
30
+ position: absolute;
31
+ width: 20px;
32
+ bottom: -7px;
33
+ left: -30px;
34
+ text-align: right;
35
+ }
36
+ &__y-max {
37
+ color: var(--yc-color-text-secondary);
38
+ position: absolute;
39
+ width: 50px;
40
+ top: -5px;
41
+ left: -60px;
42
+ text-align: right;
43
+ }
44
+ &__item {
45
+ width: 1.5%;
46
+ margin-right: 0.5%;
47
+ cursor: pointer;
48
+ }
49
+ }
@@ -0,0 +1,110 @@
1
+ const CRIT = {r: 255, g: 4, b: 0};
2
+ const WARN = {r: 255, g: 219, b: 77};
3
+ const OK = {r: 59, g: 201, b: 53};
4
+
5
+ export const COLORS_RANGE_SIZE = 500;
6
+ export const LIMITED_METRICS = {
7
+ CPU: {
8
+ min: 0,
9
+ max: 1000000,
10
+ },
11
+ Network: {
12
+ min: 0,
13
+ max: 1000000000,
14
+ },
15
+ Storage: {
16
+ min: 0,
17
+ max: 2000000000,
18
+ },
19
+ DataSize: {
20
+ min: 0,
21
+ max: 2000000000,
22
+ },
23
+ RowCount: {
24
+ min: 0,
25
+ },
26
+ IndexSize: {
27
+ min: 0,
28
+ },
29
+ };
30
+
31
+ const cToHex = (c) => {
32
+ const hex = c.toString(16);
33
+ return hex.length === 1 ? `0${hex}` : hex;
34
+ };
35
+ const rgbToHex = ({r, g, b}) => {
36
+ return `#${cToHex(r)}${cToHex(g)}${cToHex(b)}`;
37
+ };
38
+
39
+ export const getRangeBetweenColors = (range, color1, color2) => {
40
+ if (range === 1) {
41
+ return [color1];
42
+ }
43
+
44
+ if (range === 2) {
45
+ return [color1, color2];
46
+ }
47
+
48
+ const redDiff = color1.r - color2.r;
49
+ const redStep = redDiff / (range - 1);
50
+
51
+ const greenDiff = color1.g - color2.g;
52
+ const greenStep = greenDiff / (range - 1);
53
+
54
+ const blueDiff = color1.b - color2.b;
55
+ const blueStep = blueDiff / (range - 1);
56
+
57
+ const colors = [];
58
+
59
+ for (let i = 0; i < range; i++) {
60
+ colors.push({
61
+ r: Math.round(color1.r - redStep * i),
62
+ g: Math.round(color1.g - greenStep * i),
63
+ b: Math.round(color1.b - blueStep * i),
64
+ });
65
+ }
66
+
67
+ return colors.map((color) => rgbToHex(color));
68
+ };
69
+ export const getColorRange = (range) => {
70
+ const halfRange = Math.floor(range / 2);
71
+ const range1 = range % 2 === 0 ? halfRange : halfRange + 1;
72
+ const range2 = halfRange + 1;
73
+
74
+ const firstInterval = getRangeBetweenColors(range1, OK, WARN);
75
+ const secondInterval = getRangeBetweenColors(range2, WARN, CRIT);
76
+
77
+ const colorsRange = [...firstInterval, ...secondInterval.slice(1)];
78
+
79
+ return colorsRange;
80
+ };
81
+ export const getColorIndex = (value, min, max) => {
82
+ if (max === 0) {
83
+ return 0;
84
+ } else {
85
+ return Math.round(((value - min) / (max - min)) * (COLORS_RANGE_SIZE - 1));
86
+ }
87
+ };
88
+
89
+ export const getCurrentMetricLimits = (metric, tablets) => {
90
+ const limits = new Set();
91
+ const limitedMetric = LIMITED_METRICS[metric] || {};
92
+
93
+ tablets.forEach((tablet) => {
94
+ limits.add(Number(tablet.metrics[metric]));
95
+ });
96
+
97
+ if (Number.isInteger(limitedMetric.min)) {
98
+ limits.add(limitedMetric.min);
99
+ }
100
+ if (Number.isInteger(limitedMetric.max)) {
101
+ limits.add(limitedMetric.max);
102
+ }
103
+
104
+ const sortedLimits = Array.from(limits.values()).sort((a, b) => a - b);
105
+
106
+ return {
107
+ min: sortedLimits[0],
108
+ max: sortedLimits[sortedLimits.length - 1],
109
+ };
110
+ };
@@ -0,0 +1,184 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import cn from 'bem-cn-lite';
4
+ import {connect} from 'react-redux';
5
+ import _ from 'lodash';
6
+
7
+ import {Loader, Tabs} from '@yandex-cloud/uikit';
8
+ import {withRouter, Link} from 'react-router-dom';
9
+
10
+ import FullNodeViewer from '../../components/FullNodeViewer/FullNodeViewer';
11
+ import {TABLETS, STORAGE, NODE_PAGES} from './NodePages';
12
+ import Tablets from '../Tablets/Tablets';
13
+ import Storage from '../StorageV2/Storage';
14
+
15
+ import {getNodeInfo} from '../../store/reducers/node';
16
+ import {NODE_AUTO_RELOAD_INTERVAL} from '../../utils/constants';
17
+ import routes, {createHref} from '../../routes';
18
+ import {backend} from '../../store';
19
+
20
+ import './Node.scss';
21
+
22
+ const b = cn('node');
23
+
24
+ export const STORAGE_ROLE = 'Storage';
25
+
26
+ class Node extends React.Component {
27
+ static renderLoader() {
28
+ return (
29
+ <div className={'loader'}>
30
+ <Loader size="l" />
31
+ </div>
32
+ );
33
+ }
34
+
35
+ static propTypes = {
36
+ className: PropTypes.string,
37
+ getNodeInfo: PropTypes.func,
38
+ match: PropTypes.object,
39
+ loading: PropTypes.bool,
40
+ wasLoaded: PropTypes.bool,
41
+ error: PropTypes.bool,
42
+ node: PropTypes.object,
43
+ activeTab: PropTypes.string,
44
+ id: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
45
+ additionalNodesInfo: PropTypes.object,
46
+ };
47
+
48
+ static defaultProps = {
49
+ className: '',
50
+ };
51
+
52
+ state = {
53
+ activeTab: '',
54
+ };
55
+
56
+ componentDidMount() {
57
+ const {id} = this.props.match.params;
58
+ this.setState({activeTab: this.props.activeTab});
59
+ this.props.getNodeInfo(id);
60
+ this.reloadDescriptor = setInterval(
61
+ () => this.props.getNodeInfo(id),
62
+ NODE_AUTO_RELOAD_INTERVAL,
63
+ );
64
+ }
65
+
66
+ componentDidUpdate() {
67
+ const {node} = this.props;
68
+ let {activeTab} = this.props;
69
+ if (node) {
70
+ const hasStorage = _.find(node.Roles, (el) => el === STORAGE_ROLE);
71
+ if (!hasStorage) {
72
+ activeTab = TABLETS;
73
+ }
74
+ this.setState((prev) => {
75
+ if (prev.activeTab !== activeTab) {
76
+ return {activeTab};
77
+ }
78
+ });
79
+ }
80
+ }
81
+
82
+ componentWillUnmount() {
83
+ clearInterval(this.reloadDescriptor);
84
+ }
85
+
86
+ renderTabs() {
87
+ const {node} = this.props;
88
+ const {id} = this.props.match.params;
89
+ const hasStorage = _.find(node?.Roles, (el) => el === STORAGE_ROLE);
90
+
91
+ const filteredNodesPages = hasStorage
92
+ ? NODE_PAGES
93
+ : NODE_PAGES.filter((el) => el.id !== STORAGE);
94
+ const pages = filteredNodesPages.map((page) => {
95
+ return {
96
+ ...page,
97
+ path: createHref(routes.node, {id, activeTab: page.id}),
98
+ };
99
+ });
100
+
101
+ return (
102
+ <div className={b('tabs')}>
103
+ <Tabs
104
+ items={pages}
105
+ activeTab={this.state.activeTab}
106
+ wrapTo={({path, id}, node) => (
107
+ <Link to={path} key={id} className={b('tab')}>
108
+ {node}
109
+ </Link>
110
+ )}
111
+ allowNotSelected={true}
112
+ />
113
+ </div>
114
+ );
115
+ }
116
+ renderTabContent() {
117
+ const {activeTab} = this.state;
118
+ const {id} = this.props.match.params;
119
+
120
+ switch (activeTab) {
121
+ case STORAGE: {
122
+ return (
123
+ <div className={b('storage')}>
124
+ <Storage nodeId={id} />
125
+ </div>
126
+ );
127
+ }
128
+ case TABLETS: {
129
+ return <Tablets nodeId={id} />;
130
+ }
131
+ default:
132
+ return false;
133
+ }
134
+ }
135
+
136
+ render() {
137
+ const {className, loading, wasLoaded, error, node, additionalNodesInfo} = this.props;
138
+
139
+ if (loading && !wasLoaded) {
140
+ return Node.renderLoader();
141
+ } else if (error) {
142
+ return <div>{error.statusText}</div>;
143
+ } else {
144
+ if (node) {
145
+ return (
146
+ <div className={`${b()} ${className}`}>
147
+ <FullNodeViewer
148
+ node={node}
149
+ backend={backend}
150
+ additionalNodesInfo={additionalNodesInfo}
151
+ />
152
+ {this.renderTabs()}
153
+
154
+ <div className={b('content')}>{this.renderTabContent()}</div>
155
+ </div>
156
+ );
157
+ }
158
+ return <div className="error">no node data</div>;
159
+ }
160
+ }
161
+ }
162
+
163
+ const mapStateToProps = (state, ownProps) => {
164
+ const {wasLoaded, loading} = state.node;
165
+ const {activeTab} = ownProps.match.params;
166
+ let {data: node} = state.node;
167
+
168
+ if (node) {
169
+ node = node.SystemStateInfo ? node.SystemStateInfo[0] : undefined;
170
+ }
171
+
172
+ return {
173
+ node,
174
+ activeTab,
175
+ wasLoaded,
176
+ loading,
177
+ };
178
+ };
179
+
180
+ const mapDispatchToProps = {
181
+ getNodeInfo,
182
+ };
183
+
184
+ export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Node));
@@ -0,0 +1,34 @@
1
+ @import '../../styles/mixins';
2
+
3
+ .node {
4
+ @include flex-container();
5
+ overflow: auto;
6
+
7
+ &__content {
8
+ @include flex-container();
9
+ overflow: auto;
10
+ }
11
+
12
+ &__storage {
13
+ padding-left: 20px;
14
+ overflow: auto;
15
+ height: 100%;
16
+ }
17
+
18
+ &__tabs {
19
+ padding: 0 15px;
20
+ }
21
+
22
+ &__tab {
23
+ text-decoration: none;
24
+ margin-right: 40px;
25
+
26
+ &:last-child {
27
+ margin-right: 0;
28
+ }
29
+
30
+ &:first-letter {
31
+ text-transform: uppercase;
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,13 @@
1
+ export const STORAGE = 'storage';
2
+ export const TABLETS = 'tablets';
3
+
4
+ export const NODE_PAGES = [
5
+ {
6
+ id: STORAGE,
7
+ name: 'Storage',
8
+ },
9
+ {
10
+ id: TABLETS,
11
+ name: 'Tablets',
12
+ },
13
+ ];