@devtable/dashboard 1.26.0 → 1.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contexts/dashboard-action-context.d.ts +7 -0
- package/dist/contexts/panel-context.d.ts +1 -0
- package/dist/dashboard.es.js +443 -68
- package/dist/dashboard.umd.js +9 -9
- package/dist/layout/index.d.ts +1 -2
- package/dist/main/actions.d.ts +2 -2
- package/dist/panel/index.d.ts +0 -1
- package/dist/panel/viz/cartesian/type.d.ts +8 -0
- package/dist/panel/viz/stats/panel/index.d.ts +10 -0
- package/dist/panel/viz/stats/panel/variables.d.ts +10 -0
- package/dist/panel/viz/stats/types.d.ts +3 -22
- package/dist/panel/viz/stats/update/index.d.ts +15 -0
- package/dist/utils/template/types.d.ts +21 -0
- package/package.json +3 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -33,15 +33,15 @@ var __publicField = (obj, key, value) => {
|
|
|
33
33
|
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
34
|
return value;
|
|
35
35
|
};
|
|
36
|
-
import React from "react";
|
|
36
|
+
import React, { createContext, useContext, useReducer } from "react";
|
|
37
37
|
import _ from "lodash";
|
|
38
38
|
import RGL, { WidthProvider } from "react-grid-layout";
|
|
39
|
-
import {
|
|
39
|
+
import { Box, Group, Button, Modal, Popover, Tooltip, Text, ActionIcon, TextInput, LoadingOverlay, Table, Select, useMantineTheme, ColorSwatch, Switch, Slider, SegmentedControl, NumberInput, ColorInput, Divider, Accordion, JsonInput, AppShell, Tabs, Menu, Container, Textarea } from "@mantine/core";
|
|
40
40
|
import { useRequest } from "ahooks";
|
|
41
41
|
import axios from "axios";
|
|
42
|
-
import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Resize, Paint, PlayerPlay, Database, Recycle, Share } from "tabler-icons-react";
|
|
42
|
+
import { InfoCircle, DeviceFloppy, Refresh, Trash, PlaylistAdd, Settings, Copy, Resize, Paint, PlayerPlay, Database, Recycle, Share } from "tabler-icons-react";
|
|
43
43
|
import RichTextEditor, { RichTextEditor as RichTextEditor$1 } from "@mantine/rte";
|
|
44
|
-
import { useInputState, useElementSize
|
|
44
|
+
import { randomId, useInputState, useElementSize } from "@mantine/hooks";
|
|
45
45
|
import ReactEChartsCore from "echarts-for-react/lib/core";
|
|
46
46
|
import * as echarts from "echarts/core";
|
|
47
47
|
import { SunburstChart, BarChart, LineChart, ScatterChart, PieChart } from "echarts/charts";
|
|
@@ -58,7 +58,7 @@ var DashboardMode = /* @__PURE__ */ ((DashboardMode2) => {
|
|
|
58
58
|
DashboardMode2["Edit"] = "edit";
|
|
59
59
|
return DashboardMode2;
|
|
60
60
|
})(DashboardMode || {});
|
|
61
|
-
const initialContext$
|
|
61
|
+
const initialContext$4 = {
|
|
62
62
|
layoutFrozen: false,
|
|
63
63
|
freezeLayout: () => {
|
|
64
64
|
},
|
|
@@ -67,7 +67,7 @@ const initialContext$3 = {
|
|
|
67
67
|
inLayoutMode: false,
|
|
68
68
|
inUseMode: true
|
|
69
69
|
};
|
|
70
|
-
const LayoutStateContext = React.createContext(initialContext$
|
|
70
|
+
const LayoutStateContext = React.createContext(initialContext$4);
|
|
71
71
|
function explainSQLSnippet(snippet, context) {
|
|
72
72
|
const names = Object.keys(context);
|
|
73
73
|
const vals = Object.values(context);
|
|
@@ -162,10 +162,11 @@ async function getQuerySources() {
|
|
|
162
162
|
return {};
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
const initialContext$
|
|
166
|
-
const initialContextInfoContext = initialContext$
|
|
167
|
-
const ContextInfoContext = React.createContext(initialContext$
|
|
168
|
-
const initialContext$
|
|
165
|
+
const initialContext$3 = {};
|
|
166
|
+
const initialContextInfoContext = initialContext$3;
|
|
167
|
+
const ContextInfoContext = React.createContext(initialContext$3);
|
|
168
|
+
const initialContext$2 = {
|
|
169
|
+
id: "",
|
|
169
170
|
data: [],
|
|
170
171
|
loading: false,
|
|
171
172
|
title: "",
|
|
@@ -186,16 +187,96 @@ const initialContext$1 = {
|
|
|
186
187
|
refreshData: () => {
|
|
187
188
|
}
|
|
188
189
|
};
|
|
189
|
-
const PanelContext = React.createContext(initialContext$
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
190
|
+
const PanelContext = React.createContext(initialContext$2);
|
|
191
|
+
const ModalsContext = createContext(null);
|
|
192
|
+
ModalsContext.displayName = "@mantine/modals/ModalsContext";
|
|
193
|
+
function useModals() {
|
|
194
|
+
const ctx = useContext(ModalsContext);
|
|
195
|
+
if (!ctx) {
|
|
196
|
+
throw new Error("[@mantine/modals] useModals hook was called outside of context, wrap your app with ModalsProvider component");
|
|
196
197
|
}
|
|
198
|
+
return ctx;
|
|
199
|
+
}
|
|
200
|
+
var __defProp$1 = Object.defineProperty;
|
|
201
|
+
var __defProps$1 = Object.defineProperties;
|
|
202
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
203
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
204
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
205
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
206
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
207
|
+
var __spreadValues$1 = (a, b) => {
|
|
208
|
+
for (var prop in b || (b = {}))
|
|
209
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
210
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
211
|
+
if (__getOwnPropSymbols$1)
|
|
212
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
213
|
+
if (__propIsEnum$1.call(b, prop))
|
|
214
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
215
|
+
}
|
|
216
|
+
return a;
|
|
197
217
|
};
|
|
198
|
-
|
|
218
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
219
|
+
function ConfirmModal({
|
|
220
|
+
id,
|
|
221
|
+
cancelProps,
|
|
222
|
+
confirmProps,
|
|
223
|
+
labels = { cancel: "", confirm: "" },
|
|
224
|
+
closeOnConfirm = true,
|
|
225
|
+
closeOnCancel = true,
|
|
226
|
+
groupProps,
|
|
227
|
+
onCancel,
|
|
228
|
+
onConfirm,
|
|
229
|
+
children
|
|
230
|
+
}) {
|
|
231
|
+
const { cancel: cancelLabel, confirm: confirmLabel } = labels;
|
|
232
|
+
const ctx = useModals();
|
|
233
|
+
const handleCancel = (event) => {
|
|
234
|
+
typeof (cancelProps == null ? void 0 : cancelProps.onClick) === "function" && (cancelProps == null ? void 0 : cancelProps.onClick(event));
|
|
235
|
+
typeof onCancel === "function" && onCancel();
|
|
236
|
+
closeOnCancel && ctx.closeModal(id);
|
|
237
|
+
};
|
|
238
|
+
const handleConfirm = (event) => {
|
|
239
|
+
typeof (confirmProps == null ? void 0 : confirmProps.onClick) === "function" && (confirmProps == null ? void 0 : confirmProps.onClick(event));
|
|
240
|
+
typeof onConfirm === "function" && onConfirm();
|
|
241
|
+
closeOnConfirm && ctx.closeModal(id);
|
|
242
|
+
};
|
|
243
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, children && /* @__PURE__ */ React.createElement(Box, {
|
|
244
|
+
mb: "md"
|
|
245
|
+
}, children), /* @__PURE__ */ React.createElement(Group, __spreadValues$1({
|
|
246
|
+
position: "right"
|
|
247
|
+
}, groupProps), /* @__PURE__ */ React.createElement(Button, __spreadProps$1(__spreadValues$1({
|
|
248
|
+
variant: "default"
|
|
249
|
+
}, cancelProps), {
|
|
250
|
+
onClick: handleCancel
|
|
251
|
+
}), (cancelProps == null ? void 0 : cancelProps.children) || cancelLabel), /* @__PURE__ */ React.createElement(Button, __spreadProps$1(__spreadValues$1({}, confirmProps), {
|
|
252
|
+
onClick: handleConfirm
|
|
253
|
+
}), (confirmProps == null ? void 0 : confirmProps.children) || confirmLabel)));
|
|
254
|
+
}
|
|
255
|
+
function modalsReducer(state, action) {
|
|
256
|
+
switch (action.type) {
|
|
257
|
+
case "OPEN": {
|
|
258
|
+
return {
|
|
259
|
+
current: action.payload,
|
|
260
|
+
modals: [...state.modals, action.payload]
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
case "CLOSE": {
|
|
264
|
+
return {
|
|
265
|
+
current: state.modals[state.modals.length - 2] || null,
|
|
266
|
+
modals: state.modals.filter((m2) => m2.id !== action.payload)
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
case "CLOSE_ALL": {
|
|
270
|
+
return {
|
|
271
|
+
current: state.current,
|
|
272
|
+
modals: []
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
default: {
|
|
276
|
+
return state;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
199
280
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
200
281
|
var jsxRuntime = { exports: {} };
|
|
201
282
|
var reactJsxRuntime_production_min = {};
|
|
@@ -230,6 +311,240 @@ reactJsxRuntime_production_min.jsxs = q;
|
|
|
230
311
|
const jsx = jsxRuntime.exports.jsx;
|
|
231
312
|
const jsxs = jsxRuntime.exports.jsxs;
|
|
232
313
|
const Fragment = jsxRuntime.exports.Fragment;
|
|
314
|
+
var __defProp2 = Object.defineProperty;
|
|
315
|
+
var __defProps2 = Object.defineProperties;
|
|
316
|
+
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
317
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
318
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
319
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
320
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
|
|
321
|
+
enumerable: true,
|
|
322
|
+
configurable: true,
|
|
323
|
+
writable: true,
|
|
324
|
+
value
|
|
325
|
+
}) : obj[key] = value;
|
|
326
|
+
var __spreadValues2 = (a, b) => {
|
|
327
|
+
for (var prop in b || (b = {}))
|
|
328
|
+
if (__hasOwnProp2.call(b, prop))
|
|
329
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
330
|
+
if (__getOwnPropSymbols2)
|
|
331
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
332
|
+
if (__propIsEnum2.call(b, prop))
|
|
333
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
334
|
+
}
|
|
335
|
+
return a;
|
|
336
|
+
};
|
|
337
|
+
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
338
|
+
var __objRest2 = (source, exclude) => {
|
|
339
|
+
var target = {};
|
|
340
|
+
for (var prop in source)
|
|
341
|
+
if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
342
|
+
target[prop] = source[prop];
|
|
343
|
+
if (source != null && __getOwnPropSymbols2)
|
|
344
|
+
for (var prop of __getOwnPropSymbols2(source)) {
|
|
345
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
|
|
346
|
+
target[prop] = source[prop];
|
|
347
|
+
}
|
|
348
|
+
return target;
|
|
349
|
+
};
|
|
350
|
+
function separateConfirmModalProps(props) {
|
|
351
|
+
if (!props) {
|
|
352
|
+
return {
|
|
353
|
+
confirmProps: {},
|
|
354
|
+
modalProps: {}
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
const _a = props, {
|
|
358
|
+
id,
|
|
359
|
+
children,
|
|
360
|
+
onCancel,
|
|
361
|
+
onConfirm,
|
|
362
|
+
closeOnConfirm,
|
|
363
|
+
closeOnCancel,
|
|
364
|
+
cancelProps,
|
|
365
|
+
confirmProps,
|
|
366
|
+
groupProps,
|
|
367
|
+
labels
|
|
368
|
+
} = _a, others = __objRest2(_a, ["id", "children", "onCancel", "onConfirm", "closeOnConfirm", "closeOnCancel", "cancelProps", "confirmProps", "groupProps", "labels"]);
|
|
369
|
+
return {
|
|
370
|
+
confirmProps: {
|
|
371
|
+
id,
|
|
372
|
+
children,
|
|
373
|
+
onCancel,
|
|
374
|
+
onConfirm,
|
|
375
|
+
closeOnConfirm,
|
|
376
|
+
closeOnCancel,
|
|
377
|
+
cancelProps,
|
|
378
|
+
confirmProps,
|
|
379
|
+
groupProps,
|
|
380
|
+
labels
|
|
381
|
+
},
|
|
382
|
+
modalProps: __spreadValues2({
|
|
383
|
+
id
|
|
384
|
+
}, others)
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function ModalsProvider({
|
|
388
|
+
children,
|
|
389
|
+
modalProps,
|
|
390
|
+
labels,
|
|
391
|
+
modals
|
|
392
|
+
}) {
|
|
393
|
+
const [state, dispatch] = useReducer(modalsReducer, {
|
|
394
|
+
modals: [],
|
|
395
|
+
current: null
|
|
396
|
+
});
|
|
397
|
+
const closeAll = (canceled) => {
|
|
398
|
+
state.modals.forEach((modal) => {
|
|
399
|
+
var _a, _b, _c, _d;
|
|
400
|
+
if (modal.type === "confirm" && canceled) {
|
|
401
|
+
(_b = (_a = modal.props) == null ? void 0 : _a.onCancel) == null ? void 0 : _b.call(_a);
|
|
402
|
+
}
|
|
403
|
+
(_d = (_c = modal.props) == null ? void 0 : _c.onClose) == null ? void 0 : _d.call(_c);
|
|
404
|
+
});
|
|
405
|
+
dispatch({
|
|
406
|
+
type: "CLOSE_ALL"
|
|
407
|
+
});
|
|
408
|
+
};
|
|
409
|
+
const openModal = (props) => {
|
|
410
|
+
const id = props.id || randomId();
|
|
411
|
+
dispatch({
|
|
412
|
+
type: "OPEN",
|
|
413
|
+
payload: {
|
|
414
|
+
id,
|
|
415
|
+
type: "content",
|
|
416
|
+
props
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
return id;
|
|
420
|
+
};
|
|
421
|
+
const openConfirmModal = (props) => {
|
|
422
|
+
const id = props.id || randomId();
|
|
423
|
+
dispatch({
|
|
424
|
+
type: "OPEN",
|
|
425
|
+
payload: {
|
|
426
|
+
id,
|
|
427
|
+
type: "confirm",
|
|
428
|
+
props
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
return id;
|
|
432
|
+
};
|
|
433
|
+
const openContextModal = (modal, props) => {
|
|
434
|
+
const id = props.id || randomId();
|
|
435
|
+
dispatch({
|
|
436
|
+
type: "OPEN",
|
|
437
|
+
payload: {
|
|
438
|
+
id,
|
|
439
|
+
type: "context",
|
|
440
|
+
props,
|
|
441
|
+
ctx: modal
|
|
442
|
+
}
|
|
443
|
+
});
|
|
444
|
+
return id;
|
|
445
|
+
};
|
|
446
|
+
const closeModal = (id, canceled) => {
|
|
447
|
+
var _a, _b, _c, _d;
|
|
448
|
+
if (state.modals.length <= 1) {
|
|
449
|
+
closeAll(canceled);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const modal = state.modals.find((item) => item.id === id);
|
|
453
|
+
if ((modal == null ? void 0 : modal.type) === "confirm" && canceled) {
|
|
454
|
+
(_b = (_a = modal.props) == null ? void 0 : _a.onCancel) == null ? void 0 : _b.call(_a);
|
|
455
|
+
}
|
|
456
|
+
(_d = (_c = modal == null ? void 0 : modal.props) == null ? void 0 : _c.onClose) == null ? void 0 : _d.call(_c);
|
|
457
|
+
dispatch({
|
|
458
|
+
type: "CLOSE",
|
|
459
|
+
payload: modal.id
|
|
460
|
+
});
|
|
461
|
+
};
|
|
462
|
+
const ctx = {
|
|
463
|
+
modals: state.modals,
|
|
464
|
+
openModal,
|
|
465
|
+
openConfirmModal,
|
|
466
|
+
openContextModal,
|
|
467
|
+
closeModal,
|
|
468
|
+
closeAll
|
|
469
|
+
};
|
|
470
|
+
const getCurrentModal = () => {
|
|
471
|
+
var _a;
|
|
472
|
+
switch ((_a = state.current) == null ? void 0 : _a.type) {
|
|
473
|
+
case "context": {
|
|
474
|
+
const _b = state.current.props, {
|
|
475
|
+
innerProps
|
|
476
|
+
} = _b, rest = __objRest2(_b, ["innerProps"]);
|
|
477
|
+
const ContextModal = modals[state.current.ctx];
|
|
478
|
+
return {
|
|
479
|
+
modalProps: rest,
|
|
480
|
+
content: /* @__PURE__ */ jsx(ContextModal, {
|
|
481
|
+
innerProps,
|
|
482
|
+
context: ctx,
|
|
483
|
+
id: state.current.id
|
|
484
|
+
})
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
case "confirm": {
|
|
488
|
+
const {
|
|
489
|
+
modalProps: separatedModalProps,
|
|
490
|
+
confirmProps: separatedConfirmProps
|
|
491
|
+
} = separateConfirmModalProps(state.current.props);
|
|
492
|
+
return {
|
|
493
|
+
modalProps: separatedModalProps,
|
|
494
|
+
content: /* @__PURE__ */ jsx(ConfirmModal, __spreadValues({}, __spreadProps2(__spreadValues2({}, separatedConfirmProps), {
|
|
495
|
+
id: state.current.id,
|
|
496
|
+
labels: state.current.props.labels || labels
|
|
497
|
+
})))
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
case "content": {
|
|
501
|
+
const _c = state.current.props, {
|
|
502
|
+
children: currentModalChildren
|
|
503
|
+
} = _c, rest = __objRest2(_c, ["children"]);
|
|
504
|
+
return {
|
|
505
|
+
modalProps: rest,
|
|
506
|
+
content: /* @__PURE__ */ jsx(Fragment, {
|
|
507
|
+
children: currentModalChildren
|
|
508
|
+
})
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
default: {
|
|
512
|
+
return {
|
|
513
|
+
modalProps: {},
|
|
514
|
+
content: null
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
const {
|
|
520
|
+
modalProps: currentModalProps,
|
|
521
|
+
content
|
|
522
|
+
} = getCurrentModal();
|
|
523
|
+
return /* @__PURE__ */ jsxs(ModalsContext.Provider, {
|
|
524
|
+
value: ctx,
|
|
525
|
+
children: [/* @__PURE__ */ jsx(Modal, __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2(__spreadValues2({}, modalProps), currentModalProps), {
|
|
526
|
+
opened: state.modals.length > 0,
|
|
527
|
+
onClose: () => closeModal(state.current.id)
|
|
528
|
+
})), {
|
|
529
|
+
children: content
|
|
530
|
+
})), children]
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
const initialContext$1 = {
|
|
534
|
+
addPanel: _.noop,
|
|
535
|
+
duplidatePanel: _.noop,
|
|
536
|
+
removePanelByID: _.noop
|
|
537
|
+
};
|
|
538
|
+
const DashboardActionContext = React.createContext(initialContext$1);
|
|
539
|
+
const initialContext = {
|
|
540
|
+
sqlSnippets: [],
|
|
541
|
+
setSQLSnippets: () => {
|
|
542
|
+
},
|
|
543
|
+
queries: [],
|
|
544
|
+
setQueries: () => {
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
const DefinitionContext = React.createContext(initialContext);
|
|
233
548
|
function DescriptionPopover({
|
|
234
549
|
position = "bottom",
|
|
235
550
|
trigger = "hover"
|
|
@@ -5744,16 +6059,34 @@ function PanelSettingsModal({
|
|
|
5744
6059
|
}
|
|
5745
6060
|
var titleBar = "";
|
|
5746
6061
|
function PanelTitleBar({}) {
|
|
6062
|
+
const modals = useModals();
|
|
5747
6063
|
const [opened, setOpened] = React.useState(false);
|
|
5748
6064
|
const open = () => setOpened(true);
|
|
5749
6065
|
const close = () => setOpened(false);
|
|
5750
6066
|
const {
|
|
6067
|
+
id,
|
|
5751
6068
|
title,
|
|
5752
6069
|
refreshData
|
|
5753
6070
|
} = React.useContext(PanelContext);
|
|
5754
6071
|
const {
|
|
5755
6072
|
inEditMode
|
|
5756
6073
|
} = React.useContext(LayoutStateContext);
|
|
6074
|
+
const {
|
|
6075
|
+
duplidatePanel,
|
|
6076
|
+
removePanelByID
|
|
6077
|
+
} = React.useContext(DashboardActionContext);
|
|
6078
|
+
const duplicate = React.useCallback(() => {
|
|
6079
|
+
duplidatePanel(id);
|
|
6080
|
+
}, [duplidatePanel, id]);
|
|
6081
|
+
const remove = () => modals.openConfirmModal({
|
|
6082
|
+
title: "Delete this panel?",
|
|
6083
|
+
labels: {
|
|
6084
|
+
confirm: "Confirm",
|
|
6085
|
+
cancel: "Cancel"
|
|
6086
|
+
},
|
|
6087
|
+
onCancel: () => console.log("Cancel"),
|
|
6088
|
+
onConfirm: () => removePanelByID(id)
|
|
6089
|
+
});
|
|
5757
6090
|
return /* @__PURE__ */ jsxs(Box, {
|
|
5758
6091
|
sx: {
|
|
5759
6092
|
position: "relative"
|
|
@@ -5794,8 +6127,14 @@ function PanelTitleBar({}) {
|
|
|
5794
6127
|
}),
|
|
5795
6128
|
children: "Settings"
|
|
5796
6129
|
}), /* @__PURE__ */ jsx(Divider, {}), /* @__PURE__ */ jsx(Menu.Item, {
|
|
6130
|
+
onClick: duplicate,
|
|
6131
|
+
icon: /* @__PURE__ */ jsx(Copy, {
|
|
6132
|
+
size: 14
|
|
6133
|
+
}),
|
|
6134
|
+
children: "Duplicate"
|
|
6135
|
+
}), /* @__PURE__ */ jsx(Menu.Item, {
|
|
5797
6136
|
color: "red",
|
|
5798
|
-
|
|
6137
|
+
onClick: remove,
|
|
5799
6138
|
icon: /* @__PURE__ */ jsx(Trash, {
|
|
5800
6139
|
size: 14
|
|
5801
6140
|
}),
|
|
@@ -5855,6 +6194,7 @@ function Panel({
|
|
|
5855
6194
|
const refreshData = refresh;
|
|
5856
6195
|
return /* @__PURE__ */ jsx(PanelContext.Provider, {
|
|
5857
6196
|
value: {
|
|
6197
|
+
id,
|
|
5858
6198
|
data,
|
|
5859
6199
|
loading,
|
|
5860
6200
|
title,
|
|
@@ -5884,7 +6224,6 @@ function DashboardLayout({
|
|
|
5884
6224
|
setPanels,
|
|
5885
6225
|
className = "layout",
|
|
5886
6226
|
rowHeight = 10,
|
|
5887
|
-
onRemoveItem,
|
|
5888
6227
|
isDraggable,
|
|
5889
6228
|
isResizable
|
|
5890
6229
|
}) {
|
|
@@ -5920,7 +6259,6 @@ function DashboardLayout({
|
|
|
5920
6259
|
children: /* @__PURE__ */ jsx(Panel, __spreadProps(__spreadValues({
|
|
5921
6260
|
id
|
|
5922
6261
|
}, rest), {
|
|
5923
|
-
destroy: () => onRemoveItem(id),
|
|
5924
6262
|
update: (panel) => {
|
|
5925
6263
|
setPanels((prevs) => {
|
|
5926
6264
|
prevs.splice(index2, 1, panel);
|
|
@@ -6664,9 +7002,12 @@ function DashboardActions({
|
|
|
6664
7002
|
mode,
|
|
6665
7003
|
setMode,
|
|
6666
7004
|
hasChanges,
|
|
6667
|
-
|
|
6668
|
-
|
|
7005
|
+
saveChanges,
|
|
7006
|
+
revertChanges
|
|
6669
7007
|
}) {
|
|
7008
|
+
const {
|
|
7009
|
+
addPanel
|
|
7010
|
+
} = React.useContext(DashboardActionContext);
|
|
6670
7011
|
const {
|
|
6671
7012
|
inLayoutMode,
|
|
6672
7013
|
inEditMode,
|
|
@@ -6716,6 +7057,7 @@ function DashboardActions({
|
|
|
6716
7057
|
color: "red",
|
|
6717
7058
|
size: "sm",
|
|
6718
7059
|
disabled: !hasChanges,
|
|
7060
|
+
onClick: revertChanges,
|
|
6719
7061
|
leftIcon: /* @__PURE__ */ jsx(Recycle, {
|
|
6720
7062
|
size: 20
|
|
6721
7063
|
}),
|
|
@@ -6771,6 +7113,11 @@ function Dashboard({
|
|
|
6771
7113
|
});
|
|
6772
7114
|
await update(d);
|
|
6773
7115
|
};
|
|
7116
|
+
const revertDashboardChanges = () => {
|
|
7117
|
+
setPanels(dashboard.panels);
|
|
7118
|
+
setSQLSnippets(dashboard.definition.sqlSnippets);
|
|
7119
|
+
setQueries(dashboard.definition.queries);
|
|
7120
|
+
};
|
|
6774
7121
|
const addPanel = () => {
|
|
6775
7122
|
const id = randomId();
|
|
6776
7123
|
const newItem = {
|
|
@@ -6791,6 +7138,24 @@ function Dashboard({
|
|
|
6791
7138
|
};
|
|
6792
7139
|
setPanels((prevs) => [...prevs, newItem]);
|
|
6793
7140
|
};
|
|
7141
|
+
const duplidatePanel = (id) => {
|
|
7142
|
+
try {
|
|
7143
|
+
const panel = panels.find((p2) => p2.id === id);
|
|
7144
|
+
if (!panel) {
|
|
7145
|
+
throw new Error(`[duplicate panel] Can't find a panel by id[${id}]`);
|
|
7146
|
+
}
|
|
7147
|
+
const newPanel = __spreadProps(__spreadValues({}, panel), {
|
|
7148
|
+
id: randomId(),
|
|
7149
|
+
layout: __spreadProps(__spreadValues({}, panel.layout), {
|
|
7150
|
+
x: 0,
|
|
7151
|
+
y: Infinity
|
|
7152
|
+
})
|
|
7153
|
+
});
|
|
7154
|
+
setPanels((prevs) => [...prevs, newPanel]);
|
|
7155
|
+
} catch (error) {
|
|
7156
|
+
console.error(error);
|
|
7157
|
+
}
|
|
7158
|
+
};
|
|
6794
7159
|
const removePanelByID = (id) => {
|
|
6795
7160
|
const index2 = panels.findIndex((p2) => p2.id === id);
|
|
6796
7161
|
setPanels((prevs) => {
|
|
@@ -6807,34 +7172,42 @@ function Dashboard({
|
|
|
6807
7172
|
queries,
|
|
6808
7173
|
setQueries
|
|
6809
7174
|
}), [sqlSnippets, setSQLSnippets, queries, setQueries]);
|
|
6810
|
-
return /* @__PURE__ */ jsx(
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
7175
|
+
return /* @__PURE__ */ jsx(ModalsProvider, {
|
|
7176
|
+
children: /* @__PURE__ */ jsx(ContextInfoContext.Provider, {
|
|
7177
|
+
value: context,
|
|
7178
|
+
children: /* @__PURE__ */ jsx(DashboardActionContext.Provider, {
|
|
7179
|
+
value: {
|
|
7180
|
+
addPanel,
|
|
7181
|
+
duplidatePanel,
|
|
7182
|
+
removePanelByID
|
|
7183
|
+
},
|
|
7184
|
+
children: /* @__PURE__ */ jsx(DefinitionContext.Provider, {
|
|
7185
|
+
value: definitions,
|
|
7186
|
+
children: /* @__PURE__ */ jsx(LayoutStateContext.Provider, {
|
|
7187
|
+
value: {
|
|
7188
|
+
layoutFrozen,
|
|
7189
|
+
freezeLayout,
|
|
7190
|
+
mode,
|
|
7191
|
+
inEditMode,
|
|
7192
|
+
inLayoutMode,
|
|
7193
|
+
inUseMode
|
|
7194
|
+
},
|
|
7195
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
7196
|
+
className,
|
|
7197
|
+
children: [/* @__PURE__ */ jsx(DashboardActions, {
|
|
7198
|
+
mode,
|
|
7199
|
+
setMode,
|
|
7200
|
+
hasChanges,
|
|
7201
|
+
saveChanges: saveDashboardChanges,
|
|
7202
|
+
revertChanges: revertDashboardChanges
|
|
7203
|
+
}), /* @__PURE__ */ jsx(DashboardLayout, {
|
|
7204
|
+
panels,
|
|
7205
|
+
setPanels,
|
|
7206
|
+
isDraggable: inLayoutMode,
|
|
7207
|
+
isResizable: inLayoutMode
|
|
7208
|
+
})]
|
|
7209
|
+
})
|
|
7210
|
+
})
|
|
6838
7211
|
})
|
|
6839
7212
|
})
|
|
6840
7213
|
})
|
|
@@ -6881,24 +7254,26 @@ function ReadOnlyDashboard({
|
|
|
6881
7254
|
setQueries: () => {
|
|
6882
7255
|
}
|
|
6883
7256
|
}), [dashboard]);
|
|
6884
|
-
return /* @__PURE__ */ jsx(
|
|
6885
|
-
|
|
6886
|
-
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
7257
|
+
return /* @__PURE__ */ jsx(ModalsProvider, {
|
|
7258
|
+
children: /* @__PURE__ */ jsx(ContextInfoContext.Provider, {
|
|
7259
|
+
value: context,
|
|
7260
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
7261
|
+
className,
|
|
7262
|
+
children: /* @__PURE__ */ jsx(DefinitionContext.Provider, {
|
|
7263
|
+
value: definition,
|
|
7264
|
+
children: /* @__PURE__ */ jsx(LayoutStateContext.Provider, {
|
|
7265
|
+
value: {
|
|
7266
|
+
layoutFrozen: true,
|
|
7267
|
+
freezeLayout: () => {
|
|
7268
|
+
},
|
|
7269
|
+
mode: DashboardMode.Use,
|
|
7270
|
+
inEditMode: false,
|
|
7271
|
+
inLayoutMode: false,
|
|
7272
|
+
inUseMode: true
|
|
6894
7273
|
},
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
inUseMode: true
|
|
6899
|
-
},
|
|
6900
|
-
children: /* @__PURE__ */ jsx(ReadOnlyDashboardLayout, {
|
|
6901
|
-
panels: dashboard.panels
|
|
7274
|
+
children: /* @__PURE__ */ jsx(ReadOnlyDashboardLayout, {
|
|
7275
|
+
panels: dashboard.panels
|
|
7276
|
+
})
|
|
6902
7277
|
})
|
|
6903
7278
|
})
|
|
6904
7279
|
})
|