@quillsql/admin 1.4.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Admin.d.ts +4 -1
- package/dist/cjs/Admin.d.ts.map +1 -1
- package/dist/cjs/Admin.js +122 -77
- package/dist/cjs/AdminProvider.d.ts +1 -1
- package/dist/cjs/AdminProvider.d.ts.map +1 -1
- package/dist/cjs/AdminProvider.js +9 -9
- package/dist/cjs/api/ConnectionClient.d.ts.map +1 -1
- package/dist/cjs/api/ConnectionClient.js +13 -0
- package/dist/cjs/components/UiComponents.d.ts +2 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +9 -7
- package/dist/cjs/forms/client_onboard/CreateSqlViews.js +1 -1
- package/dist/cjs/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
- package/dist/cjs/forms/sql_views/CreateEditSqlView.js +19 -6
- package/dist/cjs/modals/NewDashboardModal.js +1 -1
- package/dist/cjs/modals/ReorderDashboardModal.d.ts.map +1 -1
- package/dist/cjs/modals/ReorderDashboardModal.js +178 -63
- package/dist/cjs/primitives/ModalPrimitive.d.ts.map +1 -1
- package/dist/cjs/primitives/ModalPrimitive.js +1 -2
- package/dist/cjs/public_components/DashboardBuilder.d.ts.map +1 -1
- package/dist/cjs/public_components/DashboardBuilder.js +92 -30
- package/dist/cjs/public_components/DashboardManager.d.ts.map +1 -1
- package/dist/cjs/public_components/DashboardManager.js +164 -160
- package/dist/cjs/public_components/SQLViewManager.d.ts.map +1 -1
- package/dist/cjs/public_components/SQLViewManager.js +23 -4
- package/dist/cjs/utils/constants.d.ts +4 -4
- package/dist/cjs/utils/constants.js +2 -2
- package/dist/esm/Admin.d.ts +4 -1
- package/dist/esm/Admin.d.ts.map +1 -1
- package/dist/esm/Admin.js +124 -79
- package/dist/esm/AdminProvider.d.ts +1 -1
- package/dist/esm/AdminProvider.d.ts.map +1 -1
- package/dist/esm/AdminProvider.js +10 -10
- package/dist/esm/api/ConnectionClient.d.ts.map +1 -1
- package/dist/esm/api/ConnectionClient.js +13 -0
- package/dist/esm/components/UiComponents.d.ts +2 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +9 -7
- package/dist/esm/forms/client_onboard/CreateSqlViews.js +2 -2
- package/dist/esm/forms/sql_views/CreateEditSqlView.d.ts.map +1 -1
- package/dist/esm/forms/sql_views/CreateEditSqlView.js +19 -6
- package/dist/esm/modals/NewDashboardModal.js +1 -1
- package/dist/esm/modals/ReorderDashboardModal.d.ts.map +1 -1
- package/dist/esm/modals/ReorderDashboardModal.js +178 -63
- package/dist/esm/primitives/ModalPrimitive.d.ts.map +1 -1
- package/dist/esm/primitives/ModalPrimitive.js +1 -2
- package/dist/esm/public_components/DashboardBuilder.d.ts.map +1 -1
- package/dist/esm/public_components/DashboardBuilder.js +93 -31
- package/dist/esm/public_components/DashboardManager.d.ts.map +1 -1
- package/dist/esm/public_components/DashboardManager.js +164 -160
- package/dist/esm/public_components/SQLViewManager.d.ts.map +1 -1
- package/dist/esm/public_components/SQLViewManager.js +23 -4
- package/dist/esm/utils/constants.d.ts +4 -4
- package/dist/esm/utils/constants.js +2 -2
- package/package.json +1 -1
|
@@ -10,7 +10,6 @@ const AdminProvider_1 = require("../../AdminProvider");
|
|
|
10
10
|
const ConnectionClient_1 = require("../../api/ConnectionClient");
|
|
11
11
|
const SqlTextEditor_1 = __importDefault(require("../../components/SqlTextEditor"));
|
|
12
12
|
const UiComponents_1 = require("../../components/UiComponents");
|
|
13
|
-
const react_3 = require("@quillsql/react");
|
|
14
13
|
const CreateSqlViews_1 = require("../client_onboard/CreateSqlViews");
|
|
15
14
|
const DynamicBanner_1 = __importDefault(require("../../components/DynamicBanner"));
|
|
16
15
|
function CreateEditSqlView({ containerStyle, initialSqlView, closeEditView, addEditView, SecondaryButtonComponent, LoadingComponent = () => (0, jsx_runtime_1.jsx)(UiComponents_1.LoadingSpinner, {}), Button = UiComponents_1.MemoizedButton, TextInput = UiComponents_1.MemoizedTextInput, Header = UiComponents_1.MemoizedHeader, allTableData, schemaIsLoading, }) {
|
|
@@ -82,6 +81,15 @@ function CreateEditSqlView({ containerStyle, initialSqlView, closeEditView, addE
|
|
|
82
81
|
}
|
|
83
82
|
setRunQueryButtonLabel('Run query');
|
|
84
83
|
setErrorInfo({ show: false, message: '' });
|
|
84
|
+
// stringify all rows that are either jsonb or json
|
|
85
|
+
resp.rows = resp.rows.map((row) => {
|
|
86
|
+
for (const key in row) {
|
|
87
|
+
if (typeof row[key] === 'object') {
|
|
88
|
+
row[key] = JSON.stringify(row[key]);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return row;
|
|
92
|
+
});
|
|
85
93
|
setTableData(resp);
|
|
86
94
|
setViewAddable(true);
|
|
87
95
|
setRanViewQuery(query);
|
|
@@ -116,12 +124,14 @@ function CreateEditSqlView({ containerStyle, initialSqlView, closeEditView, addE
|
|
|
116
124
|
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
117
125
|
paddingLeft: '20px',
|
|
118
126
|
paddingRight: '30px',
|
|
119
|
-
}, children: (0, jsx_runtime_1.jsx)(TextInput, { placeholder: "Search...",
|
|
127
|
+
}, children: (0, jsx_runtime_1.jsx)(TextInput, { placeholder: "Search...",
|
|
128
|
+
// @ts-ignore
|
|
129
|
+
onChange: (e) => {
|
|
120
130
|
setTableSearchQuery(e);
|
|
121
131
|
setDisplayedTableData(allTableData.filter((table) => table.tableName
|
|
122
132
|
.toLowerCase()
|
|
123
133
|
.includes(e.toLowerCase().trim())));
|
|
124
|
-
}, value: tableSearchQuery, id: 'edit-name', width: "100%" }) }), (0, jsx_runtime_1.jsx)(
|
|
134
|
+
}, value: tableSearchQuery, id: 'edit-name', width: "100%" }) }), (0, jsx_runtime_1.jsx)(react_1.SchemaListComponent, { schema: displayedTableData, theme: state.theme, LoadingComponent: LoadingComponent, loading: schemaIsLoading, width: '400px' })] }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
125
135
|
display: 'flex',
|
|
126
136
|
gap: 20,
|
|
127
137
|
flexDirection: 'column',
|
|
@@ -136,10 +146,13 @@ function CreateEditSqlView({ containerStyle, initialSqlView, closeEditView, addE
|
|
|
136
146
|
justifyContent: 'space-between',
|
|
137
147
|
gap: 20,
|
|
138
148
|
width: '100%',
|
|
139
|
-
}, children: [(0, jsx_runtime_1.jsx)(TextInput
|
|
149
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInput
|
|
150
|
+
// @ts-ignore
|
|
151
|
+
, {
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
onChange: (e) => {
|
|
140
154
|
setAIPrompt(e);
|
|
141
155
|
}, placeholder: 'Describe a query...', value: aiPrompt, id: 'ai-prompt', width: '95%' }), (0, jsx_runtime_1.jsx)(Button, { label: askAIButton, onClick: handleRunSqlPrompt, width: "100px" })] }), (0, jsx_runtime_1.jsx)(SqlTextEditor_1.default, { value: editViewQuery, setValue: (e) => {
|
|
142
|
-
setErrorInfo({ show: false, message: '' });
|
|
143
156
|
setEditViewQuery(e);
|
|
144
157
|
} }), (0, jsx_runtime_1.jsx)("div", { style: { width: '200px' }, children: (0, jsx_runtime_1.jsx)(Button, { label: runQueryButtonLabel, onClick: handleRunQuery }) }), errorInfo.show ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
145
158
|
fontSize: 15,
|
|
@@ -156,6 +169,6 @@ function CreateEditSqlView({ containerStyle, initialSqlView, closeEditView, addE
|
|
|
156
169
|
display: 'flex',
|
|
157
170
|
justifyContent: 'center',
|
|
158
171
|
alignItems: 'center',
|
|
159
|
-
}, children: (0, jsx_runtime_1.jsx)(LoadingComponent, {}) })), tableData && ((0, jsx_runtime_1.jsx)(react_1.
|
|
172
|
+
}, children: (0, jsx_runtime_1.jsx)(LoadingComponent, {}) })), tableData && ((0, jsx_runtime_1.jsx)(react_1.Table, { rows: tableData.rows, columns: tableData.fields, containerStyle: { height: '360px' } })), viewAddable && ((0, jsx_runtime_1.jsx)("div", { style: { width: '200px' }, children: (0, jsx_runtime_1.jsx)(Button, { label: `${initialSqlView ? 'Save changes' : 'Create view'}`, onClick: () => addEditSqlView(false) }) }))] })] }), (0, jsx_runtime_1.jsx)(CreateSqlViews_1.ForeignKeyModal, { isOpen: showFKModal, setIsOpen: setShowFKModal, override: addEditSqlView, foreignKey: state.client.customerFieldName, tableName: state.client.customerTableName })] }) }));
|
|
160
173
|
}
|
|
161
174
|
exports.default = CreateEditSqlView;
|
|
@@ -104,7 +104,7 @@ function NewDashboardModal({ isOpen, client, setIsOpen, onSave, ModalComponent,
|
|
|
104
104
|
const body = {
|
|
105
105
|
newDashboardName: selectedDashboardName,
|
|
106
106
|
filters: updatedFilters,
|
|
107
|
-
dateFilter: {
|
|
107
|
+
dateFilter: showDateFilter && {
|
|
108
108
|
...newDateFilter,
|
|
109
109
|
comparison: isDateComparison,
|
|
110
110
|
primaryRange: initialRange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReorderDashboardModal.d.ts","sourceRoot":"","sources":["../../../src/modals/ReorderDashboardModal.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ReorderDashboardModal.d.ts","sourceRoot":"","sources":["../../../src/modals/ReorderDashboardModal.tsx"],"names":[],"mappings":"AA0BA,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,EAC5C,MAAM,EACN,SAAS,EACT,MAAM,EACN,MAAM,EACN,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,cAAc,GACf;;;;;;;;;CAAA,2CAuKA"}
|
|
@@ -4,18 +4,22 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
4
4
|
// @ts-nocheck
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const AdminProvider_1 = require("../AdminProvider");
|
|
7
|
-
const Admin_1 = require("../Admin");
|
|
8
7
|
const constants_1 = require("../utils/constants");
|
|
8
|
+
const sortable_1 = require("@dnd-kit/sortable");
|
|
9
|
+
const utilities_1 = require("@dnd-kit/utilities");
|
|
10
|
+
const core_1 = require("@dnd-kit/core");
|
|
11
|
+
const react_2 = require("@quillsql/react");
|
|
9
12
|
function ReorderDashboardModal({ isOpen, setIsOpen, client, onSave, ModalComponent, ButtonComponent, selectedDashboard, organizationId, }) {
|
|
10
13
|
// const [client] = useContext(ClientContext);
|
|
11
14
|
const [dashboardItems, setDashboardItems] = (0, react_1.useState)([]);
|
|
12
15
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
13
|
-
const [chartType, setChartType] = (0, react_1.useState)('metric');
|
|
14
16
|
const [doesDashboardHaveTables, setDoesDashboardHaveTables] = (0, react_1.useState)(false);
|
|
15
17
|
const [doesDashboardHaveCharts, setDoesDashboardHaveCharts] = (0, react_1.useState)(false);
|
|
16
18
|
const [doesDashboardHaveMetrics, setDoesDashboardHaveMetrics] = (0, react_1.useState)(false);
|
|
17
|
-
const [orderArray, setOrderArray] = (0, react_1.useState)([]);
|
|
18
19
|
const [itemMap, setItemMap] = (0, react_1.useState)(null);
|
|
20
|
+
const [metrics, setMetrics] = (0, react_1.useState)([]);
|
|
21
|
+
const [charts, setCharts] = (0, react_1.useState)([]);
|
|
22
|
+
const [tables, setTables] = (0, react_1.useState)([]);
|
|
19
23
|
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
20
24
|
(0, react_1.useEffect)(() => {
|
|
21
25
|
async function getDashboardItems() {
|
|
@@ -40,6 +44,9 @@ function ReorderDashboardModal({ isOpen, setIsOpen, client, onSave, ModalCompone
|
|
|
40
44
|
flattened = flattened.concat(responseData.sections[key]);
|
|
41
45
|
}
|
|
42
46
|
setDashboardItems(flattened);
|
|
47
|
+
setMetrics(flattened.filter((elem) => elem.chartType === 'metric'));
|
|
48
|
+
setTables(flattened.filter((elem) => elem.chartType === 'table'));
|
|
49
|
+
setCharts(flattened.filter((elem) => !['metric', 'table'].includes(elem.chartType)));
|
|
43
50
|
setLoading(false);
|
|
44
51
|
}
|
|
45
52
|
if (selectedDashboard && state.client) {
|
|
@@ -62,66 +69,174 @@ function ReorderDashboardModal({ isOpen, setIsOpen, client, onSave, ModalCompone
|
|
|
62
69
|
});
|
|
63
70
|
setItemMap(itemMap);
|
|
64
71
|
}, [dashboardItems]);
|
|
65
|
-
const
|
|
66
|
-
|
|
72
|
+
const handleSaveChanges = async () => {
|
|
73
|
+
if (!client)
|
|
74
|
+
return;
|
|
75
|
+
if (!dashboardItems.length)
|
|
76
|
+
return;
|
|
77
|
+
try {
|
|
78
|
+
const response = await fetch(`${constants_1.QUILL_SERVER}/dashorder/`, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
headers: {
|
|
81
|
+
'Content-Type': 'application/json',
|
|
82
|
+
},
|
|
83
|
+
body: JSON.stringify({
|
|
84
|
+
publicKey: client._id,
|
|
85
|
+
orderArray: [...metrics, ...charts, ...tables],
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
const errorData = await response.json();
|
|
90
|
+
throw new Error(`Error: ${errorData.error || 'Unknown error'}`);
|
|
91
|
+
}
|
|
92
|
+
await response.json();
|
|
93
|
+
onSave();
|
|
94
|
+
setIsOpen(false);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
console.error('An unknown error occurred in ReorderDashboardModal');
|
|
98
|
+
console.error(error.message);
|
|
99
|
+
}
|
|
67
100
|
};
|
|
68
|
-
return ((0, jsx_runtime_1.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
display: 'flex',
|
|
89
|
-
flexDirection: 'row',
|
|
90
|
-
alignItems: 'center',
|
|
91
|
-
justifyContent: 'space-between',
|
|
92
|
-
}, children: [(0, jsx_runtime_1.jsx)("h1", { style: { fontSize: 22, fontWeight: 600 }, children: "Reorder items" }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
93
|
-
background: '#f7f7f7',
|
|
94
|
-
borderRadius: 6,
|
|
95
|
-
height: 32,
|
|
96
|
-
display: 'flex',
|
|
97
|
-
flexDirection: 'row',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
paddingLeft: 4,
|
|
100
|
-
paddingRight: 4,
|
|
101
|
-
}, children: [doesDashboardHaveMetrics && ((0, jsx_runtime_1.jsx)("button", { style: {
|
|
102
|
-
background: chartType === 'metric' ? 'white' : undefined,
|
|
103
|
-
color: chartType === 'metric' ? '#384151' : '#677389',
|
|
104
|
-
fontWeight: chartType === 'metric' ? '600' : '500',
|
|
105
|
-
borderRadius: 4,
|
|
106
|
-
paddingLeft: 6,
|
|
107
|
-
paddingRight: 6,
|
|
108
|
-
fontSize: 16,
|
|
109
|
-
}, onClick: () => setChartType('metric'), children: "Metrics" })), doesDashboardHaveCharts && ((0, jsx_runtime_1.jsx)("button", { style: {
|
|
110
|
-
background: chartType === 'chart' ? 'white' : undefined,
|
|
111
|
-
color: chartType === 'chart' ? '#384151' : '#677389',
|
|
112
|
-
fontWeight: chartType === 'chart' ? '600' : '500',
|
|
113
|
-
borderRadius: 4,
|
|
114
|
-
paddingLeft: 6,
|
|
115
|
-
paddingRight: 6,
|
|
116
|
-
fontSize: 16,
|
|
117
|
-
}, onClick: () => setChartType('chart'), children: "Charts" })), doesDashboardHaveTables && ((0, jsx_runtime_1.jsx)("button", { style: {
|
|
118
|
-
background: chartType === 'table' ? 'white' : undefined,
|
|
119
|
-
color: chartType === 'table' ? '#384151' : '#677389',
|
|
120
|
-
fontWeight: chartType === 'table' ? '600' : '500',
|
|
121
|
-
borderRadius: 4,
|
|
122
|
-
paddingLeft: 6,
|
|
123
|
-
paddingRight: 6,
|
|
124
|
-
fontSize: 16,
|
|
125
|
-
}, onClick: () => setChartType('table'), children: "Tables" }))] })] })] }) }));
|
|
101
|
+
return ((0, jsx_runtime_1.jsxs)(ModalComponent, { isOpen: isOpen, close: () => setIsOpen(false), style: {
|
|
102
|
+
gap: 20,
|
|
103
|
+
display: 'flex',
|
|
104
|
+
flexDirection: 'column',
|
|
105
|
+
width: 'calc(100vw - 80px)',
|
|
106
|
+
height: 'calc(100vh - 80px)',
|
|
107
|
+
}, children: [(0, jsx_runtime_1.jsx)("h1", { style: { fontSize: 22, fontWeight: 600, width: '100%' }, children: "Reorder Items" }), loading ? (0, jsx_runtime_1.jsx)("div", { children: "Loading..." }) : null, (0, jsx_runtime_1.jsx)("div", { style: {
|
|
108
|
+
display: 'flex',
|
|
109
|
+
flexDirection: 'column',
|
|
110
|
+
gap: 20,
|
|
111
|
+
overflowY: 'auto',
|
|
112
|
+
width: '100%',
|
|
113
|
+
height: 'calc(100% - 20px)',
|
|
114
|
+
zIndex: 100,
|
|
115
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', flexDirection: 'column', gap: 20 }, children: dashboardItems.length > 0 && itemMap.size > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [doesDashboardHaveMetrics && ((0, jsx_runtime_1.jsx)(ReorderableGrid, { type: 'metrics', items: metrics, setItems: setMetrics })), doesDashboardHaveCharts && ((0, jsx_runtime_1.jsx)(ReorderableGrid, { type: 'charts', items: charts, setItems: setCharts })), doesDashboardHaveTables && ((0, jsx_runtime_1.jsx)(ReorderableGrid, { type: 'tables', items: tables, setItems: setTables }))] })) }) }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
116
|
+
width: '100%',
|
|
117
|
+
display: 'flex',
|
|
118
|
+
flexDirection: 'row',
|
|
119
|
+
justifyContent: 'right',
|
|
120
|
+
}, children: (0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleSaveChanges, label: "Save changes" }) })] }));
|
|
126
121
|
}
|
|
127
122
|
exports.default = ReorderDashboardModal;
|
|
123
|
+
const SortableItem = (props) => {
|
|
124
|
+
const { attributes, listeners, setNodeRef, transform, transition } = (0, sortable_1.useSortable)({ id: props.id });
|
|
125
|
+
const style = {
|
|
126
|
+
transform: utilities_1.CSS.Translate.toString(transform),
|
|
127
|
+
transition,
|
|
128
|
+
display: 'flex',
|
|
129
|
+
width: props.chartType === 'table' ? '100%' : '100%',
|
|
130
|
+
justifyContent: 'space-between',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
borderRadius: '10px',
|
|
133
|
+
border: '1px solid #E7E7E7',
|
|
134
|
+
boxShadow: '0px 2px 8px 0px rgba(56, 65, 81, 0.08)',
|
|
135
|
+
cursor: 'grab',
|
|
136
|
+
userSelect: 'none',
|
|
137
|
+
background: 'white',
|
|
138
|
+
};
|
|
139
|
+
return ((0, jsx_runtime_1.jsx)("div", { ref: setNodeRef, style: style, ...attributes, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
140
|
+
cursor: 'pointer',
|
|
141
|
+
width: '100%',
|
|
142
|
+
display: 'flex',
|
|
143
|
+
flexDirection: 'row',
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
justifyContent: 'space-between',
|
|
146
|
+
}, ...listeners, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
147
|
+
display: 'flex',
|
|
148
|
+
flexDirection: 'column',
|
|
149
|
+
justifyContent: 'space-between',
|
|
150
|
+
padding: 20,
|
|
151
|
+
width: '100%',
|
|
152
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
153
|
+
display: 'flex',
|
|
154
|
+
flexDirection: 'row',
|
|
155
|
+
paddingBottom: props.chartType === 'table' ? 10 : 0,
|
|
156
|
+
}, children: [(0, jsx_runtime_1.jsx)("h1", { style: {
|
|
157
|
+
fontSize: 18,
|
|
158
|
+
fontWeight: '500',
|
|
159
|
+
flexGrow: 1,
|
|
160
|
+
}, children: props.value }), (0, jsx_runtime_1.jsx)(HandleButton, {})] }), (0, jsx_runtime_1.jsx)(react_2.Chart, { chartId: props.id, containerStyle: {
|
|
161
|
+
padding: 10,
|
|
162
|
+
height: props.chartType === 'metric' ? 80 : 250,
|
|
163
|
+
width: 'calc(100% - 20px)',
|
|
164
|
+
} })] }) }) }));
|
|
165
|
+
};
|
|
166
|
+
function ReorderableGrid({ type, items, setItems }) {
|
|
167
|
+
const sensors = (0, core_1.useSensors)((0, core_1.useSensor)(core_1.PointerSensor), (0, core_1.useSensor)(core_1.KeyboardSensor, {
|
|
168
|
+
coordinateGetter: sortable_1.sortableKeyboardCoordinates,
|
|
169
|
+
}), (0, core_1.useSensor)(core_1.TouchSensor, {
|
|
170
|
+
activationConstraint: '',
|
|
171
|
+
}));
|
|
172
|
+
const handleDragEnd = (event) => {
|
|
173
|
+
const { active, over } = event;
|
|
174
|
+
if (!active || !over)
|
|
175
|
+
return;
|
|
176
|
+
if (active.id !== over.id) {
|
|
177
|
+
setItems((itemList) => {
|
|
178
|
+
const oldIndex = itemList.findIndex((item) => item._id === active.id);
|
|
179
|
+
const newIndex = itemList.findIndex((item) => item._id === over.id);
|
|
180
|
+
return (0, sortable_1.arrayMove)(itemList, oldIndex, newIndex);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
return ((0, jsx_runtime_1.jsx)(core_1.DndContext, { sensors: sensors, collisionDetection: core_1.closestCenter, onDragEnd: handleDragEnd, children: (0, jsx_runtime_1.jsx)("div", { style: type === 'tables'
|
|
185
|
+
? {
|
|
186
|
+
display: 'flex',
|
|
187
|
+
flexDirection: 'row',
|
|
188
|
+
flexWrap: 'wrap',
|
|
189
|
+
gap: 20,
|
|
190
|
+
}
|
|
191
|
+
: {
|
|
192
|
+
boxSizing: 'content-box',
|
|
193
|
+
width: '100%',
|
|
194
|
+
listStyleType: 'none',
|
|
195
|
+
display: 'grid',
|
|
196
|
+
gap: 20,
|
|
197
|
+
gridTemplateColumns: `repeat(auto-fill,minmax(400px, 1fr))`,
|
|
198
|
+
gridTemplateRows: `repeat(${170}px)`,
|
|
199
|
+
}, children: (0, jsx_runtime_1.jsx)(sortable_1.SortableContext, { items: items.map((item) => item._id), strategy: sortable_1.rectSortingStrategy, children: items.map((item) => ((0, jsx_runtime_1.jsx)(SortableItem, { handle: true, id: item._id, chartType: items.find((itm) => itm._id === item._id)?.chartType ?? 'chart', value: items.find((itm) => itm._id === item._id)?.name ?? item._id }, item._id))) }) }) }));
|
|
200
|
+
}
|
|
201
|
+
function HandleButton() {
|
|
202
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
203
|
+
display: 'flex',
|
|
204
|
+
gap: 2,
|
|
205
|
+
flexDirection: 'row',
|
|
206
|
+
paddingTop: 8,
|
|
207
|
+
paddingBottom: 8,
|
|
208
|
+
paddingLeft: 8,
|
|
209
|
+
paddingRight: 8,
|
|
210
|
+
borderRadius: 4,
|
|
211
|
+
}, className: "handle", children: [(0, jsx_runtime_1.jsx)("style", { children: `.handle{background:white;} .handle:hover{background:rgba(0,0,0,0.03);}` }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
212
|
+
width: 3,
|
|
213
|
+
height: 3,
|
|
214
|
+
borderRadius: 3,
|
|
215
|
+
background: '#9CA0A7',
|
|
216
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
217
|
+
width: 3,
|
|
218
|
+
height: 3,
|
|
219
|
+
borderRadius: 3,
|
|
220
|
+
background: '#9CA0A7',
|
|
221
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
222
|
+
width: 3,
|
|
223
|
+
height: 3,
|
|
224
|
+
borderRadius: 3,
|
|
225
|
+
background: '#9CA0A7',
|
|
226
|
+
} })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 2, flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
227
|
+
width: 3,
|
|
228
|
+
height: 3,
|
|
229
|
+
borderRadius: 3,
|
|
230
|
+
background: '#9CA0A7',
|
|
231
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
232
|
+
width: 3,
|
|
233
|
+
height: 3,
|
|
234
|
+
borderRadius: 3,
|
|
235
|
+
background: '#9CA0A7',
|
|
236
|
+
} }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
237
|
+
width: 3,
|
|
238
|
+
height: 3,
|
|
239
|
+
borderRadius: 3,
|
|
240
|
+
background: '#9CA0A7',
|
|
241
|
+
} })] })] }));
|
|
242
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalPrimitive.d.ts","sourceRoot":"","sources":["../../../src/primitives/ModalPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,UAAU,EAAyB,MAAM,UAAU,CAAC;AAE7D,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,
|
|
1
|
+
{"version":3,"file":"ModalPrimitive.d.ts","sourceRoot":"","sources":["../../../src/primitives/ModalPrimitive.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,UAAU,EAAyB,MAAM,UAAU,CAAC;AAE7D,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,QAAA,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA8DjD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -34,8 +34,6 @@ const ModalPrimitive = ({ isOpen, close, children, style, theme = Admin_1.theme,
|
|
|
34
34
|
maxHeight: '90vh',
|
|
35
35
|
minWidth: 462,
|
|
36
36
|
display: 'flex',
|
|
37
|
-
justifyContent: 'center',
|
|
38
|
-
alignItems: 'center',
|
|
39
37
|
transform: 'translateX(-50%) translateY(-50%)',
|
|
40
38
|
background: 'white',
|
|
41
39
|
borderRadius: 8,
|
|
@@ -43,6 +41,7 @@ const ModalPrimitive = ({ isOpen, close, children, style, theme = Admin_1.theme,
|
|
|
43
41
|
borderWidth: 1,
|
|
44
42
|
borderColor: '#e7e7e7',
|
|
45
43
|
padding: 30,
|
|
44
|
+
overflow: 'auto',
|
|
46
45
|
...style,
|
|
47
46
|
}, children: children })] }));
|
|
48
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardBuilder.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DashboardBuilder.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAwC,MAAM,OAAO,CAAC;AAa5E,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,EACd,SAAgB,GACjB,EAAE;IACD,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,2CA8ZA"}
|
|
@@ -12,6 +12,8 @@ const react_2 = require("@quillsql/react");
|
|
|
12
12
|
const constants_1 = require("../utils/constants");
|
|
13
13
|
const Banner_1 = __importDefault(require("../components/Banner"));
|
|
14
14
|
const DatabaseMismatchCard_1 = __importDefault(require("../components/DatabaseMismatchCard"));
|
|
15
|
+
const primitives_1 = require("../primitives");
|
|
16
|
+
const modeToggleOptions = ['SQL Editor', 'Report Builder'];
|
|
15
17
|
function DashboardBuilder({ navigateToDashboardManager, containerStyle, sqlEditor = true, }) {
|
|
16
18
|
const parentRef = (0, react_1.useRef)(null);
|
|
17
19
|
const { state, dispatch } = (0, AdminProvider_1.useAdmin)();
|
|
@@ -32,6 +34,7 @@ function DashboardBuilder({ navigateToDashboardManager, containerStyle, sqlEdito
|
|
|
32
34
|
const [fields, setFields] = (0, react_1.useState)([]);
|
|
33
35
|
const [errorMessage, setErrorMessage] = (0, react_1.useState)('');
|
|
34
36
|
const [sqlResponseLoading, setSqlResponseLoading] = (0, react_1.useState)(false);
|
|
37
|
+
const [toggleMode, setToggleMode] = (0, react_1.useState)('SQL Editor');
|
|
35
38
|
(0, react_1.useEffect)(() => {
|
|
36
39
|
if (state.activeQuery) {
|
|
37
40
|
setIsEditActive(true);
|
|
@@ -169,18 +172,57 @@ function DashboardBuilder({ navigateToDashboardManager, containerStyle, sqlEdito
|
|
|
169
172
|
alignItems: 'flex-end',
|
|
170
173
|
justifyContent: 'space-between',
|
|
171
174
|
width: '100%',
|
|
172
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("h1", { style: {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
175
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsx)("h1", { style: {
|
|
176
|
+
fontSize: '14px',
|
|
177
|
+
paddingTop: '0px',
|
|
178
|
+
marginTop: '0px',
|
|
179
|
+
marginBottom: '4px',
|
|
180
|
+
fontWeight: '600',
|
|
181
|
+
color: state.theme.secondaryTextColor,
|
|
182
|
+
fontFamily: state.theme.fontFamily,
|
|
183
|
+
userSelect: 'none',
|
|
184
|
+
}, children: "Environment" }), (0, jsx_runtime_1.jsx)(components_1.EnvSelectPopover, { setEnvironment: (env) => {
|
|
185
|
+
dispatch({ type: 'SET_ENVIRONMENT', payload: env });
|
|
186
|
+
}, environment: state.environment, clients: state.clients, client: state.client, setClient: (client) => dispatch({ type: 'SET_CLIENT', payload: client }), theme: state.theme, showPromote: false })] }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', marginTop: 'auto', height: 38 }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
187
|
+
display: 'flex',
|
|
188
|
+
flexDirection: 'row',
|
|
189
|
+
alignItems: 'center',
|
|
190
|
+
borderRadius: '0.25rem',
|
|
191
|
+
borderStyle: 'none',
|
|
192
|
+
outlineStyle: 'none',
|
|
193
|
+
background: '#F9FAFB',
|
|
194
|
+
paddingLeft: 3,
|
|
195
|
+
paddingRight: 3,
|
|
196
|
+
paddingTop: 4,
|
|
197
|
+
paddingBottom: 4,
|
|
198
|
+
}, children: modeToggleOptions.map((label) => ((0, jsx_runtime_1.jsx)("button", { onClick: () => setToggleMode(label), style: {
|
|
199
|
+
borderRadius: '0.25rem',
|
|
200
|
+
borderWidth: '1px',
|
|
201
|
+
fontSize: '14px',
|
|
202
|
+
outlineStyle: 'none',
|
|
203
|
+
transitionProperty: 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform',
|
|
204
|
+
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
205
|
+
transitionDuration: '300ms',
|
|
206
|
+
margin: '0px',
|
|
207
|
+
paddingTop: '0.375rem',
|
|
208
|
+
paddingBottom: '0.375rem',
|
|
209
|
+
paddingLeft: '0.75rem',
|
|
210
|
+
paddingRight: '0.75rem',
|
|
211
|
+
...(label === toggleMode
|
|
212
|
+
? {
|
|
213
|
+
fontWeight: 600,
|
|
214
|
+
backgroundColor: '#ffffff',
|
|
215
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
216
|
+
color: '#212121',
|
|
217
|
+
borderColor: '#e7e7e7',
|
|
218
|
+
}
|
|
219
|
+
: {
|
|
220
|
+
borderColor: 'transparent',
|
|
221
|
+
fontWeight: 500,
|
|
222
|
+
backgroundColor: 'transparent',
|
|
223
|
+
color: '#606572',
|
|
224
|
+
}),
|
|
225
|
+
}, children: label }, label))) }) })] }), !state.databaseTypeMismatch.show && ((0, jsx_runtime_1.jsx)(components_1.OrgSelect, { environment: state.environment, setEnvironment: (env) => {
|
|
184
226
|
dispatch({ type: 'SET_ENVIRONMENT', payload: env });
|
|
185
227
|
}, organizations: state.organizations, organizationId: state.organizationId, setOrganizationId: (orgId) => {
|
|
186
228
|
dispatch({ type: 'SET_ORGANIZATION_ID', payload: orgId });
|
|
@@ -190,23 +232,43 @@ function DashboardBuilder({ navigateToDashboardManager, containerStyle, sqlEdito
|
|
|
190
232
|
return;
|
|
191
233
|
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
192
234
|
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
193
|
-
} })), state.databaseTypeMismatch.show && ((0, jsx_runtime_1.jsx)(DatabaseMismatchCard_1.default, { environemntName: state.client.name, environemntDatabaseType: state.client.databaseType, backendDatabaseType: state.databaseTypeMismatch.backendDatabaseType })),
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
});
|
|
201
|
-
state.navigateToDashboardManager
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
235
|
+
} })), state.databaseTypeMismatch.show && ((0, jsx_runtime_1.jsx)(DatabaseMismatchCard_1.default, { environemntName: state.client.name, environemntDatabaseType: state.client.databaseType, backendDatabaseType: state.databaseTypeMismatch.backendDatabaseType })), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
236
|
+
// Toggle the height of the container so they both stay in the DOM
|
|
237
|
+
// and don't refetch when switching back and forth.
|
|
238
|
+
height: toggleMode === 'Report Builder' ? '100%' : 0,
|
|
239
|
+
overflow: 'hidden',
|
|
240
|
+
}, children: (0, jsx_runtime_1.jsx)(react_2.ReportBuilder, { admin: true, initialTableName: state.tables.length > 0 && state.tables[0].name, onAddToDashboardComplete: () => {
|
|
241
|
+
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
242
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
243
|
+
if (state.navigateToDashboardManager) {
|
|
244
|
+
dispatch({
|
|
245
|
+
type: 'SET_ACTIVE_COMPONENT',
|
|
246
|
+
payload: 'Dashboards',
|
|
247
|
+
});
|
|
248
|
+
state.navigateToDashboardManager();
|
|
249
|
+
}
|
|
250
|
+
}, organizationName: state.organizations.find((org) => {
|
|
251
|
+
return (org.id && String(org.id) === String(state.organizationId));
|
|
252
|
+
})?.name }) }), sqlEditor && !state.databaseTypeMismatch.show && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
253
|
+
height: toggleMode === 'SQL Editor' ? '100%' : 0,
|
|
254
|
+
overflow: 'hidden',
|
|
255
|
+
}, children: (0, jsx_runtime_1.jsx)(react_2.SQLEditor, { chartBuilderEnabled: true, showAccessControlOptions: true, showDateFieldOptions: true, showTableFormatOptions: true, defaultQuery: query, isEditMode: !!state.activeQuery, addToDashboardButtonLabel: state.activeQuery ? 'Save changes' : 'Add to dashboard', chartBuilderTitle: state.activeQuery ? 'Save changes' : 'Add to dashboard', dashboardItem: state.activeQuery ? state.activeEditItem : undefined, onAddToDashboardComplete: () => {
|
|
256
|
+
dispatch({ type: 'SET_ACTIVE_QUERY', payload: '' });
|
|
257
|
+
dispatch({ type: 'SET_ACTIVE_EDIT_ITEM', payload: null });
|
|
258
|
+
if (state.navigateToDashboardManager) {
|
|
259
|
+
dispatch({
|
|
260
|
+
type: 'SET_ACTIVE_COMPONENT',
|
|
261
|
+
payload: 'Dashboards',
|
|
262
|
+
});
|
|
263
|
+
state.navigateToDashboardManager();
|
|
264
|
+
}
|
|
265
|
+
}, containerStyle: {
|
|
266
|
+
height: '100%',
|
|
267
|
+
width: '100%',
|
|
268
|
+
// paddingRight: 25,
|
|
269
|
+
// paddingTop: 25,
|
|
270
|
+
}, organizationName: state.organizations.find((org) => {
|
|
271
|
+
return (org.id && String(org.id) === String(state.organizationId));
|
|
272
|
+
})?.name, ButtonComponent: primitives_1.ButtonPrimitive }) }))] }) }));
|
|
211
273
|
}
|
|
212
274
|
exports.default = DashboardBuilder;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardManager.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA+B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"DashboardManager.d.ts","sourceRoot":"","sources":["../../../src/public_components/DashboardManager.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAA+B,MAAM,OAAO,CAAC;AAiCnE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,EACvC,0BAA0B,EAC1B,cAAc,GACf,EAAE;IACD,0BAA0B,CAAC,EAAE,MAAM,IAAI,CAAC;IACxC,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC,2CAukBA"}
|