@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,16 @@
1
+ import packageJson from '../package.json';
2
+ /**
3
+ * Returns the plugin module information from package.json
4
+ */ export function getPluginModule() {
5
+ const { name, version, perses } = packageJson;
6
+ return {
7
+ kind: 'PluginModule',
8
+ metadata: {
9
+ name,
10
+ version
11
+ },
12
+ spec: perses
13
+ };
14
+ }
15
+
16
+ //# sourceMappingURL=getPluginModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/getPluginModule.ts"],"sourcesContent":["import { PluginModuleResource, PluginModuleSpec } from '@perses-dev/plugin-system';\nimport packageJson from '../package.json';\n\n/**\n * Returns the plugin module information from package.json\n */\nexport function getPluginModule(): PluginModuleResource {\n const { name, version, perses } = packageJson;\n return {\n kind: 'PluginModule',\n metadata: {\n name,\n version,\n },\n spec: perses as PluginModuleSpec,\n };\n}\n"],"names":["packageJson","getPluginModule","name","version","perses","kind","metadata","spec"],"mappings":"AACA,OAAOA,iBAAiB,kBAAkB;AAE1C;;CAEC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGJ;IAClC,OAAO;QACLK,MAAM;QACNC,UAAU;YACRJ;YACAC;QACF;QACAI,MAAMH;IACR;AACF"}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index-federation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-federation.d.ts","sourceRoot":"","sources":["../../src/index-federation.ts"],"names":[],"mappings":""}
@@ -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
+ import('./bootstrap');
14
+
15
+ //# sourceMappingURL=index-federation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index-federation.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\nimport('./bootstrap');\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,MAAM,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { getPluginModule } from './getPluginModule';
2
+ export * from './status-history-model';
3
+ export * from './StatusHistoryChart';
4
+ export * from './StatusHistoryChartOptionsEditorSettings';
5
+ export * from './StatusHistoryPanel';
6
+ export * from './StatusHistoryValueMappingEditor';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,2CAA2C,CAAC;AAC1D,cAAc,sBAAsB,CAAC;AACrC,cAAc,mCAAmC,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export { getPluginModule } from './getPluginModule';
2
+ export * from './status-history-model';
3
+ export * from './StatusHistoryChart';
4
+ export * from './StatusHistoryChartOptionsEditorSettings';
5
+ export * from './StatusHistoryPanel';
6
+ export * from './StatusHistoryValueMappingEditor';
7
+
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["export { getPluginModule } from './getPluginModule';\nexport * from './status-history-model';\nexport * from './StatusHistoryChart';\nexport * from './StatusHistoryChartOptionsEditorSettings';\nexport * from './StatusHistoryPanel';\nexport * from './StatusHistoryValueMappingEditor';\n"],"names":["getPluginModule"],"mappings":"AAAA,SAASA,eAAe,QAAQ,oBAAoB;AACpD,cAAc,yBAAyB;AACvC,cAAc,uBAAuB;AACrC,cAAc,4CAA4C;AAC1D,cAAc,uBAAuB;AACrC,cAAc,oCAAoC"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom';
2
+ //# sourceMappingURL=setup-tests.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/setup-tests.ts"],"names":[],"mappings":"AAaA,OAAO,2BAA2B,CAAC"}
@@ -0,0 +1,17 @@
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
+ import '@testing-library/jest-dom';
14
+ // Always mock e-charts during tests since we don't have a proper canvas in jsdom
15
+ jest.mock('echarts/core');
16
+
17
+ //# sourceMappingURL=setup-tests.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/setup-tests.ts"],"sourcesContent":["// Copyright 2023 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 '@testing-library/jest-dom';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n"],"names":["jest","mock"],"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,OAAO,4BAA4B;AAEnC,iFAAiF;AACjFA,KAAKC,IAAI,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { ValueMapping } from '@perses-dev/core';
2
+ import { LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';
3
+ export declare function createInitialStatusHistoryChartOptions(): Record<string, unknown>;
4
+ export interface StatusHistoryChartOptions {
5
+ legend?: LegendSpecOptions;
6
+ mappings?: ValueMapping[];
7
+ }
8
+ export type StatusHistroyChartEditorProps = OptionsEditorProps<StatusHistoryChartOptions>;
9
+ //# sourceMappingURL=status-history-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-history-model.d.ts","sourceRoot":"","sources":["../../src/status-history-model.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAElF,wBAAgB,sCAAsC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEhF;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B;AAED,MAAM,MAAM,6BAA6B,GAAG,kBAAkB,CAAC,yBAAyB,CAAC,CAAC"}
@@ -0,0 +1,17 @@
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
+ export function createInitialStatusHistoryChartOptions() {
14
+ return {};
15
+ }
16
+
17
+ //# sourceMappingURL=status-history-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/status-history-model.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\nimport { ValueMapping } from '@perses-dev/core';\nimport { LegendSpecOptions, OptionsEditorProps } from '@perses-dev/plugin-system';\n\nexport function createInitialStatusHistoryChartOptions(): Record<string, unknown> {\n return {};\n}\n\nexport interface StatusHistoryChartOptions {\n legend?: LegendSpecOptions;\n mappings?: ValueMapping[];\n}\n\nexport type StatusHistroyChartEditorProps = OptionsEditorProps<StatusHistoryChartOptions>;\n"],"names":["createInitialStatusHistoryChartOptions"],"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;AAKjC,OAAO,SAASA;IACd,OAAO,CAAC;AACV"}
@@ -0,0 +1,18 @@
1
+ import { LegendItem, StatusHistoryDataItem } from '@perses-dev/components';
2
+ import { TimeScale, TimeSeriesData } from '@perses-dev/core';
3
+ import { PanelData } from '@perses-dev/plugin-system';
4
+ import { StatusHistoryChartOptions } from '../status-history-model';
5
+ interface StatusHistoryDataModel {
6
+ legendItems: LegendItem[];
7
+ statusHistoryData: StatusHistoryDataItem[];
8
+ xAxisCategories: number[];
9
+ yAxisCategories: string[];
10
+ timeScale?: TimeScale;
11
+ colors: Array<{
12
+ value: string | number;
13
+ color: string;
14
+ }>;
15
+ }
16
+ export declare function useStatusHistoryDataModel(queryResults: Array<PanelData<TimeSeriesData>>, themeColors: string[], spec: StatusHistoryChartOptions): StatusHistoryDataModel;
17
+ export {};
18
+ //# sourceMappingURL=data-transform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-transform.d.ts","sourceRoot":"","sources":["../../../src/utils/data-transform.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsC,UAAU,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC/G,OAAO,EAAqB,SAAS,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAGpE,UAAU,sBAAsB;IAC9B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,iBAAiB,EAAE,qBAAqB,EAAE,CAAC;IAC3C,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAcD,wBAAgB,yBAAyB,CACvC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,EAC9C,WAAW,EAAE,MAAM,EAAE,EACrB,IAAI,EAAE,yBAAyB,GAC9B,sBAAsB,CA8FxB"}
@@ -0,0 +1,116 @@
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 { FALLBACK_COLOR, getColorsForValues } from '@perses-dev/components';
14
+ import { applyValueMapping } from '@perses-dev/core';
15
+ import { useMemo } from 'react';
16
+ import { getCommonTimeScaleForQueries } from './get-timescale';
17
+ function generateCompleteTimestamps(timescale) {
18
+ if (!timescale) {
19
+ return [];
20
+ }
21
+ const { startMs, endMs, stepMs } = timescale;
22
+ const timestamps = [];
23
+ for(let time = startMs; time <= endMs; time += stepMs){
24
+ timestamps.push(time);
25
+ }
26
+ return timestamps;
27
+ }
28
+ export function useStatusHistoryDataModel(queryResults, themeColors, spec) {
29
+ return useMemo(()=>{
30
+ if (!queryResults || queryResults.length === 0) {
31
+ return {
32
+ legendItems: [],
33
+ statusHistoryData: [],
34
+ xAxisCategories: [],
35
+ yAxisCategories: [],
36
+ colors: []
37
+ };
38
+ }
39
+ const timeScale = getCommonTimeScaleForQueries(queryResults);
40
+ const statusHistoryData = [];
41
+ const yAxisCategories = [];
42
+ const legendSet = new Set();
43
+ const hasValueMappings = spec.mappings?.length;
44
+ const xAxisCategories = generateCompleteTimestamps(timeScale);
45
+ queryResults.forEach(({ data })=>{
46
+ if (!data) {
47
+ return;
48
+ }
49
+ data.series.forEach((item)=>{
50
+ const instance = item.formattedName || '';
51
+ yAxisCategories.push(instance);
52
+ const yIndex = yAxisCategories.length - 1;
53
+ item.values.forEach(([time, value])=>{
54
+ const itemIndexOnXaxis = xAxisCategories.findIndex((v)=>v === time);
55
+ if (value !== null && itemIndexOnXaxis !== -1) {
56
+ let itemLabel = value;
57
+ if (hasValueMappings) {
58
+ const mappedValue = applyValueMapping(value, spec.mappings);
59
+ itemLabel = mappedValue.value;
60
+ }
61
+ legendSet.add(value);
62
+ statusHistoryData.push({
63
+ value: [
64
+ itemIndexOnXaxis,
65
+ yIndex,
66
+ value
67
+ ],
68
+ label: String(itemLabel)
69
+ });
70
+ }
71
+ });
72
+ });
73
+ });
74
+ const uniqueValues = Array.from(legendSet);
75
+ const colorsForValues = getColorsForValues(uniqueValues, themeColors);
76
+ // get colors from theme and generate colors if not provided
77
+ const colors = uniqueValues.map((value, index)=>{
78
+ let valueColor = colorsForValues[index] ?? FALLBACK_COLOR;
79
+ if (hasValueMappings) {
80
+ const mappedValue = applyValueMapping(value, spec.mappings);
81
+ valueColor = mappedValue.color ?? valueColor;
82
+ }
83
+ return {
84
+ value,
85
+ color: valueColor
86
+ };
87
+ });
88
+ const legendItems = uniqueValues.map((value, idx)=>{
89
+ let label = String(value);
90
+ if (hasValueMappings) {
91
+ const mappedValue = applyValueMapping(value, spec.mappings);
92
+ label = String(mappedValue.value);
93
+ }
94
+ const color = colors.find((i)=>i.value === value)?.color || FALLBACK_COLOR;
95
+ return {
96
+ id: `${idx}-${value}`,
97
+ label,
98
+ color
99
+ };
100
+ });
101
+ return {
102
+ xAxisCategories,
103
+ yAxisCategories,
104
+ legendItems,
105
+ statusHistoryData,
106
+ timeScale,
107
+ colors
108
+ };
109
+ }, [
110
+ queryResults,
111
+ spec.mappings,
112
+ themeColors
113
+ ]);
114
+ }
115
+
116
+ //# sourceMappingURL=data-transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/data-transform.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\nimport { FALLBACK_COLOR, getColorsForValues, LegendItem, StatusHistoryDataItem } from '@perses-dev/components';\nimport { applyValueMapping, TimeScale, TimeSeriesData } from '@perses-dev/core';\nimport { PanelData } from '@perses-dev/plugin-system';\nimport { useMemo } from 'react';\nimport { StatusHistoryChartOptions } from '../status-history-model';\nimport { getCommonTimeScaleForQueries } from './get-timescale';\n\ninterface StatusHistoryDataModel {\n legendItems: LegendItem[];\n statusHistoryData: StatusHistoryDataItem[];\n xAxisCategories: number[];\n yAxisCategories: string[];\n timeScale?: TimeScale;\n colors: Array<{\n value: string | number;\n color: string;\n }>;\n}\n\nfunction generateCompleteTimestamps(timescale?: TimeScale): number[] {\n if (!timescale) {\n return [];\n }\n const { startMs, endMs, stepMs } = timescale;\n const timestamps: number[] = [];\n for (let time = startMs; time <= endMs; time += stepMs) {\n timestamps.push(time);\n }\n return timestamps;\n}\n\nexport function useStatusHistoryDataModel(\n queryResults: Array<PanelData<TimeSeriesData>>,\n themeColors: string[],\n spec: StatusHistoryChartOptions\n): StatusHistoryDataModel {\n return useMemo(() => {\n if (!queryResults || queryResults.length === 0) {\n return {\n legendItems: [],\n statusHistoryData: [],\n xAxisCategories: [],\n yAxisCategories: [],\n colors: [],\n };\n }\n\n const timeScale = getCommonTimeScaleForQueries(queryResults);\n const statusHistoryData: StatusHistoryDataItem[] = [];\n const yAxisCategories: string[] = [];\n const legendSet = new Set<number>();\n const hasValueMappings = spec.mappings?.length;\n\n const xAxisCategories = generateCompleteTimestamps(timeScale);\n\n queryResults.forEach(({ data }) => {\n if (!data) {\n return;\n }\n\n data.series.forEach((item) => {\n const instance = item.formattedName || '';\n\n yAxisCategories.push(instance);\n\n const yIndex = yAxisCategories.length - 1;\n\n item.values.forEach(([time, value]) => {\n const itemIndexOnXaxis = xAxisCategories.findIndex((v) => v === time);\n if (value !== null && itemIndexOnXaxis !== -1) {\n let itemLabel: string | number = value;\n if (hasValueMappings) {\n const mappedValue = applyValueMapping(value, spec.mappings);\n itemLabel = mappedValue.value;\n }\n legendSet.add(value);\n statusHistoryData.push({\n value: [itemIndexOnXaxis, yIndex, value],\n label: String(itemLabel),\n });\n }\n });\n });\n });\n\n const uniqueValues = Array.from(legendSet);\n const colorsForValues = getColorsForValues(uniqueValues, themeColors);\n\n // get colors from theme and generate colors if not provided\n const colors = uniqueValues.map((value, index) => {\n let valueColor: string = colorsForValues[index] ?? FALLBACK_COLOR;\n\n if (hasValueMappings) {\n const mappedValue = applyValueMapping(value, spec.mappings);\n valueColor = mappedValue.color ?? valueColor;\n }\n\n return {\n value,\n color: valueColor,\n };\n });\n\n const legendItems: LegendItem[] = uniqueValues.map((value, idx) => {\n let label = String(value);\n\n if (hasValueMappings) {\n const mappedValue = applyValueMapping(value, spec.mappings);\n label = String(mappedValue.value);\n }\n\n const color = colors.find((i) => i.value === value)?.color || FALLBACK_COLOR;\n\n return {\n id: `${idx}-${value}`,\n label,\n color,\n };\n });\n\n return {\n xAxisCategories,\n yAxisCategories,\n legendItems,\n statusHistoryData,\n timeScale,\n colors,\n };\n }, [queryResults, spec.mappings, themeColors]);\n}\n"],"names":["FALLBACK_COLOR","getColorsForValues","applyValueMapping","useMemo","getCommonTimeScaleForQueries","generateCompleteTimestamps","timescale","startMs","endMs","stepMs","timestamps","time","push","useStatusHistoryDataModel","queryResults","themeColors","spec","length","legendItems","statusHistoryData","xAxisCategories","yAxisCategories","colors","timeScale","legendSet","Set","hasValueMappings","mappings","forEach","data","series","item","instance","formattedName","yIndex","values","value","itemIndexOnXaxis","findIndex","v","itemLabel","mappedValue","add","label","String","uniqueValues","Array","from","colorsForValues","map","index","valueColor","color","idx","find","i","id"],"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,SAASA,cAAc,EAAEC,kBAAkB,QAA2C,yBAAyB;AAC/G,SAASC,iBAAiB,QAAmC,mBAAmB;AAEhF,SAASC,OAAO,QAAQ,QAAQ;AAEhC,SAASC,4BAA4B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
3
+ export declare function getCommonTimeScaleForQueries(queries: Array<PanelData<TimeSeriesData>>): TimeScale | undefined;
4
+ //# sourceMappingURL=get-timescale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-timescale.d.ts","sourceRoot":"","sources":["../../../src/utils/get-timescale.ts"],"names":[],"mappings":"AAaA,OAAO,EAAsB,SAAS,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC,GAAG,SAAS,GAAG,SAAS,CAG7G"}
@@ -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 { getCommonTimeScale } from '@perses-dev/core';
14
+ export function getCommonTimeScaleForQueries(queries) {
15
+ const seriesData = queries.map((query)=>query.data);
16
+ return getCommonTimeScale(seriesData);
17
+ }
18
+
19
+ //# sourceMappingURL=get-timescale.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utils/get-timescale.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\nimport { getCommonTimeScale, TimeScale, TimeSeriesData } from '@perses-dev/core';\nimport { PanelData } from '@perses-dev/plugin-system';\n\nexport function getCommonTimeScaleForQueries(queries: Array<PanelData<TimeSeriesData>>): TimeScale | undefined {\n const seriesData = queries.map((query) => query.data);\n return getCommonTimeScale(seriesData);\n}\n"],"names":["getCommonTimeScale","getCommonTimeScaleForQueries","queries","seriesData","map","query","data"],"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,SAASA,kBAAkB,QAAmC,mBAAmB;AAGjF,OAAO,SAASC,6BAA6BC,OAAyC;IACpF,MAAMC,aAAaD,QAAQE,GAAG,CAAC,CAACC,QAAUA,MAAMC,IAAI;IACpD,OAAON,mBAAmBG;AAC5B"}