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,306 @@
|
|
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 {
|
7
|
+
getTabletsInfo,
|
8
|
+
clearWasLoadingFlag,
|
9
|
+
setStateFilter,
|
10
|
+
setTypeFilter,
|
11
|
+
} from '../../store/reducers/tablets';
|
12
|
+
import {showTooltip, hideTooltip} from '../../store/reducers/tooltip';
|
13
|
+
|
14
|
+
import Tablet from '../../components/Tablet/Tablet';
|
15
|
+
import {Loader, Progress} from '@yandex-cloud/uikit';
|
16
|
+
import {Select} from '@yandex-cloud/uikit/build/esm/components/unstable/Select';
|
17
|
+
import ReactList from 'react-list';
|
18
|
+
import {COLORS_PRIORITY} from '../../utils/constants';
|
19
|
+
import {AutoFetcher} from '../Cluster/Cluster';
|
20
|
+
|
21
|
+
import './Tablets.scss';
|
22
|
+
|
23
|
+
// чтобы при очень маленьком проценте все равно были видны проблемные места, установим минимальный процент в 3
|
24
|
+
const minOverallPercentValue = 3;
|
25
|
+
|
26
|
+
const b = cn('tablets');
|
27
|
+
|
28
|
+
class Tablets extends React.Component {
|
29
|
+
static propTypes = {
|
30
|
+
tablets: PropTypes.array,
|
31
|
+
error: PropTypes.bool,
|
32
|
+
wasLoaded: PropTypes.bool,
|
33
|
+
loading: PropTypes.bool,
|
34
|
+
showTooltip: PropTypes.func,
|
35
|
+
hideTooltip: PropTypes.func,
|
36
|
+
getTabletsInfo: PropTypes.func,
|
37
|
+
nodeId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
38
|
+
timeoutForRequest: PropTypes.number,
|
39
|
+
path: PropTypes.string,
|
40
|
+
clearWasLoadingFlag: PropTypes.func,
|
41
|
+
};
|
42
|
+
|
43
|
+
autofetcher;
|
44
|
+
|
45
|
+
static renderLoader() {
|
46
|
+
return (
|
47
|
+
<div className={b('loader-wrapper')}>
|
48
|
+
<Loader size="m" />
|
49
|
+
</div>
|
50
|
+
);
|
51
|
+
}
|
52
|
+
|
53
|
+
state = {
|
54
|
+
filteredTablets: [],
|
55
|
+
};
|
56
|
+
|
57
|
+
componentDidMount() {
|
58
|
+
this.makeRequestIfPathOrNodeExist();
|
59
|
+
this.autofetcher = new AutoFetcher();
|
60
|
+
if (this.props.autorefresh) {
|
61
|
+
this.autofetcher.start();
|
62
|
+
this.autofetcher.fetch(() => this.makeRequestIfPathOrNodeExist());
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
componentDidUpdate(prevProps) {
|
67
|
+
const {autorefresh} = this.props;
|
68
|
+
if (prevProps.path && this.props.path && prevProps.path !== this.props.path) {
|
69
|
+
this.props.clearWasLoadingFlag();
|
70
|
+
this.makeRequestIfPathOrNodeExist();
|
71
|
+
}
|
72
|
+
|
73
|
+
if (autorefresh && !prevProps.autorefresh) {
|
74
|
+
this.makeRequestIfPathOrNodeExist();
|
75
|
+
this.autofetcher.stop();
|
76
|
+
this.autofetcher.start();
|
77
|
+
this.autofetcher.fetch(() => this.makeRequestIfPathOrNodeExist());
|
78
|
+
}
|
79
|
+
if (!autorefresh && prevProps.autorefresh) {
|
80
|
+
this.autofetcher.stop();
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
componentWillUnmount() {
|
85
|
+
this.autofetcher.stop();
|
86
|
+
}
|
87
|
+
|
88
|
+
makeRequestIfPathOrNodeExist = () => {
|
89
|
+
const {nodeId, path} = this.props;
|
90
|
+
if (typeof nodeId !== 'undefined') {
|
91
|
+
this.props.getTabletsInfo({nodes: [nodeId]}).then(this.updateFilteredTablets);
|
92
|
+
} else if (typeof path !== 'undefined') {
|
93
|
+
this.props.getTabletsInfo({path}).then(this.updateFilteredTablets);
|
94
|
+
}
|
95
|
+
};
|
96
|
+
|
97
|
+
handleStateFilterChange = (stateFilter) => {
|
98
|
+
this.props.setStateFilter(stateFilter);
|
99
|
+
this.updateFilteredTablets();
|
100
|
+
};
|
101
|
+
|
102
|
+
handleTypeFilterChange = (typeFilter) => {
|
103
|
+
this.props.setTypeFilter(typeFilter);
|
104
|
+
this.updateFilteredTablets();
|
105
|
+
};
|
106
|
+
|
107
|
+
renderTablet = (tablet, tabletIndex) => {
|
108
|
+
return (
|
109
|
+
<Tablet
|
110
|
+
onMouseLeave={this.props.hideTooltip}
|
111
|
+
onMouseEnter={this.props.showTooltip}
|
112
|
+
tablet={this.state.filteredTablets[parseInt(tabletIndex, 10)]}
|
113
|
+
key={tabletIndex}
|
114
|
+
size={this.props.size}
|
115
|
+
className={b('tablet')}
|
116
|
+
/>
|
117
|
+
);
|
118
|
+
};
|
119
|
+
|
120
|
+
updateFilteredTablets = () => {
|
121
|
+
const {stateFilter, typeFilter} = this.props;
|
122
|
+
const {tablets} = this.props;
|
123
|
+
|
124
|
+
let filteredTablets = tablets;
|
125
|
+
|
126
|
+
if (typeFilter.length > 0) {
|
127
|
+
filteredTablets = filteredTablets.filter((tblt) =>
|
128
|
+
typeFilter.some((filter) => tblt.Type === filter),
|
129
|
+
);
|
130
|
+
}
|
131
|
+
if (stateFilter.length > 0) {
|
132
|
+
filteredTablets = filteredTablets.filter((tblt) =>
|
133
|
+
stateFilter.some((filter) => tblt.State === filter),
|
134
|
+
);
|
135
|
+
}
|
136
|
+
this.setState({filteredTablets});
|
137
|
+
};
|
138
|
+
|
139
|
+
renderOverall = (tablets) => {
|
140
|
+
const {hideTooltip, showTooltip} = this.props;
|
141
|
+
const tabletsCount = tablets.length;
|
142
|
+
|
143
|
+
const substractPercentsFromMaxPercents = (statesForOverallProgress, substractValue) => {
|
144
|
+
Object.keys(statesForOverallProgress).some((key) => {
|
145
|
+
if (statesForOverallProgress[key] > 10) {
|
146
|
+
statesForOverallProgress[key] -= minOverallPercentValue - substractValue;
|
147
|
+
return true;
|
148
|
+
}
|
149
|
+
return false;
|
150
|
+
});
|
151
|
+
};
|
152
|
+
|
153
|
+
// определим, сколько таблеток какого цвета имеется в tablets
|
154
|
+
const statesForOverallProgress = tablets.reduce((acc, tablet) => {
|
155
|
+
const color = tablet.Overall.toLowerCase();
|
156
|
+
if (!acc[color]) {
|
157
|
+
acc[color] = 1;
|
158
|
+
} else {
|
159
|
+
acc[color]++;
|
160
|
+
}
|
161
|
+
|
162
|
+
return acc;
|
163
|
+
}, {});
|
164
|
+
|
165
|
+
const tooltipData = [];
|
166
|
+
|
167
|
+
// подсчитаем, сколько процентов составляет каждый цвет в statesForOverallProgress и заодно сгенерируем информацию для тултипа
|
168
|
+
Object.keys(statesForOverallProgress).forEach((key) => {
|
169
|
+
const percents = (statesForOverallProgress[key] / tabletsCount) * 100;
|
170
|
+
const value = statesForOverallProgress[key];
|
171
|
+
statesForOverallProgress[key] = percents;
|
172
|
+
tooltipData.push({color: key, percents, value, total: tablets.length});
|
173
|
+
});
|
174
|
+
|
175
|
+
// заменим все проценты, значения которых меньше 3 на тройку
|
176
|
+
Object.keys(statesForOverallProgress).forEach((key) => {
|
177
|
+
if (statesForOverallProgress[key] < minOverallPercentValue) {
|
178
|
+
substractPercentsFromMaxPercents(
|
179
|
+
statesForOverallProgress,
|
180
|
+
statesForOverallProgress[key],
|
181
|
+
);
|
182
|
+
statesForOverallProgress[key] = minOverallPercentValue;
|
183
|
+
}
|
184
|
+
});
|
185
|
+
|
186
|
+
const memoryProgress = 100;
|
187
|
+
const stack = Object.keys(statesForOverallProgress).map((key) => ({
|
188
|
+
color: `var(--color-status-${key}-solid-70)`,
|
189
|
+
colorKey: key,
|
190
|
+
value: statesForOverallProgress[key],
|
191
|
+
}));
|
192
|
+
|
193
|
+
// сортируем наш stack, чтобы цвета были в порядке "зеленый, оранжевый, желтый, красный, черный"
|
194
|
+
stack.sort((a, b) => COLORS_PRIORITY[b.colorKey] - COLORS_PRIORITY[a.colorKey]);
|
195
|
+
|
196
|
+
return (
|
197
|
+
<div className={b('row', {overall: true})}>
|
198
|
+
<span className={b('label', {overall: true})}>Overall</span>
|
199
|
+
<div
|
200
|
+
onMouseLeave={hideTooltip}
|
201
|
+
onMouseEnter={(e) => showTooltip(e.target, tooltipData, 'tabletsOverall')}
|
202
|
+
>
|
203
|
+
<Progress value={memoryProgress} stack={stack} />
|
204
|
+
</div>
|
205
|
+
</div>
|
206
|
+
);
|
207
|
+
};
|
208
|
+
|
209
|
+
renderContent = (tablets) => {
|
210
|
+
const states = Array.from(new Set(...[tablets.map((tblt) => tblt.State)])).map((item) => ({
|
211
|
+
value: item,
|
212
|
+
content: item,
|
213
|
+
}));
|
214
|
+
const types = Array.from(new Set(...[tablets.map((tblt) => tblt.Type)])).map((item) => ({
|
215
|
+
value: item,
|
216
|
+
content: item,
|
217
|
+
}));
|
218
|
+
const {filteredTablets} = this.state;
|
219
|
+
const {stateFilter, typeFilter} = this.props;
|
220
|
+
|
221
|
+
return (
|
222
|
+
<div className={b()}>
|
223
|
+
{this.renderOverall(tablets)}
|
224
|
+
|
225
|
+
<div className={b('filters')}>
|
226
|
+
<Select
|
227
|
+
className={b('filter-control')}
|
228
|
+
multiple
|
229
|
+
placeholder="All"
|
230
|
+
label="States:"
|
231
|
+
options={states}
|
232
|
+
value={stateFilter}
|
233
|
+
onUpdate={this.handleStateFilterChange}
|
234
|
+
width="100%"
|
235
|
+
/>
|
236
|
+
<Select
|
237
|
+
className={b('filter-control')}
|
238
|
+
multiple
|
239
|
+
placeholder="All"
|
240
|
+
label="Types:"
|
241
|
+
options={types}
|
242
|
+
value={typeFilter}
|
243
|
+
onUpdate={this.handleTypeFilterChange}
|
244
|
+
width="100%"
|
245
|
+
/>
|
246
|
+
</div>
|
247
|
+
|
248
|
+
<div className={b('items')}>
|
249
|
+
<ReactList
|
250
|
+
itemRenderer={this.renderTablet}
|
251
|
+
length={filteredTablets.length}
|
252
|
+
type="uniform"
|
253
|
+
/>
|
254
|
+
</div>
|
255
|
+
</div>
|
256
|
+
);
|
257
|
+
};
|
258
|
+
|
259
|
+
render() {
|
260
|
+
const {loading, wasLoaded, error, tablets} = this.props;
|
261
|
+
if (loading && !wasLoaded) {
|
262
|
+
return Tablets.renderLoader();
|
263
|
+
} else if (error) {
|
264
|
+
return <div>{error.statusText}</div>;
|
265
|
+
} else {
|
266
|
+
return tablets.length > 0 ? (
|
267
|
+
this.renderContent(tablets)
|
268
|
+
) : (
|
269
|
+
<div className="error">no tablets data</div>
|
270
|
+
);
|
271
|
+
}
|
272
|
+
}
|
273
|
+
}
|
274
|
+
|
275
|
+
const mapStateToProps = (state) => {
|
276
|
+
const {
|
277
|
+
data = {},
|
278
|
+
wasLoaded,
|
279
|
+
loading,
|
280
|
+
timeoutForRequest,
|
281
|
+
stateFilter,
|
282
|
+
typeFilter,
|
283
|
+
} = state.tablets;
|
284
|
+
const {autorefresh} = state.schema;
|
285
|
+
const {TabletStateInfo: tablets = []} = data;
|
286
|
+
return {
|
287
|
+
tablets,
|
288
|
+
timeoutForRequest,
|
289
|
+
wasLoaded,
|
290
|
+
loading,
|
291
|
+
stateFilter,
|
292
|
+
typeFilter,
|
293
|
+
autorefresh,
|
294
|
+
};
|
295
|
+
};
|
296
|
+
|
297
|
+
const mapDispatchToProps = {
|
298
|
+
getTabletsInfo,
|
299
|
+
hideTooltip,
|
300
|
+
showTooltip,
|
301
|
+
clearWasLoadingFlag,
|
302
|
+
setStateFilter,
|
303
|
+
setTypeFilter,
|
304
|
+
};
|
305
|
+
|
306
|
+
export default connect(mapStateToProps, mapDispatchToProps)(Tablets);
|
@@ -0,0 +1,77 @@
|
|
1
|
+
@import '../../styles/mixins';
|
2
|
+
|
3
|
+
.tablets {
|
4
|
+
@include flex-container();
|
5
|
+
|
6
|
+
&__row {
|
7
|
+
display: flex;
|
8
|
+
align-items: center;
|
9
|
+
|
10
|
+
&_overall {
|
11
|
+
margin: 15px 20px;
|
12
|
+
|
13
|
+
.yc-progress {
|
14
|
+
width: 300px;
|
15
|
+
margin: 0;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
&__label {
|
21
|
+
font-size: var(--yc-text-body2-font-size);
|
22
|
+
line-height: var(--yc-text-body2-line-height);
|
23
|
+
font-weight: 500;
|
24
|
+
text-transform: uppercase;
|
25
|
+
margin-right: 16px;
|
26
|
+
|
27
|
+
&_overall {
|
28
|
+
margin-right: 15px;
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
&__items {
|
33
|
+
display: flex;
|
34
|
+
flex-wrap: wrap;
|
35
|
+
flex: 1 1 auto;
|
36
|
+
padding: 0 20px;
|
37
|
+
}
|
38
|
+
|
39
|
+
&__items-wrapper {
|
40
|
+
overflow: auto;
|
41
|
+
}
|
42
|
+
|
43
|
+
&__filters {
|
44
|
+
display: flex;
|
45
|
+
align-items: center;
|
46
|
+
margin: 10px 0;
|
47
|
+
padding: 0 20px;
|
48
|
+
}
|
49
|
+
|
50
|
+
&__filter-control {
|
51
|
+
margin-right: 10px;
|
52
|
+
min-width: 100px;
|
53
|
+
width: 200px;
|
54
|
+
max-width: 200px;
|
55
|
+
|
56
|
+
&:last-child {
|
57
|
+
margin-right: 0;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
&__tablet {
|
62
|
+
margin-bottom: 2px;
|
63
|
+
}
|
64
|
+
|
65
|
+
.tablet {
|
66
|
+
display: inline-block;
|
67
|
+
text-align: center;
|
68
|
+
line-height: 18px;
|
69
|
+
}
|
70
|
+
|
71
|
+
&__loader-wrapper {
|
72
|
+
display: flex;
|
73
|
+
justify-content: center;
|
74
|
+
align-items: center;
|
75
|
+
height: 100%;
|
76
|
+
}
|
77
|
+
}
|