@quillsql/admin 1.5.2 → 1.6.1
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/cjs/Admin.d.ts +19 -72
- package/dist/cjs/Admin.d.ts.map +1 -1
- package/dist/cjs/Admin.js +215 -996
- package/dist/cjs/AdminProvider.d.ts +2 -12
- package/dist/cjs/AdminProvider.d.ts.map +1 -1
- package/dist/cjs/AdminProvider.js +27 -32
- package/dist/cjs/api/ConnectionClient.d.ts +19 -0
- package/dist/cjs/api/ConnectionClient.d.ts.map +1 -1
- package/dist/cjs/api/ConnectionClient.js +108 -13
- package/dist/cjs/components/DashboardSelectPopover.d.ts.map +1 -1
- package/dist/cjs/components/DashboardSelectPopover.js +20 -3
- package/dist/cjs/components/DropDownMenu.js +1 -1
- package/dist/cjs/components/DropDownMenuWithLabel.d.ts.map +1 -1
- package/dist/cjs/components/DropDownMenuWithLabel.js +18 -87
- package/dist/cjs/components/EmptyDashboardComponent/index.d.ts.map +1 -1
- package/dist/cjs/components/EmptyDashboardComponent/index.js +11 -9
- package/dist/cjs/components/OrgSelect.d.ts.map +1 -1
- package/dist/cjs/components/OrgSelect.js +10 -20
- package/dist/cjs/components/QuillSelect.d.ts +3 -0
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -0
- package/dist/cjs/components/QuillSelect.js +137 -0
- package/dist/cjs/components/SegmentedControl.d.ts +9 -0
- package/dist/cjs/components/SegmentedControl.d.ts.map +1 -0
- package/dist/cjs/components/SegmentedControl.js +60 -0
- package/dist/cjs/components/SqlTextEditor.d.ts +9 -1
- package/dist/cjs/components/SqlTextEditor.d.ts.map +1 -1
- package/dist/cjs/components/SqlTextEditor.js +60 -12
- package/dist/cjs/components/UiComponents.d.ts +18 -30
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +48 -84
- package/dist/cjs/constants/dataTypes.d.ts +2 -0
- package/dist/cjs/constants/dataTypes.d.ts.map +1 -0
- package/dist/cjs/constants/dataTypes.js +21 -0
- package/dist/cjs/forms/client_onboard/ConnectDatabase.d.ts.map +1 -1
- package/dist/cjs/forms/client_onboard/ConnectDatabase.js +9 -17
- package/dist/cjs/forms/client_onboard/ConnectSchema.d.ts +2 -1
- package/dist/cjs/forms/client_onboard/ConnectSchema.d.ts.map +1 -1
- package/dist/cjs/forms/client_onboard/ConnectSchema.js +143 -68
- package/dist/cjs/forms/client_onboard/CreateSqlViews.d.ts.map +1 -1
- package/dist/cjs/forms/client_onboard/CreateSqlViews.js +57 -15
- package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts +11 -5
- package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
- package/dist/cjs/forms/sql_views/CreateEditSqlView.js +107 -53
- package/dist/cjs/hooks/useOnClickOutside.d.ts +3 -0
- package/dist/cjs/hooks/useOnClickOutside.d.ts.map +1 -0
- package/dist/cjs/hooks/useOnClickOutside.js +20 -0
- package/dist/cjs/modals/EditFiltersModal.d.ts +17 -0
- package/dist/cjs/modals/EditFiltersModal.d.ts.map +1 -0
- package/dist/cjs/modals/EditFiltersModal.js +355 -0
- package/dist/cjs/modals/NewDashboardModal.d.ts +1 -3
- package/dist/cjs/modals/NewDashboardModal.d.ts.map +1 -1
- package/dist/cjs/modals/NewDashboardModal.js +64 -47
- package/dist/cjs/modals/PromoteDashModal.d.ts.map +1 -1
- package/dist/cjs/modals/PromoteDashModal.js +11 -4
- package/dist/cjs/modals/PromoteViewModal.d.ts +2 -1
- package/dist/cjs/modals/PromoteViewModal.d.ts.map +1 -1
- package/dist/cjs/modals/PromoteViewModal.js +46 -36
- package/dist/cjs/modals/ReorderDashboardModal.d.ts.map +1 -1
- package/dist/cjs/modals/ReorderDashboardModal.js +42 -45
- package/dist/cjs/modals/index.d.ts +0 -1
- package/dist/cjs/modals/index.d.ts.map +1 -1
- package/dist/cjs/modals/index.js +1 -3
- package/dist/cjs/primitives/ButtonPrimitive.d.ts +3 -1
- package/dist/cjs/primitives/ButtonPrimitive.d.ts.map +1 -1
- package/dist/cjs/primitives/ButtonPrimitive.js +5 -3
- package/dist/cjs/primitives/TextInputPrimitive.d.ts +1 -0
- package/dist/cjs/primitives/TextInputPrimitive.d.ts.map +1 -1
- package/dist/cjs/primitives/TextInputPrimitive.js +35 -20
- package/dist/cjs/primitives/TogglePrimitive.js +5 -5
- package/dist/cjs/public_components/CreateEnvironment.d.ts +2 -1
- package/dist/cjs/public_components/CreateEnvironment.d.ts.map +1 -1
- package/dist/cjs/public_components/CreateEnvironment.js +5 -2
- package/dist/cjs/public_components/DashboardBuilder.d.ts.map +1 -1
- package/dist/cjs/public_components/DashboardBuilder.js +71 -125
- package/dist/cjs/public_components/DashboardManager.d.ts.map +1 -1
- package/dist/cjs/public_components/DashboardManager.js +109 -146
- package/dist/cjs/public_components/SQLViewManager.d.ts +1 -0
- package/dist/cjs/public_components/SQLViewManager.d.ts.map +1 -1
- package/dist/cjs/public_components/SQLViewManager.js +271 -46
- package/dist/cjs/utils/astProcessing.d.ts +2 -0
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/astProcessing.js +41 -0
- package/dist/cjs/utils/astProcessing.uspec.d.ts +2 -0
- package/dist/cjs/utils/astProcessing.uspec.d.ts.map +1 -0
- package/dist/cjs/utils/astProcessing.uspec.js +26 -0
- package/dist/cjs/utils/columnProcessing.d.ts +3 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/columnProcessing.js +42 -0
- package/dist/cjs/utils/dataEditor.d.ts +2 -2
- package/dist/cjs/utils/dataEditor.d.ts.map +1 -1
- package/dist/cjs/utils/dataEditor.js +4 -2
- package/dist/cjs/utils/databases.d.ts +0 -1
- package/dist/cjs/utils/databases.d.ts.map +1 -1
- package/dist/cjs/utils/databases.js +5 -6
- package/dist/cjs/utils/monacoAutocomplete.d.ts +21 -0
- package/dist/cjs/utils/monacoAutocomplete.d.ts.map +1 -0
- package/dist/cjs/utils/monacoAutocomplete.js +250 -0
- package/dist/cjs/utils/schema.d.ts +11 -0
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +129 -0
- package/dist/cjs/utils/table.d.ts +1 -0
- package/dist/cjs/utils/table.d.ts.map +1 -1
- package/dist/cjs/utils/table.js +13 -0
- package/dist/cjs/utils/textProcessing.d.ts +2 -0
- package/dist/cjs/utils/textProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/textProcessing.js +9 -0
- package/dist/esm/Admin.d.ts +19 -72
- package/dist/esm/Admin.d.ts.map +1 -1
- package/dist/esm/Admin.js +218 -989
- package/dist/esm/AdminProvider.d.ts +2 -12
- package/dist/esm/AdminProvider.d.ts.map +1 -1
- package/dist/esm/AdminProvider.js +27 -32
- package/dist/esm/api/ConnectionClient.d.ts +19 -0
- package/dist/esm/api/ConnectionClient.d.ts.map +1 -1
- package/dist/esm/api/ConnectionClient.js +106 -12
- package/dist/esm/components/DashboardSelectPopover.d.ts.map +1 -1
- package/dist/esm/components/DashboardSelectPopover.js +20 -3
- package/dist/esm/components/DropDownMenu.js +1 -1
- package/dist/esm/components/DropDownMenuWithLabel.d.ts.map +1 -1
- package/dist/esm/components/DropDownMenuWithLabel.js +18 -87
- package/dist/esm/components/EmptyDashboardComponent/index.d.ts.map +1 -1
- package/dist/esm/components/EmptyDashboardComponent/index.js +11 -9
- package/dist/esm/components/OrgSelect.d.ts.map +1 -1
- package/dist/esm/components/OrgSelect.js +6 -19
- package/dist/esm/components/QuillSelect.d.ts +3 -0
- package/dist/esm/components/QuillSelect.d.ts.map +1 -0
- package/dist/esm/components/QuillSelect.js +130 -0
- package/dist/esm/components/SegmentedControl.d.ts +9 -0
- package/dist/esm/components/SegmentedControl.d.ts.map +1 -0
- package/dist/esm/components/SegmentedControl.js +56 -0
- package/dist/esm/components/SqlTextEditor.d.ts +9 -1
- package/dist/esm/components/SqlTextEditor.d.ts.map +1 -1
- package/dist/esm/components/SqlTextEditor.js +59 -11
- package/dist/esm/components/UiComponents.d.ts +18 -30
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +45 -83
- package/dist/esm/constants/dataTypes.d.ts +2 -0
- package/dist/esm/constants/dataTypes.d.ts.map +1 -0
- package/dist/esm/constants/dataTypes.js +18 -0
- package/dist/esm/forms/client_onboard/ConnectDatabase.d.ts.map +1 -1
- package/dist/esm/forms/client_onboard/ConnectDatabase.js +9 -17
- package/dist/esm/forms/client_onboard/ConnectSchema.d.ts +2 -1
- package/dist/esm/forms/client_onboard/ConnectSchema.d.ts.map +1 -1
- package/dist/esm/forms/client_onboard/ConnectSchema.js +145 -70
- package/dist/esm/forms/client_onboard/CreateSqlViews.d.ts.map +1 -1
- package/dist/esm/forms/client_onboard/CreateSqlViews.js +58 -16
- package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts +11 -5
- package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
- package/dist/esm/forms/sql_views/CreateEditSqlView.js +108 -54
- package/dist/esm/hooks/useOnClickOutside.d.ts +3 -0
- package/dist/esm/hooks/useOnClickOutside.d.ts.map +1 -0
- package/dist/esm/hooks/useOnClickOutside.js +18 -0
- package/dist/esm/modals/EditFiltersModal.d.ts +17 -0
- package/dist/esm/modals/EditFiltersModal.d.ts.map +1 -0
- package/dist/esm/modals/EditFiltersModal.js +348 -0
- package/dist/esm/modals/NewDashboardModal.d.ts +1 -3
- package/dist/esm/modals/NewDashboardModal.d.ts.map +1 -1
- package/dist/esm/modals/NewDashboardModal.js +64 -47
- package/dist/esm/modals/PromoteDashModal.d.ts.map +1 -1
- package/dist/esm/modals/PromoteDashModal.js +11 -4
- package/dist/esm/modals/PromoteViewModal.d.ts +2 -1
- package/dist/esm/modals/PromoteViewModal.d.ts.map +1 -1
- package/dist/esm/modals/PromoteViewModal.js +50 -40
- package/dist/esm/modals/ReorderDashboardModal.d.ts.map +1 -1
- package/dist/esm/modals/ReorderDashboardModal.js +43 -46
- package/dist/esm/modals/index.d.ts +0 -1
- package/dist/esm/modals/index.d.ts.map +1 -1
- package/dist/esm/modals/index.js +0 -1
- package/dist/esm/primitives/ButtonPrimitive.d.ts +3 -1
- package/dist/esm/primitives/ButtonPrimitive.d.ts.map +1 -1
- package/dist/esm/primitives/ButtonPrimitive.js +5 -3
- package/dist/esm/primitives/TextInputPrimitive.d.ts +1 -0
- package/dist/esm/primitives/TextInputPrimitive.d.ts.map +1 -1
- package/dist/esm/primitives/TextInputPrimitive.js +33 -21
- package/dist/esm/primitives/TogglePrimitive.js +5 -5
- package/dist/esm/public_components/CreateEnvironment.d.ts +2 -1
- package/dist/esm/public_components/CreateEnvironment.d.ts.map +1 -1
- package/dist/esm/public_components/CreateEnvironment.js +5 -2
- package/dist/esm/public_components/DashboardBuilder.d.ts.map +1 -1
- package/dist/esm/public_components/DashboardBuilder.js +72 -126
- package/dist/esm/public_components/DashboardManager.d.ts.map +1 -1
- package/dist/esm/public_components/DashboardManager.js +112 -149
- package/dist/esm/public_components/SQLViewManager.d.ts +1 -0
- package/dist/esm/public_components/SQLViewManager.d.ts.map +1 -1
- package/dist/esm/public_components/SQLViewManager.js +271 -48
- package/dist/esm/utils/astProcessing.d.ts +2 -0
- package/dist/esm/utils/astProcessing.d.ts.map +1 -0
- package/dist/esm/utils/astProcessing.js +37 -0
- package/dist/esm/utils/astProcessing.uspec.d.ts +2 -0
- package/dist/esm/utils/astProcessing.uspec.d.ts.map +1 -0
- package/dist/esm/utils/astProcessing.uspec.js +24 -0
- package/dist/esm/utils/columnProcessing.d.ts +3 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -0
- package/dist/esm/utils/columnProcessing.js +37 -0
- package/dist/esm/utils/dataEditor.d.ts +2 -2
- package/dist/esm/utils/dataEditor.d.ts.map +1 -1
- package/dist/esm/utils/dataEditor.js +4 -2
- package/dist/esm/utils/databases.d.ts +0 -1
- package/dist/esm/utils/databases.d.ts.map +1 -1
- package/dist/esm/utils/databases.js +5 -6
- package/dist/esm/utils/monacoAutocomplete.d.ts +21 -0
- package/dist/esm/utils/monacoAutocomplete.d.ts.map +1 -0
- package/dist/esm/utils/monacoAutocomplete.js +245 -0
- package/dist/esm/utils/schema.d.ts +11 -0
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +126 -1
- package/dist/esm/utils/table.d.ts +1 -0
- package/dist/esm/utils/table.d.ts.map +1 -1
- package/dist/esm/utils/table.js +11 -1
- package/dist/esm/utils/textProcessing.d.ts +2 -0
- package/dist/esm/utils/textProcessing.d.ts.map +1 -0
- package/dist/esm/utils/textProcessing.js +5 -0
- package/package.json +3 -2
- package/dist/cjs/modals/EditDashboardsModal.d.ts +0 -20
- package/dist/cjs/modals/EditDashboardsModal.d.ts.map +0 -1
- package/dist/cjs/modals/EditDashboardsModal.js +0 -94
- package/dist/esm/modals/EditDashboardsModal.d.ts +0 -20
- package/dist/esm/modals/EditDashboardsModal.d.ts.map +0 -1
- package/dist/esm/modals/EditDashboardsModal.js +0 -91
package/dist/esm/Admin.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import { QuillProvider, useQuill, Chart, ChartEditor, useDashboard, } from '@quillsql/react';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef, useCallback } from 'react';
|
|
3
|
+
import { QuillProvider, useQuill, ChartEditor, ReportBuilder, } from '@quillsql/react';
|
|
5
4
|
import prismTheme from 'prism-react-renderer/themes/nightOwlLight';
|
|
6
5
|
import Highlight, { defaultProps } from 'prism-react-renderer';
|
|
7
|
-
import { DndContext, closestCenter, KeyboardSensor, PointerSensor, useSensor, useSensors, MeasuringStrategy, TouchSensor, } from '@dnd-kit/core';
|
|
8
|
-
import InputLabel from './components/InputLabel';
|
|
9
|
-
import CardSection from './components/CardSection';
|
|
10
|
-
import { arrayMove, SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy, useSortable, defaultAnimateLayoutChanges, } from '@dnd-kit/sortable';
|
|
11
|
-
import { CSS } from '@dnd-kit/utilities';
|
|
12
6
|
import { DashboardManager } from './components';
|
|
13
7
|
import { AdminProvider, useAdmin } from './AdminProvider';
|
|
14
|
-
import {
|
|
8
|
+
import { HeaderPrimitive, ModalPrimitive, SelectPrimitive, TextInputPrimitive, } from './primitives';
|
|
9
|
+
import { MemoizedButton, MemoizedSecondaryButton, } from './components/UiComponents';
|
|
15
10
|
import DashboardBuilder from './public_components/DashboardBuilder';
|
|
16
11
|
import SQLViewManager from './public_components/SQLViewManager';
|
|
17
|
-
import {
|
|
18
|
-
import TogglePrimitive from './primitives/TogglePrimitive';
|
|
12
|
+
import { QUILL_SERVER } from './utils/constants';
|
|
19
13
|
import { MemoizedModal } from './components/UiComponents';
|
|
20
14
|
import { SQLEditor } from '@quillsql/react';
|
|
15
|
+
import { hasColumnAlias } from './utils/table';
|
|
21
16
|
// chartColors: ["#6269E9", "#E14F62"],
|
|
22
|
-
const defaultTheme = {
|
|
17
|
+
export const defaultTheme = {
|
|
23
18
|
fontFamily: 'Inter; Helvetica',
|
|
24
19
|
backgroundColor: '#FFFFFF',
|
|
25
20
|
primaryTextColor: '#364153',
|
|
@@ -27,394 +22,23 @@ const defaultTheme = {
|
|
|
27
22
|
chartLabelFontFamily: 'Inter; Helvetica',
|
|
28
23
|
chartLabelColor: '#666666',
|
|
29
24
|
chartTickColor: '#CCCCCC',
|
|
25
|
+
chartColors: ['#6269E9', '#E14F62', '#55B5A6', '#E9A23B', '#D0ACCF'],
|
|
30
26
|
borderColor: '#E5E7EB',
|
|
31
27
|
primaryButtonColor: '#364153',
|
|
32
28
|
borderWidth: 1,
|
|
33
|
-
labelFontWeight:
|
|
29
|
+
labelFontWeight: 500,
|
|
34
30
|
fontSize: 14,
|
|
35
31
|
};
|
|
36
|
-
export function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const [showDateFilter, setShowDateFilter] = useState(true);
|
|
47
|
-
const [newDateFilter, setNewDateFilter] = useState(null);
|
|
48
|
-
const [selectedTable, setSelectedTable] = useState(null);
|
|
49
|
-
const [field, setField] = useState('');
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
if (data && data.dateFilter) {
|
|
52
|
-
setIsDateComparison(data.dateFilter.comparison);
|
|
53
|
-
dispatch('SET_DATE_FILTER', data.dateFilter);
|
|
54
|
-
}
|
|
55
|
-
setShowDateFilter(Boolean(data?.dateFilter));
|
|
56
|
-
}, [data]);
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
setIsDateComparison(!!state.dateFilter?.comparison ?? false);
|
|
59
|
-
}, [state.dateFilter]);
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
if (state.tables?.length) {
|
|
62
|
-
const defaultTable = state.tables[0];
|
|
63
|
-
const name = state.editDashboardData?.filters[0]?.table;
|
|
64
|
-
const table = state.tables.find((t) => t.name === name) ?? defaultTable;
|
|
65
|
-
setSelectedTable(table);
|
|
66
|
-
setField(table.columns.map((elem) => elem.name)[0]);
|
|
67
|
-
}
|
|
68
|
-
}, [state.tables, state.editDashboardData]);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (dashboardData && dashboardData.filters) {
|
|
71
|
-
setNewFilters(dashboardData.filters);
|
|
72
|
-
}
|
|
73
|
-
if (dashboardData && dashboardData.dateFilter) {
|
|
74
|
-
setNewDateFilter(dashboardData.dateFilter);
|
|
75
|
-
}
|
|
76
|
-
}, [dashboardData]);
|
|
77
|
-
const handleAddFilter = async () => {
|
|
78
|
-
setNewFilters([...newFilters, { label: '' }]);
|
|
79
|
-
};
|
|
80
|
-
const handleSubmitDashboardChanges = async () => {
|
|
81
|
-
if (!selectedDashboardName ||
|
|
82
|
-
newFilters.some((filter) => !filter.label) ||
|
|
83
|
-
(newDateFilter &&
|
|
84
|
-
Object.keys(newDateFilter).length &&
|
|
85
|
-
!newDateFilter.label)) {
|
|
86
|
-
alert('Empty fields');
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (newFilters.filter((elem) => !elem.field).length) {
|
|
90
|
-
alert(`no filter field for: ${newFilters.filter((elem) => !elem.field)[0].label}`);
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
const updatedFilters = newFilters.map((filter) => {
|
|
94
|
-
const table = state.tables.find((table) => table.name === filter.table);
|
|
95
|
-
const filterType = getPostgresBasicType(table.columns.find((col) => col.name === filter.field));
|
|
96
|
-
return {
|
|
97
|
-
table: filter.table,
|
|
98
|
-
field: filter.field,
|
|
99
|
-
labelField: filter.field,
|
|
100
|
-
label: filter.label,
|
|
101
|
-
filterType,
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
if (dashNames &&
|
|
105
|
-
dashNames.length > 0 &&
|
|
106
|
-
dashNames.some((dashName) => dashName.name === selectedDashboardName &&
|
|
107
|
-
selectedDashboardName !== selectedDashboard)) {
|
|
108
|
-
alert('Dashboard name already taken!');
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
const fieldsSet = new Set();
|
|
112
|
-
const hasDuplicateField = updatedFilters.some((filter) => {
|
|
113
|
-
if (fieldsSet.has(filter.field)) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
fieldsSet.add(filter.field);
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
if (hasDuplicateField ||
|
|
122
|
-
(newDateFilter &&
|
|
123
|
-
Object.keys(newDateFilter).length > 0 &&
|
|
124
|
-
updatedFilters.some((filter) => filter.filterType === 'date'))) {
|
|
125
|
-
alert('Maximum of one filter per field');
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
let allValid = true;
|
|
129
|
-
updatedFilters.forEach((filter) => {
|
|
130
|
-
if (filter.filterType !== 'string' && filter.filterType !== 'date') {
|
|
131
|
-
allValid = false;
|
|
132
|
-
console.error(`Invalid filterType found: ${filter.filterType}`);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
if (!allValid) {
|
|
136
|
-
alert('We only support string and filters.');
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const url = `${QUILL_SERVER}/dashfilter/${client._id}/`;
|
|
140
|
-
const body = {
|
|
141
|
-
newDashboardName: selectedDashboardName,
|
|
142
|
-
filters: updatedFilters,
|
|
143
|
-
dateFilter: newDateFilter
|
|
144
|
-
? {
|
|
145
|
-
...newDateFilter,
|
|
146
|
-
comparison: isDateComparison,
|
|
147
|
-
primaryRange: initialRange,
|
|
148
|
-
}
|
|
149
|
-
: null,
|
|
150
|
-
name: selectedDashboard,
|
|
151
|
-
databaseType: state.client.databaseType,
|
|
152
|
-
};
|
|
153
|
-
dispatch({ type: 'SET_DATE_FILTER', payload: body.dateFilter });
|
|
154
|
-
const headers = {
|
|
155
|
-
'Content-Type': 'application/json',
|
|
156
|
-
Authorization: `Bearer `,
|
|
157
|
-
};
|
|
158
|
-
try {
|
|
159
|
-
const response = await fetch(url, {
|
|
160
|
-
method: 'POST',
|
|
161
|
-
headers: headers,
|
|
162
|
-
body: JSON.stringify(body),
|
|
163
|
-
});
|
|
164
|
-
await onSave();
|
|
165
|
-
setSelectedEditDashboard(null);
|
|
166
|
-
setIsOpen(false);
|
|
167
|
-
}
|
|
168
|
-
catch (e) {
|
|
169
|
-
console.log('error');
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
const handleDeleteFilter = (filter) => {
|
|
173
|
-
setNewFilters(newFilters.filter((f) => f !== filter));
|
|
174
|
-
};
|
|
175
|
-
const handleDeleteDateFilter = async () => {
|
|
176
|
-
setShowDateFilter(false);
|
|
177
|
-
setNewDateFilter(null);
|
|
178
|
-
};
|
|
179
|
-
const handleAddDateFilter = async () => {
|
|
180
|
-
setShowDateFilter(true);
|
|
181
|
-
if (dashboardData && dashboardData.dateFilter) {
|
|
182
|
-
setNewDateFilter(dashboardData.dateFilter);
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const handleDeleteDashboard = async () => {
|
|
186
|
-
if (confirm('Are you sure? This action cannot be undone.')) {
|
|
187
|
-
const URL = `${QUILL_SERVER}/dashboard/${selectedDashboard}`;
|
|
188
|
-
await fetch(URL, {
|
|
189
|
-
method: 'DELETE',
|
|
190
|
-
headers: { 'Content-Type': 'application/json' },
|
|
191
|
-
body: JSON.stringify({
|
|
192
|
-
clientId: client._id,
|
|
193
|
-
databaseType: state.client.databaseType,
|
|
194
|
-
}),
|
|
195
|
-
});
|
|
196
|
-
setIsOpen(false);
|
|
197
|
-
setNewFilters([]);
|
|
198
|
-
await onSave();
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
return (_jsx(ModalComponent, { isOpen: isOpen, close: () => {
|
|
202
|
-
setIsOpen(false);
|
|
203
|
-
setNewFilters([]);
|
|
204
|
-
setIsDateComparison(state.dateFilter?.comparison ?? false);
|
|
205
|
-
}, style: {
|
|
206
|
-
minWidth: '814px',
|
|
207
|
-
maxWidth: '814px',
|
|
208
|
-
}, children: _jsxs("div", { style: {
|
|
209
|
-
display: 'flex',
|
|
210
|
-
gap: 16,
|
|
211
|
-
flexDirection: 'column',
|
|
212
|
-
width: '100%',
|
|
213
|
-
height: '100%',
|
|
214
|
-
maxHeight: '100%',
|
|
215
|
-
overflowY: 'auto',
|
|
216
|
-
}, children: [_jsx(HeaderComponent, { label: "Manage dashboard" }), _jsxs("div", { children: [_jsx(InputLabel, { children: "Name" }), _jsx("div", { style: { maxWidth: 230 }, children: _jsx(TextInputComponent, { value: selectedDashboardName, onChange: (e) => setSelectedDashboardName(e.target.value) }) })] }), _jsxs("div", { children: [_jsxs("div", { style: {
|
|
217
|
-
display: 'flex',
|
|
218
|
-
flexDirection: 'column',
|
|
219
|
-
gap: '10px',
|
|
220
|
-
}, children: [_jsx(CardSection, { children: "Date Filter" }), showDateFilter && (_jsx(_Fragment, { children: _jsxs("div", { style: {
|
|
221
|
-
display: 'flex',
|
|
222
|
-
flexDirection: 'row',
|
|
223
|
-
gap: '10px',
|
|
224
|
-
}, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(InputLabel, { children: "Label" }), _jsx("div", { style: {
|
|
225
|
-
display: 'flex',
|
|
226
|
-
flexDirection: 'row',
|
|
227
|
-
alignItems: 'center',
|
|
228
|
-
}, children: _jsx(TextInputComponent, { value: newDateFilter?.label, onChange: (e) => {
|
|
229
|
-
setNewDateFilter({
|
|
230
|
-
...newDateFilter,
|
|
231
|
-
label: e.target.value,
|
|
232
|
-
});
|
|
233
|
-
} }) })] }), _jsx("div", { style: {
|
|
234
|
-
display: 'flex',
|
|
235
|
-
flexDirection: 'row',
|
|
236
|
-
gap: '10px',
|
|
237
|
-
}, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(InputLabel, { children: "Initial Range" }), _jsx(SelectComponent, { value: initialRange.label, onChange: (e) => {
|
|
238
|
-
setInitialRange(InitialDateRangeOptions.find((table) => table.label === e) ?? initialRange);
|
|
239
|
-
}, options: InitialDateRangeOptions.map((table) => {
|
|
240
|
-
return { label: table.label, value: table.label };
|
|
241
|
-
}) })] }) }), _jsx("div", { style: {
|
|
242
|
-
display: 'flex',
|
|
243
|
-
flexDirection: 'row',
|
|
244
|
-
gap: '10px',
|
|
245
|
-
}, children: _jsxs("div", { style: {
|
|
246
|
-
display: 'flex',
|
|
247
|
-
flexDirection: 'column',
|
|
248
|
-
}, children: [_jsx(InputLabel, { children: "Date Comparison" }), _jsx("div", { style: {
|
|
249
|
-
display: 'flex',
|
|
250
|
-
flexDirection: 'column',
|
|
251
|
-
justifyContent: 'center',
|
|
252
|
-
height: '100%',
|
|
253
|
-
minWidth: 200,
|
|
254
|
-
maxWidth: 200,
|
|
255
|
-
width: 200,
|
|
256
|
-
}, children: _jsx(TogglePrimitive, { value: isDateComparison, onClick: () => {
|
|
257
|
-
setIsDateComparison((isDateComparison) => !isDateComparison);
|
|
258
|
-
} }) })] }) }), _jsx("div", { style: {
|
|
259
|
-
display: 'flex',
|
|
260
|
-
flexGrow: 1,
|
|
261
|
-
flexDirection: 'row',
|
|
262
|
-
alignItems: 'end',
|
|
263
|
-
justifyContent: 'end',
|
|
264
|
-
gap: '10px',
|
|
265
|
-
}, children: _jsx("div", { style: {
|
|
266
|
-
display: 'flex',
|
|
267
|
-
flexDirection: 'column',
|
|
268
|
-
justifyContent: 'center',
|
|
269
|
-
}, children: _jsx("div", { onClick: () => handleDeleteDateFilter(), style: {
|
|
270
|
-
height: 38,
|
|
271
|
-
width: 42,
|
|
272
|
-
alignItems: 'center',
|
|
273
|
-
justifyContent: 'center',
|
|
274
|
-
display: 'flex',
|
|
275
|
-
cursor: 'pointer',
|
|
276
|
-
}, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: _jsx("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) }) }) })] }) })), !showDateFilter && (_jsx("div", { style: { maxWidth: 230 }, children: _jsx(SecondaryButtonComponent, { onClick: handleAddDateFilter, label: "Add date filter +" }) }))] }), _jsx("div", { style: {
|
|
277
|
-
display: 'flex',
|
|
278
|
-
flexDirection: 'row',
|
|
279
|
-
alignItems: 'center',
|
|
280
|
-
justifyContent: 'space-between',
|
|
281
|
-
marginTop: 20,
|
|
282
|
-
}, children: _jsx(CardSection, { children: "Filters" }) }), newFilters.length > 0 && (_jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: '6px' }, children: newFilters.map((filter, index) => {
|
|
283
|
-
return (_jsxs("div", { style: {
|
|
284
|
-
display: 'flex',
|
|
285
|
-
flexDirection: 'row',
|
|
286
|
-
gap: '10px',
|
|
287
|
-
}, children: [_jsxs("div", { style: {
|
|
288
|
-
display: 'flex',
|
|
289
|
-
flexDirection: 'column',
|
|
290
|
-
maxWidth: 300,
|
|
291
|
-
}, children: [index === 0 && _jsx(InputLabel, { children: "Label" }), _jsx(TextInputComponent, { value: filter.label, onChange: (e) => {
|
|
292
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
293
|
-
? { ...otherFilter, label: e.target.value }
|
|
294
|
-
: otherFilter);
|
|
295
|
-
setNewFilters(updatedFilters);
|
|
296
|
-
}, width: "230px" })] }), _jsxs("div", { style: {
|
|
297
|
-
display: 'flex',
|
|
298
|
-
flexDirection: 'column',
|
|
299
|
-
maxWidth: 300,
|
|
300
|
-
}, children: [index === 0 && _jsx(InputLabel, { children: "Table" }), _jsx(SelectComponent, { defaultValue: "", value: filter.table, onChange: (e) => {
|
|
301
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
302
|
-
? { ...otherFilter, table: e }
|
|
303
|
-
: otherFilter);
|
|
304
|
-
setNewFilters(updatedFilters);
|
|
305
|
-
}, options: [
|
|
306
|
-
{ label: 'Select', value: '' },
|
|
307
|
-
...state.tables.map((table) => {
|
|
308
|
-
return { label: table.name, value: table.name };
|
|
309
|
-
}),
|
|
310
|
-
,
|
|
311
|
-
] })] }), _jsxs("div", { style: {
|
|
312
|
-
display: 'flex',
|
|
313
|
-
flexDirection: 'column',
|
|
314
|
-
maxWidth: 300,
|
|
315
|
-
}, children: [index === 0 && _jsx(InputLabel, { children: "Field" }), _jsx("div", { style: {
|
|
316
|
-
display: 'flex',
|
|
317
|
-
flexDirection: 'column',
|
|
318
|
-
alignItems: 'center',
|
|
319
|
-
}, children: _jsxs("div", { style: {
|
|
320
|
-
display: 'flex',
|
|
321
|
-
flexDirection: 'row',
|
|
322
|
-
alignItems: 'center',
|
|
323
|
-
}, children: [_jsx(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : '', options: state.tables
|
|
324
|
-
.find((table) => table.name === filter.table)
|
|
325
|
-
?.columns.map((column) => {
|
|
326
|
-
return {
|
|
327
|
-
label: column.name,
|
|
328
|
-
value: column.name,
|
|
329
|
-
};
|
|
330
|
-
}), onChange: (e) => {
|
|
331
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
332
|
-
? { ...otherFilter, field: e }
|
|
333
|
-
: otherFilter);
|
|
334
|
-
setNewFilters(updatedFilters);
|
|
335
|
-
} }), _jsx("div", { onClick: () => handleDeleteFilter(filter), style: {
|
|
336
|
-
height: 38,
|
|
337
|
-
width: 42,
|
|
338
|
-
alignItems: 'center',
|
|
339
|
-
justifyContent: 'center',
|
|
340
|
-
display: 'flex',
|
|
341
|
-
cursor: 'pointer',
|
|
342
|
-
}, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: _jsx("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) })] }) })] })] }, index));
|
|
343
|
-
}) })), _jsx("div", { style: { height: 12 } }), _jsx(SecondaryButtonComponent, { onClick: handleAddFilter, label: "Add filter +" })] }), _jsx(CardSection, { children: "Chart order" }), _jsx("div", { style: { maxWidth: 230 }, children: _jsx(SecondaryButtonComponent, { onClick: () => openEditOrderModal(selectedDashboardName), label: "Edit chart order" }) }), _jsx(CardSection, { children: "Danger Zone" }), _jsx("div", { style: { maxWidth: 230 }, children: _jsx(SecondaryButtonComponent, { onClick: handleDeleteDashboard, label: "Delete Dashboard" }) }), _jsx("div", { style: { height: 18 } }), _jsx("div", { style: { maxWidth: 230 }, children: _jsx(ButtonComponent, { onClick: handleSubmitDashboardChanges, label: "Save changes" }) })] }) }));
|
|
344
|
-
}
|
|
345
|
-
export function AddFilterModal({ isOpen, selectedDashboard, client, setIsOpen, ModalComponent, TextInputComponent, SelectComponent, HeaderComponent, ButtonComponent, openAddDashboardModal, }) {
|
|
346
|
-
const [selectedTable, setSelectedTable] = useState(null);
|
|
347
|
-
const [name, setName] = useState('');
|
|
348
|
-
const [field, setField] = useState('');
|
|
349
|
-
const [filterType, setFilterType] = useState('string');
|
|
350
|
-
const [dateRange, setDateRange] = useState([new Date(), new Date()]);
|
|
351
|
-
const { state, dispatch } = useAdmin();
|
|
352
|
-
useEffect(() => {
|
|
353
|
-
if (state.tables?.length) {
|
|
354
|
-
setSelectedTable(state.tables[0]);
|
|
355
|
-
// setField(tables[0].columns.map((elem) => elem.name));
|
|
356
|
-
setField(state.tables[0].columns[0].name);
|
|
357
|
-
}
|
|
358
|
-
}, [state.tables]);
|
|
359
|
-
const handleAddFilter = async () => {
|
|
360
|
-
if (!selectedTable || !field) {
|
|
361
|
-
return;
|
|
362
|
-
}
|
|
363
|
-
const filterType = getPostgresBasicType(selectedTable.columns.find((col) => col.name === field));
|
|
364
|
-
if (filterType !== 'string' && filterType !== 'date') {
|
|
365
|
-
alert('We only support string and filters.');
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
let responseData;
|
|
369
|
-
const url = `${QUILL_SERVER}/dashfilter/${client._id}/`;
|
|
370
|
-
const body = {
|
|
371
|
-
name: selectedDashboard,
|
|
372
|
-
filter: {
|
|
373
|
-
table: selectedTable.name,
|
|
374
|
-
field: field,
|
|
375
|
-
labelField: field,
|
|
376
|
-
label: name,
|
|
377
|
-
filterType,
|
|
378
|
-
},
|
|
379
|
-
};
|
|
380
|
-
const headers = {
|
|
381
|
-
'Content-Type': 'application/json',
|
|
382
|
-
Authorization: `Bearer `,
|
|
383
|
-
};
|
|
384
|
-
try {
|
|
385
|
-
const response = await fetch(url, {
|
|
386
|
-
method: 'POST',
|
|
387
|
-
headers: headers,
|
|
388
|
-
body: JSON.stringify(body),
|
|
389
|
-
});
|
|
390
|
-
if (!response.ok) {
|
|
391
|
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
392
|
-
}
|
|
393
|
-
responseData = await response.json();
|
|
394
|
-
}
|
|
395
|
-
catch (error) {
|
|
396
|
-
console.error('There was a problem with the fetch operation:', error);
|
|
397
|
-
}
|
|
398
|
-
if (responseData) {
|
|
399
|
-
setIsOpen(false);
|
|
400
|
-
setName('');
|
|
401
|
-
setField('');
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
};
|
|
405
|
-
if (!selectedTable) {
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
return (_jsx(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx(HeaderComponent, { label: "Add filter" }), _jsx("div", { children: "Label" }), _jsx(TextInputComponent, { value: name, onChange: (e) => setName(e.target.value) }), _jsx("div", { children: "Table" }), _jsx(SelectComponent, { defaultValue: "", value: selectedTable ? selectedTable : '', onChange: (e) => setSelectedTable(e.target.value), QuillOptions: state.tables.map((table) => {
|
|
409
|
-
return { label: table.name, value: table.name };
|
|
410
|
-
}) }), _jsx("div", { children: "Field" }), _jsx(SelectComponent, { defaultValue: "", value: field ? field : '', QuillOptions: selectedTable.columns.map((column) => {
|
|
411
|
-
return { label: column.name, value: column.name };
|
|
412
|
-
}), onChange: (e) => {
|
|
413
|
-
setField(e);
|
|
414
|
-
} }), _jsx(ButtonComponent, { label: "Add filter", onClick: handleAddFilter })] }) }));
|
|
415
|
-
}
|
|
416
|
-
export default function Portal({ publicKey, queryEndpoint, theme = defaultTheme, queryHeaders, withCredentials, environment, organizationId, TextInputComponent, ButtonComponent, SecondaryButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, UserManagementComponent, HeaderComponent, }) {
|
|
417
|
-
return (_jsx(AdminProvider, { publicKey: publicKey, children: _jsx(Navigation, { theme: theme, publicKey: publicKey, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials, TextInputComponent: TextInputComponent || TextInputPrimitive, ButtonComponent: ButtonComponent || ButtonPrimitive, HeaderComponent: HeaderComponent || HeaderPrimitive, SecondaryButtonComponent: SecondaryButtonComponent || SecondaryButtonPrimitive, ModalComponent: ModalComponent || ModalPrimitive, environment: environment, OrganizationSelectComponent: OrganizationSelectComponent, UserManagementComponent: UserManagementComponent, SelectComponent: SelectComponent || SelectPrimitive }) }));
|
|
32
|
+
export default function Portal({ publicKey, queryEndpoint, theme = defaultTheme, queryHeaders, withCredentials, environment, organizationId, TextInputComponent, ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, ModalComponent, SelectComponent, OrganizationSelectComponent, UserManagementComponent, HeaderComponent, }) {
|
|
33
|
+
return (_jsx(AdminProvider, { publicKey: publicKey, children: _jsx(Navigation, { theme: theme, publicKey: publicKey, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials,
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
TextInputComponent: TextInputComponent || TextInputPrimitive, ButtonComponent: ButtonComponent,
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
HeaderComponent: HeaderComponent || HeaderPrimitive, SecondaryButtonComponent: SecondaryButtonComponent,
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
ModalComponent: ModalComponent || ModalPrimitive, environment: environment, OrganizationSelectComponent: OrganizationSelectComponent, UserManagementComponent: UserManagementComponent,
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
SelectComponent: SelectComponent || SelectPrimitive }) }));
|
|
418
42
|
}
|
|
419
43
|
function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, UserManagementComponent, HeaderComponent, publicKey, queryEndpoint, queryHeaders, environment, withCredentials, }) {
|
|
420
44
|
const { state, dispatch } = useAdmin();
|
|
@@ -428,15 +52,21 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
|
|
|
428
52
|
const renderComponentBasedOnName = () => {
|
|
429
53
|
switch (state.activeComponent) {
|
|
430
54
|
case 'Dashboards':
|
|
431
|
-
return (_jsx(DashboardManager
|
|
55
|
+
return (_jsx(DashboardManager
|
|
56
|
+
// @ts-ignore
|
|
57
|
+
, {
|
|
58
|
+
// @ts-ignore
|
|
59
|
+
TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, HeaderComponent: HeaderComponent, setReportId: (id) => dispatch({ type: 'SET_REPORT_ID', payload: id }), queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
|
|
432
60
|
case 'SQL editor':
|
|
433
61
|
return _jsx(DashboardBuilder, {});
|
|
434
|
-
case 'Report':
|
|
435
|
-
return (_jsx(ReportWrapper, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, OrganizationSelectComponent: OrganizationSelectComponent, organizationId: state.organizationId, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
|
|
436
62
|
case 'SQL views':
|
|
437
63
|
return _jsx(SQLViewManager, {});
|
|
438
64
|
default:
|
|
439
|
-
return (_jsx(
|
|
65
|
+
return (_jsx(DashboardManager
|
|
66
|
+
// @ts-ignore
|
|
67
|
+
, {
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, HeaderComponent: HeaderComponent, setReportId: (id) => dispatch({ type: 'SET_REPORT_ID', payload: id }), queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
|
|
440
70
|
}
|
|
441
71
|
};
|
|
442
72
|
return (_jsxs("div", { style: {
|
|
@@ -537,7 +167,7 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
|
|
|
537
167
|
, {
|
|
538
168
|
// organizationId={'2'}
|
|
539
169
|
// publicKey={client?._id}
|
|
540
|
-
organizationId: state.organizationId, queryEndpoint: queryEndpoint, withCredentials: withCredentials, queryHeaders: queryHeaders, publicKey: state.client._id, environment: state.environment, theme: theme, children: renderComponentBasedOnName() }) })] }));
|
|
170
|
+
organizationId: state.organizationId, queryEndpoint: queryEndpoint || '', withCredentials: withCredentials, queryHeaders: queryHeaders || {}, publicKey: state.client._id, environment: state.environment, theme: theme, children: renderComponentBasedOnName() }) })] }));
|
|
541
171
|
}
|
|
542
172
|
export const theme = {
|
|
543
173
|
fontFamily: 'Inter; Helvetica',
|
|
@@ -633,172 +263,7 @@ export function getPostgresBasicType(column) {
|
|
|
633
263
|
}
|
|
634
264
|
return format;
|
|
635
265
|
}
|
|
636
|
-
export function
|
|
637
|
-
return classes.filter(Boolean).join(' ');
|
|
638
|
-
}
|
|
639
|
-
export function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, ModalComponent, TextInputComponent, SelectComponent, HeaderComponent, ButtonComponent, dashNames, getDashNames, organizationId, }) {
|
|
640
|
-
const { state, dispatch } = useAdmin();
|
|
641
|
-
const [selectedDashboardName, setSelectedDashboardName] = useState(selectedDashboard?.name);
|
|
642
|
-
// const [tables] = useContext(TablesContext);
|
|
643
|
-
const [selectedTable, setSelectedTable] = useState(null);
|
|
644
|
-
const [name, setName] = useState('');
|
|
645
|
-
const [field, setField] = useState('');
|
|
646
|
-
const [filterType, setFilterType] = useState('string');
|
|
647
|
-
const [dateRange, setDateRange] = useState([new Date(), new Date()]);
|
|
648
|
-
const [newFilters, setNewFilters] = useState([]);
|
|
649
|
-
const [newDateFilter, setNewDateFilter] = useState(null);
|
|
650
|
-
useEffect(() => {
|
|
651
|
-
if (state.tables?.length) {
|
|
652
|
-
setSelectedTable(state.tables[0]);
|
|
653
|
-
// setField(tables[0].columns.map((elem) => elem.name));
|
|
654
|
-
setField(state.tables[0].columns[0].name);
|
|
655
|
-
}
|
|
656
|
-
}, [state.tables]);
|
|
657
|
-
const handleDeleteFilter = async (filter) => {
|
|
658
|
-
setNewFilters(newFilters.filter((f) => f !== filter));
|
|
659
|
-
};
|
|
660
|
-
const handleAddDashboardSubmit = async () => {
|
|
661
|
-
if (!selectedDashboardName ||
|
|
662
|
-
newFilters.some((filter) => !filter.label) ||
|
|
663
|
-
(newDateFilter && newDateFilter.label)) {
|
|
664
|
-
alert('Empty labels');
|
|
665
|
-
return;
|
|
666
|
-
}
|
|
667
|
-
if (newFilters.some((filter) => !filter.field)) {
|
|
668
|
-
alert('Empty fields');
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
if (!selectedTable || !field) {
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
if (dashNames &&
|
|
675
|
-
dashNames.length > 0 &&
|
|
676
|
-
dashNames.some((dashName) => dashName.name === selectedDashboardName)) {
|
|
677
|
-
alert('Dashboard name already taken!');
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
let updatedFilters = newFilters.map((filter) => {
|
|
681
|
-
const filterType = getPostgresBasicType(selectedTable.columns.find((col) => col.name === filter.field));
|
|
682
|
-
return {
|
|
683
|
-
table: selectedTable.name,
|
|
684
|
-
field: filter.field,
|
|
685
|
-
labelField: filter.field,
|
|
686
|
-
label: filter.label,
|
|
687
|
-
filterType,
|
|
688
|
-
};
|
|
689
|
-
});
|
|
690
|
-
const fieldsSet = new Set();
|
|
691
|
-
const hasDuplicateField = updatedFilters.some((filter) => {
|
|
692
|
-
if (fieldsSet.has(filter.field)) {
|
|
693
|
-
return true;
|
|
694
|
-
}
|
|
695
|
-
else {
|
|
696
|
-
fieldsSet.add(filter.field);
|
|
697
|
-
return false;
|
|
698
|
-
}
|
|
699
|
-
});
|
|
700
|
-
if (hasDuplicateField) {
|
|
701
|
-
alert('Maximum of one filter per field');
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
let allValid = true;
|
|
705
|
-
updatedFilters.forEach((filter) => {
|
|
706
|
-
if (filter.filterType !== 'string' && filter.filterType !== 'date') {
|
|
707
|
-
allValid = false;
|
|
708
|
-
console.error(`Invalid filterType found: ${filter.filterType}`);
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
if (!allValid) {
|
|
712
|
-
alert('We only support string and filters.');
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (updatedFilters.filter((filter) => filter.filterType === 'date').length > 1) {
|
|
716
|
-
alert('More than one date filter');
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
let responseData;
|
|
720
|
-
const url = `${QUILL_SERVER}/newdash/${client._id}/`;
|
|
721
|
-
const body = newDateFilter && Object.keys(newDateFilter).length
|
|
722
|
-
? {
|
|
723
|
-
dateFilter: newDateFilter,
|
|
724
|
-
newDashboardName: selectedDashboardName,
|
|
725
|
-
filters: updatedFilters,
|
|
726
|
-
organizationId,
|
|
727
|
-
}
|
|
728
|
-
: {
|
|
729
|
-
newDashboardName: selectedDashboardName,
|
|
730
|
-
filters: updatedFilters,
|
|
731
|
-
organizationId,
|
|
732
|
-
};
|
|
733
|
-
const headers = {
|
|
734
|
-
'Content-Type': 'application/json',
|
|
735
|
-
Authorization: `Bearer `,
|
|
736
|
-
};
|
|
737
|
-
try {
|
|
738
|
-
const response = await fetch(url, {
|
|
739
|
-
method: 'POST',
|
|
740
|
-
headers: headers,
|
|
741
|
-
body: JSON.stringify(body),
|
|
742
|
-
});
|
|
743
|
-
if (!response.ok) {
|
|
744
|
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
745
|
-
}
|
|
746
|
-
responseData = await response.json();
|
|
747
|
-
}
|
|
748
|
-
catch (e) {
|
|
749
|
-
console.log('error');
|
|
750
|
-
}
|
|
751
|
-
if (responseData) {
|
|
752
|
-
setIsOpen(false);
|
|
753
|
-
setName('');
|
|
754
|
-
setSelectedDashboardName('');
|
|
755
|
-
setNewFilters([]);
|
|
756
|
-
setNewDateFilter(null);
|
|
757
|
-
getDashNames();
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
};
|
|
761
|
-
if (!selectedTable) {
|
|
762
|
-
return _jsx(_Fragment, {});
|
|
763
|
-
}
|
|
764
|
-
const handleAddFilter = async () => {
|
|
765
|
-
setNewFilters([...newFilters, { label: '', field }]);
|
|
766
|
-
};
|
|
767
|
-
return (_jsx(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: _jsxs("div", { children: [_jsx(TextInputComponent, { placeholder: "Enter Dashboard Name...", onChange: (e) => setSelectedDashboardName(e.target.value), value: selectedDashboardName }), _jsxs("div", { style: {
|
|
768
|
-
display: 'flex',
|
|
769
|
-
flexDirection: 'column',
|
|
770
|
-
alignItems: 'center',
|
|
771
|
-
}, children: [newFilters.map((filter, index) => {
|
|
772
|
-
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'row' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("h2", { children: "Label" }), _jsx(TextInputComponent, { value: filter.label, onChange: (e) => {
|
|
773
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
774
|
-
? { ...otherFilter, label: e.target.value }
|
|
775
|
-
: otherFilter);
|
|
776
|
-
setNewFilters(updatedFilters);
|
|
777
|
-
} })] }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsx("h4", { children: "Field" }), _jsx("div", { style: {
|
|
778
|
-
display: 'flex',
|
|
779
|
-
flexDirection: 'column',
|
|
780
|
-
alignItems: 'center',
|
|
781
|
-
}, children: _jsxs("div", { style: {
|
|
782
|
-
display: 'flex',
|
|
783
|
-
flexDirection: 'row',
|
|
784
|
-
alignItems: 'center',
|
|
785
|
-
}, children: [_jsx(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : '', QuillOptions: selectedTable.columns.map((column) => {
|
|
786
|
-
return { label: column.name, value: column.name };
|
|
787
|
-
}), onChange: (e) => {
|
|
788
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
789
|
-
? { ...otherFilter, field: e }
|
|
790
|
-
: otherFilter);
|
|
791
|
-
setNewFilters(updatedFilters);
|
|
792
|
-
} }), _jsx("div", { onClick: () => handleDeleteFilter(filter), style: {
|
|
793
|
-
height: 38,
|
|
794
|
-
width: 42,
|
|
795
|
-
alignItems: 'center',
|
|
796
|
-
justifyContent: 'center',
|
|
797
|
-
display: 'flex',
|
|
798
|
-
}, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: _jsx("path", { fillRule: "evenodd", d: "M5.47 5.47a.75.75 0 011.06 0L12 10.94l5.47-5.47a.75.75 0 111.06 1.06L13.06 12l5.47 5.47a.75.75 0 11-1.06 1.06L12 13.06l-5.47 5.47a.75.75 0 01-1.06-1.06L10.94 12 5.47 6.53a.75.75 0 010-1.06z", clipRule: "evenodd" }) }) })] }) })] })] }, filter.field + index));
|
|
799
|
-
}), _jsx(ButtonComponent, { onClick: handleAddFilter, label: "Add new filter +" }), _jsx(ButtonComponent, { onClick: handleAddDashboardSubmit, label: "Add Dashboard +" })] })] }) }));
|
|
800
|
-
}
|
|
801
|
-
export function TableCell({ table, clickTableCell }) {
|
|
266
|
+
export function TableCell({ table, clickTableCell, }) {
|
|
802
267
|
const handleClickTableCell = () => {
|
|
803
268
|
clickTableCell(table);
|
|
804
269
|
};
|
|
@@ -820,306 +285,211 @@ export function TableCell({ table, clickTableCell }) {
|
|
|
820
285
|
// height: "1.3em",
|
|
821
286
|
}, children: tokens.map((line, i) => (_jsx("div", { ...getLineProps({ line, key: i }), children: line.map((token, key) => (_jsx("span", { ...getTokenProps({ token, key }) }, key))) }, i))) })) })] }, table._id));
|
|
822
287
|
}
|
|
823
|
-
const SchemaListComponent = ({ schema, theme }) => {
|
|
824
|
-
return (_jsx("div", { style: {
|
|
825
|
-
background: theme.backgroundColor,
|
|
826
|
-
maxHeight: 700,
|
|
827
|
-
width: 300,
|
|
828
|
-
minWidth: 300,
|
|
829
|
-
overflowY: 'scroll',
|
|
830
|
-
// maxHeight: "100%",
|
|
831
|
-
paddingLeft: 20,
|
|
832
|
-
paddingRight: 20,
|
|
833
|
-
}, children: schema.map((elem, index) => (_jsx(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index))) }));
|
|
834
|
-
};
|
|
835
|
-
function SchemaItem({ elem, theme, index }) {
|
|
836
|
-
const [isOpen, setIsOpen] = useState(index === 0);
|
|
837
|
-
const schemaContainerStyle = {
|
|
838
|
-
display: 'flex',
|
|
839
|
-
flexDirection: 'column',
|
|
840
|
-
// WebkitTouchCallout: "none",
|
|
841
|
-
// WebkitUserSelect: "none",
|
|
842
|
-
// KhtmlUserSelect: "none",
|
|
843
|
-
// MozUserSelect: "none",
|
|
844
|
-
// msUserSelect: "none",
|
|
845
|
-
// userSelect: "none",
|
|
846
|
-
};
|
|
847
|
-
const schemaRowStyle = {
|
|
848
|
-
display: 'flex',
|
|
849
|
-
flexDirection: 'row',
|
|
850
|
-
alignItems: 'center',
|
|
851
|
-
width: '100%',
|
|
852
|
-
justifyContent: 'space-between',
|
|
853
|
-
cursor: 'pointer',
|
|
854
|
-
};
|
|
855
|
-
const schemaRowHoverStyle = {
|
|
856
|
-
background: theme.selectUnderlayColor,
|
|
857
|
-
};
|
|
858
|
-
return (_jsxs("div", { style: schemaContainerStyle, children: [_jsxs("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, onClick: () => setIsOpen(!isOpen), children: [_jsx("p", { style: {
|
|
859
|
-
marginLeft: theme.padding,
|
|
860
|
-
fontSize: theme.fontSize,
|
|
861
|
-
color: '#384151',
|
|
862
|
-
fontWeight: '500',
|
|
863
|
-
}, children: elem.displayName }), _jsx("div", { style: {
|
|
864
|
-
display: 'flex',
|
|
865
|
-
alignItems: 'center',
|
|
866
|
-
justifyContent: 'center',
|
|
867
|
-
// paddingRight: 25,
|
|
868
|
-
paddingTop: 20,
|
|
869
|
-
paddingBottom: 20,
|
|
870
|
-
paddingLeft: 0,
|
|
871
|
-
cursor: 'pointer',
|
|
872
|
-
}, children: isOpen ? (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "h-5 w-5 text-gray-400", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) })) : (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "h-5 w-5", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) })) })] }), isOpen ? (_jsx("div", { style: {
|
|
873
|
-
paddingBottom: theme.padding,
|
|
874
|
-
display: 'flex',
|
|
875
|
-
flexDirection: 'column',
|
|
876
|
-
paddingLeft: theme.padding,
|
|
877
|
-
paddingRight: theme.padding,
|
|
878
|
-
}, children: elem.columns.map((elem, index) => (_jsxs("div", { style: {
|
|
879
|
-
paddingTop: theme.padding,
|
|
880
|
-
display: 'flex',
|
|
881
|
-
flexDirection: 'row',
|
|
882
|
-
alignItems: 'center',
|
|
883
|
-
justifyContent: 'space-between',
|
|
884
|
-
}, children: [_jsx("div", { title: elem.displayName, className: "text-gray-500", style: {
|
|
885
|
-
fontSize: 13,
|
|
886
|
-
// color: theme.secondaryFontColor,
|
|
887
|
-
whiteSpace: 'nowrap',
|
|
888
|
-
padding: 0,
|
|
889
|
-
margin: 0,
|
|
890
|
-
textOverflow: 'ellipsis',
|
|
891
|
-
overflow: 'hidden',
|
|
892
|
-
width: 200,
|
|
893
|
-
maxWidth: 200,
|
|
894
|
-
}, children: elem.displayName }), _jsx("div", { className: "text-gray-500", title: elem.displayName, style: {
|
|
895
|
-
fontSize: 13,
|
|
896
|
-
color: theme.secondaryFontColor,
|
|
897
|
-
padding: 0,
|
|
898
|
-
margin: 0,
|
|
899
|
-
}, children: elem.fieldType })] }, elem.displayName + elem.index))) })) : null] }));
|
|
900
|
-
}
|
|
901
|
-
export function defineEditorTheme(monaco, theme) {
|
|
902
|
-
monaco.editor.defineTheme('onedark', {
|
|
903
|
-
base: theme.darkMode ? 'vs-dark' : 'vs',
|
|
904
|
-
inherit: true,
|
|
905
|
-
rules: [
|
|
906
|
-
{
|
|
907
|
-
token: 'comment',
|
|
908
|
-
foreground: '#5d7988',
|
|
909
|
-
fontStyle: 'italic',
|
|
910
|
-
},
|
|
911
|
-
{ token: 'constant', foreground: '#e06c75' },
|
|
912
|
-
],
|
|
913
|
-
colors: {
|
|
914
|
-
'editor.background': '#F9F9F9',
|
|
915
|
-
},
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
export function setEditorTheme(editor, monaco) {
|
|
919
|
-
try {
|
|
920
|
-
monaco.editor.setTheme('onedark');
|
|
921
|
-
}
|
|
922
|
-
catch (e) {
|
|
923
|
-
console.log('ERROR: ', e);
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
export function isValidDate(d) {
|
|
927
|
-
return d instanceof Date && !isNaN(d);
|
|
928
|
-
}
|
|
929
|
-
export const isArrayOfValidDates = (arr, field) => arr.every((d) => new Date(d[field]) instanceof Date && !isNaN(new Date(d[field])));
|
|
930
|
-
export function formatDateBuckets(startDate, endDate) {
|
|
931
|
-
// Calculate the distance in hours
|
|
932
|
-
const distanceInHours = Math.abs(differenceInHours(endDate, startDate));
|
|
933
|
-
// Check if the distance is less than or equal to one hour
|
|
934
|
-
if (distanceInHours <= 1) {
|
|
935
|
-
return {
|
|
936
|
-
unit: 'hour',
|
|
937
|
-
format: 'h a',
|
|
938
|
-
startOf: startOfHour,
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
// Calculate the distance in days
|
|
942
|
-
const distanceInDays = Math.abs(differenceInDays(endDate, startDate));
|
|
943
|
-
// Check if the distance is less than or equal to one day
|
|
944
|
-
if (distanceInDays <= 1) {
|
|
945
|
-
return {
|
|
946
|
-
unit: 'day',
|
|
947
|
-
format: 'MMM d',
|
|
948
|
-
startOf: startOfDay,
|
|
949
|
-
};
|
|
950
|
-
}
|
|
951
|
-
// Calculate the distance in months
|
|
952
|
-
const distanceInMonths = Math.abs(differenceInMonths(endDate, startDate));
|
|
953
|
-
// Check if the distance is less than or equal to one month
|
|
954
|
-
if (distanceInMonths <= 1) {
|
|
955
|
-
return {
|
|
956
|
-
unit: 'month',
|
|
957
|
-
format: 'MMM yyyy',
|
|
958
|
-
startOf: startOfMonth,
|
|
959
|
-
};
|
|
960
|
-
}
|
|
961
|
-
// Calculate the distance in years
|
|
962
|
-
const distanceInYears = Math.abs(differenceInYears(endDate, startDate));
|
|
963
|
-
// Check if the distance is less than or equal to one year
|
|
964
|
-
if (distanceInYears <= 1) {
|
|
965
|
-
return {
|
|
966
|
-
unit: 'year',
|
|
967
|
-
format: 'yyyy',
|
|
968
|
-
startOf: startOfYear,
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
// Otherwise, the distance is more than one year
|
|
972
|
-
return {
|
|
973
|
-
unit: 'year',
|
|
974
|
-
format: 'yyyy',
|
|
975
|
-
startOf: startOfYear,
|
|
976
|
-
};
|
|
977
|
-
}
|
|
978
|
-
const POSTGRES_DATE_TYPES = [
|
|
979
|
-
'timestamp',
|
|
980
|
-
'date',
|
|
981
|
-
'timestamptz',
|
|
982
|
-
'time',
|
|
983
|
-
'timetz',
|
|
984
|
-
];
|
|
985
|
-
const FORMAT_QuillOptionS = [
|
|
986
|
-
{ value: 'whole_number', label: 'whole number' },
|
|
987
|
-
{ value: 'one_decimal_place', label: 'one decimal place' },
|
|
988
|
-
{ value: 'dollar_amount', label: 'dollar amount' },
|
|
989
|
-
{ value: 'MMM_yyyy', label: 'month' },
|
|
990
|
-
{ value: 'MMM_dd-MMM_dd', label: 'week' },
|
|
991
|
-
{ value: 'MMM_dd_yyyy', label: 'day' },
|
|
992
|
-
{ value: 'MMM_dd_hh:mm_ap_pm', label: 'day and time' },
|
|
993
|
-
{ value: 'hh_ap_pm', label: 'hour' },
|
|
994
|
-
{ value: 'percent', label: 'percent' },
|
|
995
|
-
{ value: 'string', label: 'string' },
|
|
996
|
-
];
|
|
997
288
|
const FakeModal = ({ children }) => (_jsx("div", { style: { height: '100%' }, children: children }));
|
|
998
|
-
const FakeSQLEditorModal = ({ children, isOpen }) => {
|
|
289
|
+
const FakeSQLEditorModal = ({ children, isOpen, }) => {
|
|
999
290
|
if (!isOpen)
|
|
1000
291
|
return null;
|
|
1001
292
|
return _jsx("div", { style: { height: '100%' }, children: children });
|
|
1002
293
|
};
|
|
1003
|
-
function QuillReport({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpen, SecondaryButtonComponent, ButtonComponent, deleteReport, handleSave, updateQuery, OrganizationSelectComponent, ModalComponent, NavigateToDashboardBuilder, }) {
|
|
294
|
+
function QuillReport({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpen, SecondaryButtonComponent, ButtonComponent, deleteReport, handleSave, updateQuery, OrganizationSelectComponent, ModalComponent = MemoizedModal, NavigateToDashboardBuilder, }) {
|
|
1004
295
|
const { state, dispatch } = useAdmin();
|
|
1005
296
|
const { data, loading, error } = useQuill(reportId);
|
|
297
|
+
const parentRef = useRef(null);
|
|
298
|
+
const [modalWidth, setModalWidth] = useState(200);
|
|
299
|
+
const [modalHeight, setModalHeight] = useState(200);
|
|
1006
300
|
const [isOpenChartBuilder, setIsOpenChartBuilder] = useState(false);
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
301
|
+
const [selectedOrgName, setSelectedOrgName] = useState('');
|
|
302
|
+
const handleResize = useCallback(() => {
|
|
303
|
+
const screenSize = window.innerWidth;
|
|
304
|
+
const isEditQuery = state.activeQuery && state.activeEditItem;
|
|
305
|
+
if (isOpenChartBuilder && !isEditQuery && screenSize < 1200) {
|
|
306
|
+
setModalWidth(undefined); // use dynamic width of contents
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
setModalWidth(window.innerWidth - 80);
|
|
310
|
+
}
|
|
311
|
+
setModalHeight(window.innerHeight - 80);
|
|
312
|
+
}, [isOpenChartBuilder, state.activeQuery, state.activeEditItem]);
|
|
313
|
+
useEffect(() => {
|
|
314
|
+
handleResize();
|
|
315
|
+
window.addEventListener('resize', handleResize);
|
|
316
|
+
return () => {
|
|
317
|
+
window.removeEventListener('resize', handleResize);
|
|
318
|
+
};
|
|
319
|
+
}, [handleResize]);
|
|
320
|
+
useEffect(() => {
|
|
321
|
+
const selectedOrg = state.organizations.find((org) => {
|
|
322
|
+
const orgId = org.id ? org.id : org.ID;
|
|
323
|
+
return orgId && String(orgId) === String(state.organizationId);
|
|
324
|
+
});
|
|
325
|
+
if (selectedOrg) {
|
|
326
|
+
setSelectedOrgName(selectedOrg.name ? selectedOrg.name : selectedOrg.NAME);
|
|
327
|
+
}
|
|
328
|
+
}, [state.organizations, state.organizationId]);
|
|
329
|
+
const handleSetIsOpen = (isOpen) => {
|
|
330
|
+
if (!isOpen) {
|
|
1016
331
|
dispatch({
|
|
1017
332
|
type: 'SET_ACTIVE_QUERY',
|
|
1018
333
|
payload: '',
|
|
1019
334
|
});
|
|
1020
335
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
border: '1px solid #e7e7e7',
|
|
1061
|
-
borderRadius: 6,
|
|
1062
|
-
outline: 'none',
|
|
1063
|
-
cursor: 'pointer',
|
|
1064
|
-
fontFamily: theme?.fontFamily,
|
|
1065
|
-
fontWeight: theme?.buttonFontWeight || 500,
|
|
1066
|
-
fontSize: 14,
|
|
1067
|
-
padding: '0px 12px',
|
|
1068
|
-
display: 'flex',
|
|
1069
|
-
flexDirection: 'row',
|
|
1070
|
-
alignItems: 'center',
|
|
1071
|
-
gap: 5,
|
|
1072
|
-
}, onClick: () => {
|
|
1073
|
-
if (state.activeQuery && state.activeEditItem) {
|
|
1074
|
-
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
336
|
+
}
|
|
337
|
+
setIsOpenChartBuilder(isOpen);
|
|
338
|
+
setIsOpen(isOpen);
|
|
339
|
+
};
|
|
340
|
+
if (!data || loading) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
return (_jsx("div", { ref: parentRef, children: _jsx(ModalComponent, { isOpen: isOpen, setIsOpen: handleSetIsOpen, title: data.name || 'Report Detail', width: modalWidth, height: modalHeight, children: _jsxs("div", { style: {
|
|
344
|
+
width: '100%',
|
|
345
|
+
height: 'calc(100% - 52px)', // full height minus header height
|
|
346
|
+
display: 'flex',
|
|
347
|
+
flexDirection: 'column',
|
|
348
|
+
flexGrow: 1,
|
|
349
|
+
}, children: [_jsxs("div", { style: {
|
|
350
|
+
display: 'flex',
|
|
351
|
+
alignItems: 'center',
|
|
352
|
+
gap: 16,
|
|
353
|
+
padding: 15,
|
|
354
|
+
}, children: [_jsxs("button", { style: {
|
|
355
|
+
height: 36,
|
|
356
|
+
color: theme?.secondaryTextColor,
|
|
357
|
+
border: '1px solid #e7e7e7',
|
|
358
|
+
borderRadius: 6,
|
|
359
|
+
outline: 'none',
|
|
360
|
+
cursor: 'pointer',
|
|
361
|
+
fontFamily: theme?.fontFamily,
|
|
362
|
+
fontWeight: theme?.buttonFontWeight || 500,
|
|
363
|
+
fontSize: 14,
|
|
364
|
+
padding: '0px 12px',
|
|
365
|
+
display: 'flex',
|
|
366
|
+
flexDirection: 'row',
|
|
367
|
+
alignItems: 'center',
|
|
368
|
+
gap: 5,
|
|
369
|
+
}, onClick: () => {
|
|
370
|
+
setIsOpenChartBuilder((showEditChart) => !showEditChart);
|
|
371
|
+
dispatch({
|
|
372
|
+
type: 'SET_ACTIVE_QUERY',
|
|
373
|
+
payload: '',
|
|
374
|
+
});
|
|
1075
375
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
376
|
+
}, className: "secondary-button-quill", children: [_jsx("style", { children: `.secondary-button-quill { background: white } .secondary-button-quill:hover { background: #F4F4F5 }` }), _jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: "currentColor", height: 15, width: 15, children: [_jsx("path", { d: "M12 9a1 1 0 0 1-1-1V3c0-.552.45-1.007.997-.93a7.004 7.004 0 0 1 5.933 5.933c.078.547-.378.997-.93.997h-5Z" }), _jsx("path", { d: "M8.003 4.07C8.55 3.994 9 4.449 9 5v5a1 1 0 0 0 1 1h5c.552 0 1.008.45.93.997A7.001 7.001 0 0 1 2 11a7.002 7.002 0 0 1 6.003-6.93Z" })] }), "Edit chart"] }), _jsxs("button", { style: {
|
|
377
|
+
height: 36,
|
|
378
|
+
color: theme?.secondaryTextColor,
|
|
379
|
+
border: '1px solid #e7e7e7',
|
|
380
|
+
borderRadius: 6,
|
|
381
|
+
outline: 'none',
|
|
382
|
+
cursor: 'pointer',
|
|
383
|
+
fontFamily: theme?.fontFamily,
|
|
384
|
+
fontWeight: theme?.buttonFontWeight || 500,
|
|
385
|
+
fontSize: 14,
|
|
386
|
+
padding: '0px 12px',
|
|
387
|
+
display: 'flex',
|
|
388
|
+
flexDirection: 'row',
|
|
389
|
+
alignItems: 'center',
|
|
390
|
+
gap: 5,
|
|
391
|
+
}, onClick: () => {
|
|
392
|
+
if (state.activeQuery && state.activeEditItem) {
|
|
393
|
+
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
394
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
dispatch({
|
|
398
|
+
type: 'SET_ACTIVE_QUERY',
|
|
399
|
+
payload: data.queryString,
|
|
400
|
+
});
|
|
401
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: data });
|
|
402
|
+
}, className: "secondary-button-quill", children: [_jsx("style", { children: `.secondary-button-quill { background: white } .secondary-button-quill:hover { background: #F4F4F5 }` }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", height: 12, width: 12, children: _jsx("path", { d: "M21.731 2.269a2.625 2.625 0 0 0-3.712 0l-1.157 1.157 3.712 3.712 1.157-1.157a2.625 2.625 0 0 0 0-3.712ZM19.513 8.199l-3.712-3.712-12.15 12.15a5.25 5.25 0 0 0-1.32 2.214l-.8 2.685a.75.75 0 0 0 .933.933l2.685-.8a5.25 5.25 0 0 0 2.214-1.32L19.513 8.2Z" }) }), "Edit query"] }), _jsxs("button", { style: {
|
|
403
|
+
height: 36,
|
|
404
|
+
color: theme?.secondaryTextColor,
|
|
405
|
+
border: '1px solid #e7e7e7',
|
|
406
|
+
borderRadius: 6,
|
|
407
|
+
outline: 'none',
|
|
408
|
+
cursor: 'pointer',
|
|
409
|
+
fontFamily: theme?.fontFamily,
|
|
410
|
+
fontWeight: theme?.buttonFontWeight || 500,
|
|
411
|
+
fontSize: 14,
|
|
412
|
+
padding: '0px 12px',
|
|
413
|
+
display: 'flex',
|
|
414
|
+
flexDirection: 'row',
|
|
415
|
+
alignItems: 'center',
|
|
416
|
+
gap: 4,
|
|
417
|
+
}, onClick: deleteReport, className: "secondary-button-quill", children: [_jsx("style", { children: `.secondary-button-quill { background: white } .secondary-button-quill:hover { background: #F4F4F5 }` }), _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: "currentColor", height: 14, width: 14, children: _jsx("path", { fillRule: "evenodd", d: "M8.75 1A2.75 2.75 0 0 0 6 3.75v.443c-.795.077-1.584.176-2.365.298a.75.75 0 1 0 .23 1.482l.149-.022.841 10.518A2.75 2.75 0 0 0 7.596 19h4.807a2.75 2.75 0 0 0 2.742-2.53l.841-10.52.149.023a.75.75 0 0 0 .23-1.482A41.03 41.03 0 0 0 14 4.193V3.75A2.75 2.75 0 0 0 11.25 1h-2.5ZM10 4c.84 0 1.673.025 2.5.075V3.75c0-.69-.56-1.25-1.25-1.25h-2.5c-.69 0-1.25.56-1.25 1.25v.325C8.327 4.025 9.16 4 10 4ZM8.58 7.72a.75.75 0 0 0-1.5.06l.3 7.5a.75.75 0 1 0 1.5-.06l-.3-7.5Zm4.34.06a.75.75 0 1 0-1.5-.06l-.3 7.5a.75.75 0 1 0 1.5.06l.3-7.5Z", clipRule: "evenodd" }) }), "Delete"] })] }), _jsx("div", { style: {
|
|
418
|
+
display: 'flex',
|
|
419
|
+
flexDirection: 'row',
|
|
420
|
+
height: 'calc(100% - 66px)', // full height minus button container
|
|
421
|
+
flexGrow: 1,
|
|
422
|
+
}, children: _jsx("div", { style: {
|
|
423
|
+
width: '100%',
|
|
424
|
+
height: '100%',
|
|
425
|
+
overflowX: 'hidden',
|
|
426
|
+
overflowY: 'auto',
|
|
427
|
+
}, children: state.activeEditItem && state.activeQuery ? (_jsx(QueryEditor, { onSave: handleSave })) : (_jsx(ChartEditor, { isOpen: isOpenChartBuilder, setIsOpen: setIsOpenChartBuilder, reportId: reportId, isAdmin: true, organizationName: selectedOrgName, onDelete: deleteReport, onAddToDashboardComplete: (report) => {
|
|
428
|
+
const dashboard = state.dashboards.find((dash) => {
|
|
429
|
+
return dash.name === report.dashboardName;
|
|
430
|
+
});
|
|
431
|
+
dispatch({
|
|
432
|
+
type: 'SET_SELECTED_DASHBOARD',
|
|
433
|
+
payload: dashboard,
|
|
434
|
+
});
|
|
435
|
+
handleSave();
|
|
436
|
+
}, isHorizontalView: true, ModalComponent: FakeModal, ButtonComponent: MemoizedButton })) }) })] }) }) }));
|
|
1111
437
|
}
|
|
1112
|
-
function QueryEditor() {
|
|
438
|
+
function QueryEditor({ onSave }) {
|
|
1113
439
|
const { state, dispatch } = useAdmin();
|
|
1114
|
-
|
|
440
|
+
const [selectedOrgName, setSelectedOrgName] = useState('');
|
|
441
|
+
useEffect(() => {
|
|
442
|
+
const selectedOrg = state.organizations.find((org) => {
|
|
443
|
+
const orgId = org.id ? org.id : org.ID;
|
|
444
|
+
return orgId && String(orgId) === String(state.organizationId);
|
|
445
|
+
});
|
|
446
|
+
if (selectedOrg) {
|
|
447
|
+
setSelectedOrgName(selectedOrg.name ? selectedOrg.name : selectedOrg.NAME);
|
|
448
|
+
}
|
|
449
|
+
}, [state.organizations, state.organizationId]);
|
|
450
|
+
if (state.activeEditItem &&
|
|
451
|
+
state.activeEditItem.referencedTables &&
|
|
452
|
+
state.activeEditItem.referencedTables.length === 1 &&
|
|
453
|
+
state.activeQuery &&
|
|
454
|
+
!state.activeQuery.match(/^\s*with\s/i) &&
|
|
455
|
+
!hasColumnAlias(state.activeEditItem.columns, state.activeEditItem.referencedColumns[state.activeEditItem.referencedTables[0]] || undefined)) {
|
|
456
|
+
return (_jsx(ReportBuilder, { isAdminEnabled: true,
|
|
457
|
+
// initialTableName={state.tables.length > 0 && state.tables[0]!.name}
|
|
458
|
+
reportId: state.activeEditItem.id, onSubmitEditReport: (report) => {
|
|
459
|
+
const dashboard = state.dashboards.find((dash) => {
|
|
460
|
+
return dash.name === report.dashboardName;
|
|
461
|
+
});
|
|
462
|
+
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
463
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
464
|
+
dispatch({
|
|
465
|
+
type: 'SET_SELECTED_DASHBOARD',
|
|
466
|
+
payload: dashboard,
|
|
467
|
+
});
|
|
468
|
+
onSave(); // refresh the dashboard in the background
|
|
469
|
+
}, organizationName: selectedOrgName, isChartBuilderHorizontalView: true,
|
|
470
|
+
// @ts-ignore
|
|
471
|
+
ChartBuilderModalComponent: FakeSQLEditorModal, containerStyle: {
|
|
472
|
+
height: '100%',
|
|
473
|
+
width: '100%',
|
|
474
|
+
} }));
|
|
475
|
+
}
|
|
476
|
+
return (_jsx(SQLEditor, { isChartBuilderHorizontalView: true, isChartBuilderEnabled: true, showAccessControlOptions: true, showDateFieldOptions: true, showTableFormatOptions: true, defaultQuery: state.activeQuery, addToDashboardButtonLabel: state.activeQuery ? 'Save changes' : 'Add to dashboard', chartBuilderTitle: state.activeQuery ? 'Save changes' : 'Add to dashboard', report: state.activeQuery ? state.activeEditItem : undefined, onAddToDashboardComplete: (report) => {
|
|
477
|
+
const dashboard = state.dashboards.find((dash) => {
|
|
478
|
+
return dash.name === report.dashboardName;
|
|
479
|
+
});
|
|
1115
480
|
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
1116
481
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
482
|
+
dispatch({
|
|
483
|
+
type: 'SET_SELECTED_DASHBOARD',
|
|
484
|
+
payload: dashboard,
|
|
485
|
+
});
|
|
486
|
+
onSave(); // refresh the dashboard in the background
|
|
1117
487
|
}, containerStyle: {
|
|
1118
488
|
height: '100%',
|
|
1119
489
|
width: '100%',
|
|
1120
|
-
}, organizationName:
|
|
1121
|
-
|
|
1122
|
-
|
|
490
|
+
}, organizationName: selectedOrgName,
|
|
491
|
+
// @ts-ignore
|
|
492
|
+
ModalComponent: FakeSQLEditorModal, ButtonComponent: MemoizedButton }));
|
|
1123
493
|
}
|
|
1124
494
|
export function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, organizationId, queryEndpoint, queryHeaders, withCredentials, isOpen, setIsOpen, reloadDashboard, }) {
|
|
1125
495
|
const { state, dispatch } = useAdmin();
|
|
@@ -1160,7 +530,7 @@ export function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, Modal
|
|
|
1160
530
|
headers: {
|
|
1161
531
|
'Content-Type': 'application/json',
|
|
1162
532
|
Authorization: 'Bearer ',
|
|
1163
|
-
environment: state.environment
|
|
533
|
+
environment: state.environment,
|
|
1164
534
|
},
|
|
1165
535
|
body: JSON.stringify(requestBody),
|
|
1166
536
|
});
|
|
@@ -1221,7 +591,7 @@ export function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, Modal
|
|
|
1221
591
|
method: 'POST',
|
|
1222
592
|
headers: {
|
|
1223
593
|
'Content-Type': 'application/json',
|
|
1224
|
-
environment: state.environment
|
|
594
|
+
environment: state.environment,
|
|
1225
595
|
},
|
|
1226
596
|
body: JSON.stringify(requestBody),
|
|
1227
597
|
});
|
|
@@ -1238,144 +608,3 @@ export function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, Modal
|
|
|
1238
608
|
};
|
|
1239
609
|
return (_jsx(QuillReport, { reportId: state.reportId, updateQuery: updateQuery, isOpen: isOpen, setIsOpen: setIsOpen, isEditQueryOpen: isEditQueryOpen, setIsEditQueryOpen: setIsEditQueryOpen, deleteReport: deleteReport, handleSave: handleSave, SecondaryButtonComponent: SecondaryButtonComponent, ButtonComponent: ButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, OrganizationSelectComponent: OrganizationSelectComponent }));
|
|
1240
610
|
}
|
|
1241
|
-
const measuringConfig = {
|
|
1242
|
-
droppable: {
|
|
1243
|
-
strategy: MeasuringStrategy.Always,
|
|
1244
|
-
},
|
|
1245
|
-
};
|
|
1246
|
-
export function ReorderableList({ initialItems, client, itemMap, ButtonComponent, closeModal, onSave, }) {
|
|
1247
|
-
const [items, setItems] = useState([]);
|
|
1248
|
-
// const [client] = useContext(ClientContext);
|
|
1249
|
-
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, {
|
|
1250
|
-
coordinateGetter: sortableKeyboardCoordinates,
|
|
1251
|
-
}), useSensor(TouchSensor, {
|
|
1252
|
-
activationConstraint: '',
|
|
1253
|
-
}));
|
|
1254
|
-
useEffect(() => {
|
|
1255
|
-
setItems(initialItems
|
|
1256
|
-
.sort((a, b) => {
|
|
1257
|
-
if (a.order === undefined && b.order === undefined)
|
|
1258
|
-
return 0; // both items don't have the 'order' field
|
|
1259
|
-
if (a.order === undefined)
|
|
1260
|
-
return 1; // only 'a' doesn't have the 'order' field, place 'a' last
|
|
1261
|
-
if (b.order === undefined)
|
|
1262
|
-
return -1; // only 'b' doesn't have the 'order' field, place 'b' last
|
|
1263
|
-
return a.order - b.order; // both items have the 'order' field, sort numerically
|
|
1264
|
-
})
|
|
1265
|
-
.map((elem) => elem._id));
|
|
1266
|
-
}, [initialItems]);
|
|
1267
|
-
const handleSaveChanges = async () => {
|
|
1268
|
-
if (!client) {
|
|
1269
|
-
return;
|
|
1270
|
-
}
|
|
1271
|
-
if (!items.length) {
|
|
1272
|
-
return;
|
|
1273
|
-
}
|
|
1274
|
-
try {
|
|
1275
|
-
const response = await fetch(`${QUILL_SERVER}/dashorder/`, {
|
|
1276
|
-
method: 'POST',
|
|
1277
|
-
headers: {
|
|
1278
|
-
'Content-Type': 'application/json',
|
|
1279
|
-
},
|
|
1280
|
-
body: JSON.stringify({
|
|
1281
|
-
publicKey: client._id,
|
|
1282
|
-
orderArray: items,
|
|
1283
|
-
}),
|
|
1284
|
-
});
|
|
1285
|
-
if (!response.ok) {
|
|
1286
|
-
const errorData = await response.json();
|
|
1287
|
-
throw new Error(`Error: ${errorData.error || 'Unknown error'}`);
|
|
1288
|
-
}
|
|
1289
|
-
const data = await response.json();
|
|
1290
|
-
await onSave();
|
|
1291
|
-
closeModal();
|
|
1292
|
-
}
|
|
1293
|
-
catch (error) {
|
|
1294
|
-
console.error(error.message);
|
|
1295
|
-
}
|
|
1296
|
-
};
|
|
1297
|
-
return (_jsxs("div", { children: [_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, measuring: measuringConfig, children: _jsx(SortableContext, { items: items, strategy: verticalListSortingStrategy, children: _jsxs("div", { style: {
|
|
1298
|
-
background: 'white',
|
|
1299
|
-
position: 'fixed',
|
|
1300
|
-
width: '100%',
|
|
1301
|
-
height: 'calc(100% - 40px)',
|
|
1302
|
-
overflowY: 'scroll',
|
|
1303
|
-
overflowX: 'hidden',
|
|
1304
|
-
maxWidth: 700,
|
|
1305
|
-
}, children: [_jsx("div", { style: { height: 80 } }), items.map((id) => (_jsx(SortableItem, { id: id, name: itemMap?.get(id).name }, id))), _jsx("div", { style: { height: 100, width: '100%' } })] }) }) }), _jsx("div", { style: {
|
|
1306
|
-
height: 80,
|
|
1307
|
-
paddingTop: 20,
|
|
1308
|
-
width: '100%',
|
|
1309
|
-
background: 'white',
|
|
1310
|
-
position: 'absolute',
|
|
1311
|
-
bottom: -20,
|
|
1312
|
-
left: 0,
|
|
1313
|
-
right: 0,
|
|
1314
|
-
}, children: _jsx(ButtonComponent, { onClick: handleSaveChanges, label: "Save changes" }) })] }));
|
|
1315
|
-
function handleDragEnd(event) {
|
|
1316
|
-
const { active, over } = event;
|
|
1317
|
-
if (!over?.id || !active?.id) {
|
|
1318
|
-
return;
|
|
1319
|
-
}
|
|
1320
|
-
if (active.id !== over.id) {
|
|
1321
|
-
setItems((items) => {
|
|
1322
|
-
const oldIndex = items.indexOf(active.id);
|
|
1323
|
-
const newIndex = items.indexOf(over.id);
|
|
1324
|
-
return arrayMove(items, oldIndex, newIndex);
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
}
|
|
1328
|
-
}
|
|
1329
|
-
const animateLayoutChanges = (args) => args.isSorting || args.wasDragging ? defaultAnimateLayoutChanges(args) : true;
|
|
1330
|
-
function SortableItem({ id, name }) {
|
|
1331
|
-
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
|
1332
|
-
animateLayoutChanges,
|
|
1333
|
-
id: id,
|
|
1334
|
-
});
|
|
1335
|
-
let height = 50;
|
|
1336
|
-
const style = {
|
|
1337
|
-
transform: CSS.Translate.toString(transform),
|
|
1338
|
-
transition,
|
|
1339
|
-
display: 'flex',
|
|
1340
|
-
justifyContent: 'space-between',
|
|
1341
|
-
alignItems: 'center',
|
|
1342
|
-
borderRadius: '10px',
|
|
1343
|
-
border: '1px solid #E7E7E7',
|
|
1344
|
-
boxShadow: '0px 2px 8px 0px rgba(56, 65, 81, 0.08)',
|
|
1345
|
-
cursor: 'grab',
|
|
1346
|
-
userSelect: 'none',
|
|
1347
|
-
marginBottom: 20,
|
|
1348
|
-
background: 'white',
|
|
1349
|
-
};
|
|
1350
|
-
return (_jsx("div", { ref: setNodeRef, style: style, ...attributes, children: _jsxs("div", { style: {
|
|
1351
|
-
cursor: 'pointer',
|
|
1352
|
-
width: '100%',
|
|
1353
|
-
display: 'flex',
|
|
1354
|
-
flexDirection: 'row',
|
|
1355
|
-
alignItems: 'center',
|
|
1356
|
-
justifyContent: 'space-between',
|
|
1357
|
-
height: 260,
|
|
1358
|
-
}, ...listeners, children: [_jsxs("div", { style: {
|
|
1359
|
-
display: 'flex',
|
|
1360
|
-
flexDirection: 'column',
|
|
1361
|
-
justifyContent: 'space-between',
|
|
1362
|
-
height: 260,
|
|
1363
|
-
paddingTop: 20,
|
|
1364
|
-
paddingBottom: 20,
|
|
1365
|
-
width: '100%',
|
|
1366
|
-
}, children: [_jsx("div", { style: {
|
|
1367
|
-
minWidth: 600,
|
|
1368
|
-
width: '100%',
|
|
1369
|
-
paddingLeft: 20,
|
|
1370
|
-
fontSize: 18,
|
|
1371
|
-
fontWeight: '500',
|
|
1372
|
-
}, children: name }), _jsx(Chart, { chartId: id, containerStyle: {
|
|
1373
|
-
height: 180,
|
|
1374
|
-
width: '100%',
|
|
1375
|
-
} })] }), _jsx("div", { style: {
|
|
1376
|
-
display: 'flex',
|
|
1377
|
-
flexDirection: 'column',
|
|
1378
|
-
paddingRight: 20,
|
|
1379
|
-
paddingLeft: 20,
|
|
1380
|
-
}, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", "stroke-width": "1.5", stroke: "#6D727E", height: 24, width: 24, children: _jsx("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9" }) }) })] }) }));
|
|
1381
|
-
}
|