@quillsql/react 2.11.9 → 2.11.12
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/BarList.d.ts +2 -1
- package/dist/cjs/BarList.d.ts.map +1 -1
- package/dist/cjs/BarList.js +9 -3
- package/dist/cjs/Chart.d.ts +11 -5
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +57 -20
- package/dist/cjs/ChartBuilder.d.ts +16 -1
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +423 -281
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +1 -0
- package/dist/cjs/Dashboard.d.ts +2 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +5 -19
- package/dist/cjs/PieChart.d.ts.map +1 -1
- package/dist/cjs/PieChart.js +2 -1
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +15 -1
- package/dist/cjs/ReportBuilder.d.ts +4 -3
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +76 -45
- package/dist/cjs/SQLEditor.d.ts +2 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +60 -90
- package/dist/cjs/components/Chart/BarChart.d.ts +2 -1
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +10 -3
- package/dist/cjs/components/Chart/LineChart.d.ts +3 -4
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +32 -15
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +0 -3
- package/dist/cjs/components/Dashboard/DashboardSection.js +4 -4
- package/dist/cjs/components/Dashboard/DashboardSectionContainer.js +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +8 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +12 -3
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +12 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +105 -9
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +78 -3
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +3 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +5 -4
- package/dist/cjs/components/ReportBuilder/ast.d.ts +4 -0
- package/dist/cjs/components/ReportBuilder/ast.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ast.js +10 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts +4 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +45 -13
- package/dist/cjs/components/ReportBuilder/pivot.d.ts +3 -0
- package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +3 -2
- package/dist/cjs/components/ReportBuilder/util.d.ts +1 -0
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +48 -1
- package/dist/cjs/components/UiComponents.d.ts +3 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +4 -4
- package/dist/cjs/hooks/useQuill.js +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +65 -62
- package/dist/cjs/utils/axisFormatter.js +74 -30
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +10 -0
- package/dist/cjs/utils/getDomain.d.ts.map +1 -1
- package/dist/cjs/utils/getDomain.js +22 -4
- package/dist/cjs/utils/valueFormatter.d.ts +2 -1
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/BarList.d.ts +2 -1
- package/dist/esm/BarList.d.ts.map +1 -1
- package/dist/esm/BarList.js +9 -3
- package/dist/esm/Chart.d.ts +11 -5
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +57 -20
- package/dist/esm/ChartBuilder.d.ts +16 -1
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +421 -280
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +1 -0
- package/dist/esm/Dashboard.d.ts +2 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +5 -19
- package/dist/esm/PieChart.d.ts.map +1 -1
- package/dist/esm/PieChart.js +2 -1
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +16 -2
- package/dist/esm/ReportBuilder.d.ts +4 -3
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +80 -49
- package/dist/esm/SQLEditor.d.ts +2 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +61 -91
- package/dist/esm/components/Chart/BarChart.d.ts +2 -1
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +10 -3
- package/dist/esm/components/Chart/LineChart.d.ts +3 -4
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +32 -15
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +0 -3
- package/dist/esm/components/Dashboard/DashboardSection.js +4 -4
- package/dist/esm/components/Dashboard/DashboardSectionContainer.js +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +8 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +13 -4
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +12 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +101 -8
- package/dist/esm/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +74 -2
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +3 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +6 -5
- package/dist/esm/components/ReportBuilder/ast.d.ts +4 -0
- package/dist/esm/components/ReportBuilder/ast.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ast.js +8 -0
- package/dist/esm/components/ReportBuilder/convert.d.ts +4 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +45 -13
- package/dist/esm/components/ReportBuilder/pivot.d.ts +3 -0
- package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +3 -2
- package/dist/esm/components/ReportBuilder/util.d.ts +1 -0
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +46 -0
- package/dist/esm/components/UiComponents.d.ts +3 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +4 -4
- package/dist/esm/hooks/useQuill.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +65 -62
- package/dist/esm/utils/axisFormatter.js +74 -30
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +10 -0
- package/dist/esm/utils/getDomain.d.ts.map +1 -1
- package/dist/esm/utils/getDomain.js +22 -4
- package/dist/esm/utils/valueFormatter.d.ts +2 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/SQLEditor.js
CHANGED
|
@@ -14,6 +14,8 @@ const Context_1 = require("./Context");
|
|
|
14
14
|
const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
15
15
|
const dataFetcher_1 = require("./utils/dataFetcher");
|
|
16
16
|
const ChartBuilder_1 = require("./ChartBuilder");
|
|
17
|
+
const UiComponents_1 = require("./components/UiComponents");
|
|
18
|
+
const ui_1 = require("./components/ReportBuilder/ui");
|
|
17
19
|
function convertPostgresColumn(column) {
|
|
18
20
|
let format;
|
|
19
21
|
let fieldType;
|
|
@@ -129,29 +131,8 @@ const QuillButton = ({ onClick, label, theme, secondary, }) => ((0, jsx_runtime_
|
|
|
129
131
|
fontFamily: theme?.fontFamily,
|
|
130
132
|
height: 38,
|
|
131
133
|
}, onClick: onClick, children: label }));
|
|
132
|
-
|
|
133
|
-
return ((0, jsx_runtime_1.jsx)("input", { style: {
|
|
134
|
-
display: 'flex',
|
|
135
|
-
flexDirection: 'row',
|
|
136
|
-
alignItems: 'center',
|
|
137
|
-
paddingLeft: '12px',
|
|
138
|
-
paddingRight: '12px',
|
|
139
|
-
fontWeight: 'medium',
|
|
140
|
-
height: 38,
|
|
141
|
-
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
|
|
142
|
-
width: '445px',
|
|
143
|
-
backgroundColor: theme?.backgroundColor || 'white',
|
|
144
|
-
color: theme?.primaryTextColor,
|
|
145
|
-
borderWidth: '1px',
|
|
146
|
-
borderColor: theme?.borderColor || '#E7E7E7',
|
|
147
|
-
borderStyle: 'solid',
|
|
148
|
-
borderRadius: '6px',
|
|
149
|
-
...style
|
|
150
|
-
}, id: id, onChange: onChange, value: value, placeholder: placeholder }));
|
|
151
|
-
};
|
|
152
|
-
function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, SecondaryButtonComponent, TextInputComponent, TableComponent = QuillTable_1.default, newQueryEnabled = false, LoadingComponent, ModalComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode = false, chartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', dashboardItem = undefined, organizationName = undefined, chartBuilderHorizontalView = false, }) {
|
|
134
|
+
function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent = UiComponents_1.MemoizedButton, SecondaryButtonComponent = UiComponents_1.MemoizedSecondaryButton, TextInputComponent = ui_1.QuillTextInput, TableComponent = QuillTable_1.default, newQueryEnabled = false, LoadingComponent, ModalComponent, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isEditMode = false, chartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', dashboardItem = undefined, organizationName = undefined, chartBuilderHorizontalView = false, }) {
|
|
153
135
|
const [sqlPrompt, setSqlPrompt] = (0, react_1.useState)('');
|
|
154
|
-
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
155
136
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
156
137
|
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
157
138
|
const [query, setQuery] = (0, react_1.useState)(defaultQuery);
|
|
@@ -243,15 +224,6 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
243
224
|
if (resp.rows.length === 0) {
|
|
244
225
|
setErrorMessage('No data found');
|
|
245
226
|
}
|
|
246
|
-
// stringify all rows that are either jsonb or json
|
|
247
|
-
resp.rows = resp.rows.map((row) => {
|
|
248
|
-
for (const key in row) {
|
|
249
|
-
if (typeof row[key] === 'object') {
|
|
250
|
-
row[key] = JSON.stringify(row[key]);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
return row;
|
|
254
|
-
});
|
|
255
227
|
setRows(resp.rows && resp.rows.length ? resp.rows : []);
|
|
256
228
|
if (onChangeData) {
|
|
257
229
|
onChangeData(resp.rows && resp.rows.length ? resp.rows : []);
|
|
@@ -270,13 +242,39 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
270
242
|
return;
|
|
271
243
|
}
|
|
272
244
|
};
|
|
273
|
-
|
|
245
|
+
const handleFixWithAI = async () => {
|
|
246
|
+
try {
|
|
247
|
+
setDisplayTable(false);
|
|
248
|
+
setSqlResponseLoading(true);
|
|
249
|
+
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, 'plsfix', {
|
|
250
|
+
initialQuestion: sqlPrompt,
|
|
251
|
+
brokenQuery: query,
|
|
252
|
+
errorMessage: errorMessage,
|
|
253
|
+
});
|
|
254
|
+
setErrorMessage('');
|
|
255
|
+
setQuery(resp.message);
|
|
256
|
+
setSqlResponseLoading(false);
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
setErrorMessage('Failed to fix query');
|
|
260
|
+
setSqlResponseLoading(false);
|
|
261
|
+
console.log('ERROR: ', e);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
const handleClickSchemaItem = async (event) => {
|
|
265
|
+
const name = event.target.textContent;
|
|
266
|
+
if (query.length > 0) {
|
|
267
|
+
await navigator.clipboard.writeText(name);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
setQuery(`SELECT * FROM ${name};`);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
274
273
|
(0, react_1.useEffect)(() => {
|
|
275
274
|
if (onChangeQuery) {
|
|
276
275
|
onChangeQuery(query);
|
|
277
276
|
}
|
|
278
277
|
}, [query]);
|
|
279
|
-
/* rest of your methods */
|
|
280
278
|
return ((0, jsx_runtime_1.jsxs)("div", { style: containerStyle, children: [(!chartBuilderHorizontalView ||
|
|
281
279
|
(chartBuilderHorizontalView && !isChartBuilderOpen)) && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
282
280
|
height: '100%',
|
|
@@ -289,22 +287,23 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
289
287
|
height: '100%',
|
|
290
288
|
flexDirection: 'row',
|
|
291
289
|
gap: 20,
|
|
292
|
-
}, children: [(0, jsx_runtime_1.jsx)(exports.SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
290
|
+
}, children: [(0, jsx_runtime_1.jsx)(exports.SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading, onClick: handleClickSchemaItem }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
293
291
|
display: 'flex',
|
|
294
292
|
// gap: 12,
|
|
295
293
|
flexDirection: 'column',
|
|
296
294
|
width: 'calc(100% - 290px)',
|
|
297
295
|
height: '100%',
|
|
298
296
|
overflowX: 'hidden',
|
|
299
|
-
}, children: [(0, jsx_runtime_1.jsxs)("
|
|
300
|
-
|
|
301
|
-
|
|
297
|
+
}, children: [(0, jsx_runtime_1.jsxs)("form", { onSubmit: (e) => {
|
|
298
|
+
e.preventDefault();
|
|
299
|
+
handleRunSqlPrompt();
|
|
300
|
+
}, style: {
|
|
302
301
|
display: 'flex',
|
|
303
302
|
flexDirection: 'row',
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
}, children: [(0, jsx_runtime_1.jsx)(
|
|
303
|
+
gap: 12,
|
|
304
|
+
paddingTop: 16,
|
|
305
|
+
paddingBottom: 16,
|
|
306
|
+
}, children: [(0, jsx_runtime_1.jsx)(TextInputComponent, { id: "ai-search", value: sqlPrompt, style: { width: '100%', fontSize: 14 }, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }), (ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] }), (0, jsx_runtime_1.jsx)("div", { style: { height: 'calc(50% - 40px)' }, children: (0, jsx_runtime_1.jsx)(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, handleFixWithAI: handleFixWithAI, newQueryEnabled: newQueryEnabled, handleClearQuery: handleClearQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
308
307
|
display: 'flex',
|
|
309
308
|
flexDirection: 'column',
|
|
310
309
|
height: 'calc(50% - 108px)',
|
|
@@ -317,16 +316,19 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
317
316
|
color: theme?.primaryTextColor,
|
|
318
317
|
fontSize: 15,
|
|
319
318
|
fontWeight: '400',
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
319
|
+
width: '100%',
|
|
320
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
321
|
+
display: 'flex',
|
|
322
|
+
flexDirection: 'row',
|
|
323
|
+
justifyContent: 'space-between',
|
|
324
|
+
gap: 12,
|
|
325
|
+
background: 'rgba(0,0,0,0.02)', // TODO: change color
|
|
327
326
|
color: theme?.primaryTextColor,
|
|
328
327
|
fontFamily: theme?.fontFamily,
|
|
329
|
-
|
|
328
|
+
borderRadius: 6,
|
|
329
|
+
padding: 20,
|
|
330
|
+
width: '100%',
|
|
331
|
+
}, children: [errorMessage, (SecondaryButtonComponent && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleFixWithAI, label: "Fix with AI" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { secondary: true, onClick: handleFixWithAI, label: "Fix with AI", theme: theme }))] }) })), errorMessage || !displayTable ? null : ((0, jsx_runtime_1.jsx)(TableComponent, { rows: rows, columns: columns, containerStyle: { height: 'calc(100%)' }, LoadingComponent: LoadingComponent, loading: sqlQueryLoading }))] }), chartBuilderEnabled && rows.length > 0 && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
330
332
|
display: 'flex',
|
|
331
333
|
flexDirection: 'row',
|
|
332
334
|
alignItems: 'center',
|
|
@@ -336,7 +338,7 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
336
338
|
}, children: (ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: () => setIsChartBuilderOpen(true), label: addToDashboardButtonLabel }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { onClick: () => setIsChartBuilderOpen(true), label: addToDashboardButtonLabel, theme: theme })) }))] })] }) }) })), (0, jsx_runtime_1.jsx)(ChartBuilder_1.ChartBuilderWithModal, { rows: rows, columns: columns, fields: fields, query: query, horizontalView: chartBuilderHorizontalView, isEditMode: isEditMode, isOpen: isChartBuilderOpen, setIsOpen: setIsChartBuilderOpen, onAddToDashboardComplete: onAddToDashboardComplete, showTableFormatOptions: showTableFormatOptions, showDateFieldOptions: showDateFieldOptions, showAccessControlOptions: showAccessControlOptions, destinationDashboard: destinationDashboard, title: chartBuilderTitle, button: chartBuilderButtonLabel, buttonLabel: addToDashboardButtonLabel, dashboardItem: dashboardItem, organizationName: organizationName, Modal: ModalComponent, Button: ButtonComponent })] }));
|
|
337
339
|
}
|
|
338
340
|
exports.default = QueryEditor;
|
|
339
|
-
const SQLEditorComponent = ({ query, setQuery, handleRunQuery, handleClearQuery, defineEditorTheme, setEditorTheme, ButtonComponent, SecondaryButtonComponent, newQueryEnabled, theme, loading, LoadingComponent, }) => {
|
|
341
|
+
const SQLEditorComponent = ({ query, setQuery, handleRunQuery, handleFixWithAI, handleClearQuery, defineEditorTheme, setEditorTheme, ButtonComponent, SecondaryButtonComponent, newQueryEnabled, theme, loading, LoadingComponent, }) => {
|
|
340
342
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
341
343
|
background: theme.backgroundColor,
|
|
342
344
|
// maxHeight: 700,
|
|
@@ -371,41 +373,9 @@ const SQLEditorComponent = ({ query, setQuery, handleRunQuery, handleClearQuery,
|
|
|
371
373
|
flexDirection: 'row',
|
|
372
374
|
alignItems: 'center',
|
|
373
375
|
height: 70,
|
|
374
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex' }, children: [(ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })), newQueryEnabled && ((0, jsx_runtime_1.jsx)("div", { children: (SecondaryButtonComponent && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleClearQuery, label: "Clear query" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { secondary: true, onClick: handleClearQuery, label: "Clear query", theme: theme })) }))] }) })] }));
|
|
376
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: 12 }, children: [(ButtonComponent && ((0, jsx_runtime_1.jsx)(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })), newQueryEnabled && ((0, jsx_runtime_1.jsx)("div", { children: (SecondaryButtonComponent && ((0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: handleClearQuery, label: "Clear query" }))) || ((0, jsx_runtime_1.jsx)(QuillButton, { secondary: true, onClick: handleClearQuery, label: "Clear query", theme: theme })) }))] }) })] }));
|
|
375
377
|
};
|
|
376
|
-
const
|
|
377
|
-
columnHeader: {
|
|
378
|
-
boxSizing: 'border-box',
|
|
379
|
-
flex: '150 0 auto',
|
|
380
|
-
minWidth: '50px',
|
|
381
|
-
width: '150px',
|
|
382
|
-
position: 'relative',
|
|
383
|
-
cursor: 'pointer',
|
|
384
|
-
background: 'rgb(249, 250, 251)',
|
|
385
|
-
borderRight: '1px solid rgb(229, 231, 235)',
|
|
386
|
-
whiteSpace: 'nowrap',
|
|
387
|
-
display: 'flex',
|
|
388
|
-
alignItems: 'center',
|
|
389
|
-
overflowX: 'visible',
|
|
390
|
-
margin: '0px',
|
|
391
|
-
textOverflow: 'ellipsis',
|
|
392
|
-
minHeight: '36px',
|
|
393
|
-
// 2.25rem * 16px = 36px
|
|
394
|
-
},
|
|
395
|
-
columnHeaderLabel: {
|
|
396
|
-
fontFamily: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',
|
|
397
|
-
WebkitTapHighlightColor: 'transparent',
|
|
398
|
-
color: 'rgb(55, 65, 81)',
|
|
399
|
-
textDecoration: 'none',
|
|
400
|
-
fontWeight: 500,
|
|
401
|
-
fontSize: '14px', // 0.875rem * 16px = 14px
|
|
402
|
-
lineHeight: '20px', // 1.25rem * 16px = 20px
|
|
403
|
-
textOverflow: 'ellipsis',
|
|
404
|
-
whiteSpace: 'nowrap',
|
|
405
|
-
overflow: 'hidden',
|
|
406
|
-
},
|
|
407
|
-
};
|
|
408
|
-
const SchemaListComponent = ({ schema, theme, loading, LoadingComponent, width, }) => {
|
|
378
|
+
const SchemaListComponent = ({ schema, theme, loading, LoadingComponent, width, onClick = () => { }, }) => {
|
|
409
379
|
if (loading) {
|
|
410
380
|
return ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
411
381
|
background: theme.backgroundColor,
|
|
@@ -433,10 +403,10 @@ const SchemaListComponent = ({ schema, theme, loading, LoadingComponent, width,
|
|
|
433
403
|
// maxHeight: "100%",
|
|
434
404
|
paddingLeft: 20,
|
|
435
405
|
paddingRight: 30,
|
|
436
|
-
}, children: schema.map((elem, index) => ((0, jsx_runtime_1.jsx)(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index))) }));
|
|
406
|
+
}, children: schema.map((elem, index) => ((0, jsx_runtime_1.jsx)(SchemaItem, { elem: elem, theme: theme, index: index, onClick: onClick }, elem.displayName + index))) }));
|
|
437
407
|
};
|
|
438
408
|
exports.SchemaListComponent = SchemaListComponent;
|
|
439
|
-
function SchemaItem({ elem, theme, index }) {
|
|
409
|
+
function SchemaItem({ elem, theme, index, onClick }) {
|
|
440
410
|
const [isOpen, setIsOpen] = (0, react_1.useState)(index === 0);
|
|
441
411
|
const schemaContainerStyle = {
|
|
442
412
|
display: 'flex',
|
|
@@ -454,12 +424,11 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
454
424
|
alignItems: 'center',
|
|
455
425
|
width: '100%',
|
|
456
426
|
justifyContent: 'space-between',
|
|
457
|
-
cursor: 'pointer',
|
|
458
427
|
};
|
|
459
428
|
const schemaRowHoverStyle = {
|
|
460
429
|
background: theme.selectUnderlayColor,
|
|
461
430
|
};
|
|
462
|
-
return ((0, jsx_runtime_1.jsxs)("div", { style: schemaContainerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) },
|
|
431
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: schemaContainerStyle, children: [(0, jsx_runtime_1.jsxs)("div", { style: { ...schemaRowStyle, ...(isOpen && schemaRowHoverStyle) }, children: [(0, jsx_runtime_1.jsx)("p", { style: {
|
|
463
432
|
marginLeft: theme.padding,
|
|
464
433
|
fontSize: 13,
|
|
465
434
|
color: '#384151',
|
|
@@ -469,9 +438,10 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
469
438
|
margin: 0,
|
|
470
439
|
textOverflow: 'ellipsis',
|
|
471
440
|
overflow: 'hidden',
|
|
441
|
+
cursor: 'pointer',
|
|
472
442
|
userSelect: 'none',
|
|
473
443
|
fontFamily: theme?.fontFamily,
|
|
474
|
-
}, title: elem.displayName, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
444
|
+
}, title: elem.displayName, onClick: onClick, children: elem.displayName }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
475
445
|
display: 'flex',
|
|
476
446
|
alignItems: 'center',
|
|
477
447
|
justifyContent: 'center',
|
|
@@ -481,7 +451,7 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
481
451
|
paddingLeft: 0,
|
|
482
452
|
cursor: 'pointer',
|
|
483
453
|
userSelect: 'none',
|
|
484
|
-
}, children: isOpen ? ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M12.53 16.28a.75.75 0 01-1.06 0l-7.5-7.5a.75.75 0 011.06-1.06L12 14.69l6.97-6.97a.75.75 0 111.06 1.06l-7.5 7.5z", clipRule: "evenodd" }) })) : ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M16.28 11.47a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 01-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 011.06-1.06l7.5 7.5z", clipRule: "evenodd" }) })) })] }), isOpen ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
454
|
+
}, onClick: () => setIsOpen(!isOpen), children: isOpen ? ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M12.53 16.28a.75.75 0 01-1.06 0l-7.5-7.5a.75.75 0 011.06-1.06L12 14.69l6.97-6.97a.75.75 0 111.06 1.06l-7.5 7.5z", clipRule: "evenodd" }) })) : ((0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "12", height: "12", fill: theme.secondaryTextColor, children: (0, jsx_runtime_1.jsx)("path", { fillRule: "evenodd", d: "M16.28 11.47a.75.75 0 010 1.06l-7.5 7.5a.75.75 0 01-1.06-1.06L14.69 12 7.72 5.03a.75.75 0 011.06-1.06l7.5 7.5z", clipRule: "evenodd" }) })) })] }), isOpen ? ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
485
455
|
paddingBottom: theme.padding,
|
|
486
456
|
display: 'flex',
|
|
487
457
|
flexDirection: 'column',
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { type ColorMapType } from '../../Chart';
|
|
2
3
|
export default function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isStacked, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, }: {
|
|
3
4
|
colors?: string[];
|
|
4
|
-
colorMap?:
|
|
5
|
+
colorMap?: ColorMapType;
|
|
5
6
|
yAxisFields: any[];
|
|
6
7
|
data: any[];
|
|
7
8
|
containerStyle?: React.CSSProperties;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/BarChart.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/BarChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,GAC1B,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;CAC5B,2CAgLA"}
|
|
@@ -28,6 +28,13 @@ function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisFi
|
|
|
28
28
|
});
|
|
29
29
|
setFormattedData(curData);
|
|
30
30
|
}, [data]);
|
|
31
|
+
const getCustomColor = (field) => {
|
|
32
|
+
const key = field.startsWith('comparison_') ? 'comparison' : 'primary';
|
|
33
|
+
field = field.replace('comparison_', '');
|
|
34
|
+
if (colorMap && colorMap[field])
|
|
35
|
+
return colorMap[field][key];
|
|
36
|
+
return undefined;
|
|
37
|
+
};
|
|
31
38
|
if (!data || data.length === 0) {
|
|
32
39
|
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
33
40
|
display: 'flex',
|
|
@@ -44,12 +51,12 @@ function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisFi
|
|
|
44
51
|
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
45
52
|
boxSizing: 'content-box',
|
|
46
53
|
...containerStyle,
|
|
47
|
-
}, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: '100%', children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: formattedData, layout: 'horizontal', children: [!hideCartesianGrid && ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { width: 44, hide: hideYAxis, axisLine: false, tickLine: false, type: "number", domain: (0, getDomain_1.default)(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, style: {
|
|
54
|
+
}, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: '100%', children: (0, jsx_runtime_1.jsxs)(recharts_1.BarChart, { data: formattedData, layout: 'horizontal', children: [!hideCartesianGrid && ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { width: 44, hide: hideYAxis, axisLine: false, tickLine: false, type: "number", domain: (0, getDomain_1.default)(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, tickCount: 5, style: {
|
|
48
55
|
fontSize: '12px',
|
|
49
56
|
fontFamily: theme.chartLabelFontFamily,
|
|
50
57
|
}, tickFormatter: (tick) => (0, axisFormatter_1.axisFormatter)({
|
|
51
58
|
value: tick,
|
|
52
|
-
field: yAxisFields[0]
|
|
59
|
+
field: yAxisFields[0]?.field,
|
|
53
60
|
fields: yAxisFields,
|
|
54
61
|
}) }), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { hide: hideXAxis, dataKey: xAxisField, tick: { transform: 'translate(0, 6)' }, style: {
|
|
55
62
|
fontSize: '12px',
|
|
@@ -78,7 +85,7 @@ function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisFi
|
|
|
78
85
|
}, position: { y: 0 } }), yAxisFields.map((elem) => {
|
|
79
86
|
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { name: elem.label, dataKey: elem.field, stackId: isStacked &&
|
|
80
87
|
(elem.field?.replace('comparison_', '') ??
|
|
81
|
-
'unknown'), type: "linear", fill: (
|
|
88
|
+
'unknown'), type: "linear", fill: getCustomColor(elem.field) ??
|
|
82
89
|
(0, color_1.selectColor)(elem, colors, yAxisFields.findIndex((field) => field.field === elem.field?.replace('comparison_', ''))), isAnimationActive: isAnimationActive }, elem.field));
|
|
83
90
|
})] }) }) }));
|
|
84
91
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { type ColorMapType } from '../../Chart';
|
|
3
|
+
export default function LineChart({ colors, colorMap, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dashedComparison, singlePointStyle, }: {
|
|
3
4
|
colors?: string[];
|
|
4
|
-
colorMap?:
|
|
5
|
+
colorMap?: ColorMapType;
|
|
5
6
|
yAxisFields: any[];
|
|
6
7
|
data: any[];
|
|
7
8
|
containerStyle?: React.CSSProperties;
|
|
@@ -15,8 +16,6 @@ export default function LineChart({ colors, colorMap, yAxisFields, data, contain
|
|
|
15
16
|
hideYAxis: boolean;
|
|
16
17
|
hideCartesianGrid: boolean;
|
|
17
18
|
dashedComparison: boolean;
|
|
18
|
-
customPrimaryColor: string | undefined;
|
|
19
|
-
customComparisonColor: string | undefined;
|
|
20
19
|
singlePointStyle: 'dot' | 'line';
|
|
21
20
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
22
21
|
//# sourceMappingURL=LineChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":";AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,gBAAwB,EACxB,gBAAwB,GACzB,EAAE;IACD,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,KAAK,GAAG,MAAM,CAAC;CAClC,kDA6OA"}
|
|
@@ -12,7 +12,8 @@ const color_1 = require("../../utils/color");
|
|
|
12
12
|
const ChartTooltip_1 = __importDefault(require("../../components/Chart/ChartTooltip"));
|
|
13
13
|
const getDomain_1 = __importDefault(require("../../utils/getDomain"));
|
|
14
14
|
const react_1 = require("react");
|
|
15
|
-
|
|
15
|
+
const crypto_1 = require("../../utils/crypto");
|
|
16
|
+
function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, xAxisField, xAxisFormat, theme, comparison, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, dashedComparison = false, singlePointStyle = 'dot', }) {
|
|
16
17
|
const [formattedData, setFormattedData] = (0, react_1.useState)([]);
|
|
17
18
|
if (!yAxisFields || !yAxisFields.length) {
|
|
18
19
|
return null;
|
|
@@ -49,19 +50,21 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, x
|
|
|
49
50
|
fontSize: 13,
|
|
50
51
|
color: theme.secondaryTextColor,
|
|
51
52
|
...containerStyle,
|
|
52
|
-
}, children: "No results
|
|
53
|
+
}, children: "No results" }));
|
|
53
54
|
}
|
|
54
55
|
// Allows the users to override the color scheme on a per-chart basis.
|
|
55
|
-
const getCustomColor = (index, field) => {
|
|
56
|
-
|
|
57
|
-
return customPrimaryColor;
|
|
58
|
-
}
|
|
59
|
-
if (index === 1 && comparison && customComparisonColor) {
|
|
60
|
-
return customComparisonColor;
|
|
61
|
-
}
|
|
56
|
+
const getCustomColor = (index, field, gradient) => {
|
|
57
|
+
let key = index === 0 ? 'primary' : 'comparison';
|
|
62
58
|
if (colorMap && colorMap[field]) {
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
if (index === 0 && gradient === 'start')
|
|
60
|
+
key = 'primaryGradientStart';
|
|
61
|
+
if (index === 0 && gradient === 'stop')
|
|
62
|
+
key = 'primaryGradientStop';
|
|
63
|
+
if (index === 1 && gradient === 'start')
|
|
64
|
+
key = 'comparisonGradientStart';
|
|
65
|
+
if (index === 1 && gradient === 'stop')
|
|
66
|
+
key = 'comparisonGradientStop';
|
|
67
|
+
return colorMap[field][key];
|
|
65
68
|
}
|
|
66
69
|
return undefined; // use the default colors from the theme
|
|
67
70
|
};
|
|
@@ -77,7 +80,7 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, x
|
|
|
77
80
|
field: xAxisField,
|
|
78
81
|
fields: [{ field: xAxisField, format: xAxisFormat }],
|
|
79
82
|
});
|
|
80
|
-
} }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: hideYAxis, width: 44, axisLine: false, tickLine: false, type: "number", domain: (0, getDomain_1.default)(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, style: {
|
|
83
|
+
} }), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { hide: hideYAxis, width: 44, axisLine: false, tickLine: false, type: "number", domain: (0, getDomain_1.default)(data, yAxisFields), tick: { transform: 'translate(-3, 0)' }, tickCount: 5, style: {
|
|
81
84
|
fontSize: '12px',
|
|
82
85
|
fontFamily: theme?.chartLabelFontFamily ||
|
|
83
86
|
theme?.fontFamily ||
|
|
@@ -109,8 +112,22 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, x
|
|
|
109
112
|
{ field: xAxisField, format: xAxisFormat },
|
|
110
113
|
],
|
|
111
114
|
}), xAxisFormat: xAxisFormat, xAxisField: xAxisField, colors: colors, theme: theme }));
|
|
112
|
-
}, position: { y: 0 } }), yAxisFields.map((elem, index) =>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
}, position: { y: 0 } }), yAxisFields.map((elem, index) => {
|
|
116
|
+
// hash the color stops so they're stable, valid html ids
|
|
117
|
+
const gradientStart = getCustomColor(index, elem.field, 'start') ??
|
|
118
|
+
(0, color_1.selectColor)(elem, colors, index);
|
|
119
|
+
const gradientStop = getCustomColor(index, elem.field, 'stop') ?? '#00000000';
|
|
120
|
+
const uniqueId = `gradient_${(0, crypto_1.hashCode)(gradientStart)}_${(0, crypto_1.hashCode)(gradientStop)}`;
|
|
121
|
+
return ((0, jsx_runtime_1.jsx)("defs", { children: (0, jsx_runtime_1.jsxs)("linearGradient", { id: uniqueId, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "5%", stopColor: gradientStart, stopOpacity: 0.4 }), (0, jsx_runtime_1.jsx)("stop", { offset: "95%", stopColor: gradientStop, stopOpacity: 0 })] }) }, `defs_${uniqueId}_${index}`));
|
|
122
|
+
}), yAxisFields.map((elem, index) => {
|
|
123
|
+
const gradientStart = (0, crypto_1.hashCode)(getCustomColor(index, elem.field, 'start') ??
|
|
124
|
+
(0, color_1.selectColor)(elem, colors, index));
|
|
125
|
+
const gradientStop = (0, crypto_1.hashCode)(getCustomColor(index, elem.field, 'stop') ?? '#00000000');
|
|
126
|
+
const uniqueId = `gradient_${gradientStart}_${gradientStop}`;
|
|
127
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: getCustomColor(index, elem.field) ??
|
|
128
|
+
(0, color_1.selectColor)(elem, colors, index), fill: `url(#${uniqueId})`, strokeWidth: 2, dot: false, strokeDasharray: comparison && dashedComparison && index > 0
|
|
129
|
+
? '5 5'
|
|
130
|
+
: undefined, isAnimationActive: isAnimationActive }, elem.field));
|
|
131
|
+
})] }) }) }));
|
|
115
132
|
}
|
|
116
133
|
exports.default = LineChart;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/ChartComponent.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"ChartComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/ChartComponent.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,EACpC,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,KAAK,EACL,QAAQ,GACT,EAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAkGnB"}
|
|
@@ -5,13 +5,10 @@ function DashboardItem({ dashboardItem, onClickDashboardItem, theme, style, chil
|
|
|
5
5
|
return ((0, jsx_runtime_1.jsx)("div", { onClick: onClickDashboardItem
|
|
6
6
|
? () => onClickDashboardItem(dashboardItem)
|
|
7
7
|
: () => { }, style: {
|
|
8
|
-
// height: '100%',
|
|
9
8
|
cursor: 'pointer',
|
|
10
9
|
boxSizing: 'content-box',
|
|
11
|
-
paddingRight: 25,
|
|
12
10
|
minHeight: 400,
|
|
13
11
|
borderRadius: 8,
|
|
14
|
-
paddingTop: 20,
|
|
15
12
|
...style,
|
|
16
13
|
}, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
17
14
|
width: '100%',
|
|
@@ -6,8 +6,8 @@ function DashboardSection({ section, children, }) {
|
|
|
6
6
|
if (section === 'tables')
|
|
7
7
|
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
8
8
|
boxSizing: 'content-box',
|
|
9
|
-
width:
|
|
10
|
-
gap:
|
|
9
|
+
width: '100%',
|
|
10
|
+
gap: 40,
|
|
11
11
|
display: 'flex',
|
|
12
12
|
flexDirection: 'column',
|
|
13
13
|
}, children: children }));
|
|
@@ -17,8 +17,8 @@ function DashboardSection({ section, children, }) {
|
|
|
17
17
|
width: '100%',
|
|
18
18
|
listStyleType: 'none',
|
|
19
19
|
display: 'grid',
|
|
20
|
-
gap:
|
|
21
|
-
gridTemplateColumns:
|
|
20
|
+
gap: 40,
|
|
21
|
+
gridTemplateColumns: 'repeat(auto-fill,minmax(400px, 1fr))',
|
|
22
22
|
gridTemplateRows: `repeat(${170}px)`,
|
|
23
23
|
}, children: children }));
|
|
24
24
|
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
export
|
|
2
|
+
export type DataLoaderChildProps = {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
error: string | null;
|
|
5
|
+
};
|
|
6
|
+
export default function DataLoader({ id, children, }: {
|
|
7
|
+
id: string;
|
|
8
|
+
children: ({ isLoading, error }: DataLoaderChildProps) => JSX.Element;
|
|
9
|
+
}): JSX.Element;
|
|
3
10
|
//# sourceMappingURL=DataLoader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAUA,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,EAAE,EACF,QAAQ,GACT,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;CACvE,GAAG,GAAG,CAAC,OAAO,CA+Ed"}
|
|
@@ -6,13 +6,17 @@ const Chart_1 = require("../../Chart");
|
|
|
6
6
|
const Context_1 = require("../../Context");
|
|
7
7
|
const dataFetcher_1 = require("../../utils/dataFetcher");
|
|
8
8
|
const merge_1 = require("../../utils/merge");
|
|
9
|
-
function DataLoader({ id, children }) {
|
|
9
|
+
function DataLoader({ id, children, }) {
|
|
10
10
|
const [client, _] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
11
11
|
const { dispatch, dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
12
12
|
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
13
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(true);
|
|
14
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
13
15
|
(0, react_1.useEffect)(() => {
|
|
14
16
|
async function getChartOptions() {
|
|
17
|
+
setIsLoading(true);
|
|
15
18
|
if (!(0, Chart_1.didFiltersChange)(dashboard[id], dashboardFilters)) {
|
|
19
|
+
setIsLoading(false);
|
|
16
20
|
return;
|
|
17
21
|
}
|
|
18
22
|
try {
|
|
@@ -43,7 +47,7 @@ function DataLoader({ id, children }) {
|
|
|
43
47
|
filters: minimalFilters,
|
|
44
48
|
};
|
|
45
49
|
const resp = await (0, dataFetcher_1.getData)(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
46
|
-
if (resp && resp.name !== 'error') {
|
|
50
|
+
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
47
51
|
if (resp.compareRows) {
|
|
48
52
|
(0, merge_1.mergeComparisonRange)(resp);
|
|
49
53
|
}
|
|
@@ -57,13 +61,18 @@ function DataLoader({ id, children }) {
|
|
|
57
61
|
},
|
|
58
62
|
});
|
|
59
63
|
}
|
|
64
|
+
else {
|
|
65
|
+
setError(resp?.errorMessage);
|
|
66
|
+
}
|
|
67
|
+
setIsLoading(false);
|
|
60
68
|
}
|
|
61
69
|
catch (e) {
|
|
62
70
|
console.log('Error fetching chart: ', e);
|
|
71
|
+
setError(e.message);
|
|
63
72
|
}
|
|
64
73
|
}
|
|
65
74
|
getChartOptions();
|
|
66
75
|
}, [dashboardFilters, client, id]);
|
|
67
|
-
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
|
|
76
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children({ isLoading, error }) });
|
|
68
77
|
}
|
|
69
78
|
exports.default = DataLoader;
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
|
|
2
|
+
import { DashboardItem } from '../../Dashboard';
|
|
3
|
+
interface DashboardItemProps {
|
|
4
|
+
dashboardItem: DashboardItem;
|
|
5
|
+
onClickDashboardItem?: any;
|
|
6
|
+
error?: string | null;
|
|
7
|
+
isLoading?: boolean;
|
|
8
|
+
children?: any;
|
|
9
|
+
theme?: any;
|
|
10
|
+
style?: any;
|
|
11
|
+
}
|
|
12
|
+
export default function QuillMetricComponent({ dashboardItem, onClickDashboardItem, error, isLoading, theme, style, }: DashboardItemProps): JSX.Element;
|
|
13
|
+
export {};
|
|
3
14
|
//# sourceMappingURL=MetricComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/MetricComponent.tsx"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,UAAU,
|
|
1
|
+
{"version":3,"file":"MetricComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/MetricComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAMhD,UAAU,kBAAkB;IAC1B,aAAa,EAAE,aAAa,CAAC;IAC7B,oBAAoB,CAAC,EAAE,GAAG,CAAC;IAC3B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,KAAK,CAAC,EAAE,GAAG,CAAC;CACb;AAED,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,SAAS,EACT,KAAK,EACL,KAAK,GACN,EAAE,kBAAkB,GAAG,GAAG,CAAC,OAAO,CAkPlC"}
|