@cloudtower/eagle 0.33.4 → 0.33.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/__test__/mockLineChart.d.ts +4 -0
  2. package/dist/cjs/core/Button/index.js +1 -2
  3. package/dist/cjs/core/ConfigProvider/index.js +6 -6
  4. package/dist/cjs/core/Legend/index.js +128 -0
  5. package/dist/cjs/core/LineChart/LineChartActions.js +52 -0
  6. package/dist/cjs/core/LineChart/LineChartLegend.js +101 -0
  7. package/dist/cjs/core/LineChart/LineChartToolBar.js +56 -0
  8. package/dist/cjs/core/LineChart/Pointer.js +45 -0
  9. package/dist/cjs/core/LineChart/RenderChart.js +304 -0
  10. package/dist/cjs/core/LineChart/TooltipFormatter.js +70 -0
  11. package/dist/cjs/core/LineChart/index.js +66 -0
  12. package/dist/cjs/core/LineChart/styled.js +35 -0
  13. package/dist/cjs/core/LineChart/type.js +30 -0
  14. package/dist/cjs/core/LineChart/utils.js +394 -0
  15. package/dist/cjs/core/Loading/index.js +2 -2
  16. package/dist/cjs/core/Progress/progress.widgets.js +1 -1
  17. package/dist/cjs/core/Second/index.js +12 -4
  18. package/dist/cjs/core/Timeline/Timeline.widget.js +4 -4
  19. package/dist/cjs/core/Timeline/index.js +4 -4
  20. package/dist/cjs/core/index.js +9 -9
  21. package/dist/cjs/coreX/CheckPointList/index.js +7 -6
  22. package/dist/cjs/coreX/CircleLoading/index.js +4 -4
  23. package/dist/cjs/coreX/DateRangePicker/Calendar.js +1 -1
  24. package/dist/cjs/coreX/Dialogs/DeleteDialog/DeleteDialog.js +47 -0
  25. package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.js +87 -0
  26. package/dist/cjs/coreX/Dialogs/RejectDialog/RejectDialog.type.js +11 -0
  27. package/dist/cjs/coreX/Dialogs/SmallDialog.js +86 -0
  28. package/dist/cjs/index.js +231 -190
  29. package/dist/cjs/stats1.html +1 -1
  30. package/dist/cjs/utils/constants.js +1 -1
  31. package/dist/cjs/utils/tower.js +81 -0
  32. package/dist/components.css +4910 -4495
  33. package/dist/esm/core/Button/index.js +1 -2
  34. package/dist/esm/core/ConfigProvider/index.js +4 -4
  35. package/dist/esm/core/Legend/index.js +117 -0
  36. package/dist/esm/core/LineChart/LineChartActions.js +46 -0
  37. package/dist/esm/core/LineChart/LineChartLegend.js +91 -0
  38. package/dist/esm/core/LineChart/LineChartToolBar.js +50 -0
  39. package/dist/esm/core/LineChart/Pointer.js +38 -0
  40. package/dist/esm/core/LineChart/RenderChart.js +296 -0
  41. package/dist/esm/core/LineChart/TooltipFormatter.js +63 -0
  42. package/dist/esm/core/LineChart/index.js +57 -0
  43. package/dist/esm/core/LineChart/styled.js +25 -0
  44. package/dist/esm/core/LineChart/type.js +26 -0
  45. package/dist/esm/core/LineChart/utils.js +369 -0
  46. package/dist/esm/core/Loading/index.js +1 -1
  47. package/dist/esm/core/Progress/progress.widgets.js +1 -1
  48. package/dist/esm/core/Second/index.js +11 -3
  49. package/dist/esm/core/Timeline/Timeline.widget.js +3 -3
  50. package/dist/esm/core/Timeline/index.js +3 -3
  51. package/dist/esm/coreX/CheckPointList/index.js +7 -6
  52. package/dist/esm/coreX/CircleLoading/index.js +3 -3
  53. package/dist/esm/coreX/DateRangePicker/Calendar.js +1 -1
  54. package/dist/esm/coreX/Dialogs/DeleteDialog/DeleteDialog.js +41 -0
  55. package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.js +81 -0
  56. package/dist/esm/coreX/Dialogs/RejectDialog/RejectDialog.type.js +9 -0
  57. package/dist/esm/coreX/Dialogs/SmallDialog.js +80 -0
  58. package/dist/esm/index.js +11 -2
  59. package/dist/esm/stats1.html +1 -1
  60. package/dist/esm/utils/constants.js +1 -1
  61. package/dist/esm/utils/tower.js +77 -1
  62. package/dist/linaria.merged.scss +7528 -0
  63. package/dist/src/antd.d.ts +1 -1
  64. package/dist/src/core/ConfigProvider/index.d.ts +2 -2
  65. package/dist/src/core/Legend/index.d.ts +1 -1
  66. package/dist/src/core/LineChart/LineChartActions.d.ts +7 -0
  67. package/dist/src/core/LineChart/LineChartLegend.d.ts +18 -0
  68. package/dist/src/core/LineChart/LineChartToolBar.d.ts +20 -0
  69. package/dist/src/core/LineChart/Pointer.d.ts +6 -0
  70. package/dist/src/core/LineChart/RenderChart.d.ts +45 -0
  71. package/dist/src/core/LineChart/TooltipFormatter.d.ts +10 -0
  72. package/dist/src/core/LineChart/__test__/h5_css.test.d.ts +1 -0
  73. package/dist/src/core/LineChart/index.d.ts +8 -0
  74. package/dist/src/core/LineChart/styled.d.ts +12 -0
  75. package/dist/src/core/LineChart/type.d.ts +191 -0
  76. package/dist/src/core/LineChart/utils.d.ts +56 -0
  77. package/dist/src/core/Metric/metric.d.ts +1 -1
  78. package/dist/src/core/Timeline/Timeline.type.d.ts +2 -2
  79. package/dist/src/core/Units/units.type.d.ts +66 -0
  80. package/dist/src/core/index.d.ts +6 -1
  81. package/dist/src/coreX/CheckPointList/checkpointlist.type.d.ts +4 -1
  82. package/dist/src/coreX/CheckPointList/index.d.ts +1 -1
  83. package/dist/src/coreX/Dialogs/DeleteDialog/DeleteDialog.d.ts +3 -0
  84. package/dist/src/coreX/Dialogs/DeleteDialog/DeleteDialog.type.d.ts +19 -0
  85. package/dist/src/coreX/Dialogs/DeleteDialog/index.d.ts +2 -0
  86. package/dist/src/coreX/Dialogs/RejectDialog/RejectDialog.d.ts +3 -0
  87. package/dist/src/coreX/Dialogs/RejectDialog/RejectDialog.type.d.ts +59 -0
  88. package/dist/src/coreX/Dialogs/RejectDialog/index.d.ts +2 -0
  89. package/dist/src/coreX/Dialogs/SmallDialog.d.ts +31 -0
  90. package/dist/src/coreX/Dialogs/index.d.ts +3 -0
  91. package/dist/src/coreX/index.d.ts +2 -1
  92. package/dist/src/utils/tower.d.ts +12 -0
  93. package/dist/stories/docs/core/LineChart.stories.d.ts +16 -0
  94. package/dist/stories/docs/core/Second.stories.d.ts +57 -22
  95. package/dist/stories/docs/core/Table.stories.d.ts +6 -0
  96. package/dist/stories/docs/core/Timeline.stories.d.ts +2 -2
  97. package/dist/stories/docs/coreX/CheckPointList.stories.d.ts +11 -1
  98. package/dist/stories/docs/coreX/Dialogs/DeleteDialog.stories.d.ts +37 -0
  99. package/dist/stories/docs/coreX/Dialogs/RejectDialog.stories.d.ts +89 -0
  100. package/dist/stories/docs/coreX/Show.stories.d.ts +2 -2
  101. package/dist/style.css +4969 -4605
  102. package/dist/variables.scss +2 -0
  103. package/package.json +6 -7
@@ -0,0 +1,63 @@
1
+ import { styled } from '@linaria/react';
2
+ import { LineChartColorBlock } from './LineChartLegend.js';
3
+ import { TooltipWrapper, TooltipColumn } from './styled.js';
4
+ import dayjs from 'dayjs';
5
+ import React__default from 'react';
6
+ import { Typo } from '../Typo/index.js';
7
+
8
+ var __defProp = Object.defineProperty;
9
+ var __defProps = Object.defineProperties;
10
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
11
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
12
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
13
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
14
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true,
18
+ value
19
+ }) : obj[key] = value;
20
+ var __spreadValues = (a, b) => {
21
+ for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
22
+ if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) {
23
+ if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
24
+ }
25
+ return a;
26
+ };
27
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ const TooltipTitle = /*#__PURE__*/styled('div')({
29
+ name: "TooltipTitle",
30
+ class: "E_t1616y1o",
31
+ propsAsIs: false
32
+ });
33
+ const TooltipFormatter = props => {
34
+ const {
35
+ active,
36
+ payload,
37
+ deselected,
38
+ legends,
39
+ format
40
+ } = props;
41
+ if (!active || !(payload == null ? void 0 : payload.length)) {
42
+ return null;
43
+ }
44
+ return /* @__PURE__ */React__default.createElement(TooltipWrapper, null, /* @__PURE__ */React__default.createElement(TooltipTitle, {
45
+ className: Typo.Label.l4_bold_title
46
+ }, dayjs(Number(payload[0].payload.t)).format("MM/DD HH:mm:ss")), payload.map((item, index) => {
47
+ return __spreadProps(__spreadValues({}, item), {
48
+ legend: legends[index]
49
+ });
50
+ }).sort((a, b) => b.value - a.value).map(item => {
51
+ return deselected.includes(item.legend.id) ? null : /* @__PURE__ */React__default.createElement(TooltipColumn, {
52
+ key: item.legend.id
53
+ }, /* @__PURE__ */React__default.createElement("div", null, /* @__PURE__ */React__default.createElement(LineChartColorBlock, {
54
+ background: item.legend.color,
55
+ borderd: true
56
+ }), item.legend.name), /* @__PURE__ */React__default.createElement("div", {
57
+ className: "column-value"
58
+ }, format(item)));
59
+ }));
60
+ };
61
+ var TooltipFormatter$1 = TooltipFormatter;
62
+
63
+ export { TooltipFormatter$1 as default };
@@ -0,0 +1,57 @@
1
+ import { parrotI18n } from '@cloudtower/parrot';
2
+ import ErrorBoundary from '../ErrorBoundary/index.js';
3
+ import Pointer from './Pointer.js';
4
+ import RenderChart from './RenderChart.js';
5
+ import { LineChartWrapper } from './styled.js';
6
+ import cs from 'classnames';
7
+ import React__default, { useState, useRef, useEffect } from 'react';
8
+
9
+ var __defProp = Object.defineProperty;
10
+ var __defProps = Object.defineProperties;
11
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
12
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
15
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
16
+ var __spreadValues = (a, b) => {
17
+ for (var prop in b || (b = {}))
18
+ if (__hasOwnProp.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ if (__getOwnPropSymbols)
21
+ for (var prop of __getOwnPropSymbols(b)) {
22
+ if (__propIsEnum.call(b, prop))
23
+ __defNormalProp(a, prop, b[prop]);
24
+ }
25
+ return a;
26
+ };
27
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
28
+ const LineChart = React__default.forwardRef(
29
+ (props, ref) => {
30
+ const {
31
+ height = 154,
32
+ showPointer = true,
33
+ showLegend = true,
34
+ showXaxis = false,
35
+ chartProps
36
+ } = props;
37
+ const [width, setWidth] = useState(0);
38
+ const wrapperRef = useRef(null);
39
+ useEffect(() => {
40
+ var _a;
41
+ setWidth(((_a = wrapperRef.current) == null ? void 0 : _a.offsetWidth) || 0);
42
+ }, []);
43
+ return /* @__PURE__ */ React__default.createElement(ErrorBoundary, { i18n: parrotI18n }, /* @__PURE__ */ React__default.createElement(
44
+ LineChartWrapper,
45
+ {
46
+ className: cs("metric-wrapper", !showXaxis && "hidden-xaxis"),
47
+ ref: wrapperRef,
48
+ style: { height: showLegend ? height + 30 : height }
49
+ },
50
+ /* @__PURE__ */ React__default.createElement(RenderChart, __spreadProps(__spreadValues({}, chartProps), { width })),
51
+ showPointer && /* @__PURE__ */ React__default.createElement(Pointer, { uuid: chartProps.syncId, metricWidth: width })
52
+ ));
53
+ }
54
+ );
55
+ var LineChart$1 = LineChart;
56
+
57
+ export { LineChart$1 as default };
@@ -0,0 +1,25 @@
1
+ import { styled } from '@linaria/react';
2
+
3
+ const MetricLegendTabStyle = "E_mn7joto";
4
+ const LegendStyle = "E_l1bifhon";
5
+ const LegendItemsStyle = "E_ltthzck";
6
+ const LegendItemsStyleDropdown = "E_l1mumj7o";
7
+ const ExtraResource = "E_e45tc5l";
8
+ const LineChartWrapper = /*#__PURE__*/styled('div')({
9
+ name: "LineChartWrapper",
10
+ class: "E_lqeaosa",
11
+ propsAsIs: false
12
+ });
13
+ const TooltipWrapper = /*#__PURE__*/styled('div')({
14
+ name: "TooltipWrapper",
15
+ class: "E_t2pr38p",
16
+ propsAsIs: false
17
+ });
18
+ const TooltipColumn = /*#__PURE__*/styled('div')({
19
+ name: "TooltipColumn",
20
+ class: "E_tecdsj7",
21
+ propsAsIs: false
22
+ });
23
+ const LineChartColorBlockStyle = "E_ljhvvia";
24
+
25
+ export { ExtraResource, LegendItemsStyle, LegendItemsStyleDropdown, LegendStyle, LineChartColorBlockStyle, LineChartWrapper, MetricLegendTabStyle, TooltipColumn, TooltipWrapper };
@@ -0,0 +1,26 @@
1
+ var ILineChartTimeUnit = /* @__PURE__ */ ((ILineChartTimeUnit2) => {
2
+ ILineChartTimeUnit2["Day"] = "DAY";
3
+ ILineChartTimeUnit2["Hour"] = "HOUR";
4
+ ILineChartTimeUnit2["Month"] = "MONTH";
5
+ return ILineChartTimeUnit2;
6
+ })(ILineChartTimeUnit || {});
7
+ var ILineChartMetricUnit = /* @__PURE__ */ ((ILineChartMetricUnit2) => {
8
+ ILineChartMetricUnit2["Count"] = "COUNT";
9
+ ILineChartMetricUnit2["DataRateBit"] = "DATA_RATE_BIT";
10
+ ILineChartMetricUnit2["DataRateByte"] = "DATA_RATE_BYTE";
11
+ ILineChartMetricUnit2["DataSize"] = "DATA_SIZE";
12
+ ILineChartMetricUnit2["Frequency"] = "FREQUENCY";
13
+ ILineChartMetricUnit2["Load"] = "LOAD";
14
+ ILineChartMetricUnit2["Percent"] = "PERCENT";
15
+ ILineChartMetricUnit2["Ratio"] = "RATIO";
16
+ ILineChartMetricUnit2["Temperature"] = "TEMPERATURE";
17
+ ILineChartMetricUnit2["Time"] = "TIME";
18
+ return ILineChartMetricUnit2;
19
+ })(ILineChartMetricUnit || {});
20
+ var ILineChartGraphType = /* @__PURE__ */ ((ILineChartGraphType2) => {
21
+ ILineChartGraphType2["Area"] = "AREA";
22
+ ILineChartGraphType2["Stack"] = "STACK";
23
+ return ILineChartGraphType2;
24
+ })(ILineChartGraphType || {});
25
+
26
+ export { ILineChartGraphType, ILineChartMetricUnit, ILineChartTimeUnit };
@@ -0,0 +1,369 @@
1
+ import { ILineChartMetricUnit, ILineChartGraphType } from './type.js';
2
+ import { HOUR, DAY, SECOND, MINUTE, unitRules, formatPercent, formatCount, formatBytes, formatBps, formatBitPerSecond, formatNanoSecond, formatFrequency, formatTemperature } from '../../utils/tower.js';
3
+ import dayjs from 'dayjs';
4
+ import _ from 'lodash';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __defProps = Object.defineProperties;
8
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
+ var __spreadValues = (a, b) => {
14
+ for (var prop in b || (b = {}))
15
+ if (__hasOwnProp.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ if (__getOwnPropSymbols)
18
+ for (var prop of __getOwnPropSymbols(b)) {
19
+ if (__propIsEnum.call(b, prop))
20
+ __defNormalProp(a, prop, b[prop]);
21
+ }
22
+ return a;
23
+ };
24
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
37
+ function filterLineChartPointsByDateRange(points, dateRange) {
38
+ const [startDate, endDate] = dateRange != null ? dateRange : [dayjs(), dayjs()];
39
+ return points == null ? void 0 : points.filter((point) => {
40
+ const pointDate = dayjs(point.t);
41
+ if (startDate && pointDate.isBefore(startDate)) {
42
+ return false;
43
+ }
44
+ if (endDate && pointDate.isAfter(endDate)) {
45
+ return false;
46
+ }
47
+ return true;
48
+ });
49
+ }
50
+ const parseLineChartRange = (range) => {
51
+ const span = parseInt(range.slice(0, range.length - 1));
52
+ const unit = range.slice(range.length - 1);
53
+ return { span, unit };
54
+ };
55
+ function getRangeTimestamp(dateRange) {
56
+ const [startDate, endDate] = dateRange;
57
+ return endDate.valueOf() - startDate.valueOf();
58
+ }
59
+ const lineChartXaxisCal = (lastTime, dateRange, width) => {
60
+ const tangeTime = getRangeTimestamp(dateRange);
61
+ const baseline = lastTime || dateRange[1].valueOf();
62
+ if (width < 290) {
63
+ const tick = tangeTime / 4;
64
+ return [baseline - tick * 3, baseline - tick];
65
+ } else if (width < 380) {
66
+ const tick = tangeTime / 6;
67
+ return [baseline - tick * 5, baseline - tick * 3, baseline - tick];
68
+ } else {
69
+ const tick = tangeTime / 8;
70
+ return [
71
+ baseline - tick * 7,
72
+ baseline - tick * 5,
73
+ baseline - tick * 3,
74
+ baseline - tick
75
+ ];
76
+ }
77
+ };
78
+ const lineChartTickFormatter = (tick, dateRange) => {
79
+ const rangeTime = getLineChartRangeTimestamp(dateRange);
80
+ if (rangeTime <= 2 * HOUR * 1e3) {
81
+ return dayjs(tick).format("HH:mm:ss");
82
+ }
83
+ if (rangeTime <= 4 * DAY * 1e3) {
84
+ return dayjs(tick).format("MM/DD HH:mm:ss");
85
+ }
86
+ return dayjs(tick).format("MM/DD");
87
+ };
88
+ function getLineChartXAxisDomain(dateRange, xaxisLastTime) {
89
+ const [startDate, endDate] = dateRange;
90
+ return [startDate.valueOf(), xaxisLastTime != null ? xaxisLastTime : endDate.valueOf()];
91
+ }
92
+ const getLineChartRangeTimestamp = (dateRange) => {
93
+ const [startDate, endDate] = dateRange;
94
+ return endDate.valueOf() - startDate.valueOf();
95
+ };
96
+ const getLineChartStep = (dateRange) => {
97
+ const [startDate, endDate] = dateRange;
98
+ const range = endDate.valueOf() - startDate.valueOf();
99
+ if (range <= 2 * 60 * 60 * 1e3) {
100
+ return SECOND * 30 * 1e3;
101
+ }
102
+ if (range <= 24 * 60 * 60 * 1e3) {
103
+ return MINUTE * 5 * 1e3;
104
+ }
105
+ if (range <= 7 * 24 * 60 * 60 * 1e3) {
106
+ return MINUTE * 30 * 1e3;
107
+ }
108
+ if (range <= 30 * 24 * 60 * 60 * 1e3) {
109
+ return DAY * 1e3;
110
+ }
111
+ return DAY * 1e3;
112
+ };
113
+ const filterLineChartDataOverlapping = (data, startTimestamp, length, step, tolerance) => {
114
+ const points = [...new Array(Math.round(length))].map((_2, index) => {
115
+ return startTimestamp + index * step;
116
+ }).map((timestamp) => {
117
+ const closestPoint = _.minBy(
118
+ data.filter((value) => {
119
+ return Math.abs(value.t - timestamp) < tolerance;
120
+ }),
121
+ (value) => {
122
+ return Math.abs(value.t - timestamp);
123
+ }
124
+ );
125
+ if (closestPoint == null) {
126
+ return {
127
+ t: timestamp,
128
+ v: -Infinity
129
+ };
130
+ }
131
+ return closestPoint;
132
+ });
133
+ return points;
134
+ };
135
+ const convertLineChartDataStruct = (streams) => {
136
+ const points = streams.flatMap((points2, index) => {
137
+ return points2.map((point) => {
138
+ return __spreadProps(__spreadValues({}, point), { [`v${index}`]: point.v });
139
+ });
140
+ });
141
+ const groupedPoints = _.groupBy(points, (point) => {
142
+ return point.t;
143
+ });
144
+ const combinedPoints = Object.entries(groupedPoints).map(([key, values]) => {
145
+ return values.reduce((p, c) => {
146
+ const _a = __spreadValues(__spreadValues({}, p), c), values2 = __objRest(_a, ["v"]);
147
+ return values2;
148
+ }, {});
149
+ });
150
+ return combinedPoints;
151
+ };
152
+ const filterLineChartOverlappingMetric = (metric, dateRange) => {
153
+ const range = getLineChartRangeTimestamp(dateRange);
154
+ return __spreadProps(__spreadValues({}, metric), {
155
+ sample_streams: metric.sample_streams.map((stream) => __spreadProps(__spreadValues({}, stream), {
156
+ points: filterLineChartDataOverlapping(
157
+ stream.points,
158
+ dateRange[0].valueOf(),
159
+ range / stream.step,
160
+ stream.step,
161
+ stream.tolerance
162
+ )
163
+ }))
164
+ });
165
+ };
166
+ const deletePointsOutOfRange = (data, timeRange, now) => {
167
+ const first = now - getLineChartRangeTimestamp(timeRange);
168
+ return (data == null ? void 0 : data.filter((item) => {
169
+ return item.t >= first && item.t <= now;
170
+ })) || [];
171
+ };
172
+ const getFirstExpectedTimestamp = (data, timeRange, now, step, dateRange) => {
173
+ const first = timeRange ? now - getLineChartRangeTimestamp(timeRange) : dayjs(dateRange == null ? void 0 : dateRange[0]).valueOf();
174
+ const firstRealTimestamp = data[0].t;
175
+ return firstRealTimestamp - Math.floor((firstRealTimestamp - first) / step) * step;
176
+ };
177
+ const getFaultToleranceTime = (timeRange) => {
178
+ const [startDate, endDate] = timeRange;
179
+ const range = endDate.valueOf() - startDate.valueOf();
180
+ switch (range) {
181
+ case 5 * MINUTE:
182
+ return 5 * 1e3;
183
+ case 15 * MINUTE:
184
+ return 15 * 1e3;
185
+ case 1 * HOUR:
186
+ return 60 * 1e3;
187
+ case 2 * HOUR:
188
+ return 120 * 1e3;
189
+ case 24 * HOUR:
190
+ return 10 * 60 * 1e3;
191
+ case 7 * DAY:
192
+ case 30 * DAY:
193
+ return 60 * 60 * 1e3;
194
+ case 182 * DAY:
195
+ return 24 * 60 * 60 * 1e3;
196
+ }
197
+ return 120 * 1e3;
198
+ };
199
+ const addMissingDataWithZero = (data, timeRange, unit, step, dateRange) => {
200
+ const now = Date.now();
201
+ const inRangePoints = deletePointsOutOfRange(data, timeRange, now);
202
+ if (!inRangePoints.length) {
203
+ return [];
204
+ }
205
+ const firsExpectedTimestamp = getFirstExpectedTimestamp(
206
+ inRangePoints,
207
+ timeRange,
208
+ now,
209
+ step,
210
+ dateRange
211
+ );
212
+ const expectedPoints = [];
213
+ const tolerance = getFaultToleranceTime(timeRange);
214
+ if (inRangePoints[0].t - firsExpectedTimestamp > tolerance + step) {
215
+ inRangePoints.unshift({
216
+ t: firsExpectedTimestamp,
217
+ v: -Infinity
218
+ });
219
+ }
220
+ if (now - inRangePoints[inRangePoints.length - 1].t > tolerance + step) {
221
+ inRangePoints.push({
222
+ t: now,
223
+ v: -Infinity
224
+ });
225
+ }
226
+ inRangePoints.forEach((item, index) => {
227
+ var _a;
228
+ expectedPoints.push({
229
+ t: item == null ? void 0 : item.t,
230
+ v: item == null ? void 0 : item.v
231
+ });
232
+ if (index + 1 <= inRangePoints.length - 1) {
233
+ const nowTimeRange = ((_a = inRangePoints[index + 1]) == null ? void 0 : _a.t) - (item == null ? void 0 : item.t);
234
+ if (nowTimeRange > tolerance + step) {
235
+ const n = Math.floor(nowTimeRange / step);
236
+ for (let i = 1; i < n; i++) {
237
+ expectedPoints.push({
238
+ t: (item == null ? void 0 : item.t) + step * i,
239
+ v: -Infinity
240
+ });
241
+ }
242
+ }
243
+ }
244
+ });
245
+ return filterLineChartPointsByDateRange(
246
+ expectedPoints.map((p) => __spreadProps(__spreadValues({}, p), { unit })),
247
+ dateRange
248
+ );
249
+ };
250
+ const convertLineChartUnit = (value, from, to, decimals) => {
251
+ if (from === to || !value)
252
+ return value;
253
+ const ruleIndex = unitRules.findIndex((rule) => rule.unit.includes(from));
254
+ if (ruleIndex === -1) {
255
+ return value;
256
+ }
257
+ const { unit, divider } = unitRules[ruleIndex];
258
+ let fromIdx = unit.indexOf(from);
259
+ const toIdx = unit.indexOf(to);
260
+ if (toIdx === -1) {
261
+ return value;
262
+ }
263
+ if (fromIdx < toIdx) {
264
+ while (fromIdx < toIdx) {
265
+ value /= divider[fromIdx];
266
+ fromIdx++;
267
+ }
268
+ } else {
269
+ while (fromIdx > toIdx) {
270
+ value *= divider[fromIdx - 1];
271
+ fromIdx--;
272
+ }
273
+ }
274
+ return _.isInteger(value) ? value : _.isNil(decimals) ? value : parseFloat(value.toFixed(decimals));
275
+ };
276
+ const UNIT_FORMATTER = {
277
+ [ILineChartMetricUnit.Percent]: [formatPercent, "%", 2, false],
278
+ [ILineChartMetricUnit.Ratio]: [formatPercent, "%"],
279
+ [ILineChartMetricUnit.Count]: [formatCount, ""],
280
+ [ILineChartMetricUnit.DataSize]: [formatBytes, "B"],
281
+ [ILineChartMetricUnit.DataRateByte]: [formatBps, "Bps"],
282
+ [ILineChartMetricUnit.DataRateBit]: [formatBitPerSecond, "bps"],
283
+ [ILineChartMetricUnit.Time]: [formatNanoSecond, "ns"],
284
+ [ILineChartMetricUnit.Frequency]: [formatFrequency, "Hz"],
285
+ [ILineChartMetricUnit.Temperature]: [formatTemperature, "\u2103"],
286
+ [ILineChartMetricUnit.Load]: [formatCount, ""]
287
+ };
288
+ const getLineChartYDataMax = (dataPoints, type) => {
289
+ const values = dataPoints.map((p) => {
290
+ if (_.isNumber(p == null ? void 0 : p.v)) {
291
+ return p.v;
292
+ }
293
+ const entries = Object.entries(p);
294
+ if (type === ILineChartGraphType.Stack) {
295
+ let sum = 0;
296
+ for (const [key, value] of entries) {
297
+ if (/^v(\d*)$/.test(key) && _.isNumber(value)) {
298
+ sum += value;
299
+ }
300
+ }
301
+ return sum;
302
+ } else {
303
+ let max = 0;
304
+ for (const [key, value] of entries) {
305
+ if (/^v(\d*)$/.test(key) && _.isNumber(value) && value > max) {
306
+ max = value;
307
+ }
308
+ }
309
+ return max;
310
+ }
311
+ });
312
+ return Math.max(...values, 0);
313
+ };
314
+ const getYAxisUpperBound = (max, type) => {
315
+ const DIVISOR = 2;
316
+ switch (type) {
317
+ case ILineChartMetricUnit.Count:
318
+ case ILineChartMetricUnit.Load:
319
+ case ILineChartMetricUnit.DataSize:
320
+ case ILineChartMetricUnit.DataRateByte:
321
+ case ILineChartMetricUnit.Time:
322
+ case ILineChartMetricUnit.Frequency:
323
+ case ILineChartMetricUnit.DataRateBit:
324
+ case ILineChartMetricUnit.Temperature: {
325
+ const [format, base] = UNIT_FORMATTER[type];
326
+ const { value, unit } = format(max);
327
+ const _value = Math.ceil(Number(value) / DIVISOR) * DIVISOR;
328
+ return convertLineChartUnit(_value, unit, base);
329
+ }
330
+ case ILineChartMetricUnit.Percent: {
331
+ const [format, base, decimals, saturated] = UNIT_FORMATTER[type];
332
+ const { value, unit } = format(max, decimals, saturated);
333
+ const _value = Math.ceil(Number(value) / DIVISOR) * DIVISOR;
334
+ return convertLineChartUnit(_value, unit, base);
335
+ }
336
+ case ILineChartMetricUnit.Ratio: {
337
+ const [format, base] = UNIT_FORMATTER[type];
338
+ const { value, unit } = format(max * 100);
339
+ const _value = Math.ceil(Number(value) / DIVISOR) * DIVISOR;
340
+ return convertLineChartUnit(_value, unit, base) / 100;
341
+ }
342
+ default:
343
+ return 2;
344
+ }
345
+ };
346
+ const getYAxisDomain = (dataPoints, graphType, unitType) => {
347
+ const max = getLineChartYDataMax(dataPoints, graphType);
348
+ if (!max) {
349
+ if (unitType === ILineChartMetricUnit.Ratio) {
350
+ return [0, 1];
351
+ } else {
352
+ return [0, 2];
353
+ }
354
+ }
355
+ return [0, getYAxisUpperBound(max, unitType)];
356
+ };
357
+ function lineChartYaxisTickFormatter(value, unit) {
358
+ if (_.isNil(unit)) {
359
+ return `${value}`;
360
+ }
361
+ if (_.isNil(value)) {
362
+ return "0";
363
+ }
364
+ const [format] = UNIT_FORMATTER[unit];
365
+ const { value: _value, unit: _unit } = format(value);
366
+ return `${_value} ${_unit}`;
367
+ }
368
+
369
+ export { UNIT_FORMATTER, addMissingDataWithZero, convertLineChartDataStruct, convertLineChartUnit, deletePointsOutOfRange, filterLineChartDataOverlapping, filterLineChartOverlappingMetric, filterLineChartPointsByDateRange, getFirstExpectedTimestamp, getLineChartRangeTimestamp, getLineChartStep, getLineChartXAxisDomain, getLineChartYDataMax, getYAxisDomain, getYAxisUpperBound, lineChartTickFormatter, lineChartXaxisCal, lineChartYaxisTickFormatter, parseLineChartRange };
@@ -1,7 +1,7 @@
1
1
  import { LoadingWrapper, LoadingLine1, LoadingLine2, LoadingLine3 } from './style.js';
2
2
  import { FullView } from '../Styled/index.js';
3
- import React__default, { Fragment } from 'react';
4
3
  import cs from 'classnames';
4
+ import React__default, { Fragment } from 'react';
5
5
 
6
6
  var __defProp = Object.defineProperty;
7
7
  var __defProps = Object.defineProperties;
@@ -1,8 +1,8 @@
1
1
  import { styled } from '@linaria/react';
2
2
  import Link from '../Link/index.js';
3
- import { splitMap } from '../../utils/constants.js';
4
3
  import { IconField, Info } from './components.js';
5
4
  import Tag from '../Tag/index.js';
5
+ import { splitMap } from '../../utils/constants.js';
6
6
  import React__default from 'react';
7
7
 
8
8
  var __defProp = Object.defineProperty;
@@ -1,6 +1,6 @@
1
1
  import { cx } from '@linaria/core';
2
2
  import Empty from '../Empty/index.js';
3
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
3
+ import { ParrotTrans } from '../ParrotTrans/index.js';
4
4
  import isEmpty from '../../utils/isEmpty.js';
5
5
  import { formatSeconds } from '../../utils/tower.js';
6
6
  import React__default from 'react';
@@ -30,12 +30,20 @@ const Second = ({
30
30
  abbreviate,
31
31
  emptyProps
32
32
  }) => {
33
- const { t } = useParrotTranslation();
34
33
  if (isEmpty(rawValue)) {
35
34
  return /* @__PURE__ */ React__default.createElement(Empty, __spreadValues({}, emptyProps));
36
35
  }
37
36
  const { value, unit } = formatSeconds(rawValue, decimals);
38
- return /* @__PURE__ */ React__default.createElement("span", null, /* @__PURE__ */ React__default.createElement("span", { className: cx("value", valueClassName) }, value, " "), /* @__PURE__ */ React__default.createElement("span", { className: cx("unit", UnitStyle, unitClassName) }, t(`common.${abbreviate ? `${unit}_abbreviation` : unit}`)));
37
+ return /* @__PURE__ */ React__default.createElement(
38
+ ParrotTrans,
39
+ {
40
+ parent: "span",
41
+ i18nKey: `unit.${abbreviate ? `${unit}_abbreviation` : unit}`,
42
+ count: value
43
+ },
44
+ /* @__PURE__ */ React__default.createElement("span", { className: cx("value", valueClassName) }),
45
+ /* @__PURE__ */ React__default.createElement("span", { className: cx("unit", UnitStyle, unitClassName) })
46
+ );
39
47
  };
40
48
  var Second$1 = Second;
41
49
 
@@ -1,12 +1,12 @@
1
- import React__default from 'react';
2
1
  import { cx } from '@linaria/core';
3
- import { splitMap } from '../../utils/constants.js';
4
2
  import Link from '../Link/index.js';
3
+ import Tag from '../Tag/index.js';
5
4
  import { Typo } from '../Typo/index.js';
6
5
  import OverflowTooltip from '../../coreX/OverflowTooltip/index.js';
7
- import Tag from '../Tag/index.js';
6
+ import { splitMap } from '../../utils/constants.js';
8
7
  import { Flex } from 'antd5';
9
8
  import cs from 'classnames';
9
+ import React__default from 'react';
10
10
  import { InfoTextWrapper, SubInfoTextWrapper } from './Timeline.style.js';
11
11
  import { Show } from '../../coreX/Show/index.js';
12
12
 
@@ -1,11 +1,11 @@
1
1
  import { CheckmarkDoneSuccessCorrect16GreenIcon, XmarkFailed16RedIcon, Loading16GradientBlueIcon, NoticeTriangleFill16YellowIcon, WaitingBreathingLed16YellowIcon, TimelineNotStart16GrayIcon } from '@cloudtower/icons-react';
2
2
  import { cx } from '@linaria/core';
3
- import { Timeline as Timeline$1, Flex } from 'antd5';
4
- import React__default from 'react';
5
- import { EmptyWrapper, TimelineWrapper, TimelineItemWrapper } from './Timeline.style.js';
6
3
  import Alert from '../Alert/index.js';
7
4
  import Icon from '../Icon/index.js';
5
+ import { Timeline as Timeline$1, Flex } from 'antd5';
8
6
  import cs from 'classnames';
7
+ import React__default from 'react';
8
+ import { EmptyWrapper, TimelineWrapper, TimelineItemWrapper } from './Timeline.style.js';
9
9
  import { TimelineArea } from './Timeline.widget.js';
10
10
 
11
11
  var __defProp = Object.defineProperty;
@@ -1,8 +1,8 @@
1
- import React__default, { useState, useCallback } from 'react';
2
- import useParrotTranslation from '../../hooks/useParrotTranslation.js';
3
1
  import { XmarkFailedSeriousWarningFill16RedIcon, CheckmarkDoneSuccessCircleFill16GreenIcon, Loading16GradientBlueIcon, NoticeTriangleFill16YellowIcon } from '@cloudtower/icons-react';
4
- import { List } from 'antd5';
5
2
  import { cx } from '@linaria/core';
3
+ import useParrotTranslation from '../../hooks/useParrotTranslation.js';
4
+ import { List } from 'antd5';
5
+ import React__default, { useState, useCallback } from 'react';
6
6
  import { CheckPointItemStyle, CheckPointListStyle, EmptyWrapper } from './checkpointlist.style.js';
7
7
  import { Show } from '../Show/index.js';
8
8
  import Icon from '../../core/Icon/index.js';
@@ -60,14 +60,15 @@ const CheckPointList = ({
60
60
  emptyRender,
61
61
  emptyText,
62
62
  emptyTextClassName,
63
- onClickSwitch
63
+ onClickSwitch,
64
+ defaultChecked = false
64
65
  }) => {
65
66
  const { t } = useParrotTranslation();
66
- const [checked, setChecked] = useState(false);
67
+ const [checked, setChecked] = useState(defaultChecked);
67
68
  const onClickSwitchFn = useCallback(() => {
68
69
  const nextChecked = !checked;
69
70
  setChecked(nextChecked);
70
- onClickSwitch == null ? void 0 : onClickSwitch(checked);
71
+ onClickSwitch == null ? void 0 : onClickSwitch(nextChecked);
71
72
  }, [onClickSwitch, checked]);
72
73
  const isEmpty = !items.length;
73
74
  return /* @__PURE__ */ React__default.createElement("div", { className: cx(CheckPointListStyle) }, /* @__PURE__ */ React__default.createElement("header", { className: cx(Typo.Label.l4_bold) }, title, /* @__PURE__ */ React__default.createElement(Show, { condition: showSwitchControl }, /* @__PURE__ */ React__default.createElement("span", { className: "switch-text" }, /* @__PURE__ */ React__default.createElement(Switch, { checked, onChange: onClickSwitchFn, size: "small" }), /* @__PURE__ */ React__default.createElement("span", null, switchText || t("common.show_unpassed"))))), /* @__PURE__ */ React__default.createElement(
@@ -1,8 +1,8 @@
1
- import { FullView } from '../../core/Styled/index.js';
1
+ import { Loading64GradientBlueIcon } from '@cloudtower/icons-react';
2
2
  import Icon from '../../core/Icon/index.js';
3
- import React__default, { Fragment } from 'react';
3
+ import { FullView } from '../../core/Styled/index.js';
4
4
  import cs from 'classnames';
5
- import { Loading64GradientBlueIcon } from '@cloudtower/icons-react';
5
+ import React__default, { Fragment } from 'react';
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __defProps = Object.defineProperties;