@quillsql/admin 1.5.2 → 1.6.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/cjs/Admin.d.ts +19 -72
- package/dist/cjs/Admin.d.ts.map +1 -1
- package/dist/cjs/Admin.js +200 -994
- package/dist/cjs/AdminProvider.d.ts +0 -11
- package/dist/cjs/AdminProvider.d.ts.map +1 -1
- package/dist/cjs/AdminProvider.js +16 -10
- package/dist/cjs/api/ConnectionClient.d.ts +11 -0
- package/dist/cjs/api/ConnectionClient.d.ts.map +1 -1
- package/dist/cjs/api/ConnectionClient.js +71 -10
- package/dist/cjs/components/DropDownMenu.js +1 -1
- package/dist/cjs/components/DropDownMenuWithLabel.d.ts.map +1 -1
- package/dist/cjs/components/DropDownMenuWithLabel.js +16 -54
- 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 +7 -0
- package/dist/cjs/components/SegmentedControl.d.ts.map +1 -0
- package/dist/cjs/components/SegmentedControl.js +54 -0
- 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 +39 -84
- 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 +39 -10
- package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts +7 -4
- package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
- package/dist/cjs/forms/sql_views/CreateEditSqlView.js +28 -25
- 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 +345 -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 +62 -45
- package/dist/cjs/modals/PromoteDashModal.d.ts.map +1 -1
- package/dist/cjs/modals/PromoteDashModal.js +10 -3
- 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/TogglePrimitive.js +5 -5
- package/dist/cjs/public_components/CreateEnvironment.d.ts.map +1 -1
- package/dist/cjs/public_components/CreateEnvironment.js +1 -1
- package/dist/cjs/public_components/DashboardBuilder.d.ts.map +1 -1
- package/dist/cjs/public_components/DashboardBuilder.js +41 -6
- package/dist/cjs/public_components/DashboardManager.d.ts.map +1 -1
- package/dist/cjs/public_components/DashboardManager.js +47 -83
- package/dist/cjs/public_components/SQLViewManager.d.ts.map +1 -1
- package/dist/cjs/public_components/SQLViewManager.js +69 -20
- package/dist/cjs/utils/schema.d.ts +6 -0
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- 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 +203 -987
- package/dist/esm/AdminProvider.d.ts +0 -11
- package/dist/esm/AdminProvider.d.ts.map +1 -1
- package/dist/esm/AdminProvider.js +16 -10
- package/dist/esm/api/ConnectionClient.d.ts +11 -0
- package/dist/esm/api/ConnectionClient.d.ts.map +1 -1
- package/dist/esm/api/ConnectionClient.js +69 -9
- package/dist/esm/components/DropDownMenu.js +1 -1
- package/dist/esm/components/DropDownMenuWithLabel.d.ts.map +1 -1
- package/dist/esm/components/DropDownMenuWithLabel.js +16 -54
- 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 +7 -0
- package/dist/esm/components/SegmentedControl.d.ts.map +1 -0
- package/dist/esm/components/SegmentedControl.js +50 -0
- 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 +36 -83
- 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 +40 -11
- package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts +7 -4
- package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
- package/dist/esm/forms/sql_views/CreateEditSqlView.js +29 -26
- 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 +338 -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 +62 -45
- package/dist/esm/modals/PromoteDashModal.d.ts.map +1 -1
- package/dist/esm/modals/PromoteDashModal.js +10 -3
- 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/TogglePrimitive.js +5 -5
- package/dist/esm/public_components/CreateEnvironment.d.ts.map +1 -1
- package/dist/esm/public_components/CreateEnvironment.js +1 -1
- package/dist/esm/public_components/DashboardBuilder.d.ts.map +1 -1
- package/dist/esm/public_components/DashboardBuilder.js +41 -6
- package/dist/esm/public_components/DashboardManager.d.ts.map +1 -1
- package/dist/esm/public_components/DashboardManager.js +49 -85
- package/dist/esm/public_components/SQLViewManager.d.ts.map +1 -1
- package/dist/esm/public_components/SQLViewManager.js +69 -20
- package/dist/esm/utils/schema.d.ts +6 -0
- package/dist/esm/utils/schema.d.ts.map +1 -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 +1 -1
- 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/cjs/Admin.js
CHANGED
|
@@ -26,29 +26,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.ReportWrapper = exports.TableCell = exports.getPostgresBasicType = exports.convertPostgresColumn = exports.theme = exports.defaultTheme = void 0;
|
|
30
30
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
-
// @ts-nocheck
|
|
32
31
|
const react_1 = require("react");
|
|
33
32
|
const react_2 = require("@quillsql/react");
|
|
34
33
|
const nightOwlLight_1 = __importDefault(require("prism-react-renderer/themes/nightOwlLight"));
|
|
35
34
|
const prism_react_renderer_1 = __importStar(require("prism-react-renderer"));
|
|
36
|
-
const core_1 = require("@dnd-kit/core");
|
|
37
|
-
const InputLabel_1 = __importDefault(require("./components/InputLabel"));
|
|
38
|
-
const CardSection_1 = __importDefault(require("./components/CardSection"));
|
|
39
|
-
const sortable_1 = require("@dnd-kit/sortable");
|
|
40
|
-
const utilities_1 = require("@dnd-kit/utilities");
|
|
41
35
|
const components_1 = require("./components");
|
|
42
36
|
const AdminProvider_1 = require("./AdminProvider");
|
|
43
37
|
const primitives_1 = require("./primitives");
|
|
38
|
+
const UiComponents_1 = require("./components/UiComponents");
|
|
44
39
|
const DashboardBuilder_1 = __importDefault(require("./public_components/DashboardBuilder"));
|
|
45
40
|
const SQLViewManager_1 = __importDefault(require("./public_components/SQLViewManager"));
|
|
46
41
|
const constants_1 = require("./utils/constants");
|
|
47
|
-
const
|
|
48
|
-
const UiComponents_1 = require("./components/UiComponents");
|
|
42
|
+
const UiComponents_2 = require("./components/UiComponents");
|
|
49
43
|
const react_3 = require("@quillsql/react");
|
|
44
|
+
const table_1 = require("./utils/table");
|
|
50
45
|
// chartColors: ["#6269E9", "#E14F62"],
|
|
51
|
-
|
|
46
|
+
exports.defaultTheme = {
|
|
52
47
|
fontFamily: 'Inter; Helvetica',
|
|
53
48
|
backgroundColor: '#FFFFFF',
|
|
54
49
|
primaryTextColor: '#364153',
|
|
@@ -56,396 +51,23 @@ const defaultTheme = {
|
|
|
56
51
|
chartLabelFontFamily: 'Inter; Helvetica',
|
|
57
52
|
chartLabelColor: '#666666',
|
|
58
53
|
chartTickColor: '#CCCCCC',
|
|
54
|
+
chartColors: ['#6269E9', '#E14F62', '#55B5A6', '#E9A23B', '#D0ACCF'],
|
|
59
55
|
borderColor: '#E5E7EB',
|
|
60
56
|
primaryButtonColor: '#364153',
|
|
61
57
|
borderWidth: 1,
|
|
62
|
-
labelFontWeight:
|
|
58
|
+
labelFontWeight: 500,
|
|
63
59
|
fontSize: 14,
|
|
64
60
|
};
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const [showDateFilter, setShowDateFilter] = (0, react_1.useState)(true);
|
|
76
|
-
const [newDateFilter, setNewDateFilter] = (0, react_1.useState)(null);
|
|
77
|
-
const [selectedTable, setSelectedTable] = (0, react_1.useState)(null);
|
|
78
|
-
const [field, setField] = (0, react_1.useState)('');
|
|
79
|
-
(0, react_1.useEffect)(() => {
|
|
80
|
-
if (data && data.dateFilter) {
|
|
81
|
-
setIsDateComparison(data.dateFilter.comparison);
|
|
82
|
-
dispatch('SET_DATE_FILTER', data.dateFilter);
|
|
83
|
-
}
|
|
84
|
-
setShowDateFilter(Boolean(data?.dateFilter));
|
|
85
|
-
}, [data]);
|
|
86
|
-
(0, react_1.useEffect)(() => {
|
|
87
|
-
setIsDateComparison(!!state.dateFilter?.comparison ?? false);
|
|
88
|
-
}, [state.dateFilter]);
|
|
89
|
-
(0, react_1.useEffect)(() => {
|
|
90
|
-
if (state.tables?.length) {
|
|
91
|
-
const defaultTable = state.tables[0];
|
|
92
|
-
const name = state.editDashboardData?.filters[0]?.table;
|
|
93
|
-
const table = state.tables.find((t) => t.name === name) ?? defaultTable;
|
|
94
|
-
setSelectedTable(table);
|
|
95
|
-
setField(table.columns.map((elem) => elem.name)[0]);
|
|
96
|
-
}
|
|
97
|
-
}, [state.tables, state.editDashboardData]);
|
|
98
|
-
(0, react_1.useEffect)(() => {
|
|
99
|
-
if (dashboardData && dashboardData.filters) {
|
|
100
|
-
setNewFilters(dashboardData.filters);
|
|
101
|
-
}
|
|
102
|
-
if (dashboardData && dashboardData.dateFilter) {
|
|
103
|
-
setNewDateFilter(dashboardData.dateFilter);
|
|
104
|
-
}
|
|
105
|
-
}, [dashboardData]);
|
|
106
|
-
const handleAddFilter = async () => {
|
|
107
|
-
setNewFilters([...newFilters, { label: '' }]);
|
|
108
|
-
};
|
|
109
|
-
const handleSubmitDashboardChanges = async () => {
|
|
110
|
-
if (!selectedDashboardName ||
|
|
111
|
-
newFilters.some((filter) => !filter.label) ||
|
|
112
|
-
(newDateFilter &&
|
|
113
|
-
Object.keys(newDateFilter).length &&
|
|
114
|
-
!newDateFilter.label)) {
|
|
115
|
-
alert('Empty fields');
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
if (newFilters.filter((elem) => !elem.field).length) {
|
|
119
|
-
alert(`no filter field for: ${newFilters.filter((elem) => !elem.field)[0].label}`);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const updatedFilters = newFilters.map((filter) => {
|
|
123
|
-
const table = state.tables.find((table) => table.name === filter.table);
|
|
124
|
-
const filterType = getPostgresBasicType(table.columns.find((col) => col.name === filter.field));
|
|
125
|
-
return {
|
|
126
|
-
table: filter.table,
|
|
127
|
-
field: filter.field,
|
|
128
|
-
labelField: filter.field,
|
|
129
|
-
label: filter.label,
|
|
130
|
-
filterType,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
if (dashNames &&
|
|
134
|
-
dashNames.length > 0 &&
|
|
135
|
-
dashNames.some((dashName) => dashName.name === selectedDashboardName &&
|
|
136
|
-
selectedDashboardName !== selectedDashboard)) {
|
|
137
|
-
alert('Dashboard name already taken!');
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
const fieldsSet = new Set();
|
|
141
|
-
const hasDuplicateField = updatedFilters.some((filter) => {
|
|
142
|
-
if (fieldsSet.has(filter.field)) {
|
|
143
|
-
return true;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
fieldsSet.add(filter.field);
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
if (hasDuplicateField ||
|
|
151
|
-
(newDateFilter &&
|
|
152
|
-
Object.keys(newDateFilter).length > 0 &&
|
|
153
|
-
updatedFilters.some((filter) => filter.filterType === 'date'))) {
|
|
154
|
-
alert('Maximum of one filter per field');
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
let allValid = true;
|
|
158
|
-
updatedFilters.forEach((filter) => {
|
|
159
|
-
if (filter.filterType !== 'string' && filter.filterType !== 'date') {
|
|
160
|
-
allValid = false;
|
|
161
|
-
console.error(`Invalid filterType found: ${filter.filterType}`);
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
if (!allValid) {
|
|
165
|
-
alert('We only support string and filters.');
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const url = `${constants_1.QUILL_SERVER}/dashfilter/${client._id}/`;
|
|
169
|
-
const body = {
|
|
170
|
-
newDashboardName: selectedDashboardName,
|
|
171
|
-
filters: updatedFilters,
|
|
172
|
-
dateFilter: newDateFilter
|
|
173
|
-
? {
|
|
174
|
-
...newDateFilter,
|
|
175
|
-
comparison: isDateComparison,
|
|
176
|
-
primaryRange: initialRange,
|
|
177
|
-
}
|
|
178
|
-
: null,
|
|
179
|
-
name: selectedDashboard,
|
|
180
|
-
databaseType: state.client.databaseType,
|
|
181
|
-
};
|
|
182
|
-
dispatch({ type: 'SET_DATE_FILTER', payload: body.dateFilter });
|
|
183
|
-
const headers = {
|
|
184
|
-
'Content-Type': 'application/json',
|
|
185
|
-
Authorization: `Bearer `,
|
|
186
|
-
};
|
|
187
|
-
try {
|
|
188
|
-
const response = await fetch(url, {
|
|
189
|
-
method: 'POST',
|
|
190
|
-
headers: headers,
|
|
191
|
-
body: JSON.stringify(body),
|
|
192
|
-
});
|
|
193
|
-
await onSave();
|
|
194
|
-
setSelectedEditDashboard(null);
|
|
195
|
-
setIsOpen(false);
|
|
196
|
-
}
|
|
197
|
-
catch (e) {
|
|
198
|
-
console.log('error');
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
const handleDeleteFilter = (filter) => {
|
|
202
|
-
setNewFilters(newFilters.filter((f) => f !== filter));
|
|
203
|
-
};
|
|
204
|
-
const handleDeleteDateFilter = async () => {
|
|
205
|
-
setShowDateFilter(false);
|
|
206
|
-
setNewDateFilter(null);
|
|
207
|
-
};
|
|
208
|
-
const handleAddDateFilter = async () => {
|
|
209
|
-
setShowDateFilter(true);
|
|
210
|
-
if (dashboardData && dashboardData.dateFilter) {
|
|
211
|
-
setNewDateFilter(dashboardData.dateFilter);
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
const handleDeleteDashboard = async () => {
|
|
215
|
-
if (confirm('Are you sure? This action cannot be undone.')) {
|
|
216
|
-
const URL = `${constants_1.QUILL_SERVER}/dashboard/${selectedDashboard}`;
|
|
217
|
-
await fetch(URL, {
|
|
218
|
-
method: 'DELETE',
|
|
219
|
-
headers: { 'Content-Type': 'application/json' },
|
|
220
|
-
body: JSON.stringify({
|
|
221
|
-
clientId: client._id,
|
|
222
|
-
databaseType: state.client.databaseType,
|
|
223
|
-
}),
|
|
224
|
-
});
|
|
225
|
-
setIsOpen(false);
|
|
226
|
-
setNewFilters([]);
|
|
227
|
-
await onSave();
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => {
|
|
231
|
-
setIsOpen(false);
|
|
232
|
-
setNewFilters([]);
|
|
233
|
-
setIsDateComparison(state.dateFilter?.comparison ?? false);
|
|
234
|
-
}, style: {
|
|
235
|
-
minWidth: '814px',
|
|
236
|
-
maxWidth: '814px',
|
|
237
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
238
|
-
display: 'flex',
|
|
239
|
-
gap: 16,
|
|
240
|
-
flexDirection: 'column',
|
|
241
|
-
width: '100%',
|
|
242
|
-
height: '100%',
|
|
243
|
-
maxHeight: '100%',
|
|
244
|
-
overflowY: 'auto',
|
|
245
|
-
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Manage dashboard" }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Name" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(TextInputComponent, { value: selectedDashboardName, onChange: (e) => setSelectedDashboardName(e.target.value) }) })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
246
|
-
display: 'flex',
|
|
247
|
-
flexDirection: 'column',
|
|
248
|
-
gap: '10px',
|
|
249
|
-
}, children: [(0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Date Filter" }), showDateFilter && ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
250
|
-
display: 'flex',
|
|
251
|
-
flexDirection: 'row',
|
|
252
|
-
gap: '10px',
|
|
253
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Label" }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
254
|
-
display: 'flex',
|
|
255
|
-
flexDirection: 'row',
|
|
256
|
-
alignItems: 'center',
|
|
257
|
-
}, children: (0, jsx_runtime_1.jsx)(TextInputComponent, { value: newDateFilter?.label, onChange: (e) => {
|
|
258
|
-
setNewDateFilter({
|
|
259
|
-
...newDateFilter,
|
|
260
|
-
label: e.target.value,
|
|
261
|
-
});
|
|
262
|
-
} }) })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
263
|
-
display: 'flex',
|
|
264
|
-
flexDirection: 'row',
|
|
265
|
-
gap: '10px',
|
|
266
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Initial Range" }), (0, jsx_runtime_1.jsx)(SelectComponent, { value: initialRange.label, onChange: (e) => {
|
|
267
|
-
setInitialRange(constants_1.InitialDateRangeOptions.find((table) => table.label === e) ?? initialRange);
|
|
268
|
-
}, options: constants_1.InitialDateRangeOptions.map((table) => {
|
|
269
|
-
return { label: table.label, value: table.label };
|
|
270
|
-
}) })] }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
271
|
-
display: 'flex',
|
|
272
|
-
flexDirection: 'row',
|
|
273
|
-
gap: '10px',
|
|
274
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
275
|
-
display: 'flex',
|
|
276
|
-
flexDirection: 'column',
|
|
277
|
-
}, children: [(0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Date Comparison" }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
278
|
-
display: 'flex',
|
|
279
|
-
flexDirection: 'column',
|
|
280
|
-
justifyContent: 'center',
|
|
281
|
-
height: '100%',
|
|
282
|
-
minWidth: 200,
|
|
283
|
-
maxWidth: 200,
|
|
284
|
-
width: 200,
|
|
285
|
-
}, children: (0, jsx_runtime_1.jsx)(TogglePrimitive_1.default, { value: isDateComparison, onClick: () => {
|
|
286
|
-
setIsDateComparison((isDateComparison) => !isDateComparison);
|
|
287
|
-
} }) })] }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
288
|
-
display: 'flex',
|
|
289
|
-
flexGrow: 1,
|
|
290
|
-
flexDirection: 'row',
|
|
291
|
-
alignItems: 'end',
|
|
292
|
-
justifyContent: 'end',
|
|
293
|
-
gap: '10px',
|
|
294
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
295
|
-
display: 'flex',
|
|
296
|
-
flexDirection: 'column',
|
|
297
|
-
justifyContent: 'center',
|
|
298
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteDateFilter(), style: {
|
|
299
|
-
height: 38,
|
|
300
|
-
width: 42,
|
|
301
|
-
alignItems: 'center',
|
|
302
|
-
justifyContent: 'center',
|
|
303
|
-
display: 'flex',
|
|
304
|
-
cursor: 'pointer',
|
|
305
|
-
}, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.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 && ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAddDateFilter, label: "Add date filter +" }) }))] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
306
|
-
display: 'flex',
|
|
307
|
-
flexDirection: 'row',
|
|
308
|
-
alignItems: 'center',
|
|
309
|
-
justifyContent: 'space-between',
|
|
310
|
-
marginTop: 20,
|
|
311
|
-
}, children: (0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Filters" }) }), newFilters.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: '6px' }, children: newFilters.map((filter, index) => {
|
|
312
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
313
|
-
display: 'flex',
|
|
314
|
-
flexDirection: 'row',
|
|
315
|
-
gap: '10px',
|
|
316
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
317
|
-
display: 'flex',
|
|
318
|
-
flexDirection: 'column',
|
|
319
|
-
maxWidth: 300,
|
|
320
|
-
}, children: [index === 0 && (0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: filter.label, onChange: (e) => {
|
|
321
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
322
|
-
? { ...otherFilter, label: e.target.value }
|
|
323
|
-
: otherFilter);
|
|
324
|
-
setNewFilters(updatedFilters);
|
|
325
|
-
}, width: "230px" })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
326
|
-
display: 'flex',
|
|
327
|
-
flexDirection: 'column',
|
|
328
|
-
maxWidth: 300,
|
|
329
|
-
}, children: [index === 0 && (0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter.table, onChange: (e) => {
|
|
330
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
331
|
-
? { ...otherFilter, table: e }
|
|
332
|
-
: otherFilter);
|
|
333
|
-
setNewFilters(updatedFilters);
|
|
334
|
-
}, options: [
|
|
335
|
-
{ label: 'Select', value: '' },
|
|
336
|
-
...state.tables.map((table) => {
|
|
337
|
-
return { label: table.name, value: table.name };
|
|
338
|
-
}),
|
|
339
|
-
,
|
|
340
|
-
] })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
341
|
-
display: 'flex',
|
|
342
|
-
flexDirection: 'column',
|
|
343
|
-
maxWidth: 300,
|
|
344
|
-
}, children: [index === 0 && (0, jsx_runtime_1.jsx)(InputLabel_1.default, { children: "Field" }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
345
|
-
display: 'flex',
|
|
346
|
-
flexDirection: 'column',
|
|
347
|
-
alignItems: 'center',
|
|
348
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
349
|
-
display: 'flex',
|
|
350
|
-
flexDirection: 'row',
|
|
351
|
-
alignItems: 'center',
|
|
352
|
-
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : '', options: state.tables
|
|
353
|
-
.find((table) => table.name === filter.table)
|
|
354
|
-
?.columns.map((column) => {
|
|
355
|
-
return {
|
|
356
|
-
label: column.name,
|
|
357
|
-
value: column.name,
|
|
358
|
-
};
|
|
359
|
-
}), onChange: (e) => {
|
|
360
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
361
|
-
? { ...otherFilter, field: e }
|
|
362
|
-
: otherFilter);
|
|
363
|
-
setNewFilters(updatedFilters);
|
|
364
|
-
} }), (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteFilter(filter), style: {
|
|
365
|
-
height: 38,
|
|
366
|
-
width: 42,
|
|
367
|
-
alignItems: 'center',
|
|
368
|
-
justifyContent: 'center',
|
|
369
|
-
display: 'flex',
|
|
370
|
-
cursor: 'pointer',
|
|
371
|
-
}, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.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));
|
|
372
|
-
}) })), (0, jsx_runtime_1.jsx)("div", { style: { height: 12 } }), (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleAddFilter, label: "Add filter +" })] }), (0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Chart order" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: () => openEditOrderModal(selectedDashboardName), label: "Edit chart order" }) }), (0, jsx_runtime_1.jsx)(CardSection_1.default, { children: "Danger Zone" }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleDeleteDashboard, label: "Delete Dashboard" }) }), (0, jsx_runtime_1.jsx)("div", { style: { height: 18 } }), (0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 230 }, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleSubmitDashboardChanges, label: "Save changes" }) })] }) }));
|
|
373
|
-
}
|
|
374
|
-
exports.EditFiltersModal = EditFiltersModal;
|
|
375
|
-
function AddFilterModal({ isOpen, selectedDashboard, client, setIsOpen, ModalComponent, TextInputComponent, SelectComponent, HeaderComponent, ButtonComponent, openAddDashboardModal, }) {
|
|
376
|
-
const [selectedTable, setSelectedTable] = (0, react_1.useState)(null);
|
|
377
|
-
const [name, setName] = (0, react_1.useState)('');
|
|
378
|
-
const [field, setField] = (0, react_1.useState)('');
|
|
379
|
-
const [filterType, setFilterType] = (0, react_1.useState)('string');
|
|
380
|
-
const [dateRange, setDateRange] = (0, react_1.useState)([new Date(), new Date()]);
|
|
381
|
-
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
382
|
-
(0, react_1.useEffect)(() => {
|
|
383
|
-
if (state.tables?.length) {
|
|
384
|
-
setSelectedTable(state.tables[0]);
|
|
385
|
-
// setField(tables[0].columns.map((elem) => elem.name));
|
|
386
|
-
setField(state.tables[0].columns[0].name);
|
|
387
|
-
}
|
|
388
|
-
}, [state.tables]);
|
|
389
|
-
const handleAddFilter = async () => {
|
|
390
|
-
if (!selectedTable || !field) {
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
const filterType = getPostgresBasicType(selectedTable.columns.find((col) => col.name === field));
|
|
394
|
-
if (filterType !== 'string' && filterType !== 'date') {
|
|
395
|
-
alert('We only support string and filters.');
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
let responseData;
|
|
399
|
-
const url = `${constants_1.QUILL_SERVER}/dashfilter/${client._id}/`;
|
|
400
|
-
const body = {
|
|
401
|
-
name: selectedDashboard,
|
|
402
|
-
filter: {
|
|
403
|
-
table: selectedTable.name,
|
|
404
|
-
field: field,
|
|
405
|
-
labelField: field,
|
|
406
|
-
label: name,
|
|
407
|
-
filterType,
|
|
408
|
-
},
|
|
409
|
-
};
|
|
410
|
-
const headers = {
|
|
411
|
-
'Content-Type': 'application/json',
|
|
412
|
-
Authorization: `Bearer `,
|
|
413
|
-
};
|
|
414
|
-
try {
|
|
415
|
-
const response = await fetch(url, {
|
|
416
|
-
method: 'POST',
|
|
417
|
-
headers: headers,
|
|
418
|
-
body: JSON.stringify(body),
|
|
419
|
-
});
|
|
420
|
-
if (!response.ok) {
|
|
421
|
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
422
|
-
}
|
|
423
|
-
responseData = await response.json();
|
|
424
|
-
}
|
|
425
|
-
catch (error) {
|
|
426
|
-
console.error('There was a problem with the fetch operation:', error);
|
|
427
|
-
}
|
|
428
|
-
if (responseData) {
|
|
429
|
-
setIsOpen(false);
|
|
430
|
-
setName('');
|
|
431
|
-
setField('');
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
};
|
|
435
|
-
if (!selectedTable) {
|
|
436
|
-
return null;
|
|
437
|
-
}
|
|
438
|
-
return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { label: "Add filter" }), (0, jsx_runtime_1.jsx)("div", { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: name, onChange: (e) => setName(e.target.value) }), (0, jsx_runtime_1.jsx)("div", { children: "Table" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: selectedTable ? selectedTable : '', onChange: (e) => setSelectedTable(e.target.value), QuillOptions: state.tables.map((table) => {
|
|
439
|
-
return { label: table.name, value: table.name };
|
|
440
|
-
}) }), (0, jsx_runtime_1.jsx)("div", { children: "Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: field ? field : '', QuillOptions: selectedTable.columns.map((column) => {
|
|
441
|
-
return { label: column.name, value: column.name };
|
|
442
|
-
}), onChange: (e) => {
|
|
443
|
-
setField(e);
|
|
444
|
-
} }), (0, jsx_runtime_1.jsx)(ButtonComponent, { label: "Add filter", onClick: handleAddFilter })] }) }));
|
|
445
|
-
}
|
|
446
|
-
exports.AddFilterModal = AddFilterModal;
|
|
447
|
-
function Portal({ publicKey, queryEndpoint, theme = defaultTheme, queryHeaders, withCredentials, environment, organizationId, TextInputComponent, ButtonComponent, SecondaryButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, UserManagementComponent, HeaderComponent, }) {
|
|
448
|
-
return ((0, jsx_runtime_1.jsx)(AdminProvider_1.AdminProvider, { publicKey: publicKey, children: (0, jsx_runtime_1.jsx)(Navigation, { theme: theme, publicKey: publicKey, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials, TextInputComponent: TextInputComponent || primitives_1.TextInputPrimitive, ButtonComponent: ButtonComponent || primitives_1.ButtonPrimitive, HeaderComponent: HeaderComponent || primitives_1.HeaderPrimitive, SecondaryButtonComponent: SecondaryButtonComponent || primitives_1.SecondaryButtonPrimitive, ModalComponent: ModalComponent || primitives_1.ModalPrimitive, environment: environment, OrganizationSelectComponent: OrganizationSelectComponent, UserManagementComponent: UserManagementComponent, SelectComponent: SelectComponent || primitives_1.SelectPrimitive }) }));
|
|
61
|
+
function Portal({ publicKey, queryEndpoint, theme = exports.defaultTheme, queryHeaders, withCredentials, environment, organizationId, TextInputComponent, ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, ModalComponent, SelectComponent, OrganizationSelectComponent, UserManagementComponent, HeaderComponent, }) {
|
|
62
|
+
return ((0, jsx_runtime_1.jsx)(AdminProvider_1.AdminProvider, { publicKey: publicKey, children: (0, jsx_runtime_1.jsx)(Navigation, { theme: theme, publicKey: publicKey, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials,
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
TextInputComponent: TextInputComponent || primitives_1.TextInputPrimitive, ButtonComponent: ButtonComponent,
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
HeaderComponent: HeaderComponent || primitives_1.HeaderPrimitive, SecondaryButtonComponent: SecondaryButtonComponent,
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
ModalComponent: ModalComponent || primitives_1.ModalPrimitive, environment: environment, OrganizationSelectComponent: OrganizationSelectComponent, UserManagementComponent: UserManagementComponent,
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
SelectComponent: SelectComponent || primitives_1.SelectPrimitive }) }));
|
|
449
71
|
}
|
|
450
72
|
exports.default = Portal;
|
|
451
73
|
function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, UserManagementComponent, HeaderComponent, publicKey, queryEndpoint, queryHeaders, environment, withCredentials, }) {
|
|
@@ -460,15 +82,21 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
|
|
|
460
82
|
const renderComponentBasedOnName = () => {
|
|
461
83
|
switch (state.activeComponent) {
|
|
462
84
|
case 'Dashboards':
|
|
463
|
-
return ((0, jsx_runtime_1.jsx)(components_1.DashboardManager
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(components_1.DashboardManager
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
, {
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
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 }));
|
|
464
90
|
case 'SQL editor':
|
|
465
91
|
return (0, jsx_runtime_1.jsx)(DashboardBuilder_1.default, {});
|
|
466
|
-
case 'Report':
|
|
467
|
-
return ((0, jsx_runtime_1.jsx)(ReportWrapper, { TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, ModalComponent: ModalComponent, SelectComponent: SelectComponent, OrganizationSelectComponent: OrganizationSelectComponent, organizationId: state.organizationId, queryEndpoint: queryEndpoint, queryHeaders: queryHeaders, withCredentials: withCredentials }));
|
|
468
92
|
case 'SQL views':
|
|
469
93
|
return (0, jsx_runtime_1.jsx)(SQLViewManager_1.default, {});
|
|
470
94
|
default:
|
|
471
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)(components_1.DashboardManager
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
, {
|
|
98
|
+
// @ts-ignore
|
|
99
|
+
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 }));
|
|
472
100
|
}
|
|
473
101
|
};
|
|
474
102
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
@@ -569,7 +197,7 @@ function Navigation({ TextInputComponent, ButtonComponent, SecondaryButtonCompon
|
|
|
569
197
|
, {
|
|
570
198
|
// organizationId={'2'}
|
|
571
199
|
// publicKey={client?._id}
|
|
572
|
-
organizationId: state.organizationId, queryEndpoint: queryEndpoint, withCredentials: withCredentials, queryHeaders: queryHeaders, publicKey: state.client._id, environment: state.environment, theme: exports.theme, children: renderComponentBasedOnName() }) })] }));
|
|
200
|
+
organizationId: state.organizationId, queryEndpoint: queryEndpoint || '', withCredentials: withCredentials, queryHeaders: queryHeaders || {}, publicKey: state.client._id, environment: state.environment, theme: exports.theme, children: renderComponentBasedOnName() }) })] }));
|
|
573
201
|
}
|
|
574
202
|
exports.theme = {
|
|
575
203
|
fontFamily: 'Inter; Helvetica',
|
|
@@ -667,174 +295,7 @@ function getPostgresBasicType(column) {
|
|
|
667
295
|
return format;
|
|
668
296
|
}
|
|
669
297
|
exports.getPostgresBasicType = getPostgresBasicType;
|
|
670
|
-
function
|
|
671
|
-
return classes.filter(Boolean).join(' ');
|
|
672
|
-
}
|
|
673
|
-
exports.classNames = classNames;
|
|
674
|
-
function AddDashboardModal({ selectedDashboard, isOpen, setIsOpen, client, ModalComponent, TextInputComponent, SelectComponent, HeaderComponent, ButtonComponent, dashNames, getDashNames, organizationId, }) {
|
|
675
|
-
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
676
|
-
const [selectedDashboardName, setSelectedDashboardName] = (0, react_1.useState)(selectedDashboard?.name);
|
|
677
|
-
// const [tables] = useContext(TablesContext);
|
|
678
|
-
const [selectedTable, setSelectedTable] = (0, react_1.useState)(null);
|
|
679
|
-
const [name, setName] = (0, react_1.useState)('');
|
|
680
|
-
const [field, setField] = (0, react_1.useState)('');
|
|
681
|
-
const [filterType, setFilterType] = (0, react_1.useState)('string');
|
|
682
|
-
const [dateRange, setDateRange] = (0, react_1.useState)([new Date(), new Date()]);
|
|
683
|
-
const [newFilters, setNewFilters] = (0, react_1.useState)([]);
|
|
684
|
-
const [newDateFilter, setNewDateFilter] = (0, react_1.useState)(null);
|
|
685
|
-
(0, react_1.useEffect)(() => {
|
|
686
|
-
if (state.tables?.length) {
|
|
687
|
-
setSelectedTable(state.tables[0]);
|
|
688
|
-
// setField(tables[0].columns.map((elem) => elem.name));
|
|
689
|
-
setField(state.tables[0].columns[0].name);
|
|
690
|
-
}
|
|
691
|
-
}, [state.tables]);
|
|
692
|
-
const handleDeleteFilter = async (filter) => {
|
|
693
|
-
setNewFilters(newFilters.filter((f) => f !== filter));
|
|
694
|
-
};
|
|
695
|
-
const handleAddDashboardSubmit = async () => {
|
|
696
|
-
if (!selectedDashboardName ||
|
|
697
|
-
newFilters.some((filter) => !filter.label) ||
|
|
698
|
-
(newDateFilter && newDateFilter.label)) {
|
|
699
|
-
alert('Empty labels');
|
|
700
|
-
return;
|
|
701
|
-
}
|
|
702
|
-
if (newFilters.some((filter) => !filter.field)) {
|
|
703
|
-
alert('Empty fields');
|
|
704
|
-
return;
|
|
705
|
-
}
|
|
706
|
-
if (!selectedTable || !field) {
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
if (dashNames &&
|
|
710
|
-
dashNames.length > 0 &&
|
|
711
|
-
dashNames.some((dashName) => dashName.name === selectedDashboardName)) {
|
|
712
|
-
alert('Dashboard name already taken!');
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
let updatedFilters = newFilters.map((filter) => {
|
|
716
|
-
const filterType = getPostgresBasicType(selectedTable.columns.find((col) => col.name === filter.field));
|
|
717
|
-
return {
|
|
718
|
-
table: selectedTable.name,
|
|
719
|
-
field: filter.field,
|
|
720
|
-
labelField: filter.field,
|
|
721
|
-
label: filter.label,
|
|
722
|
-
filterType,
|
|
723
|
-
};
|
|
724
|
-
});
|
|
725
|
-
const fieldsSet = new Set();
|
|
726
|
-
const hasDuplicateField = updatedFilters.some((filter) => {
|
|
727
|
-
if (fieldsSet.has(filter.field)) {
|
|
728
|
-
return true;
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
fieldsSet.add(filter.field);
|
|
732
|
-
return false;
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
if (hasDuplicateField) {
|
|
736
|
-
alert('Maximum of one filter per field');
|
|
737
|
-
return;
|
|
738
|
-
}
|
|
739
|
-
let allValid = true;
|
|
740
|
-
updatedFilters.forEach((filter) => {
|
|
741
|
-
if (filter.filterType !== 'string' && filter.filterType !== 'date') {
|
|
742
|
-
allValid = false;
|
|
743
|
-
console.error(`Invalid filterType found: ${filter.filterType}`);
|
|
744
|
-
}
|
|
745
|
-
});
|
|
746
|
-
if (!allValid) {
|
|
747
|
-
alert('We only support string and filters.');
|
|
748
|
-
return;
|
|
749
|
-
}
|
|
750
|
-
if (updatedFilters.filter((filter) => filter.filterType === 'date').length > 1) {
|
|
751
|
-
alert('More than one date filter');
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
let responseData;
|
|
755
|
-
const url = `${constants_1.QUILL_SERVER}/newdash/${client._id}/`;
|
|
756
|
-
const body = newDateFilter && Object.keys(newDateFilter).length
|
|
757
|
-
? {
|
|
758
|
-
dateFilter: newDateFilter,
|
|
759
|
-
newDashboardName: selectedDashboardName,
|
|
760
|
-
filters: updatedFilters,
|
|
761
|
-
organizationId,
|
|
762
|
-
}
|
|
763
|
-
: {
|
|
764
|
-
newDashboardName: selectedDashboardName,
|
|
765
|
-
filters: updatedFilters,
|
|
766
|
-
organizationId,
|
|
767
|
-
};
|
|
768
|
-
const headers = {
|
|
769
|
-
'Content-Type': 'application/json',
|
|
770
|
-
Authorization: `Bearer `,
|
|
771
|
-
};
|
|
772
|
-
try {
|
|
773
|
-
const response = await fetch(url, {
|
|
774
|
-
method: 'POST',
|
|
775
|
-
headers: headers,
|
|
776
|
-
body: JSON.stringify(body),
|
|
777
|
-
});
|
|
778
|
-
if (!response.ok) {
|
|
779
|
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
780
|
-
}
|
|
781
|
-
responseData = await response.json();
|
|
782
|
-
}
|
|
783
|
-
catch (e) {
|
|
784
|
-
console.log('error');
|
|
785
|
-
}
|
|
786
|
-
if (responseData) {
|
|
787
|
-
setIsOpen(false);
|
|
788
|
-
setName('');
|
|
789
|
-
setSelectedDashboardName('');
|
|
790
|
-
setNewFilters([]);
|
|
791
|
-
setNewDateFilter(null);
|
|
792
|
-
getDashNames();
|
|
793
|
-
return;
|
|
794
|
-
}
|
|
795
|
-
};
|
|
796
|
-
if (!selectedTable) {
|
|
797
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
798
|
-
}
|
|
799
|
-
const handleAddFilter = async () => {
|
|
800
|
-
setNewFilters([...newFilters, { label: '', field }]);
|
|
801
|
-
};
|
|
802
|
-
return ((0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), children: (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { placeholder: "Enter Dashboard Name...", onChange: (e) => setSelectedDashboardName(e.target.value), value: selectedDashboardName }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
803
|
-
display: 'flex',
|
|
804
|
-
flexDirection: 'column',
|
|
805
|
-
alignItems: 'center',
|
|
806
|
-
}, children: [newFilters.map((filter, index) => {
|
|
807
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("h2", { children: "Label" }), (0, jsx_runtime_1.jsx)(TextInputComponent, { value: filter.label, onChange: (e) => {
|
|
808
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
809
|
-
? { ...otherFilter, label: e.target.value }
|
|
810
|
-
: otherFilter);
|
|
811
|
-
setNewFilters(updatedFilters);
|
|
812
|
-
} })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("h4", { children: "Field" }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
813
|
-
display: 'flex',
|
|
814
|
-
flexDirection: 'column',
|
|
815
|
-
alignItems: 'center',
|
|
816
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
817
|
-
display: 'flex',
|
|
818
|
-
flexDirection: 'row',
|
|
819
|
-
alignItems: 'center',
|
|
820
|
-
}, children: [(0, jsx_runtime_1.jsx)(SelectComponent, { defaultValue: "", value: filter && filter.field ? filter.field : '', QuillOptions: selectedTable.columns.map((column) => {
|
|
821
|
-
return { label: column.name, value: column.name };
|
|
822
|
-
}), onChange: (e) => {
|
|
823
|
-
const updatedFilters = newFilters.map((otherFilter, i) => index === i
|
|
824
|
-
? { ...otherFilter, field: e }
|
|
825
|
-
: otherFilter);
|
|
826
|
-
setNewFilters(updatedFilters);
|
|
827
|
-
} }), (0, jsx_runtime_1.jsx)("div", { onClick: () => handleDeleteFilter(filter), style: {
|
|
828
|
-
height: 38,
|
|
829
|
-
width: 42,
|
|
830
|
-
alignItems: 'center',
|
|
831
|
-
justifyContent: 'center',
|
|
832
|
-
display: 'flex',
|
|
833
|
-
}, children: (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#4C5462", width: "20", height: "20", children: (0, jsx_runtime_1.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));
|
|
834
|
-
}), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleAddFilter, label: "Add new filter +" }), (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleAddDashboardSubmit, label: "Add Dashboard +" })] })] }) }));
|
|
835
|
-
}
|
|
836
|
-
exports.AddDashboardModal = AddDashboardModal;
|
|
837
|
-
function TableCell({ table, clickTableCell }) {
|
|
298
|
+
function TableCell({ table, clickTableCell, }) {
|
|
838
299
|
const handleClickTableCell = () => {
|
|
839
300
|
clickTableCell(table);
|
|
840
301
|
};
|
|
@@ -857,311 +318,198 @@ function TableCell({ table, clickTableCell }) {
|
|
|
857
318
|
}, children: tokens.map((line, i) => ((0, jsx_runtime_1.jsx)("div", { ...getLineProps({ line, key: i }), children: line.map((token, key) => ((0, jsx_runtime_1.jsx)("span", { ...getTokenProps({ token, key }) }, key))) }, i))) })) })] }, table._id));
|
|
858
319
|
}
|
|
859
320
|
exports.TableCell = TableCell;
|
|
860
|
-
const SchemaListComponent = ({ schema, theme }) => {
|
|
861
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
862
|
-
background: theme.backgroundColor,
|
|
863
|
-
maxHeight: 700,
|
|
864
|
-
width: 300,
|
|
865
|
-
minWidth: 300,
|
|
866
|
-
overflowY: 'scroll',
|
|
867
|
-
// maxHeight: "100%",
|
|
868
|
-
paddingLeft: 20,
|
|
869
|
-
paddingRight: 20,
|
|
870
|
-
}, children: schema.map((elem, index) => ((0, jsx_runtime_1.jsx)(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index))) }));
|
|
871
|
-
};
|
|
872
|
-
function SchemaItem({ elem, theme, index }) {
|
|
873
|
-
const [isOpen, setIsOpen] = (0, react_1.useState)(index === 0);
|
|
874
|
-
const schemaContainerStyle = {
|
|
875
|
-
display: 'flex',
|
|
876
|
-
flexDirection: 'column',
|
|
877
|
-
// WebkitTouchCallout: "none",
|
|
878
|
-
// WebkitUserSelect: "none",
|
|
879
|
-
// KhtmlUserSelect: "none",
|
|
880
|
-
// MozUserSelect: "none",
|
|
881
|
-
// msUserSelect: "none",
|
|
882
|
-
// userSelect: "none",
|
|
883
|
-
};
|
|
884
|
-
const schemaRowStyle = {
|
|
885
|
-
display: 'flex',
|
|
886
|
-
flexDirection: 'row',
|
|
887
|
-
alignItems: 'center',
|
|
888
|
-
width: '100%',
|
|
889
|
-
justifyContent: 'space-between',
|
|
890
|
-
cursor: 'pointer',
|
|
891
|
-
};
|
|
892
|
-
const schemaRowHoverStyle = {
|
|
893
|
-
background: theme.selectUnderlayColor,
|
|
894
|
-
};
|
|
895
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: schemaContainerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, onClick: () => setIsOpen(!isOpen), children: [(0, jsx_runtime_1.jsx)("p", { style: {
|
|
896
|
-
marginLeft: theme.padding,
|
|
897
|
-
fontSize: theme.fontSize,
|
|
898
|
-
color: '#384151',
|
|
899
|
-
fontWeight: '500',
|
|
900
|
-
}, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
901
|
-
display: 'flex',
|
|
902
|
-
alignItems: 'center',
|
|
903
|
-
justifyContent: 'center',
|
|
904
|
-
// paddingRight: 25,
|
|
905
|
-
paddingTop: 20,
|
|
906
|
-
paddingBottom: 20,
|
|
907
|
-
paddingLeft: 0,
|
|
908
|
-
cursor: 'pointer',
|
|
909
|
-
}, children: isOpen ? ((0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) })) : ((0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) })) })] }), isOpen ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
910
|
-
paddingBottom: theme.padding,
|
|
911
|
-
display: 'flex',
|
|
912
|
-
flexDirection: 'column',
|
|
913
|
-
paddingLeft: theme.padding,
|
|
914
|
-
paddingRight: theme.padding,
|
|
915
|
-
}, children: elem.columns.map((elem, index) => ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
916
|
-
paddingTop: theme.padding,
|
|
917
|
-
display: 'flex',
|
|
918
|
-
flexDirection: 'row',
|
|
919
|
-
alignItems: 'center',
|
|
920
|
-
justifyContent: 'space-between',
|
|
921
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { title: elem.displayName, className: "text-gray-500", style: {
|
|
922
|
-
fontSize: 13,
|
|
923
|
-
// color: theme.secondaryFontColor,
|
|
924
|
-
whiteSpace: 'nowrap',
|
|
925
|
-
padding: 0,
|
|
926
|
-
margin: 0,
|
|
927
|
-
textOverflow: 'ellipsis',
|
|
928
|
-
overflow: 'hidden',
|
|
929
|
-
width: 200,
|
|
930
|
-
maxWidth: 200,
|
|
931
|
-
}, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { className: "text-gray-500", title: elem.displayName, style: {
|
|
932
|
-
fontSize: 13,
|
|
933
|
-
color: theme.secondaryFontColor,
|
|
934
|
-
padding: 0,
|
|
935
|
-
margin: 0,
|
|
936
|
-
}, children: elem.fieldType })] }, elem.displayName + elem.index))) })) : null] }));
|
|
937
|
-
}
|
|
938
|
-
function defineEditorTheme(monaco, theme) {
|
|
939
|
-
monaco.editor.defineTheme('onedark', {
|
|
940
|
-
base: theme.darkMode ? 'vs-dark' : 'vs',
|
|
941
|
-
inherit: true,
|
|
942
|
-
rules: [
|
|
943
|
-
{
|
|
944
|
-
token: 'comment',
|
|
945
|
-
foreground: '#5d7988',
|
|
946
|
-
fontStyle: 'italic',
|
|
947
|
-
},
|
|
948
|
-
{ token: 'constant', foreground: '#e06c75' },
|
|
949
|
-
],
|
|
950
|
-
colors: {
|
|
951
|
-
'editor.background': '#F9F9F9',
|
|
952
|
-
},
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
exports.defineEditorTheme = defineEditorTheme;
|
|
956
|
-
function setEditorTheme(editor, monaco) {
|
|
957
|
-
try {
|
|
958
|
-
monaco.editor.setTheme('onedark');
|
|
959
|
-
}
|
|
960
|
-
catch (e) {
|
|
961
|
-
console.log('ERROR: ', e);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
exports.setEditorTheme = setEditorTheme;
|
|
965
|
-
function isValidDate(d) {
|
|
966
|
-
return d instanceof Date && !isNaN(d);
|
|
967
|
-
}
|
|
968
|
-
exports.isValidDate = isValidDate;
|
|
969
|
-
const isArrayOfValidDates = (arr, field) => arr.every((d) => new Date(d[field]) instanceof Date && !isNaN(new Date(d[field])));
|
|
970
|
-
exports.isArrayOfValidDates = isArrayOfValidDates;
|
|
971
|
-
function formatDateBuckets(startDate, endDate) {
|
|
972
|
-
// Calculate the distance in hours
|
|
973
|
-
const distanceInHours = Math.abs(differenceInHours(endDate, startDate));
|
|
974
|
-
// Check if the distance is less than or equal to one hour
|
|
975
|
-
if (distanceInHours <= 1) {
|
|
976
|
-
return {
|
|
977
|
-
unit: 'hour',
|
|
978
|
-
format: 'h a',
|
|
979
|
-
startOf: startOfHour,
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
// Calculate the distance in days
|
|
983
|
-
const distanceInDays = Math.abs(differenceInDays(endDate, startDate));
|
|
984
|
-
// Check if the distance is less than or equal to one day
|
|
985
|
-
if (distanceInDays <= 1) {
|
|
986
|
-
return {
|
|
987
|
-
unit: 'day',
|
|
988
|
-
format: 'MMM d',
|
|
989
|
-
startOf: startOfDay,
|
|
990
|
-
};
|
|
991
|
-
}
|
|
992
|
-
// Calculate the distance in months
|
|
993
|
-
const distanceInMonths = Math.abs(differenceInMonths(endDate, startDate));
|
|
994
|
-
// Check if the distance is less than or equal to one month
|
|
995
|
-
if (distanceInMonths <= 1) {
|
|
996
|
-
return {
|
|
997
|
-
unit: 'month',
|
|
998
|
-
format: 'MMM yyyy',
|
|
999
|
-
startOf: startOfMonth,
|
|
1000
|
-
};
|
|
1001
|
-
}
|
|
1002
|
-
// Calculate the distance in years
|
|
1003
|
-
const distanceInYears = Math.abs(differenceInYears(endDate, startDate));
|
|
1004
|
-
// Check if the distance is less than or equal to one year
|
|
1005
|
-
if (distanceInYears <= 1) {
|
|
1006
|
-
return {
|
|
1007
|
-
unit: 'year',
|
|
1008
|
-
format: 'yyyy',
|
|
1009
|
-
startOf: startOfYear,
|
|
1010
|
-
};
|
|
1011
|
-
}
|
|
1012
|
-
// Otherwise, the distance is more than one year
|
|
1013
|
-
return {
|
|
1014
|
-
unit: 'year',
|
|
1015
|
-
format: 'yyyy',
|
|
1016
|
-
startOf: startOfYear,
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
exports.formatDateBuckets = formatDateBuckets;
|
|
1020
|
-
const POSTGRES_DATE_TYPES = [
|
|
1021
|
-
'timestamp',
|
|
1022
|
-
'date',
|
|
1023
|
-
'timestamptz',
|
|
1024
|
-
'time',
|
|
1025
|
-
'timetz',
|
|
1026
|
-
];
|
|
1027
|
-
const FORMAT_QuillOptionS = [
|
|
1028
|
-
{ value: 'whole_number', label: 'whole number' },
|
|
1029
|
-
{ value: 'one_decimal_place', label: 'one decimal place' },
|
|
1030
|
-
{ value: 'dollar_amount', label: 'dollar amount' },
|
|
1031
|
-
{ value: 'MMM_yyyy', label: 'month' },
|
|
1032
|
-
{ value: 'MMM_dd-MMM_dd', label: 'week' },
|
|
1033
|
-
{ value: 'MMM_dd_yyyy', label: 'day' },
|
|
1034
|
-
{ value: 'MMM_dd_hh:mm_ap_pm', label: 'day and time' },
|
|
1035
|
-
{ value: 'hh_ap_pm', label: 'hour' },
|
|
1036
|
-
{ value: 'percent', label: 'percent' },
|
|
1037
|
-
{ value: 'string', label: 'string' },
|
|
1038
|
-
];
|
|
1039
321
|
const FakeModal = ({ children }) => ((0, jsx_runtime_1.jsx)("div", { style: { height: '100%' }, children: children }));
|
|
1040
|
-
const FakeSQLEditorModal = ({ children, isOpen }) => {
|
|
322
|
+
const FakeSQLEditorModal = ({ children, isOpen, }) => {
|
|
1041
323
|
if (!isOpen)
|
|
1042
324
|
return null;
|
|
1043
325
|
return (0, jsx_runtime_1.jsx)("div", { style: { height: '100%' }, children: children });
|
|
1044
326
|
};
|
|
1045
|
-
function QuillReport({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpen, SecondaryButtonComponent, ButtonComponent, deleteReport, handleSave, updateQuery, OrganizationSelectComponent, ModalComponent, NavigateToDashboardBuilder, }) {
|
|
327
|
+
function QuillReport({ reportId, saveDashboardItem, isOpen, setIsOpen, isEditQueryOpen, SecondaryButtonComponent, ButtonComponent, deleteReport, handleSave, updateQuery, OrganizationSelectComponent, ModalComponent = UiComponents_2.MemoizedModal, NavigateToDashboardBuilder, }) {
|
|
1046
328
|
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
1047
329
|
const { data, loading, error } = (0, react_2.useQuill)(reportId);
|
|
330
|
+
const parentRef = (0, react_1.useRef)(null);
|
|
331
|
+
const [modalWidth, setModalWidth] = (0, react_1.useState)(200);
|
|
332
|
+
const [modalHeight, setModalHeight] = (0, react_1.useState)(200);
|
|
1048
333
|
const [isOpenChartBuilder, setIsOpenChartBuilder] = (0, react_1.useState)(false);
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
334
|
+
const handleResize = (0, react_1.useCallback)(() => {
|
|
335
|
+
const screenSize = window.innerWidth;
|
|
336
|
+
const isEditQuery = state.activeQuery && state.activeEditItem;
|
|
337
|
+
if (isOpenChartBuilder && !isEditQuery && screenSize < 1200) {
|
|
338
|
+
setModalWidth(undefined); // use dynamic width of contents
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
setModalWidth(window.innerWidth - 80);
|
|
342
|
+
}
|
|
343
|
+
setModalHeight(window.innerHeight - 80);
|
|
344
|
+
}, [isOpenChartBuilder, state.activeQuery, state.activeEditItem]);
|
|
345
|
+
(0, react_1.useEffect)(() => {
|
|
346
|
+
handleResize();
|
|
347
|
+
window.addEventListener('resize', handleResize);
|
|
348
|
+
return () => {
|
|
349
|
+
window.removeEventListener('resize', handleResize);
|
|
350
|
+
};
|
|
351
|
+
}, [handleResize]);
|
|
352
|
+
const handleSetIsOpen = (isOpen) => {
|
|
353
|
+
if (!isOpen) {
|
|
1058
354
|
dispatch({
|
|
1059
355
|
type: 'SET_ACTIVE_QUERY',
|
|
1060
356
|
payload: '',
|
|
1061
357
|
});
|
|
1062
358
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
1063
|
-
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
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
|
-
border: '1px solid #e7e7e7',
|
|
1103
|
-
borderRadius: 6,
|
|
1104
|
-
outline: 'none',
|
|
1105
|
-
cursor: 'pointer',
|
|
1106
|
-
fontFamily: exports.theme?.fontFamily,
|
|
1107
|
-
fontWeight: exports.theme?.buttonFontWeight || 500,
|
|
1108
|
-
fontSize: 14,
|
|
1109
|
-
padding: '0px 12px',
|
|
1110
|
-
display: 'flex',
|
|
1111
|
-
flexDirection: 'row',
|
|
1112
|
-
alignItems: 'center',
|
|
1113
|
-
gap: 5,
|
|
1114
|
-
}, onClick: () => {
|
|
1115
|
-
if (state.activeQuery && state.activeEditItem) {
|
|
1116
|
-
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
359
|
+
}
|
|
360
|
+
setIsOpenChartBuilder(isOpen);
|
|
361
|
+
setIsOpen(isOpen);
|
|
362
|
+
};
|
|
363
|
+
if (!data || loading) {
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: parentRef, children: (0, jsx_runtime_1.jsx)(ModalComponent, { isOpen: isOpen, setIsOpen: handleSetIsOpen, title: data.name || 'Report Detail', width: modalWidth, height: modalHeight, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
367
|
+
width: '100%',
|
|
368
|
+
height: 'calc(100% - 52px)', // full height minus header height
|
|
369
|
+
display: 'flex',
|
|
370
|
+
flexDirection: 'column',
|
|
371
|
+
flexGrow: 1,
|
|
372
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
373
|
+
display: 'flex',
|
|
374
|
+
alignItems: 'center',
|
|
375
|
+
gap: 16,
|
|
376
|
+
padding: 15,
|
|
377
|
+
}, children: [(0, jsx_runtime_1.jsxs)("button", { style: {
|
|
378
|
+
height: 36,
|
|
379
|
+
color: exports.theme?.secondaryTextColor,
|
|
380
|
+
border: '1px solid #e7e7e7',
|
|
381
|
+
borderRadius: 6,
|
|
382
|
+
outline: 'none',
|
|
383
|
+
cursor: 'pointer',
|
|
384
|
+
fontFamily: exports.theme?.fontFamily,
|
|
385
|
+
fontWeight: exports.theme?.buttonFontWeight || 500,
|
|
386
|
+
fontSize: 14,
|
|
387
|
+
padding: '0px 12px',
|
|
388
|
+
display: 'flex',
|
|
389
|
+
flexDirection: 'row',
|
|
390
|
+
alignItems: 'center',
|
|
391
|
+
gap: 5,
|
|
392
|
+
}, onClick: () => {
|
|
393
|
+
setIsOpenChartBuilder((showEditChart) => !showEditChart);
|
|
394
|
+
dispatch({
|
|
395
|
+
type: 'SET_ACTIVE_QUERY',
|
|
396
|
+
payload: '',
|
|
397
|
+
});
|
|
1117
398
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
399
|
+
}, className: "secondary-button-quill", children: [(0, jsx_runtime_1.jsx)("style", { children: `.secondary-button-quill { background: white } .secondary-button-quill:hover { background: #F4F4F5 }` }), (0, jsx_runtime_1.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: "currentColor", height: 15, width: 15, children: [(0, jsx_runtime_1.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" }), (0, jsx_runtime_1.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"] }), (0, jsx_runtime_1.jsxs)("button", { style: {
|
|
400
|
+
height: 36,
|
|
401
|
+
color: exports.theme?.secondaryTextColor,
|
|
402
|
+
border: '1px solid #e7e7e7',
|
|
403
|
+
borderRadius: 6,
|
|
404
|
+
outline: 'none',
|
|
405
|
+
cursor: 'pointer',
|
|
406
|
+
fontFamily: exports.theme?.fontFamily,
|
|
407
|
+
fontWeight: exports.theme?.buttonFontWeight || 500,
|
|
408
|
+
fontSize: 14,
|
|
409
|
+
padding: '0px 12px',
|
|
410
|
+
display: 'flex',
|
|
411
|
+
flexDirection: 'row',
|
|
412
|
+
alignItems: 'center',
|
|
413
|
+
gap: 5,
|
|
414
|
+
}, onClick: () => {
|
|
415
|
+
if (state.activeQuery && state.activeEditItem) {
|
|
416
|
+
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
417
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
dispatch({
|
|
421
|
+
type: 'SET_ACTIVE_QUERY',
|
|
422
|
+
payload: data.queryString,
|
|
423
|
+
});
|
|
424
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: data });
|
|
425
|
+
}, className: "secondary-button-quill", children: [(0, jsx_runtime_1.jsx)("style", { children: `.secondary-button-quill { background: white } .secondary-button-quill:hover { background: #F4F4F5 }` }), (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", height: 12, width: 12, children: (0, jsx_runtime_1.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"] }), (0, jsx_runtime_1.jsxs)("button", { style: {
|
|
426
|
+
height: 36,
|
|
427
|
+
color: exports.theme?.secondaryTextColor,
|
|
428
|
+
border: '1px solid #e7e7e7',
|
|
429
|
+
borderRadius: 6,
|
|
430
|
+
outline: 'none',
|
|
431
|
+
cursor: 'pointer',
|
|
432
|
+
fontFamily: exports.theme?.fontFamily,
|
|
433
|
+
fontWeight: exports.theme?.buttonFontWeight || 500,
|
|
434
|
+
fontSize: 14,
|
|
435
|
+
padding: '0px 12px',
|
|
436
|
+
display: 'flex',
|
|
437
|
+
flexDirection: 'row',
|
|
438
|
+
alignItems: 'center',
|
|
439
|
+
gap: 4,
|
|
440
|
+
}, onClick: deleteReport, className: "secondary-button-quill", children: [(0, jsx_runtime_1.jsx)("style", { children: `.secondary-button-quill { background: white } .secondary-button-quill:hover { background: #F4F4F5 }` }), (0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", fill: "currentColor", height: 14, width: 14, children: (0, jsx_runtime_1.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"] })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
441
|
+
display: 'flex',
|
|
442
|
+
flexDirection: 'row',
|
|
443
|
+
height: 'calc(100% - 66px)', // full height minus button container
|
|
444
|
+
flexGrow: 1,
|
|
445
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
446
|
+
width: '100%',
|
|
447
|
+
height: '100%',
|
|
448
|
+
overflowX: 'hidden',
|
|
449
|
+
overflowY: 'auto',
|
|
450
|
+
}, children: state.activeEditItem && state.activeQuery ? ((0, jsx_runtime_1.jsx)(QueryEditor, { onSave: handleSave })) : ((0, jsx_runtime_1.jsx)(react_2.ChartEditor, { isOpen: isOpenChartBuilder, setIsOpen: setIsOpenChartBuilder, reportId: reportId, isAdmin: true, organizationName: state.organizations.find((org) => {
|
|
451
|
+
return (org.id &&
|
|
452
|
+
String(org.id) === String(state.organizationId));
|
|
453
|
+
})?.name, onDelete: deleteReport, onAddToDashboardComplete: (report) => {
|
|
454
|
+
const dashboard = state.dashboards.find((dash) => {
|
|
455
|
+
return dash.name === report.dashboardName;
|
|
456
|
+
});
|
|
457
|
+
dispatch({
|
|
458
|
+
type: 'SET_SELECTED_DASHBOARD',
|
|
459
|
+
payload: dashboard,
|
|
460
|
+
});
|
|
461
|
+
handleSave();
|
|
462
|
+
}, isHorizontalView: true, ModalComponent: FakeModal, ButtonComponent: UiComponents_1.MemoizedButton })) }) })] }) }) }));
|
|
1153
463
|
}
|
|
1154
|
-
function QueryEditor() {
|
|
464
|
+
function QueryEditor({ onSave }) {
|
|
1155
465
|
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
1156
|
-
|
|
466
|
+
if (state.activeEditItem &&
|
|
467
|
+
state.activeEditItem.referencedTables &&
|
|
468
|
+
state.activeEditItem.referencedTables.length === 1 &&
|
|
469
|
+
state.activeQuery &&
|
|
470
|
+
!state.activeQuery.match(/^\s*with\s/i) &&
|
|
471
|
+
!(0, table_1.hasColumnAlias)(state.activeEditItem.columns, state.activeEditItem.referencedColumns[state.activeEditItem.referencedTables[0]] || undefined)) {
|
|
472
|
+
return ((0, jsx_runtime_1.jsx)(react_2.ReportBuilder, { isAdminEnabled: true,
|
|
473
|
+
// initialTableName={state.tables.length > 0 && state.tables[0]!.name}
|
|
474
|
+
reportId: state.activeEditItem._id, onSubmitEditReport: (report) => {
|
|
475
|
+
const dashboard = state.dashboards.find((dash) => {
|
|
476
|
+
return dash.name === report.dashboardName;
|
|
477
|
+
});
|
|
478
|
+
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
479
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
480
|
+
dispatch({
|
|
481
|
+
type: 'SET_SELECTED_DASHBOARD',
|
|
482
|
+
payload: dashboard,
|
|
483
|
+
});
|
|
484
|
+
onSave(); // refresh the dashboard in the background
|
|
485
|
+
}, organizationName: state.organizations.find((org) => {
|
|
486
|
+
return org.id && String(org.id) === String(state.organizationId);
|
|
487
|
+
})?.name, isChartBuilderHorizontalView: true,
|
|
488
|
+
// @ts-ignore
|
|
489
|
+
ChartBuilderModalComponent: FakeSQLEditorModal, containerStyle: {
|
|
490
|
+
height: '100%',
|
|
491
|
+
width: '100%',
|
|
492
|
+
} }));
|
|
493
|
+
}
|
|
494
|
+
return ((0, jsx_runtime_1.jsx)(react_3.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) => {
|
|
495
|
+
const dashboard = state.dashboards.find((dash) => {
|
|
496
|
+
return dash.name === report.dashboardName;
|
|
497
|
+
});
|
|
1157
498
|
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
1158
499
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
500
|
+
dispatch({
|
|
501
|
+
type: 'SET_SELECTED_DASHBOARD',
|
|
502
|
+
payload: dashboard,
|
|
503
|
+
});
|
|
504
|
+
onSave(); // refresh the dashboard in the background
|
|
1159
505
|
}, containerStyle: {
|
|
1160
506
|
height: '100%',
|
|
1161
507
|
width: '100%',
|
|
1162
508
|
}, organizationName: state.organizations.find((org) => {
|
|
1163
509
|
return org.id && String(org.id) === String(state.organizationId);
|
|
1164
|
-
})?.name,
|
|
510
|
+
})?.name,
|
|
511
|
+
// @ts-ignore
|
|
512
|
+
ModalComponent: FakeSQLEditorModal, ButtonComponent: UiComponents_1.MemoizedButton }));
|
|
1165
513
|
}
|
|
1166
514
|
function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalComponent, SelectComponent, OrganizationSelectComponent, organizationId, queryEndpoint, queryHeaders, withCredentials, isOpen, setIsOpen, reloadDashboard, }) {
|
|
1167
515
|
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
@@ -1202,7 +550,7 @@ function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalCompone
|
|
|
1202
550
|
headers: {
|
|
1203
551
|
'Content-Type': 'application/json',
|
|
1204
552
|
Authorization: 'Bearer ',
|
|
1205
|
-
environment: state.environment
|
|
553
|
+
environment: state.environment,
|
|
1206
554
|
},
|
|
1207
555
|
body: JSON.stringify(requestBody),
|
|
1208
556
|
});
|
|
@@ -1263,7 +611,7 @@ function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalCompone
|
|
|
1263
611
|
method: 'POST',
|
|
1264
612
|
headers: {
|
|
1265
613
|
'Content-Type': 'application/json',
|
|
1266
|
-
environment: state.environment
|
|
614
|
+
environment: state.environment,
|
|
1267
615
|
},
|
|
1268
616
|
body: JSON.stringify(requestBody),
|
|
1269
617
|
});
|
|
@@ -1281,145 +629,3 @@ function ReportWrapper({ SecondaryButtonComponent, ButtonComponent, ModalCompone
|
|
|
1281
629
|
return ((0, jsx_runtime_1.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 }));
|
|
1282
630
|
}
|
|
1283
631
|
exports.ReportWrapper = ReportWrapper;
|
|
1284
|
-
const measuringConfig = {
|
|
1285
|
-
droppable: {
|
|
1286
|
-
strategy: core_1.MeasuringStrategy.Always,
|
|
1287
|
-
},
|
|
1288
|
-
};
|
|
1289
|
-
function ReorderableList({ initialItems, client, itemMap, ButtonComponent, closeModal, onSave, }) {
|
|
1290
|
-
const [items, setItems] = (0, react_1.useState)([]);
|
|
1291
|
-
// const [client] = useContext(ClientContext);
|
|
1292
|
-
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
|
|
1293
|
-
coordinateGetter: sortable_1.sortableKeyboardCoordinates,
|
|
1294
|
-
}), (0, core_1.useSensor)(core_1.TouchSensor, {
|
|
1295
|
-
activationConstraint: '',
|
|
1296
|
-
}));
|
|
1297
|
-
(0, react_1.useEffect)(() => {
|
|
1298
|
-
setItems(initialItems
|
|
1299
|
-
.sort((a, b) => {
|
|
1300
|
-
if (a.order === undefined && b.order === undefined)
|
|
1301
|
-
return 0; // both items don't have the 'order' field
|
|
1302
|
-
if (a.order === undefined)
|
|
1303
|
-
return 1; // only 'a' doesn't have the 'order' field, place 'a' last
|
|
1304
|
-
if (b.order === undefined)
|
|
1305
|
-
return -1; // only 'b' doesn't have the 'order' field, place 'b' last
|
|
1306
|
-
return a.order - b.order; // both items have the 'order' field, sort numerically
|
|
1307
|
-
})
|
|
1308
|
-
.map((elem) => elem._id));
|
|
1309
|
-
}, [initialItems]);
|
|
1310
|
-
const handleSaveChanges = async () => {
|
|
1311
|
-
if (!client) {
|
|
1312
|
-
return;
|
|
1313
|
-
}
|
|
1314
|
-
if (!items.length) {
|
|
1315
|
-
return;
|
|
1316
|
-
}
|
|
1317
|
-
try {
|
|
1318
|
-
const response = await fetch(`${constants_1.QUILL_SERVER}/dashorder/`, {
|
|
1319
|
-
method: 'POST',
|
|
1320
|
-
headers: {
|
|
1321
|
-
'Content-Type': 'application/json',
|
|
1322
|
-
},
|
|
1323
|
-
body: JSON.stringify({
|
|
1324
|
-
publicKey: client._id,
|
|
1325
|
-
orderArray: items,
|
|
1326
|
-
}),
|
|
1327
|
-
});
|
|
1328
|
-
if (!response.ok) {
|
|
1329
|
-
const errorData = await response.json();
|
|
1330
|
-
throw new Error(`Error: ${errorData.error || 'Unknown error'}`);
|
|
1331
|
-
}
|
|
1332
|
-
const data = await response.json();
|
|
1333
|
-
await onSave();
|
|
1334
|
-
closeModal();
|
|
1335
|
-
}
|
|
1336
|
-
catch (error) {
|
|
1337
|
-
console.error(error.message);
|
|
1338
|
-
}
|
|
1339
|
-
};
|
|
1340
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(core_1.DndContext, { sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, measuring: measuringConfig, children: (0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items, strategy: sortable_1.verticalListSortingStrategy, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1341
|
-
background: 'white',
|
|
1342
|
-
position: 'fixed',
|
|
1343
|
-
width: '100%',
|
|
1344
|
-
height: 'calc(100% - 40px)',
|
|
1345
|
-
overflowY: 'scroll',
|
|
1346
|
-
overflowX: 'hidden',
|
|
1347
|
-
maxWidth: 700,
|
|
1348
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 80 } }), items.map((id) => ((0, jsx_runtime_1.jsx)(SortableItem, { id: id, name: itemMap?.get(id).name }, id))), (0, jsx_runtime_1.jsx)("div", { style: { height: 100, width: '100%' } })] }) }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1349
|
-
height: 80,
|
|
1350
|
-
paddingTop: 20,
|
|
1351
|
-
width: '100%',
|
|
1352
|
-
background: 'white',
|
|
1353
|
-
position: 'absolute',
|
|
1354
|
-
bottom: -20,
|
|
1355
|
-
left: 0,
|
|
1356
|
-
right: 0,
|
|
1357
|
-
}, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleSaveChanges, label: "Save changes" }) })] }));
|
|
1358
|
-
function handleDragEnd(event) {
|
|
1359
|
-
const { active, over } = event;
|
|
1360
|
-
if (!over?.id || !active?.id) {
|
|
1361
|
-
return;
|
|
1362
|
-
}
|
|
1363
|
-
if (active.id !== over.id) {
|
|
1364
|
-
setItems((items) => {
|
|
1365
|
-
const oldIndex = items.indexOf(active.id);
|
|
1366
|
-
const newIndex = items.indexOf(over.id);
|
|
1367
|
-
return (0, sortable_1.arrayMove)(items, oldIndex, newIndex);
|
|
1368
|
-
});
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
exports.ReorderableList = ReorderableList;
|
|
1373
|
-
const animateLayoutChanges = (args) => args.isSorting || args.wasDragging ? (0, sortable_1.defaultAnimateLayoutChanges)(args) : true;
|
|
1374
|
-
function SortableItem({ id, name }) {
|
|
1375
|
-
const { attributes, listeners, setNodeRef, transform, transition } = (0, sortable_1.useSortable)({
|
|
1376
|
-
animateLayoutChanges,
|
|
1377
|
-
id: id,
|
|
1378
|
-
});
|
|
1379
|
-
let height = 50;
|
|
1380
|
-
const style = {
|
|
1381
|
-
transform: utilities_1.CSS.Translate.toString(transform),
|
|
1382
|
-
transition,
|
|
1383
|
-
display: 'flex',
|
|
1384
|
-
justifyContent: 'space-between',
|
|
1385
|
-
alignItems: 'center',
|
|
1386
|
-
borderRadius: '10px',
|
|
1387
|
-
border: '1px solid #E7E7E7',
|
|
1388
|
-
boxShadow: '0px 2px 8px 0px rgba(56, 65, 81, 0.08)',
|
|
1389
|
-
cursor: 'grab',
|
|
1390
|
-
userSelect: 'none',
|
|
1391
|
-
marginBottom: 20,
|
|
1392
|
-
background: 'white',
|
|
1393
|
-
};
|
|
1394
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: setNodeRef, style: style, ...attributes, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1395
|
-
cursor: 'pointer',
|
|
1396
|
-
width: '100%',
|
|
1397
|
-
display: 'flex',
|
|
1398
|
-
flexDirection: 'row',
|
|
1399
|
-
alignItems: 'center',
|
|
1400
|
-
justifyContent: 'space-between',
|
|
1401
|
-
height: 260,
|
|
1402
|
-
}, ...listeners, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
1403
|
-
display: 'flex',
|
|
1404
|
-
flexDirection: 'column',
|
|
1405
|
-
justifyContent: 'space-between',
|
|
1406
|
-
height: 260,
|
|
1407
|
-
paddingTop: 20,
|
|
1408
|
-
paddingBottom: 20,
|
|
1409
|
-
width: '100%',
|
|
1410
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
1411
|
-
minWidth: 600,
|
|
1412
|
-
width: '100%',
|
|
1413
|
-
paddingLeft: 20,
|
|
1414
|
-
fontSize: 18,
|
|
1415
|
-
fontWeight: '500',
|
|
1416
|
-
}, children: name }), (0, jsx_runtime_1.jsx)(react_2.Chart, { chartId: id, containerStyle: {
|
|
1417
|
-
height: 180,
|
|
1418
|
-
width: '100%',
|
|
1419
|
-
} })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
1420
|
-
display: 'flex',
|
|
1421
|
-
flexDirection: 'column',
|
|
1422
|
-
paddingRight: 20,
|
|
1423
|
-
paddingLeft: 20,
|
|
1424
|
-
}, children: (0, jsx_runtime_1.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: (0, jsx_runtime_1.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" }) }) })] }) }));
|
|
1425
|
-
}
|