@quillsql/react 2.12.26 → 2.12.28
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/Chart.d.ts +17 -2
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +137 -90
- package/dist/cjs/ChartBuilder.d.ts +3 -3
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +30 -23
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +66 -26
- package/dist/cjs/Context.d.ts +1 -0
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +17 -2
- package/dist/cjs/Dashboard.d.ts +6 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +3 -1
- package/dist/cjs/ReportBuilder.d.ts +1 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +12 -10
- package/dist/cjs/SQLEditor.d.ts +10 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +27 -3
- package/dist/cjs/Table.d.ts +15 -1
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +143 -59
- package/dist/cjs/components/Chart/ChartTooltip.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartTooltip.js +5 -4
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +52 -15
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +7 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +16 -2
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +2 -14
- package/dist/cjs/components/QuillTable.d.ts +2 -2
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +7 -5
- package/dist/cjs/components/UiComponents.d.ts +3 -3
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +4 -4
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +16 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +155 -80
- package/dist/cjs/utils/constants.d.ts +2 -0
- package/dist/cjs/utils/constants.d.ts.map +1 -0
- package/dist/cjs/utils/constants.js +4 -0
- package/dist/cjs/utils/dashboard.d.ts +1 -0
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +46 -97
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +56 -13
- package/dist/cjs/utils/dates.d.ts +8 -0
- package/dist/cjs/utils/dates.d.ts.map +1 -1
- package/dist/cjs/utils/dates.js +34 -1
- package/dist/cjs/utils/filterProcessing.d.ts +2 -0
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +129 -1
- package/dist/cjs/utils/logging.d.ts +2 -0
- package/dist/cjs/utils/logging.d.ts.map +1 -0
- package/dist/cjs/utils/logging.js +10 -0
- package/dist/cjs/utils/pivotConstructor.d.ts +6 -0
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -0
- package/dist/cjs/utils/pivotConstructor.js +87 -0
- package/dist/cjs/utils/queryConstructor.d.ts +2 -1
- package/dist/cjs/utils/queryConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/queryConstructor.js +46 -11
- package/dist/cjs/utils/tableProcessing.d.ts +22 -0
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +87 -1
- package/dist/esm/Chart.d.ts +17 -2
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +140 -93
- package/dist/esm/ChartBuilder.d.ts +3 -3
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +30 -23
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +66 -26
- package/dist/esm/Context.d.ts +1 -0
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +16 -1
- package/dist/esm/Dashboard.d.ts +6 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +3 -1
- package/dist/esm/ReportBuilder.d.ts +1 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +13 -11
- package/dist/esm/SQLEditor.d.ts +10 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +27 -3
- package/dist/esm/Table.d.ts +15 -1
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +146 -62
- package/dist/esm/components/Chart/ChartTooltip.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartTooltip.js +5 -4
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +52 -15
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +7 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts +16 -2
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +2 -14
- package/dist/esm/components/QuillTable.d.ts +2 -2
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +7 -5
- package/dist/esm/components/UiComponents.d.ts +3 -3
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +4 -4
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +16 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +153 -80
- package/dist/esm/utils/constants.d.ts +2 -0
- package/dist/esm/utils/constants.d.ts.map +1 -0
- package/dist/esm/utils/constants.js +1 -0
- package/dist/esm/utils/dashboard.d.ts +1 -0
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +45 -97
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +56 -13
- package/dist/esm/utils/dates.d.ts +8 -0
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +31 -0
- package/dist/esm/utils/filterProcessing.d.ts +2 -0
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +126 -0
- package/dist/esm/utils/logging.d.ts +2 -0
- package/dist/esm/utils/logging.d.ts.map +1 -0
- package/dist/esm/utils/logging.js +6 -0
- package/dist/esm/utils/pivotConstructor.d.ts +6 -0
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -0
- package/dist/esm/utils/pivotConstructor.js +83 -0
- package/dist/esm/utils/queryConstructor.d.ts +2 -1
- package/dist/esm/utils/queryConstructor.d.ts.map +1 -1
- package/dist/esm/utils/queryConstructor.js +44 -10
- package/dist/esm/utils/tableProcessing.d.ts +22 -0
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +85 -1
- package/package.json +1 -1
package/dist/esm/SQLEditor.js
CHANGED
|
@@ -14,6 +14,7 @@ import { QuillSelectComponent } from './components/QuillSelect';
|
|
|
14
14
|
import { quillFormat } from './utils/valueFormatter';
|
|
15
15
|
import { convertPostgresColumn } from './utils/columnProcessing';
|
|
16
16
|
import { getSchemaInfoWithCustomFields } from './utils/schema';
|
|
17
|
+
import { MAX_COLUMN_ROWS_LIMIT } from './utils/constants';
|
|
17
18
|
function defineEditorTheme(monaco, theme) {
|
|
18
19
|
monaco.editor.defineTheme('onedark', {
|
|
19
20
|
base: theme.darkMode ? 'vs-dark' : 'vs',
|
|
@@ -64,7 +65,7 @@ function setEditorTheme(editor, monaco) {
|
|
|
64
65
|
* ### SQLEditor API
|
|
65
66
|
* @see https://docs.quillsql.com/components/sql-editor
|
|
66
67
|
*/
|
|
67
|
-
export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, TableComponent = QuillTableSQLEditorComponent, isNewQueryEnabled = false, LoadingComponent = QuillLoadingComponent, ModalComponent = MemoizedModal, PopoverComponent = MemoizedPopover, CardComponent = QuillCard, LabelComponent = MemoizedLabel, HeaderComponent = MemoizedHeader, SubHeaderComponent = MemoizedSubHeader, TextComponent = MemoizedText, ErrorMessageComponent = QuillErrorMessageComponent, ChartBuilderInputRowContainer = QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = QuillChartBuilderInputColumnContainer, PivotRowContainer = QuillPivotRowContainer, PivotColumnContainer = QuillPivotColumnContainer, ChartBuilderFormContainer = QuillChartBuilderFormContainer, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isChartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', report = undefined, organizationName = undefined, isChartBuilderHorizontalView = true, containerStyle = { height: '100vh' }, className, onClickChartElement }) {
|
|
68
|
+
export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryButtonComponent = MemoizedSecondaryButton, DeleteButtonComponent = MemoizedDeleteButton, TextInputComponent = QuillTextInput, SelectComponent = QuillSelectComponent, TableComponent = QuillTableSQLEditorComponent, isNewQueryEnabled = false, LoadingComponent = QuillLoadingComponent, ModalComponent = MemoizedModal, PopoverComponent = MemoizedPopover, CardComponent = QuillCard, LabelComponent = MemoizedLabel, HeaderComponent = MemoizedHeader, SubHeaderComponent = MemoizedSubHeader, TextComponent = MemoizedText, ErrorMessageComponent = QuillErrorMessageComponent, ChartBuilderInputRowContainer = QuillChartBuilderInputRowContainer, ChartBuilderInputColumnContainer = QuillChartBuilderInputColumnContainer, PivotRowContainer = QuillPivotRowContainer, PivotColumnContainer = QuillPivotColumnContainer, ChartBuilderFormContainer = QuillChartBuilderFormContainer, defaultQuery, onChangeQuery, onChangeData, onChangeColumns, onChangeFields, isChartBuilderEnabled = false, showTableFormatOptions = false, showDateFieldOptions = false, showAccessControlOptions = false, destinationDashboard, chartBuilderTitle, chartBuilderButtonLabel, onAddToDashboardComplete, addToDashboardButtonLabel = 'Add to dashboard', report = undefined, organizationName = undefined, isChartBuilderHorizontalView = true, containerStyle = { height: '100vh' }, className, onClickChartElement, }) {
|
|
68
69
|
const [sqlPrompt, setSqlPrompt] = useState('');
|
|
69
70
|
const [client] = useContext(ClientContext);
|
|
70
71
|
const [theme] = useContext(ThemeContext);
|
|
@@ -82,6 +83,11 @@ export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryB
|
|
|
82
83
|
const formRef = useRef(null);
|
|
83
84
|
const [searchBarWidth, setSearchBarWidth] = useState(200);
|
|
84
85
|
const [formattedRows, setFormattedRows] = useState([]);
|
|
86
|
+
const [numberOfRows, setNumberOfRows] = useState(undefined);
|
|
87
|
+
const [previousPage, setPreviousPage] = useState(0);
|
|
88
|
+
const [currentProcessing, setCurrentProcessing] = useState({
|
|
89
|
+
page: { currentPage: 0, rowsPerPage: 20 },
|
|
90
|
+
});
|
|
85
91
|
useEffect(() => {
|
|
86
92
|
// Since the TextInput component takes a required numeric width parameter,
|
|
87
93
|
// we dynamically calculate the width of this component here.
|
|
@@ -120,7 +126,20 @@ export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryB
|
|
|
120
126
|
const handleClearQuery = async () => {
|
|
121
127
|
setQuery('');
|
|
122
128
|
};
|
|
123
|
-
const
|
|
129
|
+
const onPageChange = (page) => {
|
|
130
|
+
if ((previousPage < page.currentPage &&
|
|
131
|
+
(page.currentPage * page.rowsPerPage) % MAX_COLUMN_ROWS_LIMIT === 0) ||
|
|
132
|
+
(previousPage > page.currentPage &&
|
|
133
|
+
(previousPage * page.rowsPerPage) % MAX_COLUMN_ROWS_LIMIT === 0)) {
|
|
134
|
+
handleRunQuery({ ...currentProcessing, page });
|
|
135
|
+
}
|
|
136
|
+
setPreviousPage(page.currentPage);
|
|
137
|
+
};
|
|
138
|
+
const onSortChange = (sort) => {
|
|
139
|
+
handleRunQuery({ sort, page: { currentPage: 0, rowsPerPage: 20 } });
|
|
140
|
+
setPreviousPage(0);
|
|
141
|
+
};
|
|
142
|
+
const handleRunQuery = async (processing) => {
|
|
124
143
|
try {
|
|
125
144
|
setDisplayTable(true);
|
|
126
145
|
setSqlQueryLoading(true);
|
|
@@ -134,6 +153,7 @@ export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryB
|
|
|
134
153
|
databaseType: client?.databaseType,
|
|
135
154
|
getCustomFields: !client.customerId || client.customerId === '*' ? false : true,
|
|
136
155
|
customFieldsByTable: customFields,
|
|
156
|
+
// additionalProcessing: processing,
|
|
137
157
|
},
|
|
138
158
|
};
|
|
139
159
|
const cloudBody = { query };
|
|
@@ -147,12 +167,14 @@ export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryB
|
|
|
147
167
|
}
|
|
148
168
|
setSqlQueryLoading(false);
|
|
149
169
|
setErrorMessage('');
|
|
170
|
+
setCurrentProcessing(processing);
|
|
150
171
|
if (resp.rows.length === 0) {
|
|
151
172
|
setErrorMessage('No data found');
|
|
152
173
|
}
|
|
153
174
|
const temp_rows = resp.rows && resp.rows.length ? resp.rows : [];
|
|
154
175
|
const processedFields = resp.fields.map((elem) => convertPostgresColumn(elem));
|
|
155
176
|
setRows(temp_rows);
|
|
177
|
+
// setNumberOfRows(resp.compareRows[0]?.count || temp_rows.length);
|
|
156
178
|
setFormattedRows(temp_rows.map((row) => {
|
|
157
179
|
return processedFields.reduce((formattedRow, column) => {
|
|
158
180
|
// Apply the format function to each field in the row
|
|
@@ -241,7 +263,9 @@ export default function SQLEditor({ ButtonComponent = MemoizedButton, SecondaryB
|
|
|
241
263
|
gap: 12,
|
|
242
264
|
paddingTop: 16,
|
|
243
265
|
paddingBottom: 16,
|
|
244
|
-
}, children: [_jsx(TextInputComponent, { id: "ai-search", value: sqlPrompt, width: searchBarWidth, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }), _jsx(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" })] }), _jsx("div", { style: { height: 'calc(50% - 40px)' }, children: _jsx(SQLEditorComponent, { query: query || '', setQuery: setQuery, handleRunQuery:
|
|
266
|
+
}, children: [_jsx(TextInputComponent, { id: "ai-search", value: sqlPrompt, width: searchBarWidth, onChange: (e) => setSqlPrompt(e.target.value), placeholder: "Ask a question..." }), _jsx(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" })] }), _jsx("div", { style: { height: 'calc(50% - 40px)' }, children: _jsx(SQLEditorComponent, { query: query || '', setQuery: setQuery, handleRunQuery: () => {
|
|
267
|
+
handleRunQuery(currentProcessing);
|
|
268
|
+
}, handleFixWithAI: handleFixWithAI, isNewQueryEnabled: isNewQueryEnabled, handleClearQuery: handleClearQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) }), _jsxs("div", { style: {
|
|
245
269
|
display: 'flex',
|
|
246
270
|
flexDirection: 'column',
|
|
247
271
|
height: 'calc(50% - 108px)',
|
package/dist/esm/Table.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { MultiSelectComponentProps, SelectComponentProps } from './components/UiComponents';
|
|
3
|
+
import { DateRangePickerComponentProps } from './DateRangePicker/QuillDateRangePicker';
|
|
2
4
|
export interface TableColumn {
|
|
3
5
|
label: string;
|
|
4
6
|
field: string;
|
|
@@ -78,6 +80,8 @@ export interface TableProps {
|
|
|
78
80
|
* Whether to show the download csv button.
|
|
79
81
|
*/
|
|
80
82
|
hideCSVDownloadButton?: boolean;
|
|
83
|
+
/** Whether to hide the table filters component, deafulted to true */
|
|
84
|
+
hideFilters?: boolean;
|
|
81
85
|
/**
|
|
82
86
|
* Whether this table component is loading.
|
|
83
87
|
*/
|
|
@@ -90,6 +94,16 @@ export interface TableProps {
|
|
|
90
94
|
* A loading component to show when the table is loading.
|
|
91
95
|
*/
|
|
92
96
|
LoadingComponent?: () => JSX.Element;
|
|
97
|
+
/** A select component prop for the table filters */
|
|
98
|
+
SelectComponent?: (props: SelectComponentProps) => JSX.Element;
|
|
99
|
+
/** A multi select component prop for the table filters */
|
|
100
|
+
MultiSelectComponent?: (props: MultiSelectComponentProps) => JSX.Element;
|
|
101
|
+
/** A date range picker component prop for the table filters */
|
|
102
|
+
DateRangePickerComponent?: (props: DateRangePickerComponentProps) => JSX.Element;
|
|
103
|
+
/** A filter container component component prop for the table filters */
|
|
104
|
+
FilterContainerComponent?: ({ children, }: {
|
|
105
|
+
children: ReactNode;
|
|
106
|
+
}) => JSX.Element;
|
|
93
107
|
/**
|
|
94
108
|
* Styles the top-level container of the Table.
|
|
95
109
|
*
|
package/dist/esm/Table.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../src/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,SAAS,EAKV,MAAM,OAAO,CAAC;AAuBf,OAAO,EACL,yBAAyB,EAEzB,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EACL,6BAA6B,EAE9B,MAAM,wCAAwC,CAAC;AAGhD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAoCD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,EAAE,CAAC;IAEhC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,CAAC,EAAE;QACR,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IAEJ;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAEhC,qEAAqE;IACrE,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IAEzB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IAErC,oDAAoD;IACpD,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;IAE/D,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,GAAG,CAAC,OAAO,CAAC;IAEzE,+DAA+D;IAC/D,wBAAwB,CAAC,EAAE,CACzB,KAAK,EAAE,6BAA6B,KACjC,GAAG,CAAC,OAAO,CAAC;IAEjB,wEAAwE;IACxE,wBAAwB,CAAC,EAAE,CAAC,EAC1B,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,SAAS,CAAC;KACrB,KAAK,GAAG,CAAC,OAAO,CAAC;IAElB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;CACtC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,QAAA,MAAM,KAAK,UAAW,UAAU,4CAuC/B,CAAC;AA6PF,eAAe,KAAK,CAAC"}
|
package/dist/esm/Table.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useContext, useEffect,
|
|
3
|
-
import { ClientContext, CustomFieldContext, DashboardContext, DashboardFiltersContext, } from './Context';
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useEffect, useState, } from 'react';
|
|
3
|
+
import { ClientContext, CustomFieldContext, DashboardContext, DashboardFiltersContext, ReportFiltersContext, } from './Context';
|
|
4
4
|
import { getData } from './utils/dataFetcher';
|
|
5
|
-
import { mergeComparisonRange } from './utils/merge';
|
|
6
5
|
import QuillTable from './components/QuillTable';
|
|
7
|
-
import { useMemoizedRows } from './hooks/useFormat';
|
|
8
6
|
import { useExport } from './hooks/useExport';
|
|
9
7
|
import { processFilterErrorList } from './utils/errorProcessing';
|
|
10
|
-
import {
|
|
8
|
+
import { cleanDashboardItem } from './utils/dashboard';
|
|
9
|
+
import { quillFormat } from './utils/valueFormatter';
|
|
10
|
+
import { processFilterFromBackend, updateFilter, } from './utils/filterProcessing';
|
|
11
|
+
import { QuillFilterContainerComponent, } from './components/UiComponents';
|
|
12
|
+
import { DashboardFilter } from './components/Dashboard/DashboardFilter';
|
|
13
|
+
import { QuillSelectComponent } from './components/QuillSelect';
|
|
14
|
+
import { QuillMultiSelectComponent } from './components/QuillMultiSelect';
|
|
15
|
+
import { QuillDateRangePicker, } from './DateRangePicker/QuillDateRangePicker';
|
|
16
|
+
import { useTheme } from './hooks';
|
|
11
17
|
/**
|
|
12
18
|
* ### Quill Table
|
|
13
19
|
*
|
|
@@ -47,69 +53,147 @@ const Table = (props) => {
|
|
|
47
53
|
if ('rows' in data && 'columns' in data) {
|
|
48
54
|
return (_jsx(QuillTable, { hideCSVDownloadButton: data.hideCSVDownloadButton, columns: data.columns, rows: data.rows, className: data.className, containerStyle: data.containerStyle, LoadingComponent: data.LoadingComponent, isLoading: data.isLoading, downloadCSV: data.downloadCSV }));
|
|
49
55
|
}
|
|
50
|
-
return (_jsx(ChartUpdater, { hideCSVDownloadButton: data.hideCSVDownloadButton, dispatch: dispatch,
|
|
56
|
+
return (_jsx(ChartUpdater, { hideCSVDownloadButton: data.hideCSVDownloadButton, dispatch: dispatch, dashboardContext: dashboard, reportId: data.reportId, className: data.className, containerStyle: data.containerStyle, dashboardFilters: dashboardFilters, client: client, csvFilename: data.csvFilename, LoadingComponent: data.LoadingComponent, SelectComponent: data.SelectComponent, MultiSelectComponent: data.MultiSelectComponent, DateRangePickerComponent: data.DateRangePickerComponent, FilterContainerComponent: data.FilterContainerComponent, hideFilters: data.hideFilters }));
|
|
51
57
|
};
|
|
52
|
-
const ChartUpdater = ({ reportId, containerStyle, className,
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
.sort((filter) => (filter.filterType === 'date_range' ? -1 : 1))
|
|
56
|
-
.filter((f) => dashboard &&
|
|
57
|
-
dashboard[reportId] &&
|
|
58
|
-
f &&
|
|
59
|
-
f.dashboardName === dashboard[reportId].dashboardName);
|
|
60
|
-
}, [dashboardFilters, dashboard]);
|
|
61
|
-
const { rows, loading } = useMemoizedRows(reportId);
|
|
58
|
+
const ChartUpdater = ({ reportId, containerStyle, className, dashboardContext, dispatch, client, dashboardFilters, csvFilename, hideCSVDownloadButton = true, hideFilters = true, LoadingComponent, SelectComponent = QuillSelectComponent, MultiSelectComponent = QuillMultiSelectComponent, DateRangePickerComponent = QuillDateRangePicker, FilterContainerComponent = QuillFilterContainerComponent, }) => {
|
|
59
|
+
const [loading, setLoading] = useState(false);
|
|
60
|
+
const [initialLoad, setInitialLoad] = useState(true);
|
|
62
61
|
const { downloadCSV } = useExport(reportId);
|
|
63
62
|
const [customFields] = useContext(CustomFieldContext);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
63
|
+
const [rows, setRows] = useState([]);
|
|
64
|
+
const [columns, setColumns] = useState([]);
|
|
65
|
+
const [tableFilters, setTableFilters] = useState([]);
|
|
66
|
+
const [filterUpdateIndex, setFilterUpdateIndex] = useState(0);
|
|
67
|
+
const { reportFiltersDispatch, reportFilters } = useContext(ReportFiltersContext);
|
|
68
|
+
const theme = useTheme();
|
|
69
|
+
const getChartData = async (useReportTask = true, reportFilterInfo) => {
|
|
70
|
+
try {
|
|
71
|
+
const filters = reportFilterInfo.filters;
|
|
72
|
+
setLoading(true);
|
|
73
|
+
if (!client.databaseType ||
|
|
74
|
+
client.databaseType.toLowerCase() !== 'postgresql') {
|
|
75
|
+
useReportTask = false;
|
|
69
76
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
dispatch({
|
|
94
|
-
type: 'UPDATE_DASHBOARD_ITEM',
|
|
95
|
-
id: reportId,
|
|
96
|
-
data: {
|
|
97
|
-
...resp,
|
|
98
|
-
filtersApplied: specificDashboardFilter,
|
|
99
|
-
},
|
|
100
|
-
});
|
|
101
|
-
}
|
|
77
|
+
const hostedBody = {
|
|
78
|
+
metadata: {
|
|
79
|
+
reportId,
|
|
80
|
+
dashboardItemId: reportId,
|
|
81
|
+
orgId: client.customerId || '*',
|
|
82
|
+
clientId: client.publicKey,
|
|
83
|
+
task: useReportTask ? 'report' : 'item',
|
|
84
|
+
getDefaultDashboardFilters: filters ? false : true,
|
|
85
|
+
databaseType: client?.databaseType,
|
|
86
|
+
customFields,
|
|
87
|
+
filters,
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
const cloudBody = {
|
|
91
|
+
id: reportId,
|
|
92
|
+
};
|
|
93
|
+
const resp = await getData(client, 'itempost', 'same-origin', hostedBody, cloudBody);
|
|
94
|
+
processFilterErrorList(resp);
|
|
95
|
+
if (resp && resp.name !== 'error' && !resp.errorMessage) {
|
|
96
|
+
const cleanedReport = await cleanDashboardItem(resp, filters ? filters : resp.filters);
|
|
97
|
+
if (cleanedReport.chartType === 'table' && cleanedReport.pivot) {
|
|
98
|
+
cleanedReport.columns = cleanedReport.yAxisFields;
|
|
102
99
|
}
|
|
103
|
-
|
|
104
|
-
|
|
100
|
+
let filterArray = filters;
|
|
101
|
+
if (!filterArray) {
|
|
102
|
+
filterArray = resp.filters
|
|
103
|
+
? resp.filters.map((filter) => {
|
|
104
|
+
return processFilterFromBackend(filter, resp.rows);
|
|
105
|
+
})
|
|
106
|
+
: [];
|
|
107
|
+
reportFiltersDispatch({
|
|
108
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
109
|
+
id: reportId,
|
|
110
|
+
data: {
|
|
111
|
+
filters: filterArray,
|
|
112
|
+
updateIndex: reportFilterInfo.updateIndex,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
105
115
|
}
|
|
116
|
+
setFilterUpdateIndex(reportFilterInfo.updateIndex);
|
|
117
|
+
setTableFilters(filterArray);
|
|
106
118
|
}
|
|
119
|
+
setRows(resp.rows.map((row) => {
|
|
120
|
+
return resp.columns.reduce((formattedRow, column) => {
|
|
121
|
+
// Apply the format function to each field in the row
|
|
122
|
+
const formattedValue = quillFormat({
|
|
123
|
+
value: row[column.field],
|
|
124
|
+
format: column.format,
|
|
125
|
+
});
|
|
126
|
+
formattedRow[column.field] = formattedValue;
|
|
127
|
+
return formattedRow;
|
|
128
|
+
}, {});
|
|
129
|
+
}));
|
|
130
|
+
setColumns(resp.columns);
|
|
131
|
+
setLoading(false);
|
|
132
|
+
}
|
|
133
|
+
catch (e) {
|
|
134
|
+
if (useReportTask) {
|
|
135
|
+
getChartData(false, reportFilterInfo);
|
|
136
|
+
}
|
|
137
|
+
console.log('Error fetching chart: ', e);
|
|
138
|
+
setLoading(false);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
// IF WE HAVE THE DATA IN DASHBOARD CONTEXT AND IT IS THE INITIAL LAOD DON'T FETCH DATA
|
|
143
|
+
if (initialLoad && dashboardContext[reportId]) {
|
|
144
|
+
setInitialLoad(false);
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
setInitialLoad(false);
|
|
148
|
+
let parsedReportFilters = reportFilters[reportId]
|
|
149
|
+
? reportFilters[reportId]
|
|
150
|
+
: { updateIndex: 0 };
|
|
151
|
+
getChartData(true, parsedReportFilters);
|
|
152
|
+
}, [client.customerId, reportId, reportFilters[reportId]?.updateIndex]);
|
|
153
|
+
useEffect(() => {
|
|
154
|
+
if (!dashboardContext || !dashboardContext[reportId]) {
|
|
155
|
+
return;
|
|
107
156
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
157
|
+
setRows(dashboardContext[reportId].rows.map((row) => {
|
|
158
|
+
return dashboardContext[reportId].columns.reduce((formattedRow, column) => {
|
|
159
|
+
// Apply the format function to each field in the row
|
|
160
|
+
const formattedValue = quillFormat({
|
|
161
|
+
value: row[column.field],
|
|
162
|
+
format: column.format,
|
|
163
|
+
});
|
|
164
|
+
formattedRow[column.field] = formattedValue;
|
|
165
|
+
return formattedRow;
|
|
166
|
+
}, {});
|
|
167
|
+
}));
|
|
168
|
+
setColumns(dashboardContext[reportId].columns);
|
|
169
|
+
}, []);
|
|
170
|
+
return (_jsxs("div", { children: [!hideFilters && (_jsx("div", { style: {
|
|
171
|
+
display: 'flex',
|
|
172
|
+
boxSizing: 'content-box',
|
|
173
|
+
flexDirection: 'row',
|
|
174
|
+
alignItems: 'center',
|
|
175
|
+
}, children: _jsx(FilterContainerComponent, { children: tableFilters.map((filter, index) => (_jsx(DashboardFilter, { filter: filter, onChangeFilter: (filter, value = null, comparison = null) => {
|
|
176
|
+
const updatedFilters = tableFilters.map((f) => {
|
|
177
|
+
if (f.field === filter.field ||
|
|
178
|
+
(f.filterType === 'date_range' &&
|
|
179
|
+
filter.filterType === 'date_range')) {
|
|
180
|
+
return updateFilter(f, value, comparison);
|
|
181
|
+
}
|
|
182
|
+
return f;
|
|
183
|
+
});
|
|
184
|
+
setTableFilters(updatedFilters);
|
|
185
|
+
getChartData(true, {
|
|
186
|
+
filters: updatedFilters,
|
|
187
|
+
updateIndex: filterUpdateIndex + 1,
|
|
188
|
+
});
|
|
189
|
+
reportFiltersDispatch({
|
|
190
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
191
|
+
id: reportId,
|
|
192
|
+
data: {
|
|
193
|
+
filters: updatedFilters,
|
|
194
|
+
updateIndex: filterUpdateIndex + 1,
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
}, theme: theme, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, DateRangePickerComponent: DateRangePickerComponent }, index))) }) })), _jsx(QuillTable, { hideCSVDownloadButton: hideCSVDownloadButton, columns: columns ?? [], rows: rows ?? [], containerStyle: containerStyle, className: className, LoadingComponent: LoadingComponent, isLoading: loading, downloadCSV: downloadCSV })] }));
|
|
114
198
|
};
|
|
115
199
|
export default Table;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/ChartTooltip.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,GAAG,CAAC;IACpB,aAAa,EAAE,GAAG,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;
|
|
1
|
+
{"version":3,"file":"ChartTooltip.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/ChartTooltip.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,EAAE,GAAG,CAAC;IACpB,aAAa,EAAE,GAAG,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAwUF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,iBAAiB,kDAK5D"}
|
|
@@ -174,10 +174,11 @@ function getTooltipLabel(props, altTooltipLabel, isDateXAxis) {
|
|
|
174
174
|
// The chart tooltip to display for comparison labels (eg. "previous period").
|
|
175
175
|
function ChartTooltipComparison(props) {
|
|
176
176
|
const isDateXAxis = isDateFormat(props.xAxisFormat);
|
|
177
|
-
const altTooltipLabel = props.payload[0]?.
|
|
178
|
-
.
|
|
179
|
-
|
|
180
|
-
|
|
177
|
+
const altTooltipLabel = props.payload[0]?.name.replace('comparison ', '') ||
|
|
178
|
+
props.payload[0]?.dataKey
|
|
179
|
+
.replace('comparison_', '')
|
|
180
|
+
.replaceAll('_', ' ')
|
|
181
|
+
.toLowerCase();
|
|
181
182
|
const presetLabel = props.dateFilter?.preset?.label || '';
|
|
182
183
|
const comparisonLabel = props.dateFilter?.comparisonRange?.value || '';
|
|
183
184
|
const newRows = reformatComparisonPayload(props, presetLabel, convertComparisonRange(presetLabel, comparisonLabel));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DashboardFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAIhG,KAAK,mBAAmB,GAAG,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACjE,KAAK,GAAG,CAAC,OAAO,CAAC;AAElB,KAAK,wBAAwB,GAAG,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACjE,KAAK,GAAG,CAAC,OAAO,CAAC;AAElB,KAAK,4BAA4B,GAAG,CAAC,EACnC,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,MAAM,EACN,WAAW,GACZ,EAAE,6BAA6B,KAAK,GAAG,CAAC,OAAO,CAAC;AAEjD,UAAU,oBAAoB;IAC5B,MAAM,EAAE,GAAG,CAAC;IACZ,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACzC,eAAe,EACX,mBAAmB,GACnB,KAAK,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;IACnD,oBAAoB,EAChB,wBAAwB,GACxB,KAAK,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IACxD,wBAAwB,EACpB,4BAA4B,GAC5B,KAAK,CAAC,mBAAmB,CAAC,4BAA4B,CAAC,CAAC;IAC5D,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,cAAc,EACd,eAAsC,EACtC,oBAAgD,EAChD,wBAAwB,EACxB,KAAK,GACN,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"DashboardFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DashboardFilter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4CAA4C,CAAC;AAIhG,KAAK,mBAAmB,GAAG,CAAC,EAC1B,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACjE,KAAK,GAAG,CAAC,OAAO,CAAC;AAElB,KAAK,wBAAwB,GAAG,CAAC,EAC/B,KAAK,EACL,KAAK,EACL,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE;IACD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACjE,KAAK,GAAG,CAAC,OAAO,CAAC;AAElB,KAAK,4BAA4B,GAAG,CAAC,EACnC,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,MAAM,EACN,WAAW,GACZ,EAAE,6BAA6B,KAAK,GAAG,CAAC,OAAO,CAAC;AAEjD,UAAU,oBAAoB;IAC5B,MAAM,EAAE,GAAG,CAAC;IACZ,cAAc,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;IACzC,eAAe,EACX,mBAAmB,GACnB,KAAK,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC;IACnD,oBAAoB,EAChB,wBAAwB,GACxB,KAAK,CAAC,mBAAmB,CAAC,wBAAwB,CAAC,CAAC;IACxD,wBAAwB,EACpB,4BAA4B,GAC5B,KAAK,CAAC,mBAAmB,CAAC,4BAA4B,CAAC,CAAC;IAC5D,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,cAAc,EACd,eAAsC,EACtC,oBAAgD,EAChD,wBAAwB,EACxB,KAAK,GACN,EAAE,oBAAoB,kDAmItB"}
|
|
@@ -16,7 +16,7 @@ export function DashboardFilter({ filter, onChangeFilter, SelectComponent = Quil
|
|
|
16
16
|
}
|
|
17
17
|
}, [filter]);
|
|
18
18
|
if (filter.filterType === 'string') {
|
|
19
|
-
if (!filter.options) {
|
|
19
|
+
if (!filter.options || filter.options.length === 0) {
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
22
|
if (filter.stringFilterType === 'multiselect') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,WAAW,EAAuB,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"DataLoader.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/DataLoader.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,WAAW,EAAuB,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAQjD,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3E,YAAY,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnE,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,EAAE,EACF,QAAQ,EACR,OAAO,GACR,EAAE;IACD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,EAAE,CAAC,EACT,SAAS,EACT,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,IAAI,GACL,EAAE,oBAAoB,KAAK,GAAG,CAAC,OAAO,CAAC;CACzC,GAAG,GAAG,CAAC,OAAO,CAwJd;AAED,KAAK,YAAY,GAAG;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;QAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,uBAAuB,CAAC,EAAE,MAAM,CAAC;QACjC,sBAAsB,CAAC,EAAE,MAAM,CAAC;KACjC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAIF,eAAO,MAAM,eAAe;QAQtB,MAAM;;;mCAIC,WAAW,UACZ,UAAU,KACf,YAAY;2BACM,GAAG;cAChB,GAAG;wDAMV,yBAAyB,KAAK,WAAW;MAC1C,WAuHH,CAAC"}
|
|
@@ -7,12 +7,14 @@ import { getData } from '../../utils/dataFetcher';
|
|
|
7
7
|
import { mergeComparisonRange } from '../../utils/merge';
|
|
8
8
|
import { processFilterErrorList } from '../../utils/errorProcessing';
|
|
9
9
|
import { cleanDashboardItem } from '../../utils/dashboard';
|
|
10
|
+
import { internalLog } from '../../utils/logging';
|
|
11
|
+
import { MAX_COLUMN_ROWS_LIMIT } from '../../utils/constants';
|
|
10
12
|
export default function DataLoader({ id, children, filters, }) {
|
|
11
13
|
const [client, _] = useContext(ClientContext);
|
|
12
14
|
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
13
15
|
// const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
14
16
|
const [customFields] = useContext(CustomFieldContext);
|
|
15
|
-
const [isLoading, setIsLoading] = useState(
|
|
17
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
16
18
|
const [isPaginationLoading, setIsPaginationLoading] = useState(true);
|
|
17
19
|
const [error, setError] = useState(undefined);
|
|
18
20
|
const [previousPage, setPreviousPage] = useState(0);
|
|
@@ -22,21 +24,22 @@ export default function DataLoader({ id, children, filters, }) {
|
|
|
22
24
|
});
|
|
23
25
|
const onPageChange = (page) => {
|
|
24
26
|
if ((previousPage < page.currentPage &&
|
|
25
|
-
(page.currentPage * page.rowsPerPage) %
|
|
27
|
+
(page.currentPage * page.rowsPerPage) % MAX_COLUMN_ROWS_LIMIT === 0) ||
|
|
26
28
|
(previousPage > page.currentPage &&
|
|
27
|
-
(previousPage * page.rowsPerPage) %
|
|
28
|
-
getChartOptions({ page });
|
|
29
|
+
(previousPage * page.rowsPerPage) % MAX_COLUMN_ROWS_LIMIT === 0)) {
|
|
30
|
+
getChartOptions(true, { page });
|
|
29
31
|
}
|
|
30
32
|
setPreviousPage(page.currentPage);
|
|
31
33
|
};
|
|
32
34
|
const onSortChange = (sort) => {
|
|
33
|
-
getChartOptions({ sort });
|
|
35
|
+
getChartOptions(true, { sort });
|
|
34
36
|
setPreviousPage(0);
|
|
35
37
|
};
|
|
36
|
-
const getChartOptions = async (processing) => {
|
|
38
|
+
const getChartOptions = async (useReportTask = true, processing) => {
|
|
37
39
|
if (!didFiltersChange(dashboard[id], filters) &&
|
|
38
40
|
!isLoading &&
|
|
39
|
-
!dashboard[id].triggerReload
|
|
41
|
+
!dashboard[id].triggerReload &&
|
|
42
|
+
!processing) {
|
|
40
43
|
setIsLoading(false);
|
|
41
44
|
setReport(dashboard[id]);
|
|
42
45
|
return;
|
|
@@ -62,12 +65,17 @@ export default function DataLoader({ id, children, filters, }) {
|
|
|
62
65
|
return newFilter;
|
|
63
66
|
})
|
|
64
67
|
: [];
|
|
68
|
+
if (!client.databaseType ||
|
|
69
|
+
client.databaseType.toLowerCase() !== 'postgresql') {
|
|
70
|
+
useReportTask = false;
|
|
71
|
+
}
|
|
65
72
|
const hostedBody = {
|
|
66
73
|
metadata: {
|
|
74
|
+
reportId: id,
|
|
67
75
|
dashboardItemId: id,
|
|
68
76
|
orgId: client.customerId || '*',
|
|
69
77
|
clientId: client.publicKey,
|
|
70
|
-
task: 'item',
|
|
78
|
+
task: useReportTask ? 'report' : 'item',
|
|
71
79
|
databaseType: client.databaseType,
|
|
72
80
|
filters: minimalFilters,
|
|
73
81
|
customFields,
|
|
@@ -95,6 +103,9 @@ export default function DataLoader({ id, children, filters, }) {
|
|
|
95
103
|
setReport(cleanedReport);
|
|
96
104
|
}
|
|
97
105
|
else {
|
|
106
|
+
if (useReportTask) {
|
|
107
|
+
throw new Error(resp?.errorMessage);
|
|
108
|
+
}
|
|
98
109
|
setError(resp?.errorMessage);
|
|
99
110
|
}
|
|
100
111
|
setAdditionProcessing(updatedProcessing);
|
|
@@ -103,11 +114,20 @@ export default function DataLoader({ id, children, filters, }) {
|
|
|
103
114
|
}, 200);
|
|
104
115
|
}
|
|
105
116
|
catch (e) {
|
|
106
|
-
|
|
107
|
-
|
|
117
|
+
if (useReportTask) {
|
|
118
|
+
internalLog('USING ITEM AS BACKUP');
|
|
119
|
+
getChartOptions(false, processing);
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
console.log('Error fetching chart: ', e);
|
|
123
|
+
setError(e.message);
|
|
124
|
+
}
|
|
108
125
|
}
|
|
109
126
|
};
|
|
110
127
|
useEffect(() => {
|
|
128
|
+
if (isLoading) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
111
131
|
getChartOptions();
|
|
112
132
|
}, [filters, id, dashboard[id]]);
|
|
113
133
|
return (_jsx(_Fragment, { children: children({
|
|
@@ -132,7 +152,7 @@ export const ChartDataLoader = ({ id, children, hideDateRangeFilter = false, dat
|
|
|
132
152
|
const [client, _] = useContext(ClientContext);
|
|
133
153
|
const [customFields] = useContext(CustomFieldContext);
|
|
134
154
|
const theme = useTheme();
|
|
135
|
-
const getChartOptions = async () => {
|
|
155
|
+
const getChartOptions = async (useReportTask = true) => {
|
|
136
156
|
try {
|
|
137
157
|
// Remove extra fields on each filter so we don't confuse the backend.
|
|
138
158
|
if (!didFiltersChange(dashboard[id], filters) &&
|
|
@@ -147,12 +167,17 @@ export const ChartDataLoader = ({ id, children, hideDateRangeFilter = false, dat
|
|
|
147
167
|
setLoading(true);
|
|
148
168
|
setLocalDateBucket(dateBucket);
|
|
149
169
|
setLocalAdditionalProcessing(additionalProcessing);
|
|
170
|
+
if (!client.databaseType ||
|
|
171
|
+
client.databaseType.toLowerCase() !== 'postgresql') {
|
|
172
|
+
useReportTask = false;
|
|
173
|
+
}
|
|
150
174
|
const hostedBody = {
|
|
151
175
|
metadata: {
|
|
176
|
+
reportId: id,
|
|
152
177
|
dashboardItemId: id,
|
|
153
178
|
orgId: client.customerId || '*',
|
|
154
179
|
clientId: client.publicKey,
|
|
155
|
-
task: 'item',
|
|
180
|
+
task: useReportTask ? 'report' : 'item',
|
|
156
181
|
databaseType: client.databaseType,
|
|
157
182
|
filters: filters,
|
|
158
183
|
customFields,
|
|
@@ -177,17 +202,29 @@ export const ChartDataLoader = ({ id, children, hideDateRangeFilter = false, dat
|
|
|
177
202
|
dispatch({
|
|
178
203
|
type: 'UPDATE_DASHBOARD_ITEM',
|
|
179
204
|
id: id,
|
|
180
|
-
data: {
|
|
205
|
+
data: {
|
|
206
|
+
...cleanedReport,
|
|
207
|
+
triggerReload: false,
|
|
208
|
+
},
|
|
181
209
|
});
|
|
182
210
|
}
|
|
183
211
|
else {
|
|
212
|
+
if (useReportTask) {
|
|
213
|
+
throw new Error(resp?.errorMessage);
|
|
214
|
+
}
|
|
184
215
|
setError(resp?.errorMessage);
|
|
185
216
|
}
|
|
186
217
|
setLoading(false);
|
|
187
218
|
}
|
|
188
219
|
catch (e) {
|
|
189
|
-
|
|
190
|
-
|
|
220
|
+
if (useReportTask) {
|
|
221
|
+
internalLog('USING ITEM AS BACKUP');
|
|
222
|
+
getChartOptions(false);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
console.log('Error fetching chart: ', e);
|
|
226
|
+
setError(e.message);
|
|
227
|
+
}
|
|
191
228
|
}
|
|
192
229
|
};
|
|
193
230
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MetricComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/MetricComponent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AASnD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,OAAO,EACP,KAAK,EACL,SAAS,GACV,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"MetricComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/MetricComponent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AASnD,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,EAC3C,MAAM,EACN,OAAO,EACP,KAAK,EACL,SAAS,GACV,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CA4PhC"}
|
|
@@ -15,7 +15,13 @@ export default function QuillMetricComponent({ report, onClick, error, isLoading
|
|
|
15
15
|
if (pivotData.data) {
|
|
16
16
|
setRows(pivotData.data.rows);
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
else if (report?.rows) {
|
|
19
|
+
setRows(report.rows);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
setRows([]);
|
|
23
|
+
}
|
|
24
|
+
}, [pivotData?.data?.rows, report?.rows]);
|
|
19
25
|
const primaryMetricLabel = report?.filtersApplied?.date_range?.preset?.label;
|
|
20
26
|
const comparisonKey = report?.filtersApplied?.date_range?.comparisonRange?.value;
|
|
21
27
|
const comparisonLabel = COMPARISON_OPTIONS.find((opt) => opt.value === comparisonKey)?.text;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export default function QuillTableComponent({ report, onClick, isLoading, error, onPageChange, onSortChange, }:
|
|
2
|
+
import { QuillReport } from '../../Dashboard';
|
|
3
|
+
export default function QuillTableComponent({ report, onClick, isLoading, error, rowCount, onPageChange, onSortChange, }: {
|
|
4
|
+
report: QuillReport;
|
|
5
|
+
onClick?: (report: QuillReport) => void;
|
|
6
|
+
isLoading?: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
rowCount?: number;
|
|
9
|
+
onPageChange?: (page: {
|
|
10
|
+
currentPage: number;
|
|
11
|
+
rowsPerPage: number;
|
|
12
|
+
}) => void;
|
|
13
|
+
onSortChange?: (sort: {
|
|
14
|
+
field: string;
|
|
15
|
+
direction: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
}): JSX.Element;
|
|
4
18
|
//# sourceMappingURL=TableComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,WAAW,EAAoB,MAAM,iBAAiB,CAAC;AAKhE,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,YAAY,GACb,EAAE;IACD,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC5E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACrE,GAAG,GAAG,CAAC,OAAO,CAuId"}
|