ydb-embedded-ui 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +8 -0
- package/README.md +28 -0
- package/dist/HOCS/WithSearch/WithSearch.js +26 -0
- package/dist/HOCS/index.js +1 -0
- package/dist/assets/icons/bug.svg +1 -0
- package/dist/assets/icons/close.svg +1 -0
- package/dist/assets/icons/control-menu-button.svg +1 -0
- package/dist/assets/icons/databases.svg +3 -0
- package/dist/assets/icons/dots.svg +1 -0
- package/dist/assets/icons/server.svg +1 -0
- package/dist/assets/icons/settings-with-dot.svg +1 -0
- package/dist/assets/icons/settings.svg +1 -0
- package/dist/assets/icons/signIn.svg +1 -0
- package/dist/assets/icons/signOut.svg +1 -0
- package/dist/assets/icons/star.svg +1 -0
- package/dist/assets/icons/storage.svg +1 -0
- package/dist/assets/icons/support.svg +1 -0
- package/dist/assets/icons/user-check.svg +1 -0
- package/dist/assets/icons/user-secret.svg +1 -0
- package/dist/assets/icons/ydb.svg +4 -0
- package/dist/components/AsideNavigation/AsideHeader.scss +148 -0
- package/dist/components/AsideNavigation/AsideHeader.tsx +388 -0
- package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.scss +82 -0
- package/dist/components/AsideNavigation/AsideHeaderFooterItem/AsideHeaderFooterItem.tsx +138 -0
- package/dist/components/AsideNavigation/AsideHeaderFooterSlot/AsideHeaderFooterSlot.tsx +33 -0
- package/dist/components/AsideNavigation/AsideHeaderFooterSlot/SlotsContext.tsx +49 -0
- package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.scss +16 -0
- package/dist/components/AsideNavigation/AsideHeaderTooltip/AsideHeaderTooltip.tsx +37 -0
- package/dist/components/AsideNavigation/CompositeBar/CompositeBar.scss +108 -0
- package/dist/components/AsideNavigation/CompositeBar/CompositeBar.tsx +282 -0
- package/dist/components/AsideNavigation/Content/Content.tsx +35 -0
- package/dist/components/AsideNavigation/Drawer/Drawer.scss +76 -0
- package/dist/components/AsideNavigation/Drawer/Drawer.tsx +134 -0
- package/dist/components/AsideNavigation/Drawer/index.ts +1 -0
- package/dist/components/AsideNavigation/Logo/Logo.scss +44 -0
- package/dist/components/AsideNavigation/Logo/Logo.tsx +82 -0
- package/dist/components/AsideNavigation/Settings/README.md +92 -0
- package/dist/components/AsideNavigation/Settings/Settings.scss +113 -0
- package/dist/components/AsideNavigation/Settings/Settings.tsx +270 -0
- package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.scss +70 -0
- package/dist/components/AsideNavigation/Settings/SettingsMenu/SettingsMenu.tsx +141 -0
- package/dist/components/AsideNavigation/Settings/SettingsSearch/SettingsSearch.tsx +57 -0
- package/dist/components/AsideNavigation/Settings/collect-settings.ts +156 -0
- package/dist/components/AsideNavigation/Settings/filter-settings.ts +38 -0
- package/dist/components/AsideNavigation/Settings/helpers.ts +39 -0
- package/dist/components/AsideNavigation/Settings/i18n/en.json +5 -0
- package/dist/components/AsideNavigation/Settings/i18n/index.ts +11 -0
- package/dist/components/AsideNavigation/Settings/i18n/ru.json +5 -0
- package/dist/components/AsideNavigation/Settings/index.ts +1 -0
- package/dist/components/AsideNavigation/constants.ts +28 -0
- package/dist/components/AsideNavigation/helpers.ts +34 -0
- package/dist/components/AsideNavigation/i18n/en.json +4 -0
- package/dist/components/AsideNavigation/i18n/index.ts +11 -0
- package/dist/components/AsideNavigation/i18n/ru.json +4 -0
- package/dist/components/AsideNavigation/icons.ts +32 -0
- package/dist/components/AsideNavigation/types.ts +23 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +25 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.scss +4 -0
- package/dist/components/ClusterInfo/ClusterInfo.scss +65 -0
- package/dist/components/ClusterInfo/ClusterInfo.tsx +157 -0
- package/dist/components/Collapse/Collapse.js +84 -0
- package/dist/components/Collapse/Collapse.scss +70 -0
- package/dist/components/CriticalActionDialog/CriticalActionDialog.js +53 -0
- package/dist/components/CriticalActionDialog/CriticalActionDialog.scss +31 -0
- package/dist/components/EmptyState/EmptyState.js +48 -0
- package/dist/components/EmptyState/EmptyState.scss +70 -0
- package/dist/components/EntityStatus/EntityStatus.js +96 -0
- package/dist/components/EntityStatus/EntityStatus.scss +81 -0
- package/dist/components/FullGroupViewer/FullGroupViewer.js +149 -0
- package/dist/components/FullGroupViewer/FullGroupViewer.scss +32 -0
- package/dist/components/FullNodeViewer/FullNodeViewer.js +108 -0
- package/dist/components/FullNodeViewer/FullNodeViewer.scss +78 -0
- package/dist/components/GroupTreeViewer/GroupTreeViewer.js +86 -0
- package/dist/components/GroupTreeViewer/GroupTreeViewer.scss +17 -0
- package/dist/components/GroupViewer/GroupViewer.js +100 -0
- package/dist/components/GroupViewer/GroupViewer.scss +41 -0
- package/dist/components/Hotkey/Hotkey.js +102 -0
- package/dist/components/Icon/Icon.js +26 -0
- package/dist/components/InfoViewer/InfoViewer.js +47 -0
- package/dist/components/InfoViewer/InfoViewer.scss +48 -0
- package/dist/components/InternalLink/InternalLink.js +15 -0
- package/dist/components/NodesViewer/NodesViewer.js +183 -0
- package/dist/components/NodesViewer/NodesViewer.scss +66 -0
- package/dist/components/PDiskViewer/PDiskViewer.js +80 -0
- package/dist/components/PDiskViewer/PDiskViewer.scss +40 -0
- package/dist/components/Pagination/Pagination.js +63 -0
- package/dist/components/Pagination/Pagination.scss +25 -0
- package/dist/components/PoolBar/PoolBar.js +52 -0
- package/dist/components/PoolBar/PoolBar.scss +40 -0
- package/dist/components/PoolUsage/PoolUsage.js +54 -0
- package/dist/components/PoolUsage/PoolUsage.scss +65 -0
- package/dist/components/PoolsGraph/PoolsGraph.js +33 -0
- package/dist/components/PoolsGraph/PoolsGraph.scss +3 -0
- package/dist/components/ProblemFilter/ProblemFilter.js +24 -0
- package/dist/components/ProgressViewer/ProgressViewer.js +92 -0
- package/dist/components/ProgressViewer/ProgressViewer.scss +84 -0
- package/dist/components/SplitPane/SplitPane.js +368 -0
- package/dist/components/SplitPane/SplitPane.scss +107 -0
- package/dist/components/SplitPane/index.js +3 -0
- package/dist/components/Tablet/Tablet.js +61 -0
- package/dist/components/Tablet/Tablet.scss +49 -0
- package/dist/components/TabletsStatistic/TabletsStatistic.js +58 -0
- package/dist/components/TabletsStatistic/TabletsStatistic.scss +41 -0
- package/dist/components/TabletsViewer/TabletsViewer.js +44 -0
- package/dist/components/TabletsViewer/TabletsViewer.scss +37 -0
- package/dist/components/Tag/Tag.js +14 -0
- package/dist/components/Tag/Tag.scss +17 -0
- package/dist/components/Tags/Tags.js +36 -0
- package/dist/components/Tags/Tags.scss +5 -0
- package/dist/components/TenantOverview/TenantOverview.js +148 -0
- package/dist/components/TenantOverview/TenantOverview.scss +75 -0
- package/dist/components/TreeView/TreeView.js +60 -0
- package/dist/components/TreeView/TreeView.scss +30 -0
- package/dist/components/TruncatedQuery/TruncatedQuery.js +26 -0
- package/dist/components/TruncatedQuery/TruncatedQuery.scss +12 -0
- package/dist/containers/App/App.js +67 -0
- package/dist/containers/App/App.scss +154 -0
- package/dist/containers/App/Content.js +109 -0
- package/dist/containers/App/TipPopup/TipPopup.js +66 -0
- package/dist/containers/App/TipPopup/TipPopup.scss +42 -0
- package/dist/containers/AppIcons/AppIcons.js +477 -0
- package/dist/containers/AsideNavigation/AsideNavigation.scss +43 -0
- package/dist/containers/AsideNavigation/AsideNavigation.tsx +228 -0
- package/dist/containers/Authentication/Authentication.scss +37 -0
- package/dist/containers/Authentication/Authentication.tsx +89 -0
- package/dist/containers/Cluster/Cluster.js +168 -0
- package/dist/containers/Cluster/Cluster.scss +52 -0
- package/dist/containers/Group/Group.js +97 -0
- package/dist/containers/Group/Group.scss +6 -0
- package/dist/containers/Header/Header.js +88 -0
- package/dist/containers/Header/Header.scss +72 -0
- package/dist/containers/Header/Host/Host.js +66 -0
- package/dist/containers/Header/Host/Host.scss +43 -0
- package/dist/containers/Heatmap/Heatmap.js +246 -0
- package/dist/containers/Heatmap/Heatmap.scss +94 -0
- package/dist/containers/Heatmap/HeatmapCanvas/HeatmapCanvas.js +167 -0
- package/dist/containers/Heatmap/Histogram/Histogram.js +108 -0
- package/dist/containers/Heatmap/Histogram/Histogram.scss +49 -0
- package/dist/containers/Heatmap/util.js +110 -0
- package/dist/containers/Node/Node.js +184 -0
- package/dist/containers/Node/Node.scss +34 -0
- package/dist/containers/Node/NodePages.js +13 -0
- package/dist/containers/Nodes/Nodes.js +193 -0
- package/dist/containers/Nodes/Nodes.scss +50 -0
- package/dist/containers/Pdisk/Pdisk.js +159 -0
- package/dist/containers/Pdisk/Pdisk.scss +40 -0
- package/dist/containers/Pool/Pool.js +169 -0
- package/dist/containers/Pool/Pool.scss +32 -0
- package/dist/containers/ReduxTooltip/ReduxTooltip.js +108 -0
- package/dist/containers/ReduxTooltip/ReduxTooltip.scss +67 -0
- package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.scss +81 -0
- package/dist/containers/StorageV2/DiskStateProgressBar/DiskStateProgressBar.tsx +56 -0
- package/dist/containers/StorageV2/Pdisk/Pdisk.scss +32 -0
- package/dist/containers/StorageV2/Pdisk/Pdisk.tsx +167 -0
- package/dist/containers/StorageV2/Storage.js +249 -0
- package/dist/containers/StorageV2/Storage.scss +57 -0
- package/dist/containers/StorageV2/StorageFilter/StorageFilter.js +39 -0
- package/dist/containers/StorageV2/StorageGroups/StorageGroups.scss +26 -0
- package/dist/containers/StorageV2/StorageGroups/StorageGroups.tsx +234 -0
- package/dist/containers/StorageV2/StorageNodes/StorageNodes.scss +30 -0
- package/dist/containers/StorageV2/StorageNodes/StorageNodes.tsx +135 -0
- package/dist/containers/StorageV2/Vdisk/Vdisk.js +250 -0
- package/dist/containers/StorageV2/Vdisk/Vdisk.scss +32 -0
- package/dist/containers/Tablet/Tablet.js +453 -0
- package/dist/containers/Tablet/Tablet.scss +88 -0
- package/dist/containers/Tablets/Tablets.js +306 -0
- package/dist/containers/Tablets/Tablets.scss +77 -0
- package/dist/containers/TabletsFilters/TabletsFilters.js +412 -0
- package/dist/containers/TabletsFilters/TabletsFilters.scss +104 -0
- package/dist/containers/Tenant/Acl/Acl.js +149 -0
- package/dist/containers/Tenant/Acl/Acl.scss +34 -0
- package/dist/containers/Tenant/Compute/Compute.js +110 -0
- package/dist/containers/Tenant/Compute/Compute.scss +6 -0
- package/dist/containers/Tenant/Describe/Describe.js +81 -0
- package/dist/containers/Tenant/Describe/Describe.scss +25 -0
- package/dist/containers/Tenant/Healthcheck/Healthcheck.js +116 -0
- package/dist/containers/Tenant/Healthcheck/Healthcheck.scss +64 -0
- package/dist/containers/Tenant/Healthcheck/IssuesViewer/IssueViewer.scss +164 -0
- package/dist/containers/Tenant/Healthcheck/IssuesViewer/IssuesViewer.js +185 -0
- package/dist/containers/Tenant/Network/Network.js +341 -0
- package/dist/containers/Tenant/Network/Network.scss +145 -0
- package/dist/containers/Tenant/Network/NodeNetwork/NodeNetwork.js +71 -0
- package/dist/containers/Tenant/Network/NodeNetwork/NodeNetwork.scss +52 -0
- package/dist/containers/Tenant/Preview/Preview.js +169 -0
- package/dist/containers/Tenant/Preview/Preview.scss +20 -0
- package/dist/containers/Tenant/QueryEditor/QueryEditor.js +649 -0
- package/dist/containers/Tenant/QueryEditor/QueryEditor.scss +71 -0
- package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +168 -0
- package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.scss +42 -0
- package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.js +58 -0
- package/dist/containers/Tenant/QueryEditor/QueryResult/QueryResult.scss +24 -0
- package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +171 -0
- package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.scss +51 -0
- package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.js +156 -0
- package/dist/containers/Tenant/QueryEditor/SavedQueries/SavedQueries.scss +82 -0
- package/dist/containers/Tenant/Schema/HotKeys/HotKeys.js +149 -0
- package/dist/containers/Tenant/Schema/HotKeys/HotKeys.scss +48 -0
- package/dist/containers/Tenant/Schema/Info/Info.js +84 -0
- package/dist/containers/Tenant/Schema/Info/Info.scss +3 -0
- package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +67 -0
- package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.scss +21 -0
- package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.js +439 -0
- package/dist/containers/Tenant/Schema/SchemaMain/SchemaMain.scss +90 -0
- package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.js +150 -0
- package/dist/containers/Tenant/Schema/SchemaNode/SchemaNode.scss +41 -0
- package/dist/containers/Tenant/Schema/SchemaPages.js +56 -0
- package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.js +115 -0
- package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.scss +13 -0
- package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.js +63 -0
- package/dist/containers/Tenant/Schema/SchemaViewer/SchemaViewer.scss +28 -0
- package/dist/containers/Tenant/Tenant.js +199 -0
- package/dist/containers/Tenant/Tenant.scss +94 -0
- package/dist/containers/Tenant/TenantPages.js +35 -0
- package/dist/containers/Tenant/TopQueries/TopQueries.js +184 -0
- package/dist/containers/Tenant/TopQueries/TopQueries.scss +53 -0
- package/dist/containers/Tenant/TopShards/TopShards.js +171 -0
- package/dist/containers/Tenant/TopShards/TopShards.scss +23 -0
- package/dist/containers/Tenants/Tenants.js +375 -0
- package/dist/containers/Tenants/Tenants.scss +73 -0
- package/dist/containers/UserSettings/UserSettings.tsx +57 -0
- package/dist/containers/Vdisk/Vdisk.js +160 -0
- package/dist/containers/Vdisk/Vdisk.scss +40 -0
- package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.js +528 -0
- package/dist/containers/VdiskPdiskNode/VdiskPdiskNode.scss +60 -0
- package/dist/contexts/HistoryContext.ts +6 -0
- package/dist/index.css +11 -0
- package/dist/index.js +28 -0
- package/dist/index.test.js +5 -0
- package/dist/react-app-env.d.ts +1 -0
- package/dist/reportWebVitals.js +13 -0
- package/dist/routes.js +40 -0
- package/dist/services/api.js +224 -0
- package/dist/setupTests.js +5 -0
- package/dist/store/index.js +61 -0
- package/dist/store/reducers/authentication.js +77 -0
- package/dist/store/reducers/cluster.js +52 -0
- package/dist/store/reducers/clusterInfo.js +48 -0
- package/dist/store/reducers/clusterNodes.js +70 -0
- package/dist/store/reducers/describe.js +45 -0
- package/dist/store/reducers/executeQuery.js +158 -0
- package/dist/store/reducers/executeTopQueries.js +69 -0
- package/dist/store/reducers/explainQuery.js +174 -0
- package/dist/store/reducers/group.js +49 -0
- package/dist/store/reducers/healthcheckInfo.js +45 -0
- package/dist/store/reducers/heatmap.js +105 -0
- package/dist/store/reducers/host.js +44 -0
- package/dist/store/reducers/hotKeys.js +57 -0
- package/dist/store/reducers/index.js +78 -0
- package/dist/store/reducers/network.js +45 -0
- package/dist/store/reducers/node.js +42 -0
- package/dist/store/reducers/nodes.js +58 -0
- package/dist/store/reducers/olapStats.js +74 -0
- package/dist/store/reducers/pdisk.js +51 -0
- package/dist/store/reducers/pool.js +42 -0
- package/dist/store/reducers/preview.js +73 -0
- package/dist/store/reducers/schema.js +95 -0
- package/dist/store/reducers/schemaAcl.js +44 -0
- package/dist/store/reducers/settings.js +76 -0
- package/dist/store/reducers/shardsWorkload.js +75 -0
- package/dist/store/reducers/storage.js +280 -0
- package/dist/store/reducers/tablet.js +94 -0
- package/dist/store/reducers/tablets.js +90 -0
- package/dist/store/reducers/tabletsFilters.js +126 -0
- package/dist/store/reducers/tenant.js +76 -0
- package/dist/store/reducers/tenants.js +61 -0
- package/dist/store/reducers/tooltip.js +64 -0
- package/dist/store/reducers/vdisk.js +49 -0
- package/dist/store/state-url-mapping.js +133 -0
- package/dist/store/utils.js +55 -0
- package/dist/styles/mixins.scss +254 -0
- package/dist/styles/react-treeview.scss +45 -0
- package/dist/types/assets.d.ts +12 -0
- package/dist/types/react-list.d.ts +4 -0
- package/dist/types/window.d.ts +33 -0
- package/dist/utils/actionsConstants.js +4 -0
- package/dist/utils/constants.js +126 -0
- package/dist/utils/getNodesColumns.js +156 -0
- package/dist/utils/i18n/i18n.ts +7 -0
- package/dist/utils/i18n/index.ts +1 -0
- package/dist/utils/index.js +136 -0
- package/dist/utils/monaco.js +69 -0
- package/dist/utils/prepareQueryExplain.ts +101 -0
- package/dist/utils/tooltip.js +197 -0
- package/dist/utils/utils.js +75 -0
- package/package.json +89 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import cn from 'bem-cn-lite';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import './NodeNetwork.scss';
|
5
|
+
const b = cn('node-network');
|
6
|
+
|
7
|
+
const getNodeModifier = (connected, capacity) => {
|
8
|
+
const percents = Math.floor((connected / capacity) * 100);
|
9
|
+
if (percents === 100) {
|
10
|
+
return 'green';
|
11
|
+
} else if (percents >= 70) {
|
12
|
+
return 'yellow';
|
13
|
+
} else if (percents >= 1) {
|
14
|
+
return 'red';
|
15
|
+
} else {
|
16
|
+
return 'gray';
|
17
|
+
}
|
18
|
+
};
|
19
|
+
|
20
|
+
export class NodeNetwork extends React.Component {
|
21
|
+
static propTypes = {
|
22
|
+
onMouseEnter: PropTypes.func,
|
23
|
+
onMouseLeave: PropTypes.func,
|
24
|
+
nodeId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
25
|
+
connected: PropTypes.number,
|
26
|
+
capacity: PropTypes.number,
|
27
|
+
rack: PropTypes.string,
|
28
|
+
status: PropTypes.string,
|
29
|
+
onClick: PropTypes.func,
|
30
|
+
showID: PropTypes.bool,
|
31
|
+
isBlurred: PropTypes.bool,
|
32
|
+
};
|
33
|
+
|
34
|
+
static defaultProps = {
|
35
|
+
onMouseEnter: () => {},
|
36
|
+
onMouseLeave: () => {},
|
37
|
+
onClick: () => {},
|
38
|
+
};
|
39
|
+
|
40
|
+
node = React.createRef();
|
41
|
+
|
42
|
+
_onNodeHover = () => {
|
43
|
+
const {onMouseEnter, nodeId, connected, capacity, rack} = this.props;
|
44
|
+
const popupData = {nodeId, connected, capacity, rack};
|
45
|
+
onMouseEnter(this.node.current, popupData, 'node');
|
46
|
+
};
|
47
|
+
_onNodeLeave = () => {
|
48
|
+
this.props.onMouseLeave();
|
49
|
+
};
|
50
|
+
|
51
|
+
render() {
|
52
|
+
const {nodeId, connected, capacity, status, onClick, showID, isBlurred} = this.props;
|
53
|
+
return (
|
54
|
+
<div
|
55
|
+
ref={this.node}
|
56
|
+
className={b({
|
57
|
+
[status?.toLowerCase() || getNodeModifier(connected, capacity)]: true,
|
58
|
+
id: showID,
|
59
|
+
blur: isBlurred,
|
60
|
+
})}
|
61
|
+
onMouseEnter={this._onNodeHover}
|
62
|
+
onMouseLeave={this._onNodeLeave}
|
63
|
+
onClick={() => onClick(nodeId)}
|
64
|
+
>
|
65
|
+
{showID && nodeId}
|
66
|
+
</div>
|
67
|
+
);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
export default NodeNetwork;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
.node-network {
|
2
|
+
box-sizing: border-box;
|
3
|
+
width: 14px;
|
4
|
+
height: 14px;
|
5
|
+
border-radius: 3px;
|
6
|
+
padding: 0 5px;
|
7
|
+
display: inline-block;
|
8
|
+
border-radius: 4px;
|
9
|
+
text-align: center;
|
10
|
+
color: var(--yc-color-text-complementary);
|
11
|
+
text-transform: uppercase;
|
12
|
+
font-size: 12px;
|
13
|
+
line-height: 14px;
|
14
|
+
cursor: pointer;
|
15
|
+
margin-right: 5px;
|
16
|
+
margin-bottom: 5px;
|
17
|
+
border: 1px solid transparent;
|
18
|
+
|
19
|
+
&_id {
|
20
|
+
width: 42px;
|
21
|
+
height: 14px;
|
22
|
+
}
|
23
|
+
|
24
|
+
&_blur {
|
25
|
+
opacity: 0.25;
|
26
|
+
}
|
27
|
+
|
28
|
+
&_gray {
|
29
|
+
background: var(--yc-color-text-secondary);
|
30
|
+
}
|
31
|
+
|
32
|
+
&_black {
|
33
|
+
background-color: var(--yc-color-text-primary);
|
34
|
+
color: var(--yc-color-text-light-primary);
|
35
|
+
}
|
36
|
+
|
37
|
+
&_green {
|
38
|
+
background-color: var(--yc-color-base-positive-heavy);
|
39
|
+
}
|
40
|
+
|
41
|
+
&_yellow {
|
42
|
+
background-color: var(--yc-color-base-warning-heavy);
|
43
|
+
}
|
44
|
+
|
45
|
+
&_red {
|
46
|
+
background-color: var(--yc-color-text-yandex-red);
|
47
|
+
}
|
48
|
+
|
49
|
+
&:hover {
|
50
|
+
border: 1px solid var(--yc-color-text-primary);
|
51
|
+
}
|
52
|
+
}
|
@@ -0,0 +1,169 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import {connect} from 'react-redux';
|
4
|
+
import cn from 'bem-cn-lite';
|
5
|
+
|
6
|
+
import DataTable from '@yandex-cloud/react-data-table';
|
7
|
+
import {Loader} from '@yandex-cloud/uikit';
|
8
|
+
|
9
|
+
import {sendQuery, setQueryOptions} from '../../../store/reducers/preview';
|
10
|
+
import {showTooltip, hideTooltip} from '../../../store/reducers/tooltip';
|
11
|
+
import {prepareQueryResponse} from '../../../utils/index';
|
12
|
+
|
13
|
+
import {OLAP_TABLE_TYPE, TABLE_TYPE} from '../Schema/SchemaMain/SchemaMain';
|
14
|
+
import {AutoFetcher} from '../../Cluster/Cluster';
|
15
|
+
|
16
|
+
import './Preview.scss';
|
17
|
+
|
18
|
+
const TABLE_SETTINGS = {
|
19
|
+
displayIndices: false,
|
20
|
+
syncHeadOnResize: true,
|
21
|
+
stickyHead: DataTable.MOVING,
|
22
|
+
};
|
23
|
+
|
24
|
+
const b = cn('kv-preview');
|
25
|
+
|
26
|
+
class Preview extends React.Component {
|
27
|
+
static propTypes = {
|
28
|
+
sendQuery: PropTypes.func,
|
29
|
+
database: PropTypes.string,
|
30
|
+
table: PropTypes.string,
|
31
|
+
error: PropTypes.string,
|
32
|
+
data: PropTypes.array,
|
33
|
+
loading: PropTypes.bool,
|
34
|
+
type: PropTypes.string,
|
35
|
+
showTooltip: PropTypes.func,
|
36
|
+
hideTooltip: PropTypes.func,
|
37
|
+
partCount: PropTypes.string,
|
38
|
+
};
|
39
|
+
|
40
|
+
autofetcher;
|
41
|
+
|
42
|
+
componentDidMount() {
|
43
|
+
this.sendQueryForPreview();
|
44
|
+
this.autofetcher = new AutoFetcher();
|
45
|
+
if (this.props.autorefresh) {
|
46
|
+
this.autofetcher.start();
|
47
|
+
this.autofetcher.fetch(() => this.sendQueryForPreview());
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
componentDidUpdate(prevProps) {
|
52
|
+
const {table, hideTooltip, autorefresh, setQueryOptions} = this.props;
|
53
|
+
|
54
|
+
if (prevProps.table !== table) {
|
55
|
+
this.sendQueryForPreview();
|
56
|
+
hideTooltip();
|
57
|
+
setQueryOptions({
|
58
|
+
wasLoaded: false,
|
59
|
+
data: undefined,
|
60
|
+
});
|
61
|
+
}
|
62
|
+
|
63
|
+
if (autorefresh && !prevProps.autorefresh) {
|
64
|
+
this.sendQueryForPreview();
|
65
|
+
this.autofetcher.start();
|
66
|
+
this.autofetcher.fetch(() => this.sendQueryForPreview());
|
67
|
+
}
|
68
|
+
if (!autorefresh && prevProps.autorefresh) {
|
69
|
+
this.autofetcher.stop();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
componentWillUnmount() {
|
74
|
+
this.autofetcher.stop();
|
75
|
+
}
|
76
|
+
|
77
|
+
sendQueryForPreview = () => {
|
78
|
+
const {sendQuery, database, table, type} = this.props;
|
79
|
+
|
80
|
+
if (type !== TABLE_TYPE && type !== OLAP_TABLE_TYPE) {
|
81
|
+
return;
|
82
|
+
}
|
83
|
+
|
84
|
+
const query = `--!syntax_v1\nselect * from \`${table}\` limit 32`;
|
85
|
+
sendQuery({
|
86
|
+
query,
|
87
|
+
database: database,
|
88
|
+
action: 'execute-scan',
|
89
|
+
path: table,
|
90
|
+
});
|
91
|
+
};
|
92
|
+
|
93
|
+
renderTable = () => {
|
94
|
+
const {data, showTooltip} = this.props;
|
95
|
+
|
96
|
+
let columns = [];
|
97
|
+
if (data && data.length > 0) {
|
98
|
+
columns = Object.keys(data[0]).map((key) => ({
|
99
|
+
name: key,
|
100
|
+
render: ({value}) => {
|
101
|
+
return (
|
102
|
+
<span
|
103
|
+
className={b('cell')}
|
104
|
+
onClick={(e) => showTooltip(e.target, value, 'cell')}
|
105
|
+
>
|
106
|
+
{value}
|
107
|
+
</span>
|
108
|
+
);
|
109
|
+
},
|
110
|
+
}));
|
111
|
+
}
|
112
|
+
|
113
|
+
const preparedData = prepareQueryResponse(data);
|
114
|
+
|
115
|
+
return <DataTable columns={columns} data={preparedData} settings={TABLE_SETTINGS} />;
|
116
|
+
};
|
117
|
+
|
118
|
+
render() {
|
119
|
+
const {error, loading, data = [], type, wasLoaded} = this.props;
|
120
|
+
|
121
|
+
if (type !== TABLE_TYPE && type !== OLAP_TABLE_TYPE) {
|
122
|
+
return <div className={b('message-container')}>Not available</div>;
|
123
|
+
}
|
124
|
+
|
125
|
+
if (loading && !wasLoaded) {
|
126
|
+
return (
|
127
|
+
<div className={b('loader-container')}>
|
128
|
+
<Loader size="m" />
|
129
|
+
</div>
|
130
|
+
);
|
131
|
+
}
|
132
|
+
|
133
|
+
if (error) {
|
134
|
+
return <div className={b('message-container')}>{error.data || error}</div>;
|
135
|
+
}
|
136
|
+
|
137
|
+
if (!loading && data.length === 0) {
|
138
|
+
return <div className={b('message-container')}>Table is empty</div>;
|
139
|
+
}
|
140
|
+
|
141
|
+
return (
|
142
|
+
<div className={b()}>
|
143
|
+
<div className={b('result')}>{this.renderTable()}</div>
|
144
|
+
</div>
|
145
|
+
);
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
const mapStateToProps = (state) => {
|
150
|
+
const {data = [], loading, error, wasLoaded} = state.preview;
|
151
|
+
const {autorefresh} = state.schema;
|
152
|
+
|
153
|
+
return {
|
154
|
+
data,
|
155
|
+
loading,
|
156
|
+
error,
|
157
|
+
autorefresh,
|
158
|
+
wasLoaded,
|
159
|
+
};
|
160
|
+
};
|
161
|
+
|
162
|
+
const mapDispatchToProps = {
|
163
|
+
sendQuery,
|
164
|
+
showTooltip,
|
165
|
+
hideTooltip,
|
166
|
+
setQueryOptions,
|
167
|
+
};
|
168
|
+
|
169
|
+
export default connect(mapStateToProps, mapDispatchToProps)(Preview);
|
@@ -0,0 +1,20 @@
|
|
1
|
+
@import '../../../styles/mixins.scss';
|
2
|
+
|
3
|
+
.kv-preview {
|
4
|
+
&__message-container {
|
5
|
+
padding: 15px 0;
|
6
|
+
}
|
7
|
+
|
8
|
+
&__loader-container {
|
9
|
+
display: flex;
|
10
|
+
justify-content: center;
|
11
|
+
align-items: center;
|
12
|
+
height: 100%;
|
13
|
+
}
|
14
|
+
|
15
|
+
@include query-data-table;
|
16
|
+
|
17
|
+
&__cell {
|
18
|
+
@include cell-container;
|
19
|
+
}
|
20
|
+
}
|