@perses-dev/dashboards 0.10.0 → 0.11.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 (193) hide show
  1. package/dist/cjs/components/Dashboard.js +4 -5
  2. package/dist/cjs/components/DashboardToolbar.js +11 -5
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +3 -11
  4. package/dist/cjs/components/GridLayout/GridLayout.js +8 -6
  5. package/dist/cjs/components/GridLayout/GridTitle.js +9 -11
  6. package/dist/cjs/components/Panel/DeletePanelDialog.js +12 -8
  7. package/dist/cjs/components/Panel/Panel.js +4 -13
  8. package/dist/cjs/components/Panel/Panel.test.js +4 -3
  9. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +1 -1
  10. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +3 -3
  11. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +21 -15
  12. package/dist/cjs/components/PanelDrawer/PanelPreview.js +9 -3
  13. package/dist/cjs/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
  14. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +70 -111
  15. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +22 -16
  16. package/dist/cjs/components/PanelGroupDialog/PanelGroupEditorForm.js +92 -0
  17. package/dist/cjs/components/PanelGroupDialog/index.js +29 -0
  18. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +8 -11
  19. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +20 -13
  20. package/dist/cjs/components/Variables/Variable.js +1 -0
  21. package/dist/cjs/components/Variables/VariableEditor.js +33 -0
  22. package/dist/cjs/components/Variables/VariableList.js +0 -1
  23. package/dist/cjs/components/index.js +1 -0
  24. package/dist/cjs/context/DashboardProvider/DashboardProvider.js +20 -8
  25. package/dist/cjs/context/DashboardProvider/dashboard-provider-api.js +122 -29
  26. package/dist/cjs/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +32 -13
  27. package/dist/cjs/context/DashboardProvider/panel-group-editor-slice.js +102 -0
  28. package/dist/cjs/context/DashboardProvider/panel-group-slice.js +187 -17
  29. package/dist/cjs/context/TimeRangeProvider.js +20 -44
  30. package/dist/cjs/context/index.js +1 -1
  31. package/dist/cjs/context/useDashboardSpec.js +61 -0
  32. package/dist/cjs/index.js +1 -0
  33. package/dist/cjs/test/render.js +25 -5
  34. package/dist/cjs/test/setup-tests.js +4 -1
  35. package/dist/cjs/test/testDashboard.js +11 -10
  36. package/dist/cjs/utils/index.js +28 -0
  37. package/dist/cjs/utils/time-range-params.js +145 -0
  38. package/dist/cjs/views/ViewDashboard/DashboardApp.js +2 -4
  39. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +5 -22
  40. package/dist/cjs/views/ViewDashboard/tests/panelGroups.test.js +42 -93
  41. package/dist/components/Dashboard.js +5 -6
  42. package/dist/components/Dashboard.js.map +1 -1
  43. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  44. package/dist/components/DashboardToolbar.js +13 -7
  45. package/dist/components/DashboardToolbar.js.map +1 -1
  46. package/dist/components/GridLayout/GridItemContent.d.ts +2 -4
  47. package/dist/components/GridLayout/GridItemContent.d.ts.map +1 -1
  48. package/dist/components/GridLayout/GridItemContent.js +4 -12
  49. package/dist/components/GridLayout/GridItemContent.js.map +1 -1
  50. package/dist/components/GridLayout/GridLayout.d.ts +2 -3
  51. package/dist/components/GridLayout/GridLayout.d.ts.map +1 -1
  52. package/dist/components/GridLayout/GridLayout.js +9 -7
  53. package/dist/components/GridLayout/GridLayout.js.map +1 -1
  54. package/dist/components/GridLayout/GridTitle.d.ts +2 -1
  55. package/dist/components/GridLayout/GridTitle.d.ts.map +1 -1
  56. package/dist/components/GridLayout/GridTitle.js +10 -12
  57. package/dist/components/GridLayout/GridTitle.js.map +1 -1
  58. package/dist/components/Panel/DeletePanelDialog.d.ts +1 -1
  59. package/dist/components/Panel/DeletePanelDialog.d.ts.map +1 -1
  60. package/dist/components/Panel/DeletePanelDialog.js +13 -9
  61. package/dist/components/Panel/DeletePanelDialog.js.map +1 -1
  62. package/dist/components/Panel/Panel.d.ts +2 -2
  63. package/dist/components/Panel/Panel.d.ts.map +1 -1
  64. package/dist/components/Panel/Panel.js +5 -14
  65. package/dist/components/Panel/Panel.js.map +1 -1
  66. package/dist/components/Panel/Panel.test.d.ts +1 -1
  67. package/dist/components/Panel/Panel.test.d.ts.map +1 -1
  68. package/dist/components/Panel/Panel.test.js +4 -3
  69. package/dist/components/Panel/Panel.test.js.map +1 -1
  70. package/dist/components/PanelDrawer/PanelDrawer.js +2 -2
  71. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -1
  72. package/dist/components/PanelDrawer/PanelDrawer.test.js +3 -3
  73. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -1
  74. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +1 -1
  75. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -1
  76. package/dist/components/PanelDrawer/PanelEditorForm.js +22 -16
  77. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -1
  78. package/dist/components/PanelDrawer/PanelPreview.d.ts +2 -2
  79. package/dist/components/PanelDrawer/PanelPreview.d.ts.map +1 -1
  80. package/dist/components/PanelDrawer/PanelPreview.js +9 -3
  81. package/dist/components/PanelDrawer/PanelPreview.js.map +1 -1
  82. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts +1 -2
  83. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.d.ts.map +1 -1
  84. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js +13 -11
  85. package/dist/components/PanelGroupDialog/DeletePanelGroupDialog.js.map +1 -1
  86. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts +4 -2
  87. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  88. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +73 -112
  89. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -1
  90. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +21 -15
  91. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -1
  92. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts +12 -0
  93. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.d.ts.map +1 -0
  94. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js +82 -0
  95. package/dist/components/PanelGroupDialog/PanelGroupEditorForm.js.map +1 -0
  96. package/dist/components/PanelGroupDialog/index.d.ts +3 -0
  97. package/dist/components/PanelGroupDialog/index.d.ts.map +1 -0
  98. package/dist/components/PanelGroupDialog/index.js +16 -0
  99. package/dist/components/PanelGroupDialog/index.js.map +1 -0
  100. package/dist/components/TimeRangeControls/TimeRangeControls.d.ts.map +1 -1
  101. package/dist/components/TimeRangeControls/TimeRangeControls.js +11 -14
  102. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -1
  103. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +21 -14
  104. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -1
  105. package/dist/components/Variables/Variable.js +1 -0
  106. package/dist/components/Variables/Variable.js.map +1 -1
  107. package/dist/components/Variables/VariableEditor.d.ts.map +1 -1
  108. package/dist/components/Variables/VariableEditor.js +33 -0
  109. package/dist/components/Variables/VariableEditor.js.map +1 -1
  110. package/dist/components/Variables/VariableList.js +0 -1
  111. package/dist/components/Variables/VariableList.js.map +1 -1
  112. package/dist/components/index.d.ts +1 -0
  113. package/dist/components/index.d.ts.map +1 -1
  114. package/dist/components/index.js +1 -0
  115. package/dist/components/index.js.map +1 -1
  116. package/dist/context/DashboardProvider/DashboardProvider.d.ts +7 -5
  117. package/dist/context/DashboardProvider/DashboardProvider.d.ts.map +1 -1
  118. package/dist/context/DashboardProvider/DashboardProvider.js +19 -7
  119. package/dist/context/DashboardProvider/DashboardProvider.js.map +1 -1
  120. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts +64 -22
  121. package/dist/context/DashboardProvider/dashboard-provider-api.d.ts.map +1 -1
  122. package/dist/context/DashboardProvider/dashboard-provider-api.js +133 -26
  123. package/dist/context/DashboardProvider/dashboard-provider-api.js.map +1 -1
  124. package/dist/context/DashboardProvider/index.d.ts +2 -0
  125. package/dist/context/DashboardProvider/index.d.ts.map +1 -1
  126. package/dist/context/DashboardProvider/index.js.map +1 -1
  127. package/dist/context/DashboardProvider/{panel-editing-slice.d.ts → panel-editor-slice.d.ts} +28 -13
  128. package/dist/context/DashboardProvider/panel-editor-slice.d.ts.map +1 -0
  129. package/dist/context/DashboardProvider/{panel-editing-slice.js → panel-editor-slice.js} +33 -14
  130. package/dist/context/DashboardProvider/panel-editor-slice.js.map +1 -0
  131. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts +40 -0
  132. package/dist/context/DashboardProvider/panel-group-editor-slice.d.ts.map +1 -0
  133. package/dist/context/DashboardProvider/panel-group-editor-slice.js +96 -0
  134. package/dist/context/DashboardProvider/panel-group-editor-slice.js.map +1 -0
  135. package/dist/context/DashboardProvider/panel-group-slice.d.ts +75 -10
  136. package/dist/context/DashboardProvider/panel-group-slice.d.ts.map +1 -1
  137. package/dist/context/DashboardProvider/panel-group-slice.js +189 -17
  138. package/dist/context/DashboardProvider/panel-group-slice.js.map +1 -1
  139. package/dist/context/TimeRangeProvider.d.ts +9 -2
  140. package/dist/context/TimeRangeProvider.d.ts.map +1 -1
  141. package/dist/context/TimeRangeProvider.js +15 -43
  142. package/dist/context/TimeRangeProvider.js.map +1 -1
  143. package/dist/context/index.d.ts +1 -1
  144. package/dist/context/index.d.ts.map +1 -1
  145. package/dist/context/index.js +1 -1
  146. package/dist/context/index.js.map +1 -1
  147. package/dist/context/useDashboardSpec.d.ts +3 -0
  148. package/dist/context/useDashboardSpec.d.ts.map +1 -0
  149. package/dist/context/useDashboardSpec.js +55 -0
  150. package/dist/context/useDashboardSpec.js.map +1 -0
  151. package/dist/index.d.ts +1 -0
  152. package/dist/index.d.ts.map +1 -1
  153. package/dist/index.js +1 -0
  154. package/dist/index.js.map +1 -1
  155. package/dist/test/render.d.ts +2 -1
  156. package/dist/test/render.d.ts.map +1 -1
  157. package/dist/test/render.js +25 -5
  158. package/dist/test/render.js.map +1 -1
  159. package/dist/test/setup-tests.d.ts.map +1 -1
  160. package/dist/test/setup-tests.js +4 -0
  161. package/dist/test/setup-tests.js.map +1 -1
  162. package/dist/test/testDashboard.d.ts.map +1 -1
  163. package/dist/test/testDashboard.js +11 -10
  164. package/dist/test/testDashboard.js.map +1 -1
  165. package/dist/utils/index.d.ts +2 -0
  166. package/dist/utils/index.d.ts.map +1 -0
  167. package/dist/utils/index.js +15 -0
  168. package/dist/utils/index.js.map +1 -0
  169. package/dist/utils/time-range-params.d.ts +25 -0
  170. package/dist/utils/time-range-params.d.ts.map +1 -0
  171. package/dist/utils/time-range-params.js +137 -0
  172. package/dist/utils/time-range-params.js.map +1 -0
  173. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -1
  174. package/dist/views/ViewDashboard/DashboardApp.js +1 -3
  175. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -1
  176. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -1
  177. package/dist/views/ViewDashboard/ViewDashboard.js +5 -22
  178. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -1
  179. package/dist/views/ViewDashboard/tests/panelGroups.test.js +45 -96
  180. package/dist/views/ViewDashboard/tests/panelGroups.test.js.map +1 -1
  181. package/package.json +5 -4
  182. package/dist/cjs/context/DashboardProvider/layout-slice.js +0 -200
  183. package/dist/cjs/context/QueryStringProvider.js +0 -89
  184. package/dist/context/DashboardProvider/layout-slice.d.ts +0 -57
  185. package/dist/context/DashboardProvider/layout-slice.d.ts.map +0 -1
  186. package/dist/context/DashboardProvider/layout-slice.js +0 -196
  187. package/dist/context/DashboardProvider/layout-slice.js.map +0 -1
  188. package/dist/context/DashboardProvider/panel-editing-slice.d.ts.map +0 -1
  189. package/dist/context/DashboardProvider/panel-editing-slice.js.map +0 -1
  190. package/dist/context/QueryStringProvider.d.ts +0 -13
  191. package/dist/context/QueryStringProvider.d.ts.map +0 -1
  192. package/dist/context/QueryStringProvider.js +0 -40
  193. package/dist/context/QueryStringProvider.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2022 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\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './QueryStringProvider';\nexport * from './TemplateVariableProvider';\nexport * from './TimeRangeProvider';\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,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"sources":["../../src/context/index.ts"],"sourcesContent":["// Copyright 2022 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\nexport * from './DashboardProvider';\nexport * from './DatasourceStoreProvider';\nexport * from './TemplateVariableProvider';\nexport * from './TimeRangeProvider';\nexport * from './useDashboardSpec';\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,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { DashboardSpec } from '@perses-dev/core';
2
+ export declare function useDashboardSpec(): DashboardSpec;
3
+ //# sourceMappingURL=useDashboardSpec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDashboardSpec.d.ts","sourceRoot":"","sources":["../../src/context/useDashboardSpec.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAkB,MAAM,kBAAkB,CAAC;AAIjE,wBAAgB,gBAAgB,IAAI,aAAa,CAehD"}
@@ -0,0 +1,55 @@
1
+ // Copyright 2022 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 { useDashboardStore } from './DashboardProvider';
14
+ import { useTemplateVariableDefinitions } from './TemplateVariableProvider';
15
+ export function useDashboardSpec() {
16
+ const { panels , panelGroups , defaultTimeRange } = useDashboardStore(({ panels , panelGroups , defaultTimeRange })=>({
17
+ panels,
18
+ panelGroups,
19
+ defaultTimeRange
20
+ }));
21
+ const variables = useTemplateVariableDefinitions();
22
+ const layouts = convertPanelGroupsToLayouts(panelGroups);
23
+ return {
24
+ panels,
25
+ layouts,
26
+ variables,
27
+ duration: defaultTimeRange.pastDuration
28
+ };
29
+ }
30
+ function convertPanelGroupsToLayouts(panelGroups) {
31
+ const layouts = [];
32
+ Object.values(panelGroups).forEach((group)=>{
33
+ const { title , isCollapsed , items } = group;
34
+ let display = undefined;
35
+ if (title) {
36
+ display = {
37
+ title,
38
+ collapse: {
39
+ open: !isCollapsed
40
+ }
41
+ };
42
+ }
43
+ const layout = {
44
+ kind: 'Grid',
45
+ spec: {
46
+ display,
47
+ items
48
+ }
49
+ };
50
+ layouts.push(layout);
51
+ });
52
+ return layouts;
53
+ }
54
+
55
+ //# sourceMappingURL=useDashboardSpec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/useDashboardSpec.tsx"],"sourcesContent":["// Copyright 2022 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 { DashboardSpec, GridDefinition } from '@perses-dev/core';\nimport { PanelGroupDefinition, useDashboardStore } from './DashboardProvider';\nimport { useTemplateVariableDefinitions } from './TemplateVariableProvider';\n\nexport function useDashboardSpec(): DashboardSpec {\n const { panels, panelGroups, defaultTimeRange } = useDashboardStore(({ panels, panelGroups, defaultTimeRange }) => ({\n panels,\n panelGroups,\n defaultTimeRange,\n }));\n const variables = useTemplateVariableDefinitions();\n const layouts = convertPanelGroupsToLayouts(panelGroups);\n\n return {\n panels,\n layouts,\n variables,\n duration: defaultTimeRange.pastDuration,\n };\n}\n\nfunction convertPanelGroupsToLayouts(panelGroups: Record<number, PanelGroupDefinition>): GridDefinition[] {\n const layouts: GridDefinition[] = [];\n Object.values(panelGroups).forEach((group) => {\n const { title, isCollapsed, items } = group;\n let display = undefined;\n if (title) {\n display = {\n title,\n collapse: {\n open: !isCollapsed,\n },\n };\n }\n const layout: GridDefinition = {\n kind: 'Grid',\n spec: {\n display,\n items,\n },\n };\n layouts.push(layout);\n });\n return layouts;\n}\n"],"names":["useDashboardStore","useTemplateVariableDefinitions","useDashboardSpec","panels","panelGroups","defaultTimeRange","variables","layouts","convertPanelGroupsToLayouts","duration","pastDuration","Object","values","forEach","group","title","isCollapsed","items","display","undefined","collapse","open","layout","kind","spec","push"],"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;AAGjC,SAA+BA,iBAAiB,QAAQ,qBAAqB,CAAC;AAC9E,SAASC,8BAA8B,QAAQ,4BAA4B,CAAC;AAE5E,OAAO,SAASC,gBAAgB,GAAkB;IAChD,MAAM,EAAEC,MAAM,CAAA,EAAEC,WAAW,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAGL,iBAAiB,CAAC,CAAC,EAAEG,MAAM,CAAA,EAAEC,WAAW,CAAA,EAAEC,gBAAgB,CAAA,EAAE,GAAM,CAAA;YAClHF,MAAM;YACNC,WAAW;YACXC,gBAAgB;SACjB,CAAA,AAAC,CAAC,AAAC;IACJ,MAAMC,SAAS,GAAGL,8BAA8B,EAAE,AAAC;IACnD,MAAMM,OAAO,GAAGC,2BAA2B,CAACJ,WAAW,CAAC,AAAC;IAEzD,OAAO;QACLD,MAAM;QACNI,OAAO;QACPD,SAAS;QACTG,QAAQ,EAAEJ,gBAAgB,CAACK,YAAY;KACxC,CAAC;AACJ,CAAC;AAED,SAASF,2BAA2B,CAACJ,WAAiD,EAAoB;IACxG,MAAMG,OAAO,GAAqB,EAAE,AAAC;IACrCI,MAAM,CAACC,MAAM,CAACR,WAAW,CAAC,CAACS,OAAO,CAAC,CAACC,KAAK,GAAK;QAC5C,MAAM,EAAEC,KAAK,CAAA,EAAEC,WAAW,CAAA,EAAEC,KAAK,CAAA,EAAE,GAAGH,KAAK,AAAC;QAC5C,IAAII,OAAO,GAAGC,SAAS,AAAC;QACxB,IAAIJ,KAAK,EAAE;YACTG,OAAO,GAAG;gBACRH,KAAK;gBACLK,QAAQ,EAAE;oBACRC,IAAI,EAAE,CAACL,WAAW;iBACnB;aACF,CAAC;QACJ,CAAC;QACD,MAAMM,MAAM,GAAmB;YAC7BC,IAAI,EAAE,MAAM;YACZC,IAAI,EAAE;gBACJN,OAAO;gBACPD,KAAK;aACN;SACF,AAAC;QACFV,OAAO,CAACkB,IAAI,CAACH,MAAM,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,OAAOf,OAAO,CAAC;AACjB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './components';
2
2
  export * from './context';
3
+ export * from './utils';
3
4
  export * from './views';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@
12
12
  // limitations under the License.
13
13
  export * from './components';
14
14
  export * from './context';
15
+ export * from './utils';
15
16
  export * from './views';
16
17
 
17
18
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2022 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\nexport * from './components';\nexport * from './context';\nexport * from './views';\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,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Copyright 2022 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\nexport * from './components';\nexport * from './context';\nexport * from './utils';\nexport * from './views';\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,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -1,7 +1,8 @@
1
1
  /// <reference types="react" />
2
2
  import { RenderOptions } from '@testing-library/react';
3
+ import { MemoryHistory } from 'history';
3
4
  /**
4
5
  * Test helper to render a React component with some common app-level providers wrapped around it.
5
6
  */
6
- export declare function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
7
+ export declare function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>, history?: MemoryHistory): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
7
8
  //# sourceMappingURL=render.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG/D;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,gIAIjG"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/test/render.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAU,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAuB,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7D;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,EAAE,KAAK,CAAC,YAAY,EACtB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,EACxC,OAAO,CAAC,EAAE,aAAa,gIAsBxB"}
@@ -12,10 +12,15 @@
12
12
  // limitations under the License.
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { render } from '@testing-library/react';
15
+ import { unstable_HistoryRouter } from 'react-router-dom';
16
+ import { createMemoryHistory } from 'history';
17
+ import { QueryParamProvider } from 'use-query-params';
18
+ import { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';
15
19
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
20
+ import { ChartsThemeProvider, testChartsTheme } from '@perses-dev/components';
16
21
  /**
17
22
  * Test helper to render a React component with some common app-level providers wrapped around it.
18
- */ export function renderWithContext(ui, options) {
23
+ */ export function renderWithContext(ui, options, history) {
19
24
  // Create a new QueryClient for each test to avoid caching issues
20
25
  const queryClient = new QueryClient({
21
26
  defaultOptions: {
@@ -25,10 +30,25 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
25
30
  }
26
31
  }
27
32
  });
28
- return render(/*#__PURE__*/ _jsx(QueryClientProvider, {
29
- client: queryClient,
30
- children: ui
31
- }), options);
33
+ const BaseRender = ()=>{
34
+ const HistoryRouter = unstable_HistoryRouter;
35
+ history = history !== null && history !== void 0 ? history : createMemoryHistory();
36
+ return /*#__PURE__*/ _jsx(HistoryRouter, {
37
+ history: history,
38
+ children: /*#__PURE__*/ _jsx(QueryClientProvider, {
39
+ client: queryClient,
40
+ children: /*#__PURE__*/ _jsx(QueryParamProvider, {
41
+ adapter: ReactRouter6Adapter,
42
+ children: /*#__PURE__*/ _jsx(ChartsThemeProvider, {
43
+ themeName: "perses",
44
+ chartsTheme: testChartsTheme,
45
+ children: ui
46
+ })
47
+ })
48
+ })
49
+ });
50
+ };
51
+ return render(/*#__PURE__*/ _jsx(BaseRender, {}), options);
32
52
  }
33
53
 
34
54
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2022 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 { render, RenderOptions } from '@testing-library/react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(ui: React.ReactElement, options?: Omit<RenderOptions, 'queries'>) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } } });\n return render(<QueryClientProvider client={queryClient}>{ui}</QueryClientProvider>, options);\n}\n"],"names":["render","QueryClient","QueryClientProvider","renderWithContext","ui","options","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","client"],"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;AAAA,SAASA,MAAM,QAAuB,wBAAwB,CAAC;AAC/D,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,uBAAuB,CAAC;AAEzE;;CAEC,GACD,OAAO,SAASC,iBAAiB,CAACC,EAAsB,EAAEC,OAAwC,EAAE;IAClG,iEAAiE;IACjE,MAAMC,WAAW,GAAG,IAAIL,WAAW,CAAC;QAAEM,cAAc,EAAE;YAAEC,OAAO,EAAE;gBAAEC,oBAAoB,EAAE,KAAK;gBAAEC,KAAK,EAAE,KAAK;aAAE;SAAE;KAAE,CAAC,AAAC;IACpH,OAAOV,MAAM,eAAC,KAACE,mBAAmB;QAACS,MAAM,EAAEL,WAAW;kBAAGF,EAAE;MAAuB,EAAEC,OAAO,CAAC,CAAC;AAC/F,CAAC"}
1
+ {"version":3,"sources":["../../src/test/render.tsx"],"sourcesContent":["// Copyright 2022 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 { render, RenderOptions } from '@testing-library/react';\nimport { unstable_HistoryRouter } from 'react-router-dom';\nimport { createMemoryHistory, MemoryHistory } from 'history';\nimport { QueryParamProvider } from 'use-query-params';\nimport { ReactRouter6Adapter } from 'use-query-params/adapters/react-router-6';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { ChartsThemeProvider, testChartsTheme } from '@perses-dev/components';\n\n/**\n * Test helper to render a React component with some common app-level providers wrapped around it.\n */\nexport function renderWithContext(\n ui: React.ReactElement,\n options?: Omit<RenderOptions, 'queries'>,\n history?: MemoryHistory\n) {\n // Create a new QueryClient for each test to avoid caching issues\n const queryClient = new QueryClient({ defaultOptions: { queries: { refetchOnWindowFocus: false, retry: false } } });\n\n const BaseRender = () => {\n const HistoryRouter = unstable_HistoryRouter;\n history = history ?? createMemoryHistory();\n return (\n <HistoryRouter history={history}>\n <QueryClientProvider client={queryClient}>\n <QueryParamProvider adapter={ReactRouter6Adapter}>\n <ChartsThemeProvider themeName=\"perses\" chartsTheme={testChartsTheme}>\n {ui}\n </ChartsThemeProvider>\n </QueryParamProvider>\n </QueryClientProvider>\n </HistoryRouter>\n );\n };\n\n return render(<BaseRender />, options);\n}\n"],"names":["render","unstable_HistoryRouter","createMemoryHistory","QueryParamProvider","ReactRouter6Adapter","QueryClient","QueryClientProvider","ChartsThemeProvider","testChartsTheme","renderWithContext","ui","options","history","queryClient","defaultOptions","queries","refetchOnWindowFocus","retry","BaseRender","HistoryRouter","client","adapter","themeName","chartsTheme"],"mappings":"AAAA,o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,OAAOV,MAAM,eAAC,KAACkB,UAAU,KAAG,EAAEP,OAAO,CAAC,CAAC;AACzC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAcA,OAAO,yCAAyC,CAAC"}
1
+ {"version":3,"file":"setup-tests.d.ts","sourceRoot":"","sources":["../../src/test/setup-tests.ts"],"names":[],"mappings":"AAgBA,OAAO,yCAAyC,CAAC"}
@@ -10,9 +10,13 @@
10
10
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
+ import { defaultFallbackInView } from 'react-intersection-observer';
13
14
  // Add testing library assertions
14
15
  import '@testing-library/jest-dom/extend-expect';
15
16
  // Always mock e-charts during tests since we don't have a proper canvas in jsdom
16
17
  jest.mock('echarts/core');
18
+ // Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation
19
+ // for other options)
20
+ defaultFallbackInView(true);
17
21
 
18
22
  //# sourceMappingURL=setup-tests.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2022 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// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\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,iCAAiC;AACjC,OAAO,yCAAyC,CAAC;AAEjD,iFAAiF;AACjFA,IAAI,CAACC,IAAI,CAAC,cAAc,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/test/setup-tests.ts"],"sourcesContent":["// Copyright 2022 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 { defaultFallbackInView } from 'react-intersection-observer';\n\n// Add testing library assertions\nimport '@testing-library/jest-dom/extend-expect';\n\n// Always mock e-charts during tests since we don't have a proper canvas in jsdom\njest.mock('echarts/core');\n\n// Tell react-intersection-observer that everything should be considered in-view for tests (see package documentation\n// for other options)\ndefaultFallbackInView(true);\n"],"names":["defaultFallbackInView","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,SAASA,qBAAqB,QAAQ,6BAA6B,CAAC;AAEpE,iCAAiC;AACjC,OAAO,yCAAyC,CAAC;AAEjD,iFAAiF;AACjFC,IAAI,CAACC,IAAI,CAAC,cAAc,CAAC,CAAC;AAE1B,qHAAqH;AACrH,qBAAqB;AACrBF,qBAAqB,CAAC,IAAI,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"testDashboard.d.ts","sourceRoot":"","sources":["../../src/test/testDashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,QAAA,MAAM,aAAa,EAAE,iBAwPpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"testDashboard.d.ts","sourceRoot":"","sources":["../../src/test/testDashboard.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,QAAA,MAAM,aAAa,EAAE,iBAyPpB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -20,7 +20,7 @@ const testDashboard = {
20
20
  version: 0
21
21
  },
22
22
  spec: {
23
- duration: '24h',
23
+ duration: '5m',
24
24
  variables: [
25
25
  {
26
26
  kind: 'TextVariable',
@@ -136,6 +136,7 @@ const testDashboard = {
136
136
  }
137
137
  }
138
138
  },
139
+ // This panel is referenced in more than one layout below
139
140
  diskIO: {
140
141
  kind: 'Panel',
141
142
  spec: {
@@ -234,6 +235,15 @@ const testDashboard = {
234
235
  kind: 'Grid',
235
236
  spec: {
236
237
  items: [
238
+ {
239
+ x: 0,
240
+ y: 0,
241
+ width: 6,
242
+ height: 2,
243
+ content: {
244
+ $ref: '#/spec/panels/diskIO'
245
+ }
246
+ },
237
247
  {
238
248
  x: 8,
239
249
  y: 0,
@@ -257,15 +267,6 @@ const testDashboard = {
257
267
  }
258
268
  },
259
269
  items: [
260
- {
261
- x: 0,
262
- y: 0,
263
- width: 6,
264
- height: 2,
265
- content: {
266
- $ref: '#/spec/panels/diskIO'
267
- }
268
- },
269
270
  {
270
271
  x: 18,
271
272
  y: 0,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/test/testDashboard.ts"],"sourcesContent":["// Copyright 2022 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 { DashboardResource } from '@perses-dev/core';\n\nconst testDashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n created_at: '2021-11-09',\n updated_at: '2021-11-09',\n version: 0,\n },\n spec: {\n duration: '24h',\n variables: [\n {\n kind: 'TextVariable',\n spec: {\n name: 'job',\n value: 'node',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'instance',\n value: 'demo.do.prometheus.io:9100',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'interval',\n value: '1m',\n },\n },\n ],\n panels: {\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'CPU' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'avg without (cpu)(rate(node_cpu_seconds_total{job=\"node\",instance=\"$instance\",mode!=\"idle\"}[$interval]))',\n },\n },\n },\n },\n ],\n unit: { kind: '%' },\n },\n },\n },\n },\n memory: {\n kind: 'Panel',\n spec: {\n display: { name: 'Memory' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'node_memory_MemTotal_bytes{job=\"node\",instance=\"$instance\"} - node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n unit: { kind: 'Bytes' },\n },\n },\n },\n },\n diskIO: {\n kind: 'Panel',\n spec: {\n display: { name: 'Disk I/O Utilization' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'rate(node_disk_io_time_seconds_total{job=\"node\",instance=\"$instance\",device!~\"^(md\\\\\\\\d+$|dm-)\"}[$interval])',\n },\n },\n },\n },\n ],\n unit: { kind: 'Percent' },\n },\n },\n },\n },\n filesystemFullness: {\n kind: 'Panel',\n spec: {\n display: { name: 'Filesystem Fullness' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n '1 - node_filesystem_free_bytes{job=\"node\",instance=\"$instance\",fstype!=\"rootfs\",mountpoint!~\"/(run|var).*\",mountpoint!=\"\"} / node_filesystem_size_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n unit: { kind: 'Percent' },\n },\n },\n },\n },\n },\n layouts: [\n // Regular Title, no collapse enabled\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'CPU Stats',\n collapse: {\n open: true,\n },\n },\n items: [\n // First Row\n {\n x: 0,\n y: 0,\n width: 12,\n height: 4,\n content: { $ref: '#/spec/panels/cpu' },\n },\n {\n x: 0,\n y: 5,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n ],\n },\n },\n // No title,\n {\n kind: 'Grid',\n spec: {\n items: [\n {\n x: 8,\n y: 0,\n width: 8,\n height: 3,\n content: { $ref: '#/spec/panels/memory' },\n },\n ],\n },\n },\n // Collapsed\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'Disk Stats',\n collapse: {\n open: false,\n },\n },\n items: [\n {\n x: 0,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n {\n x: 18,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/filesystemFullness' },\n },\n ],\n },\n },\n ],\n },\n};\n\nexport default testDashboard;\n"],"names":["testDashboard","kind","metadata","name","project","created_at","updated_at","version","spec","duration","variables","value","panels","cpu","display","plugin","queries","query","unit","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"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,MAAMA,aAAa,GAAsB;IACvCC,IAAI,EAAE,WAAW;IACjBC,QAAQ,EAAE;QACRC,IAAI,EAAE,YAAY;QAClBC,OAAO,EAAE,QAAQ;QACjBC,UAAU,EAAE,YAAY;QACxBC,UAAU,EAAE,YAAY;QACxBC,OAAO,EAAE,CAAC;KACX;IACDC,IAAI,EAAE;QACJC,QAAQ,EAAE,KAAK;QACfC,SAAS,EAAE;YACT;gBACET,IAAI,EAAE,cAAc;gBACpBO,IAAI,EAAE;oBACJL,IAAI,EAAE,KAAK;oBACXQ,KAAK,EAAE,MAAM;iBACd;aACF;YACD;gBACEV,IAAI,EAAE,cAAc;gBACpBO,IAAI,EAAE;oBACJL,IAAI,EAAE,UAAU;oBAChBQ,KAAK,EAAE,4BAA4B;iBACpC;aACF;YACD;gBACEV,IAAI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AI,EAAE,sBAAsB;6BAAE;yBAC1C;wBACD;4BACEL,CAAC,EAAE,EAAE;4BACLC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,kCAAkC;6BAAE;yBACtD;qBACF;iBACF;aACF;SACF;KACF;CACF,AAAC;AAEF,eAAehC,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/test/testDashboard.ts"],"sourcesContent":["// Copyright 2022 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 { DashboardResource } from '@perses-dev/core';\n\nconst testDashboard: DashboardResource = {\n kind: 'Dashboard',\n metadata: {\n name: 'Node Stats',\n project: 'perses',\n created_at: '2021-11-09',\n updated_at: '2021-11-09',\n version: 0,\n },\n spec: {\n duration: '5m',\n variables: [\n {\n kind: 'TextVariable',\n spec: {\n name: 'job',\n value: 'node',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'instance',\n value: 'demo.do.prometheus.io:9100',\n },\n },\n {\n kind: 'TextVariable',\n spec: {\n name: 'interval',\n value: '1m',\n },\n },\n ],\n panels: {\n cpu: {\n kind: 'Panel',\n spec: {\n display: { name: 'CPU' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'avg without (cpu)(rate(node_cpu_seconds_total{job=\"node\",instance=\"$instance\",mode!=\"idle\"}[$interval]))',\n },\n },\n },\n },\n ],\n unit: { kind: '%' },\n },\n },\n },\n },\n memory: {\n kind: 'Panel',\n spec: {\n display: { name: 'Memory' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'node_memory_MemTotal_bytes{job=\"node\",instance=\"$instance\"} - node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"} - node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Buffers_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_Cached_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query: 'node_memory_MemFree_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n unit: { kind: 'Bytes' },\n },\n },\n },\n },\n // This panel is referenced in more than one layout below\n diskIO: {\n kind: 'Panel',\n spec: {\n display: { name: 'Disk I/O Utilization' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n 'rate(node_disk_io_time_seconds_total{job=\"node\",instance=\"$instance\",device!~\"^(md\\\\\\\\d+$|dm-)\"}[$interval])',\n },\n },\n },\n },\n ],\n unit: { kind: 'Percent' },\n },\n },\n },\n },\n filesystemFullness: {\n kind: 'Panel',\n spec: {\n display: { name: 'Filesystem Fullness' },\n plugin: {\n kind: 'TimeSeriesChart',\n spec: {\n queries: [\n {\n kind: 'TimeSeriesQuery',\n spec: {\n plugin: {\n kind: 'PrometheusTimeSeriesQuery',\n spec: {\n query:\n '1 - node_filesystem_free_bytes{job=\"node\",instance=\"$instance\",fstype!=\"rootfs\",mountpoint!~\"/(run|var).*\",mountpoint!=\"\"} / node_filesystem_size_bytes{job=\"node\",instance=\"$instance\"}',\n },\n },\n },\n },\n ],\n unit: { kind: 'Percent' },\n },\n },\n },\n },\n },\n layouts: [\n // Regular Title, no collapse enabled\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'CPU Stats',\n collapse: {\n open: true,\n },\n },\n items: [\n // First Row\n {\n x: 0,\n y: 0,\n width: 12,\n height: 4,\n content: { $ref: '#/spec/panels/cpu' },\n },\n {\n x: 0,\n y: 5,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n ],\n },\n },\n // No title,\n {\n kind: 'Grid',\n spec: {\n items: [\n {\n x: 0,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/diskIO' },\n },\n {\n x: 8,\n y: 0,\n width: 8,\n height: 3,\n content: { $ref: '#/spec/panels/memory' },\n },\n ],\n },\n },\n // Collapsed\n {\n kind: 'Grid',\n spec: {\n display: {\n title: 'Disk Stats',\n collapse: {\n open: false,\n },\n },\n items: [\n {\n x: 18,\n y: 0,\n width: 6,\n height: 2,\n content: { $ref: '#/spec/panels/filesystemFullness' },\n },\n ],\n },\n },\n ],\n },\n};\n\nexport default testDashboard;\n"],"names":["testDashboard","kind","metadata","name","project","created_at","updated_at","version","spec","duration","variables","value","panels","cpu","display","plugin","queries","query","unit","memory","diskIO","filesystemFullness","layouts","title","collapse","open","items","x","y","width","height","content","$ref"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE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AAI,EAAE;oBACJkB,KAAK,EAAE;wBACL;4BACEC,CAAC,EAAE,CAAC;4BACJC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,sBAAsB;6BAAE;yBAC1C;wBACD;4BACEL,CAAC,EAAE,CAAC;4BACJC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,sBAAsB;6BAAE;yBAC1C;qBACF;iBACF;aACF;YACD,YAAY;YACZ;gBACE/B,IAAI,EAAE,MAAM;gBACZO,IAAI,EAAE;oBACJM,OAAO,EAAE;wBACPS,KAAK,EAAE,YAAY;wBACnBC,QAAQ,EAAE;4BACRC,IAAI,EAAE,KAAK;yBACZ;qBACF;oBACDC,KAAK,EAAE;wBACL;4BACEC,CAAC,EAAE,EAAE;4BACLC,CAAC,EAAE,CAAC;4BACJC,KAAK,EAAE,CAAC;4BACRC,MAAM,EAAE,CAAC;4BACTC,OAAO,EAAE;gCAAEC,IAAI,EAAE,kCAAkC;6BAAE;yBACtD;qBACF;iBACF;aACF;SACF;KACF;CACF,AAAC;AAEF,eAAehC,aAAa,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './time-range-params';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAaA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2022 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 * from './time-range-params';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["// Copyright 2022 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\nexport * from './time-range-params';\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,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { QueryParamConfig } from 'use-query-params';
2
+ import { TimeRangeValue, DurationString } from '@perses-dev/core';
3
+ import { TimeRange } from '@perses-dev/plugin-system';
4
+ export declare type TimeOptionValue = Date | DurationString | null | undefined;
5
+ export declare function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined;
6
+ export declare function decodeTimeRangeValue(input: string | Array<string | null> | null | undefined): Date | DurationString | null | undefined;
7
+ /**
8
+ * Custom TimeRangeValue param type
9
+ * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types
10
+ */
11
+ export declare const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
12
+ export declare const timeRangeQueryConfig: {
13
+ start: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
14
+ end: QueryParamConfig<TimeOptionValue, TimeOptionValue>;
15
+ };
16
+ /**
17
+ * Gets the initial time range taking into account URL params and dashboard JSON duration
18
+ * Sets start query param if it is empty on page load
19
+ */
20
+ export declare function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue;
21
+ /**
22
+ * Returns time range getter and setter, set paramsEnabled to false to disable query string serialization
23
+ */
24
+ export declare function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, paramsEnabled?: boolean): TimeRange;
25
+ //# sourceMappingURL=time-range-params.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-range-params.d.ts","sourceRoot":"","sources":["../../src/utils/time-range-params.ts"],"names":[],"mappings":"AAcA,OAAO,EAAkB,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpE,OAAO,EACL,cAAc,EAGd,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,oBAAY,eAAe,GAAG,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAAC;AA2BvE,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAWhG;AAGD,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GACtD,IAAI,GAAG,cAAc,GAAG,IAAI,GAAG,SAAS,CAI1C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAQ7E,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;CAGhC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,iBAAiB,EAAE,cAAc,GAAG,cAAc,CAgBrF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,cAAc,EAAE,aAAa,UAAO,GAAG,SAAS,CA8BvG"}
@@ -0,0 +1,137 @@
1
+ // Copyright 2022 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 { useMemo, useCallback, useState } from 'react';
14
+ import { useQueryParams } from 'use-query-params';
15
+ import { getUnixTime, isDate } from 'date-fns';
16
+ import { isRelativeTimeRange, isDurationString } from '@perses-dev/core';
17
+ /* Interprets an encoded string and returns either the string or null/undefined if not available */ function getEncodedValue(input, allowEmptyString) {
18
+ if (input == null) {
19
+ return input;
20
+ }
21
+ // '' or []
22
+ if (input.length === 0 && (!allowEmptyString || allowEmptyString && input !== '')) {
23
+ return null;
24
+ }
25
+ const str = input instanceof Array ? input[0] : input;
26
+ if (str == null) {
27
+ return str;
28
+ }
29
+ if (!allowEmptyString && str === '') {
30
+ return null;
31
+ }
32
+ return str;
33
+ }
34
+ /* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */ export function encodeTimeRangeValue(timeOptionValue) {
35
+ if (!timeOptionValue) {
36
+ return timeOptionValue;
37
+ }
38
+ if (typeof timeOptionValue === 'string') {
39
+ if (isDurationString(timeOptionValue)) {
40
+ return timeOptionValue;
41
+ }
42
+ }
43
+ return (getUnixTime(timeOptionValue) * 1000).toString();
44
+ }
45
+ /* Converts param input to supported relative or absolute time range format */ export function decodeTimeRangeValue(input) {
46
+ const paramString = getEncodedValue(input);
47
+ if (paramString == null) return paramString;
48
+ return isDurationString(paramString) ? paramString : new Date(Number(paramString));
49
+ }
50
+ /**
51
+ * Custom TimeRangeValue param type
52
+ * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types
53
+ */ export const TimeRangeParam = {
54
+ encode: encodeTimeRangeValue,
55
+ decode: decodeTimeRangeValue,
56
+ equals: (valueA, valueB)=>{
57
+ if (valueA === valueB) return true;
58
+ if (valueA == null || valueB == null) return valueA === valueB;
59
+ return valueA.valueOf() === valueB.valueOf();
60
+ }
61
+ };
62
+ export const timeRangeQueryConfig = {
63
+ start: TimeRangeParam,
64
+ end: TimeRangeParam
65
+ };
66
+ /**
67
+ * Gets the initial time range taking into account URL params and dashboard JSON duration
68
+ * Sets start query param if it is empty on page load
69
+ */ export function useInitialTimeRange(dashboardDuration) {
70
+ const [query] = useQueryParams(timeRangeQueryConfig);
71
+ const { start , end } = query;
72
+ return useMemo(()=>{
73
+ let initialTimeRange = {
74
+ pastDuration: dashboardDuration
75
+ };
76
+ if (!start) {
77
+ return initialTimeRange;
78
+ }
79
+ const startStr = start.toString();
80
+ if (isDurationString(startStr)) {
81
+ initialTimeRange = {
82
+ pastDuration: startStr
83
+ };
84
+ } else if (isDate(start) && isDate(end)) {
85
+ initialTimeRange = {
86
+ start: start,
87
+ end: end
88
+ };
89
+ }
90
+ return initialTimeRange;
91
+ }, [
92
+ start,
93
+ end,
94
+ dashboardDuration
95
+ ]);
96
+ }
97
+ /**
98
+ * Returns time range getter and setter, set paramsEnabled to false to disable query string serialization
99
+ */ export function useSetTimeRangeParams(initialTimeRange, paramsEnabled = true) {
100
+ const [query, setQuery] = useQueryParams(timeRangeQueryConfig);
101
+ // fallback when app does not want query string as source of truth
102
+ const [timeRangeState, setTimeRangeState] = useState(initialTimeRange);
103
+ const { start } = query;
104
+ // set start param on page load if empty
105
+ if (paramsEnabled && !start) {
106
+ if (isRelativeTimeRange(initialTimeRange)) {
107
+ setQuery({
108
+ start: initialTimeRange.pastDuration,
109
+ end: undefined
110
+ });
111
+ }
112
+ }
113
+ const setTimeRange = useCallback((value)=>{
114
+ if (isRelativeTimeRange(value)) {
115
+ setQuery({
116
+ start: value.pastDuration,
117
+ end: undefined
118
+ });
119
+ } else {
120
+ setQuery(value);
121
+ }
122
+ }, [
123
+ setQuery
124
+ ]);
125
+ if (!paramsEnabled) {
126
+ return {
127
+ timeRange: timeRangeState,
128
+ setTimeRange: setTimeRangeState
129
+ };
130
+ }
131
+ return {
132
+ timeRange: initialTimeRange,
133
+ setTimeRange: setTimeRange
134
+ };
135
+ }
136
+
137
+ //# sourceMappingURL=time-range-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/time-range-params.ts"],"sourcesContent":["// Copyright 2022 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 { useMemo, useCallback, useState } from 'react';\nimport { useQueryParams, QueryParamConfig } from 'use-query-params';\nimport { getUnixTime, isDate } from 'date-fns';\nimport {\n TimeRangeValue,\n isRelativeTimeRange,\n isDurationString,\n DurationString,\n AbsoluteTimeRange,\n} from '@perses-dev/core';\nimport { TimeRange } from '@perses-dev/plugin-system';\n\nexport type TimeOptionValue = Date | DurationString | null | undefined;\n\n/* Interprets an encoded string and returns either the string or null/undefined if not available */\nfunction getEncodedValue(\n input: string | Array<string | null> | null | undefined,\n allowEmptyString?: boolean\n): string | null | undefined {\n if (input == null) {\n return input;\n }\n // '' or []\n if (input.length === 0 && (!allowEmptyString || (allowEmptyString && input !== ''))) {\n return null;\n }\n\n const str = input instanceof Array ? input[0] : input;\n if (str == null) {\n return str;\n }\n if (!allowEmptyString && str === '') {\n return null;\n }\n\n return str;\n}\n\n/* Encodes individual TimeRangeValue as a string, depends on whether start is relative or absolute */\nexport function encodeTimeRangeValue(timeOptionValue: TimeOptionValue): string | null | undefined {\n if (!timeOptionValue) {\n return timeOptionValue;\n }\n\n if (typeof timeOptionValue === 'string') {\n if (isDurationString(timeOptionValue)) {\n return timeOptionValue;\n }\n }\n return (getUnixTime(timeOptionValue) * 1000).toString();\n}\n\n/* Converts param input to supported relative or absolute time range format */\nexport function decodeTimeRangeValue(\n input: string | Array<string | null> | null | undefined\n): Date | DurationString | null | undefined {\n const paramString = getEncodedValue(input);\n if (paramString == null) return paramString;\n return isDurationString(paramString) ? paramString : new Date(Number(paramString));\n}\n\n/**\n * Custom TimeRangeValue param type\n * See: https://github.com/pbeshai/use-query-params/tree/master/packages/serialize-query-params#param-types\n */\nexport const TimeRangeParam: QueryParamConfig<TimeOptionValue, TimeOptionValue> = {\n encode: encodeTimeRangeValue,\n decode: decodeTimeRangeValue,\n equals: (valueA: TimeOptionValue, valueB: TimeOptionValue) => {\n if (valueA === valueB) return true;\n if (valueA == null || valueB == null) return valueA === valueB;\n return valueA.valueOf() === valueB.valueOf();\n },\n};\n\nexport const timeRangeQueryConfig = {\n start: TimeRangeParam,\n end: TimeRangeParam,\n};\n\n/**\n * Gets the initial time range taking into account URL params and dashboard JSON duration\n * Sets start query param if it is empty on page load\n */\nexport function useInitialTimeRange(dashboardDuration: DurationString): TimeRangeValue {\n const [query] = useQueryParams(timeRangeQueryConfig);\n const { start, end } = query;\n return useMemo(() => {\n let initialTimeRange: TimeRangeValue = { pastDuration: dashboardDuration };\n if (!start) {\n return initialTimeRange;\n }\n const startStr = start.toString();\n if (isDurationString(startStr)) {\n initialTimeRange = { pastDuration: startStr };\n } else if (isDate(start) && isDate(end)) {\n initialTimeRange = { start: start, end: end } as AbsoluteTimeRange;\n }\n return initialTimeRange;\n }, [start, end, dashboardDuration]);\n}\n\n/**\n * Returns time range getter and setter, set paramsEnabled to false to disable query string serialization\n */\nexport function useSetTimeRangeParams(initialTimeRange: TimeRangeValue, paramsEnabled = true): TimeRange {\n const [query, setQuery] = useQueryParams(timeRangeQueryConfig);\n\n // fallback when app does not want query string as source of truth\n const [timeRangeState, setTimeRangeState] = useState<TimeRangeValue>(initialTimeRange);\n\n const { start } = query;\n\n // set start param on page load if empty\n if (paramsEnabled && !start) {\n if (isRelativeTimeRange(initialTimeRange)) {\n setQuery({ start: initialTimeRange.pastDuration, end: undefined });\n }\n }\n\n const setTimeRange: TimeRange['setTimeRange'] = useCallback(\n (value: TimeRangeValue) => {\n if (isRelativeTimeRange(value)) {\n setQuery({ start: value.pastDuration, end: undefined });\n } else {\n setQuery(value);\n }\n },\n [setQuery]\n );\n\n if (!paramsEnabled) {\n return { timeRange: timeRangeState, setTimeRange: setTimeRangeState };\n }\n return { timeRange: initialTimeRange, setTimeRange: setTimeRange };\n}\n"],"names":["useMemo","useCallback","useState","useQueryParams","getUnixTime","isDate","isRelativeTimeRange","isDurationString","getEncodedValue","input","allowEmptyString","length","str","Array","encodeTimeRangeValue","timeOptionValue","toString","decodeTimeRangeValue","paramString","Date","Number","TimeRangeParam","encode","decode","equals","valueA","valueB","valueOf","timeRangeQueryConfig","start","end","useInitialTimeRange","dashboardDuration","query","initialTimeRange","pastDuration","startStr","useSetTimeRangeParams","paramsEnabled","setQuery","timeRangeState","setTimeRangeState","undefined","setTimeRange","value","timeRange"],"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,OAAO,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AACvD,SAASC,cAAc,QAA0B,kBAAkB,CAAC;AACpE,SAASC,WAAW,EAAEC,MAAM,QAAQ,UAAU,CAAC;AAC/C,SAEEC,mBAAmB,EACnBC,gBAAgB,QAGX,kBAAkB,CAAC;AAK1B,iGAAiG,GACjG,SAASC,eAAe,CACtBC,KAAuD,EACvDC,gBAA0B,EACC;IAC3B,IAAID,KAAK,IAAI,IAAI,EAAE;QACjB,O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d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAOrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAyBpD,CAAC"}
1
+ {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAyBpD,CAAC"}
@@ -13,10 +13,8 @@
13
13
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  import { Box } from '@mui/material';
15
15
  import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
16
- import { PanelDrawer, Dashboard } from '../../components';
17
- import PanelGroupDialog from '../../components/PanelGroupDialog/PanelGroupDialog';
16
+ import { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog } from '../../components';
18
17
  import { DashboardToolbar } from '../../components/DashboardToolbar';
19
- import DeletePanelGroupDialog from '../../components/PanelGroupDialog/DeletePanelGroupDialog';
20
18
  import DeletePanelDialog from '../../components/Panel/DeletePanelDialog';
21
19
  export const DashboardApp = (props)=>{
22
20
  const { dashboardResource } = props;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 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 { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { PanelDrawer, Dashboard } from '../../components';\nimport PanelGroupDialog from '../../components/PanelGroupDialog/PanelGroupDialog';\nimport { DashboardToolbar } from '../../components/DashboardToolbar';\nimport DeletePanelGroupDialog from '../../components/PanelGroupDialog/DeletePanelGroupDialog';\nimport DeletePanelDialog from '../../components/Panel/DeletePanelDialog';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource } = props;\n return (\n <Box\n sx={{\n padding: (theme) => theme.spacing(1, 0),\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar dashboardName={dashboardResource.metadata.name} />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DashboardToolbar","DeletePanelGroupDialog","DeletePanelDialog","DashboardApp","props","dashboardResource","sx","padding","theme","spacing","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","FallbackComponent"],"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;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,UAAU,EAAEC,aAAa,QAAQ,wBAAwB,CAAC;AAEnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,kBAAkB,CAAC;AAC1D,OAAOC,gBAAgB,MAAM,oDAAoD,CAAC;AAClF,SAASC,gBAAgB,QAAQ,mCAAmC,CAAC;AACrE,OAAOC,sBAAsB,MAAM,0DAA0D,CAAC;AAC9F,OAAOC,iBAAiB,MAAM,0CAA0C,CAAC;AAMzE,OAAO,MAAMC,YAAY,GAAG,CAACC,KAAwB,GAAK;IACxD,MAAM,EAAEC,iBAAiB,CAAA,EAAE,GAAGD,KAAK,AAAC;IACpC,qBACE,MAACV,GAAG;QACFY,EAAE,EAAE;YACFC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;YACvCC,QAAQ,EAAE,CAAC;YACXC,SAAS,EAAE,QAAQ;YACnBC,SAAS,EAAE,MAAM;YACjBC,OAAO,EAAE,MAAM;YACfC,aAAa,EAAE,QAAQ;SACxB;;0BAED,KAACd,gBAAgB;gBAACe,aAAa,EAAEV,iBAAiB,CAACW,QAAQ,CAACC,IAAI;cAAI;0BACpE,MAACvB,GAAG;gBAACY,EAAE,EAAE;oBAAEC,OAAO,EAAE,CAACC,KAAK,GAAKA,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC;iBAAE;;kCAC/C,KAACb,aAAa;wBAACsB,iBAAiB,EAAEvB,UAAU;kCAC1C,cAAA,KAACG,SAAS,KAAG;sBACC;kCAChB,KAACD,WAAW,KAAG;kCACf,KAACE,gBAAgB,KAAG;kCACpB,KAACE,sBAAsB,KAAG;kCAC1B,KAACC,iBAAiB,KAAG;;cACjB;;MACF,CACN;AACJ,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"sourcesContent":["// Copyright 2022 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 { Box } from '@mui/material';\nimport { ErrorAlert, ErrorBoundary } from '@perses-dev/components';\nimport { DashboardResource } from '@perses-dev/core';\nimport { PanelDrawer, Dashboard, PanelGroupDialog, DeletePanelGroupDialog } from '../../components';\nimport { DashboardToolbar } from '../../components/DashboardToolbar';\nimport DeletePanelDialog from '../../components/Panel/DeletePanelDialog';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource } = props;\n return (\n <Box\n sx={{\n padding: (theme) => theme.spacing(1, 0),\n flexGrow: 1,\n overflowX: 'hidden',\n overflowY: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <DashboardToolbar dashboardName={dashboardResource.metadata.name} />\n <Box sx={{ padding: (theme) => theme.spacing(2) }}>\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <Dashboard />\n </ErrorBoundary>\n <PanelDrawer />\n <PanelGroupDialog />\n <DeletePanelGroupDialog />\n <DeletePanelDialog />\n </Box>\n </Box>\n );\n};\n"],"names":["Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DeletePanelGroupDialog","DashboardToolbar","DeletePanelDialog","DashboardApp","props","dashboardResource","sx","padding","theme","spacing","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","FallbackComponent"],"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;AAAA,SAASA,GAAG,Q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