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,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 {Loader} from '@yandex-cloud/uikit';
|
6
|
+
import DataTable from '@yandex-cloud/react-data-table';
|
7
|
+
|
8
|
+
import {changeUserInput} from '../../../store/reducers/executeQuery';
|
9
|
+
import {sendQuery, setQueryOptions} from '../../../store/reducers/executeTopQueries';
|
10
|
+
import {QUERY} from '../Schema/SchemaPages';
|
11
|
+
import TruncatedQuery from '../../../components/TruncatedQuery/TruncatedQuery';
|
12
|
+
import {AutoFetcher} from '../../Cluster/Cluster';
|
13
|
+
import {OLAP_STORE_TYPE, OLAP_TABLE_TYPE} from '../Schema/SchemaMain/SchemaMain';
|
14
|
+
|
15
|
+
import './TopQueries.scss';
|
16
|
+
|
17
|
+
const b = cn('kv-top-queries');
|
18
|
+
|
19
|
+
const TABLE_SETTINGS = {
|
20
|
+
displayIndices: false,
|
21
|
+
syncHeadOnResize: true,
|
22
|
+
stickyHead: DataTable.MOVING,
|
23
|
+
highlightRows: true,
|
24
|
+
};
|
25
|
+
const MAX_QUERY_HEIGHT = 10;
|
26
|
+
const COLUMNS = [
|
27
|
+
{
|
28
|
+
name: 'CPUTimeUs',
|
29
|
+
width: 140,
|
30
|
+
sortAccessor: (row) => Number(row['CPUTimeUs']),
|
31
|
+
},
|
32
|
+
{
|
33
|
+
name: 'QueryText',
|
34
|
+
width: 500,
|
35
|
+
sortable: false,
|
36
|
+
// eslint-disable-next-line
|
37
|
+
render: ({value}) => <TruncatedQuery value={value} maxQueryHeight={MAX_QUERY_HEIGHT} />,
|
38
|
+
},
|
39
|
+
];
|
40
|
+
const getQueryText = (path) => `
|
41
|
+
--!syntax_v1
|
42
|
+
$last = (
|
43
|
+
SELECT
|
44
|
+
MAX(IntervalEnd)
|
45
|
+
FROM \`${path}/.sys/top_queries_by_cpu_time_one_hour\`
|
46
|
+
);
|
47
|
+
SELECT
|
48
|
+
CPUTime as CPUTimeUs,
|
49
|
+
QueryText
|
50
|
+
FROM \`${path}/.sys/top_queries_by_cpu_time_one_hour\`
|
51
|
+
WHERE IntervalEnd IN $last
|
52
|
+
`;
|
53
|
+
|
54
|
+
class TopQueries extends React.Component {
|
55
|
+
static propTypes = {
|
56
|
+
error: PropTypes.string,
|
57
|
+
sendQuery: PropTypes.func,
|
58
|
+
path: PropTypes.string,
|
59
|
+
data: PropTypes.array,
|
60
|
+
loading: PropTypes.bool,
|
61
|
+
changeSchemaTab: PropTypes.func,
|
62
|
+
currentSchema: PropTypes.object,
|
63
|
+
};
|
64
|
+
|
65
|
+
autofetcher;
|
66
|
+
|
67
|
+
componentDidMount() {
|
68
|
+
this.autofetcher = new AutoFetcher();
|
69
|
+
this.getTopQueries();
|
70
|
+
}
|
71
|
+
|
72
|
+
componentDidUpdate(prevProps) {
|
73
|
+
const {autorefresh, path, setQueryOptions} = this.props;
|
74
|
+
|
75
|
+
if (autorefresh && !prevProps.autorefresh) {
|
76
|
+
this.getTopQueries();
|
77
|
+
this.autofetcher.start();
|
78
|
+
this.autofetcher.fetch(() => this.getTopQueries());
|
79
|
+
}
|
80
|
+
if (!autorefresh && prevProps.autorefresh) {
|
81
|
+
this.autofetcher.stop();
|
82
|
+
}
|
83
|
+
|
84
|
+
if (path !== prevProps.path) {
|
85
|
+
setQueryOptions({
|
86
|
+
wasLoaded: false,
|
87
|
+
data: undefined,
|
88
|
+
});
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
componentWillUnmount() {
|
93
|
+
this.autofetcher.stop();
|
94
|
+
}
|
95
|
+
|
96
|
+
getTopQueries() {
|
97
|
+
const {path} = this.props;
|
98
|
+
const query = getQueryText(path);
|
99
|
+
this.props.sendQuery({query, database: path, action: 'execute-scan'});
|
100
|
+
}
|
101
|
+
|
102
|
+
onRowClick = (row) => {
|
103
|
+
const {QueryText: input} = row;
|
104
|
+
const {changeUserInput, changeSchemaTab} = this.props;
|
105
|
+
|
106
|
+
changeUserInput({input});
|
107
|
+
changeSchemaTab(QUERY);
|
108
|
+
};
|
109
|
+
|
110
|
+
renderTable = () => {
|
111
|
+
const {data} = this.props;
|
112
|
+
|
113
|
+
if (!data) {
|
114
|
+
return null;
|
115
|
+
}
|
116
|
+
|
117
|
+
return (
|
118
|
+
<DataTable
|
119
|
+
columns={COLUMNS}
|
120
|
+
data={data}
|
121
|
+
settings={TABLE_SETTINGS}
|
122
|
+
onRowClick={this.onRowClick}
|
123
|
+
/>
|
124
|
+
);
|
125
|
+
};
|
126
|
+
|
127
|
+
renderResult = () => {
|
128
|
+
return (
|
129
|
+
<div className={b('table-wrapper')}>
|
130
|
+
<div className={b('table-content')}>{this.renderTable()}</div>
|
131
|
+
</div>
|
132
|
+
);
|
133
|
+
};
|
134
|
+
|
135
|
+
render() {
|
136
|
+
const {error, loading, data, wasLoaded, type} = this.props;
|
137
|
+
|
138
|
+
if (loading && !wasLoaded) {
|
139
|
+
return (
|
140
|
+
<div className={b('loader-container')}>
|
141
|
+
<Loader size="m" />
|
142
|
+
</div>
|
143
|
+
);
|
144
|
+
}
|
145
|
+
|
146
|
+
let message;
|
147
|
+
if (type === OLAP_STORE_TYPE || type === OLAP_TABLE_TYPE) {
|
148
|
+
message = 'No data';
|
149
|
+
} else if (error && !error.isCancelled) {
|
150
|
+
message = (error.data || error).slice(0, 300);
|
151
|
+
} else if (!loading && !data) {
|
152
|
+
message = 'No data';
|
153
|
+
}
|
154
|
+
|
155
|
+
if (message) {
|
156
|
+
return <div className={b('message-container')}>{message}</div>;
|
157
|
+
}
|
158
|
+
|
159
|
+
return (
|
160
|
+
<div className={b()}>
|
161
|
+
<div className={b('result')}>{this.renderResult()}</div>
|
162
|
+
</div>
|
163
|
+
);
|
164
|
+
}
|
165
|
+
}
|
166
|
+
const mapStateToProps = (state) => {
|
167
|
+
const {loading, data, error, wasLoaded} = state.executeTopQueries;
|
168
|
+
const {autorefresh} = state.schema;
|
169
|
+
return {
|
170
|
+
loading,
|
171
|
+
data,
|
172
|
+
error,
|
173
|
+
wasLoaded,
|
174
|
+
autorefresh,
|
175
|
+
};
|
176
|
+
};
|
177
|
+
|
178
|
+
const mapDispatchToProps = {
|
179
|
+
sendQuery,
|
180
|
+
changeUserInput,
|
181
|
+
setQueryOptions,
|
182
|
+
};
|
183
|
+
|
184
|
+
export default connect(mapStateToProps, mapDispatchToProps)(TopQueries);
|
@@ -0,0 +1,53 @@
|
|
1
|
+
@import '../../../styles/mixins.scss';
|
2
|
+
|
3
|
+
.kv-top-queries {
|
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
|
+
&__owner-container {
|
18
|
+
margin: 10px;
|
19
|
+
|
20
|
+
.yc-staff-card {
|
21
|
+
display: inline-block;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
&__text {
|
26
|
+
font-size: var(--yc-text-body-font-size);
|
27
|
+
line-height: var(--yc-text-body-line-height);
|
28
|
+
color: var(--yc-color-text-primary);
|
29
|
+
|
30
|
+
&::first-letter {
|
31
|
+
color: var(--yc-color-text-danger);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
&__result &__table-content {
|
36
|
+
& .data-table {
|
37
|
+
&,
|
38
|
+
&__table {
|
39
|
+
width: 100%;
|
40
|
+
}
|
41
|
+
&__td {
|
42
|
+
word-break: break-word;
|
43
|
+
white-space: pre;
|
44
|
+
vertical-align: top;
|
45
|
+
}
|
46
|
+
|
47
|
+
&__row {
|
48
|
+
cursor: pointer;
|
49
|
+
max-height: 80px;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
import {useContext, useEffect, useMemo} from 'react';
|
2
|
+
import cn from 'bem-cn-lite';
|
3
|
+
import {connect} from 'react-redux';
|
4
|
+
import InternalLink from '../../../components/InternalLink/InternalLink';
|
5
|
+
import {Loader} from '@yandex-cloud/uikit';
|
6
|
+
import DataTable from '@yandex-cloud/react-data-table';
|
7
|
+
import routes, {createHref} from '../../../routes';
|
8
|
+
|
9
|
+
import {sendShardQuery, setShardQueryOptions} from '../../../store/reducers/shardsWorkload';
|
10
|
+
import {setCurrentSchemaPath, getSchema} from '../../../store/reducers/schema';
|
11
|
+
import {AutoFetcher} from '../../Cluster/Cluster';
|
12
|
+
|
13
|
+
import './TopShards.scss';
|
14
|
+
import {OLAP_STORE_TYPE, OLAP_TABLE_TYPE} from '../Schema/SchemaMain/SchemaMain';
|
15
|
+
import HistoryContext from '../../../contexts/HistoryContext';
|
16
|
+
|
17
|
+
const b = cn('top-shards');
|
18
|
+
const bLink = cn('yc-link');
|
19
|
+
|
20
|
+
const TABLE_SETTINGS = {
|
21
|
+
displayIndices: false,
|
22
|
+
syncHeadOnResize: true,
|
23
|
+
stickyHead: DataTable.MOVING,
|
24
|
+
};
|
25
|
+
|
26
|
+
const tableColumnsNames = {
|
27
|
+
TabletId: 'TabletId',
|
28
|
+
CPUCores: 'CPUCores',
|
29
|
+
Path: 'Path',
|
30
|
+
};
|
31
|
+
|
32
|
+
const autofetcher = new AutoFetcher();
|
33
|
+
|
34
|
+
function prepareCPUWorkloadValue(value) {
|
35
|
+
return `${(value * 100).toFixed(2)}%`;
|
36
|
+
}
|
37
|
+
|
38
|
+
function TopShards({
|
39
|
+
sendShardQuery,
|
40
|
+
currentSchemaPath,
|
41
|
+
path,
|
42
|
+
loading,
|
43
|
+
data,
|
44
|
+
error,
|
45
|
+
setCurrentSchemaPath,
|
46
|
+
getSchema,
|
47
|
+
autorefresh,
|
48
|
+
wasLoaded,
|
49
|
+
setShardQueryOptions,
|
50
|
+
type,
|
51
|
+
}) {
|
52
|
+
useEffect(() => {
|
53
|
+
if (autorefresh) {
|
54
|
+
autofetcher.start();
|
55
|
+
autofetcher.fetch(() => sendShardQuery({database: path, path: currentSchemaPath}));
|
56
|
+
} else {
|
57
|
+
autofetcher.stop();
|
58
|
+
}
|
59
|
+
return () => {
|
60
|
+
autofetcher.stop();
|
61
|
+
};
|
62
|
+
}, [autorefresh]);
|
63
|
+
|
64
|
+
useEffect(() => {
|
65
|
+
sendShardQuery({database: path, path: currentSchemaPath});
|
66
|
+
setShardQueryOptions({
|
67
|
+
wasLoaded: false,
|
68
|
+
data: undefined,
|
69
|
+
});
|
70
|
+
}, [currentSchemaPath]);
|
71
|
+
|
72
|
+
const renderLoader = () => {
|
73
|
+
return (
|
74
|
+
<div className={b('loader')}>
|
75
|
+
<Loader size="l" />
|
76
|
+
</div>
|
77
|
+
);
|
78
|
+
};
|
79
|
+
|
80
|
+
const history = useContext(HistoryContext);
|
81
|
+
|
82
|
+
const onSchemaClick = (schemaPath) => {
|
83
|
+
return () => {
|
84
|
+
setCurrentSchemaPath(schemaPath);
|
85
|
+
getSchema({path: schemaPath});
|
86
|
+
history.go(0);
|
87
|
+
};
|
88
|
+
};
|
89
|
+
|
90
|
+
const tableColumns = useMemo(() => {
|
91
|
+
return [
|
92
|
+
{
|
93
|
+
name: tableColumnsNames.Path,
|
94
|
+
// eslint-disable-next-line
|
95
|
+
render: ({value}) => {
|
96
|
+
return (
|
97
|
+
<span onClick={onSchemaClick(value)} className={bLink({view: 'normal'})}>
|
98
|
+
{value}
|
99
|
+
</span>
|
100
|
+
);
|
101
|
+
},
|
102
|
+
},
|
103
|
+
{
|
104
|
+
name: tableColumnsNames.CPUCores,
|
105
|
+
// eslint-disable-next-line
|
106
|
+
render: ({value}) => {
|
107
|
+
return prepareCPUWorkloadValue(value);
|
108
|
+
},
|
109
|
+
align: DataTable.RIGHT,
|
110
|
+
},
|
111
|
+
{
|
112
|
+
name: tableColumnsNames.TabletId,
|
113
|
+
// eslint-disable-next-line
|
114
|
+
render: ({value}) => {
|
115
|
+
return (
|
116
|
+
<InternalLink to={createHref(routes.tablet, {id: value})}>
|
117
|
+
{value}
|
118
|
+
</InternalLink>
|
119
|
+
);
|
120
|
+
},
|
121
|
+
},
|
122
|
+
];
|
123
|
+
}, []);
|
124
|
+
|
125
|
+
const renderContent = () => {
|
126
|
+
if (type === OLAP_STORE_TYPE || type === OLAP_TABLE_TYPE) {
|
127
|
+
return <div className={b('no-data')}>No data</div>;
|
128
|
+
}
|
129
|
+
if (error) {
|
130
|
+
return error.data;
|
131
|
+
}
|
132
|
+
return data && data.length > 0 ? (
|
133
|
+
<div className={b('table')}>
|
134
|
+
<DataTable
|
135
|
+
columns={tableColumns}
|
136
|
+
data={data}
|
137
|
+
settings={TABLE_SETTINGS}
|
138
|
+
className={b('table')}
|
139
|
+
theme="internal"
|
140
|
+
/>
|
141
|
+
</div>
|
142
|
+
) : (
|
143
|
+
data
|
144
|
+
);
|
145
|
+
};
|
146
|
+
|
147
|
+
return <div className={b()}>{loading && !wasLoaded ? renderLoader() : renderContent()}</div>;
|
148
|
+
}
|
149
|
+
|
150
|
+
const mapStateToProps = (state) => {
|
151
|
+
const {loading, data, error, wasLoaded} = state.shardsWorkload;
|
152
|
+
const {Path} = state.schema.currentSchema;
|
153
|
+
const {autorefresh} = state.schema;
|
154
|
+
return {
|
155
|
+
loading,
|
156
|
+
data,
|
157
|
+
error,
|
158
|
+
currentSchemaPath: Path,
|
159
|
+
autorefresh,
|
160
|
+
wasLoaded,
|
161
|
+
};
|
162
|
+
};
|
163
|
+
|
164
|
+
const mapDispatchToProps = {
|
165
|
+
sendShardQuery,
|
166
|
+
setCurrentSchemaPath,
|
167
|
+
getSchema,
|
168
|
+
setShardQueryOptions,
|
169
|
+
};
|
170
|
+
|
171
|
+
export default connect(mapStateToProps, mapDispatchToProps)(TopShards);
|
@@ -0,0 +1,23 @@
|
|
1
|
+
.top-shards {
|
2
|
+
height: 100%;
|
3
|
+
padding-top: 10px;
|
4
|
+
|
5
|
+
background-color: var(--yc-color-base-background);
|
6
|
+
&__loader {
|
7
|
+
display: flex;
|
8
|
+
align-items: center;
|
9
|
+
justify-content: center;
|
10
|
+
|
11
|
+
height: 100%;
|
12
|
+
}
|
13
|
+
|
14
|
+
&__table {
|
15
|
+
overflow: auto;
|
16
|
+
|
17
|
+
margin-top: 5px;
|
18
|
+
}
|
19
|
+
|
20
|
+
&__no-data {
|
21
|
+
margin-top: 5px;
|
22
|
+
}
|
23
|
+
}
|