@perses-dev/status-history-chart-plugin 0.13.0 → 0.14.0-beta.2

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 (148) hide show
  1. package/__mf/js/StatusHistoryChart.b562e547.js +7 -0
  2. package/__mf/js/async/121.7c7dfd24.js +2 -0
  3. package/__mf/js/async/192.e0378d27.js +1 -0
  4. package/__mf/js/async/2.854844cd.js +1 -0
  5. package/__mf/js/async/235.7a97cc35.js +1 -0
  6. package/__mf/js/async/274.ba37d2a5.js +2 -0
  7. package/__mf/js/async/356.c6abe355.js +1 -0
  8. package/__mf/js/async/392.28f62ac0.js +2 -0
  9. package/__mf/js/async/470.5e20d4ce.js +2 -0
  10. package/__mf/js/async/481.c5d339b8.js +2 -0
  11. package/__mf/js/async/496.e922287d.js +1 -0
  12. package/__mf/js/async/525.581e52cb.js +2 -0
  13. package/__mf/js/async/587.8c8aa1fd.js +1 -0
  14. package/__mf/js/async/588.478d90f1.js +1 -0
  15. package/__mf/js/async/616.66d420a8.js +1 -0
  16. package/__mf/js/async/623.5838e6aa.js +1 -0
  17. package/__mf/js/async/628.447b1f89.js +3 -0
  18. package/__mf/js/async/644.06760cb8.js +110 -0
  19. package/__mf/js/async/71.2c2c2fe4.js +1 -0
  20. package/__mf/js/async/77.f97bba54.js +1 -0
  21. package/__mf/js/async/788.d10cf35c.js +43 -0
  22. package/__mf/js/async/{464.d426dd00.js.LICENSE.txt → 788.d10cf35c.js.LICENSE.txt} +41 -1
  23. package/__mf/js/async/873.6eef1fae.js +1 -0
  24. package/__mf/js/async/941.b4bb3575.js +2 -0
  25. package/__mf/js/async/947.3bd98a2b.js +2 -0
  26. package/__mf/js/async/968.f63cc1d1.js +1 -0
  27. package/__mf/js/async/978.63d6babd.js +1 -0
  28. package/__mf/js/async/__federation_expose_StatusHistoryChart.fb6fe4d9.js +23 -0
  29. package/__mf/js/async/lib-router.67526781.js +2 -0
  30. package/__mf/js/{main.3e9b5ca3.js → main.91a9d666.js} +2 -2
  31. package/lib/StatusHistoryChart.d.ts +3 -3
  32. package/lib/StatusHistoryChart.d.ts.map +1 -1
  33. package/lib/StatusHistoryChart.js +4 -4
  34. package/lib/StatusHistoryChart.js.map +1 -1
  35. package/lib/StatusHistoryChartBase.d.ts +3 -3
  36. package/lib/StatusHistoryChartBase.d.ts.map +1 -1
  37. package/lib/StatusHistoryChartBase.js +10 -10
  38. package/lib/StatusHistoryChartBase.js.map +1 -1
  39. package/lib/StatusHistoryChartOptionsEditorSettings.d.ts +2 -2
  40. package/lib/StatusHistoryChartOptionsEditorSettings.d.ts.map +1 -1
  41. package/lib/StatusHistoryChartOptionsEditorSettings.js +4 -4
  42. package/lib/StatusHistoryChartOptionsEditorSettings.js.map +1 -1
  43. package/lib/StatusHistoryPanel.d.ts +4 -4
  44. package/lib/StatusHistoryPanel.d.ts.map +1 -1
  45. package/lib/StatusHistoryPanel.js +7 -7
  46. package/lib/StatusHistoryPanel.js.map +1 -1
  47. package/lib/StatusHistoryTooltip.d.ts +2 -2
  48. package/lib/StatusHistoryTooltip.d.ts.map +1 -1
  49. package/lib/StatusHistoryTooltip.js +2 -2
  50. package/lib/StatusHistoryTooltip.js.map +1 -1
  51. package/lib/StatusHistoryValueMappingEditor.d.ts +3 -3
  52. package/lib/StatusHistoryValueMappingEditor.d.ts.map +1 -1
  53. package/lib/StatusHistoryValueMappingEditor.js +1 -1
  54. package/lib/StatusHistoryValueMappingEditor.js.map +1 -1
  55. package/lib/bootstrap.js +2 -2
  56. package/lib/getPluginModule.d.ts +1 -1
  57. package/lib/getPluginModule.d.ts.map +1 -1
  58. package/lib/getPluginModule.js +3 -1
  59. package/lib/getPluginModule.js.map +1 -1
  60. package/lib/index-federation.js +1 -1
  61. package/lib/index.js +6 -6
  62. package/lib/index.js.map +1 -1
  63. package/lib/setup-tests.d.ts +1 -1
  64. package/lib/setup-tests.d.ts.map +1 -1
  65. package/lib/setup-tests.js +2 -2
  66. package/lib/setup-tests.js.map +1 -1
  67. package/lib/status-history-model.d.ts +2 -2
  68. package/lib/status-history-model.d.ts.map +1 -1
  69. package/lib/status-history-model.js.map +1 -1
  70. package/lib/utils/data-transform.d.ts +5 -5
  71. package/lib/utils/data-transform.d.ts.map +1 -1
  72. package/lib/utils/data-transform.js +4 -4
  73. package/lib/utils/data-transform.js.map +1 -1
  74. package/lib/utils/get-color.js +1 -2
  75. package/lib/utils/get-color.js.map +1 -1
  76. package/lib/utils/get-formatted-axis-label.js +1 -1
  77. package/lib/utils/get-timescale.d.ts +2 -2
  78. package/lib/utils/get-timescale.d.ts.map +1 -1
  79. package/lib/utils/get-timescale.js +1 -1
  80. package/lib/utils/get-timescale.js.map +1 -1
  81. package/lib/utils/get-tooltip-position.d.ts +1 -1
  82. package/lib/utils/get-tooltip-position.d.ts.map +1 -1
  83. package/lib/utils/get-tooltip-position.js.map +1 -1
  84. package/lib/utils/index.js +5 -5
  85. package/lib/utils/index.js.map +1 -1
  86. package/mf-manifest.json +35 -34
  87. package/mf-stats.json +37 -36
  88. package/package.json +10 -10
  89. package/__mf/js/StatusHistoryChart.946b9620.js +0 -7
  90. package/__mf/js/async/121.4774256d.js +0 -2
  91. package/__mf/js/async/177.b42019ec.js +0 -1
  92. package/__mf/js/async/187.e35200d2.js +0 -7
  93. package/__mf/js/async/187.e35200d2.js.LICENSE.txt +0 -39
  94. package/__mf/js/async/189.50a773ab.js +0 -2
  95. package/__mf/js/async/192.5c2ccbc8.js +0 -1
  96. package/__mf/js/async/2.51860681.js +0 -1
  97. package/__mf/js/async/235.82ceb925.js +0 -1
  98. package/__mf/js/async/274.00260b59.js +0 -2
  99. package/__mf/js/async/356.3f5befdf.js +0 -1
  100. package/__mf/js/async/392.6e9f16f1.js +0 -2
  101. package/__mf/js/async/464.d426dd00.js +0 -39
  102. package/__mf/js/async/470.d7ccfb94.js +0 -2
  103. package/__mf/js/async/481.7e46c8f8.js +0 -1
  104. package/__mf/js/async/525.9cf2cd99.js +0 -2
  105. package/__mf/js/async/558.68d38020.js +0 -1
  106. package/__mf/js/async/587.96ffef24.js +0 -1
  107. package/__mf/js/async/588.09ddb723.js +0 -1
  108. package/__mf/js/async/616.d292bca5.js +0 -1
  109. package/__mf/js/async/623.d2ed4458.js +0 -1
  110. package/__mf/js/async/644.51078a40.js +0 -110
  111. package/__mf/js/async/71.88cfb0f7.js +0 -1
  112. package/__mf/js/async/873.3b862492.js +0 -1
  113. package/__mf/js/async/941.8225ba98.js +0 -2
  114. package/__mf/js/async/968.bd2564b8.js +0 -1
  115. package/__mf/js/async/978.144b77a4.js +0 -1
  116. package/__mf/js/async/981.5ec29a41.js +0 -24
  117. package/__mf/js/async/981.5ec29a41.js.LICENSE.txt +0 -19
  118. package/__mf/js/async/__federation_expose_StatusHistoryChart.c43ab053.js +0 -23
  119. package/__mf/js/async/lib-router.33e6a460.js +0 -2
  120. package/lib/cjs/StatusHistoryChart.js +0 -43
  121. package/lib/cjs/StatusHistoryChartBase.js +0 -147
  122. package/lib/cjs/StatusHistoryChartOptionsEditorSettings.js +0 -78
  123. package/lib/cjs/StatusHistoryPanel.js +0 -77
  124. package/lib/cjs/StatusHistoryTooltip.js +0 -55
  125. package/lib/cjs/StatusHistoryValueMappingEditor.js +0 -36
  126. package/lib/cjs/bootstrap.js +0 -26
  127. package/lib/cjs/env.d.js +0 -14
  128. package/lib/cjs/getPluginModule.js +0 -39
  129. package/lib/cjs/index-federation.js +0 -55
  130. package/lib/cjs/index.js +0 -41
  131. package/lib/cjs/setup-tests.js +0 -19
  132. package/lib/cjs/status-history-model.js +0 -25
  133. package/lib/cjs/utils/data-transform.js +0 -136
  134. package/lib/cjs/utils/get-color.js +0 -125
  135. package/lib/cjs/utils/get-formatted-axis-label.js +0 -48
  136. package/lib/cjs/utils/get-timescale.js +0 -27
  137. package/lib/cjs/utils/get-tooltip-position.js +0 -35
  138. package/lib/cjs/utils/index.js +0 -34
  139. /package/__mf/css/async/{187.85c2cbf6.css → 788.85c2cbf6.css} +0 -0
  140. /package/__mf/js/async/{121.4774256d.js.LICENSE.txt → 121.7c7dfd24.js.LICENSE.txt} +0 -0
  141. /package/__mf/js/async/{274.00260b59.js.LICENSE.txt → 274.ba37d2a5.js.LICENSE.txt} +0 -0
  142. /package/__mf/js/async/{392.6e9f16f1.js.LICENSE.txt → 392.28f62ac0.js.LICENSE.txt} +0 -0
  143. /package/__mf/js/async/{470.d7ccfb94.js.LICENSE.txt → 470.5e20d4ce.js.LICENSE.txt} +0 -0
  144. /package/__mf/js/async/{189.50a773ab.js.LICENSE.txt → 481.c5d339b8.js.LICENSE.txt} +0 -0
  145. /package/__mf/js/async/{525.9cf2cd99.js.LICENSE.txt → 525.581e52cb.js.LICENSE.txt} +0 -0
  146. /package/__mf/js/async/{644.51078a40.js.LICENSE.txt → 644.06760cb8.js.LICENSE.txt} +0 -0
  147. /package/__mf/js/async/{941.8225ba98.js.LICENSE.txt → 941.b4bb3575.js.LICENSE.txt} +0 -0
  148. /package/__mf/js/async/{lib-router.33e6a460.js.LICENSE.txt → lib-router.67526781.js.LICENSE.txt} +0 -0
@@ -1,55 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "generateTooltipHTML", {
18
- enumerable: true,
19
- get: function() {
20
- return generateTooltipHTML;
21
- }
22
- });
23
- const _material = require("@mui/material");
24
- const _components = require("@perses-dev/components");
25
- function generateTooltipHTML({ data, label, marker, xAxisCategories, yAxisCategories, theme }) {
26
- const [x, y] = data;
27
- const xAxisLabel = xAxisCategories[x];
28
- const { formattedDate, formattedTime } = (0, _components.getDateAndTime)(xAxisLabel);
29
- const tooltipHeader = (0, _material.css)`
30
- border-bottom: 1px solid ${theme.palette.grey[500]};
31
- padding-bottom: 8px;
32
- `;
33
- const tooltipContentStyles = (0, _material.css)`
34
- display: flex;
35
- justify-content: space-between;
36
- padding-top: 8px;
37
- `;
38
- const labelStyles = (0, _material.css)`
39
- margin-right: 16px;
40
- `;
41
- return `
42
- <div>
43
- <div style="${tooltipHeader.styles}">${formattedDate} - ${formattedTime}</div>
44
- <div style="${tooltipContentStyles.styles}">
45
- <div style="${labelStyles.styles}">
46
- ${marker}
47
- <strong>${yAxisCategories[y]}</strong>
48
- </div>
49
- <div>
50
- ${label}
51
- </div>
52
- </div>
53
- </div>
54
- `;
55
- }
@@ -1,36 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "StatusHistoryValueMappingEditor", {
18
- enumerable: true,
19
- get: function() {
20
- return StatusHistoryValueMappingEditor;
21
- }
22
- });
23
- const _jsxruntime = require("react/jsx-runtime");
24
- const _components = require("@perses-dev/components");
25
- const StatusHistoryValueMappingEditor = ({ onChange, value })=>{
26
- function handleValueMappingChange(mappings) {
27
- onChange({
28
- ...value,
29
- mappings
30
- });
31
- }
32
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ValueMappingsEditor, {
33
- mappings: value.mappings ?? [],
34
- onChange: handleValueMappingChange
35
- });
36
- };
@@ -1,26 +0,0 @@
1
- // Copyright 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
- const _jsxruntime = require("react/jsx-runtime");
18
- const _react = /*#__PURE__*/ _interop_require_default(require("react"));
19
- const _client = /*#__PURE__*/ _interop_require_default(require("react-dom/client"));
20
- function _interop_require_default(obj) {
21
- return obj && obj.__esModule ? obj : {
22
- default: obj
23
- };
24
- }
25
- const root = _client.default.createRoot(document.getElementById('root'));
26
- root.render(/*#__PURE__*/ (0, _jsxruntime.jsx)(_react.default.StrictMode, {}));
package/lib/cjs/env.d.js DELETED
@@ -1,14 +0,0 @@
1
- // Copyright 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
- /// <reference types="@rsbuild/core/types" />
14
- "use strict";
@@ -1,39 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "getPluginModule", {
18
- enumerable: true,
19
- get: function() {
20
- return getPluginModule;
21
- }
22
- });
23
- const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
24
- function _interop_require_default(obj) {
25
- return obj && obj.__esModule ? obj : {
26
- default: obj
27
- };
28
- }
29
- function getPluginModule() {
30
- const { name, version, perses } = _packagejson.default;
31
- return {
32
- kind: 'PluginModule',
33
- metadata: {
34
- name,
35
- version
36
- },
37
- spec: perses
38
- };
39
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- function _getRequireWildcardCache(nodeInterop) {
3
- if (typeof WeakMap !== "function") return null;
4
- var cacheBabelInterop = new WeakMap();
5
- var cacheNodeInterop = new WeakMap();
6
- return (_getRequireWildcardCache = function(nodeInterop) {
7
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
8
- })(nodeInterop);
9
- }
10
- function _interop_require_wildcard(obj, nodeInterop) {
11
- if (!nodeInterop && obj && obj.__esModule) {
12
- return obj;
13
- }
14
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
15
- return {
16
- default: obj
17
- };
18
- }
19
- var cache = _getRequireWildcardCache(nodeInterop);
20
- if (cache && cache.has(obj)) {
21
- return cache.get(obj);
22
- }
23
- var newObj = {
24
- __proto__: null
25
- };
26
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
27
- for(var key in obj){
28
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
29
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
30
- if (desc && (desc.get || desc.set)) {
31
- Object.defineProperty(newObj, key, desc);
32
- } else {
33
- newObj[key] = obj[key];
34
- }
35
- }
36
- }
37
- newObj.default = obj;
38
- if (cache) {
39
- cache.set(obj, newObj);
40
- }
41
- return newObj;
42
- }
43
- // Copyright The Perses Authors
44
- // Licensed under the Apache License, Version 2.0 (the "License");
45
- // you may not use this file except in compliance with the License.
46
- // You may obtain a copy of the License at
47
- //
48
- // http://www.apache.org/licenses/LICENSE-2.0
49
- //
50
- // Unless required by applicable law or agreed to in writing, software
51
- // distributed under the License is distributed on an "AS IS" BASIS,
52
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
- // See the License for the specific language governing permissions and
54
- // limitations under the License.
55
- Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
package/lib/cjs/index.js DELETED
@@ -1,41 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "getPluginModule", {
18
- enumerable: true,
19
- get: function() {
20
- return _getPluginModule.getPluginModule;
21
- }
22
- });
23
- const _getPluginModule = require("./getPluginModule");
24
- _export_star(require("./status-history-model"), exports);
25
- _export_star(require("./StatusHistoryChart"), exports);
26
- _export_star(require("./StatusHistoryChartOptionsEditorSettings"), exports);
27
- _export_star(require("./StatusHistoryPanel"), exports);
28
- _export_star(require("./StatusHistoryValueMappingEditor"), exports);
29
- function _export_star(from, to) {
30
- Object.keys(from).forEach(function(k) {
31
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
32
- Object.defineProperty(to, k, {
33
- enumerable: true,
34
- get: function() {
35
- return from[k];
36
- }
37
- });
38
- }
39
- });
40
- return from;
41
- }
@@ -1,19 +0,0 @@
1
- // Copyright 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
- require("@testing-library/jest-dom");
18
- // Always mock e-charts during tests since we don't have a proper canvas in jsdom
19
- jest.mock('echarts/core');
@@ -1,25 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "createInitialStatusHistoryChartOptions", {
18
- enumerable: true,
19
- get: function() {
20
- return createInitialStatusHistoryChartOptions;
21
- }
22
- });
23
- function createInitialStatusHistoryChartOptions() {
24
- return {};
25
- }
@@ -1,136 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "useStatusHistoryDataModel", {
18
- enumerable: true,
19
- get: function() {
20
- return useStatusHistoryDataModel;
21
- }
22
- });
23
- const _components = require("@perses-dev/components");
24
- const _react = require("react");
25
- const _getcolor = require("./get-color");
26
- const _gettimescale = require("./get-timescale");
27
- function generateCompleteTimestamps(timescale) {
28
- if (!timescale) {
29
- return [];
30
- }
31
- const { startMs, endMs, stepMs } = timescale;
32
- const timestamps = [];
33
- for(let time = startMs; time <= endMs; time += stepMs){
34
- timestamps.push(time);
35
- }
36
- return timestamps;
37
- }
38
- function useStatusHistoryDataModel(queryResults, themeColors, spec) {
39
- return (0, _react.useMemo)(()=>{
40
- if (!queryResults || queryResults.length === 0) {
41
- return {
42
- legendItems: [],
43
- statusHistoryData: [],
44
- xAxisCategories: [],
45
- yAxisCategories: [],
46
- colors: []
47
- };
48
- }
49
- const allSeries = queryResults.reduce((acc, { data })=>{
50
- if (data && data.series) {
51
- acc.push(...data.series);
52
- }
53
- return acc;
54
- }, []);
55
- if (spec.sorting) {
56
- allSeries.sort((a, b)=>{
57
- const nameA = a.formattedName || '';
58
- const nameB = b.formattedName || '';
59
- if (spec.sorting === 'asc') {
60
- return nameA.localeCompare(nameA);
61
- } else {
62
- return nameB.localeCompare(nameB);
63
- }
64
- });
65
- }
66
- const timeScale = (0, _gettimescale.getCommonTimeScaleForQueries)(queryResults);
67
- const statusHistoryData = [];
68
- const yAxisCategories = [];
69
- const legendSet = new Set();
70
- const hasValueMappings = spec.mappings?.length;
71
- const xAxisCategories = generateCompleteTimestamps(timeScale);
72
- allSeries.forEach((item)=>{
73
- const instance = item.formattedName || '';
74
- yAxisCategories.push(instance);
75
- const yIndex = yAxisCategories.length - 1;
76
- item.values.forEach(([time, value])=>{
77
- const itemIndexOnXaxis = xAxisCategories.findIndex((v)=>v === time);
78
- if (value !== null && itemIndexOnXaxis !== -1) {
79
- let itemLabel = value;
80
- if (hasValueMappings) {
81
- const mappedValue = (0, _components.applyValueMapping)(value, spec.mappings);
82
- itemLabel = mappedValue.value;
83
- }
84
- legendSet.add(value);
85
- statusHistoryData.push({
86
- value: [
87
- itemIndexOnXaxis,
88
- yIndex,
89
- value
90
- ],
91
- label: String(itemLabel)
92
- });
93
- }
94
- });
95
- });
96
- const uniqueValues = Array.from(legendSet);
97
- const colorsForValues = (0, _getcolor.getColorsForValues)(uniqueValues, themeColors);
98
- // get colors from theme and generate colors if not provided
99
- const colors = uniqueValues.map((value, index)=>{
100
- let valueColor = colorsForValues[index] ?? _getcolor.FALLBACK_COLOR;
101
- if (hasValueMappings) {
102
- const mappedValue = (0, _components.applyValueMapping)(value, spec.mappings);
103
- valueColor = mappedValue.color ?? valueColor;
104
- }
105
- return {
106
- value,
107
- color: valueColor
108
- };
109
- });
110
- const legendItems = uniqueValues.map((value, idx)=>{
111
- let label = String(value);
112
- if (hasValueMappings) {
113
- const mappedValue = (0, _components.applyValueMapping)(value, spec.mappings);
114
- label = String(mappedValue.value);
115
- }
116
- const color = colors.find((i)=>i.value === value)?.color || _getcolor.FALLBACK_COLOR;
117
- return {
118
- id: `${idx}-${value}`,
119
- label,
120
- color
121
- };
122
- });
123
- return {
124
- xAxisCategories,
125
- yAxisCategories,
126
- legendItems,
127
- statusHistoryData,
128
- timeScale,
129
- colors
130
- };
131
- }, [
132
- queryResults,
133
- themeColors,
134
- spec
135
- ]);
136
- }
@@ -1,125 +0,0 @@
1
- // Copyright 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: Object.getOwnPropertyDescriptor(all, name).get
21
- });
22
- }
23
- _export(exports, {
24
- get FALLBACK_COLOR () {
25
- return FALLBACK_COLOR;
26
- },
27
- get getColorForValue () {
28
- return getColorForValue;
29
- },
30
- get getColorsForValues () {
31
- return getColorsForValues;
32
- },
33
- get hexToHSL () {
34
- return hexToHSL;
35
- },
36
- get hslToHex () {
37
- return hslToHex;
38
- }
39
- });
40
- const FALLBACK_COLOR = '#1f77b4';
41
- function getColorForValue(value, baseColor) {
42
- // Validate base color
43
- if (!baseColor.match(/^#[0-9A-Fa-f]{6}$/)) {
44
- baseColor = FALLBACK_COLOR;
45
- }
46
- try {
47
- const [baseH, baseS, baseL] = hexToHSL(baseColor);
48
- // Ensure numeric values are valid
49
- if (isNaN(baseH) || isNaN(baseS) || isNaN(baseL)) {
50
- throw new Error('Invalid HSL values');
51
- }
52
- // Create deterministic hash
53
- const hash = String(value).split('').reduce((acc, char)=>acc + char.charCodeAt(0), 0);
54
- const hueStep = 60;
55
- const lightnessVariation = 15;
56
- const hueOffset = hash % 6 * hueStep; // 6 segments of 60° each
57
- const newH = (baseH + hueOffset) % 360;
58
- const newL = baseL + (hash % 2 ? lightnessVariation : -lightnessVariation);
59
- // Keep saturation high for better distinction
60
- const newS = Math.min(baseS + 10, 90);
61
- const color = hslToHex(Math.abs(newH), Math.min(Math.max(newS, 50), 90), Math.min(Math.max(newL, 30), 70) // Keep lightness 30-70%
62
- );
63
- // Validate generated color
64
- if (!color.match(/^#[0-9A-Fa-f]{6}$/)) {
65
- throw new Error('Invalid generated color');
66
- }
67
- return color;
68
- } catch {
69
- return FALLBACK_COLOR;
70
- }
71
- }
72
- function getColorsForValues(uniqueValues, themeColors) {
73
- // If we have enough theme colors, use them
74
- if (themeColors.length >= uniqueValues.length) {
75
- return themeColors.slice(0, uniqueValues.length);
76
- }
77
- // Use theme colors first, then generate additional ones
78
- return uniqueValues.map((value, index)=>{
79
- if (index < themeColors.length) {
80
- return themeColors[index] || FALLBACK_COLOR;
81
- }
82
- return getColorForValue(value, themeColors[0] || FALLBACK_COLOR);
83
- });
84
- }
85
- function hexToHSL(hex) {
86
- const r = parseInt(hex.slice(1, 3), 16) / 255;
87
- const g = parseInt(hex.slice(3, 5), 16) / 255;
88
- const b = parseInt(hex.slice(5, 7), 16) / 255;
89
- const max = Math.max(r, g, b);
90
- const min = Math.min(r, g, b);
91
- let h = 0;
92
- let s = 0;
93
- const l = (max + min) / 2;
94
- if (max !== min) {
95
- const d = max - min;
96
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
97
- switch(max){
98
- case r:
99
- h = (g - b) / d + (g < b ? 6 : 0);
100
- break;
101
- case g:
102
- h = (b - r) / d + 2;
103
- break;
104
- case b:
105
- h = (r - g) / d + 4;
106
- break;
107
- }
108
- h /= 6;
109
- }
110
- return [
111
- h * 360,
112
- s * 100,
113
- l * 100
114
- ];
115
- }
116
- function hslToHex(h, s, l) {
117
- l /= 100;
118
- const a = s * Math.min(l, 1 - l) / 100;
119
- const f = (n)=>{
120
- const k = (n + h / 30) % 12;
121
- const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
122
- return Math.round(255 * color).toString(16).padStart(2, '0');
123
- };
124
- return `#${f(0)}${f(8)}${f(4)}`;
125
- }
@@ -1,48 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "getFormattedStatusHistoryAxisLabel", {
18
- enumerable: true,
19
- get: function() {
20
- return getFormattedStatusHistoryAxisLabel;
21
- }
22
- });
23
- const _components = require("@perses-dev/components");
24
- function getFormattedStatusHistoryAxisLabel(rangeMs, timezone) {
25
- return function(value) {
26
- const dayMs = 86400000;
27
- const monthMs = 2629440000;
28
- const yearMs = 31536000000;
29
- const timeStamp = new Date(Number(value));
30
- // more than 5 years
31
- if (rangeMs > yearMs * 5) {
32
- return (0, _components.formatWithTimeZone)(timeStamp, 'yyy', timezone);
33
- }
34
- // more than 2 years
35
- if (rangeMs > yearMs * 2) {
36
- return (0, _components.formatWithTimeZone)(timeStamp, 'MMM yyy', timezone);
37
- }
38
- // between 5 days to 6 months
39
- if (rangeMs > dayMs * 10 && rangeMs < monthMs * 6) {
40
- return (0, _components.formatWithTimeZone)(timeStamp, 'dd.MM', timezone); // 12-01
41
- }
42
- // between 2 and 10 days
43
- if (rangeMs > dayMs * 2 && rangeMs <= dayMs * 10) {
44
- return (0, _components.formatWithTimeZone)(timeStamp, 'dd.MM HH:mm', timezone); // 12-01; // 12-01 12:30
45
- }
46
- return (0, _components.formatWithTimeZone)(timeStamp, 'HH:mm', timezone);
47
- };
48
- }
@@ -1,27 +0,0 @@
1
- // Copyright 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
- Object.defineProperty(exports, "getCommonTimeScaleForQueries", {
18
- enumerable: true,
19
- get: function() {
20
- return getCommonTimeScaleForQueries;
21
- }
22
- });
23
- const _components = require("@perses-dev/components");
24
- function getCommonTimeScaleForQueries(queries) {
25
- const seriesData = queries.map((query)=>query.data);
26
- return (0, _components.getCommonTimeScale)(seriesData);
27
- }