@perses-dev/dashboards 0.8.0 → 0.9.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 (196) hide show
  1. package/dist/cjs/components/Dashboard.js +29 -14
  2. package/dist/cjs/components/DashboardToolbar.js +148 -20
  3. package/dist/cjs/components/GridLayout/GridItemContent.js +24 -18
  4. package/dist/cjs/components/GridLayout/GridLayout.js +88 -26
  5. package/dist/cjs/components/GridLayout/GridTitle.js +69 -31
  6. package/dist/cjs/components/GridLayout/index.js +18 -19
  7. package/dist/cjs/components/Panel/Panel.js +145 -55
  8. package/dist/cjs/components/Panel/Panel.test.js +50 -41
  9. package/dist/cjs/components/Panel/PanelContent.js +40 -12
  10. package/dist/cjs/components/Panel/index.js +16 -17
  11. package/dist/cjs/components/PanelDrawer/PanelDrawer.js +82 -107
  12. package/dist/cjs/components/PanelDrawer/PanelDrawer.test.js +91 -92
  13. package/dist/cjs/components/PanelDrawer/PanelEditorForm.js +152 -0
  14. package/dist/cjs/components/PanelDrawer/PanelSpecEditor.js +40 -0
  15. package/dist/cjs/components/PanelDrawer/PanelTypeSelect.js +38 -0
  16. package/dist/cjs/components/PanelDrawer/index.js +28 -0
  17. package/dist/cjs/components/PanelDrawer/panel-editor-model.js +140 -0
  18. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.js +120 -31
  19. package/dist/cjs/components/PanelGroupDialog/PanelGroupDialog.test.js +90 -83
  20. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.js +120 -38
  21. package/dist/cjs/components/TimeRangeControls/TimeRangeControls.test.js +42 -27
  22. package/dist/cjs/components/TimeRangeControls/index.js +16 -17
  23. package/dist/cjs/components/Variables/Variable.js +186 -35
  24. package/dist/cjs/components/Variables/VariableList.js +100 -13
  25. package/dist/cjs/components/Variables/index.js +17 -18
  26. package/dist/cjs/components/index.js +21 -21
  27. package/dist/cjs/context/DashboardAppSlice.js +43 -31
  28. package/dist/cjs/context/DashboardProvider.js +88 -58
  29. package/dist/cjs/context/DatasourceStoreProvider.js +68 -0
  30. package/dist/cjs/context/LayoutsSlice.js +40 -27
  31. package/dist/cjs/context/QueryStringProvider.js +69 -15
  32. package/dist/cjs/context/TemplateVariableProvider.js +128 -136
  33. package/dist/cjs/context/TimeRangeProvider.js +79 -30
  34. package/dist/cjs/context/index.js +22 -22
  35. package/dist/cjs/css/styles.js +43 -39
  36. package/dist/cjs/index.js +19 -20
  37. package/dist/cjs/test/dashboard-provider.js +51 -0
  38. package/dist/cjs/test/index.js +18 -18
  39. package/dist/cjs/test/plugin-registry.js +52 -25
  40. package/dist/cjs/test/render.js +25 -22
  41. package/dist/cjs/test/setup-tests.js +4 -2
  42. package/dist/cjs/test/testDashboard.js +193 -109
  43. package/dist/cjs/utils/functions.js +9 -5
  44. package/dist/cjs/views/ViewDashboard/DashboardApp.js +67 -0
  45. package/dist/cjs/views/ViewDashboard/ViewDashboard.js +83 -0
  46. package/dist/cjs/views/ViewDashboard/index.js +28 -0
  47. package/dist/cjs/views/index.js +16 -17
  48. package/dist/components/Dashboard.js +38 -1
  49. package/dist/components/Dashboard.js.map +1 -0
  50. package/dist/components/DashboardToolbar.d.ts.map +1 -1
  51. package/dist/components/DashboardToolbar.js +154 -1
  52. package/dist/components/DashboardToolbar.js.map +1 -0
  53. package/dist/components/GridLayout/GridItemContent.js +35 -1
  54. package/dist/components/GridLayout/GridItemContent.js.map +1 -0
  55. package/dist/components/GridLayout/GridLayout.js +99 -1
  56. package/dist/components/GridLayout/GridLayout.js.map +1 -0
  57. package/dist/components/GridLayout/GridTitle.js +77 -1
  58. package/dist/components/GridLayout/GridTitle.js.map +1 -0
  59. package/dist/components/GridLayout/index.js +16 -1
  60. package/dist/components/GridLayout/index.js.map +1 -0
  61. package/dist/components/Panel/Panel.d.ts.map +1 -1
  62. package/dist/components/Panel/Panel.js +170 -1
  63. package/dist/components/Panel/Panel.js.map +1 -0
  64. package/dist/components/Panel/Panel.test.js +71 -1
  65. package/dist/components/Panel/Panel.test.js.map +1 -0
  66. package/dist/components/Panel/PanelContent.d.ts +2 -4
  67. package/dist/components/Panel/PanelContent.d.ts.map +1 -1
  68. package/dist/components/Panel/PanelContent.js +40 -1
  69. package/dist/components/Panel/PanelContent.js.map +1 -0
  70. package/dist/components/Panel/index.js +15 -1
  71. package/dist/components/Panel/index.js.map +1 -0
  72. package/dist/components/PanelDrawer/PanelDrawer.d.ts +4 -2
  73. package/dist/components/PanelDrawer/PanelDrawer.d.ts.map +1 -1
  74. package/dist/components/PanelDrawer/PanelDrawer.js +95 -1
  75. package/dist/components/PanelDrawer/PanelDrawer.js.map +1 -0
  76. package/dist/components/PanelDrawer/PanelDrawer.test.js +103 -1
  77. package/dist/components/PanelDrawer/PanelDrawer.test.js.map +1 -0
  78. package/dist/components/PanelDrawer/PanelEditorForm.d.ts +12 -0
  79. package/dist/components/PanelDrawer/PanelEditorForm.d.ts.map +1 -0
  80. package/dist/components/PanelDrawer/PanelEditorForm.js +142 -0
  81. package/dist/components/PanelDrawer/PanelEditorForm.js.map +1 -0
  82. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts +7 -0
  83. package/dist/components/PanelDrawer/PanelSpecEditor.d.ts.map +1 -0
  84. package/dist/components/PanelDrawer/PanelSpecEditor.js +34 -0
  85. package/dist/components/PanelDrawer/PanelSpecEditor.js.map +1 -0
  86. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts +8 -0
  87. package/dist/components/PanelDrawer/PanelTypeSelect.d.ts.map +1 -0
  88. package/dist/components/PanelDrawer/PanelTypeSelect.js +34 -0
  89. package/dist/components/PanelDrawer/PanelTypeSelect.js.map +1 -0
  90. package/dist/components/PanelDrawer/index.d.ts +2 -0
  91. package/dist/components/PanelDrawer/index.d.ts.map +1 -0
  92. package/dist/components/PanelDrawer/index.js +15 -0
  93. package/dist/components/PanelDrawer/index.js.map +1 -0
  94. package/dist/components/PanelDrawer/panel-editor-model.d.ts +27 -0
  95. package/dist/components/PanelDrawer/panel-editor-model.d.ts.map +1 -0
  96. package/dist/components/PanelDrawer/panel-editor-model.js +133 -0
  97. package/dist/components/PanelDrawer/panel-editor-model.js.map +1 -0
  98. package/dist/components/PanelGroupDialog/PanelGroupDialog.d.ts.map +1 -1
  99. package/dist/components/PanelGroupDialog/PanelGroupDialog.js +138 -1
  100. package/dist/components/PanelGroupDialog/PanelGroupDialog.js.map +1 -0
  101. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js +95 -1
  102. package/dist/components/PanelGroupDialog/PanelGroupDialog.test.js.map +1 -0
  103. package/dist/components/TimeRangeControls/TimeRangeControls.js +137 -1
  104. package/dist/components/TimeRangeControls/TimeRangeControls.js.map +1 -0
  105. package/dist/components/TimeRangeControls/TimeRangeControls.test.js +59 -1
  106. package/dist/components/TimeRangeControls/TimeRangeControls.test.js.map +1 -0
  107. package/dist/components/TimeRangeControls/index.js +15 -1
  108. package/dist/components/TimeRangeControls/index.js.map +1 -0
  109. package/dist/components/Variables/Variable.d.ts.map +1 -1
  110. package/dist/components/Variables/Variable.js +202 -1
  111. package/dist/components/Variables/Variable.js.map +1 -0
  112. package/dist/components/Variables/VariableList.js +108 -1
  113. package/dist/components/Variables/VariableList.js.map +1 -0
  114. package/dist/components/Variables/index.js +16 -1
  115. package/dist/components/Variables/index.js.map +1 -0
  116. package/dist/components/index.d.ts +1 -0
  117. package/dist/components/index.d.ts.map +1 -1
  118. package/dist/components/index.js +20 -1
  119. package/dist/components/index.js.map +1 -0
  120. package/dist/context/DashboardAppSlice.js +45 -1
  121. package/dist/context/DashboardAppSlice.js.map +1 -0
  122. package/dist/context/DashboardProvider.d.ts +4 -2
  123. package/dist/context/DashboardProvider.d.ts.map +1 -1
  124. package/dist/context/DashboardProvider.js +107 -1
  125. package/dist/context/DashboardProvider.js.map +1 -0
  126. package/dist/context/DatasourceStoreProvider.d.ts +16 -0
  127. package/dist/context/DatasourceStoreProvider.d.ts.map +1 -0
  128. package/dist/context/DatasourceStoreProvider.js +64 -0
  129. package/dist/context/DatasourceStoreProvider.js.map +1 -0
  130. package/dist/context/LayoutsSlice.js +43 -1
  131. package/dist/context/LayoutsSlice.js.map +1 -0
  132. package/dist/context/QueryStringProvider.js +40 -1
  133. package/dist/context/QueryStringProvider.js.map +1 -0
  134. package/dist/context/TemplateVariableProvider.d.ts +6 -3
  135. package/dist/context/TemplateVariableProvider.d.ts.map +1 -1
  136. package/dist/context/TemplateVariableProvider.js +192 -1
  137. package/dist/context/TemplateVariableProvider.js.map +1 -0
  138. package/dist/context/TimeRangeProvider.js +72 -1
  139. package/dist/context/TimeRangeProvider.js.map +1 -0
  140. package/dist/context/index.d.ts +3 -2
  141. package/dist/context/index.d.ts.map +1 -1
  142. package/dist/context/index.js +21 -1
  143. package/dist/context/index.js.map +1 -0
  144. package/dist/css/styles.js +186 -1
  145. package/dist/css/styles.js.map +1 -0
  146. package/dist/index.js +17 -1
  147. package/dist/index.js.map +1 -0
  148. package/dist/test/dashboard-provider.d.ts +19 -0
  149. package/dist/test/dashboard-provider.d.ts.map +1 -0
  150. package/dist/test/dashboard-provider.js +40 -0
  151. package/dist/test/dashboard-provider.js.map +1 -0
  152. package/dist/test/index.d.ts +1 -0
  153. package/dist/test/index.d.ts.map +1 -1
  154. package/dist/test/index.js +17 -1
  155. package/dist/test/index.js.map +1 -0
  156. package/dist/test/plugin-registry.d.ts +2 -3
  157. package/dist/test/plugin-registry.d.ts.map +1 -1
  158. package/dist/test/plugin-registry.js +74 -1
  159. package/dist/test/plugin-registry.js.map +1 -0
  160. package/dist/test/render.d.ts +1 -2
  161. package/dist/test/render.d.ts.map +1 -1
  162. package/dist/test/render.js +34 -1
  163. package/dist/test/render.js.map +1 -0
  164. package/dist/test/setup-tests.js +18 -1
  165. package/dist/test/setup-tests.js.map +1 -0
  166. package/dist/test/testDashboard.d.ts.map +1 -1
  167. package/dist/test/testDashboard.js +274 -1
  168. package/dist/test/testDashboard.js.map +1 -0
  169. package/dist/utils/functions.js +17 -1
  170. package/dist/utils/functions.js.map +1 -0
  171. package/dist/views/ViewDashboard/DashboardApp.d.ts +7 -0
  172. package/dist/views/ViewDashboard/DashboardApp.d.ts.map +1 -0
  173. package/dist/views/ViewDashboard/DashboardApp.js +56 -0
  174. package/dist/views/ViewDashboard/DashboardApp.js.map +1 -0
  175. package/dist/views/{ViewDashboard.d.ts → ViewDashboard/ViewDashboard.d.ts} +3 -1
  176. package/dist/views/ViewDashboard/ViewDashboard.d.ts.map +1 -0
  177. package/dist/views/ViewDashboard/ViewDashboard.js +79 -0
  178. package/dist/views/ViewDashboard/ViewDashboard.js.map +1 -0
  179. package/dist/views/ViewDashboard/index.d.ts +2 -0
  180. package/dist/views/ViewDashboard/index.d.ts.map +1 -0
  181. package/dist/views/ViewDashboard/index.js +15 -0
  182. package/dist/views/ViewDashboard/index.js.map +1 -0
  183. package/dist/views/index.js +15 -1
  184. package/dist/views/index.js.map +1 -0
  185. package/package.json +13 -7
  186. package/dist/cjs/components/PanelDrawer/PanelOptionsEditor.js +0 -19
  187. package/dist/cjs/views/DashboardApp.js +0 -46
  188. package/dist/cjs/views/ViewDashboard.js +0 -43
  189. package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts +0 -9
  190. package/dist/components/PanelDrawer/PanelOptionsEditor.d.ts.map +0 -1
  191. package/dist/components/PanelDrawer/PanelOptionsEditor.js +0 -1
  192. package/dist/views/DashboardApp.d.ts +0 -4
  193. package/dist/views/DashboardApp.d.ts.map +0 -1
  194. package/dist/views/DashboardApp.js +0 -1
  195. package/dist/views/ViewDashboard.d.ts.map +0 -1
  196. package/dist/views/ViewDashboard.js +0 -1
@@ -1 +1,274 @@
1
- const testDashboard={kind:"Dashboard",metadata:{name:"Node Stats",project:"perses",created_at:"2021-11-09",updated_at:"2021-11-09",version:0},spec:{datasource:{kind:"Prometheus",global:!0,name:"Public Prometheus Demo Server"},duration:"24h",variables:[{name:"job",kind:"TextVariable",options:{value:"node"}},{name:"instance",kind:"TextVariable",options:{value:"demo.do.prometheus.io:9100"}},{name:"interval",kind:"TextVariable",options:{value:"1m"}}],panels:{cpu:{kind:"LineChart",display:{name:"CPU"},options:{queries:[{kind:"PrometheusGraphQuery",options:{query:'avg without (cpu)(rate(node_cpu_seconds_total{job="node",instance="$instance",mode!="idle"}[$interval]))'}}],unit:{kind:"%"}}},memory:{kind:"LineChart",display:{name:"Memory"},options:{queries:[{kind:"PrometheusGraphQuery",options:{query:'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"}'}},{kind:"PrometheusGraphQuery",options:{query:'node_memory_Buffers_bytes{job="node",instance="$instance"}'}},{kind:"PrometheusGraphQuery",options:{query:'node_memory_Cached_bytes{job="node",instance="$instance"}'}},{kind:"PrometheusGraphQuery",options:{query:'node_memory_MemFree_bytes{job="node",instance="$instance"}'}}],unit:{kind:"Bytes"}}},diskIO:{kind:"LineChart",display:{name:"Disk I/O Utilization"},options:{queries:[{kind:"PrometheusGraphQuery",options:{query:'rate(node_disk_io_time_seconds_total{job="node",instance="$instance",device!~"^(md\\\\d+$|dm-)"}[$interval])'}}],unit:{kind:"Percent"}}},filesystemFullness:{kind:"LineChart",display:{name:"Filesystem Fullness"},options:{queries:[{kind:"PrometheusGraphQuery",options:{query:'1 - node_filesystem_free_bytes{job="node",instance="$instance",fstype!="rootfs",mountpoint!~"/(run|var).*",mountpoint!=""} / node_filesystem_size_bytes{job="node",instance="$instance"}'}}],unit:{kind:"Percent"}}}},layouts:[{kind:"Grid",spec:{display:{title:"CPU Stats"},items:[{x:0,y:0,width:12,height:4,content:{$ref:"#/spec/panels/cpu"}}]}},{kind:"Grid",spec:{items:[{x:8,y:0,width:8,height:3,content:{$ref:"#/spec/panels/memory"}}]}},{kind:"Grid",spec:{display:{title:"Disk Stats",collapse:{open:!1}},items:[{x:0,y:0,width:6,height:2,content:{$ref:"#/spec/panels/diskIO"}},{x:18,y:0,width:6,height:2,content:{$ref:"#/spec/panels/filesystemFullness"}}]}}]}};export default testDashboard;
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
+ const testDashboard = {
14
+ kind: 'Dashboard',
15
+ metadata: {
16
+ name: 'Node Stats',
17
+ project: 'perses',
18
+ created_at: '2021-11-09',
19
+ updated_at: '2021-11-09',
20
+ version: 0
21
+ },
22
+ spec: {
23
+ duration: '24h',
24
+ variables: [
25
+ {
26
+ kind: 'TextVariable',
27
+ spec: {
28
+ name: 'job',
29
+ value: 'node'
30
+ }
31
+ },
32
+ {
33
+ kind: 'TextVariable',
34
+ spec: {
35
+ name: 'instance',
36
+ value: 'demo.do.prometheus.io:9100'
37
+ }
38
+ },
39
+ {
40
+ kind: 'TextVariable',
41
+ spec: {
42
+ name: 'interval',
43
+ value: '1m'
44
+ }
45
+ }
46
+ ],
47
+ panels: {
48
+ cpu: {
49
+ kind: 'Panel',
50
+ spec: {
51
+ display: {
52
+ name: 'CPU'
53
+ },
54
+ plugin: {
55
+ kind: 'TimeSeriesChart',
56
+ spec: {
57
+ queries: [
58
+ {
59
+ kind: 'TimeSeriesQuery',
60
+ spec: {
61
+ plugin: {
62
+ kind: 'PrometheusTimeSeriesQuery',
63
+ spec: {
64
+ query: 'avg without (cpu)(rate(node_cpu_seconds_total{job="node",instance="$instance",mode!="idle"}[$interval]))'
65
+ }
66
+ }
67
+ }
68
+ }
69
+ ],
70
+ unit: {
71
+ kind: '%'
72
+ }
73
+ }
74
+ }
75
+ }
76
+ },
77
+ memory: {
78
+ kind: 'Panel',
79
+ spec: {
80
+ display: {
81
+ name: 'Memory'
82
+ },
83
+ plugin: {
84
+ kind: 'TimeSeriesChart',
85
+ spec: {
86
+ queries: [
87
+ {
88
+ kind: 'TimeSeriesQuery',
89
+ spec: {
90
+ plugin: {
91
+ kind: 'PrometheusTimeSeriesQuery',
92
+ spec: {
93
+ query: '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"}'
94
+ }
95
+ }
96
+ }
97
+ },
98
+ {
99
+ kind: 'TimeSeriesQuery',
100
+ spec: {
101
+ plugin: {
102
+ kind: 'PrometheusTimeSeriesQuery',
103
+ spec: {
104
+ query: 'node_memory_Buffers_bytes{job="node",instance="$instance"}'
105
+ }
106
+ }
107
+ }
108
+ },
109
+ {
110
+ kind: 'TimeSeriesQuery',
111
+ spec: {
112
+ plugin: {
113
+ kind: 'PrometheusTimeSeriesQuery',
114
+ spec: {
115
+ query: 'node_memory_Cached_bytes{job="node",instance="$instance"}'
116
+ }
117
+ }
118
+ }
119
+ },
120
+ {
121
+ kind: 'TimeSeriesQuery',
122
+ spec: {
123
+ plugin: {
124
+ kind: 'PrometheusTimeSeriesQuery',
125
+ spec: {
126
+ query: 'node_memory_MemFree_bytes{job="node",instance="$instance"}'
127
+ }
128
+ }
129
+ }
130
+ }
131
+ ],
132
+ unit: {
133
+ kind: 'Bytes'
134
+ }
135
+ }
136
+ }
137
+ }
138
+ },
139
+ diskIO: {
140
+ kind: 'Panel',
141
+ spec: {
142
+ display: {
143
+ name: 'Disk I/O Utilization'
144
+ },
145
+ plugin: {
146
+ kind: 'TimeSeriesChart',
147
+ spec: {
148
+ queries: [
149
+ {
150
+ kind: 'TimeSeriesQuery',
151
+ spec: {
152
+ plugin: {
153
+ kind: 'PrometheusTimeSeriesQuery',
154
+ spec: {
155
+ query: 'rate(node_disk_io_time_seconds_total{job="node",instance="$instance",device!~"^(md\\\\d+$|dm-)"}[$interval])'
156
+ }
157
+ }
158
+ }
159
+ }
160
+ ],
161
+ unit: {
162
+ kind: 'Percent'
163
+ }
164
+ }
165
+ }
166
+ }
167
+ },
168
+ filesystemFullness: {
169
+ kind: 'Panel',
170
+ spec: {
171
+ display: {
172
+ name: 'Filesystem Fullness'
173
+ },
174
+ plugin: {
175
+ kind: 'TimeSeriesChart',
176
+ spec: {
177
+ queries: [
178
+ {
179
+ kind: 'TimeSeriesQuery',
180
+ spec: {
181
+ plugin: {
182
+ kind: 'PrometheusTimeSeriesQuery',
183
+ spec: {
184
+ query: '1 - node_filesystem_free_bytes{job="node",instance="$instance",fstype!="rootfs",mountpoint!~"/(run|var).*",mountpoint!=""} / node_filesystem_size_bytes{job="node",instance="$instance"}'
185
+ }
186
+ }
187
+ }
188
+ }
189
+ ],
190
+ unit: {
191
+ kind: 'Percent'
192
+ }
193
+ }
194
+ }
195
+ }
196
+ }
197
+ },
198
+ layouts: [
199
+ // Regular Title, no collapse enabled
200
+ {
201
+ kind: 'Grid',
202
+ spec: {
203
+ display: {
204
+ title: 'CPU Stats'
205
+ },
206
+ items: [
207
+ // First Row
208
+ {
209
+ x: 0,
210
+ y: 0,
211
+ width: 12,
212
+ height: 4,
213
+ content: {
214
+ $ref: '#/spec/panels/cpu'
215
+ }
216
+ }
217
+ ]
218
+ }
219
+ },
220
+ // No title,
221
+ {
222
+ kind: 'Grid',
223
+ spec: {
224
+ items: [
225
+ {
226
+ x: 8,
227
+ y: 0,
228
+ width: 8,
229
+ height: 3,
230
+ content: {
231
+ $ref: '#/spec/panels/memory'
232
+ }
233
+ }
234
+ ]
235
+ }
236
+ },
237
+ // Collapsed
238
+ {
239
+ kind: 'Grid',
240
+ spec: {
241
+ display: {
242
+ title: 'Disk Stats',
243
+ collapse: {
244
+ open: false
245
+ }
246
+ },
247
+ items: [
248
+ {
249
+ x: 0,
250
+ y: 0,
251
+ width: 6,
252
+ height: 2,
253
+ content: {
254
+ $ref: '#/spec/panels/diskIO'
255
+ }
256
+ },
257
+ {
258
+ x: 18,
259
+ y: 0,
260
+ width: 6,
261
+ height: 2,
262
+ content: {
263
+ $ref: '#/spec/panels/filesystemFullness'
264
+ }
265
+ }
266
+ ]
267
+ }
268
+ }
269
+ ]
270
+ }
271
+ };
272
+ export default testDashboard;
273
+
274
+ //# sourceMappingURL=testDashboard.js.map
@@ -0,0 +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 },\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 },\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","items","x","y","width","height","content","$ref","collapse","open"],"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,Y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AE;4BACRC,IAAI,EAAE,KAAK;yBACZ;qBACF;oBACDR,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,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,eAAe9B,aAAa,CAAC"}
@@ -1 +1,17 @@
1
- export const removeWhiteSpacesAndSpecialCharacters=e=>e.replace(/\s+/g,"");
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 const removeWhiteSpacesAndSpecialCharacters = (str)=>{
14
+ return str.replace(/\s+/g, '');
15
+ };
16
+
17
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/functions.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 const removeWhiteSpacesAndSpecialCharacters = (str: string) => {\n return str.replace(/\\s+/g, '');\n};\n"],"names":["removeWhiteSpacesAndSpecialCharacters","str","replace"],"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,MAAMA,qCAAqC,GAAG,CAACC,GAAW,GAAK;IACpE,OAAOA,GAAG,CAACC,OAAO,SAAS,EAAE,CAAC,CAAC;AACjC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { DashboardResource } from '@perses-dev/core';
3
+ export interface DashboardAppProps {
4
+ dashboardResource: DashboardResource;
5
+ }
6
+ export declare const DashboardApp: (props: DashboardAppProps) => JSX.Element;
7
+ //# sourceMappingURL=DashboardApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DashboardApp.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/DashboardApp.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,eAAO,MAAM,YAAY,UAAW,iBAAiB,gBAyBpD,CAAC"}
@@ -0,0 +1,56 @@
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { Box } from '@mui/material';
15
+ import { ErrorAlert, ErrorBoundary } from '@perses-dev/components';
16
+ import { PanelDrawer, Dashboard } from '../../components';
17
+ import PanelGroupDialog from '../../components/PanelGroupDialog/PanelGroupDialog';
18
+ import { DashboardToolbar } from '../../components/DashboardToolbar';
19
+ import { useDashboard, useDashboardApp } from '../../context';
20
+ export const DashboardApp = (props)=>{
21
+ const { dashboardResource } = props;
22
+ const { dashboard } = useDashboard();
23
+ const { panelGroupDialog } = useDashboardApp();
24
+ return /*#__PURE__*/ _jsxs(Box, {
25
+ sx: {
26
+ padding: (theme)=>theme.spacing(1, 0),
27
+ flexGrow: 1,
28
+ overflowX: 'hidden',
29
+ overflowY: 'auto',
30
+ display: 'flex',
31
+ flexDirection: 'column'
32
+ },
33
+ children: [
34
+ /*#__PURE__*/ _jsx(DashboardToolbar, {
35
+ dashboardName: dashboardResource.metadata.name
36
+ }),
37
+ /*#__PURE__*/ _jsxs(Box, {
38
+ sx: {
39
+ padding: (theme)=>theme.spacing(2)
40
+ },
41
+ children: [
42
+ /*#__PURE__*/ _jsx(ErrorBoundary, {
43
+ FallbackComponent: ErrorAlert,
44
+ children: /*#__PURE__*/ _jsx(Dashboard, {
45
+ spec: dashboard
46
+ })
47
+ }),
48
+ /*#__PURE__*/ _jsx(PanelDrawer, {}),
49
+ panelGroupDialog && /*#__PURE__*/ _jsx(PanelGroupDialog, {})
50
+ ]
51
+ })
52
+ ]
53
+ });
54
+ };
55
+
56
+ //# sourceMappingURL=DashboardApp.js.map
@@ -0,0 +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 { useDashboard, useDashboardApp } from '../../context';\n\nexport interface DashboardAppProps {\n dashboardResource: DashboardResource;\n}\n\nexport const DashboardApp = (props: DashboardAppProps) => {\n const { dashboardResource } = props;\n const { dashboard } = useDashboard();\n const { panelGroupDialog } = useDashboardApp();\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 spec={dashboard} />\n </ErrorBoundary>\n <PanelDrawer />\n {panelGroupDialog && <PanelGroupDialog />}\n </Box>\n </Box>\n );\n};\n"],"names":["Box","ErrorAlert","ErrorBoundary","PanelDrawer","Dashboard","PanelGroupDialog","DashboardToolbar","useDashboard","useDashboardApp","DashboardApp","props","dashboardResource","dashboard","panelGroupDialog","sx","padding","theme","spacing","flexGrow","overflowX","overflowY","display","flexDirection","dashboardName","metadata","name","FallbackComponent","spec"],"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;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8 +1,10 @@
1
1
  /// <reference types="react" />
2
2
  import { BoxProps } from '@mui/material';
3
3
  import { DashboardResource } from '@perses-dev/core';
4
- export interface ViewDashboardProps extends BoxProps {
4
+ import { DatasourceStoreProviderProps } from '../../context';
5
+ export interface ViewDashboardProps extends Omit<BoxProps, 'children'> {
5
6
  dashboardResource: DashboardResource;
7
+ datasourceApi: DatasourceStoreProviderProps['datasourceApi'];
6
8
  }
7
9
  /**
8
10
  * The View for displaying a Dashboard, along with the UI for selecting variable values.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewDashboard.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/ViewDashboard.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAO,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAuB,MAAM,kBAAkB,CAAC;AAG1E,OAAO,EAIL,4BAA4B,EAE7B,MAAM,eAAe,CAAC;AAGvB,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC;IACpE,iBAAiB,EAAE,iBAAiB,CAAC;IACrC,aAAa,EAAE,4BAA4B,CAAC,eAAe,CAAC,CAAC;CAC9D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,eA8CtD"}
@@ -0,0 +1,79 @@
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 { jsx as _jsx } from "react/jsx-runtime";
14
+ import { useEffect } from 'react';
15
+ import { Box } from '@mui/material';
16
+ import { getDefaultTimeRange } from '@perses-dev/core';
17
+ import { useQueryString } from '@perses-dev/plugin-system';
18
+ import { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';
19
+ import { TimeRangeProvider, TemplateVariableProvider, DashboardProvider, DatasourceStoreProvider } from '../../context';
20
+ import { DashboardApp } from './DashboardApp';
21
+ /**
22
+ * The View for displaying a Dashboard, along with the UI for selecting variable values.
23
+ */ export function ViewDashboard(props) {
24
+ const { dashboardResource , datasourceApi , sx , ...others } = props;
25
+ const { spec } = dashboardResource;
26
+ const { queryString , setQueryString } = useQueryString();
27
+ var _duration;
28
+ const dashboardDuration = (_duration = spec.duration) !== null && _duration !== void 0 ? _duration : '1h';
29
+ const defaultTimeRange = getDefaultTimeRange(dashboardDuration, queryString);
30
+ // TODO: add reusable sync query string or no-op util
31
+ useEffect(()=>{
32
+ const currentParams = Object.fromEntries([
33
+ ...queryString
34
+ ]);
35
+ // if app does not provide query string implementation, setTimeRange is used instead
36
+ if (!currentParams.start && setQueryString) {
37
+ // default to duration in dashboard definition if start param is not already set
38
+ queryString.set('start', dashboardDuration);
39
+ setQueryString(queryString);
40
+ }
41
+ }, [
42
+ dashboardDuration,
43
+ queryString,
44
+ setQueryString
45
+ ]);
46
+ return /*#__PURE__*/ _jsx(DatasourceStoreProvider, {
47
+ dashboardResource: dashboardResource,
48
+ datasourceApi: datasourceApi,
49
+ children: /*#__PURE__*/ _jsx(DashboardProvider, {
50
+ initialState: {
51
+ dashboardSpec: spec
52
+ },
53
+ children: /*#__PURE__*/ _jsx(TimeRangeProvider, {
54
+ initialTimeRange: defaultTimeRange,
55
+ children: /*#__PURE__*/ _jsx(TemplateVariableProvider, {
56
+ initialVariableDefinitions: spec.variables,
57
+ children: /*#__PURE__*/ _jsx(Box, {
58
+ sx: combineSx({
59
+ display: 'flex',
60
+ width: '100%',
61
+ height: '100%',
62
+ position: 'relative',
63
+ overflow: 'hidden'
64
+ }, sx),
65
+ ...others,
66
+ children: /*#__PURE__*/ _jsx(ErrorBoundary, {
67
+ FallbackComponent: ErrorAlert,
68
+ children: /*#__PURE__*/ _jsx(DashboardApp, {
69
+ dashboardResource: dashboardResource
70
+ })
71
+ })
72
+ })
73
+ })
74
+ })
75
+ })
76
+ });
77
+ }
78
+
79
+ //# sourceMappingURL=ViewDashboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/ViewDashboard.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 { useEffect } from 'react';\nimport { Box, BoxProps } from '@mui/material';\nimport { DashboardResource, getDefaultTimeRange } from '@perses-dev/core';\nimport { useQueryString } from '@perses-dev/plugin-system';\nimport { ErrorBoundary, ErrorAlert, combineSx } from '@perses-dev/components';\nimport {\n TimeRangeProvider,\n TemplateVariableProvider,\n DashboardProvider,\n DatasourceStoreProviderProps,\n DatasourceStoreProvider,\n} from '../../context';\nimport { DashboardApp } from './DashboardApp';\n\nexport interface ViewDashboardProps extends Omit<BoxProps, 'children'> {\n dashboardResource: DashboardResource;\n datasourceApi: DatasourceStoreProviderProps['datasourceApi'];\n}\n\n/**\n * The View for displaying a Dashboard, along with the UI for selecting variable values.\n */\nexport function ViewDashboard(props: ViewDashboardProps) {\n const { dashboardResource, datasourceApi, sx, ...others } = props;\n const { spec } = dashboardResource;\n\n const { queryString, setQueryString } = useQueryString();\n const dashboardDuration = spec.duration ?? '1h';\n const defaultTimeRange = getDefaultTimeRange(dashboardDuration, queryString);\n\n // TODO: add reusable sync query string or no-op util\n useEffect(() => {\n const currentParams = Object.fromEntries([...queryString]);\n // if app does not provide query string implementation, setTimeRange is used instead\n if (!currentParams.start && setQueryString) {\n // default to duration in dashboard definition if start param is not already set\n queryString.set('start', dashboardDuration);\n setQueryString(queryString);\n }\n }, [dashboardDuration, queryString, setQueryString]);\n\n return (\n <DatasourceStoreProvider dashboardResource={dashboardResource} datasourceApi={datasourceApi}>\n <DashboardProvider initialState={{ dashboardSpec: spec }}>\n <TimeRangeProvider initialTimeRange={defaultTimeRange}>\n <TemplateVariableProvider initialVariableDefinitions={spec.variables}>\n <Box\n sx={combineSx(\n {\n display: 'flex',\n width: '100%',\n height: '100%',\n position: 'relative',\n overflow: 'hidden',\n },\n sx\n )}\n {...others}\n >\n <ErrorBoundary FallbackComponent={ErrorAlert}>\n <DashboardApp dashboardResource={dashboardResource} />\n </ErrorBoundary>\n </Box>\n </TemplateVariableProvider>\n </TimeRangeProvider>\n </DashboardProvider>\n </DatasourceStoreProvider>\n );\n}\n"],"names":["useEffect","Box","getDefaultTimeRange","useQueryString","ErrorBoundary","ErrorAlert","combineSx","TimeRangeProvider","TemplateVariableProvider","DashboardProvider","DatasourceStoreProvider","DashboardApp","ViewDashboard","props","dashboardResource","datasourceApi","sx","others","spec","queryString","setQueryString","dashboardDuration","duration","defaultTimeRange","currentParams","Object","fromEntries","start","set","initialState","dashboardSpec","initialTimeRange","initialVariableDefinitions","variables","display","width","height","position","overflow","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,SAAS,QAAQ,OAAO,CAAC;AAClC,SAASC,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAA4BC,mBAAmB,QAAQ,kBAAkB,CAAC;AAC1E,SAASC,cAAc,QAAQ,2BAA2B,CAAC;AAC3D,SAASC,aAAa,EAAEC,UAAU,EAAE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,EAAEZ,IAAI;aAAE;sBACtD,cAAA,KAACX,iBAAiB;gBAACwB,gBAAgB,EAAER,gBAAgB;0BACnD,cAAA,KAACf,wBAAwB;oBAACwB,0BAA0B,EAAEd,IAAI,CAACe,SAAS;8BAClE,cAAA,KAAChC,GAAG;wBACFe,EAAE,EAAEV,SAAS,CACX;4BACE4B,OAAO,EAAE,MAAM;4BACfC,KAAK,EAAE,MAAM;4BACbC,MAAM,EAAE,MAAM;4BACdC,QAAQ,EAAE,UAAU;4BACpBC,QAAQ,EAAE,QAAQ;yBACnB,EACDtB,EAAE,CACH;wBACA,GAAGC,MAAM;kCAEV,cAAA,KAACb,aAAa;4BAACmC,iBAAiB,EAAElC,UAAU;sCAC1C,cAAA,KAACM,YAAY;gCAACG,iBAAiB,EAAEA,iBAAiB;8BAAI;0BACxC;sBACZ;kBACmB;cACT;UACF;MACI,CAC1B;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './ViewDashboard';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/ViewDashboard/index.ts"],"names":[],"mappings":"AAaA,cAAc,iBAAiB,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 './ViewDashboard';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/views/ViewDashboard/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 './ViewDashboard';\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,iBAAiB,CAAC"}
@@ -1 +1,15 @@
1
- export*from"./ViewDashboard";
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 './ViewDashboard';
14
+
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/views/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 './ViewDashboard';\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,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@perses-dev/dashboards",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "The dashboards feature in Perses",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/perses/perses/blob/main/README.md",
@@ -16,19 +16,24 @@
16
16
  "types": "dist/index.d.ts",
17
17
  "scripts": {
18
18
  "clean": "rimraf dist/",
19
- "build": "tsc --build",
20
- "build:cjs": "tsc --project ./tsconfig.cjs.json",
19
+ "build": "concurrently \"npm:build:*\"",
20
+ "build:cjs": "swc ./src -d dist/cjs --config-file ../.cjs.swcrc",
21
+ "build:esm": "swc ./src -d dist --config-file ../.swcrc",
22
+ "build:types": "tsc --emitDeclarationOnly --declaration --preserveWatchOutput",
23
+ "start": "concurrently -P \"npm:build:* -- {*}\" -- --watch",
21
24
  "test": "TZ=UTC jest",
22
- "test:watch": "TZ=UTC jest --watch",
25
+ "test:watch": "npm run test -- --watch",
23
26
  "lint": "eslint src --ext .ts,.tsx",
24
27
  "lint:fix": "eslint --fix src --ext .ts,.tsx"
25
28
  },
26
29
  "dependencies": {
27
- "@perses-dev/components": "^0.8.0",
28
- "@perses-dev/core": "^0.8.0",
29
- "@perses-dev/plugin-system": "^0.8.0",
30
+ "@perses-dev/components": "^0.9.0",
31
+ "@perses-dev/core": "^0.9.0",
32
+ "@perses-dev/plugin-system": "^0.9.0",
30
33
  "@types/react-grid-layout": "^1.3.2",
34
+ "date-fns": "^2.28.0",
31
35
  "immer": "^9.0.15",
36
+ "mdi-material-ui": "^7.4.0",
32
37
  "react-grid-layout": "^1.3.4",
33
38
  "react-intersection-observer": "^9.4.0",
34
39
  "use-immer": "^0.7.0",
@@ -40,6 +45,7 @@
40
45
  },
41
46
  "peerDependencies": {
42
47
  "@mui/material": "^5.6.0",
48
+ "@tanstack/react-query": "^4.7.1",
43
49
  "react": "^17.0.2 || ^18.0.0",
44
50
  "react-dom": "^17.0.2 || ^18.0.0"
45
51
  },