@perses-dev/components 0.8.0 → 0.9.0
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.
- package/dist/Drawer/Drawer.d.ts +3 -4
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +35 -1
- package/dist/Drawer/Drawer.js.map +1 -0
- package/dist/Drawer/index.js +15 -1
- package/dist/Drawer/index.js.map +1 -0
- package/dist/EChart.d.ts.map +1 -1
- package/dist/EChart.js +142 -1
- package/dist/EChart.js.map +1 -0
- package/dist/ErrorAlert.js +25 -1
- package/dist/ErrorAlert.js.map +1 -0
- package/dist/ErrorBoundary.js +16 -1
- package/dist/ErrorBoundary.js.map +1 -0
- package/dist/GaugeChart/GaugeChart.js +172 -1
- package/dist/GaugeChart/GaugeChart.js.map +1 -0
- package/dist/GaugeChart/index.js +15 -1
- package/dist/GaugeChart/index.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.js +79 -1
- package/dist/InfoTooltip/InfoTooltip.js.map +1 -0
- package/dist/InfoTooltip/InfoTooltip.test.js +36 -1
- package/dist/InfoTooltip/InfoTooltip.test.js.map +1 -0
- package/dist/InfoTooltip/index.js +15 -1
- package/dist/InfoTooltip/index.js.map +1 -0
- package/dist/LineChart/LineChart.js +198 -1
- package/dist/LineChart/LineChart.js.map +1 -0
- package/dist/LineChart/index.js +15 -1
- package/dist/LineChart/index.js.map +1 -0
- package/dist/LineChart/utils.js +63 -1
- package/dist/LineChart/utils.js.map +1 -0
- package/dist/StatChart/StatChart.js +121 -1
- package/dist/StatChart/StatChart.js.map +1 -0
- package/dist/StatChart/StatChart.test.js +82 -1
- package/dist/StatChart/StatChart.test.js.map +1 -0
- package/dist/StatChart/index.js +15 -1
- package/dist/StatChart/index.js.map +1 -0
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js +175 -1
- package/dist/TimeRangeSelector/AbsoluteTimePicker.js.map +1 -0
- package/dist/TimeRangeSelector/TimeRangeSelector.js +52 -1
- package/dist/TimeRangeSelector/TimeRangeSelector.js.map +1 -0
- package/dist/TimeRangeSelector/index.js +16 -1
- package/dist/TimeRangeSelector/index.js.map +1 -0
- package/dist/TimeRangeSelector/utils.js +36 -1
- package/dist/TimeRangeSelector/utils.js.map +1 -0
- package/dist/Tooltip/SeriesInfo.js +143 -1
- package/dist/Tooltip/SeriesInfo.js.map +1 -0
- package/dist/Tooltip/SeriesMarker.js +33 -1
- package/dist/Tooltip/SeriesMarker.js.map +1 -0
- package/dist/Tooltip/Tooltip.js +72 -1
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/TooltipContent.js +89 -1
- package/dist/Tooltip/TooltipContent.js.map +1 -0
- package/dist/Tooltip/focused-series.js +108 -1
- package/dist/Tooltip/focused-series.js.map +1 -0
- package/dist/Tooltip/focused-series.test.js +75 -1
- package/dist/Tooltip/focused-series.test.js.map +1 -0
- package/dist/Tooltip/index.js +16 -1
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/Tooltip/tooltip-model.js +80 -1
- package/dist/Tooltip/tooltip-model.js.map +1 -0
- package/dist/Tooltip/utils.js +46 -1
- package/dist/Tooltip/utils.js.map +1 -0
- package/dist/cjs/Drawer/Drawer.js +26 -13
- package/dist/cjs/Drawer/index.js +16 -17
- package/dist/cjs/EChart.js +114 -89
- package/dist/cjs/ErrorAlert.js +16 -12
- package/dist/cjs/ErrorBoundary.js +10 -6
- package/dist/cjs/GaugeChart/GaugeChart.js +90 -57
- package/dist/cjs/GaugeChart/index.js +16 -17
- package/dist/cjs/InfoTooltip/InfoTooltip.js +90 -33
- package/dist/cjs/InfoTooltip/InfoTooltip.test.js +27 -17
- package/dist/cjs/InfoTooltip/index.js +16 -17
- package/dist/cjs/LineChart/LineChart.js +122 -87
- package/dist/cjs/LineChart/index.js +16 -17
- package/dist/cjs/LineChart/utils.js +23 -23
- package/dist/cjs/StatChart/StatChart.js +107 -46
- package/dist/cjs/StatChart/StatChart.test.js +65 -21
- package/dist/cjs/StatChart/index.js +16 -17
- package/dist/cjs/TimeRangeSelector/AbsoluteTimePicker.js +144 -64
- package/dist/cjs/TimeRangeSelector/TimeRangeSelector.js +45 -22
- package/dist/cjs/TimeRangeSelector/index.js +17 -18
- package/dist/cjs/TimeRangeSelector/utils.js +19 -16
- package/dist/cjs/Tooltip/SeriesInfo.js +120 -48
- package/dist/cjs/Tooltip/SeriesMarker.js +20 -11
- package/dist/cjs/Tooltip/Tooltip.js +95 -67
- package/dist/cjs/Tooltip/TooltipContent.js +76 -31
- package/dist/cjs/Tooltip/focused-series.js +40 -36
- package/dist/cjs/Tooltip/focused-series.test.js +36 -16
- package/dist/cjs/Tooltip/index.js +17 -18
- package/dist/cjs/Tooltip/tooltip-model.js +46 -30
- package/dist/cjs/Tooltip/utils.js +13 -16
- package/dist/cjs/context/ChartsThemeProvider.js +65 -13
- package/dist/cjs/index.js +27 -28
- package/dist/cjs/model/graph.js +10 -5
- package/dist/cjs/model/index.js +18 -19
- package/dist/cjs/model/theme.js +4 -2
- package/dist/cjs/model/units.js +68 -51
- package/dist/cjs/test/index.js +16 -17
- package/dist/cjs/test/render.js +22 -12
- package/dist/cjs/test/setup-tests.js +4 -2
- package/dist/cjs/utils/combine-sx.js +15 -16
- package/dist/cjs/utils/index.js +17 -18
- package/dist/cjs/utils/theme-gen.js +64 -55
- package/dist/cjs/utils/theme-gen.test.js +14 -12
- package/dist/context/ChartsThemeProvider.js +36 -1
- package/dist/context/ChartsThemeProvider.js.map +1 -0
- package/dist/index.js +26 -1
- package/dist/index.js.map +1 -0
- package/dist/model/graph.js +15 -1
- package/dist/model/graph.js.map +1 -0
- package/dist/model/index.js +17 -1
- package/dist/model/index.js.map +1 -0
- package/dist/model/theme.js +15 -1
- package/dist/model/theme.js.map +1 -0
- package/dist/model/units.d.ts.map +1 -1
- package/dist/model/units.js +196 -1
- package/dist/model/units.js.map +1 -0
- package/dist/test/index.js +15 -1
- package/dist/test/index.js.map +1 -0
- package/dist/test/render.js +32 -1
- package/dist/test/render.js.map +1 -0
- package/dist/test/setup-tests.js +18 -1
- package/dist/test/setup-tests.js.map +1 -0
- package/dist/utils/combine-sx.js +27 -1
- package/dist/utils/combine-sx.js.map +1 -0
- package/dist/utils/index.js +16 -1
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/theme-gen.js +183 -1
- package/dist/utils/theme-gen.js.map +1 -0
- package/dist/utils/theme-gen.test.js +196 -1
- package/dist/utils/theme-gen.test.js.map +1 -0
- package/package.json +8 -4
|
@@ -1,17 +1,37 @@
|
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
1
13
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _react = /*#__PURE__*/ _interopRequireDefault(require("react"));
|
|
19
|
+
const _react1 = require("@testing-library/react");
|
|
20
|
+
const _chartsThemeProvider = require("../context/ChartsThemeProvider");
|
|
21
|
+
const _statChart = require("./StatChart");
|
|
22
|
+
function _interopRequireDefault(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
describe('StatChart', ()=>{
|
|
8
28
|
const contentDimensions = {
|
|
9
29
|
width: 200,
|
|
10
|
-
height: 200
|
|
30
|
+
height: 200
|
|
11
31
|
};
|
|
12
32
|
const unit = {
|
|
13
33
|
kind: 'Decimal',
|
|
14
|
-
decimal_places: 2
|
|
34
|
+
decimal_places: 2
|
|
15
35
|
};
|
|
16
36
|
const mockStatData = {
|
|
17
37
|
calculatedValue: 7.72931659687181,
|
|
@@ -19,13 +39,28 @@ describe('StatChart', () => {
|
|
|
19
39
|
seriesData: {
|
|
20
40
|
name: '(((count(count(node_cpu_seconds_total{job="example"}) by (cpu))',
|
|
21
41
|
values: [
|
|
22
|
-
[
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
[
|
|
27
|
-
|
|
28
|
-
|
|
42
|
+
[
|
|
43
|
+
1654006170000,
|
|
44
|
+
7.736401673473903
|
|
45
|
+
],
|
|
46
|
+
[
|
|
47
|
+
1654006185000,
|
|
48
|
+
7.733891213538757
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
1654006200000,
|
|
52
|
+
7.731101813010433
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
1654006215000,
|
|
56
|
+
7.722454672079215
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
1654006230000,
|
|
60
|
+
7.722733612256738
|
|
61
|
+
]
|
|
62
|
+
]
|
|
63
|
+
}
|
|
29
64
|
};
|
|
30
65
|
const exampleChartsTheme = {
|
|
31
66
|
themeName: 'perses',
|
|
@@ -33,13 +68,22 @@ describe('StatChart', () => {
|
|
|
33
68
|
noDataOption: {},
|
|
34
69
|
sparkline: {
|
|
35
70
|
width: 1,
|
|
36
|
-
color: '#000000'
|
|
37
|
-
}
|
|
71
|
+
color: '#000000'
|
|
72
|
+
}
|
|
38
73
|
};
|
|
39
|
-
describe('Render default options (no sparkline)', ()
|
|
40
|
-
it('should render', ()
|
|
41
|
-
(0,
|
|
42
|
-
|
|
74
|
+
describe('Render default options (no sparkline)', ()=>{
|
|
75
|
+
it('should render', ()=>{
|
|
76
|
+
(0, _react1.render)(/*#__PURE__*/ (0, _jsxRuntime.jsx)(_chartsThemeProvider.ChartsThemeProvider, {
|
|
77
|
+
themeName: "perses",
|
|
78
|
+
chartsTheme: exampleChartsTheme,
|
|
79
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsx)(_statChart.StatChart, {
|
|
80
|
+
width: contentDimensions.width,
|
|
81
|
+
height: contentDimensions.height,
|
|
82
|
+
data: mockStatData,
|
|
83
|
+
unit: unit
|
|
84
|
+
})
|
|
85
|
+
}));
|
|
86
|
+
expect(_react1.screen.getByText('7.73')).toBeInTheDocument();
|
|
43
87
|
});
|
|
44
88
|
});
|
|
45
89
|
});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,19 +10,19 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Object.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./StatChart"), exports);
|
|
18
|
+
function _exportStar(from, to) {
|
|
19
|
+
Object.keys(from).forEach(function(k) {
|
|
20
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return from[k];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return from;
|
|
28
|
+
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbsoluteTimePicker = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
1
|
// Copyright 2022 The Perses Authors
|
|
6
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -14,88 +10,172 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
14
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
11
|
// See the License for the specific language governing permissions and
|
|
16
12
|
// limitations under the License.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "AbsoluteTimePicker", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>AbsoluteTimePicker
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _react = require("react");
|
|
23
|
+
const _material = require("@mui/material");
|
|
24
|
+
const _xDatePickers = require("@mui/x-date-pickers");
|
|
25
|
+
const _adapterDateFns = require("@mui/x-date-pickers/AdapterDateFns");
|
|
26
|
+
const _dateFns = require("date-fns");
|
|
27
|
+
const _utils = require("./utils");
|
|
23
28
|
const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
|
24
|
-
const AbsoluteTimePicker = ({ initialTimeRange, onChange
|
|
25
|
-
const [timeRange, setTimeRange] = (0,
|
|
26
|
-
const [showStartCalendar, setShowStartCalendar] = (0,
|
|
29
|
+
const AbsoluteTimePicker = ({ initialTimeRange , onChange })=>{
|
|
30
|
+
const [timeRange, setTimeRange] = (0, _react.useState)(initialTimeRange);
|
|
31
|
+
const [showStartCalendar, setShowStartCalendar] = (0, _react.useState)(true);
|
|
27
32
|
// validate start and end time, propagate changes
|
|
28
|
-
const updateDateRange = (input, isStartDate)
|
|
33
|
+
const updateDateRange = (input, isStartDate)=>{
|
|
29
34
|
const newDate = new Date(input);
|
|
30
35
|
if (isStartDate === true) {
|
|
31
|
-
const isValidDateRange = (0,
|
|
36
|
+
const isValidDateRange = (0, _utils.validateDateRange)(newDate, timeRange.end);
|
|
32
37
|
if (isValidDateRange === true) {
|
|
33
|
-
setTimeRange((current)
|
|
34
|
-
const updatedRange = {
|
|
38
|
+
setTimeRange((current)=>{
|
|
39
|
+
const updatedRange = {
|
|
40
|
+
start: newDate,
|
|
41
|
+
end: current.end
|
|
42
|
+
};
|
|
35
43
|
onChange(updatedRange);
|
|
36
44
|
return updatedRange;
|
|
37
45
|
});
|
|
38
46
|
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
47
|
+
} else {
|
|
48
|
+
const isValidDateRange1 = (0, _utils.validateDateRange)(timeRange.start, newDate);
|
|
49
|
+
if (isValidDateRange1 === true) {
|
|
50
|
+
setTimeRange((current)=>{
|
|
51
|
+
const updatedRange = {
|
|
52
|
+
start: current.start,
|
|
53
|
+
end: newDate
|
|
54
|
+
};
|
|
45
55
|
onChange(updatedRange);
|
|
46
56
|
return updatedRange;
|
|
47
57
|
});
|
|
48
58
|
}
|
|
49
59
|
}
|
|
50
60
|
};
|
|
51
|
-
return (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.LocalizationProvider, {
|
|
62
|
+
dateAdapter: _adapterDateFns.AdapterDateFns,
|
|
63
|
+
children: /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
64
|
+
spacing: 3,
|
|
65
|
+
sx: {
|
|
66
|
+
padding: (theme)=>theme.spacing(1, 2, 3)
|
|
67
|
+
},
|
|
68
|
+
children: [
|
|
69
|
+
showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
70
|
+
sx: (theme)=>({
|
|
71
|
+
// TODO: create separate reusable calendar component
|
|
72
|
+
'.MuiPickerStaticWrapper-content': {
|
|
73
|
+
backgroundColor: theme.palette.background.default
|
|
74
|
+
},
|
|
75
|
+
// reposition AM and PM buttons
|
|
76
|
+
'.MuiIconButton-sizeMedium': {
|
|
77
|
+
top: 80,
|
|
78
|
+
bottom: 'auto',
|
|
79
|
+
margin: theme.spacing(0, 3)
|
|
80
|
+
}
|
|
81
|
+
}),
|
|
82
|
+
children: [
|
|
83
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("h3", {
|
|
84
|
+
children: "Select Start Time"
|
|
85
|
+
}),
|
|
86
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
|
|
87
|
+
displayStaticWrapperAs: "desktop",
|
|
88
|
+
openTo: "day",
|
|
89
|
+
disableHighlightToday: true,
|
|
90
|
+
value: initialTimeRange.start,
|
|
91
|
+
onChange: (newValue)=>{
|
|
92
|
+
if (newValue === null) return;
|
|
93
|
+
setTimeRange((current)=>{
|
|
94
|
+
return {
|
|
95
|
+
start: newValue,
|
|
96
|
+
end: current.end
|
|
97
|
+
};
|
|
67
98
|
});
|
|
68
|
-
},
|
|
99
|
+
},
|
|
100
|
+
onAccept: ()=>{
|
|
69
101
|
setShowStartCalendar(false);
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
},
|
|
103
|
+
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
104
|
+
...params
|
|
105
|
+
})
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
}),
|
|
109
|
+
!showStartCalendar && /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Box, {
|
|
110
|
+
sx: (theme)=>({
|
|
111
|
+
'.MuiPickerStaticWrapper-content': {
|
|
112
|
+
backgroundColor: theme.palette.background.default
|
|
113
|
+
},
|
|
114
|
+
// reposition AM and PM buttons
|
|
115
|
+
'.MuiIconButton-sizeMedium': {
|
|
116
|
+
top: 80,
|
|
117
|
+
bottom: 'auto',
|
|
118
|
+
margin: theme.spacing(0, 3)
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
children: [
|
|
122
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)("h3", {
|
|
123
|
+
children: "Select End Time"
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_xDatePickers.StaticDateTimePicker, {
|
|
126
|
+
displayStaticWrapperAs: "desktop",
|
|
127
|
+
openTo: "day",
|
|
128
|
+
disableHighlightToday: true,
|
|
129
|
+
value: initialTimeRange.end,
|
|
130
|
+
minDateTime: timeRange.start,
|
|
131
|
+
onChange: (newValue)=>{
|
|
132
|
+
if (newValue === null) return;
|
|
133
|
+
setTimeRange((current)=>{
|
|
134
|
+
return {
|
|
135
|
+
start: current.start,
|
|
136
|
+
end: newValue
|
|
137
|
+
};
|
|
85
138
|
});
|
|
86
|
-
},
|
|
139
|
+
},
|
|
140
|
+
onAccept: ()=>{
|
|
87
141
|
setShowStartCalendar(true);
|
|
88
142
|
onChange(timeRange);
|
|
89
|
-
},
|
|
143
|
+
},
|
|
144
|
+
renderInput: (params)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
145
|
+
...params
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
]
|
|
149
|
+
}),
|
|
150
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
151
|
+
fullWidth: true,
|
|
152
|
+
onChange: (event)=>{
|
|
90
153
|
// TODO: add helperText, fix validation after we decide on form state solution
|
|
91
154
|
updateDateRange(event.target.value, true);
|
|
92
|
-
},
|
|
155
|
+
},
|
|
156
|
+
value: (0, _dateFns.format)(timeRange.start, DATE_TIME_FORMAT),
|
|
157
|
+
label: "Start Time",
|
|
158
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
93
159
|
// tel used to match MUI DateTimePicker, may change in future: https://github.com/mui/material-ui/issues/27590
|
|
94
|
-
type: "tel"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
160
|
+
type: "tel"
|
|
161
|
+
}),
|
|
162
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.Divider, {
|
|
163
|
+
sx: (theme)=>({
|
|
164
|
+
margin: theme.spacing(2, 0),
|
|
165
|
+
borderColor: theme.palette.grey['500']
|
|
166
|
+
})
|
|
167
|
+
}),
|
|
168
|
+
/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.TextField, {
|
|
169
|
+
fullWidth: true,
|
|
170
|
+
onChange: (event)=>{
|
|
98
171
|
updateDateRange(event.target.value, false);
|
|
99
|
-
},
|
|
172
|
+
},
|
|
173
|
+
value: (0, _dateFns.format)(timeRange.end, DATE_TIME_FORMAT),
|
|
174
|
+
label: "End Time",
|
|
175
|
+
placeholder: "mm/dd/yyyy hh:mm",
|
|
176
|
+
type: "tel"
|
|
177
|
+
})
|
|
178
|
+
]
|
|
179
|
+
})
|
|
180
|
+
});
|
|
100
181
|
};
|
|
101
|
-
exports.AbsoluteTimePicker = AbsoluteTimePicker;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.TimeRangeSelector = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
1
|
// Copyright 2022 The Perses Authors
|
|
9
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -17,24 +10,54 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
17
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
11
|
// See the License for the specific language governing permissions and
|
|
19
12
|
// limitations under the License.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "TimeRangeSelector", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>TimeRangeSelector
|
|
20
|
+
});
|
|
21
|
+
const _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
+
const _material = require("@mui/material");
|
|
23
|
+
const _event = /*#__PURE__*/ _interopRequireDefault(require("@mui/icons-material/Event"));
|
|
24
|
+
const _core = require("@perses-dev/core");
|
|
25
|
+
const _utils = require("./utils");
|
|
26
|
+
function _interopRequireDefault(obj) {
|
|
27
|
+
return obj && obj.__esModule ? obj : {
|
|
28
|
+
default: obj
|
|
29
|
+
};
|
|
30
|
+
}
|
|
24
31
|
const DATE_TIME_FORMAT = 'yyyy-MM-dd HH:mm:ss';
|
|
25
32
|
function TimeRangeSelector(props) {
|
|
26
|
-
const { value, timeOptions, onSelectChange, onCustomClick
|
|
27
|
-
const formattedValue = !(0,
|
|
28
|
-
|
|
29
|
-
:
|
|
30
|
-
|
|
33
|
+
const { value , timeOptions , onSelectChange , onCustomClick } = props;
|
|
34
|
+
const formattedValue = !(0, _core.isRelativeTimeRange)(value) ? (0, _utils.formatAbsoluteRange)(value, DATE_TIME_FORMAT) : value.pastDuration;
|
|
35
|
+
return /*#__PURE__*/ (0, _jsxRuntime.jsxs)(_material.Select, {
|
|
36
|
+
value: formattedValue,
|
|
37
|
+
onChange: onSelectChange,
|
|
38
|
+
IconComponent: _event.default,
|
|
39
|
+
sx: {
|
|
31
40
|
'.MuiSelect-icon': {
|
|
32
|
-
marginTop: '1px'
|
|
33
|
-
}
|
|
34
|
-
},
|
|
41
|
+
marginTop: '1px'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
children: [
|
|
45
|
+
timeOptions.map((item, idx)=>/*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
46
|
+
value: item.value.pastDuration,
|
|
47
|
+
children: item.display
|
|
48
|
+
}, idx)),
|
|
49
|
+
(0, _core.isRelativeTimeRange)(value) ? /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
50
|
+
onClick: ()=>{
|
|
35
51
|
onCustomClick();
|
|
36
|
-
},
|
|
52
|
+
},
|
|
53
|
+
children: "Custom time range"
|
|
54
|
+
}) : /*#__PURE__*/ (0, _jsxRuntime.jsx)(_material.MenuItem, {
|
|
55
|
+
value: formattedValue,
|
|
56
|
+
onClick: ()=>{
|
|
37
57
|
onCustomClick();
|
|
38
|
-
},
|
|
58
|
+
},
|
|
59
|
+
children: formattedValue
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
});
|
|
39
63
|
}
|
|
40
|
-
exports.TimeRangeSelector = TimeRangeSelector;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,20 +10,20 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./TimeRangeSelector"), exports);
|
|
18
|
+
_exportStar(require("./AbsoluteTimePicker"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,31 +10,35 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
validateDateRange: ()=>validateDateRange,
|
|
25
|
+
formatAbsoluteRange: ()=>formatAbsoluteRange
|
|
26
|
+
});
|
|
27
|
+
const _dateFns = require("date-fns");
|
|
20
28
|
function validateDateRange(startDate, endDate) {
|
|
21
29
|
// TODO: display error as helperText
|
|
22
|
-
if (!(0,
|
|
30
|
+
if (!(0, _dateFns.isValid)(startDate) || !(0, _dateFns.isValid)(endDate)) {
|
|
23
31
|
console.error('Invalid Date');
|
|
24
32
|
return false;
|
|
25
33
|
}
|
|
26
|
-
if (!(0,
|
|
34
|
+
if (!(0, _dateFns.isBefore)(startDate, endDate)) {
|
|
27
35
|
console.error('End Time is before Start Time');
|
|
28
36
|
return false;
|
|
29
37
|
}
|
|
30
38
|
return true;
|
|
31
39
|
}
|
|
32
|
-
exports.validateDateRange = validateDateRange;
|
|
33
|
-
/**
|
|
34
|
-
* Format start and end time based on provided date format
|
|
35
|
-
*/
|
|
36
40
|
function formatAbsoluteRange(timeRange, dateFormat) {
|
|
37
|
-
const formattedStart = (0,
|
|
38
|
-
const formattedEnd = (0,
|
|
41
|
+
const formattedStart = (0, _dateFns.format)(timeRange.start, dateFormat);
|
|
42
|
+
const formattedEnd = (0, _dateFns.format)(timeRange.end, dateFormat);
|
|
39
43
|
return `${formattedStart} - ${formattedEnd}`;
|
|
40
44
|
}
|
|
41
|
-
exports.formatAbsoluteRange = formatAbsoluteRange;
|