ydb-embedded-ui 4.29.0 → 4.31.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. package/README.md +2 -1
  2. package/dist/components/ClipboardButton/ClipboardButton.tsx +52 -0
  3. package/dist/components/ClipboardButton/index.ts +1 -0
  4. package/dist/components/EntityStatus/EntityStatus.js +9 -12
  5. package/dist/components/EntityStatus/EntityStatus.scss +2 -13
  6. package/dist/components/MetricChart/MetricChart.scss +34 -0
  7. package/dist/components/MetricChart/MetricChart.tsx +198 -0
  8. package/dist/components/MetricChart/convertReponse.ts +32 -0
  9. package/dist/components/MetricChart/getChartData.ts +20 -0
  10. package/dist/components/MetricChart/getDefaultDataFormatter.ts +36 -0
  11. package/dist/components/MetricChart/index.ts +2 -0
  12. package/dist/components/MetricChart/reducer.ts +86 -0
  13. package/dist/components/MetricChart/types.ts +32 -0
  14. package/dist/components/TimeFrameSelector/TimeFrameSelector.scss +5 -0
  15. package/dist/components/TimeFrameSelector/TimeFrameSelector.tsx +33 -0
  16. package/dist/containers/App/App.scss +9 -9
  17. package/dist/containers/App/Content.js +16 -12
  18. package/dist/containers/Tenant/Diagnostics/TenantOverview/DefaultDashboard.tsx +50 -0
  19. package/dist/containers/Tenant/Diagnostics/TenantOverview/MetricsCards/MetricsCards.tsx +13 -4
  20. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/CpuDashboard.tsx +18 -0
  21. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantCpu/TenantCpu.tsx +2 -0
  22. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantDashboard/TenantDashboard.scss +14 -0
  23. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantDashboard/TenantDashboard.tsx +71 -0
  24. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/MemoryDashboard.tsx +21 -0
  25. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantMemory/TenantMemory.tsx +7 -1
  26. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.tsx +2 -1
  27. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/StorageDashboard.tsx +21 -0
  28. package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantStorage/TenantStorage.tsx +2 -0
  29. package/dist/containers/Tenant/Diagnostics/TenantOverview/i18n/en.json +7 -1
  30. package/dist/containers/Tenant/Diagnostics/TenantOverview/i18n/ru.json +7 -1
  31. package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +24 -30
  32. package/dist/containers/Tenant/Query/ExecuteResult/ExecuteResult.tsx +10 -16
  33. package/dist/containers/UserSettings/i18n/en.json +4 -1
  34. package/dist/containers/UserSettings/i18n/ru.json +4 -1
  35. package/dist/containers/UserSettings/settings.ts +12 -1
  36. package/dist/containers/Versions/NodesTreeTitle/NodesTreeTitle.scss +15 -0
  37. package/dist/containers/Versions/NodesTreeTitle/NodesTreeTitle.tsx +9 -6
  38. package/dist/services/api.ts +18 -0
  39. package/dist/services/settings.ts +2 -0
  40. package/dist/store/reducers/tenant/tenant.ts +6 -1
  41. package/dist/types/api/render.ts +34 -0
  42. package/dist/utils/cn.ts +3 -0
  43. package/dist/utils/constants.ts +2 -0
  44. package/dist/utils/timeParsers/formatDuration.ts +10 -0
  45. package/dist/utils/timeframes.ts +10 -0
  46. package/dist/utils/versions/getVersionsColors.ts +1 -0
  47. package/package.json +4 -2
  48. package/CHANGELOG.md +0 -1552
  49. package/dist/components/CopyToClipboard/CopyToClipboard.tsx +0 -38
@@ -28,6 +28,7 @@ import type {DescribeTopicResult} from '../types/api/topic';
28
28
  import type {TEvPDiskStateResponse} from '../types/api/pdisk';
29
29
  import type {TEvVDiskStateResponse} from '../types/api/vdisk';
30
30
  import type {TUserToken} from '../types/api/whoami';
31
+ import type {JsonRenderRequestParams, JsonRenderResponse} from '../types/api/render';
31
32
  import type {QuerySyntax} from '../types/store/query';
32
33
  import type {ComputeApiRequestParams, NodesApiRequestParams} from '../store/reducers/nodes/types';
33
34
  import type {StorageApiRequestParams} from '../store/reducers/storage/types';
@@ -377,7 +378,24 @@ export class YdbEmbeddedAPI extends AxiosWrapper {
377
378
  path_id: tenantId?.PathId,
378
379
  });
379
380
  }
381
+ getChartData(
382
+ {target, from, until, maxDataPoints}: JsonRenderRequestParams,
383
+ {concurrentId}: AxiosOptions = {},
384
+ ) {
385
+ const requestString = `${target}&from=${from}&until=${until}&maxDataPoints=${maxDataPoints}&format=json`;
380
386
 
387
+ return this.post<JsonRenderResponse>(
388
+ this.getPath('/viewer/json/render'),
389
+ requestString,
390
+ {},
391
+ {
392
+ concurrentId,
393
+ headers: {
394
+ 'Content-Type': 'application/x-www-form-urlencoded',
395
+ },
396
+ },
397
+ );
398
+ }
381
399
  /** @deprecated use localStorage instead */
382
400
  postSetting(settingsApi: string, name: string, value: string) {
383
401
  return this.request({
@@ -3,6 +3,7 @@ import {TENANT_PAGES_IDS} from '../store/reducers/tenant/constants';
3
3
  import {
4
4
  ASIDE_HEADER_COMPACT_KEY,
5
5
  CLUSTER_INFO_HIDDEN_KEY,
6
+ DISPLAY_CHARTS_IN_DB_DIAGNOSTICS_KEY,
6
7
  INVERTED_DISKS_KEY,
7
8
  LANGUAGE_KEY,
8
9
  LAST_USED_QUERY_ACTION_KEY,
@@ -37,6 +38,7 @@ export const DEFAULT_USER_SETTINGS: SettingsObject = {
37
38
  [PARTITIONS_HIDDEN_COLUMNS_KEY]: [],
38
39
  [CLUSTER_INFO_HIDDEN_KEY]: true,
39
40
  [USE_BACKEND_PARAMS_FOR_TABLES_KEY]: false,
41
+ [DISPLAY_CHARTS_IN_DB_DIAGNOSTICS_KEY]: false,
40
42
  };
41
43
 
42
44
  class SettingsManager {
@@ -24,7 +24,12 @@ const SET_METRICS_TAB = 'tenant/SET_METRICS_TAB';
24
24
  const CLEAR_TENANT = 'tenant/CLEAR_TENANT';
25
25
  const SET_DATA_WAS_NOT_LOADED = 'tenant/SET_DATA_WAS_NOT_LOADED';
26
26
 
27
- const initialState = {loading: false, wasLoaded: false};
27
+ // Tenant diagnostics tab content was requested twice,
28
+ // because requests were sent before state was set as loading and after tenant data is fully loaded
29
+ // So tenant data is considered loading from the start, there is no attempt to load tab content
30
+ // TODO: try fix with 'display: none' for tenant diagnostics tab content while tenant data loading,
31
+ // but with parallel (not sequent) data requests
32
+ const initialState = {loading: true, wasLoaded: false};
28
33
 
29
34
  const tenantReducer: Reducer<TenantState, TenantAction> = (state = initialState, action) => {
30
35
  switch (action.type) {
@@ -0,0 +1,34 @@
1
+ /**
2
+ * endpoint: /viewer/json/render
3
+ *
4
+ * source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/viewer/json_render.h
5
+ */
6
+
7
+ export type JsonRenderResponse =
8
+ | {
9
+ error?: string;
10
+ status?: string;
11
+ }
12
+ | MetricData[];
13
+
14
+ export interface MetricData {
15
+ datapoints: MetricDatapoint[];
16
+ target: string;
17
+ title: string;
18
+ tags: MetricTags;
19
+ }
20
+
21
+ interface MetricTags {
22
+ name: string;
23
+ }
24
+
25
+ /** [metric value - null or double, timestamp - seconds] */
26
+ export type MetricDatapoint = [null | number, number];
27
+
28
+ export interface JsonRenderRequestParams {
29
+ /** metrics names in format "target=queries.latencies.p50&target=queries.latencies.p75&target=queries.latencies.p90" */
30
+ target: string;
31
+ from: number;
32
+ until: number;
33
+ maxDataPoints: number;
34
+ }
@@ -0,0 +1,3 @@
1
+ import cn from 'bem-cn-lite';
2
+
3
+ export {cn};
@@ -125,3 +125,5 @@ export const USE_BACKEND_PARAMS_FOR_TABLES_KEY = 'useBackendParamsForTables';
125
125
 
126
126
  // Enable schema that supports multiple resultsets
127
127
  export const QUERY_USE_MULTI_SCHEMA_KEY = 'queryUseMultiSchema';
128
+
129
+ export const DISPLAY_CHARTS_IN_DB_DIAGNOSTICS_KEY = 'displayChartsInDbDiagnostics';
@@ -1,4 +1,5 @@
1
1
  import {DAY_IN_SECONDS, HOUR_IN_SECONDS} from '../constants';
2
+ import {formatNumber} from '../dataFormatters/dataFormatters';
2
3
 
3
4
  import i18n from './i18n';
4
5
 
@@ -6,6 +7,8 @@ import i18n from './i18n';
6
7
  * Process time difference in ms and returns formated time.
7
8
  * By default only two major values are returned (days & hours, hours & minutes, minutes & seconds, etc.).
8
9
  * It can be altered with valuesCount arg
10
+ *
11
+ * value - duration in ms
9
12
  */
10
13
  export const formatDurationToShortTimeFormat = (value: number, valuesCount: 1 | 2 = 2) => {
11
14
  const ms = value % 1000;
@@ -62,3 +65,10 @@ export const formatDurationToShortTimeFormat = (value: number, valuesCount: 1 |
62
65
 
63
66
  return i18n('ms', duration);
64
67
  };
68
+
69
+ /**
70
+ * Parse ms duration to string
71
+ */
72
+ export const formatToMs = (value: number) => {
73
+ return i18n('ms', {ms: formatNumber(value)});
74
+ };
@@ -0,0 +1,10 @@
1
+ import {DAY_IN_SECONDS, HOUR_IN_SECONDS, MINUTE_IN_SECONDS} from './constants';
2
+
3
+ export const TIMEFRAMES = {
4
+ '30m': 30 * MINUTE_IN_SECONDS,
5
+ '1h': HOUR_IN_SECONDS,
6
+ '1d': DAY_IN_SECONDS,
7
+ '1w': 7 * DAY_IN_SECONDS,
8
+ } as const;
9
+
10
+ export type TimeFrame = keyof typeof TIMEFRAMES;
@@ -9,6 +9,7 @@ export const hashCode = (s: string) => {
9
9
  }, 0);
10
10
  };
11
11
 
12
+ // TODO: colors used in charts as well, need to move to constants
12
13
  // 11 distinct colors from https://mokole.com/palette.html
13
14
  export const COLORS = [
14
15
  '#008000', // green
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-embedded-ui",
3
- "version": "4.29.0",
3
+ "version": "4.31.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -10,6 +10,7 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@gravity-ui/axios-wrapper": "^1.3.0",
13
+ "@gravity-ui/chartkit": "^4.15.0",
13
14
  "@gravity-ui/components": "^2.9.1",
14
15
  "@gravity-ui/date-utils": "^1.1.1",
15
16
  "@gravity-ui/i18n": "^1.0.0",
@@ -45,8 +46,9 @@
45
46
  "reselect": "4.1.6",
46
47
  "sass": "1.32.8",
47
48
  "url": "^0.11.0",
49
+ "use-query-params": "^2.2.1",
48
50
  "web-vitals": "1.1.2",
49
- "ydb-ui-components": "^3.5.0"
51
+ "ydb-ui-components": "^3.6.0"
50
52
  },
51
53
  "scripts": {
52
54
  "start": "react-app-rewired start",