@ssa-ui-kit/infra-dash 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/BasePanel/BasePanel.d.ts +4 -0
  3. package/dist/components/BasePanel/index.d.ts +1 -0
  4. package/dist/components/DashboardError/DashboardError.d.ts +4 -0
  5. package/dist/components/DashboardError/index.d.ts +1 -0
  6. package/dist/components/ErrorPanel/ErrorPanel.d.ts +5 -0
  7. package/dist/components/ErrorPanel/index.d.ts +1 -0
  8. package/dist/components/LoadingDashboard/LoadingDashboard.d.ts +4 -0
  9. package/dist/components/LoadingDashboard/index.d.ts +1 -0
  10. package/dist/components/LoadingPanel/LoadingPanel.d.ts +5 -0
  11. package/dist/components/LoadingPanel/index.d.ts +1 -0
  12. package/dist/entities/dashboard/index.d.ts +71 -0
  13. package/dist/entities/grafana-dashboard/index.d.ts +25 -0
  14. package/dist/entities/grafana-panel/index.d.ts +25 -0
  15. package/dist/entities/panel/index.d.ts +2 -0
  16. package/dist/entities/panel/usePanelData.d.ts +29 -0
  17. package/dist/entities/panel/withPanelData.d.ts +17 -0
  18. package/dist/features/DashboardPanelGrid.d.ts +19 -0
  19. package/dist/index.d.ts +7 -0
  20. package/dist/index.js +2971 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/panels/BarGaugePanel/BarGaugePanel.d.ts +11 -0
  23. package/dist/panels/BarGaugePanel/data-adapters/grafana.d.ts +16 -0
  24. package/dist/panels/BarGaugePanel/index.d.ts +1 -0
  25. package/dist/panels/GaugePanel/GaugePanel.d.ts +9 -0
  26. package/dist/panels/GaugePanel/data-adapters/grafana.d.ts +17 -0
  27. package/dist/panels/GaugePanel/index.d.ts +1 -0
  28. package/dist/panels/TimeseriesPanel/TimeseriesPanel.d.ts +9 -0
  29. package/dist/panels/TimeseriesPanel/data-adapters/grafana.d.ts +18 -0
  30. package/dist/panels/TimeseriesPanel/index.d.ts +1 -0
  31. package/dist/panels/index.d.ts +3 -0
  32. package/dist/provider.d.ts +11 -0
  33. package/dist/shared/context.d.ts +13 -0
  34. package/dist/shared/dashboard.d.ts +22 -0
  35. package/dist/shared/dataAdapter.d.ts +14 -0
  36. package/dist/shared/exception.d.ts +1 -0
  37. package/dist/shared/grafana.d.ts +50 -0
  38. package/dist/shared/icons/DashboardIcon.d.ts +2 -0
  39. package/dist/shared/icons/ErrorIcon.d.ts +1 -0
  40. package/dist/shared/icons/SidebarIcon.d.ts +2 -0
  41. package/dist/shared/icons/index.d.ts +3 -0
  42. package/dist/shared/panel.d.ts +96 -0
  43. package/dist/shared/panelRegistry.d.ts +9 -0
  44. package/dist/shared/query/index.d.ts +4 -0
  45. package/dist/shared/query/key.d.ts +4 -0
  46. package/dist/shared/query/mutation.d.ts +35 -0
  47. package/dist/shared/query/query.d.ts +52 -0
  48. package/dist/shared/query/useMutation.d.ts +11 -0
  49. package/dist/shared/query/useQuery.d.ts +22 -0
  50. package/dist/shared/transport/baseTransport.d.ts +35 -0
  51. package/dist/shared/transport/index.d.ts +3 -0
  52. package/dist/shared/transport/restTransport.d.ts +29 -0
  53. package/dist/shared/transport/useTransport.d.ts +2 -0
  54. package/dist/widgets/DashboardEditor/DashboardEditor.d.ts +15 -0
  55. package/dist/widgets/DashboardEditor/__mock__/index.d.ts +20 -0
  56. package/dist/widgets/DashboardEditor/components/DashboardSelectorDrawer.d.ts +6 -0
  57. package/dist/widgets/DashboardEditor/components/ExternalDashboardsList.d.ts +5 -0
  58. package/dist/widgets/DashboardEditor/components/PanelControl.d.ts +8 -0
  59. package/dist/widgets/DashboardEditor/components/PanelSettings.d.ts +7 -0
  60. package/dist/widgets/DashboardEditor/components/PanelSettingsDrawer.d.ts +6 -0
  61. package/dist/widgets/DashboardEditor/helpers.d.ts +39 -0
  62. package/dist/widgets/DashboardEditor/index.d.ts +1 -0
  63. package/dist/widgets/DashboardViewer/DashboardViewer.d.ts +7 -0
  64. package/dist/widgets/DashboardViewer/__mock__/index.d.ts +16 -0
  65. package/dist/widgets/DashboardViewer/index.d.ts +1 -0
  66. package/package.json +70 -0
package/dist/index.js ADDED
@@ -0,0 +1,2971 @@
1
+ (function webpackUniversalModuleDefinition(root, factory) {
2
+ if(typeof exports === 'object' && typeof module === 'object')
3
+ module.exports = factory();
4
+ else if(typeof define === 'function' && define.amd)
5
+ define([], factory);
6
+ else if(typeof exports === 'object')
7
+ exports["SSAInfraDash"] = factory();
8
+ else
9
+ root["SSAInfraDash"] = factory();
10
+ })(self, () => {
11
+ return /******/ (() => { // webpackBootstrap
12
+ /******/ "use strict";
13
+ /******/ // The require scope
14
+ /******/ var __webpack_require__ = {};
15
+ /******/
16
+ /************************************************************************/
17
+ /******/ /* webpack/runtime/compat get default export */
18
+ /******/ (() => {
19
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
20
+ /******/ __webpack_require__.n = (module) => {
21
+ /******/ var getter = module && module.__esModule ?
22
+ /******/ () => (module['default']) :
23
+ /******/ () => (module);
24
+ /******/ __webpack_require__.d(getter, { a: getter });
25
+ /******/ return getter;
26
+ /******/ };
27
+ /******/ })();
28
+ /******/
29
+ /******/ /* webpack/runtime/define property getters */
30
+ /******/ (() => {
31
+ /******/ // define getter functions for harmony exports
32
+ /******/ __webpack_require__.d = (exports, definition) => {
33
+ /******/ for(var key in definition) {
34
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
35
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
36
+ /******/ }
37
+ /******/ }
38
+ /******/ };
39
+ /******/ })();
40
+ /******/
41
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
42
+ /******/ (() => {
43
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
44
+ /******/ })();
45
+ /******/
46
+ /******/ /* webpack/runtime/make namespace object */
47
+ /******/ (() => {
48
+ /******/ // define __esModule on exports
49
+ /******/ __webpack_require__.r = (exports) => {
50
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
51
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
52
+ /******/ }
53
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
54
+ /******/ };
55
+ /******/ })();
56
+ /******/
57
+ /************************************************************************/
58
+ var __webpack_exports__ = {};
59
+ // ESM COMPAT FLAG
60
+ __webpack_require__.r(__webpack_exports__);
61
+
62
+ // EXPORTS
63
+ __webpack_require__.d(__webpack_exports__, {
64
+ DashboardEditor: () => (/* reexport */ DashboardEditor),
65
+ DashboardEditorInternal: () => (/* reexport */ DashboardEditorInternal),
66
+ DashboardViewer: () => (/* reexport */ DashboardViewer),
67
+ InfraDashProvider: () => (/* reexport */ InfraDashProvider),
68
+ RestInfraDashTransport: () => (/* reexport */ RestInfraDashTransport),
69
+ useCreateDashboard: () => (/* reexport */ useCreateDashboard),
70
+ useDashboard: () => (/* reexport */ useDashboard),
71
+ useDashboards: () => (/* reexport */ useDashboards),
72
+ useDeleteDashboard: () => (/* reexport */ useDeleteDashboard),
73
+ useInfraDashContext: () => (/* reexport */ useInfraDashContext),
74
+ useMutationClient: () => (/* reexport */ useMutationClient),
75
+ useQueryClient: () => (/* reexport */ useQueryClient),
76
+ useTransport: () => (/* reexport */ useTransport),
77
+ useUpdateDashboard: () => (/* reexport */ useUpdateDashboard)
78
+ });
79
+
80
+ ;// external "react-error-boundary"
81
+ const external_react_error_boundary_namespaceObject = require("react-error-boundary");
82
+ ;// external "@ssa-ui-kit/core"
83
+ const core_namespaceObject = require("@ssa-ui-kit/core");
84
+ ;// external "@emotion/react/jsx-runtime"
85
+ const jsx_runtime_namespaceObject = require("@emotion/react/jsx-runtime");
86
+ ;// ./src/shared/icons/ErrorIcon.tsx
87
+
88
+ const ErrorIcon = () => (0,jsx_runtime_namespaceObject.jsxs)("svg", {
89
+ width: "80",
90
+ height: "80",
91
+ viewBox: "0 0 80 80",
92
+ fill: "none",
93
+ xmlns: "http://www.w3.org/2000/svg",
94
+ children: [(0,jsx_runtime_namespaceObject.jsx)("circle", {
95
+ cx: "40",
96
+ cy: "40",
97
+ r: "40",
98
+ fill: "#EEF1F7"
99
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
100
+ fillRule: "evenodd",
101
+ clipRule: "evenodd",
102
+ d: "M56.9165 39.6055H24.4165V54.6465C24.4165 55.3639 24.8869 55.9968 25.5743 56.2032C28.8398 57.1823 38.0226 59.9375 40.1993 60.5907C40.504 60.6817 40.829 60.6817 41.1337 60.5907C43.3104 59.9375 52.4933 57.1823 55.7587 56.2032C56.4461 55.9968 56.9165 55.3639 56.9165 54.6465C56.9165 50.8797 56.9165 39.6055 56.9165 39.6055Z",
103
+ fill: "url(#paint0_linear_175_25229)"
104
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
105
+ fillRule: "evenodd",
106
+ clipRule: "evenodd",
107
+ d: "M56.9162 39.6055H40.6662C40.6662 39.6055 40.5086 60.659 40.6662 60.659C40.8239 60.659 40.9807 60.6362 41.1334 60.5907C43.3101 59.9375 52.493 57.1823 55.7584 56.2032C56.4458 55.9968 56.9162 55.3639 56.9162 54.6465C56.9162 50.8797 56.9162 39.6055 56.9162 39.6055Z",
108
+ fill: "url(#paint1_linear_175_25229)"
109
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
110
+ fillRule: "evenodd",
111
+ clipRule: "evenodd",
112
+ d: "M40.6665 44.8778L24.4165 39.6055C24.4165 39.6055 21.567 43.8305 20.293 45.7187C20.15 45.9308 20.1151 46.1965 20.198 46.4378C20.2817 46.6791 20.4726 46.8668 20.7155 46.9464C23.8022 47.949 32.9396 50.9179 35.3365 51.6963C35.6802 51.8084 36.0572 51.6792 36.2603 51.3794C37.3498 49.7715 40.6665 44.8778 40.6665 44.8778Z",
113
+ fill: "url(#paint2_linear_175_25229)"
114
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
115
+ fillRule: "evenodd",
116
+ clipRule: "evenodd",
117
+ d: "M56.9165 39.6055L40.6665 44.8778C40.6665 44.8778 43.9831 49.7715 45.0727 51.3794C45.2758 51.6792 45.6528 51.8084 45.9965 51.6963C48.3934 50.9179 57.5308 47.949 60.6174 46.9464C60.8604 46.8668 61.0513 46.6791 61.135 46.4378C61.2179 46.1965 61.1829 45.9308 61.0399 45.7187C59.7659 43.8305 56.9165 39.6055 56.9165 39.6055Z",
118
+ fill: "url(#paint3_linear_175_25229)"
119
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
120
+ fillRule: "evenodd",
121
+ clipRule: "evenodd",
122
+ d: "M36.7329 28.5303C36.5298 28.2321 36.1536 28.1029 35.8099 28.215C33.4147 28.9926 24.2749 31.9623 21.1882 32.9657C20.9452 33.0445 20.7535 33.2322 20.6706 33.4735C20.5877 33.7148 20.6227 33.9813 20.7657 34.1926C21.9389 35.933 24.4162 39.6055 24.4162 39.6055L40.6662 34.3153C40.6662 34.3153 37.7477 30.0228 36.7329 28.5303Z",
123
+ fill: "url(#paint4_linear_175_25229)"
124
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
125
+ fillRule: "evenodd",
126
+ clipRule: "evenodd",
127
+ d: "M60.5671 34.1926C60.7101 33.9813 60.745 33.7148 60.6621 33.4735C60.5793 33.2322 60.3875 33.0445 60.1446 32.9657C57.0579 31.9623 47.9181 28.9926 45.5228 28.215C45.1791 28.1029 44.8029 28.2321 44.5998 28.5303C43.585 30.0228 40.6665 34.3153 40.6665 34.3153L56.9165 39.6055C56.9165 39.6055 59.3938 35.933 60.5671 34.1926Z",
128
+ fill: "url(#paint5_linear_175_25229)"
129
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
130
+ fillRule: "evenodd",
131
+ clipRule: "evenodd",
132
+ d: "M56.9165 39.6055L40.6665 34.3153L24.4165 39.6055L40.6665 44.8778L56.9165 39.6055Z",
133
+ fill: "url(#paint6_linear_175_25229)"
134
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
135
+ fillRule: "evenodd",
136
+ clipRule: "evenodd",
137
+ d: "M40.6665 44.8778V34.3153L24.4165 39.6055L40.6665 44.8778Z",
138
+ fill: "url(#paint7_linear_175_25229)"
139
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
140
+ fillRule: "evenodd",
141
+ clipRule: "evenodd",
142
+ d: "M37.4019 36.6488C37.0639 36.4278 36.7592 36.1913 36.4886 35.9435C36.1588 35.6405 35.6445 35.6624 35.3406 35.9931C35.0375 36.323 35.0595 36.8373 35.3901 37.1403C35.7225 37.4458 36.097 37.7367 36.513 38.0089C36.8884 38.2543 37.3921 38.1486 37.6375 37.7733C37.8829 37.3979 37.7773 36.8941 37.4019 36.6488Z",
143
+ fill: "url(#paint8_linear_175_25229)"
144
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
145
+ fillRule: "evenodd",
146
+ clipRule: "evenodd",
147
+ d: "M34.8703 34.1528C34.629 33.8253 34.4251 33.4963 34.2577 33.1672C34.0546 32.7675 33.5646 32.6082 33.1649 32.8113C32.7651 33.0145 32.6059 33.5044 32.809 33.9042C33.0154 34.3088 33.2656 34.7142 33.5622 35.1164C33.8279 35.4772 34.3365 35.5543 34.6981 35.2887C35.0588 35.0222 35.136 34.5135 34.8703 34.1528Z",
148
+ fill: "url(#paint9_linear_175_25229)"
149
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
150
+ fillRule: "evenodd",
151
+ clipRule: "evenodd",
152
+ d: "M33.6824 30.837C33.6905 30.5095 33.7384 30.1918 33.8262 29.8872C33.9497 29.4565 33.7002 29.0056 33.2688 28.8821C32.8382 28.7586 32.3872 29.008 32.2637 29.4395C32.1394 29.875 32.0695 30.3292 32.0574 30.7963C32.0468 31.2448 32.401 31.6178 32.8495 31.6283C33.298 31.6397 33.671 31.2855 33.6824 30.837Z",
153
+ fill: "url(#paint10_linear_175_25229)"
154
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
155
+ fillRule: "evenodd",
156
+ clipRule: "evenodd",
157
+ d: "M34.9318 28.1232C35.1406 27.9299 35.3746 27.7511 35.6305 27.5894C36.0099 27.3497 36.1237 26.8476 35.8848 26.469C35.6451 26.0895 35.143 25.9758 34.7636 26.2147C34.4199 26.4316 34.1079 26.6713 33.8276 26.9313C33.4985 27.236 33.479 27.7503 33.7837 28.0794C34.0884 28.4084 34.6027 28.4279 34.9318 28.1232Z",
158
+ fill: "url(#paint11_linear_175_25229)"
159
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
160
+ fillRule: "evenodd",
161
+ clipRule: "evenodd",
162
+ d: "M37.9535 26.7216C38.3622 26.6461 38.7953 26.5973 39.2519 26.5786C39.7004 26.5591 40.0481 26.1797 40.0295 25.732C40.0108 25.2843 39.6313 24.9358 39.1828 24.9545C38.6466 24.9772 38.138 25.0349 37.6578 25.1235C37.2174 25.2055 36.9249 25.6296 37.007 26.07C37.0882 26.5112 37.5123 26.8029 37.9535 26.7216Z",
163
+ fill: "url(#paint12_linear_175_25229)"
164
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
165
+ fillRule: "evenodd",
166
+ clipRule: "evenodd",
167
+ d: "M42.1886 26.6737C42.8816 26.6818 43.5267 26.6575 44.1256 26.6047C44.5724 26.5648 44.9031 26.17 44.8633 25.7231C44.8235 25.277 44.4286 24.9463 43.9817 24.9862C43.4333 25.0341 42.8426 25.0568 42.2072 25.0487C41.7587 25.0438 41.3907 25.4038 41.3858 25.8515C41.3801 26.3 41.7401 26.6688 42.1886 26.6737Z",
168
+ fill: "url(#paint13_linear_175_25229)"
169
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
170
+ fillRule: "evenodd",
171
+ clipRule: "evenodd",
172
+ d: "M46.796 26.1066C47.6003 25.8604 48.2796 25.5452 48.8483 25.1836C49.2261 24.9423 49.3383 24.4402 49.097 24.0615C48.8565 23.6837 48.3535 23.5716 47.9749 23.8129C47.5175 24.1038 46.969 24.354 46.3206 24.5523C45.8925 24.6839 45.6503 25.1381 45.782 25.5671C45.9128 25.9961 46.3678 26.2374 46.796 26.1066Z",
173
+ fill: "url(#paint14_linear_175_25229)"
174
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
175
+ fillRule: "evenodd",
176
+ clipRule: "evenodd",
177
+ d: "M50.9315 22.9094C51.315 22.1164 51.4621 21.2779 51.4247 20.4695C51.4036 20.021 51.0225 19.6748 50.5749 19.696C50.1272 19.7171 49.7802 20.0973 49.8014 20.545C49.8274 21.0943 49.7282 21.6638 49.4682 22.2025C49.2732 22.6063 49.4422 23.093 49.846 23.288C50.2499 23.483 50.7365 23.3132 50.9315 22.9094Z",
178
+ fill: "url(#paint15_linear_175_25229)"
179
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
180
+ fillRule: "evenodd",
181
+ clipRule: "evenodd",
182
+ d: "M50.4143 17.5965C49.822 16.7962 49.0184 16.2388 48.1425 16.0592C47.703 15.9698 47.2732 16.2526 47.183 16.6922C47.0936 17.1317 47.3772 17.5615 47.8159 17.6517C48.3213 17.7549 48.7665 18.1018 49.1086 18.5642C49.3759 18.9241 49.8853 18.9997 50.2453 18.7332C50.606 18.4658 50.6816 17.9564 50.4143 17.5965Z",
183
+ fill: "url(#paint16_linear_175_25229)"
184
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
185
+ fillRule: "evenodd",
186
+ clipRule: "evenodd",
187
+ d: "M39.7993 16.2168C40.6784 11.2386 48.2973 11.5604 43.8618 16.2168H39.7993Z",
188
+ fill: "url(#paint17_linear_175_25229)"
189
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
190
+ fillRule: "evenodd",
191
+ clipRule: "evenodd",
192
+ d: "M39.7993 17.4778C40.6784 22.4552 48.2973 22.1343 43.8618 17.4778H39.7993Z",
193
+ fill: "url(#paint18_linear_175_25229)"
194
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
195
+ fillRule: "evenodd",
196
+ clipRule: "evenodd",
197
+ d: "M39.7266 17.668H45.1671C45.6156 17.668 45.9796 17.304 45.9796 16.8555C45.9796 16.407 45.6156 16.043 45.1671 16.043H39.7266C39.2789 16.043 38.9141 16.407 38.9141 16.8555C38.9141 17.304 39.2789 17.668 39.7266 17.668Z",
198
+ fill: "url(#paint19_linear_175_25229)"
199
+ }), (0,jsx_runtime_namespaceObject.jsxs)("defs", {
200
+ children: [(0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
201
+ id: "paint0_linear_175_25229",
202
+ x1: "24.4165",
203
+ y1: "50.1322",
204
+ x2: "56.9165",
205
+ y2: "50.1322",
206
+ gradientUnits: "userSpaceOnUse",
207
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
208
+ stopColor: "#CADCF0"
209
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
210
+ offset: "1",
211
+ stopColor: "#A4BBDB"
212
+ })]
213
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
214
+ id: "paint1_linear_175_25229",
215
+ x1: "40.5964",
216
+ y1: "50.1322",
217
+ x2: "56.9162",
218
+ y2: "50.1322",
219
+ gradientUnits: "userSpaceOnUse",
220
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
221
+ stopColor: "#A4BBDB"
222
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
223
+ offset: "1",
224
+ stopColor: "#8DA3BE"
225
+ })]
226
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
227
+ id: "paint2_linear_175_25229",
228
+ x1: "24.5245",
229
+ y1: "39.599",
230
+ x2: "26.7957",
231
+ y2: "54.6248",
232
+ gradientUnits: "userSpaceOnUse",
233
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
234
+ stopColor: "#E9F3FC"
235
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
236
+ offset: "1",
237
+ stopColor: "#CADCF0"
238
+ })]
239
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
240
+ id: "paint3_linear_175_25229",
241
+ x1: "40.7323",
242
+ y1: "44.8225",
243
+ x2: "57.8628",
244
+ y2: "54.6748",
245
+ gradientUnits: "userSpaceOnUse",
246
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
247
+ stopColor: "#E9F3FC"
248
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
249
+ offset: "1",
250
+ stopColor: "#CADCF0"
251
+ })]
252
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
253
+ id: "paint4_linear_175_25229",
254
+ x1: "22.2891",
255
+ y1: "36.4521",
256
+ x2: "24.7405",
257
+ y2: "24.8965",
258
+ gradientUnits: "userSpaceOnUse",
259
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
260
+ stopColor: "#E9F3FC"
261
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
262
+ offset: "1",
263
+ stopColor: "#CADCF0"
264
+ })]
265
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
266
+ id: "paint5_linear_175_25229",
267
+ x1: "45.0166",
268
+ y1: "28.0192",
269
+ x2: "45.8932",
270
+ y2: "42.2824",
271
+ gradientUnits: "userSpaceOnUse",
272
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
273
+ stopColor: "#E9F3FC"
274
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
275
+ offset: "1",
276
+ stopColor: "#CADCF0"
277
+ })]
278
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
279
+ id: "paint6_linear_175_25229",
280
+ x1: "24.4165",
281
+ y1: "39.5965",
282
+ x2: "56.9165",
283
+ y2: "39.5965",
284
+ gradientUnits: "userSpaceOnUse",
285
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
286
+ stopColor: "#CADCF0"
287
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
288
+ offset: "1",
289
+ stopColor: "#A4BBDB"
290
+ })]
291
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
292
+ id: "paint7_linear_175_25229",
293
+ x1: "42.3305",
294
+ y1: "34.0788",
295
+ x2: "42.6807",
296
+ y2: "47.2032",
297
+ gradientUnits: "userSpaceOnUse",
298
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
299
+ stopColor: "#A4BBDB"
300
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
301
+ offset: "1",
302
+ stopColor: "#8DA3BE"
303
+ })]
304
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
305
+ id: "paint8_linear_175_25229",
306
+ x1: "31.7217",
307
+ y1: "16.2168",
308
+ x2: "47.7475",
309
+ y2: "35.1261",
310
+ gradientUnits: "userSpaceOnUse",
311
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
312
+ stopColor: "#559AFF"
313
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
314
+ offset: "1",
315
+ stopColor: "#2E69EF"
316
+ })]
317
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
318
+ id: "paint9_linear_175_25229",
319
+ x1: "31.7219",
320
+ y1: "16.2168",
321
+ x2: "47.7476",
322
+ y2: "35.1261",
323
+ gradientUnits: "userSpaceOnUse",
324
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
325
+ stopColor: "#559AFF"
326
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
327
+ offset: "1",
328
+ stopColor: "#2E69EF"
329
+ })]
330
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
331
+ id: "paint10_linear_175_25229",
332
+ x1: "31.7218",
333
+ y1: "16.2168",
334
+ x2: "47.7475",
335
+ y2: "35.1262",
336
+ gradientUnits: "userSpaceOnUse",
337
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
338
+ stopColor: "#559AFF"
339
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
340
+ offset: "1",
341
+ stopColor: "#2E69EF"
342
+ })]
343
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
344
+ id: "paint11_linear_175_25229",
345
+ x1: "31.7216",
346
+ y1: "16.2169",
347
+ x2: "47.7473",
348
+ y2: "35.1262",
349
+ gradientUnits: "userSpaceOnUse",
350
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
351
+ stopColor: "#559AFF"
352
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
353
+ offset: "1",
354
+ stopColor: "#2E69EF"
355
+ })]
356
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
357
+ id: "paint12_linear_175_25229",
358
+ x1: "31.7217",
359
+ y1: "16.2168",
360
+ x2: "47.7474",
361
+ y2: "35.1261",
362
+ gradientUnits: "userSpaceOnUse",
363
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
364
+ stopColor: "#559AFF"
365
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
366
+ offset: "1",
367
+ stopColor: "#2E69EF"
368
+ })]
369
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
370
+ id: "paint13_linear_175_25229",
371
+ x1: "31.7219",
372
+ y1: "16.2168",
373
+ x2: "47.7477",
374
+ y2: "35.1262",
375
+ gradientUnits: "userSpaceOnUse",
376
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
377
+ stopColor: "#559AFF"
378
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
379
+ offset: "1",
380
+ stopColor: "#2E69EF"
381
+ })]
382
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
383
+ id: "paint14_linear_175_25229",
384
+ x1: "31.7217",
385
+ y1: "16.2168",
386
+ x2: "47.7474",
387
+ y2: "35.1262",
388
+ gradientUnits: "userSpaceOnUse",
389
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
390
+ stopColor: "#559AFF"
391
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
392
+ offset: "1",
393
+ stopColor: "#2E69EF"
394
+ })]
395
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
396
+ id: "paint15_linear_175_25229",
397
+ x1: "31.7216",
398
+ y1: "16.2168",
399
+ x2: "47.7474",
400
+ y2: "35.1261",
401
+ gradientUnits: "userSpaceOnUse",
402
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
403
+ stopColor: "#559AFF"
404
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
405
+ offset: "1",
406
+ stopColor: "#2E69EF"
407
+ })]
408
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
409
+ id: "paint16_linear_175_25229",
410
+ x1: "31.7219",
411
+ y1: "16.2168",
412
+ x2: "47.7476",
413
+ y2: "35.1262",
414
+ gradientUnits: "userSpaceOnUse",
415
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
416
+ stopColor: "#559AFF"
417
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
418
+ offset: "1",
419
+ stopColor: "#2E69EF"
420
+ })]
421
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
422
+ id: "paint17_linear_175_25229",
423
+ x1: "39.7993",
424
+ y1: "14.4098",
425
+ x2: "45.239",
426
+ y2: "14.4098",
427
+ gradientUnits: "userSpaceOnUse",
428
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
429
+ stopColor: "#E9F3FC"
430
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
431
+ offset: "1",
432
+ stopColor: "#CADCF0"
433
+ })]
434
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
435
+ id: "paint18_linear_175_25229",
436
+ x1: "39.7993",
437
+ y1: "19.2848",
438
+ x2: "45.239",
439
+ y2: "19.2848",
440
+ gradientUnits: "userSpaceOnUse",
441
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
442
+ stopColor: "#E9F3FC"
443
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
444
+ offset: "1",
445
+ stopColor: "#CADCF0"
446
+ })]
447
+ }), (0,jsx_runtime_namespaceObject.jsxs)("linearGradient", {
448
+ id: "paint19_linear_175_25229",
449
+ x1: "31.7218",
450
+ y1: "16.2168",
451
+ x2: "47.7476",
452
+ y2: "35.1262",
453
+ gradientUnits: "userSpaceOnUse",
454
+ children: [(0,jsx_runtime_namespaceObject.jsx)("stop", {
455
+ stopColor: "#559AFF"
456
+ }), (0,jsx_runtime_namespaceObject.jsx)("stop", {
457
+ offset: "1",
458
+ stopColor: "#2E69EF"
459
+ })]
460
+ })]
461
+ })]
462
+ });
463
+ ;// ./src/components/DashboardError/DashboardError.tsx
464
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
465
+
466
+
467
+
468
+ var _ref = true ? {
469
+ name: "67cb9k",
470
+ styles: "justify-content:center;height:100%"
471
+ } : 0;
472
+ var _ref2 = true ? {
473
+ name: "1kdycl6",
474
+ styles: "margin-top:12px;text-align:center"
475
+ } : 0;
476
+ const DashboardError = ({
477
+ children
478
+ }) => (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
479
+ direction: "column",
480
+ css: _ref,
481
+ children: [(0,jsx_runtime_namespaceObject.jsx)(ErrorIcon, {}), (0,jsx_runtime_namespaceObject.jsx)("div", {
482
+ css: _ref2,
483
+ children: children ?? 'An error occurred while loading the dashboard'
484
+ })]
485
+ });
486
+ ;// external "@emotion/css"
487
+ const css_namespaceObject = require("@emotion/css");
488
+ ;// external "@emotion/react"
489
+ const react_namespaceObject = require("@emotion/react");
490
+ ;// ./src/components/LoadingDashboard/LoadingDashboard.tsx
491
+ function LoadingDashboard_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
492
+
493
+
494
+
495
+
496
+ var LoadingDashboard_ref = true ? {
497
+ name: "67cb9k",
498
+ styles: "justify-content:center;height:100%"
499
+ } : 0;
500
+ var LoadingDashboard_ref2 = true ? {
501
+ name: "1kdycl6",
502
+ styles: "margin-top:12px;text-align:center"
503
+ } : 0;
504
+ const LoadingDashboard = ({
505
+ children
506
+ }) => {
507
+ const theme = (0,react_namespaceObject.useTheme)();
508
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
509
+ direction: "column",
510
+ css: LoadingDashboard_ref,
511
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.ProgressCircle, {
512
+ classnames: {
513
+ inner: /*#__PURE__*/(0,css_namespaceObject.css)(`
514
+ background: none !important;
515
+ `, true ? "" : 0, true ? "" : 0),
516
+ outer: /*#__PURE__*/(0,css_namespaceObject.css)(`
517
+ background: none !important;
518
+ border: 12px solid ${theme.colors.greyLighter};
519
+ `, true ? "" : 0, true ? "" : 0)
520
+ },
521
+ currentValue: 3,
522
+ max: 10,
523
+ size: 120,
524
+ color: "blue",
525
+ mode: "infinite"
526
+ }), children && (0,jsx_runtime_namespaceObject.jsx)("div", {
527
+ css: LoadingDashboard_ref2,
528
+ children: children
529
+ })]
530
+ });
531
+ };
532
+ ;// external "react"
533
+ const external_react_namespaceObject = require("react");
534
+ ;// ./src/shared/query/key.ts
535
+ const hashKey = queryKey => {
536
+ return JSON.stringify(queryKey);
537
+ };
538
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
539
+ function partialMatchKey(a, b) {
540
+ if (a === b) {
541
+ return true;
542
+ }
543
+ if (typeof a !== typeof b) {
544
+ return false;
545
+ }
546
+ if (a && b && typeof a === 'object' && typeof b === 'object') {
547
+ return Object.keys(b).every(key => partialMatchKey(a[key], b[key]));
548
+ }
549
+ return false;
550
+ }
551
+ ;// external "@ssa-ui-kit/hooks"
552
+ const hooks_namespaceObject = require("@ssa-ui-kit/hooks");
553
+ ;// ./src/shared/context.ts
554
+
555
+ const [InfraDashInternalProvider, useInfraDashContext] = (0,hooks_namespaceObject.createSafeContext)('useInfraDashContext must be used within a InfraDashProvider');
556
+ ;// ./src/shared/query/useQuery.ts
557
+
558
+
559
+
560
+ const useQueryClient = () => {
561
+ const {
562
+ queryClient
563
+ } = useInfraDashContext();
564
+ return queryClient;
565
+ };
566
+ const useQuery = (key, fetcher, options) => {
567
+ const queryClient = useQueryClient();
568
+ const keyHash = (0,external_react_namespaceObject.useMemo)(() => hashKey(key), [key]);
569
+ const entry = (0,external_react_namespaceObject.useMemo)(() => queryClient.fetchQuery(key, fetcher, options), [keyHash]);
570
+ entry.updateEntity(fetcher, options);
571
+ const subscribe = (0,external_react_namespaceObject.useCallback)(onStoreChange => {
572
+ return entry.subscribe(() => {
573
+ onStoreChange();
574
+ });
575
+ }, [entry]);
576
+ const getSnapshot = () => {
577
+ return entry.state;
578
+ };
579
+ const getServerSnapshot = getSnapshot;
580
+ const state = (0,external_react_namespaceObject.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
581
+ return {
582
+ ...state,
583
+ refetch: () => queryClient.invalidateQueries({
584
+ key,
585
+ exact: true
586
+ })
587
+ };
588
+ };
589
+ ;// ./src/shared/query/useMutation.ts
590
+
591
+
592
+
593
+ const useMutationClient = () => {
594
+ const {
595
+ mutationClient
596
+ } = useInfraDashContext();
597
+ return mutationClient;
598
+ };
599
+ const useMutation = (key, mutationFn, options) => {
600
+ const mutationClient = useMutationClient();
601
+ const keyHash = (0,external_react_namespaceObject.useMemo)(() => hashKey(key), [key]);
602
+ const entry = (0,external_react_namespaceObject.useMemo)(() => mutationClient.fetchMutation(key, mutationFn, options), [keyHash]);
603
+ entry.updateEntity(mutationFn, options);
604
+ const subscribe = (0,external_react_namespaceObject.useCallback)(onStoreChange => {
605
+ return entry.subscribe(() => {
606
+ onStoreChange();
607
+ });
608
+ }, [entry]);
609
+ const getSnapshot = () => {
610
+ return entry.state;
611
+ };
612
+ const getServerSnapshot = getSnapshot;
613
+ const state = (0,external_react_namespaceObject.useSyncExternalStore)(subscribe, getSnapshot, getServerSnapshot);
614
+ const mutate = (0,external_react_namespaceObject.useCallback)((...args) => {
615
+ return entry.mutate(...args);
616
+ }, [entry]);
617
+ const reset = (0,external_react_namespaceObject.useCallback)(() => {
618
+ entry.reset();
619
+ }, [entry]);
620
+ const cancel = (0,external_react_namespaceObject.useCallback)(() => {
621
+ entry.cancel();
622
+ }, [entry]);
623
+ return {
624
+ mutate,
625
+ data: state.data,
626
+ error: state.error,
627
+ isLoading: state.isLoading,
628
+ reset,
629
+ cancel
630
+ };
631
+ };
632
+ ;// ./src/shared/transport/useTransport.ts
633
+
634
+ const useTransport = transport => {
635
+ const {
636
+ transport: contextTransport
637
+ } = useInfraDashContext();
638
+ return transport ?? contextTransport;
639
+ };
640
+ ;// ./src/entities/dashboard/index.ts
641
+
642
+
643
+ const useDashboards = options => {
644
+ const {
645
+ transport,
646
+ ...queryOptions
647
+ } = options || {};
648
+ const _transport = useTransport(transport);
649
+ const result = useQuery(['dashboards'], async signal => {
650
+ return await _transport.getDashboards(signal);
651
+ }, queryOptions);
652
+ return result;
653
+ };
654
+ const useDashboard = (dashboardId, options) => {
655
+ const {
656
+ transport,
657
+ ...queryOptions
658
+ } = options || {};
659
+ const _transport = useTransport(transport);
660
+ const result = useQuery(['dashboards', dashboardId], async signal => {
661
+ return await _transport.getDashboard(dashboardId, signal);
662
+ }, queryOptions);
663
+ return result;
664
+ };
665
+ const useCreateDashboard = options => {
666
+ const {
667
+ transport,
668
+ ...mutationOptions
669
+ } = options || {};
670
+ const _transport = useTransport(transport);
671
+ const result = useMutation(['create-dashboard'], async (payload, signal) => {
672
+ const panels = payload.panels.map(panel => ({
673
+ ...panel,
674
+ id: panel.panelDefinition.source.panelId
675
+ }));
676
+ const dashboardsUid = new Set(panels.map(panel => panel.panelDefinition.source.dashboardUid));
677
+ if (!dashboardsUid.size) {
678
+ throw new Error('At least one panel must be provided');
679
+ }
680
+ return await _transport.createDashboard({
681
+ ...payload,
682
+ dashboardUid: dashboardsUid.values().next().value,
683
+ panels
684
+ }, signal);
685
+ }, mutationOptions);
686
+ return result;
687
+ };
688
+ const useUpdateDashboard = (dashboardId, options) => {
689
+ const {
690
+ transport,
691
+ ...mutationOptions
692
+ } = options || {};
693
+ const _transport = useTransport(transport);
694
+ const result = useMutation(['update-dashboard', dashboardId], async (payload, signal) => {
695
+ const panels = payload.panels.map(panel => ({
696
+ ...panel,
697
+ id: panel.panelDefinition.source.panelId
698
+ }));
699
+ const dashboardsUid = new Set(panels.map(panel => panel.panelDefinition.source.dashboardUid));
700
+ if (!dashboardsUid.size) {
701
+ throw new Error('At least one panel must be provided');
702
+ }
703
+ return await _transport.updateDashboard({
704
+ ...payload,
705
+ panels,
706
+ dashboardId
707
+ }, signal);
708
+ }, mutationOptions);
709
+ return result;
710
+ };
711
+ const useDeleteDashboard = (dashboardId, options) => {
712
+ const {
713
+ transport,
714
+ ...mutationOptions
715
+ } = options || {};
716
+ const _transport = useTransport(transport);
717
+ const result = useMutation(['delete-dashboard', dashboardId], async (_, signal) => {
718
+ return await _transport.deleteDashboard(dashboardId, signal);
719
+ }, mutationOptions);
720
+ return result;
721
+ };
722
+ ;// external "react-grid-layout"
723
+ const external_react_grid_layout_namespaceObject = require("react-grid-layout");
724
+ var external_react_grid_layout_default = /*#__PURE__*/__webpack_require__.n(external_react_grid_layout_namespaceObject);
725
+ ;// ./src/components/BasePanel/BasePanel.tsx
726
+ function BasePanel_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
727
+
728
+
729
+ var BasePanel_ref = true ? {
730
+ name: "3ytxc3",
731
+ styles: "height:100%;overflow:hidden"
732
+ } : 0;
733
+ const BasePanel = ({
734
+ children
735
+ }) => (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Wrapper, {
736
+ alignItems: "center",
737
+ direction: "column",
738
+ css: BasePanel_ref,
739
+ children: children
740
+ });
741
+ ;// ./src/components/ErrorPanel/ErrorPanel.tsx
742
+ function ErrorPanel_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
743
+
744
+
745
+
746
+
747
+ var ErrorPanel_ref = true ? {
748
+ name: "1kdycl6",
749
+ styles: "margin-top:12px;text-align:center"
750
+ } : 0;
751
+ const ErrorPanel = ({
752
+ title,
753
+ children
754
+ }) => {
755
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.WidgetCard, {
756
+ title: title,
757
+ contentClassName: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
758
+ name: "1wgy75t",
759
+ styles: "align-items:center!important;justify-content:center!important"
760
+ } : 0),
761
+ children: [(0,jsx_runtime_namespaceObject.jsx)(ErrorIcon, {}), (0,jsx_runtime_namespaceObject.jsx)("div", {
762
+ css: ErrorPanel_ref,
763
+ children: children ?? 'An error occurred while loading the panel'
764
+ })]
765
+ });
766
+ };
767
+ ;// external "react-grid-layout/css/styles.css"
768
+ const styles_css_namespaceObject = require("react-grid-layout/css/styles.css");
769
+ ;// external "react-resizable/css/styles.css"
770
+ const external_react_resizable_css_styles_css_namespaceObject = require("react-resizable/css/styles.css");
771
+ ;// ./src/features/DashboardPanelGrid.tsx
772
+ function DashboardPanelGrid_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
773
+
774
+
775
+
776
+
777
+
778
+
779
+
780
+
781
+
782
+
783
+
784
+ var DashboardPanelGrid_ref2 = true ? {
785
+ name: "52s4fb",
786
+ styles: "width:100%;.react-grid-item.cssTransforms{transition-property:none;}.react-grid-layout{transition:none;}"
787
+ } : 0;
788
+ var _ref3 = true ? {
789
+ name: "k9eird",
790
+ styles: "position:absolute;z-index:100;right:0"
791
+ } : 0;
792
+ const DashboardPanelGrid = ({
793
+ dashboard,
794
+ header,
795
+ cols = 24,
796
+ rowHeight = 30,
797
+ draggable = false,
798
+ resizable = false,
799
+ refetchIntervalMs = 60000,
800
+ // 60 seconds
801
+ onLayoutChange,
802
+ onDragStart,
803
+ onResizeStart,
804
+ renderPanelControl,
805
+ ...divProps
806
+ }) => {
807
+ const {
808
+ ref,
809
+ width
810
+ } = (0,hooks_namespaceObject.useElementSize)();
811
+ const isMinMD = (0,hooks_namespaceObject.useMinMDMediaQuery)();
812
+ const {
813
+ panelRegistry,
814
+ queryClient
815
+ } = useInfraDashContext();
816
+ (0,external_react_namespaceObject.useEffect)(() => {
817
+ if (refetchIntervalMs) {
818
+ queryClient.invalidateQueries({
819
+ key: ['panel-data']
820
+ });
821
+ const intervalId = setInterval(() => {
822
+ queryClient.invalidateQueries({
823
+ key: ['panel-data']
824
+ });
825
+ }, refetchIntervalMs);
826
+ return () => clearInterval(intervalId);
827
+ }
828
+ }, [refetchIntervalMs]);
829
+
830
+ // sort panels by their grid position
831
+ // for mobile view it will ensure they are stacked vertically in the right order
832
+ const sortedPanels = [...dashboard.panels].sort((a, b) => {
833
+ const aPos = a.panelDefinition.gridPos;
834
+ const bPos = b.panelDefinition.gridPos;
835
+ if (aPos.y !== bPos.y) {
836
+ return aPos.y - bPos.y; // top to bottom
837
+ }
838
+ return aPos.x - bPos.x; // left to right within the same row
839
+ });
840
+ const layout = sortedPanels.map(({
841
+ id,
842
+ panelDefinition: {
843
+ gridPos
844
+ }
845
+ }, index) => {
846
+ if (!isMinMD) {
847
+ // single column layout for mobile
848
+ return {
849
+ i: id.toString(),
850
+ x: 0,
851
+ y: index * gridPos.h,
852
+ w: cols,
853
+ h: gridPos.h
854
+ };
855
+ }
856
+ return {
857
+ i: id.toString(),
858
+ ...gridPos
859
+ };
860
+ });
861
+ const renderPanel = panel => {
862
+ const panelConfig = panelRegistry.getPanelConfig(panel.panelDefinition.component.id);
863
+ if (panelConfig) {
864
+ return (0,jsx_runtime_namespaceObject.jsx)(external_react_error_boundary_namespaceObject.ErrorBoundary, {
865
+ fallback: (0,jsx_runtime_namespaceObject.jsx)(ErrorPanel, {}),
866
+ children: (0,jsx_runtime_namespaceObject.jsx)(BasePanel, {
867
+ children: (0,jsx_runtime_namespaceObject.jsx)(panelConfig.Component, {
868
+ panel: panel,
869
+ ...panel.panelDefinition.component.props
870
+ })
871
+ })
872
+ });
873
+ }
874
+ return (0,jsx_runtime_namespaceObject.jsxs)(BasePanel, {
875
+ children: ["Unsupported panel type: ", panel.panelSchema.type]
876
+ });
877
+ };
878
+ const _header = typeof header === 'function' ? header(dashboard) : header;
879
+ return (0,jsx_runtime_namespaceObject.jsxs)("div", {
880
+ ref: ref,
881
+ css: DashboardPanelGrid_ref2,
882
+ ...divProps,
883
+ children: [_header, (0,jsx_runtime_namespaceObject.jsx)((external_react_grid_layout_default()), {
884
+ autoSize: true,
885
+ layout: layout,
886
+ cols: cols,
887
+ rowHeight: rowHeight,
888
+ containerPadding: [0, 0],
889
+ margin: [8, 8],
890
+ width: width
891
+ // disable interaction for mobile view
892
+ ,
893
+ isDraggable: isMinMD && draggable,
894
+ isResizable: isMinMD && resizable,
895
+ onLayoutChange: isMinMD ? onLayoutChange : undefined,
896
+ onDragStart: onDragStart,
897
+ onResizeStart: onResizeStart,
898
+ children: dashboard.panels.map(panel => (0,jsx_runtime_namespaceObject.jsxs)(GridItem, {
899
+ children: [renderPanelControl &&
900
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
901
+ (0,jsx_runtime_namespaceObject.jsx)("div", {
902
+ css: _ref3,
903
+ onMouseDown: e => e.stopPropagation(),
904
+ children: renderPanelControl(panel)
905
+ }), renderPanel(panel)]
906
+ }, panel.id.toString()))
907
+ })]
908
+ });
909
+ };
910
+ var DashboardPanelGrid_ref = true ? {
911
+ name: "p3gkp4",
912
+ styles: ".react-resizable-handle-se{z-index:1;}"
913
+ } : 0;
914
+ const GridItem = /*#__PURE__*/(0,external_react_namespaceObject.forwardRef)(function GridItem({
915
+ children,
916
+ ...props
917
+ }, ref) {
918
+ return (0,jsx_runtime_namespaceObject.jsx)("div", {
919
+ ref: ref,
920
+ css: DashboardPanelGrid_ref,
921
+ ...props,
922
+ children: children
923
+ });
924
+ });
925
+ ;// ./src/widgets/DashboardViewer/DashboardViewer.tsx
926
+
927
+
928
+
929
+
930
+
931
+
932
+ const DashboardViewer = ({
933
+ dashboard,
934
+ dashboardId,
935
+ ...props
936
+ }) => {
937
+ const dashboardById = useDashboard(dashboardId ?? -1, {
938
+ enabled: !!dashboardId && !dashboard
939
+ });
940
+ if (dashboard) {
941
+ return (0,jsx_runtime_namespaceObject.jsx)(external_react_error_boundary_namespaceObject.ErrorBoundary, {
942
+ fallback: (0,jsx_runtime_namespaceObject.jsx)(DashboardError, {
943
+ children: "Something went wrong"
944
+ }),
945
+ children: (0,jsx_runtime_namespaceObject.jsx)(DashboardPanelGrid, {
946
+ ...props,
947
+ dashboard: dashboard
948
+ })
949
+ });
950
+ }
951
+ if (!dashboardById.isLoaded) {
952
+ return (0,jsx_runtime_namespaceObject.jsx)(LoadingDashboard, {});
953
+ }
954
+ if (dashboardById.error) {
955
+ return (0,jsx_runtime_namespaceObject.jsx)(DashboardError, {});
956
+ }
957
+ return (0,jsx_runtime_namespaceObject.jsx)(external_react_error_boundary_namespaceObject.ErrorBoundary, {
958
+ fallback: (0,jsx_runtime_namespaceObject.jsx)(DashboardError, {
959
+ children: "Something went wrong"
960
+ }),
961
+ children: (0,jsx_runtime_namespaceObject.jsx)(DashboardPanelGrid, {
962
+ ...props,
963
+ dashboard: dashboardById.data
964
+ })
965
+ });
966
+ };
967
+ ;// ./src/widgets/DashboardViewer/index.ts
968
+
969
+ ;// ./src/shared/icons/DashboardIcon.tsx
970
+
971
+ const DashboardIcon = ({
972
+ fill = '#2B2D31',
973
+ size = 18,
974
+ tooltip = 'Dashboard',
975
+ ...props
976
+ }) => (0,jsx_runtime_namespaceObject.jsxs)("svg", {
977
+ width: `${size}px`,
978
+ height: `${size}px`,
979
+ viewBox: "0 0 18 18",
980
+ fill: "none",
981
+ xmlns: "http://www.w3.org/2000/svg",
982
+ ...props,
983
+ children: [(0,jsx_runtime_namespaceObject.jsx)("title", {
984
+ children: tooltip
985
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
986
+ d: "M6.4541 11.2607C7.46278 11.363 8.25 12.2143 8.25 13.25V13.75L8.23926 13.9541C8.1438 14.8957 7.39565 15.6438 6.4541 15.7393L6.25 15.75H4.25L4.0459 15.7393C3.10435 15.6438 2.3562 14.8957 2.26074 13.9541L2.25 13.75V13.25C2.25 12.2143 3.03722 11.363 4.0459 11.2607L4.25 11.25H6.25L6.4541 11.2607ZM13.9541 8.26074C14.9628 8.363 15.75 9.21435 15.75 10.25V13.75L15.7393 13.9541C15.6438 14.8957 14.8957 15.6438 13.9541 15.7393L13.75 15.75H11.75L11.5459 15.7393C10.6043 15.6438 9.8562 14.8957 9.76074 13.9541L9.75 13.75V10.25C9.75 9.21435 10.5372 8.363 11.5459 8.26074L11.75 8.25H13.75L13.9541 8.26074ZM11.75 9.65039C11.4186 9.65039 11.1504 9.91863 11.1504 10.25V13.75C11.1504 14.0814 11.4186 14.3496 11.75 14.3496H13.75C14.0814 14.3496 14.3496 14.0814 14.3496 13.75V10.25C14.3496 9.91863 14.0814 9.65039 13.75 9.65039H11.75ZM4.25 12.6504C3.91863 12.6504 3.65039 12.9186 3.65039 13.25V13.75C3.65039 14.0814 3.91863 14.3496 4.25 14.3496H6.25C6.58137 14.3496 6.84961 14.0814 6.84961 13.75V13.25C6.84961 12.9186 6.58137 12.6504 6.25 12.6504H4.25ZM6.4541 2.26074C7.46278 2.363 8.25 3.21435 8.25 4.25V7.75L8.23926 7.9541C8.1438 8.89565 7.39565 9.6438 6.4541 9.73926L6.25 9.75H4.25L4.0459 9.73926C3.10435 9.6438 2.3562 8.89565 2.26074 7.9541L2.25 7.75V4.25C2.25 3.21435 3.03722 2.363 4.0459 2.26074L4.25 2.25H6.25L6.4541 2.26074ZM4.25 3.65039C3.91863 3.65039 3.65039 3.91863 3.65039 4.25V7.75C3.65039 8.08137 3.91863 8.34961 4.25 8.34961H6.25C6.58137 8.34961 6.84961 8.08137 6.84961 7.75V4.25C6.84961 3.91863 6.58137 3.65039 6.25 3.65039H4.25ZM13.9541 2.26074C14.9628 2.363 15.75 3.21435 15.75 4.25V4.75L15.7393 4.9541C15.6438 5.89565 14.8957 6.6438 13.9541 6.73926L13.75 6.75H11.75L11.5459 6.73926C10.6043 6.6438 9.8562 5.89565 9.76074 4.9541L9.75 4.75V4.25C9.75 3.21435 10.5372 2.363 11.5459 2.26074L11.75 2.25H13.75L13.9541 2.26074ZM11.75 3.65039C11.4186 3.65039 11.1504 3.91863 11.1504 4.25V4.75C11.1504 5.08137 11.4186 5.34961 11.75 5.34961H13.75C14.0814 5.34961 14.3496 5.08137 14.3496 4.75V4.25C14.3496 3.91863 14.0814 3.65039 13.75 3.65039H11.75Z",
987
+ fill: fill
988
+ })]
989
+ });
990
+ ;// ./src/shared/panel.ts
991
+ /**
992
+ * Defines the configuration and positioning information for a dashboard panel.
993
+ * Contains both the component configuration and grid layout positioning.
994
+ */
995
+
996
+ /**
997
+ * Represents a complete dashboard panel with its metadata, schema, and definition.
998
+ * Combines panel identity, display information, data schema, and component configuration.
999
+ */
1000
+
1001
+ /**
1002
+ * Optional schema defining the structure of props this component expects.
1003
+ * Used for validation and form generation in configuration UIs.
1004
+ */
1005
+
1006
+ /**
1007
+ * Configuration object for registering a panel component type.
1008
+ * Defines how a specific component should be rendered and what panel types it supports.
1009
+ */
1010
+
1011
+ /**
1012
+ * Constant object defining available panel data sources.
1013
+ * Currently only supports Grafana as a data source.
1014
+ */
1015
+ const PANEL_DATA_SOURCE = {
1016
+ GRAFANA: 'grafana'
1017
+ };
1018
+ /**
1019
+ * Pattern matching utility function for handling different panel data sources.
1020
+ * Provides type-safe way to handle operations based on the data source type.
1021
+ *
1022
+ * @param source - The panel data source to match against
1023
+ * @param handlers - Object containing handler functions for each data source type
1024
+ */
1025
+ const matchPanelDataSource = (source, handlers) => {
1026
+ switch (source) {
1027
+ case PANEL_DATA_SOURCE.GRAFANA:
1028
+ return handlers.grafana();
1029
+ default:
1030
+ {
1031
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1032
+ const _ = source;
1033
+ throw new Error(`Unsupported panel data source: ${source}`);
1034
+ }
1035
+ }
1036
+ };
1037
+
1038
+ /**
1039
+ * Represents panel data with its source and associated data.
1040
+ * Currently only supports Grafana as a data source.
1041
+ */
1042
+ ;// ./src/widgets/DashboardEditor/components/DashboardSelectorDrawer.tsx
1043
+ function DashboardSelectorDrawer_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1044
+
1045
+
1046
+
1047
+
1048
+ var DashboardSelectorDrawer_ref = true ? {
1049
+ name: "1gk49vx",
1050
+ styles: "width:400px;padding:24px 32px"
1051
+ } : 0;
1052
+ var DashboardSelectorDrawer_ref2 = true ? {
1053
+ name: "13udsys",
1054
+ styles: "height:100%"
1055
+ } : 0;
1056
+ var DashboardSelectorDrawer_ref3 = true ? {
1057
+ name: "1d3w5wq",
1058
+ styles: "width:100%"
1059
+ } : 0;
1060
+ const DashboardSelectorDrawer = ({
1061
+ drawer,
1062
+ children
1063
+ }) => {
1064
+ const theme = (0,react_namespaceObject.useTheme)();
1065
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Drawer.Root, {
1066
+ store: drawer,
1067
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Drawer.Content, {
1068
+ css: DashboardSelectorDrawer_ref,
1069
+ children: (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1070
+ direction: "column",
1071
+ alignItems: "start",
1072
+ css: DashboardSelectorDrawer_ref2,
1073
+ children: [(0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Drawer.Header, {
1074
+ css: DashboardSelectorDrawer_ref3,
1075
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Drawer.Title, {
1076
+ children: "Dashboard Selector"
1077
+ }), (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1078
+ variant: "secondary",
1079
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
1080
+ ':hover': {
1081
+ background: theme.colors.greyDropdownFocused
1082
+ },
1083
+ width: '36px',
1084
+ height: '36px',
1085
+ padding: '8px',
1086
+ background: theme.colors.greyDropdownFocused
1087
+ }, true ? "" : 0, true ? "" : 0),
1088
+ onClick: () => drawer.toggle(false),
1089
+ children: (0,jsx_runtime_namespaceObject.jsx)(DashboardIcon, {
1090
+ fill: theme.colors.white
1091
+ })
1092
+ })]
1093
+ }), children]
1094
+ })
1095
+ })
1096
+ });
1097
+ };
1098
+ ;// ./src/shared/icons/SidebarIcon.tsx
1099
+
1100
+ const SidebarIcon = ({
1101
+ fill = '#2B2D31',
1102
+ size = 18,
1103
+ tooltip = 'Sidebar',
1104
+ ...props
1105
+ }) => (0,jsx_runtime_namespaceObject.jsxs)("svg", {
1106
+ width: `${size}px`,
1107
+ height: `${size}px`,
1108
+ viewBox: "0 0 18 18",
1109
+ fill: "none",
1110
+ xmlns: "http://www.w3.org/2000/svg",
1111
+ ...props,
1112
+ children: [(0,jsx_runtime_namespaceObject.jsx)("title", {
1113
+ children: tooltip
1114
+ }), (0,jsx_runtime_namespaceObject.jsx)("path", {
1115
+ d: "M12.7061 2.25488C14.8194 2.36211 16.5 4.10996 16.5 6.25V11.75L16.4951 11.9561C16.3913 14.0012 14.7512 15.6413 12.7061 15.7451L12.5 15.75H5.5L5.29395 15.7451C3.2488 15.6413 1.60865 14.0012 1.50488 11.9561L1.5 11.75V6.25C1.5 4.10996 3.18056 2.36211 5.29395 2.25488L5.5 2.25H12.5L12.7061 2.25488ZM5.5 3.65039C4.06406 3.65039 2.90039 4.81406 2.90039 6.25V11.75C2.90039 13.1859 4.06406 14.3496 5.5 14.3496H10.9248V3.65039H5.5ZM12.3252 14.3496H12.5C13.9359 14.3496 15.0996 13.1859 15.0996 11.75V6.25C15.0996 4.81406 13.9359 3.65039 12.5 3.65039H12.3252V14.3496Z",
1116
+ fill: fill
1117
+ })]
1118
+ });
1119
+ ;// ./src/widgets/DashboardEditor/components/PanelSettingsDrawer.tsx
1120
+ function PanelSettingsDrawer_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1121
+
1122
+
1123
+
1124
+
1125
+ var PanelSettingsDrawer_ref = true ? {
1126
+ name: "1c73qam",
1127
+ styles: "max-width:400px;padding:24px 32px"
1128
+ } : 0;
1129
+ var PanelSettingsDrawer_ref2 = true ? {
1130
+ name: "1d3w5wq",
1131
+ styles: "width:100%"
1132
+ } : 0;
1133
+ const PanelSettingsDrawer = ({
1134
+ drawer,
1135
+ children
1136
+ }) => {
1137
+ const theme = (0,react_namespaceObject.useTheme)();
1138
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Drawer.Root, {
1139
+ store: drawer,
1140
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Drawer.Overlay, {
1141
+ children: (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Drawer.Content, {
1142
+ css: PanelSettingsDrawer_ref,
1143
+ children: [(0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Drawer.Header, {
1144
+ css: PanelSettingsDrawer_ref2,
1145
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Drawer.Title, {
1146
+ children: "Panel Settings"
1147
+ }), (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1148
+ variant: "secondary",
1149
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
1150
+ ':hover': {
1151
+ background: theme.colors.greyDropdownFocused
1152
+ },
1153
+ width: '36px',
1154
+ height: '36px',
1155
+ padding: '8px',
1156
+ background: theme.colors.greyDropdownFocused
1157
+ }, true ? "" : 0, true ? "" : 0),
1158
+ onClick: () => drawer.toggle(false),
1159
+ children: (0,jsx_runtime_namespaceObject.jsx)(SidebarIcon, {
1160
+ fill: theme.colors.white
1161
+ })
1162
+ })]
1163
+ }), children]
1164
+ })
1165
+ })
1166
+ });
1167
+ };
1168
+ ;// ./src/entities/grafana-dashboard/index.ts
1169
+
1170
+
1171
+ const useGrafanaDashboards = options => {
1172
+ const {
1173
+ transport,
1174
+ ...queryOptions
1175
+ } = options || {};
1176
+ const _transport = useTransport(transport);
1177
+ const result = useQuery(['grafana-dashboards'], async signal => {
1178
+ return await _transport.getGrafanaDashboards(signal);
1179
+ }, queryOptions);
1180
+ return result;
1181
+ };
1182
+ ;// ./src/entities/grafana-panel/index.ts
1183
+
1184
+
1185
+ const useGrafanaPanels = (grafanaDashboardUid, options) => {
1186
+ const {
1187
+ transport,
1188
+ ...queryOptions
1189
+ } = options || {};
1190
+ const _transport = useTransport(transport);
1191
+ const result = useQuery(['grafana-panels', grafanaDashboardUid], async signal => {
1192
+ const panels = await _transport.getGrafanaPanels(grafanaDashboardUid, signal);
1193
+ return panels.flatMap(panel => {
1194
+ if (!panel.panelSchema || panel.panelSchema.type === 'row') {
1195
+ return panel.subPanels || [];
1196
+ }
1197
+ return panel;
1198
+ });
1199
+ }, queryOptions);
1200
+ return result;
1201
+ };
1202
+ ;// ./src/widgets/DashboardEditor/components/ExternalDashboardsList.tsx
1203
+
1204
+ function ExternalDashboardsList_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1205
+
1206
+
1207
+
1208
+
1209
+
1210
+
1211
+
1212
+
1213
+ var ExternalDashboardsList_ref = true ? {
1214
+ name: "tc4e7",
1215
+ styles: "justify-content:center;height:100%;padding:8px"
1216
+ } : 0;
1217
+ var ExternalDashboardsList_ref2 = true ? {
1218
+ name: "67cb9k",
1219
+ styles: "justify-content:center;height:100%"
1220
+ } : 0;
1221
+ var ExternalDashboardsList_ref3 = true ? {
1222
+ name: "67cb9k",
1223
+ styles: "justify-content:center;height:100%"
1224
+ } : 0;
1225
+ const ExternalPanelList = ({
1226
+ dashboard,
1227
+ onPanelClick
1228
+ }) => {
1229
+ const theme = (0,react_namespaceObject.useTheme)();
1230
+ const {
1231
+ panelRegistry
1232
+ } = useInfraDashContext();
1233
+ const externalPanels = useGrafanaPanels(dashboard.id);
1234
+ if (!externalPanels.isLoaded) {
1235
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Wrapper, {
1236
+ direction: "column",
1237
+ css: ExternalDashboardsList_ref,
1238
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.ProgressCircle, {
1239
+ classnames: {
1240
+ inner: /*#__PURE__*/(0,css_namespaceObject.css)(`
1241
+ background: none !important;
1242
+ `, true ? "" : 0, true ? "" : 0),
1243
+ outer: /*#__PURE__*/(0,css_namespaceObject.css)(`
1244
+ background: none !important;
1245
+ border: 12px solid ${theme.colors.greyLighter};
1246
+ `, true ? "" : 0, true ? "" : 0)
1247
+ },
1248
+ currentValue: 3,
1249
+ max: 10,
1250
+ size: 20,
1251
+ color: "blue",
1252
+ mode: "infinite"
1253
+ })
1254
+ });
1255
+ }
1256
+ if (externalPanels.error) {
1257
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1258
+ direction: "column",
1259
+ css: ExternalDashboardsList_ref2,
1260
+ children: [(0,jsx_runtime_namespaceObject.jsx)(ErrorIcon, {}), (0,jsx_runtime_namespaceObject.jsxs)("p", {
1261
+ children: ["Failed to load panels for ", dashboard.title]
1262
+ })]
1263
+ });
1264
+ }
1265
+ if (!externalPanels.data.length) {
1266
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1267
+ direction: "column",
1268
+ css: ExternalDashboardsList_ref3,
1269
+ children: [(0,jsx_runtime_namespaceObject.jsx)(ErrorIcon, {}), (0,jsx_runtime_namespaceObject.jsxs)("p", {
1270
+ children: ["No panels found for ", dashboard.title]
1271
+ })]
1272
+ });
1273
+ }
1274
+ const availablePanels = externalPanels.data.filter(panel => {
1275
+ if (!panel.panelSchema?.type) {
1276
+ return false;
1277
+ }
1278
+ const availableComponents = panelRegistry.findPanelConfigsByType(panel.panelSchema.type);
1279
+ return availableComponents.length > 0;
1280
+ });
1281
+ return (0,jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
1282
+ children: availablePanels.map(panel => (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Button, {
1283
+ variant: "tertiary",
1284
+ className: /*#__PURE__*/(0,css_namespaceObject.css)("width:100%;min-height:34px;gap:8px;padding:8px 14px 8px 34px!important;justify-content:space-between;text-align:left;& svg{& path{stroke:", theme.colors.greyDarker, ";stroke-width:1.4px;}}" + ( true ? "" : 0), true ? "" : 0),
1285
+ onClick: () => onPanelClick?.(dashboard, panel),
1286
+ children: [panel.title, (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Icon, {
1287
+ name: "plus",
1288
+ size: 12
1289
+ })]
1290
+ }, panel.id))
1291
+ });
1292
+ };
1293
+ var _ref4 = true ? {
1294
+ name: "67cb9k",
1295
+ styles: "justify-content:center;height:100%"
1296
+ } : 0;
1297
+ var _ref5 = true ? {
1298
+ name: "67cb9k",
1299
+ styles: "justify-content:center;height:100%"
1300
+ } : 0;
1301
+ var _ref6 = true ? {
1302
+ name: "67cb9k",
1303
+ styles: "justify-content:center;height:100%"
1304
+ } : 0;
1305
+ var _ref7 = true ? {
1306
+ name: "1qmr6ab",
1307
+ styles: "overflow:auto"
1308
+ } : 0;
1309
+ const ExternalDashboardsList = ({
1310
+ onPanelClick,
1311
+ ...divProps
1312
+ }) => {
1313
+ const theme = (0,react_namespaceObject.useTheme)();
1314
+ const dashboardsQuery = useGrafanaDashboards();
1315
+ if (!dashboardsQuery.isLoaded) {
1316
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Wrapper, {
1317
+ direction: "column",
1318
+ css: _ref4,
1319
+ ...divProps,
1320
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.ProgressCircle, {
1321
+ classnames: {
1322
+ inner: /*#__PURE__*/(0,css_namespaceObject.css)(`
1323
+ background: none !important;
1324
+ `, true ? "" : 0, true ? "" : 0),
1325
+ outer: /*#__PURE__*/(0,css_namespaceObject.css)(`
1326
+ background: none !important;
1327
+ border: 12px solid ${theme.colors.greyLighter};
1328
+ `, true ? "" : 0, true ? "" : 0)
1329
+ },
1330
+ currentValue: 3,
1331
+ max: 10,
1332
+ size: 64,
1333
+ color: "blue",
1334
+ mode: "infinite"
1335
+ })
1336
+ });
1337
+ }
1338
+ if (dashboardsQuery.error) {
1339
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1340
+ direction: "column",
1341
+ css: _ref5,
1342
+ ...divProps,
1343
+ children: [(0,jsx_runtime_namespaceObject.jsx)(ErrorIcon, {}), (0,jsx_runtime_namespaceObject.jsx)("p", {
1344
+ children: "Failed to load external dashboards"
1345
+ })]
1346
+ });
1347
+ }
1348
+ if (!dashboardsQuery.data.length) {
1349
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1350
+ direction: "column",
1351
+ css: _ref6,
1352
+ ...divProps,
1353
+ children: [(0,jsx_runtime_namespaceObject.jsx)(ErrorIcon, {}), (0,jsx_runtime_namespaceObject.jsx)("p", {
1354
+ children: "No external dashboards found"
1355
+ })]
1356
+ });
1357
+ }
1358
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.AccordionGroupContextProvider, {
1359
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.AccordionGroup, {
1360
+ size: "small",
1361
+ css: _ref7,
1362
+ ...divProps,
1363
+ children: dashboardsQuery.data.map(dashboard => (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Accordion, {
1364
+ id: dashboard.id,
1365
+ title: dashboard.title,
1366
+ className: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
1367
+ name: "2zzvc7",
1368
+ styles: "padding:0!important;align-items:start!important"
1369
+ } : 0),
1370
+ renderTitle: ({
1371
+ title,
1372
+ isOpened,
1373
+ onClick
1374
+ }) => (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1375
+ onClick: onClick,
1376
+ variant: "tertiary",
1377
+ className: /*#__PURE__*/(0,css_namespaceObject.css)("width:100%;min-height:34px;gap:8px;padding:8px 14px!important;text-align:left;& svg{& path{stroke:", theme.colors.greyDarker, ";stroke-width:1.4px;}}" + ( true ? "" : 0), true ? "" : 0),
1378
+ startIcon: isOpened ? (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Icon, {
1379
+ name: "carrot-down",
1380
+ size: 12
1381
+ }) : (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Icon, {
1382
+ name: "carrot-right",
1383
+ size: 12
1384
+ }),
1385
+ children: title
1386
+ }),
1387
+ renderContent: ({
1388
+ isOpened
1389
+ }) => (0,jsx_runtime_namespaceObject.jsx)("div", {
1390
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
1391
+ width: '100%',
1392
+ display: isOpened ? 'block' : 'none',
1393
+ fontWeight: 500,
1394
+ fontSize: '14px'
1395
+ }, true ? "" : 0, true ? "" : 0),
1396
+ children: (0,jsx_runtime_namespaceObject.jsx)(ExternalPanelList, {
1397
+ dashboard: dashboard,
1398
+ onPanelClick: onPanelClick
1399
+ })
1400
+ })
1401
+ }, dashboard.id))
1402
+ })
1403
+ });
1404
+ };
1405
+ ;// ./src/widgets/DashboardEditor/helpers.ts
1406
+
1407
+ const appendPanel = params => {
1408
+ const {
1409
+ dashboard,
1410
+ panelRegistry,
1411
+ source
1412
+ } = params;
1413
+ const nextY = dashboard.panels.reduce((maxY, {
1414
+ panelDefinition: {
1415
+ gridPos
1416
+ }
1417
+ }) => Math.max(maxY, gridPos.y + gridPos.h), 0);
1418
+ const newPanel = matchPanelDataSource(source.type, {
1419
+ grafana: () => {
1420
+ const {
1421
+ grafanaDashboard,
1422
+ grafanaPanel
1423
+ } = source;
1424
+ if (!grafanaPanel.panelSchema) {
1425
+ return; // no schema, cannot append panel
1426
+ }
1427
+ const [defaultComponentConfig] = panelRegistry.findPanelConfigsByType(grafanaPanel.panelSchema.type);
1428
+ const newPanel = {
1429
+ id: -Date.now(),
1430
+ // use a negative ID to indicate a new panel
1431
+ panelDefinition: {
1432
+ version: 1,
1433
+ source: {
1434
+ type: 'grafana',
1435
+ dashboardUid: grafanaDashboard.id,
1436
+ panelId: grafanaPanel.id
1437
+ },
1438
+ component: {
1439
+ id: defaultComponentConfig.componentId,
1440
+ props: {}
1441
+ },
1442
+ gridPos: {
1443
+ x: 0,
1444
+ y: nextY,
1445
+ w: 12,
1446
+ h: 6
1447
+ }
1448
+ },
1449
+ panelSchema: grafanaPanel.panelSchema,
1450
+ title: grafanaPanel.title
1451
+ };
1452
+ return newPanel;
1453
+ }
1454
+ });
1455
+ if (!newPanel) {
1456
+ return dashboard; // no new panel created, return original dashboard
1457
+ }
1458
+ return {
1459
+ ...dashboard,
1460
+ panels: [...(dashboard.panels || []), newPanel]
1461
+ };
1462
+ };
1463
+ const updatePanel = ({
1464
+ dashboard,
1465
+ panel
1466
+ }) => {
1467
+ const newPanels = dashboard.panels.map(p => p.id === panel.id ? {
1468
+ ...p,
1469
+ ...panel
1470
+ } : p);
1471
+ return {
1472
+ ...dashboard,
1473
+ panels: newPanels
1474
+ };
1475
+ };
1476
+ const removePanel = ({
1477
+ dashboard,
1478
+ panel
1479
+ }) => {
1480
+ const newPanels = dashboard.panels.filter(p => p.id !== panel.id);
1481
+ return {
1482
+ ...dashboard,
1483
+ panels: newPanels
1484
+ };
1485
+ };
1486
+ const applyNewLayout = ({
1487
+ dashboard,
1488
+ newLayout
1489
+ }) => {
1490
+ const newLayoutMap = newLayout.reduce((map, {
1491
+ i,
1492
+ ...layout
1493
+ }) => ({
1494
+ ...map,
1495
+ [i]: layout
1496
+ }), {});
1497
+ dashboard.panels.forEach(panel => {
1498
+ const newGridPos = newLayoutMap[panel.id.toString()];
1499
+ if (!newGridPos) {
1500
+ throw new Error(`New position for the ${panel.id} not fount`);
1501
+ }
1502
+ panel.panelDefinition.gridPos = newGridPos;
1503
+ return panel;
1504
+ });
1505
+ return dashboard;
1506
+ };
1507
+ ;// ./src/widgets/DashboardEditor/components/PanelControl.tsx
1508
+ function PanelControl_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1509
+
1510
+
1511
+
1512
+ var PanelControl_ref = true ? {
1513
+ name: "88ft23",
1514
+ styles: "gap:5px;width:100%"
1515
+ } : 0;
1516
+ var PanelControl_ref2 = true ? {
1517
+ name: "88ft23",
1518
+ styles: "gap:5px;width:100%"
1519
+ } : 0;
1520
+ const PanelControlContent = ({
1521
+ panel,
1522
+ onEdit,
1523
+ onRemove
1524
+ }) => {
1525
+ const theme = (0,react_namespaceObject.useTheme)();
1526
+ const popover = (0,core_namespaceObject.usePopoverContext)();
1527
+ const handleClose = () => {
1528
+ popover.setOpen(false);
1529
+ };
1530
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.PopoverContent, {
1531
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
1532
+ gap: 15,
1533
+ alignItems: 'start',
1534
+ border: `2px solid ${theme.colors.greyLighter}`,
1535
+ backgroundColor: theme.colors.white,
1536
+ borderRadius: 15,
1537
+ padding: 15
1538
+ }, true ? "" : 0, true ? "" : 0),
1539
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1540
+ variant: "tertiary",
1541
+ css: PanelControl_ref,
1542
+ onClick: () => {
1543
+ onEdit?.(panel);
1544
+ handleClose();
1545
+ },
1546
+ startIcon: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Icon, {
1547
+ name: "edit",
1548
+ size: 14
1549
+ }),
1550
+ children: "Edit"
1551
+ }), (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1552
+ variant: "tertiary",
1553
+ css: PanelControl_ref2,
1554
+ onClick: () => {
1555
+ onRemove?.(panel);
1556
+ handleClose();
1557
+ },
1558
+ startIcon: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Icon, {
1559
+ name: "bin",
1560
+ size: 14
1561
+ }),
1562
+ children: "Remove"
1563
+ })]
1564
+ });
1565
+ };
1566
+ const PanelControl = props => {
1567
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Popover, {
1568
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.PopoverTrigger, {
1569
+ variant: "tertiary",
1570
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Icon, {
1571
+ name: "more-vertical",
1572
+ size: 14
1573
+ })
1574
+ }), (0,jsx_runtime_namespaceObject.jsx)(PanelControlContent, {
1575
+ ...props
1576
+ })]
1577
+ });
1578
+ };
1579
+ ;// external "@rjsf/validator-ajv8"
1580
+ const validator_ajv8_namespaceObject = require("@rjsf/validator-ajv8");
1581
+ var validator_ajv8_default = /*#__PURE__*/__webpack_require__.n(validator_ajv8_namespaceObject);
1582
+ ;// ./src/widgets/DashboardEditor/components/PanelSettings.tsx
1583
+ function PanelSettings_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1584
+
1585
+
1586
+
1587
+
1588
+
1589
+
1590
+ var PanelSettings_ref = true ? {
1591
+ name: "iqoq9n",
1592
+ styles: "margin-top:20px"
1593
+ } : 0;
1594
+ var PanelSettings_ref2 = true ? {
1595
+ name: "iqoq9n",
1596
+ styles: "margin-top:20px"
1597
+ } : 0;
1598
+ const PanelSettings = ({
1599
+ panel,
1600
+ onChange,
1601
+ onSave
1602
+ }) => {
1603
+ const {
1604
+ panelRegistry
1605
+ } = useInfraDashContext();
1606
+ const [originalPanel, setOriginalPanel] = (0,external_react_namespaceObject.useState)(panel);
1607
+ const savedRef = (0,external_react_namespaceObject.useRef)(false);
1608
+ if (panel.id !== originalPanel.id) {
1609
+ setOriginalPanel(panel);
1610
+ }
1611
+
1612
+ // cleanup function to reset the original panel when the component unmounts or panel changes
1613
+ (0,external_react_namespaceObject.useEffect)(() => {
1614
+ return () => {
1615
+ if (savedRef.current) {
1616
+ savedRef.current = false;
1617
+ return;
1618
+ }
1619
+ onChange?.(originalPanel);
1620
+ };
1621
+ }, [originalPanel]);
1622
+ const panelComponent = panel.panelDefinition.component;
1623
+ const {
1624
+ propsSchema,
1625
+ uiSchema
1626
+ } = panelRegistry.getPanelConfig(panelComponent.id);
1627
+ const availableComponents = panelRegistry.findPanelConfigsByType(panel.panelSchema.type);
1628
+ const handleComponentChange = componentId => {
1629
+ const originalComponent = originalPanel.panelDefinition.component;
1630
+ const props = originalComponent.id === componentId ? originalComponent.props : {};
1631
+ const newPanel = {
1632
+ ...panel,
1633
+ panelDefinition: {
1634
+ ...panel.panelDefinition,
1635
+ component: {
1636
+ id: componentId,
1637
+ props
1638
+ }
1639
+ }
1640
+ };
1641
+ onChange?.(newPanel);
1642
+ };
1643
+ const handlePropsChange = props => {
1644
+ const newPanel = {
1645
+ ...panel,
1646
+ panelDefinition: {
1647
+ ...panel.panelDefinition,
1648
+ component: {
1649
+ ...panelComponent,
1650
+ props: props
1651
+ }
1652
+ }
1653
+ };
1654
+ onChange?.(newPanel);
1655
+ };
1656
+ const handlePanelSave = () => {
1657
+ savedRef.current = true;
1658
+ setOriginalPanel(panel);
1659
+ onSave?.();
1660
+ };
1661
+ return (0,jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
1662
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Typeahead, {
1663
+ label: "Panel Component",
1664
+ wrapperClassName: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
1665
+ name: "101yl78",
1666
+ styles: "margin-top:20px;width:100%!important"
1667
+ } : 0),
1668
+ filterOptions: false,
1669
+ selectedItems: [panelComponent.id],
1670
+ onChange: componentId => handleComponentChange(componentId),
1671
+ children: availableComponents.map(component => (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.TypeaheadOption, {
1672
+ value: component.componentId,
1673
+ label: component.name,
1674
+ children: component.name
1675
+ }, component.componentId))
1676
+ }), propsSchema && (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.JsonSchema.Form, {
1677
+ idPrefix: "infra-dash-panel-settings",
1678
+ onChange: ({
1679
+ formData
1680
+ }) => handlePropsChange(formData),
1681
+ css: PanelSettings_ref,
1682
+ formData: panelComponent.props,
1683
+ schema: propsSchema,
1684
+ uiSchema: {
1685
+ 'ui:submitButtonOptions': {
1686
+ norender: true
1687
+ },
1688
+ ...uiSchema
1689
+ },
1690
+ validator: (validator_ajv8_default())
1691
+ }), (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1692
+ css: PanelSettings_ref2,
1693
+ variant: "info",
1694
+ onClick: handlePanelSave,
1695
+ children: "Save"
1696
+ })]
1697
+ });
1698
+ };
1699
+ ;// ./src/widgets/DashboardEditor/DashboardEditor.tsx
1700
+ function DashboardEditor_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
1701
+
1702
+
1703
+
1704
+
1705
+
1706
+
1707
+
1708
+
1709
+
1710
+
1711
+
1712
+
1713
+
1714
+
1715
+
1716
+
1717
+
1718
+
1719
+ var DashboardEditor_ref = true ? {
1720
+ name: "1st9kbp",
1721
+ styles: "height:100%;position:relative"
1722
+ } : 0;
1723
+ var DashboardEditor_ref2 = true ? {
1724
+ name: "iqoq9n",
1725
+ styles: "margin-top:20px"
1726
+ } : 0;
1727
+ var DashboardEditor_ref3 = true ? {
1728
+ name: "f7mf5j",
1729
+ styles: "flex-grow:1;padding:24px 32px;height:100%"
1730
+ } : 0;
1731
+ var DashboardEditor_ref4 = true ? {
1732
+ name: "z5ygou",
1733
+ styles: "gap:24px"
1734
+ } : 0;
1735
+ var DashboardEditor_ref5 = true ? {
1736
+ name: "hwdztk",
1737
+ styles: "width:36px;height:36px;padding:8px"
1738
+ } : 0;
1739
+ var DashboardEditor_ref6 = true ? {
1740
+ name: "1hsfcap",
1741
+ styles: "flex-shrink:0;font-weight:600;font-size:20px;text-align:center"
1742
+ } : 0;
1743
+ var DashboardEditor_ref7 = true ? {
1744
+ name: "1lsto0t",
1745
+ styles: "max-width:250px"
1746
+ } : 0;
1747
+ var _ref8 = true ? {
1748
+ name: "1yxfaqj",
1749
+ styles: "height:46px"
1750
+ } : 0;
1751
+ var _ref9 = true ? {
1752
+ name: "14lyq40",
1753
+ styles: "margin-top:20px;overflow:auto;height:100%"
1754
+ } : 0;
1755
+ const DashboardEditorInternal = ({
1756
+ dashboard: controlledDashboard,
1757
+ defaultDashboard,
1758
+ gridProps,
1759
+ onChange,
1760
+ onSaved,
1761
+ onCreate,
1762
+ onError,
1763
+ ...divProps
1764
+ }) => {
1765
+ const [selectedPanelId, setSelectedPanelId] = (0,external_react_namespaceObject.useState)(null);
1766
+ const {
1767
+ panelRegistry
1768
+ } = useInfraDashContext();
1769
+ const dashboardsSelectorDrawer = (0,core_namespaceObject.useDrawer)({});
1770
+ const panelSettingsDrawer = (0,core_namespaceObject.useDrawer)({
1771
+ position: 'right',
1772
+ onOpenChange: open => {
1773
+ if (!open && selectedPanelId !== null) {
1774
+ setSelectedPanelId(null);
1775
+ }
1776
+ }
1777
+ });
1778
+ const [dashboard, setDashboard] = (0,hooks_namespaceObject.useUncontrolled)({
1779
+ value: controlledDashboard,
1780
+ defaultValue: defaultDashboard,
1781
+ finalValue: {
1782
+ dashboardDefinition: {
1783
+ version: 1
1784
+ },
1785
+ id: -1,
1786
+ panels: [],
1787
+ title: 'New Dashboard'
1788
+ },
1789
+ onChange
1790
+ });
1791
+ (0,external_react_namespaceObject.useEffect)(() => {
1792
+ // if the default dashboard changes, update the current dashboard
1793
+ if (defaultDashboard && dashboard.id !== defaultDashboard.id) {
1794
+ setDashboard(defaultDashboard);
1795
+ }
1796
+ }, [dashboard.id, defaultDashboard?.id]);
1797
+ const {
1798
+ mutate: updateDashboard,
1799
+ isLoading: isUpdating
1800
+ } = useUpdateDashboard(dashboard.id);
1801
+ const {
1802
+ mutate: createDashboard,
1803
+ isLoading: isCreating
1804
+ } = useCreateDashboard();
1805
+ const handleAddPanel = (grafanaDashboard, grafanaPanel) => {
1806
+ const newDashboard = appendPanel({
1807
+ dashboard,
1808
+ panelRegistry,
1809
+ source: {
1810
+ type: PANEL_DATA_SOURCE.GRAFANA,
1811
+ grafanaDashboard,
1812
+ grafanaPanel
1813
+ }
1814
+ });
1815
+ setDashboard(newDashboard);
1816
+ };
1817
+ const handleLayoutChange = newLayout => {
1818
+ setDashboard(applyNewLayout({
1819
+ dashboard,
1820
+ newLayout
1821
+ }));
1822
+ };
1823
+ const handlePanelEdit = panel => {
1824
+ setSelectedPanelId(panel.id);
1825
+ panelSettingsDrawer.toggle(true);
1826
+ };
1827
+ const handlePanelUpdate = panel => {
1828
+ setDashboard(updatePanel({
1829
+ dashboard,
1830
+ panel
1831
+ }));
1832
+ };
1833
+ const handlePanelRemove = panel => {
1834
+ setDashboard(removePanel({
1835
+ dashboard,
1836
+ panel
1837
+ }));
1838
+ };
1839
+ const handlePersistDashboard = () => {
1840
+ if (dashboard.id > 0) {
1841
+ updateDashboard(dashboard).then(() => onSaved?.(dashboard)).catch(error => onError?.(error));
1842
+ } else {
1843
+ createDashboard({
1844
+ panels: dashboard.panels,
1845
+ dashboardDefinition: dashboard.dashboardDefinition,
1846
+ title: dashboard.title,
1847
+ dashboardUid: dashboard.id.toString()
1848
+ }).then(() => onCreate?.()).catch(error => onError?.(error));
1849
+ }
1850
+ };
1851
+ const selectedPanel = selectedPanelId !== null ? dashboard.panels.find(p => p.id === selectedPanelId) : null;
1852
+ const cannotPersist = isCreating || isUpdating || !dashboard.panels.length;
1853
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1854
+ alignItems: "start",
1855
+ css: DashboardEditor_ref,
1856
+ ...divProps,
1857
+ children: [(0,jsx_runtime_namespaceObject.jsx)(DashboardSelectorDrawer, {
1858
+ drawer: dashboardsSelectorDrawer,
1859
+ children: (0,jsx_runtime_namespaceObject.jsx)(ExternalDashboardsList, {
1860
+ css: DashboardEditor_ref2,
1861
+ onPanelClick: handleAddPanel
1862
+ })
1863
+ }), (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1864
+ direction: "column",
1865
+ alignItems: "start",
1866
+ css: DashboardEditor_ref3,
1867
+ children: [(0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.Wrapper, {
1868
+ css: DashboardEditor_ref4,
1869
+ children: [!dashboardsSelectorDrawer.opened && !dashboardsSelectorDrawer.transition.isMounted && (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1870
+ variant: "secondary",
1871
+ css: DashboardEditor_ref5,
1872
+ onClick: () => dashboardsSelectorDrawer.toggle(true),
1873
+ children: (0,jsx_runtime_namespaceObject.jsx)(DashboardIcon, {})
1874
+ }), (0,jsx_runtime_namespaceObject.jsx)("h2", {
1875
+ css: DashboardEditor_ref6,
1876
+ children: "Dashboard Editor"
1877
+ }), (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Input, {
1878
+ name: "dashboard-name",
1879
+ placeholder: "Dashboard Name",
1880
+ inputProps: {
1881
+ value: dashboard.title,
1882
+ onChange: e => setDashboard({
1883
+ ...dashboard,
1884
+ title: e.target.value
1885
+ })
1886
+ },
1887
+ css: DashboardEditor_ref7
1888
+ }), (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.Button, {
1889
+ variant: "info",
1890
+ css: _ref8,
1891
+ isDisabled: cannotPersist,
1892
+ onClick: handlePersistDashboard,
1893
+ children: dashboard.id > 0 ? 'Save' : 'Create'
1894
+ })]
1895
+ }), (0,jsx_runtime_namespaceObject.jsx)(DashboardPanelGrid, {
1896
+ resizable: true,
1897
+ draggable: true,
1898
+ dashboard: dashboard,
1899
+ css: _ref9,
1900
+ onLayoutChange: handleLayoutChange,
1901
+ onDragStart: () => panelSettingsDrawer.toggle(false),
1902
+ onResizeStart: () => panelSettingsDrawer.toggle(false),
1903
+ renderPanelControl: panel => (0,jsx_runtime_namespaceObject.jsx)(PanelControl, {
1904
+ panel: panel,
1905
+ onEdit: () => handlePanelEdit(panel),
1906
+ onRemove: () => handlePanelRemove(panel)
1907
+ }),
1908
+ ...gridProps
1909
+ })]
1910
+ }), (0,jsx_runtime_namespaceObject.jsx)(PanelSettingsDrawer, {
1911
+ drawer: panelSettingsDrawer,
1912
+ children: selectedPanel && (0,jsx_runtime_namespaceObject.jsx)(PanelSettings, {
1913
+ panel: selectedPanel,
1914
+ onChange: handlePanelUpdate,
1915
+ onSave: () => panelSettingsDrawer.toggle(false)
1916
+ })
1917
+ })]
1918
+ });
1919
+ };
1920
+ const DashboardEditor = ({
1921
+ dashboardId,
1922
+ ...props
1923
+ }) => {
1924
+ const {
1925
+ dashboard,
1926
+ defaultDashboard
1927
+ } = props;
1928
+ const dashboardById = useDashboard(dashboardId ?? -1, {
1929
+ enabled: !!dashboardId && !dashboard && !defaultDashboard
1930
+ });
1931
+ if (!dashboardId) {
1932
+ return (0,jsx_runtime_namespaceObject.jsx)(external_react_error_boundary_namespaceObject.ErrorBoundary, {
1933
+ fallback: (0,jsx_runtime_namespaceObject.jsx)(DashboardError, {
1934
+ children: "Something went wrong"
1935
+ }),
1936
+ children: (0,jsx_runtime_namespaceObject.jsx)(DashboardEditorInternal, {
1937
+ ...props
1938
+ })
1939
+ });
1940
+ }
1941
+ if (!dashboardById.isLoaded) {
1942
+ return (0,jsx_runtime_namespaceObject.jsx)(LoadingDashboard, {});
1943
+ }
1944
+ if (dashboardById.error) {
1945
+ return (0,jsx_runtime_namespaceObject.jsx)(DashboardError, {});
1946
+ }
1947
+ return (0,jsx_runtime_namespaceObject.jsx)(external_react_error_boundary_namespaceObject.ErrorBoundary, {
1948
+ fallback: (0,jsx_runtime_namespaceObject.jsx)(DashboardError, {
1949
+ children: "Something went wrong"
1950
+ }),
1951
+ children: (0,jsx_runtime_namespaceObject.jsx)(DashboardEditorInternal, {
1952
+ ...props,
1953
+ defaultDashboard: dashboardById.data
1954
+ })
1955
+ });
1956
+ };
1957
+ ;// ./src/widgets/DashboardEditor/index.ts
1958
+
1959
+ ;// ./src/shared/exception.ts
1960
+ const tryCatch = async promise => {
1961
+ try {
1962
+ const data = await promise;
1963
+ return [null, data];
1964
+ } catch (error) {
1965
+ return [error, null];
1966
+ }
1967
+ };
1968
+ ;// ./src/shared/transport/restTransport.ts
1969
+
1970
+ class RestInfraDashTransport {
1971
+ constructor({
1972
+ baseUrl,
1973
+ authMiddleware,
1974
+ unwrapResponse
1975
+ }) {
1976
+ if (!baseUrl) {
1977
+ throw new Error('Base URL is required for RestInfraDashTransport');
1978
+ }
1979
+ this.baseUrl = baseUrl;
1980
+ this.authMiddleware = authMiddleware;
1981
+ this.unwrapResponse = unwrapResponse;
1982
+ }
1983
+ getUrl(path) {
1984
+ return `${this.baseUrl}${path}`;
1985
+ }
1986
+ async applyMiddlewares(request) {
1987
+ if (this.authMiddleware) {
1988
+ return await this.authMiddleware(request);
1989
+ }
1990
+ return request;
1991
+ }
1992
+
1993
+ // TODO: add validation schema support
1994
+ async makeRequest(request, parseResponse = true) {
1995
+ const finalizedRequest = await this.applyMiddlewares(request);
1996
+ const [error, response] = await tryCatch(fetch(finalizedRequest));
1997
+ if (error || !response.ok) {
1998
+ throw new Error(`Request ${finalizedRequest.url} failed: ${error?.message ?? response?.statusText}`);
1999
+ }
2000
+ if (!parseResponse) {
2001
+ return response;
2002
+ }
2003
+ const json = await response.json();
2004
+ let result = json;
2005
+ if (this.unwrapResponse) {
2006
+ result = await this.unwrapResponse(json);
2007
+ }
2008
+ return result;
2009
+ }
2010
+ async getGrafanaDashboards(signal) {
2011
+ const request = new Request(this.getUrl('/grafana/dashboards'), {
2012
+ method: 'GET',
2013
+ signal
2014
+ });
2015
+ return await this.makeRequest(request);
2016
+ }
2017
+ async getGrafanaPanels(grafanaDashboardUid, signal) {
2018
+ const request = new Request(this.getUrl(`/grafana/dashboards/${grafanaDashboardUid}`), {
2019
+ method: 'GET',
2020
+ signal
2021
+ });
2022
+ return await this.makeRequest(request);
2023
+ }
2024
+ async getGrafanaPanelData({
2025
+ dashboardUid,
2026
+ panelId
2027
+ }, signal) {
2028
+ const request = new Request(this.getUrl(`/grafana/dashboards/${dashboardUid}/panel/${panelId}`), {
2029
+ method: 'POST',
2030
+ signal
2031
+ });
2032
+ return await this.makeRequest(request);
2033
+ }
2034
+ async getPanelData(panelId, signal) {
2035
+ const request = new Request(this.getUrl(`/dashboards/panels/${panelId}`), {
2036
+ method: 'POST',
2037
+ signal
2038
+ });
2039
+ return await this.makeRequest(request);
2040
+ }
2041
+ async getDashboards(signal) {
2042
+ const request = new Request(this.getUrl(`/dashboards`), {
2043
+ method: 'GET',
2044
+ signal
2045
+ });
2046
+ return await this.makeRequest(request);
2047
+ }
2048
+ async getDashboard(dashboardUid, signal) {
2049
+ const request = new Request(this.getUrl(`/dashboards/${dashboardUid}`), {
2050
+ method: 'GET',
2051
+ signal
2052
+ });
2053
+ return await this.makeRequest(request);
2054
+ }
2055
+ async createDashboard(payload, signal) {
2056
+ const request = new Request(this.getUrl(`/dashboards`), {
2057
+ method: 'POST',
2058
+ body: JSON.stringify(payload),
2059
+ headers: {
2060
+ 'Content-Type': 'application/json'
2061
+ },
2062
+ signal
2063
+ });
2064
+ return await this.makeRequest(request, false);
2065
+ }
2066
+ async updateDashboard(payload, signal) {
2067
+ const {
2068
+ dashboardId,
2069
+ ...body
2070
+ } = payload;
2071
+ const request = new Request(this.getUrl(`/dashboards/${dashboardId}`), {
2072
+ method: 'POST',
2073
+ body: JSON.stringify(body),
2074
+ headers: {
2075
+ 'Content-Type': 'application/json'
2076
+ },
2077
+ signal
2078
+ });
2079
+ return await this.makeRequest(request, false);
2080
+ }
2081
+ async deleteDashboard(dashboardId, signal) {
2082
+ const request = new Request(this.getUrl(`/dashboards/${dashboardId}`), {
2083
+ method: 'DELETE',
2084
+ signal
2085
+ });
2086
+ return await this.makeRequest(request, false);
2087
+ }
2088
+ }
2089
+ ;// ./src/shared/transport/index.ts
2090
+
2091
+
2092
+
2093
+ ;// ./src/shared/query/query.ts
2094
+
2095
+ class QueryEntry {
2096
+ state = {
2097
+ data: undefined,
2098
+ error: null,
2099
+ isLoaded: false,
2100
+ isFetching: false
2101
+ };
2102
+ promise = null;
2103
+ subscribers = new Set();
2104
+ controller = null;
2105
+ constructor(key, fetcher, options) {
2106
+ this.key = key;
2107
+ this.fetcher = fetcher;
2108
+ this.options = {
2109
+ enabled: options?.enabled ?? true
2110
+ };
2111
+ }
2112
+ notify() {
2113
+ // ensure subscribers are notified after the current call stack
2114
+ queueMicrotask(() => {
2115
+ for (const sub of this.subscribers) {
2116
+ sub(this.state);
2117
+ }
2118
+ });
2119
+ }
2120
+ updateEntity(fetcher, options) {
2121
+ this.fetcher = fetcher;
2122
+ this.options = {
2123
+ ...this.options,
2124
+ ...options
2125
+ };
2126
+ this.fetch(); // re-trigger fetch with new fetcher
2127
+ return this;
2128
+ }
2129
+ fetch() {
2130
+ if (!this.options.enabled) {
2131
+ if (this.state.isLoaded || this.state.isFetching) {
2132
+ this.state = {
2133
+ ...this.state,
2134
+ data: undefined,
2135
+ error: null,
2136
+ isLoaded: false,
2137
+ isFetching: false
2138
+ };
2139
+ this.cancel();
2140
+ this.notify();
2141
+ }
2142
+ return Promise.resolve(this.state.data);
2143
+ }
2144
+
2145
+ // dedupe in-flight fetches
2146
+ if (this.promise && !this.controller?.signal.aborted) {
2147
+ return this.promise;
2148
+ }
2149
+ if (this.state.isLoaded && !this.state.isFetching) {
2150
+ return Promise.resolve(this.state.data);
2151
+ }
2152
+ this.state = {
2153
+ ...this.state,
2154
+ isFetching: true
2155
+ };
2156
+ this.notify();
2157
+ this.controller = new AbortController();
2158
+ const signal = this.controller.signal;
2159
+ this.promise = this.fetcher(signal).then(data => {
2160
+ this.state = {
2161
+ data,
2162
+ error: null,
2163
+ isLoaded: true,
2164
+ isFetching: false
2165
+ };
2166
+ return data;
2167
+ }).catch(error => {
2168
+ if (signal.aborted) {
2169
+ return undefined;
2170
+ }
2171
+ this.state = {
2172
+ data: undefined,
2173
+ error,
2174
+ isLoaded: true,
2175
+ isFetching: false
2176
+ };
2177
+ return undefined;
2178
+ }).finally(() => {
2179
+ this.promise = null;
2180
+ this.notify();
2181
+ });
2182
+ return this.promise;
2183
+ }
2184
+ subscribe(sub) {
2185
+ this.subscribers.add(sub);
2186
+ sub(this.state);
2187
+ return () => {
2188
+ this.subscribers.delete(sub);
2189
+ setTimeout(() => {
2190
+ if (!this.subscribers.size) {
2191
+ this.cancel();
2192
+ }
2193
+ });
2194
+ };
2195
+ }
2196
+ setData(data) {
2197
+ this.state = {
2198
+ ...this.state,
2199
+ isLoaded: true,
2200
+ isFetching: false,
2201
+ error: null,
2202
+ data
2203
+ };
2204
+ this.notify();
2205
+ }
2206
+ invalidate(reset = false) {
2207
+ if (reset) {
2208
+ // if reset is true, we reset the state to initial
2209
+ this.state = {
2210
+ data: undefined,
2211
+ error: null,
2212
+ isLoaded: false,
2213
+ isFetching: false
2214
+ };
2215
+ }
2216
+ // kick off a new fetch
2217
+ this.state.isFetching = true;
2218
+ this.cancel();
2219
+ this.fetch();
2220
+ }
2221
+ cancel() {
2222
+ if (this.controller) {
2223
+ this.controller.abort('Query cancelled');
2224
+ this.controller = null;
2225
+ }
2226
+ }
2227
+ }
2228
+ class QueryClient {
2229
+ cache = new Map();
2230
+ get(key) {
2231
+ return this.cache.get(hashKey(key));
2232
+ }
2233
+ fetchQuery(key, fetcher, options) {
2234
+ const keyHash = hashKey(key);
2235
+ let entry = this.cache.get(keyHash);
2236
+ if (!entry) {
2237
+ entry = new QueryEntry(key, fetcher, options);
2238
+ this.cache.set(keyHash, entry);
2239
+ }
2240
+ entry.fetch(); // trigger network (or return cached in-flight promise)
2241
+ return entry;
2242
+ }
2243
+ invalidateQueries({
2244
+ key,
2245
+ exact,
2246
+ reset
2247
+ }) {
2248
+ const matchingEntries = [];
2249
+ for (const [hash, entry] of this.cache.entries()) {
2250
+ if (exact) {
2251
+ if (hash === hashKey(key)) {
2252
+ matchingEntries.push(entry);
2253
+ }
2254
+ } else {
2255
+ if (partialMatchKey(entry.key, key)) {
2256
+ matchingEntries.push(entry);
2257
+ }
2258
+ }
2259
+ }
2260
+ for (const entry of matchingEntries) {
2261
+ entry.invalidate(reset);
2262
+ }
2263
+ }
2264
+ setQueryData(key, data) {
2265
+ const keyHash = hashKey(key);
2266
+ const existing = this.cache.get(keyHash);
2267
+ if (existing) {
2268
+ existing.setData(data);
2269
+ } else {
2270
+ const newEntry = new QueryEntry(key, () => Promise.resolve(data));
2271
+ newEntry.setData(data);
2272
+ this.cache.set(keyHash, newEntry);
2273
+ }
2274
+ }
2275
+ }
2276
+ const queryClient = new QueryClient();
2277
+ ;// ./src/shared/query/mutation.ts
2278
+
2279
+ class MutationEntry {
2280
+ state = {
2281
+ data: undefined,
2282
+ error: undefined,
2283
+ isLoading: false
2284
+ };
2285
+ promise = null;
2286
+ subscribers = new Set();
2287
+ controller = null;
2288
+ constructor(key, mutationFn, options) {
2289
+ this.key = key;
2290
+ this.mutationFn = mutationFn;
2291
+ this.options = options;
2292
+ }
2293
+ notify() {
2294
+ for (const sub of this.subscribers) {
2295
+ sub(this.state);
2296
+ }
2297
+ }
2298
+ updateEntity(mutationFn, options) {
2299
+ this.mutationFn = mutationFn;
2300
+ if (options !== undefined) {
2301
+ this.options = options;
2302
+ }
2303
+ }
2304
+ mutate(...args) {
2305
+ const variables = args[0];
2306
+
2307
+ // abort any existing in-flight mutation
2308
+ if (this.controller) {
2309
+ this.controller.abort();
2310
+ }
2311
+ this.controller = new AbortController();
2312
+ const signal = this.controller.signal;
2313
+ this.state = {
2314
+ ...this.state,
2315
+ isLoading: true
2316
+ };
2317
+ this.notify();
2318
+ const {
2319
+ onSuccess,
2320
+ onError,
2321
+ onSettled
2322
+ } = this.options || {};
2323
+ this.promise = this.mutationFn(variables, signal).then(data => {
2324
+ this.state = {
2325
+ data,
2326
+ error: undefined,
2327
+ isLoading: false
2328
+ };
2329
+ this.notify();
2330
+ if (onSuccess) {
2331
+ try {
2332
+ onSuccess(data, variables);
2333
+ } catch (err) {
2334
+ console.error('Error in onSuccess callback:', err);
2335
+ }
2336
+ }
2337
+ if (onSettled) {
2338
+ try {
2339
+ onSettled(undefined, data, variables);
2340
+ } catch (err) {
2341
+ console.error('Error in onSettled callback (success):', err);
2342
+ }
2343
+ }
2344
+ return data;
2345
+ }).catch(error => {
2346
+ if (signal.aborted) {
2347
+ return undefined;
2348
+ }
2349
+ this.state = {
2350
+ data: undefined,
2351
+ error,
2352
+ isLoading: false
2353
+ };
2354
+ this.notify();
2355
+ if (onError) {
2356
+ try {
2357
+ onError(error, variables);
2358
+ } catch (err) {
2359
+ console.error('Error in onError callback:', err);
2360
+ }
2361
+ }
2362
+ if (onSettled) {
2363
+ try {
2364
+ onSettled(error, undefined, variables);
2365
+ } catch (err) {
2366
+ console.error('Error in onSettled callback (error):', err);
2367
+ }
2368
+ }
2369
+ throw error;
2370
+ }).finally(() => {
2371
+ this.promise = null;
2372
+ });
2373
+ return this.promise;
2374
+ }
2375
+ subscribe(sub) {
2376
+ this.subscribers.add(sub);
2377
+ sub(this.state);
2378
+ return () => {
2379
+ this.subscribers.delete(sub);
2380
+ };
2381
+ }
2382
+ cancel() {
2383
+ if (this.controller) {
2384
+ this.controller.abort();
2385
+ }
2386
+ }
2387
+ reset() {
2388
+ this.state = {
2389
+ data: undefined,
2390
+ error: undefined,
2391
+ isLoading: false
2392
+ };
2393
+ this.notify();
2394
+ this.cancel();
2395
+ }
2396
+ }
2397
+ class MutationClient {
2398
+ cache = new Map();
2399
+ fetchMutation(key, mutationFn, options) {
2400
+ const keyHash = hashKey(key);
2401
+ let entry = this.cache.get(keyHash);
2402
+ if (!entry) {
2403
+ entry = new MutationEntry(key, mutationFn, options);
2404
+ this.cache.set(keyHash, entry);
2405
+ }
2406
+ return entry;
2407
+ }
2408
+ }
2409
+ const mutationClient = new MutationClient();
2410
+ ;// ./src/shared/panelRegistry.ts
2411
+ class PanelRegistry {
2412
+ panels = new Map();
2413
+ registerPanel(panelConfig) {
2414
+ if (this.panels.has(panelConfig.componentId)) {
2415
+ throw new Error(`Panel with id ${panelConfig.componentId} is already registered.`);
2416
+ }
2417
+ this.panels.set(panelConfig.componentId, panelConfig);
2418
+ }
2419
+ getPanelConfig(componentId) {
2420
+ const panel = this.panels.get(componentId);
2421
+ if (!panel) {
2422
+ throw new Error(`Panel with id ${componentId} is not registered.`);
2423
+ }
2424
+ return panel;
2425
+ }
2426
+ findPanelConfigsByType(type) {
2427
+ return Array.from(this.panels.values()).filter(panel => panel.supportedTypes.includes(type));
2428
+ }
2429
+ }
2430
+ ;// ./src/components/LoadingPanel/LoadingPanel.tsx
2431
+ function LoadingPanel_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
2432
+
2433
+
2434
+
2435
+ var LoadingPanel_ref = true ? {
2436
+ name: "1kdycl6",
2437
+ styles: "margin-top:12px;text-align:center"
2438
+ } : 0;
2439
+ const LoadingPanel = ({
2440
+ title,
2441
+ children
2442
+ }) => {
2443
+ return (0,jsx_runtime_namespaceObject.jsxs)(core_namespaceObject.WidgetCard, {
2444
+ title: title,
2445
+ contentClassName: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
2446
+ name: "1wgy75t",
2447
+ styles: "align-items:center!important;justify-content:center!important"
2448
+ } : 0),
2449
+ children: [(0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.ProgressCircle, {
2450
+ currentValue: 3,
2451
+ max: 10,
2452
+ size: 64,
2453
+ color: "blue",
2454
+ mode: "infinite"
2455
+ }), children && (0,jsx_runtime_namespaceObject.jsx)("div", {
2456
+ css: LoadingPanel_ref,
2457
+ children: children
2458
+ })]
2459
+ });
2460
+ };
2461
+ ;// ./src/entities/panel/usePanelData.ts
2462
+
2463
+
2464
+
2465
+ const usePanelData = (panel, options = {}) => {
2466
+ const _transport = useTransport(options?.transport);
2467
+ const panelSource = panel.panelDefinition.source;
2468
+ const result = useQuery(['panel-data', panelSource], async signal => {
2469
+ if (panelSource.type === PANEL_DATA_SOURCE.GRAFANA) {
2470
+ const {
2471
+ dashboardUid,
2472
+ panelId
2473
+ } = panelSource;
2474
+ const data = await _transport.getGrafanaPanelData({
2475
+ dashboardUid,
2476
+ panelId
2477
+ }, signal);
2478
+ return {
2479
+ source: PANEL_DATA_SOURCE.GRAFANA,
2480
+ data
2481
+ };
2482
+ }
2483
+ throw new Error(`Unsupported panel data source: ${panelSource}`);
2484
+ }, options);
2485
+ return result;
2486
+ };
2487
+ ;// ./src/entities/panel/withPanelData.tsx
2488
+
2489
+
2490
+
2491
+
2492
+
2493
+ function withPanelData(Wrapped, {
2494
+ LoadingComponent,
2495
+ ErrorComponent
2496
+ } = {}) {
2497
+ const Enhanced = ({
2498
+ panel,
2499
+ title: providedTitle,
2500
+ ...rest
2501
+ }) => {
2502
+ const title = providedTitle ?? panel.title;
2503
+ const query = usePanelData(panel);
2504
+ if (!query.isLoaded) {
2505
+ return LoadingComponent ? (0,jsx_runtime_namespaceObject.jsx)(LoadingComponent, {
2506
+ title: title
2507
+ }) : (0,jsx_runtime_namespaceObject.jsx)(LoadingPanel, {
2508
+ title: title
2509
+ });
2510
+ }
2511
+ if (query.error) {
2512
+ return ErrorComponent ? (0,jsx_runtime_namespaceObject.jsx)(ErrorComponent, {
2513
+ title: title
2514
+ }) : (0,jsx_runtime_namespaceObject.jsx)(ErrorPanel, {
2515
+ title: title
2516
+ });
2517
+ }
2518
+ const injectedProps = {
2519
+ ...rest,
2520
+ panel,
2521
+ title,
2522
+ panelData: query.data
2523
+ };
2524
+ return (0,jsx_runtime_namespaceObject.jsx)(Wrapped, {
2525
+ ...injectedProps
2526
+ });
2527
+ };
2528
+ return Enhanced;
2529
+ }
2530
+ ;// external "@grafana/data"
2531
+ const data_namespaceObject = require("@grafana/data");
2532
+ ;// ./src/panels/TimeseriesPanel/data-adapters/grafana.tsx
2533
+
2534
+ const grafanaDataAdapter = ({
2535
+ panel,
2536
+ data
2537
+ }) => {
2538
+ const {
2539
+ results
2540
+ } = data.data;
2541
+ const xIndex = 0;
2542
+ const yIndex = 1;
2543
+ const frames = Object.values(results).flatMap(result => result.frames);
2544
+ const defaultFieldConfig = panel.panelSchema?.fieldConfig?.defaults;
2545
+ const unit = frames[0]?.schema?.fields?.[yIndex]?.config?.unit ?? defaultFieldConfig?.unit;
2546
+ const formattedValue = (0,data_namespaceObject.getValueFormat)(unit)(0);
2547
+ const series = frames.map(frame => {
2548
+ const values = frame?.data?.values ?? [];
2549
+ const x = values[xIndex] ?? [];
2550
+ const y = values[yIndex] ?? [];
2551
+ const yField = frame.schema?.fields?.[yIndex];
2552
+ const color = defaultFieldConfig?.color?.fixedColor;
2553
+ const name = yField?.config?.displayName ?? yField?.config?.displayNameFromDS ?? yField?.name ?? frame.schema?.refId;
2554
+ return {
2555
+ x: x,
2556
+ y: y,
2557
+ name,
2558
+ marker: {
2559
+ color: color
2560
+ },
2561
+ selected: true,
2562
+ showlegend: true,
2563
+ type: 'scatter',
2564
+ hovertemplate: `${name}: ${formattedValue.prefix ?? ''}%{y:}${formattedValue.suffix ?? ''}<extra></extra>`
2565
+ };
2566
+ });
2567
+ return {
2568
+ series,
2569
+ valuePrefix: formattedValue.prefix,
2570
+ valueSuffix: formattedValue.suffix
2571
+ };
2572
+ };
2573
+ ;// ./src/panels/TimeseriesPanel/TimeseriesPanel.tsx
2574
+
2575
+
2576
+
2577
+
2578
+
2579
+
2580
+ const TimeseriesPanel = ({
2581
+ panel,
2582
+ panelData,
2583
+ title: providedTitle
2584
+ }) => {
2585
+ const {
2586
+ ref,
2587
+ width
2588
+ } = (0,hooks_namespaceObject.useElementSize)();
2589
+ const title = providedTitle ?? panel.title;
2590
+ const {
2591
+ series,
2592
+ valuePrefix,
2593
+ valueSuffix
2594
+ } = matchPanelDataSource(panelData.source, {
2595
+ grafana: () => grafanaDataAdapter({
2596
+ panel,
2597
+ data: panelData.data
2598
+ })
2599
+ });
2600
+ return (0,jsx_runtime_namespaceObject.jsx)("div", {
2601
+ ref: ref,
2602
+ style: {
2603
+ width: '100%',
2604
+ height: '100%'
2605
+ },
2606
+ children: (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.BarLineComplexChart, {
2607
+ width: "100%",
2608
+ height: "100%",
2609
+ features: ['header'],
2610
+ systemModeBarButtons: [],
2611
+ cardProps: {
2612
+ title
2613
+ },
2614
+ layout: {
2615
+ autosize: true,
2616
+ width: width,
2617
+ margin: {
2618
+ r: 50
2619
+ },
2620
+ xaxis: {
2621
+ tickmode: 'auto'
2622
+ },
2623
+ yaxis2: {
2624
+ ticksuffix: valueSuffix,
2625
+ tickprefix: valuePrefix,
2626
+ tickmode: 'auto'
2627
+ }
2628
+ },
2629
+ data: series
2630
+ })
2631
+ });
2632
+ };
2633
+ const panelConfig = {
2634
+ componentId: 'timeseries-default',
2635
+ name: 'Timeseries Panel',
2636
+ Component: withPanelData(TimeseriesPanel),
2637
+ supportedTypes: ['timeseries', 'bargauge'],
2638
+ propsSchema: {
2639
+ type: 'object',
2640
+ properties: {
2641
+ title: {
2642
+ type: 'string',
2643
+ title: 'Panel Title'
2644
+ }
2645
+ }
2646
+ },
2647
+ uiSchema: {
2648
+ title: {
2649
+ 'ui:help': 'Override the default panel title',
2650
+ 'ui:placeholder': 'Panel Title'
2651
+ }
2652
+ }
2653
+ };
2654
+ ;// ./src/panels/GaugePanel/data-adapters/grafana.tsx
2655
+
2656
+ const inferMinMax = (values, unit) => {
2657
+ if (unit === 'percent') {
2658
+ return {
2659
+ min: 0,
2660
+ max: 100
2661
+ };
2662
+ }
2663
+ if (unit === 'percentunit') {
2664
+ return {
2665
+ min: 0,
2666
+ max: 1
2667
+ };
2668
+ }
2669
+ if (!values.length) {
2670
+ return {
2671
+ min: 0,
2672
+ max: 100
2673
+ };
2674
+ }
2675
+ return {
2676
+ min: Math.min(...values),
2677
+ max: Math.max(...values)
2678
+ };
2679
+ };
2680
+ const grafana_grafanaDataAdapter = ({
2681
+ panel,
2682
+ data
2683
+ }) => {
2684
+ const {
2685
+ results
2686
+ } = data.data;
2687
+ const yIndex = 1;
2688
+ const frames = Object.values(results).flatMap(result => result.frames);
2689
+ const defaultFieldConfig = panel.panelSchema?.fieldConfig?.defaults;
2690
+ if (frames.length > 1) {
2691
+ throw new Error(`Expected a single frame for gauge panel, but found ${frames.length} frames.`);
2692
+ }
2693
+ const dataFrame = frames[0];
2694
+ const values = dataFrame?.data?.values?.[yIndex] ?? [];
2695
+ const value = values?.at(-1) ?? 0;
2696
+ const unit = dataFrame?.schema?.fields?.[yIndex]?.config?.unit ?? defaultFieldConfig?.unit;
2697
+ const formattedValue = (0,data_namespaceObject.getValueFormat)(unit)(value);
2698
+ const {
2699
+ min,
2700
+ max
2701
+ } = inferMinMax(values, unit);
2702
+ const thresholds = defaultFieldConfig?.thresholds?.steps?.map(({
2703
+ color,
2704
+ value
2705
+ }) => ({
2706
+ color,
2707
+ value: value ?? 0
2708
+ })) ?? [];
2709
+ const segments = thresholds.map((threshold, index) => ({
2710
+ color: threshold.color,
2711
+ value: thresholds[index + 1]?.value ?? 100 // use next threshold value or default to 100
2712
+ }));
2713
+ return {
2714
+ min,
2715
+ max,
2716
+ thresholds,
2717
+ segments,
2718
+ value,
2719
+ valueSuffix: formattedValue.suffix,
2720
+ valuePrefix: formattedValue.prefix
2721
+ };
2722
+ };
2723
+ ;// ./src/panels/GaugePanel/GaugePanel.tsx
2724
+ function GaugePanel_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
2725
+
2726
+
2727
+
2728
+
2729
+
2730
+
2731
+ const GaugePanel = ({
2732
+ panel,
2733
+ panelData,
2734
+ title: providedTitle
2735
+ }) => {
2736
+ const title = providedTitle ?? panel.title;
2737
+ const {
2738
+ min,
2739
+ max,
2740
+ value,
2741
+ valuePrefix,
2742
+ valueSuffix,
2743
+ segments
2744
+ } = matchPanelDataSource(panelData.source, {
2745
+ grafana: () => grafana_grafanaDataAdapter({
2746
+ panel,
2747
+ data: panelData.data
2748
+ })
2749
+ });
2750
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.GaugeChart, {
2751
+ features: ['header'],
2752
+ containerProps: {
2753
+ className: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
2754
+ name: "w1atjl",
2755
+ styles: "width:100%;height:100%"
2756
+ } : 0)
2757
+ },
2758
+ title: title,
2759
+ unitLabel: valueSuffix,
2760
+ maxValue: max,
2761
+ minValue: min,
2762
+ minLabel: `${valuePrefix ?? ''}${min}${valueSuffix ?? ''}`,
2763
+ maxLabel: `${valuePrefix ?? ''}${max}${valueSuffix ?? ''}`,
2764
+ value: value,
2765
+ segments: segments
2766
+ });
2767
+ };
2768
+ const GaugePanel_panelConfig = {
2769
+ componentId: 'gauge-default',
2770
+ name: 'Gauge Panel',
2771
+ Component: withPanelData(GaugePanel),
2772
+ supportedTypes: ['gauge'],
2773
+ propsSchema: {
2774
+ type: 'object',
2775
+ properties: {
2776
+ title: {
2777
+ type: 'string',
2778
+ title: 'Panel Title'
2779
+ }
2780
+ }
2781
+ },
2782
+ uiSchema: {
2783
+ title: {
2784
+ 'ui:help': 'Override the default panel title',
2785
+ 'ui:placeholder': 'Panel Title'
2786
+ }
2787
+ }
2788
+ };
2789
+ ;// ./src/panels/BarGaugePanel/data-adapters/grafana.tsx
2790
+
2791
+ function grafana_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
2792
+
2793
+
2794
+ var grafana_ref = true ? {
2795
+ name: "mmdt3g",
2796
+ styles: "font-size:14px"
2797
+ } : 0;
2798
+ var grafana_ref2 = true ? {
2799
+ name: "mmdt3g",
2800
+ styles: "font-size:14px"
2801
+ } : 0;
2802
+ const data_adapters_grafana_grafanaDataAdapter = ({
2803
+ panel,
2804
+ data,
2805
+ labelWidth
2806
+ }) => {
2807
+ const panelData = data.data;
2808
+ const yIndex = 1;
2809
+ const defaultFieldConfig = panel.panelSchema?.fieldConfig?.defaults;
2810
+ const thresholds = defaultFieldConfig?.thresholds?.steps?.map(({
2811
+ color,
2812
+ value
2813
+ }) => ({
2814
+ color,
2815
+ value: value ?? 0
2816
+ })) ?? [];
2817
+ const frames = Object.values(panelData.results).flatMap(result => result.frames);
2818
+ const unit = frames[0]?.schema?.fields?.[yIndex]?.config?.unit ?? defaultFieldConfig?.unit;
2819
+ const valueFormat = (0,data_namespaceObject.getValueFormat)(unit);
2820
+ const valueFormatter = (v, color) => {
2821
+ const formattedValue = valueFormat(v);
2822
+ return (0,jsx_runtime_namespaceObject.jsxs)("div", {
2823
+ css: /*#__PURE__*/(0,react_namespaceObject.css)({
2824
+ color,
2825
+ textAlign: 'right'
2826
+ }, true ? "" : 0, true ? "" : 0),
2827
+ style: {
2828
+ width: `${labelWidth}px`
2829
+ },
2830
+ children: [formattedValue.prefix && (0,jsx_runtime_namespaceObject.jsx)("span", {
2831
+ css: grafana_ref,
2832
+ children: formattedValue.prefix
2833
+ }), formattedValue.text, ' ', formattedValue.suffix && (0,jsx_runtime_namespaceObject.jsx)("span", {
2834
+ css: grafana_ref2,
2835
+ children: formattedValue.suffix
2836
+ })]
2837
+ });
2838
+ };
2839
+ const bars = frames.map(frame => {
2840
+ const y = frame.data?.values?.[yIndex] ?? [];
2841
+ const value = y.at(-1) ?? 0;
2842
+ const yField = frame.schema?.fields?.[yIndex];
2843
+ return {
2844
+ title: yField?.config?.displayName ?? yField?.config?.displayNameFromDS ?? yField?.name ?? frame.schema?.refId,
2845
+ value: Number(value.toFixed(2)),
2846
+ valueFormatter,
2847
+ thresholds
2848
+ };
2849
+ }).filter(bar => bar.value !== undefined);
2850
+ return {
2851
+ bars
2852
+ };
2853
+ };
2854
+ ;// ./src/panels/BarGaugePanel/BarGaugePanel.tsx
2855
+ function BarGaugePanel_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
2856
+
2857
+
2858
+
2859
+
2860
+
2861
+
2862
+ const GrafanaBarGaugePanel = ({
2863
+ panel,
2864
+ panelData,
2865
+ title: providedTitle,
2866
+ labelWidth = 80
2867
+ }) => {
2868
+ const title = providedTitle ?? panel.title;
2869
+ const {
2870
+ bars
2871
+ } = matchPanelDataSource(panelData.source, {
2872
+ grafana: () => data_adapters_grafana_grafanaDataAdapter({
2873
+ panel,
2874
+ data: panelData.data,
2875
+ labelWidth
2876
+ })
2877
+ });
2878
+ return (0,jsx_runtime_namespaceObject.jsx)(core_namespaceObject.BarGaugeChart, {
2879
+ features: ['header'],
2880
+ title: title,
2881
+ bars: bars,
2882
+ widgetCardProps: {
2883
+ contentClassName: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
2884
+ name: "1qmr6ab",
2885
+ styles: "overflow:auto"
2886
+ } : 0)
2887
+ },
2888
+ wrapperProps: {
2889
+ className: /*#__PURE__*/(0,css_namespaceObject.css)( true ? {
2890
+ name: "9d39k0",
2891
+ styles: "gap:2px !important"
2892
+ } : 0)
2893
+ }
2894
+ });
2895
+ };
2896
+ const BarGaugePanel_panelConfig = {
2897
+ componentId: 'bargauge-default',
2898
+ name: 'Bar Gauge Panel',
2899
+ Component: withPanelData(GrafanaBarGaugePanel),
2900
+ supportedTypes: ['bargauge', 'gauge'],
2901
+ propsSchema: {
2902
+ type: 'object',
2903
+ properties: {
2904
+ title: {
2905
+ type: 'string',
2906
+ title: 'Panel Title'
2907
+ },
2908
+ labelWidth: {
2909
+ type: 'number',
2910
+ title: 'Label Width',
2911
+ default: 80,
2912
+ description: 'Width of the label in pixels'
2913
+ }
2914
+ }
2915
+ },
2916
+ uiSchema: {
2917
+ title: {
2918
+ 'ui:help': 'Override the default panel title',
2919
+ 'ui:placeholder': 'Panel Title'
2920
+ },
2921
+ labelWidth: {
2922
+ 'ui:help': 'Set the width of the label in pixels',
2923
+ 'ui:placeholder': 'Label Width'
2924
+ }
2925
+ }
2926
+ };
2927
+ ;// ./src/panels/index.ts
2928
+
2929
+
2930
+
2931
+
2932
+ const panelRegistry = new PanelRegistry();
2933
+ panelRegistry.registerPanel(panelConfig);
2934
+ panelRegistry.registerPanel(GaugePanel_panelConfig);
2935
+ panelRegistry.registerPanel(BarGaugePanel_panelConfig);
2936
+
2937
+ ;// ./src/provider.tsx
2938
+
2939
+
2940
+
2941
+
2942
+ const InfraDashProvider = ({
2943
+ children,
2944
+ transport,
2945
+ queryClient: providedQueryClient,
2946
+ mutationClient: providedMutationClient,
2947
+ panelRegistry: providedPanelRegistry
2948
+ }) => {
2949
+ return (0,jsx_runtime_namespaceObject.jsx)(InfraDashInternalProvider, {
2950
+ value: {
2951
+ transport,
2952
+ queryClient: providedQueryClient ?? queryClient,
2953
+ mutationClient: providedMutationClient ?? mutationClient,
2954
+ panelRegistry: providedPanelRegistry ?? panelRegistry
2955
+ },
2956
+ children: children
2957
+ });
2958
+ };
2959
+ ;// ./src/index.ts
2960
+
2961
+
2962
+
2963
+
2964
+
2965
+
2966
+
2967
+ /******/ return __webpack_exports__;
2968
+ /******/ })()
2969
+ ;
2970
+ });
2971
+ //# sourceMappingURL=index.js.map