@perses-dev/core 0.39.0 → 0.40.1
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 -49
- package/dist/cjs/model/index.js +28 -26
- package/dist/cjs/model/legend.js +39 -19
- package/dist/cjs/model/resource.js +9 -0
- package/dist/cjs/model/time-series-queries.js +3 -1
- package/dist/cjs/model/time.js +147 -64
- package/dist/cjs/model/units/bytes.js +26 -20
- package/dist/cjs/model/units/constants.js +3 -1
- package/dist/cjs/model/units/decimal.js +20 -14
- package/dist/cjs/model/units/index.js +13 -11
- package/dist/cjs/model/units/percent.js +21 -15
- package/dist/cjs/model/units/time.js +68 -60
- package/dist/cjs/model/units/types.js +3 -1
- package/dist/cjs/model/units/units.js +67 -43
- 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 +12 -4
- package/dist/cjs/utils/index.js +17 -14
- package/dist/cjs/utils/is-empty-object.js +3 -1
- package/dist/cjs/utils/mathjs.js +3 -1
- 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 +9 -8
- package/dist/model/calculations.d.ts.map +1 -1
- package/dist/model/calculations.js +46 -45
- package/dist/model/calculations.js.map +1 -1
- package/dist/model/datasource.d.ts +19 -3
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.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/index.js.map +1 -1
- package/dist/model/legend.d.ts +6 -6
- 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.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/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-queries.js.map +1 -1
- package/dist/model/time.d.ts +3 -0
- package/dist/model/time.d.ts.map +1 -1
- package/dist/model/time.js +115 -55
- package/dist/model/time.js.map +1 -1
- 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 +16 -16
- 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 +12 -12
- 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 +12 -12
- package/dist/model/units/percent.js.map +1 -1
- 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 +56 -56
- package/dist/model/units/time.js.map +1 -1
- package/dist/model/units/types.d.ts +14 -5
- package/dist/model/units/types.d.ts.map +1 -1
- package/dist/model/units/types.js.map +1 -1
- package/dist/model/units/units.d.ts +30 -30
- package/dist/model/units/units.d.ts.map +1 -1
- package/dist/model/units/units.js +31 -31
- 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 +25 -7
- 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.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.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 +5 -5
- 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.js +6 -6
- 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
|
@@ -21,72 +21,80 @@ 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
99
|
/**
|
|
92
100
|
* Note: This conversion will not be exactly accurate for months and years,
|
|
@@ -94,31 +102,31 @@ var PersesTimeToIntlTime;
|
|
|
94
102
|
* For precision with months and years, we would need more complex algorithms and/or external libraries.
|
|
95
103
|
* However, we expect that measurements in months and years will be rare.
|
|
96
104
|
*/ const TIME_UNITS_IN_SECONDS = {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
|
105
113
|
};
|
|
106
114
|
const LARGEST_TO_SMALLEST_TIME_UNITS = [
|
|
107
|
-
'
|
|
108
|
-
'
|
|
109
|
-
'
|
|
110
|
-
'
|
|
111
|
-
'
|
|
112
|
-
'
|
|
113
|
-
'
|
|
114
|
-
'
|
|
115
|
+
'years',
|
|
116
|
+
'months',
|
|
117
|
+
'weeks',
|
|
118
|
+
'days',
|
|
119
|
+
'hours',
|
|
120
|
+
'minutes',
|
|
121
|
+
'seconds',
|
|
122
|
+
'milliseconds'
|
|
115
123
|
];
|
|
116
124
|
/**
|
|
117
125
|
* Choose the first time unit that produces a number greater than 1, starting from the biggest time unit.
|
|
118
|
-
*/ function getValueAndKindForNaturalNumbers(value,
|
|
119
|
-
const valueInSeconds = value * TIME_UNITS_IN_SECONDS[
|
|
126
|
+
*/ function getValueAndKindForNaturalNumbers(value, unit) {
|
|
127
|
+
const valueInSeconds = value * TIME_UNITS_IN_SECONDS[unit];
|
|
120
128
|
// Initialize for TS
|
|
121
|
-
const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || '
|
|
129
|
+
const largestTimeUnit = LARGEST_TO_SMALLEST_TIME_UNITS[0] || 'years';
|
|
122
130
|
let timeUnit = largestTimeUnit;
|
|
123
131
|
let valueInTimeUnit = valueInSeconds / TIME_UNITS_IN_SECONDS[largestTimeUnit];
|
|
124
132
|
for (timeUnit of LARGEST_TO_SMALLEST_TIME_UNITS){
|
|
@@ -126,30 +134,30 @@ const LARGEST_TO_SMALLEST_TIME_UNITS = [
|
|
|
126
134
|
if (valueInTimeUnit >= 1) {
|
|
127
135
|
return {
|
|
128
136
|
value: valueInTimeUnit,
|
|
129
|
-
|
|
137
|
+
unit: timeUnit
|
|
130
138
|
};
|
|
131
139
|
}
|
|
132
140
|
}
|
|
133
141
|
// If we didn't find a time unit, we have to settle for the smallest time unit (which is the last time unit).
|
|
134
142
|
return {
|
|
135
143
|
value: valueInTimeUnit,
|
|
136
|
-
|
|
144
|
+
unit: timeUnit
|
|
137
145
|
};
|
|
138
146
|
}
|
|
139
|
-
function isMonthOrYear(
|
|
140
|
-
return
|
|
147
|
+
function isMonthOrYear(unit) {
|
|
148
|
+
return unit === 'months' || unit === 'years';
|
|
141
149
|
}
|
|
142
|
-
function formatTime(value, {
|
|
150
|
+
function formatTime(value, { unit , decimalPlaces }) {
|
|
143
151
|
if (value === 0) return '0s';
|
|
144
|
-
const results = getValueAndKindForNaturalNumbers(value,
|
|
152
|
+
const results = getValueAndKindForNaturalNumbers(value, unit);
|
|
145
153
|
const formatterOptions = {
|
|
146
154
|
style: 'unit',
|
|
147
|
-
unit: PersesTimeToIntlTime[results.
|
|
148
|
-
unitDisplay: isMonthOrYear(results.
|
|
155
|
+
unit: PersesTimeToIntlTime[results.unit],
|
|
156
|
+
unitDisplay: isMonthOrYear(results.unit) ? 'long' : 'narrow'
|
|
149
157
|
};
|
|
150
|
-
if ((0, _utils.hasDecimalPlaces)(
|
|
151
|
-
formatterOptions.minimumFractionDigits = (0, _utils.limitDecimalPlaces)(
|
|
152
|
-
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);
|
|
153
161
|
} else {
|
|
154
162
|
formatterOptions.maximumSignificantDigits = _constants.MAX_SIGNIFICANT_DIGITS;
|
|
155
163
|
}
|
|
@@ -21,18 +21,42 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
UNIT_GROUP_CONFIG: ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
24
|
+
UNIT_GROUP_CONFIG: function() {
|
|
25
|
+
return UNIT_GROUP_CONFIG;
|
|
26
|
+
},
|
|
27
|
+
UNIT_CONFIG: function() {
|
|
28
|
+
return UNIT_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
|
+
isTimeUnit: function() {
|
|
43
|
+
return isTimeUnit;
|
|
44
|
+
},
|
|
45
|
+
isPercentUnit: function() {
|
|
46
|
+
return isPercentUnit;
|
|
47
|
+
},
|
|
48
|
+
isDecimalUnit: function() {
|
|
49
|
+
return isDecimalUnit;
|
|
50
|
+
},
|
|
51
|
+
isBytesUnit: function() {
|
|
52
|
+
return isBytesUnit;
|
|
53
|
+
},
|
|
54
|
+
isUnitWithDecimalPlaces: function() {
|
|
55
|
+
return isUnitWithDecimalPlaces;
|
|
56
|
+
},
|
|
57
|
+
isUnitWithShortValues: function() {
|
|
58
|
+
return isUnitWithShortValues;
|
|
59
|
+
}
|
|
36
60
|
});
|
|
37
61
|
const _bytes = require("./bytes");
|
|
38
62
|
const _decimal = require("./decimal");
|
|
@@ -50,52 +74,52 @@ const UNIT_CONFIG = {
|
|
|
50
74
|
..._decimal.DECIMAL_UNIT_CONFIG,
|
|
51
75
|
..._bytes.BYTES_UNIT_CONFIG
|
|
52
76
|
};
|
|
53
|
-
function formatValue(value,
|
|
54
|
-
if (
|
|
77
|
+
function formatValue(value, formatOptions) {
|
|
78
|
+
if (formatOptions === undefined) {
|
|
55
79
|
return value.toString();
|
|
56
80
|
}
|
|
57
|
-
if (isBytesUnit(
|
|
58
|
-
return (0, _bytes.formatBytes)(value,
|
|
81
|
+
if (isBytesUnit(formatOptions)) {
|
|
82
|
+
return (0, _bytes.formatBytes)(value, formatOptions);
|
|
59
83
|
}
|
|
60
|
-
if (isDecimalUnit(
|
|
61
|
-
return (0, _decimal.formatDecimal)(value,
|
|
84
|
+
if (isDecimalUnit(formatOptions)) {
|
|
85
|
+
return (0, _decimal.formatDecimal)(value, formatOptions);
|
|
62
86
|
}
|
|
63
|
-
if (isPercentUnit(
|
|
64
|
-
return (0, _percent.formatPercent)(value,
|
|
87
|
+
if (isPercentUnit(formatOptions)) {
|
|
88
|
+
return (0, _percent.formatPercent)(value, formatOptions);
|
|
65
89
|
}
|
|
66
|
-
if (isTimeUnit(
|
|
67
|
-
return (0, _time.formatTime)(value,
|
|
90
|
+
if (isTimeUnit(formatOptions)) {
|
|
91
|
+
return (0, _time.formatTime)(value, formatOptions);
|
|
68
92
|
}
|
|
69
|
-
const exhaustive =
|
|
93
|
+
const exhaustive = formatOptions;
|
|
70
94
|
throw new Error(`Unknown unit options ${exhaustive}`);
|
|
71
95
|
}
|
|
72
|
-
function
|
|
73
|
-
return UNIT_CONFIG[
|
|
96
|
+
function getUnitConfig(formatOptions) {
|
|
97
|
+
return UNIT_CONFIG[formatOptions.unit];
|
|
74
98
|
}
|
|
75
|
-
function getUnitGroup(
|
|
76
|
-
return
|
|
99
|
+
function getUnitGroup(formatOptions) {
|
|
100
|
+
return getUnitConfig(formatOptions).group;
|
|
77
101
|
}
|
|
78
|
-
function getUnitGroupConfig(
|
|
79
|
-
const unitConfig =
|
|
102
|
+
function getUnitGroupConfig(formatOptions) {
|
|
103
|
+
const unitConfig = getUnitConfig(formatOptions);
|
|
80
104
|
return UNIT_GROUP_CONFIG[unitConfig.group];
|
|
81
105
|
}
|
|
82
|
-
function isTimeUnit(
|
|
83
|
-
return getUnitGroup(
|
|
106
|
+
function isTimeUnit(formatOptions) {
|
|
107
|
+
return getUnitGroup(formatOptions) === 'Time';
|
|
84
108
|
}
|
|
85
|
-
function isPercentUnit(
|
|
86
|
-
return getUnitGroup(
|
|
109
|
+
function isPercentUnit(formatOptions) {
|
|
110
|
+
return getUnitGroup(formatOptions) === 'Percent';
|
|
87
111
|
}
|
|
88
|
-
function isDecimalUnit(
|
|
89
|
-
return getUnitGroup(
|
|
112
|
+
function isDecimalUnit(formatOptions) {
|
|
113
|
+
return getUnitGroup(formatOptions) === 'Decimal';
|
|
90
114
|
}
|
|
91
|
-
function isBytesUnit(
|
|
92
|
-
return getUnitGroup(
|
|
115
|
+
function isBytesUnit(formatOptions) {
|
|
116
|
+
return getUnitGroup(formatOptions) === 'Bytes';
|
|
93
117
|
}
|
|
94
|
-
function isUnitWithDecimalPlaces(
|
|
95
|
-
const groupConfig = getUnitGroupConfig(
|
|
96
|
-
return !!groupConfig.
|
|
118
|
+
function isUnitWithDecimalPlaces(formatOptions) {
|
|
119
|
+
const groupConfig = getUnitGroupConfig(formatOptions);
|
|
120
|
+
return !!groupConfig.decimalPlaces;
|
|
97
121
|
}
|
|
98
|
-
function
|
|
99
|
-
const groupConfig = getUnitGroupConfig(
|
|
100
|
-
return !!groupConfig.
|
|
122
|
+
function isUnitWithShortValues(formatOptions) {
|
|
123
|
+
const groupConfig = getUnitGroupConfig(formatOptions);
|
|
124
|
+
return !!groupConfig.shortValues;
|
|
101
125
|
}
|
|
@@ -21,15 +21,21 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
shouldShortenValues: function() {
|
|
25
|
+
return shouldShortenValues;
|
|
26
|
+
},
|
|
27
|
+
hasDecimalPlaces: function() {
|
|
28
|
+
return hasDecimalPlaces;
|
|
29
|
+
},
|
|
30
|
+
limitDecimalPlaces: function() {
|
|
31
|
+
return limitDecimalPlaces;
|
|
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
|
+
getVariableProject: function() {
|
|
25
|
+
return getVariableProject;
|
|
26
|
+
},
|
|
27
|
+
DEFAULT_ALL_VALUE: function() {
|
|
28
|
+
return DEFAULT_ALL_VALUE;
|
|
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,10 +23,18 @@ function _export(target, all) {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
_export(exports, {
|
|
26
|
-
fetch: ()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
fetch: function() {
|
|
27
|
+
return fetch;
|
|
28
|
+
},
|
|
29
|
+
fetchJson: function() {
|
|
30
|
+
return fetchJson;
|
|
31
|
+
},
|
|
32
|
+
FetchError: function() {
|
|
33
|
+
return FetchError;
|
|
34
|
+
},
|
|
35
|
+
UserFriendlyError: function() {
|
|
36
|
+
return UserFriendlyError;
|
|
37
|
+
}
|
|
30
38
|
});
|
|
31
39
|
async function fetch(...args) {
|
|
32
40
|
const response = await global.fetch(...args);
|
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;
|
package/dist/cjs/utils/mathjs.js
CHANGED
|
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "gcd", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: ()
|
|
19
|
+
get: function() {
|
|
20
|
+
return gcd;
|
|
21
|
+
}
|
|
20
22
|
});
|
|
21
23
|
const _mathjs = require("mathjs");
|
|
22
24
|
// This ensures we get a minimal mathjs bundle for just what we need (see https://mathjs.org/docs/custom_bundling.html)
|
package/dist/cjs/utils/memo.js
CHANGED
|
@@ -21,12 +21,16 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
useMemoized: ()
|
|
25
|
-
|
|
24
|
+
useMemoized: function() {
|
|
25
|
+
return useMemoized;
|
|
26
|
+
},
|
|
27
|
+
useDeepMemo: function() {
|
|
28
|
+
return useDeepMemo;
|
|
29
|
+
}
|
|
26
30
|
});
|
|
27
31
|
const _react = require("react");
|
|
28
|
-
const _isEqual = /*#__PURE__*/
|
|
29
|
-
function
|
|
32
|
+
const _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
|
|
33
|
+
function _interop_require_default(obj) {
|
|
30
34
|
return obj && obj.__esModule ? obj : {
|
|
31
35
|
default: obj
|
|
32
36
|
};
|
|
@@ -35,8 +39,8 @@ function useMemoized(factory, deps) {
|
|
|
35
39
|
const ref = (0, _react.useRef)();
|
|
36
40
|
let areEqual = true;
|
|
37
41
|
for(let i = 0; i < deps.length; i++){
|
|
38
|
-
var
|
|
39
|
-
if (((
|
|
42
|
+
var _ref_current;
|
|
43
|
+
if (((_ref_current = ref.current) === null || _ref_current === void 0 ? void 0 : _ref_current.deps[i]) !== deps[i]) {
|
|
40
44
|
areEqual = false;
|
|
41
45
|
break;
|
|
42
46
|
}
|
|
@@ -21,9 +21,15 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
resolvePanelRef: ()
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
resolvePanelRef: function() {
|
|
25
|
+
return resolvePanelRef;
|
|
26
|
+
},
|
|
27
|
+
getPanelKeyFromRef: function() {
|
|
28
|
+
return getPanelKeyFromRef;
|
|
29
|
+
},
|
|
30
|
+
createPanelRef: function() {
|
|
31
|
+
return createPanelRef;
|
|
32
|
+
}
|
|
27
33
|
});
|
|
28
34
|
function resolvePanelRef(spec, panelRef) {
|
|
29
35
|
const panelsKey = getPanelKeyFromRef(panelRef);
|
package/dist/cjs/utils/text.js
CHANGED
|
@@ -21,45 +21,57 @@ function _export(target, all) {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
_export(exports, {
|
|
24
|
-
getDashboardDisplayName: ()
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
getDashboardDisplayName: function() {
|
|
25
|
+
return getDashboardDisplayName;
|
|
26
|
+
},
|
|
27
|
+
getVariableDisplayName: function() {
|
|
28
|
+
return getVariableDisplayName;
|
|
29
|
+
},
|
|
30
|
+
getDatasourceDisplayName: function() {
|
|
31
|
+
return getDatasourceDisplayName;
|
|
32
|
+
},
|
|
33
|
+
getDashboardExtendedDisplayName: function() {
|
|
34
|
+
return getDashboardExtendedDisplayName;
|
|
35
|
+
},
|
|
36
|
+
getVariableExtendedDisplayName: function() {
|
|
37
|
+
return getVariableExtendedDisplayName;
|
|
38
|
+
},
|
|
39
|
+
getDatasourceExtendedDisplayName: function() {
|
|
40
|
+
return getDatasourceExtendedDisplayName;
|
|
41
|
+
}
|
|
30
42
|
});
|
|
31
43
|
function getDashboardDisplayName(dashboard) {
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
return (
|
|
44
|
+
var _dashboard_spec_display;
|
|
45
|
+
var _dashboard_spec_display_name;
|
|
46
|
+
return (_dashboard_spec_display_name = (_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) !== null && _dashboard_spec_display_name !== void 0 ? _dashboard_spec_display_name : dashboard.metadata.name;
|
|
35
47
|
}
|
|
36
48
|
function getVariableDisplayName(variable) {
|
|
37
|
-
var
|
|
38
|
-
var
|
|
39
|
-
return (
|
|
49
|
+
var _variable_spec_spec_display;
|
|
50
|
+
var _variable_spec_spec_display_name;
|
|
51
|
+
return (_variable_spec_spec_display_name = (_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) !== null && _variable_spec_spec_display_name !== void 0 ? _variable_spec_spec_display_name : variable.metadata.name;
|
|
40
52
|
}
|
|
41
53
|
function getDatasourceDisplayName(datasource) {
|
|
42
|
-
var
|
|
43
|
-
return ((
|
|
54
|
+
var _datasource_spec_display;
|
|
55
|
+
return ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) || datasource.metadata.name;
|
|
44
56
|
}
|
|
45
57
|
function getDashboardExtendedDisplayName(dashboard) {
|
|
46
|
-
var
|
|
47
|
-
if ((
|
|
58
|
+
var _dashboard_spec_display;
|
|
59
|
+
if ((_dashboard_spec_display = dashboard.spec.display) === null || _dashboard_spec_display === void 0 ? void 0 : _dashboard_spec_display.name) {
|
|
48
60
|
return `${dashboard.spec.display.name} (Name: ${dashboard.metadata.name})`;
|
|
49
61
|
}
|
|
50
62
|
return dashboard.metadata.name;
|
|
51
63
|
}
|
|
52
64
|
function getVariableExtendedDisplayName(variable) {
|
|
53
|
-
var
|
|
54
|
-
if ((
|
|
65
|
+
var _variable_spec_spec_display;
|
|
66
|
+
if ((_variable_spec_spec_display = variable.spec.spec.display) === null || _variable_spec_spec_display === void 0 ? void 0 : _variable_spec_spec_display.name) {
|
|
55
67
|
return `${variable.spec.spec.display.name} (Name: ${variable.metadata.name})`;
|
|
56
68
|
}
|
|
57
69
|
return variable.metadata.name;
|
|
58
70
|
}
|
|
59
71
|
function getDatasourceExtendedDisplayName(datasource) {
|
|
60
|
-
var
|
|
61
|
-
if ((
|
|
62
|
-
return `${datasource.spec.display.name} (
|
|
72
|
+
var _datasource_spec_display;
|
|
73
|
+
if ((_datasource_spec_display = datasource.spec.display) === null || _datasource_spec_display === void 0 ? void 0 : _datasource_spec_display.name) {
|
|
74
|
+
return `${datasource.spec.display.name} (Name: ${datasource.metadata.name})`;
|
|
63
75
|
}
|
|
64
76
|
return datasource.metadata.name;
|
|
65
77
|
}
|