@perses-dev/core 0.0.0-snapshot-panel-extra-content-3-17f9c42 → 0.0.0-snapshot-scatterplot-fix-imports-95e1b59
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/cjs/constants/dashboard-defaults.js +6 -2
- package/dist/cjs/constants/dialog.js +3 -1
- package/dist/cjs/constants/index.js +11 -9
- package/dist/cjs/index.js +12 -10
- package/dist/cjs/model/calculations.js +61 -51
- package/dist/cjs/model/ephemeraldashboard.js +16 -0
- package/dist/cjs/model/http-proxy.js +16 -0
- package/dist/cjs/model/index.js +35 -26
- package/dist/cjs/model/kind.js +39 -0
- package/dist/cjs/model/legend.js +39 -19
- package/dist/cjs/model/resource.js +9 -0
- package/dist/cjs/model/rolebindings.js +16 -0
- package/dist/cjs/model/roles.js +60 -0
- package/dist/cjs/model/secrets.js +16 -0
- package/dist/cjs/model/time-series-queries.js +3 -1
- package/dist/cjs/model/time.js +151 -65
- package/dist/cjs/model/trace-data.js +16 -0
- package/dist/cjs/model/units/bytes.js +37 -25
- package/dist/cjs/model/units/constants.js +3 -1
- package/dist/cjs/model/units/decimal.js +22 -16
- package/dist/cjs/model/units/index.js +13 -11
- package/dist/cjs/model/units/percent.js +26 -19
- package/dist/cjs/model/units/throughput.js +113 -0
- package/dist/cjs/model/units/time.js +99 -38
- package/dist/cjs/model/units/types.js +5 -2
- package/dist/cjs/model/units/units.js +81 -45
- package/dist/cjs/model/units/utils.js +13 -7
- package/dist/cjs/model/variables.js +16 -3
- package/dist/cjs/utils/event.js +3 -1
- package/dist/cjs/utils/fetch.js +32 -7
- package/dist/cjs/utils/index.js +17 -14
- package/dist/cjs/utils/is-empty-object.js +3 -1
- package/dist/cjs/utils/mathjs.js +4 -2
- package/dist/cjs/utils/memo.js +10 -6
- package/dist/cjs/utils/panel-refs.js +9 -3
- package/dist/cjs/utils/text.js +33 -21
- package/dist/cjs/utils/time-series-data.js +21 -11
- package/dist/cjs/utils/types.js +16 -0
- package/dist/constants/dashboard-defaults.js.map +1 -1
- package/dist/constants/dialog.js.map +1 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/model/calculations.d.ts +12 -12
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js +46 -46
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/dashboard.js.map +1 -1
- package/dist/model/datasource.d.ts +17 -3
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +3 -1
- package/dist/model/datasource.js.map +1 -1
- package/dist/model/definitions.d.ts +1 -1
- package/dist/model/definitions.d.ts.map +1 -1
- package/dist/model/definitions.js +3 -0
- package/dist/model/definitions.js.map +1 -1
- package/dist/model/display.d.ts +1 -1
- package/dist/model/display.d.ts.map +1 -1
- package/dist/model/display.js.map +1 -1
- package/dist/model/ephemeraldashboard.d.ts +15 -0
- package/dist/model/ephemeraldashboard.d.ts.map +1 -0
- package/dist/model/ephemeraldashboard.js +15 -0
- package/dist/model/ephemeraldashboard.js.map +1 -0
- package/dist/model/http-proxy.d.ts +16 -0
- package/dist/model/http-proxy.d.ts.map +1 -0
- package/dist/model/http-proxy.js +15 -0
- package/dist/model/http-proxy.js.map +1 -0
- package/dist/model/http.d.ts +1 -1
- package/dist/model/http.d.ts.map +1 -1
- package/dist/model/index.d.ts +7 -0
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +7 -0
- package/dist/model/index.js.map +1 -1
- package/dist/model/kind.d.ts +3 -0
- package/dist/model/kind.d.ts.map +1 -0
- package/dist/model/kind.js +31 -0
- package/dist/model/kind.js.map +1 -0
- package/dist/model/layout.d.ts +1 -1
- package/dist/model/layout.d.ts.map +1 -1
- package/dist/model/layout.js.map +1 -1
- package/dist/model/legend.d.ts +9 -9
- package/dist/model/legend.d.ts.map +1 -1
- package/dist/model/legend.js +9 -9
- package/dist/model/legend.js.map +1 -1
- package/dist/model/panels.d.ts +5 -2
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +3 -1
- package/dist/model/panels.js.map +1 -1
- package/dist/model/project.js.map +1 -1
- package/dist/model/query.d.ts +15 -2
- package/dist/model/query.d.ts.map +1 -1
- package/dist/model/query.js +4 -1
- package/dist/model/query.js.map +1 -1
- package/dist/model/resource.d.ts +3 -2
- package/dist/model/resource.d.ts.map +1 -1
- package/dist/model/resource.js +3 -1
- package/dist/model/resource.js.map +1 -1
- package/dist/model/rolebindings.d.ts +27 -0
- package/dist/model/rolebindings.d.ts.map +1 -0
- package/dist/model/rolebindings.js +15 -0
- package/dist/model/rolebindings.js.map +1 -0
- package/dist/model/roles.d.ts +32 -0
- package/dist/model/roles.d.ts.map +1 -0
- package/dist/model/roles.js +41 -0
- package/dist/model/roles.js.map +1 -0
- package/dist/model/secrets.d.ts +44 -0
- package/dist/model/secrets.d.ts.map +1 -0
- package/dist/model/secrets.js +15 -0
- package/dist/model/secrets.js.map +1 -0
- package/dist/model/thresholds.d.ts +2 -2
- package/dist/model/thresholds.d.ts.map +1 -1
- package/dist/model/thresholds.js.map +1 -1
- package/dist/model/time-series-data.js.map +1 -1
- package/dist/model/time-series-queries.d.ts +3 -3
- package/dist/model/time-series-queries.d.ts.map +1 -1
- package/dist/model/time-series-queries.js.map +1 -1
- package/dist/model/time.d.ts +15 -11
- package/dist/model/time.d.ts.map +1 -1
- package/dist/model/time.js +117 -57
- package/dist/model/time.js.map +1 -1
- package/dist/model/trace-data.d.ts +20 -0
- package/dist/model/trace-data.d.ts.map +1 -0
- package/dist/model/trace-data.js +18 -0
- package/dist/model/trace-data.js.map +1 -0
- package/dist/model/units/bytes.d.ts +8 -8
- package/dist/model/units/bytes.d.ts.map +1 -1
- package/dist/model/units/bytes.js +27 -21
- package/dist/model/units/bytes.js.map +1 -1
- package/dist/model/units/constants.js.map +1 -1
- package/dist/model/units/decimal.d.ts +8 -8
- package/dist/model/units/decimal.d.ts.map +1 -1
- package/dist/model/units/decimal.js +14 -14
- package/dist/model/units/decimal.js.map +1 -1
- package/dist/model/units/index.js.map +1 -1
- package/dist/model/units/percent.d.ts +7 -7
- package/dist/model/units/percent.d.ts.map +1 -1
- package/dist/model/units/percent.js +17 -16
- package/dist/model/units/percent.js.map +1 -1
- package/dist/model/units/throughput.d.ts +13 -0
- package/dist/model/units/throughput.d.ts.map +1 -0
- package/dist/model/units/throughput.js +94 -0
- package/dist/model/units/throughput.js.map +1 -0
- package/dist/model/units/time.d.ts +15 -15
- package/dist/model/units/time.d.ts.map +1 -1
- package/dist/model/units/time.js +87 -34
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +18 -9
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js +2 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +50 -31
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +52 -37
- package/dist/model/units/units.js.map +1 -1
- package/dist/model/units/utils.d.ts +2 -2
- package/dist/model/units/utils.d.ts.map +1 -1
- package/dist/model/units/utils.js +4 -4
- package/dist/model/units/utils.js.map +1 -1
- package/dist/model/variables.d.ts +28 -9
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +3 -0
- package/dist/model/variables.js.map +1 -1
- package/dist/test/setup-tests.js.map +1 -1
- package/dist/utils/event.js.map +1 -1
- package/dist/utils/fetch.d.ts +3 -1
- package/dist/utils/fetch.d.ts.map +1 -1
- package/dist/utils/fetch.js +21 -4
- package/dist/utils/fetch.js.map +1 -1
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/is-empty-object.js.map +1 -1
- package/dist/utils/mathjs.js +1 -1
- package/dist/utils/mathjs.js.map +1 -1
- package/dist/utils/memo.js +2 -2
- package/dist/utils/memo.js.map +1 -1
- package/dist/utils/panel-refs.js.map +1 -1
- package/dist/utils/text.d.ts +7 -7
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/text.js +17 -17
- package/dist/utils/text.js.map +1 -1
- package/dist/utils/time-series-data.d.ts +1 -1
- package/dist/utils/time-series-data.d.ts.map +1 -1
- package/dist/utils/time-series-data.js +7 -7
- package/dist/utils/time-series-data.js.map +1 -1
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +15 -0
- package/dist/utils/types.js.map +1 -0
- package/package.json +5 -4
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright 2023 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.
|
|
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
|
+
THROUGHPUT_GROUP_CONFIG: function() {
|
|
25
|
+
return THROUGHPUT_GROUP_CONFIG;
|
|
26
|
+
},
|
|
27
|
+
THROUGHPUT_UNIT_CONFIG: function() {
|
|
28
|
+
return THROUGHPUT_UNIT_CONFIG;
|
|
29
|
+
},
|
|
30
|
+
formatThroughput: function() {
|
|
31
|
+
return formatThroughput;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const _constants = require("./constants");
|
|
35
|
+
const _utils = require("./utils");
|
|
36
|
+
const throughputUnits = [
|
|
37
|
+
'counts/sec',
|
|
38
|
+
'events/sec',
|
|
39
|
+
'messages/sec',
|
|
40
|
+
'ops/sec',
|
|
41
|
+
'packets/sec',
|
|
42
|
+
'reads/sec',
|
|
43
|
+
'records/sec',
|
|
44
|
+
'requests/sec',
|
|
45
|
+
'rows/sec',
|
|
46
|
+
'writes/sec'
|
|
47
|
+
];
|
|
48
|
+
const THROUGHPUT_GROUP_CONFIG = {
|
|
49
|
+
label: 'Throughput',
|
|
50
|
+
decimalPlaces: true
|
|
51
|
+
};
|
|
52
|
+
const THROUGHPUT_GROUP = 'Throughput';
|
|
53
|
+
const THROUGHPUT_UNIT_CONFIG = {
|
|
54
|
+
'counts/sec': {
|
|
55
|
+
group: THROUGHPUT_GROUP,
|
|
56
|
+
label: 'Counts/sec'
|
|
57
|
+
},
|
|
58
|
+
'events/sec': {
|
|
59
|
+
group: THROUGHPUT_GROUP,
|
|
60
|
+
label: 'Events/sec'
|
|
61
|
+
},
|
|
62
|
+
'messages/sec': {
|
|
63
|
+
group: THROUGHPUT_GROUP,
|
|
64
|
+
label: 'Messages/sec'
|
|
65
|
+
},
|
|
66
|
+
'ops/sec': {
|
|
67
|
+
group: THROUGHPUT_GROUP,
|
|
68
|
+
label: 'Ops/sec'
|
|
69
|
+
},
|
|
70
|
+
'packets/sec': {
|
|
71
|
+
group: THROUGHPUT_GROUP,
|
|
72
|
+
label: 'Packets/sec'
|
|
73
|
+
},
|
|
74
|
+
'reads/sec': {
|
|
75
|
+
group: THROUGHPUT_GROUP,
|
|
76
|
+
label: 'Reads/sec'
|
|
77
|
+
},
|
|
78
|
+
'requests/sec': {
|
|
79
|
+
group: THROUGHPUT_GROUP,
|
|
80
|
+
label: 'Requests/sec'
|
|
81
|
+
},
|
|
82
|
+
'records/sec': {
|
|
83
|
+
group: THROUGHPUT_GROUP,
|
|
84
|
+
label: 'Records/sec'
|
|
85
|
+
},
|
|
86
|
+
'rows/sec': {
|
|
87
|
+
group: THROUGHPUT_GROUP,
|
|
88
|
+
label: 'Rows/sec'
|
|
89
|
+
},
|
|
90
|
+
'writes/sec': {
|
|
91
|
+
group: THROUGHPUT_GROUP,
|
|
92
|
+
label: 'Writes/sec'
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function formatThroughput(value, { unit, shortValues, decimalPlaces }) {
|
|
96
|
+
const formatterOptions = {
|
|
97
|
+
style: 'decimal',
|
|
98
|
+
useGrouping: true
|
|
99
|
+
};
|
|
100
|
+
if ((0, _utils.shouldShortenValues)(shortValues)) {
|
|
101
|
+
formatterOptions.notation = 'compact';
|
|
102
|
+
}
|
|
103
|
+
if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
|
|
104
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
105
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
106
|
+
} else {
|
|
107
|
+
if ((0, _utils.shouldShortenValues)(shortValues)) {
|
|
108
|
+
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
const formatter = Intl.NumberFormat('en-US', formatterOptions);
|
|
112
|
+
return formatter.format(value) + ' ' + unit;
|
|
113
|
+
}
|
|
@@ -21,85 +21,146 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
PersesTimeToIntlTime: ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
PersesTimeToIntlTime: function() {
|
|
25
|
+
return PersesTimeToIntlTime;
|
|
26
|
+
},
|
|
27
|
+
TIME_GROUP_CONFIG: function() {
|
|
28
|
+
return TIME_GROUP_CONFIG;
|
|
29
|
+
},
|
|
30
|
+
TIME_UNIT_CONFIG: function() {
|
|
31
|
+
return TIME_UNIT_CONFIG;
|
|
32
|
+
},
|
|
33
|
+
formatTime: function() {
|
|
34
|
+
return formatTime;
|
|
35
|
+
}
|
|
28
36
|
});
|
|
29
37
|
const _constants = require("./constants");
|
|
30
38
|
const _utils = require("./utils");
|
|
31
|
-
const
|
|
32
|
-
'
|
|
33
|
-
'
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'
|
|
37
|
-
'
|
|
38
|
-
'
|
|
39
|
-
'
|
|
39
|
+
const timeUnits = [
|
|
40
|
+
'milliseconds',
|
|
41
|
+
'seconds',
|
|
42
|
+
'minutes',
|
|
43
|
+
'hours',
|
|
44
|
+
'days',
|
|
45
|
+
'weeks',
|
|
46
|
+
'months',
|
|
47
|
+
'years'
|
|
40
48
|
];
|
|
41
49
|
const TIME_GROUP = 'Time';
|
|
42
50
|
const TIME_GROUP_CONFIG = {
|
|
43
51
|
label: 'Time',
|
|
44
|
-
|
|
52
|
+
decimalPlaces: true
|
|
45
53
|
};
|
|
46
54
|
const TIME_UNIT_CONFIG = {
|
|
47
|
-
|
|
55
|
+
milliseconds: {
|
|
48
56
|
group: TIME_GROUP,
|
|
49
57
|
label: 'Milliseconds'
|
|
50
58
|
},
|
|
51
|
-
|
|
59
|
+
seconds: {
|
|
52
60
|
group: TIME_GROUP,
|
|
53
61
|
label: 'Seconds'
|
|
54
62
|
},
|
|
55
|
-
|
|
63
|
+
minutes: {
|
|
56
64
|
group: TIME_GROUP,
|
|
57
65
|
label: 'Minutes'
|
|
58
66
|
},
|
|
59
|
-
|
|
67
|
+
hours: {
|
|
60
68
|
group: TIME_GROUP,
|
|
61
69
|
label: 'Hours'
|
|
62
70
|
},
|
|
63
|
-
|
|
71
|
+
days: {
|
|
64
72
|
group: TIME_GROUP,
|
|
65
73
|
label: 'Days'
|
|
66
74
|
},
|
|
67
|
-
|
|
75
|
+
weeks: {
|
|
68
76
|
group: TIME_GROUP,
|
|
69
77
|
label: 'Weeks'
|
|
70
78
|
},
|
|
71
|
-
|
|
79
|
+
months: {
|
|
72
80
|
group: TIME_GROUP,
|
|
73
81
|
label: 'Months'
|
|
74
82
|
},
|
|
75
|
-
|
|
83
|
+
years: {
|
|
76
84
|
group: TIME_GROUP,
|
|
77
85
|
label: 'Years'
|
|
78
86
|
}
|
|
79
87
|
};
|
|
80
88
|
var PersesTimeToIntlTime;
|
|
81
89
|
(function(PersesTimeToIntlTime) {
|
|
82
|
-
PersesTimeToIntlTime["
|
|
83
|
-
PersesTimeToIntlTime["
|
|
84
|
-
PersesTimeToIntlTime["
|
|
85
|
-
PersesTimeToIntlTime["
|
|
86
|
-
PersesTimeToIntlTime["
|
|
87
|
-
PersesTimeToIntlTime["
|
|
88
|
-
PersesTimeToIntlTime["
|
|
89
|
-
PersesTimeToIntlTime["
|
|
90
|
+
PersesTimeToIntlTime["milliseconds"] = "millisecond";
|
|
91
|
+
PersesTimeToIntlTime["seconds"] = "second";
|
|
92
|
+
PersesTimeToIntlTime["minutes"] = "minute";
|
|
93
|
+
PersesTimeToIntlTime["hours"] = "hour";
|
|
94
|
+
PersesTimeToIntlTime["days"] = "day";
|
|
95
|
+
PersesTimeToIntlTime["weeks"] = "week";
|
|
96
|
+
PersesTimeToIntlTime["months"] = "month";
|
|
97
|
+
PersesTimeToIntlTime["years"] = "year";
|
|
90
98
|
})(PersesTimeToIntlTime || (PersesTimeToIntlTime = {}));
|
|
91
|
-
|
|
92
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Note: This conversion will not be exactly accurate for months and years,
|
|
101
|
+
* due variations in the lengths of months (i.e. 28 - 31 days) and years (i.e. leap years).
|
|
102
|
+
* For precision with months and years, we would need more complex algorithms and/or external libraries.
|
|
103
|
+
* However, we expect that measurements in months and years will be rare.
|
|
104
|
+
*/ const TIME_UNITS_IN_SECONDS = {
|
|
105
|
+
years: 31536000,
|
|
106
|
+
months: 2592000,
|
|
107
|
+
weeks: 604800,
|
|
108
|
+
days: 86400,
|
|
109
|
+
hours: 3600,
|
|
110
|
+
minutes: 60,
|
|
111
|
+
seconds: 1,
|
|
112
|
+
milliseconds: 0.001
|
|
113
|
+
};
|
|
114
|
+
const LARGEST_TO_SMALLEST_TIME_UNITS = [
|
|
115
|
+
'years',
|
|
116
|
+
'months',
|
|
117
|
+
'weeks',
|
|
118
|
+
'days',
|
|
119
|
+
'hours',
|
|
120
|
+
'minutes',
|
|
121
|
+
'seconds',
|
|
122
|
+
'milliseconds'
|
|
123
|
+
];
|
|
124
|
+
/**
|
|
125
|
+
* Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.
|
|
126
|
+
*/ function getValueAndKindForNaturalNumbers(value, unit) {
|
|
127
|
+
const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];
|
|
128
|
+
// Initialize for TS
|
|
129
|
+
const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';
|
|
130
|
+
let timeUnit = largestTimeUnit;
|
|
131
|
+
let valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];
|
|
132
|
+
for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS){
|
|
133
|
+
valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[timeUnit];
|
|
134
|
+
if (valueInTimeUnit >= 1) {
|
|
135
|
+
return {
|
|
136
|
+
value: valueInTimeUnit,
|
|
137
|
+
unit: timeUnit
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).
|
|
142
|
+
return {
|
|
143
|
+
value: valueInTimeUnit,
|
|
144
|
+
unit: timeUnit
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
function isMonthOrYear(unit) {
|
|
148
|
+
return unit === 'months' || unit === 'years';
|
|
149
|
+
}
|
|
150
|
+
function formatTime(value, { unit, decimalPlaces }) {
|
|
151
|
+
if (value === 0) return '0s';
|
|
152
|
+
const results = getValueAndKindForNaturalNumbers(value, unit);
|
|
93
153
|
const formatterOptions = {
|
|
94
154
|
style: 'unit',
|
|
95
|
-
unit: PersesTimeToIntlTime[
|
|
96
|
-
unitDisplay: isMonthOrYear ? 'long' : 'narrow'
|
|
155
|
+
unit: PersesTimeToIntlTime[results.unit],
|
|
156
|
+
unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow'
|
|
97
157
|
};
|
|
98
|
-
if ((0, _utils.hasDecimalPlaces)(
|
|
99
|
-
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(
|
|
100
|
-
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(
|
|
158
|
+
if ((0, _utils.hasDecimalPlaces)(decimalPlaces)) {
|
|
159
|
+
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
160
|
+
formatterOptions.maximumFractionDigits = (0, _utils.limitDecimalPlaces)(decimalPlaces);
|
|
101
161
|
} else {
|
|
102
162
|
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
103
163
|
}
|
|
104
|
-
|
|
164
|
+
const formatter = Intl.NumberFormat('en-US', formatterOptions);
|
|
165
|
+
return formatter.format(results.value);
|
|
105
166
|
}
|
|
@@ -18,11 +18,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "UNIT_GROUPS", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: ()
|
|
21
|
+
get: function() {
|
|
22
|
+
return UNIT_GROUPS;
|
|
23
|
+
}
|
|
22
24
|
});
|
|
23
25
|
const UNIT_GROUPS = [
|
|
24
26
|
'Time',
|
|
25
27
|
'Percent',
|
|
26
28
|
'Decimal',
|
|
27
|
-
'Bytes'
|
|
29
|
+
'Bytes',
|
|
30
|
+
'Throughput'
|
|
28
31
|
];
|
|
@@ -21,81 +21,117 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
UNIT_CONFIG: function() {
|
|
25
|
+
return UNIT_CONFIG;
|
|
26
|
+
},
|
|
27
|
+
UNIT_GROUP_CONFIG: function() {
|
|
28
|
+
return UNIT_GROUP_CONFIG;
|
|
29
|
+
},
|
|
30
|
+
formatValue: function() {
|
|
31
|
+
return formatValue;
|
|
32
|
+
},
|
|
33
|
+
getUnitConfig: function() {
|
|
34
|
+
return getUnitConfig;
|
|
35
|
+
},
|
|
36
|
+
getUnitGroup: function() {
|
|
37
|
+
return getUnitGroup;
|
|
38
|
+
},
|
|
39
|
+
getUnitGroupConfig: function() {
|
|
40
|
+
return getUnitGroupConfig;
|
|
41
|
+
},
|
|
42
|
+
isBytesUnit: function() {
|
|
43
|
+
return isBytesUnit;
|
|
44
|
+
},
|
|
45
|
+
isDecimalUnit: function() {
|
|
46
|
+
return isDecimalUnit;
|
|
47
|
+
},
|
|
48
|
+
isPercentUnit: function() {
|
|
49
|
+
return isPercentUnit;
|
|
50
|
+
},
|
|
51
|
+
isThroughputUnit: function() {
|
|
52
|
+
return isThroughputUnit;
|
|
53
|
+
},
|
|
54
|
+
isTimeUnit: function() {
|
|
55
|
+
return isTimeUnit;
|
|
56
|
+
},
|
|
57
|
+
isUnitWithDecimalPlaces: function() {
|
|
58
|
+
return isUnitWithDecimalPlaces;
|
|
59
|
+
},
|
|
60
|
+
isUnitWithShortValues: function() {
|
|
61
|
+
return isUnitWithShortValues;
|
|
62
|
+
}
|
|
36
63
|
});
|
|
37
64
|
const _bytes = require("./bytes");
|
|
38
65
|
const _decimal = require("./decimal");
|
|
39
66
|
const _percent = require("./percent");
|
|
40
67
|
const _time = require("./time");
|
|
68
|
+
const _throughput = require("./throughput");
|
|
41
69
|
const UNIT_GROUP_CONFIG = {
|
|
42
70
|
Time: _time.TIME_GROUP_CONFIG,
|
|
43
71
|
Percent: _percent.PERCENT_GROUP_CONFIG,
|
|
44
72
|
Decimal: _decimal.DECIMAL_GROUP_CONFIG,
|
|
45
|
-
Bytes: _bytes.BYTES_GROUP_CONFIG
|
|
73
|
+
Bytes: _bytes.BYTES_GROUP_CONFIG,
|
|
74
|
+
Throughput: _throughput.THROUGHPUT_GROUP_CONFIG
|
|
46
75
|
};
|
|
47
76
|
const UNIT_CONFIG = {
|
|
48
77
|
..._time.TIME_UNIT_CONFIG,
|
|
49
78
|
..._percent.PERCENT_UNIT_CONFIG,
|
|
50
79
|
..._decimal.DECIMAL_UNIT_CONFIG,
|
|
51
|
-
..._bytes.BYTES_UNIT_CONFIG
|
|
80
|
+
..._bytes.BYTES_UNIT_CONFIG,
|
|
81
|
+
..._throughput.THROUGHPUT_UNIT_CONFIG
|
|
52
82
|
};
|
|
53
|
-
function formatValue(value,
|
|
54
|
-
if (
|
|
83
|
+
function formatValue(value, formatOptions) {
|
|
84
|
+
if (formatOptions === undefined) {
|
|
55
85
|
return value.toString();
|
|
56
86
|
}
|
|
57
|
-
if (
|
|
58
|
-
return (0,
|
|
87
|
+
if (isBytesUnit(formatOptions)) {
|
|
88
|
+
return (0, _bytes.formatBytes)(value, formatOptions);
|
|
89
|
+
}
|
|
90
|
+
if (isDecimalUnit(formatOptions)) {
|
|
91
|
+
return (0, _decimal.formatDecimal)(value, formatOptions);
|
|
59
92
|
}
|
|
60
|
-
if (
|
|
61
|
-
return (0,
|
|
93
|
+
if (isPercentUnit(formatOptions)) {
|
|
94
|
+
return (0, _percent.formatPercent)(value, formatOptions);
|
|
62
95
|
}
|
|
63
|
-
if (
|
|
64
|
-
return (0,
|
|
96
|
+
if (isTimeUnit(formatOptions)) {
|
|
97
|
+
return (0, _time.formatTime)(value, formatOptions);
|
|
65
98
|
}
|
|
66
|
-
if (
|
|
67
|
-
return (0,
|
|
99
|
+
if (isThroughputUnit(formatOptions)) {
|
|
100
|
+
return (0, _throughput.formatThroughput)(value, formatOptions);
|
|
68
101
|
}
|
|
69
|
-
const exhaustive =
|
|
102
|
+
const exhaustive = formatOptions;
|
|
70
103
|
throw new Error(`Unknown unit options ${exhaustive}`);
|
|
71
104
|
}
|
|
72
|
-
function
|
|
73
|
-
return UNIT_CONFIG[
|
|
105
|
+
function getUnitConfig(formatOptions) {
|
|
106
|
+
return UNIT_CONFIG[formatOptions.unit];
|
|
74
107
|
}
|
|
75
|
-
function getUnitGroup(
|
|
76
|
-
return
|
|
108
|
+
function getUnitGroup(formatOptions) {
|
|
109
|
+
return getUnitConfig(formatOptions).group;
|
|
77
110
|
}
|
|
78
|
-
function getUnitGroupConfig(
|
|
79
|
-
const unitConfig =
|
|
111
|
+
function getUnitGroupConfig(formatOptions) {
|
|
112
|
+
const unitConfig = getUnitConfig(formatOptions);
|
|
80
113
|
return UNIT_GROUP_CONFIG[unitConfig.group];
|
|
81
114
|
}
|
|
82
|
-
function isTimeUnit(
|
|
83
|
-
return getUnitGroup(
|
|
115
|
+
function isTimeUnit(formatOptions) {
|
|
116
|
+
return getUnitGroup(formatOptions) === 'Time';
|
|
117
|
+
}
|
|
118
|
+
function isPercentUnit(formatOptions) {
|
|
119
|
+
return getUnitGroup(formatOptions) === 'Percent';
|
|
84
120
|
}
|
|
85
|
-
function
|
|
86
|
-
return getUnitGroup(
|
|
121
|
+
function isDecimalUnit(formatOptions) {
|
|
122
|
+
return getUnitGroup(formatOptions) === 'Decimal';
|
|
87
123
|
}
|
|
88
|
-
function
|
|
89
|
-
return getUnitGroup(
|
|
124
|
+
function isBytesUnit(formatOptions) {
|
|
125
|
+
return getUnitGroup(formatOptions) === 'Bytes';
|
|
90
126
|
}
|
|
91
|
-
function
|
|
92
|
-
|
|
127
|
+
function isUnitWithDecimalPlaces(formatOptions) {
|
|
128
|
+
const groupConfig = getUnitGroupConfig(formatOptions);
|
|
129
|
+
return !!groupConfig.decimalPlaces;
|
|
93
130
|
}
|
|
94
|
-
function
|
|
95
|
-
const groupConfig = getUnitGroupConfig(
|
|
96
|
-
return !!groupConfig.
|
|
131
|
+
function isUnitWithShortValues(formatOptions) {
|
|
132
|
+
const groupConfig = getUnitGroupConfig(formatOptions);
|
|
133
|
+
return !!groupConfig.shortValues;
|
|
97
134
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
100
|
-
return !!groupConfig.abbreviate;
|
|
135
|
+
function isThroughputUnit(formatOptions) {
|
|
136
|
+
return getUnitGroup(formatOptions) == 'Throughput';
|
|
101
137
|
}
|
|
@@ -21,15 +21,21 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
hasDecimalPlaces: function() {
|
|
25
|
+
return hasDecimalPlaces;
|
|
26
|
+
},
|
|
27
|
+
limitDecimalPlaces: function() {
|
|
28
|
+
return limitDecimalPlaces;
|
|
29
|
+
},
|
|
30
|
+
shouldShortenValues: function() {
|
|
31
|
+
return shouldShortenValues;
|
|
32
|
+
}
|
|
27
33
|
});
|
|
28
|
-
function
|
|
29
|
-
return
|
|
34
|
+
function shouldShortenValues(shortValues) {
|
|
35
|
+
return shortValues !== false;
|
|
30
36
|
}
|
|
31
|
-
function hasDecimalPlaces(
|
|
32
|
-
return typeof
|
|
37
|
+
function hasDecimalPlaces(decimalPlaces) {
|
|
38
|
+
return typeof decimalPlaces === 'number';
|
|
33
39
|
}
|
|
34
40
|
function limitDecimalPlaces(num) {
|
|
35
41
|
if (!num) return num;
|
|
@@ -14,8 +14,21 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
DEFAULT_ALL_VALUE: function() {
|
|
25
|
+
return DEFAULT_ALL_VALUE;
|
|
26
|
+
},
|
|
27
|
+
getVariableProject: function() {
|
|
28
|
+
return getVariableProject;
|
|
29
|
+
}
|
|
20
30
|
});
|
|
31
|
+
function getVariableProject(variable) {
|
|
32
|
+
return 'project' in variable.metadata ? variable.metadata.project : undefined;
|
|
33
|
+
}
|
|
21
34
|
const DEFAULT_ALL_VALUE = '$__all';
|
package/dist/cjs/utils/event.js
CHANGED
|
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "useEvent", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return useEvent;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
23
|
const _react = require("react");
|
|
22
24
|
function useEvent(handler) {
|
package/dist/cjs/utils/fetch.js
CHANGED
|
@@ -23,20 +23,41 @@ function _export(target, all) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
_export(exports, {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
UserFriendlyError: ()
|
|
26
|
+
FetchError: function() {
|
|
27
|
+
return FetchError;
|
|
28
|
+
},
|
|
29
|
+
UserFriendlyError: function() {
|
|
30
|
+
return UserFriendlyError;
|
|
31
|
+
},
|
|
32
|
+
fetch: function() {
|
|
33
|
+
return fetch;
|
|
34
|
+
},
|
|
35
|
+
fetchJson: function() {
|
|
36
|
+
return fetchJson;
|
|
37
|
+
}
|
|
30
38
|
});
|
|
39
|
+
function _define_property(obj, key, value) {
|
|
40
|
+
if (key in obj) {
|
|
41
|
+
Object.defineProperty(obj, key, {
|
|
42
|
+
value: value,
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true,
|
|
45
|
+
writable: true
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
obj[key] = value;
|
|
49
|
+
}
|
|
50
|
+
return obj;
|
|
51
|
+
}
|
|
31
52
|
async function fetch(...args) {
|
|
32
53
|
const response = await global.fetch(...args);
|
|
33
54
|
if (response.ok === false) {
|
|
34
55
|
const json = await response.json();
|
|
35
56
|
if (json.error) {
|
|
36
|
-
throw new UserFriendlyError(json.error);
|
|
57
|
+
throw new UserFriendlyError(json.error, response.status);
|
|
37
58
|
}
|
|
38
59
|
if (json.message) {
|
|
39
|
-
throw new UserFriendlyError(json.message);
|
|
60
|
+
throw new UserFriendlyError(json.message, response.status);
|
|
40
61
|
}
|
|
41
62
|
throw new FetchError(response);
|
|
42
63
|
}
|
|
@@ -50,12 +71,16 @@ async function fetchJson(...args) {
|
|
|
50
71
|
class FetchError extends Error {
|
|
51
72
|
constructor(response){
|
|
52
73
|
super(`${response.status} ${response.statusText}`);
|
|
74
|
+
_define_property(this, "status", void 0);
|
|
75
|
+
this.status = response.status;
|
|
53
76
|
Object.setPrototypeOf(this, FetchError.prototype);
|
|
54
77
|
}
|
|
55
78
|
}
|
|
56
79
|
class UserFriendlyError extends Error {
|
|
57
|
-
constructor(message){
|
|
80
|
+
constructor(message, status){
|
|
58
81
|
super(message);
|
|
82
|
+
_define_property(this, "status", void 0);
|
|
83
|
+
this.status = status;
|
|
59
84
|
Object.setPrototypeOf(this, UserFriendlyError.prototype);
|
|
60
85
|
}
|
|
61
86
|
}
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -14,21 +14,24 @@
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", {
|
|
15
15
|
value: true
|
|
16
16
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
_export_star(require("./event"), exports);
|
|
18
|
+
_export_star(require("./fetch"), exports);
|
|
19
|
+
_export_star(require("./is-empty-object"), exports);
|
|
20
|
+
_export_star(require("./memo"), exports);
|
|
21
|
+
_export_star(require("./panel-refs"), exports);
|
|
22
|
+
_export_star(require("./text"), exports);
|
|
23
|
+
_export_star(require("./time-series-data"), exports);
|
|
24
|
+
_export_star(require("./types"), exports);
|
|
25
|
+
function _export_star(from, to) {
|
|
25
26
|
Object.keys(from).forEach(function(k) {
|
|
26
|
-
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k))
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
28
|
+
Object.defineProperty(to, k, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function() {
|
|
31
|
+
return from[k];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
36
|
return from;
|
|
34
37
|
}
|
|
@@ -18,7 +18,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "isEmptyObject", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: ()
|
|
21
|
+
get: function() {
|
|
22
|
+
return isEmptyObject;
|
|
23
|
+
}
|
|
22
24
|
});
|
|
23
25
|
function isEmptyObject(obj) {
|
|
24
26
|
return Object.getOwnPropertyNames(obj).length === 0;
|