@perses-dev/status-history-chart-plugin 0.6.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.
Files changed (126) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +41 -0
  3. package/__mf/css/async/263.17332bd7.css +1 -0
  4. package/__mf/css/async/341.17332bd7.css +1 -0
  5. package/__mf/css/async/759.17332bd7.css +1 -0
  6. package/__mf/font/lato-all-300-normal.322bdf14.woff +0 -0
  7. package/__mf/font/lato-all-400-normal.63513b00.woff +0 -0
  8. package/__mf/font/lato-all-700-normal.bb27db94.woff +0 -0
  9. package/__mf/font/lato-all-900-normal.a27049a3.woff +0 -0
  10. package/__mf/font/lato-latin-300-normal.c5195215.woff2 +0 -0
  11. package/__mf/font/lato-latin-400-normal.b7ffde23.woff2 +0 -0
  12. package/__mf/font/lato-latin-700-normal.d5eb20bc.woff2 +0 -0
  13. package/__mf/font/lato-latin-900-normal.d884a71c.woff2 +0 -0
  14. package/__mf/font/lato-latin-ext-300-normal.abcc64a9.woff2 +0 -0
  15. package/__mf/font/lato-latin-ext-400-normal.6ebed106.woff2 +0 -0
  16. package/__mf/font/lato-latin-ext-700-normal.8697d1d5.woff2 +0 -0
  17. package/__mf/font/lato-latin-ext-900-normal.20a2b415.woff2 +0 -0
  18. package/__mf/js/456.ee65e816.js +5 -0
  19. package/__mf/js/StatusHistoryChart.3532083a.js +5 -0
  20. package/__mf/js/async/13.714dc818.js +73 -0
  21. package/__mf/js/async/13.714dc818.js.LICENSE.txt +19 -0
  22. package/__mf/js/async/173.23a9af58.js +2 -0
  23. package/__mf/js/async/173.23a9af58.js.LICENSE.txt +19 -0
  24. package/__mf/js/async/214.bd903be0.js +1 -0
  25. package/__mf/js/async/22.b2b97531.js +38 -0
  26. package/__mf/js/async/224.d1554d4a.js +1 -0
  27. package/__mf/js/async/232.cccd71f6.js +1 -0
  28. package/__mf/js/async/238.e1063a95.js +1 -0
  29. package/__mf/js/async/292.6a606f52.js +1 -0
  30. package/__mf/js/async/333.a82fc8bd.js +2 -0
  31. package/__mf/js/async/333.a82fc8bd.js.LICENSE.txt +9 -0
  32. package/__mf/js/async/488.f3f63548.js +1 -0
  33. package/__mf/js/async/539.e7706a03.js +2 -0
  34. package/__mf/js/async/539.e7706a03.js.LICENSE.txt +15 -0
  35. package/__mf/js/async/610.37fe76b5.js +1 -0
  36. package/__mf/js/async/62.b55b7073.js +1 -0
  37. package/__mf/js/async/620.9ead3302.js +2 -0
  38. package/__mf/js/async/620.9ead3302.js.LICENSE.txt +9 -0
  39. package/__mf/js/async/651.f99d8a40.js +1 -0
  40. package/__mf/js/async/694.f0fc36da.js +1 -0
  41. package/__mf/js/async/738.a0be8511.js +1 -0
  42. package/__mf/js/async/740.6b036ded.js +1 -0
  43. package/__mf/js/async/75.2cda0740.js +1 -0
  44. package/__mf/js/async/770.ddaea8f9.js +1 -0
  45. package/__mf/js/async/822.c6b015c5.js +29 -0
  46. package/__mf/js/async/822.c6b015c5.js.LICENSE.txt +43 -0
  47. package/__mf/js/async/960.587af91a.js +2 -0
  48. package/__mf/js/async/960.587af91a.js.LICENSE.txt +8 -0
  49. package/__mf/js/async/964.03c8778c.js +2 -0
  50. package/__mf/js/async/964.03c8778c.js.LICENSE.txt +9 -0
  51. package/__mf/js/async/977.1462b2d4.js +110 -0
  52. package/__mf/js/async/977.1462b2d4.js.LICENSE.txt +27 -0
  53. package/__mf/js/async/981.caaa6409.js +2 -0
  54. package/__mf/js/async/981.caaa6409.js.LICENSE.txt +8 -0
  55. package/__mf/js/async/996.06dcce9b.js +2 -0
  56. package/__mf/js/async/996.06dcce9b.js.LICENSE.txt +24 -0
  57. package/__mf/js/async/__federation_expose_StatusHistoryChart.7de772fb.js +1 -0
  58. package/__mf/js/async/lib-router.c90fcaed.js +2 -0
  59. package/__mf/js/async/lib-router.c90fcaed.js.LICENSE.txt +32 -0
  60. package/__mf/js/main.2afb03fb.js +1 -0
  61. package/lib/StatusHistoryChart.d.ts +5 -0
  62. package/lib/StatusHistoryChart.d.ts.map +1 -0
  63. package/lib/StatusHistoryChart.js +35 -0
  64. package/lib/StatusHistoryChart.js.map +1 -0
  65. package/lib/StatusHistoryChartOptionsEditorSettings.d.ts +4 -0
  66. package/lib/StatusHistoryChartOptionsEditorSettings.d.ts.map +1 -0
  67. package/lib/StatusHistoryChartOptionsEditorSettings.js +55 -0
  68. package/lib/StatusHistoryChartOptionsEditorSettings.js.map +1 -0
  69. package/lib/StatusHistoryPanel.d.ts +7 -0
  70. package/lib/StatusHistoryPanel.d.ts.map +1 -0
  71. package/lib/StatusHistoryPanel.js +71 -0
  72. package/lib/StatusHistoryPanel.js.map +1 -0
  73. package/lib/StatusHistoryValueMappingEditor.d.ts +6 -0
  74. package/lib/StatusHistoryValueMappingEditor.d.ts.map +1 -0
  75. package/lib/StatusHistoryValueMappingEditor.js +28 -0
  76. package/lib/StatusHistoryValueMappingEditor.js.map +1 -0
  77. package/lib/bootstrap.d.ts +2 -0
  78. package/lib/bootstrap.d.ts.map +1 -0
  79. package/lib/bootstrap.js +19 -0
  80. package/lib/bootstrap.js.map +1 -0
  81. package/lib/cjs/StatusHistoryChart.js +43 -0
  82. package/lib/cjs/StatusHistoryChartOptionsEditorSettings.js +63 -0
  83. package/lib/cjs/StatusHistoryPanel.js +79 -0
  84. package/lib/cjs/StatusHistoryValueMappingEditor.js +36 -0
  85. package/lib/cjs/bootstrap.js +26 -0
  86. package/lib/cjs/env.d.js +14 -0
  87. package/lib/cjs/getPluginModule.js +27 -0
  88. package/lib/cjs/index-federation.js +55 -0
  89. package/lib/cjs/index.js +29 -0
  90. package/lib/cjs/setup-tests.js +19 -0
  91. package/lib/cjs/status-history-model.js +25 -0
  92. package/lib/cjs/utils/data-transform.js +124 -0
  93. package/lib/cjs/utils/get-timescale.js +27 -0
  94. package/lib/env.d.js +15 -0
  95. package/lib/env.d.js.map +1 -0
  96. package/lib/getPluginModule.d.ts +6 -0
  97. package/lib/getPluginModule.d.ts.map +1 -0
  98. package/lib/getPluginModule.js +16 -0
  99. package/lib/getPluginModule.js.map +1 -0
  100. package/lib/index-federation.d.ts +1 -0
  101. package/lib/index-federation.d.ts.map +1 -0
  102. package/lib/index-federation.js +15 -0
  103. package/lib/index-federation.js.map +1 -0
  104. package/lib/index.d.ts +7 -0
  105. package/lib/index.d.ts.map +1 -0
  106. package/lib/index.js +8 -0
  107. package/lib/index.js.map +1 -0
  108. package/lib/setup-tests.d.ts +2 -0
  109. package/lib/setup-tests.d.ts.map +1 -0
  110. package/lib/setup-tests.js +17 -0
  111. package/lib/setup-tests.js.map +1 -0
  112. package/lib/status-history-model.d.ts +9 -0
  113. package/lib/status-history-model.d.ts.map +1 -0
  114. package/lib/status-history-model.js +17 -0
  115. package/lib/status-history-model.js.map +1 -0
  116. package/lib/utils/data-transform.d.ts +18 -0
  117. package/lib/utils/data-transform.d.ts.map +1 -0
  118. package/lib/utils/data-transform.js +116 -0
  119. package/lib/utils/data-transform.js.map +1 -0
  120. package/lib/utils/get-timescale.d.ts +4 -0
  121. package/lib/utils/get-timescale.d.ts.map +1 -0
  122. package/lib/utils/get-timescale.js +19 -0
  123. package/lib/utils/get-timescale.js.map +1 -0
  124. package/mf-manifest.json +367 -0
  125. package/mf-stats.json +421 -0
  126. package/package.json +53 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/StatusHistoryValueMappingEditor.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport { ValueMapping } from '@perses-dev/core';\nimport { ValueMappingsEditor } from '@perses-dev/components';\nimport { FC } from 'react';\nimport { StatusHistoryChartOptions } from './status-history-model';\n\nexport type StatusHistoryValueMappingEditorProps = OptionsEditorProps<StatusHistoryChartOptions>;\n\nexport const StatusHistoryValueMappingEditor: FC<StatusHistoryValueMappingEditorProps> = ({ onChange, value }) => {\n function handleValueMappingChange(mappings: ValueMapping[]): void {\n onChange({ ...value, mappings });\n }\n\n return <ValueMappingsEditor mappings={value.mappings ?? []} onChange={handleValueMappingChange} />;\n};\n"],"names":["ValueMappingsEditor","StatusHistoryValueMappingEditor","onChange","value","handleValueMappingChange","mappings"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAIjC,SAASA,mBAAmB,QAAQ,yBAAyB;AAM7D,OAAO,MAAMC,kCAA4E,CAAC,EAAEC,QAAQ,EAAEC,KAAK,EAAE;IAC3G,SAASC,yBAAyBC,QAAwB;QACxDH,SAAS;YAAE,GAAGC,KAAK;YAAEE;QAAS;IAChC;IAEA,qBAAO,KAACL;QAAoBK,UAAUF,MAAME,QAAQ,IAAI,EAAE;QAAEH,UAAUE;;AACxE,EAAE"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/bootstrap.tsx"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ // Copyright 2024 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
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import React from 'react';
15
+ import ReactDOM from 'react-dom/client';
16
+ const root = ReactDOM.createRoot(document.getElementById('root'));
17
+ root.render(/*#__PURE__*/ _jsx(React.StrictMode, {}));
18
+
19
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/bootstrap.tsx"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport React from 'react';\nimport ReactDOM from 'react-dom/client';\n\nconst root = ReactDOM.createRoot(document.getElementById('root')!);\nroot.render(<React.StrictMode></React.StrictMode>);\n"],"names":["React","ReactDOM","root","createRoot","document","getElementById","render","StrictMode"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,cAAc,mBAAmB;AAExC,MAAMC,OAAOD,SAASE,UAAU,CAACC,SAASC,cAAc,CAAC;AACzDH,KAAKI,MAAM,eAAC,KAACN,MAAMO,UAAU"}
@@ -0,0 +1,43 @@
1
+ // Copyright 2024 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, "StatusHistoryChart", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return StatusHistoryChart;
21
+ }
22
+ });
23
+ const _statushistorymodel = require("./status-history-model");
24
+ const _StatusHistoryChartOptionsEditorSettings = require("./StatusHistoryChartOptionsEditorSettings");
25
+ const _StatusHistoryPanel = require("./StatusHistoryPanel");
26
+ const _StatusHistoryValueMappingEditor = require("./StatusHistoryValueMappingEditor");
27
+ const StatusHistoryChart = {
28
+ PanelComponent: _StatusHistoryPanel.StatusHistoryPanel,
29
+ supportedQueryTypes: [
30
+ 'TimeSeriesQuery'
31
+ ],
32
+ panelOptionsEditorComponents: [
33
+ {
34
+ label: 'Settings',
35
+ content: _StatusHistoryChartOptionsEditorSettings.StatusHistoryChartOptionsEditorSettings
36
+ },
37
+ {
38
+ label: 'Value mapping',
39
+ content: _StatusHistoryValueMappingEditor.StatusHistoryValueMappingEditor
40
+ }
41
+ ],
42
+ createInitialOptions: _statushistorymodel.createInitialStatusHistoryChartOptions
43
+ };
@@ -0,0 +1,63 @@
1
+ // Copyright 2024 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, "StatusHistoryChartOptionsEditorSettings", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return StatusHistoryChartOptionsEditorSettings;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _pluginsystem = require("@perses-dev/plugin-system");
25
+ const _immer = require("immer");
26
+ const _components = require("@perses-dev/components");
27
+ const _material = require("@mui/material");
28
+ function StatusHistoryChartOptionsEditorSettings(props) {
29
+ const { onChange, value } = props;
30
+ const handleLegendChange = (newLegend)=>{
31
+ // TODO (sjcobb): fix type, add position, fix glitch
32
+ onChange((0, _immer.produce)(value, (draft)=>{
33
+ draft.legend = newLegend;
34
+ }));
35
+ };
36
+ return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_components.OptionsEditorGrid, {
37
+ children: [
38
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
39
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_pluginsystem.LegendOptionsEditor, {
40
+ showValuesEditor: false,
41
+ value: value.legend,
42
+ onChange: handleLegendChange
43
+ })
44
+ }),
45
+ /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorColumn, {
46
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.OptionsEditorGroup, {
47
+ title: "Reset Settings",
48
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Button, {
49
+ variant: "outlined",
50
+ color: "secondary",
51
+ onClick: ()=>{
52
+ onChange((0, _immer.produce)(value, (draft)=>{
53
+ // reset button removes all optional panel options
54
+ draft.legend = undefined;
55
+ }));
56
+ },
57
+ children: "Reset To Defaults"
58
+ })
59
+ })
60
+ })
61
+ ]
62
+ });
63
+ }
@@ -0,0 +1,79 @@
1
+ // Copyright 2024 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, "StatusHistoryPanel", {
18
+ enumerable: true,
19
+ get: function() {
20
+ return StatusHistoryPanel;
21
+ }
22
+ });
23
+ const _jsxruntime = require("react/jsx-runtime");
24
+ const _material = require("@mui/material");
25
+ const _components = require("@perses-dev/components");
26
+ const _pluginsystem = require("@perses-dev/plugin-system");
27
+ const _lodash = require("lodash");
28
+ const _react = require("react");
29
+ const _datatransform = require("./utils/data-transform");
30
+ function StatusHistoryPanel(props) {
31
+ const { spec, contentDimensions, queryResults } = props;
32
+ const legend = (0, _react.useMemo)(()=>{
33
+ return spec.legend && (0, _pluginsystem.validateLegendSpec)(spec.legend) ? (0, _lodash.merge)({}, spec.legend) : undefined;
34
+ }, [
35
+ spec.legend
36
+ ]);
37
+ const chartsTheme = (0, _components.useChartsTheme)();
38
+ const PADDING = chartsTheme.container.padding.default;
39
+ const { statusHistoryData, yAxisCategories, xAxisCategories, legendItems, timeScale, colors } = (0, _datatransform.useStatusHistoryDataModel)(queryResults, chartsTheme.echartsTheme.color, spec);
40
+ const adjustedContentDimensions = contentDimensions ? {
41
+ width: contentDimensions.width - PADDING * 2,
42
+ height: contentDimensions.height - PADDING * 2
43
+ } : undefined;
44
+ if (!statusHistoryData || statusHistoryData.length === 0) {
45
+ return null;
46
+ }
47
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
48
+ sx: {
49
+ padding: `${PADDING}px`
50
+ },
51
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.ContentWithLegend, {
52
+ width: adjustedContentDimensions?.width ?? 400,
53
+ height: adjustedContentDimensions?.height ?? 1000,
54
+ legendSize: legend?.size,
55
+ legendProps: legend && {
56
+ options: legend,
57
+ data: legendItems || [],
58
+ selectedItems: 'ALL',
59
+ onSelectedItemsChange: ()=>null
60
+ },
61
+ children: ({ height, width })=>{
62
+ return /*#__PURE__*/ (0, _jsxruntime.jsx)(_material.Box, {
63
+ sx: {
64
+ height,
65
+ width
66
+ },
67
+ children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_components.StatusHistoryChart, {
68
+ xAxisCategories: xAxisCategories,
69
+ yAxisCategories: yAxisCategories,
70
+ data: statusHistoryData,
71
+ timeScale: timeScale,
72
+ height: height,
73
+ colors: colors
74
+ })
75
+ });
76
+ }
77
+ })
78
+ });
79
+ }
@@ -0,0 +1,36 @@
1
+ // Copyright 2024 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
+ };
@@ -0,0 +1,26 @@
1
+ // Copyright 2024 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, {}));
@@ -0,0 +1,14 @@
1
+ // Copyright 2024 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";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getPluginModule", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return getPluginModule;
9
+ }
10
+ });
11
+ const _packagejson = /*#__PURE__*/ _interop_require_default(require("../package.json"));
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
17
+ function getPluginModule() {
18
+ const { name, version, perses } = _packagejson.default;
19
+ return {
20
+ kind: 'PluginModule',
21
+ metadata: {
22
+ name,
23
+ version
24
+ },
25
+ spec: perses
26
+ };
27
+ }
@@ -0,0 +1,55 @@
1
+ // Copyright 2024 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
+ function _getRequireWildcardCache(nodeInterop) {
15
+ if (typeof WeakMap !== "function") return null;
16
+ var cacheBabelInterop = new WeakMap();
17
+ var cacheNodeInterop = new WeakMap();
18
+ return (_getRequireWildcardCache = function(nodeInterop) {
19
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
20
+ })(nodeInterop);
21
+ }
22
+ function _interop_require_wildcard(obj, nodeInterop) {
23
+ if (!nodeInterop && obj && obj.__esModule) {
24
+ return obj;
25
+ }
26
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
27
+ return {
28
+ default: obj
29
+ };
30
+ }
31
+ var cache = _getRequireWildcardCache(nodeInterop);
32
+ if (cache && cache.has(obj)) {
33
+ return cache.get(obj);
34
+ }
35
+ var newObj = {
36
+ __proto__: null
37
+ };
38
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
39
+ for(var key in obj){
40
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
41
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
42
+ if (desc && (desc.get || desc.set)) {
43
+ Object.defineProperty(newObj, key, desc);
44
+ } else {
45
+ newObj[key] = obj[key];
46
+ }
47
+ }
48
+ }
49
+ newObj.default = obj;
50
+ if (cache) {
51
+ cache.set(obj, newObj);
52
+ }
53
+ return newObj;
54
+ }
55
+ Promise.resolve().then(()=>/*#__PURE__*/ _interop_require_wildcard(require("./bootstrap")));
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "getPluginModule", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return _getPluginModule.getPluginModule;
9
+ }
10
+ });
11
+ const _getPluginModule = require("./getPluginModule");
12
+ _export_star(require("./status-history-model"), exports);
13
+ _export_star(require("./StatusHistoryChart"), exports);
14
+ _export_star(require("./StatusHistoryChartOptionsEditorSettings"), exports);
15
+ _export_star(require("./StatusHistoryPanel"), exports);
16
+ _export_star(require("./StatusHistoryValueMappingEditor"), exports);
17
+ function _export_star(from, to) {
18
+ Object.keys(from).forEach(function(k) {
19
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
20
+ Object.defineProperty(to, k, {
21
+ enumerable: true,
22
+ get: function() {
23
+ return from[k];
24
+ }
25
+ });
26
+ }
27
+ });
28
+ return from;
29
+ }
@@ -0,0 +1,19 @@
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
+ 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');
@@ -0,0 +1,25 @@
1
+ // Copyright 2024 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
+ }
@@ -0,0 +1,124 @@
1
+ // Copyright 2024 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 _core = require("@perses-dev/core");
25
+ const _react = require("react");
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 timeScale = (0, _gettimescale.getCommonTimeScaleForQueries)(queryResults);
50
+ const statusHistoryData = [];
51
+ const yAxisCategories = [];
52
+ const legendSet = new Set();
53
+ const hasValueMappings = spec.mappings?.length;
54
+ const xAxisCategories = generateCompleteTimestamps(timeScale);
55
+ queryResults.forEach(({ data })=>{
56
+ if (!data) {
57
+ return;
58
+ }
59
+ data.series.forEach((item)=>{
60
+ const instance = item.formattedName || '';
61
+ yAxisCategories.push(instance);
62
+ const yIndex = yAxisCategories.length - 1;
63
+ item.values.forEach(([time, value])=>{
64
+ const itemIndexOnXaxis = xAxisCategories.findIndex((v)=>v === time);
65
+ if (value !== null && itemIndexOnXaxis !== -1) {
66
+ let itemLabel = value;
67
+ if (hasValueMappings) {
68
+ const mappedValue = (0, _core.applyValueMapping)(value, spec.mappings);
69
+ itemLabel = mappedValue.value;
70
+ }
71
+ legendSet.add(value);
72
+ statusHistoryData.push({
73
+ value: [
74
+ itemIndexOnXaxis,
75
+ yIndex,
76
+ value
77
+ ],
78
+ label: String(itemLabel)
79
+ });
80
+ }
81
+ });
82
+ });
83
+ });
84
+ const uniqueValues = Array.from(legendSet);
85
+ const colorsForValues = (0, _components.getColorsForValues)(uniqueValues, themeColors);
86
+ // get colors from theme and generate colors if not provided
87
+ const colors = uniqueValues.map((value, index)=>{
88
+ let valueColor = colorsForValues[index] ?? _components.FALLBACK_COLOR;
89
+ if (hasValueMappings) {
90
+ const mappedValue = (0, _core.applyValueMapping)(value, spec.mappings);
91
+ valueColor = mappedValue.color ?? valueColor;
92
+ }
93
+ return {
94
+ value,
95
+ color: valueColor
96
+ };
97
+ });
98
+ const legendItems = uniqueValues.map((value, idx)=>{
99
+ let label = String(value);
100
+ if (hasValueMappings) {
101
+ const mappedValue = (0, _core.applyValueMapping)(value, spec.mappings);
102
+ label = String(mappedValue.value);
103
+ }
104
+ const color = colors.find((i)=>i.value === value)?.color || _components.FALLBACK_COLOR;
105
+ return {
106
+ id: `${idx}-${value}`,
107
+ label,
108
+ color
109
+ };
110
+ });
111
+ return {
112
+ xAxisCategories,
113
+ yAxisCategories,
114
+ legendItems,
115
+ statusHistoryData,
116
+ timeScale,
117
+ colors
118
+ };
119
+ }, [
120
+ queryResults,
121
+ spec.mappings,
122
+ themeColors
123
+ ]);
124
+ }
@@ -0,0 +1,27 @@
1
+ // Copyright 2024 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 _core = require("@perses-dev/core");
24
+ function getCommonTimeScaleForQueries(queries) {
25
+ const seriesData = queries.map((query)=>query.data);
26
+ return (0, _core.getCommonTimeScale)(seriesData);
27
+ }
package/lib/env.d.js ADDED
@@ -0,0 +1,15 @@
1
+ // Copyright 2024 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
+
15
+ //# sourceMappingURL=env.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/env.d.ts"],"sourcesContent":["// Copyright 2024 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/// <reference types=\"@rsbuild/core/types\" />\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,6CAA6C"}
@@ -0,0 +1,6 @@
1
+ import { PluginModuleResource } from '@perses-dev/plugin-system';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */
5
+ export declare function getPluginModule(): PluginModuleResource;
6
+ //# sourceMappingURL=getPluginModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPluginModule.d.ts","sourceRoot":"","sources":["../../src/getPluginModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAoB,MAAM,2BAA2B,CAAC;AAGnF;;GAEG;AACH,wBAAgB,eAAe,IAAI,oBAAoB,CAUtD"}