@quillsql/react 2.13.47 → 2.13.49
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 +2 -2
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +56 -49
- package/dist/cjs/ChartBuilder.d.ts +3 -2
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +172 -138
- package/dist/cjs/ChartEditor.d.ts +2 -2
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +5 -2
- package/dist/cjs/Context.d.ts +121 -41
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +449 -261
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +26 -25
- package/dist/cjs/DateRangePicker/QuillDateRangePicker.js +0 -3
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts +24 -10
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/dateRangePickerUtils.js +472 -96
- package/dist/cjs/QuillProvider.d.ts +3 -1
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +2 -2
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +25 -14
- package/dist/cjs/SQLEditor.d.ts +1 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +51 -16
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +85 -14
- package/dist/cjs/assets/ExclamationFilledIcon.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +2 -1
- package/dist/cjs/components/Chart/CustomReferenceLine.d.ts +1 -1
- package/dist/cjs/components/Chart/CustomReferenceLine.d.ts.map +1 -1
- package/dist/cjs/components/Chart/CustomReferenceLine.js +7 -6
- package/dist/cjs/components/Chart/GaugeChart.d.ts +1 -1
- package/dist/cjs/components/Chart/GaugeChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/GaugeChart.js +63 -36
- package/dist/cjs/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/InternalChart.js +30 -33
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +3 -1
- package/dist/cjs/components/Chart/MapChart.d.ts +3 -3
- package/dist/cjs/components/Chart/MapChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/MapChart.js +62 -34
- package/dist/cjs/components/Chart/PieChart.d.ts +3 -1
- package/dist/cjs/components/Chart/PieChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/PieChart.js +80 -39
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +4 -20
- package/dist/cjs/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardTemplate.js +2 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +4 -4
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +101 -65
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +2 -2
- package/dist/cjs/components/Dashboard/util.d.ts +1 -1
- package/dist/cjs/components/Dashboard/util.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/util.js +7 -6
- package/dist/cjs/components/QuillMultiSelectSectionList.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectSectionList.js +32 -22
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +186 -159
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +83 -75
- package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.js +18 -11
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +59 -61
- package/dist/cjs/components/ReportBuilder/FilterStack.d.ts +2 -1
- package/dist/cjs/components/ReportBuilder/FilterStack.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterStack.js +3 -4
- package/dist/cjs/components/ReportBuilder/ui.d.ts +2 -2
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +4 -7
- package/dist/cjs/components/UiComponents.d.ts +1 -1
- package/dist/cjs/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useAskQuill.js +5 -1
- package/dist/cjs/hooks/useDashboard.d.ts +2 -2
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +160 -69
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +29 -15
- package/dist/cjs/hooks/useOnClickOutside.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.d.ts +1 -0
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +22 -12
- package/dist/cjs/hooks/useReport.d.ts +2 -2
- package/dist/cjs/hooks/useReport.d.ts.map +1 -1
- package/dist/cjs/hooks/useReport.js +3 -4
- package/dist/cjs/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/cjs/hooks/useVirtualTables.js +16 -22
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +2 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +19 -7
- package/dist/cjs/models/Client.d.ts +0 -1
- package/dist/cjs/models/Client.d.ts.map +1 -1
- package/dist/cjs/models/Data.d.ts +20 -0
- package/dist/cjs/models/Data.d.ts.map +1 -0
- package/dist/cjs/models/Data.js +2 -0
- package/dist/cjs/models/Filter.d.ts +42 -4
- package/dist/cjs/models/Filter.d.ts.map +1 -1
- package/dist/cjs/models/Pivot.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.d.ts +3 -2
- package/dist/cjs/utils/astProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astProcessing.js +28 -37
- package/dist/cjs/utils/client.d.ts +3 -2
- package/dist/cjs/utils/client.d.ts.map +1 -1
- package/dist/cjs/utils/client.js +38 -39
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +14 -3
- package/dist/cjs/utils/constants.d.ts +1 -0
- package/dist/cjs/utils/constants.d.ts.map +1 -1
- package/dist/cjs/utils/constants.js +2 -1
- package/dist/cjs/utils/dashboard.d.ts +3 -2
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +30 -12
- package/dist/cjs/utils/dataFetcher.d.ts +8 -5
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +189 -65
- package/dist/cjs/utils/filterProcessing.d.ts +2 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +24 -38
- package/dist/cjs/utils/getDomain.d.ts.map +1 -1
- package/dist/cjs/utils/paginationProcessing.d.ts +1 -0
- package/dist/cjs/utils/paginationProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/paginationProcessing.js +6 -1
- package/dist/cjs/utils/pivotConstructor.d.ts +2 -1
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +15 -9
- package/dist/cjs/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/pivotProcessing.js +3 -5
- package/dist/cjs/utils/queryConstructor.js +1 -1
- package/dist/cjs/utils/report.d.ts +10 -7
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +52 -60
- package/dist/cjs/utils/schema.d.ts +4 -3
- package/dist/cjs/utils/schema.d.ts.map +1 -1
- package/dist/cjs/utils/schema.js +30 -44
- package/dist/cjs/utils/tableProcessing.d.ts +16 -10
- package/dist/cjs/utils/tableProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/tableProcessing.js +92 -90
- package/dist/cjs/utils/textProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/textProcessing.js +2 -1
- package/dist/cjs/utils/ui.d.ts.map +1 -1
- package/dist/esm/Chart.d.ts +2 -2
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +60 -53
- package/dist/esm/ChartBuilder.d.ts +3 -2
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +173 -139
- package/dist/esm/ChartEditor.d.ts +2 -2
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +6 -3
- package/dist/esm/Context.d.ts +121 -41
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +450 -262
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +28 -27
- package/dist/esm/DateRangePicker/QuillDateRangePicker.js +0 -3
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts +24 -10
- package/dist/esm/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/dateRangePickerUtils.js +471 -95
- package/dist/esm/QuillProvider.d.ts +3 -1
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +2 -2
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +28 -17
- package/dist/esm/SQLEditor.d.ts +1 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +54 -19
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +88 -17
- package/dist/esm/assets/ExclamationFilledIcon.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +2 -1
- package/dist/esm/components/Chart/CustomReferenceLine.d.ts +1 -1
- package/dist/esm/components/Chart/CustomReferenceLine.d.ts.map +1 -1
- package/dist/esm/components/Chart/CustomReferenceLine.js +8 -7
- package/dist/esm/components/Chart/GaugeChart.d.ts +1 -1
- package/dist/esm/components/Chart/GaugeChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/GaugeChart.js +65 -38
- package/dist/esm/components/Chart/InternalChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/InternalChart.js +32 -35
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +3 -1
- package/dist/esm/components/Chart/MapChart.d.ts +3 -3
- package/dist/esm/components/Chart/MapChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/MapChart.js +67 -39
- package/dist/esm/components/Chart/PieChart.d.ts +3 -1
- package/dist/esm/components/Chart/PieChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/PieChart.js +80 -39
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +5 -21
- package/dist/esm/components/Dashboard/DashboardSection.js +2 -2
- package/dist/esm/components/Dashboard/DashboardTemplate.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardTemplate.js +3 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts +4 -4
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +102 -66
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +2 -2
- package/dist/esm/components/Dashboard/util.d.ts +1 -1
- package/dist/esm/components/Dashboard/util.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/util.js +8 -7
- package/dist/esm/components/QuillMultiSelectSectionList.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectSectionList.js +32 -22
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +187 -160
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +85 -77
- package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillSelectWithCombo.js +18 -11
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +59 -61
- package/dist/esm/components/ReportBuilder/FilterStack.d.ts +2 -1
- package/dist/esm/components/ReportBuilder/FilterStack.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterStack.js +3 -4
- package/dist/esm/components/ReportBuilder/ui.d.ts +2 -2
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +4 -7
- package/dist/esm/components/UiComponents.d.ts +1 -1
- package/dist/esm/hooks/useAskQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useAskQuill.js +6 -2
- package/dist/esm/hooks/useDashboard.d.ts +2 -2
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +162 -71
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +31 -17
- package/dist/esm/hooks/useOnClickOutside.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.d.ts +1 -0
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +23 -13
- package/dist/esm/hooks/useReport.d.ts +2 -2
- package/dist/esm/hooks/useReport.d.ts.map +1 -1
- package/dist/esm/hooks/useReport.js +4 -5
- package/dist/esm/hooks/useVirtualTables.d.ts.map +1 -1
- package/dist/esm/hooks/useVirtualTables.js +17 -23
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +2 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +20 -8
- package/dist/esm/models/Client.d.ts +0 -1
- package/dist/esm/models/Client.d.ts.map +1 -1
- package/dist/esm/models/Data.d.ts +20 -0
- package/dist/esm/models/Data.d.ts.map +1 -0
- package/dist/esm/models/Data.js +1 -0
- package/dist/esm/models/Filter.d.ts +42 -4
- package/dist/esm/models/Filter.d.ts.map +1 -1
- package/dist/esm/models/Pivot.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.d.ts +3 -2
- package/dist/esm/utils/astProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astProcessing.js +28 -37
- package/dist/esm/utils/client.d.ts +3 -2
- package/dist/esm/utils/client.d.ts.map +1 -1
- package/dist/esm/utils/client.js +38 -39
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +14 -3
- package/dist/esm/utils/constants.d.ts +1 -0
- package/dist/esm/utils/constants.d.ts.map +1 -1
- package/dist/esm/utils/constants.js +1 -0
- package/dist/esm/utils/dashboard.d.ts +3 -2
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +31 -13
- package/dist/esm/utils/dataFetcher.d.ts +8 -5
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +187 -65
- package/dist/esm/utils/filterProcessing.d.ts +2 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +25 -39
- package/dist/esm/utils/getDomain.d.ts.map +1 -1
- package/dist/esm/utils/paginationProcessing.d.ts +1 -0
- package/dist/esm/utils/paginationProcessing.d.ts.map +1 -1
- package/dist/esm/utils/paginationProcessing.js +5 -0
- package/dist/esm/utils/pivotConstructor.d.ts +2 -1
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +16 -10
- package/dist/esm/utils/pivotProcessing.d.ts.map +1 -1
- package/dist/esm/utils/pivotProcessing.js +5 -7
- package/dist/esm/utils/queryConstructor.js +1 -1
- package/dist/esm/utils/report.d.ts +10 -7
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +53 -61
- package/dist/esm/utils/schema.d.ts +4 -3
- package/dist/esm/utils/schema.d.ts.map +1 -1
- package/dist/esm/utils/schema.js +30 -44
- package/dist/esm/utils/tableProcessing.d.ts +16 -10
- package/dist/esm/utils/tableProcessing.d.ts.map +1 -1
- package/dist/esm/utils/tableProcessing.js +94 -92
- package/dist/esm/utils/textProcessing.d.ts.map +1 -1
- package/dist/esm/utils/textProcessing.js +2 -1
- package/dist/esm/utils/ui.d.ts.map +1 -1
- package/package.json +2 -1
package/dist/esm/Context.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import equal from 'fast-deep-equal';
|
|
3
|
+
import { createContext, useEffect, useMemo, useReducer, useRef, useState, } from 'react';
|
|
4
|
+
import { convertPresetOptionsToSelectableList, defaultOptionsV2, } from './DateRangePicker/dateRangePickerUtils';
|
|
5
5
|
import { InternalFilterType, } from './models/Filter';
|
|
6
|
+
import { fetchClient } from './utils/client';
|
|
6
7
|
import { getDashboard as requestGetDashboard } from './utils/dashboard';
|
|
7
|
-
import
|
|
8
|
-
import { defaultOptionsV2, PRIMARY_RANGE, } from './DateRangePicker/dateRangePickerUtils';
|
|
9
|
-
import { processReportResponse } from './utils/report';
|
|
8
|
+
import { quillFetch, parseFetchResponse } from './utils/dataFetcher';
|
|
10
9
|
import { createDefaultDateFilter, mergeCustomFilters, } from './utils/filterProcessing';
|
|
11
|
-
import {
|
|
10
|
+
import { processReportResponse } from './utils/report';
|
|
11
|
+
import { getSchemaInfo } from './utils/schema';
|
|
12
12
|
const dummySetter = () => { };
|
|
13
13
|
export const SchemaDataContext = createContext([
|
|
14
14
|
{
|
|
@@ -176,6 +176,8 @@ const reportsReducer = (state = {}, action) => {
|
|
|
176
176
|
...action.data,
|
|
177
177
|
},
|
|
178
178
|
};
|
|
179
|
+
case 'CLEAR_REPORTS':
|
|
180
|
+
return {};
|
|
179
181
|
default:
|
|
180
182
|
return state;
|
|
181
183
|
}
|
|
@@ -185,6 +187,24 @@ export const ReportsContext = createContext({
|
|
|
185
187
|
reportsDispatch: dummySetter,
|
|
186
188
|
fetchIndividualReport: async () => { },
|
|
187
189
|
});
|
|
190
|
+
const customReportFiltersReducer = (state, action) => {
|
|
191
|
+
switch (action.type) {
|
|
192
|
+
case 'ADD_CUSTOM_REPORT_FILTERS':
|
|
193
|
+
if (!action.data) {
|
|
194
|
+
const newState = { ...state };
|
|
195
|
+
delete newState[action.reportId];
|
|
196
|
+
return newState;
|
|
197
|
+
}
|
|
198
|
+
return {
|
|
199
|
+
...state,
|
|
200
|
+
[action.reportId]: action.data,
|
|
201
|
+
};
|
|
202
|
+
case 'DELETE_CUSTOM_REPORT_FILTERS':
|
|
203
|
+
return Object.fromEntries(Object.entries(state).filter(([key]) => key !== action.reportId));
|
|
204
|
+
default:
|
|
205
|
+
return state;
|
|
206
|
+
}
|
|
207
|
+
};
|
|
188
208
|
const reportFiltersReducer = (state = {}, action) => {
|
|
189
209
|
switch (action.type) {
|
|
190
210
|
case 'ADD_REPORT_FILTERS':
|
|
@@ -224,10 +244,30 @@ const reportFiltersReducer = (state = {}, action) => {
|
|
|
224
244
|
};
|
|
225
245
|
export const ReportFiltersContext = createContext({
|
|
226
246
|
reportFilters: {},
|
|
247
|
+
customReportFilters: {},
|
|
227
248
|
reportFiltersDispatch: dummySetter,
|
|
249
|
+
customReportFiltersDispatch: dummySetter,
|
|
228
250
|
loadFiltersForReport: async () => { },
|
|
229
251
|
abortLoadingFilters: () => { },
|
|
230
252
|
});
|
|
253
|
+
const customDashboardFiltersReducer = (state, action) => {
|
|
254
|
+
switch (action.type) {
|
|
255
|
+
case 'ADD_CUSTOM_DASHBOARD_FILTERS':
|
|
256
|
+
if (!action.data) {
|
|
257
|
+
const newState = { ...state };
|
|
258
|
+
delete newState[action.dashboardName];
|
|
259
|
+
return newState;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
...state,
|
|
263
|
+
[action.dashboardName]: action.data,
|
|
264
|
+
};
|
|
265
|
+
case 'DELETE_CUSTOM_DASHBOARD_FILTERS':
|
|
266
|
+
return Object.fromEntries(Object.entries(state).filter(([key]) => key !== action.dashboardName));
|
|
267
|
+
default:
|
|
268
|
+
return state;
|
|
269
|
+
}
|
|
270
|
+
};
|
|
231
271
|
const dashboardFiltersReducer = (state, action) => {
|
|
232
272
|
switch (action.type) {
|
|
233
273
|
case 'SET_INITIAL_DASHBOARD_FILTERS':
|
|
@@ -267,12 +307,18 @@ const dashboardFiltersReducer = (state, action) => {
|
|
|
267
307
|
};
|
|
268
308
|
export const DashboardFiltersContext = createContext({
|
|
269
309
|
dashboardFilters: {},
|
|
310
|
+
dashboardCustomFilters: {},
|
|
270
311
|
dispatch: dummySetter,
|
|
312
|
+
customFilterDispatch: dummySetter,
|
|
271
313
|
loadFiltersForDashboard: async () => { },
|
|
272
314
|
});
|
|
273
315
|
export const TenantContext = createContext({});
|
|
316
|
+
export const FetchContext = createContext({
|
|
317
|
+
getToken: async () => '',
|
|
318
|
+
quillFetchWithToken: async () => ({ data: null }),
|
|
319
|
+
});
|
|
274
320
|
// TODO: track errors per dashboard in the same way as loading state
|
|
275
|
-
export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoint, queryHeaders, withCredentials, tenants, flags, }) => {
|
|
321
|
+
export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoint, queryHeaders, withCredentials, tenants, flags, isAdmin, getAuthorizationToken = async () => '', }) => {
|
|
276
322
|
// get client from session storage
|
|
277
323
|
const [client, setClient] = useState(typeof window !== 'undefined' && sessionStorage
|
|
278
324
|
? JSON.parse(sessionStorage.getItem('quill-client') ?? 'null')
|
|
@@ -314,6 +360,8 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
314
360
|
const [dashboard, dispatch] = useReducer(dashboardReducer, {});
|
|
315
361
|
const [dashboardConfig, dashboardConfigDispatch] = useReducer(dashboardConfigReducer, {});
|
|
316
362
|
const [dashboardFilters, dashboardFiltersDispatch] = useReducer(dashboardFiltersReducer, {});
|
|
363
|
+
const [dashboardCustomFilters, customFilterDispatch] = useReducer(customDashboardFiltersReducer, {});
|
|
364
|
+
const [customReportFilters, customReportFiltersDispatch] = useReducer(customReportFiltersReducer, {});
|
|
317
365
|
const filterOptionsAbortControllers = useRef(new Set());
|
|
318
366
|
const [reportFilters, reportFiltersDispatch] = useReducer(reportFiltersReducer, {});
|
|
319
367
|
const reportFilterOptionsAbortControllers = useRef({});
|
|
@@ -321,6 +369,8 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
321
369
|
const reportsAbortControllers = useRef({});
|
|
322
370
|
const fetchSchemaAbortController = useRef(null);
|
|
323
371
|
const fetchSchemaProcessId = useRef(0);
|
|
372
|
+
const currentTenant = useRef(null);
|
|
373
|
+
const currentPublicKey = useRef(null);
|
|
324
374
|
// SETS INITIAL THEME
|
|
325
375
|
useEffect(() => {
|
|
326
376
|
if (!theme) {
|
|
@@ -348,7 +398,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
348
398
|
// id: reportId,
|
|
349
399
|
// });
|
|
350
400
|
}
|
|
351
|
-
async function loadFiltersForReport(reportId, initiator, filters, updatedFilterLabel, customFilters,
|
|
401
|
+
async function loadFiltersForReport(reportId, initiator, filters, updatedFilterLabel, customFilters, dashboardName) {
|
|
352
402
|
// Abort all previous fetch requests
|
|
353
403
|
reportFilterOptionsAbortControllers.current[reportId]?.requests.forEach((controller) => controller.abort());
|
|
354
404
|
reportFilterOptionsAbortControllers.current[reportId] = {
|
|
@@ -393,56 +443,54 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
393
443
|
const filterOptionsAbortController = new AbortController();
|
|
394
444
|
reportFilterOptionsAbortControllers.current[reportId]?.requests.add(filterOptionsAbortController);
|
|
395
445
|
try {
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
446
|
+
const result = await quillFetch({
|
|
447
|
+
client: {
|
|
448
|
+
clientId: publicKey,
|
|
449
|
+
queryEndpoint,
|
|
450
|
+
queryHeaders,
|
|
451
|
+
withCredentials: !!withCredentials,
|
|
452
|
+
},
|
|
453
|
+
task: 'filter-options',
|
|
454
|
+
metadata: {
|
|
455
|
+
clientId: publicKey,
|
|
456
|
+
publicKey: publicKey,
|
|
457
|
+
reportId: dashboardName ? undefined : reportId,
|
|
458
|
+
name: dashboardName,
|
|
459
|
+
useNewNodeSql: true,
|
|
460
|
+
filter: {
|
|
461
|
+
...filter,
|
|
462
|
+
query: undefined,
|
|
463
|
+
options: undefined,
|
|
464
|
+
},
|
|
465
|
+
appliedFilters: filters
|
|
466
|
+
.filter((f) => f.label !== filter.label)
|
|
467
|
+
.map((f) => ({
|
|
468
|
+
...f,
|
|
469
|
+
query: undefined,
|
|
470
|
+
options: undefined,
|
|
471
|
+
})),
|
|
472
|
+
customFilters: customFilters?.filter((f) => f.filterType !== InternalFilterType.DateCustomFilter &&
|
|
473
|
+
f.filterType !== InternalFilterType.DateFilter &&
|
|
474
|
+
f.filterType !== InternalFilterType.DateComparisonFilter),
|
|
475
|
+
tenants,
|
|
401
476
|
},
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
477
|
+
abortSignal: filterOptionsAbortController?.signal,
|
|
478
|
+
getToken: getAuthorizationToken,
|
|
479
|
+
});
|
|
480
|
+
const filterOptions = result.data?.filters[0]?.options ?? [];
|
|
481
|
+
if (!filterOptionsAbortController.signal.aborted) {
|
|
482
|
+
reportFiltersDispatch({
|
|
483
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
484
|
+
id: reportId,
|
|
485
|
+
data: {
|
|
410
486
|
filter: {
|
|
411
487
|
...filter,
|
|
412
|
-
options:
|
|
488
|
+
options: filterOptions,
|
|
413
489
|
},
|
|
414
|
-
|
|
415
|
-
.filter((f) => f.label !== filter.label)
|
|
416
|
-
.map((f) => ({
|
|
417
|
-
...f,
|
|
418
|
-
query: undefined,
|
|
419
|
-
options: undefined,
|
|
420
|
-
})),
|
|
421
|
-
customFilters: customFilters?.filter((f) => f.filterType !== InternalFilterType.DateCustomFilter &&
|
|
422
|
-
f.filterType !== InternalFilterType.DateFilter &&
|
|
423
|
-
f.filterType !== InternalFilterType.DateComparisonFilter),
|
|
424
|
-
tenants,
|
|
490
|
+
loading: false,
|
|
425
491
|
},
|
|
426
|
-
})
|
|
427
|
-
|
|
428
|
-
credentials: withCredentials ? 'include' : 'omit',
|
|
429
|
-
});
|
|
430
|
-
return response.json().then((result) => {
|
|
431
|
-
const filterOptions = result.data?.filters[0]?.options ?? [];
|
|
432
|
-
if (reportFilters[reportId]?.[filter.label]) {
|
|
433
|
-
reportFiltersDispatch({
|
|
434
|
-
type: 'UPDATE_REPORT_FILTER',
|
|
435
|
-
id: reportId,
|
|
436
|
-
data: {
|
|
437
|
-
filter: {
|
|
438
|
-
...filter,
|
|
439
|
-
options: filterOptions,
|
|
440
|
-
},
|
|
441
|
-
loading: false,
|
|
442
|
-
},
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
});
|
|
492
|
+
});
|
|
493
|
+
}
|
|
446
494
|
}
|
|
447
495
|
catch (error) {
|
|
448
496
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
@@ -465,7 +513,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
465
513
|
delete reportFilterOptionsAbortControllers.current[reportId];
|
|
466
514
|
}
|
|
467
515
|
}
|
|
468
|
-
async function fetchIndividualReport({ reportId, initiator, fetchRows = true, dashboardFilters, customFilters, additionalProcessing, dateBucket, reportAbortController, customFields,
|
|
516
|
+
async function fetchIndividualReport({ reportId, initiator, fetchRows = true, dashboardFilters, customFilters, additionalProcessing, dateBucket, reportAbortController, customFields, propagateChanges, }) {
|
|
469
517
|
if (!populatedClient) {
|
|
470
518
|
return;
|
|
471
519
|
}
|
|
@@ -473,7 +521,8 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
473
521
|
const currentRequest = reportsAbortControllers.current[reportId];
|
|
474
522
|
if (currentRequest) {
|
|
475
523
|
// Chart requests override useQuill and useExport requests
|
|
476
|
-
if (initiator === 'Chart'
|
|
524
|
+
if (initiator === 'Chart' ||
|
|
525
|
+
(currentRequest.initiator !== 'Chart' && initiator === 'Table')) {
|
|
477
526
|
currentRequest.request.abort();
|
|
478
527
|
}
|
|
479
528
|
else {
|
|
@@ -486,55 +535,33 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
486
535
|
request: abortController,
|
|
487
536
|
};
|
|
488
537
|
try {
|
|
489
|
-
const
|
|
538
|
+
const resp = await quillFetch({
|
|
539
|
+
client: {
|
|
540
|
+
clientId: publicKey,
|
|
541
|
+
queryEndpoint,
|
|
542
|
+
queryHeaders,
|
|
543
|
+
withCredentials: !!withCredentials,
|
|
544
|
+
},
|
|
545
|
+
task: fetchRows ? 'report' : 'report-info',
|
|
490
546
|
metadata: {
|
|
491
547
|
reportId,
|
|
492
|
-
dashboardItemId: reportId,
|
|
493
548
|
clientId: populatedClient.publicKey,
|
|
494
|
-
task: 'report',
|
|
495
|
-
databaseType: populatedClient.databaseType,
|
|
496
|
-
filters: filters.map((filter) => ({ ...filter, options: undefined })),
|
|
497
|
-
additionalProcessing,
|
|
498
549
|
useNewNodeSql: true,
|
|
499
|
-
|
|
550
|
+
filters: filters?.map((f) => ({ ...f, options: undefined })),
|
|
551
|
+
additionalProcessing,
|
|
552
|
+
dateBucket,
|
|
553
|
+
databaseType: populatedClient.databaseType,
|
|
500
554
|
tenants,
|
|
501
555
|
flags,
|
|
502
556
|
customFields,
|
|
503
557
|
},
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
? await getData(populatedClient, 'itempost', 'omit', hostedBody, cloudBody, 'POST', 'fetch-data', abortController.signal)
|
|
512
|
-
: await fetch(`${queryEndpoint}`, {
|
|
513
|
-
method: 'POST',
|
|
514
|
-
headers: {
|
|
515
|
-
'Content-Type': 'application/json',
|
|
516
|
-
...queryHeaders,
|
|
517
|
-
},
|
|
518
|
-
body: JSON.stringify({
|
|
519
|
-
metadata: {
|
|
520
|
-
task: fetchRows ? 'report' : 'report-info',
|
|
521
|
-
reportId,
|
|
522
|
-
clientId: populatedClient.publicKey,
|
|
523
|
-
useNewNodeSql: true,
|
|
524
|
-
filters: filters?.map((f) => ({ ...f, options: undefined })),
|
|
525
|
-
getDefaultDashboardFilters: !filters.length,
|
|
526
|
-
additionalProcessing,
|
|
527
|
-
dateBucket,
|
|
528
|
-
databaseType: populatedClient.databaseType,
|
|
529
|
-
tenants,
|
|
530
|
-
flags,
|
|
531
|
-
customFields,
|
|
532
|
-
},
|
|
533
|
-
}),
|
|
534
|
-
signal: abortController.signal,
|
|
535
|
-
credentials: withCredentials ? 'include' : 'omit',
|
|
536
|
-
});
|
|
537
|
-
const results = fetchRows ? resp : await resp.json();
|
|
558
|
+
abortSignal: abortController.signal,
|
|
559
|
+
getToken: getAuthorizationToken,
|
|
560
|
+
urlParameters: `caller=fetchReport&task=report`,
|
|
561
|
+
});
|
|
562
|
+
const results = fetchRows
|
|
563
|
+
? await parseFetchResponse(populatedClient, 'report', resp, getAuthorizationToken)
|
|
564
|
+
: resp;
|
|
538
565
|
if (results.error) {
|
|
539
566
|
console.error('Error fetching report:', results.error);
|
|
540
567
|
return;
|
|
@@ -548,6 +575,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
548
575
|
dateBucket,
|
|
549
576
|
additionalProcessing,
|
|
550
577
|
customFields,
|
|
578
|
+
getToken: getAuthorizationToken,
|
|
551
579
|
});
|
|
552
580
|
reportsDispatch({
|
|
553
581
|
type: 'ADD_REPORT',
|
|
@@ -559,7 +587,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
559
587
|
},
|
|
560
588
|
});
|
|
561
589
|
// If the report matches the active dashboard, update the dashboard state
|
|
562
|
-
if (
|
|
590
|
+
if (propagateChanges) {
|
|
563
591
|
if (dashboard[report.dashboardName]) {
|
|
564
592
|
dispatch({
|
|
565
593
|
type: 'UPDATE_DASHBOARD_ITEM',
|
|
@@ -577,7 +605,26 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
577
605
|
const returnedFilters = !fetchRows
|
|
578
606
|
? results.data.filters
|
|
579
607
|
: results.filters;
|
|
580
|
-
|
|
608
|
+
let dateFilterTemplate = returnedFilters.find((f) => f.filterType === 'date_range');
|
|
609
|
+
if (dateFilterTemplate) {
|
|
610
|
+
dateFilterTemplate = {
|
|
611
|
+
...dateFilterTemplate,
|
|
612
|
+
presetOptions: dateFilterTemplate?.presetOptions?.map((preset) => ({
|
|
613
|
+
...preset,
|
|
614
|
+
loopStart: preset.loopStart
|
|
615
|
+
? new Date(preset.loopStart)
|
|
616
|
+
: undefined,
|
|
617
|
+
loopEnd: preset.loopEnd ? new Date(preset.loopEnd) : undefined,
|
|
618
|
+
})),
|
|
619
|
+
defaultPresetRanges: dateFilterTemplate?.defaultPresetRanges?.map((preset) => ({
|
|
620
|
+
...preset,
|
|
621
|
+
loopStart: preset.loopStart
|
|
622
|
+
? new Date(preset.loopStart)
|
|
623
|
+
: undefined,
|
|
624
|
+
loopEnd: preset.loopEnd ? new Date(preset.loopEnd) : undefined,
|
|
625
|
+
})),
|
|
626
|
+
};
|
|
627
|
+
}
|
|
581
628
|
const dateFilter = dateFilterTemplate
|
|
582
629
|
? createDefaultDateFilter(dateFilterTemplate, [report], report.dashboardName)
|
|
583
630
|
: undefined;
|
|
@@ -586,14 +633,6 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
586
633
|
...(dateFilter ? [dateFilter] : []),
|
|
587
634
|
...stringFilters,
|
|
588
635
|
];
|
|
589
|
-
reportFiltersDispatch({
|
|
590
|
-
type: 'ADD_REPORT_FILTERS',
|
|
591
|
-
id: reportId,
|
|
592
|
-
data: allFilters.map((filter) => ({
|
|
593
|
-
filter,
|
|
594
|
-
loading: filter.filterType !== 'date_range',
|
|
595
|
-
})),
|
|
596
|
-
});
|
|
597
636
|
loadFiltersForReport(reportId, initiator, allFilters, undefined, customFilters);
|
|
598
637
|
}
|
|
599
638
|
}
|
|
@@ -653,64 +692,63 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
653
692
|
const filterOptionsAbortController = new AbortController();
|
|
654
693
|
filterOptionsAbortControllers.current.add(filterOptionsAbortController);
|
|
655
694
|
try {
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
695
|
+
const result = await quillFetch({
|
|
696
|
+
client: {
|
|
697
|
+
clientId: publicKey,
|
|
698
|
+
queryEndpoint,
|
|
699
|
+
queryHeaders,
|
|
700
|
+
withCredentials: !!withCredentials,
|
|
661
701
|
},
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
filter
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
},
|
|
673
|
-
appliedFilters: filters
|
|
674
|
-
.filter((f) => f.label !== filter.label)
|
|
675
|
-
.map((f) => ({
|
|
676
|
-
...f,
|
|
677
|
-
query: undefined,
|
|
678
|
-
options: undefined,
|
|
679
|
-
})),
|
|
680
|
-
customFilters,
|
|
681
|
-
tenants: tenants,
|
|
702
|
+
task: 'filter-options',
|
|
703
|
+
metadata: {
|
|
704
|
+
clientId: publicKey,
|
|
705
|
+
publicKey,
|
|
706
|
+
name: dashboardName,
|
|
707
|
+
useNewNodeSql: true,
|
|
708
|
+
filter: {
|
|
709
|
+
...filter,
|
|
710
|
+
query: undefined,
|
|
711
|
+
options: undefined,
|
|
682
712
|
},
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
713
|
+
appliedFilters: filters
|
|
714
|
+
.filter((f) => f.label !== filter.label)
|
|
715
|
+
.map((f) => ({
|
|
716
|
+
...f,
|
|
717
|
+
query: undefined,
|
|
718
|
+
options: undefined,
|
|
719
|
+
})),
|
|
720
|
+
customFilters,
|
|
721
|
+
tenants,
|
|
722
|
+
},
|
|
723
|
+
abortSignal: filterOptionsAbortController?.signal,
|
|
724
|
+
getToken: getAuthorizationToken,
|
|
686
725
|
});
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
filter
|
|
695
|
-
|
|
696
|
-
options: filterOptions,
|
|
697
|
-
},
|
|
698
|
-
loading: false,
|
|
726
|
+
const filterOptions = result.data?.filters[0]?.options ?? [];
|
|
727
|
+
dashboardFiltersDispatch({
|
|
728
|
+
type: 'UPDATE_DASHBOARD_FILTER',
|
|
729
|
+
dashboardName,
|
|
730
|
+
filterName: filter.label,
|
|
731
|
+
data: {
|
|
732
|
+
filter: {
|
|
733
|
+
...filter,
|
|
734
|
+
options: filterOptions,
|
|
699
735
|
},
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
736
|
+
loading: false,
|
|
737
|
+
},
|
|
738
|
+
});
|
|
739
|
+
// Should we be updating the filters for all attached reports when the dashboard filters change?
|
|
740
|
+
reportFiltersDispatch({
|
|
741
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
742
|
+
id: filter.label,
|
|
743
|
+
data: {
|
|
744
|
+
filter: {
|
|
745
|
+
...filter,
|
|
746
|
+
options: filterOptions,
|
|
747
|
+
},
|
|
748
|
+
loading: false,
|
|
749
|
+
},
|
|
713
750
|
});
|
|
751
|
+
return null;
|
|
714
752
|
}
|
|
715
753
|
catch (error) {
|
|
716
754
|
if (error instanceof Error && error.name === 'AbortError') {
|
|
@@ -733,6 +771,8 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
733
771
|
}));
|
|
734
772
|
}
|
|
735
773
|
async function loadDashboard(dashboardName, fetchFromServer = false, reportAction) {
|
|
774
|
+
if (!client)
|
|
775
|
+
return;
|
|
736
776
|
let curDashboardConfig = dashboardConfig[dashboardName]?.config;
|
|
737
777
|
if (!fetchFromServer && curDashboardConfig?.sections) {
|
|
738
778
|
if (reportAction?.action === 'delete') {
|
|
@@ -750,7 +790,6 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
750
790
|
});
|
|
751
791
|
dispatch({
|
|
752
792
|
type: 'REMOVE_DASHBOARD_ITEM',
|
|
753
|
-
dashboard: dashboardName,
|
|
754
793
|
id: reportAction.report.id,
|
|
755
794
|
});
|
|
756
795
|
}
|
|
@@ -767,12 +806,75 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
767
806
|
},
|
|
768
807
|
});
|
|
769
808
|
}
|
|
809
|
+
let newSectionOrder = curDashboardConfig.sectionOrder;
|
|
810
|
+
if (newSectionOrder) {
|
|
811
|
+
newSectionOrder = newSectionOrder.map((section) => {
|
|
812
|
+
if (section.section === report.section &&
|
|
813
|
+
!section.reportOrder.includes(report.id)) {
|
|
814
|
+
section.reportOrder.push(report.id);
|
|
815
|
+
}
|
|
816
|
+
else if (section.section !== report.section &&
|
|
817
|
+
section.reportOrder.includes(report.id)) {
|
|
818
|
+
section.reportOrder = section.reportOrder.filter((id) => id !== report.id);
|
|
819
|
+
}
|
|
820
|
+
return section;
|
|
821
|
+
});
|
|
822
|
+
const newSections = newSectionOrder.reduce((acc, section) => {
|
|
823
|
+
acc[section.section] = section.reportOrder
|
|
824
|
+
.map((id, index) => {
|
|
825
|
+
if (id === report.id) {
|
|
826
|
+
return { ...report, id: id, order: index };
|
|
827
|
+
}
|
|
828
|
+
return dashboard?.[dashboardName]?.[id]
|
|
829
|
+
? { ...dashboard[dashboardName][id], id: id, order: index }
|
|
830
|
+
: null;
|
|
831
|
+
})
|
|
832
|
+
.filter((r) => r);
|
|
833
|
+
return acc;
|
|
834
|
+
}, {});
|
|
835
|
+
dashboardConfigDispatch({
|
|
836
|
+
type: 'UPDATE_DASHBOARD',
|
|
837
|
+
id: dashboardName,
|
|
838
|
+
data: {
|
|
839
|
+
config: {
|
|
840
|
+
...curDashboardConfig,
|
|
841
|
+
sections: newSections,
|
|
842
|
+
sectionOrder: newSectionOrder?.map((section) => ({
|
|
843
|
+
...section,
|
|
844
|
+
_id: section._id ?? 'temp_section_id_' + Date.now().toString(),
|
|
845
|
+
})) ?? [],
|
|
846
|
+
},
|
|
847
|
+
loading: false,
|
|
848
|
+
},
|
|
849
|
+
});
|
|
850
|
+
if ((curDashboardConfig.sectionOrder?.find((section) => section.reportOrder?.includes(report?.id ?? ''))?.section ?? '') !== report.section) {
|
|
851
|
+
const body = {
|
|
852
|
+
task: 'set-section-order',
|
|
853
|
+
clientId: client?.clientId,
|
|
854
|
+
dashboardName,
|
|
855
|
+
sectionOrder: newSectionOrder,
|
|
856
|
+
};
|
|
857
|
+
try {
|
|
858
|
+
await quillFetch({
|
|
859
|
+
client,
|
|
860
|
+
task: 'set-section-order',
|
|
861
|
+
metadata: body,
|
|
862
|
+
getToken: getAuthorizationToken,
|
|
863
|
+
});
|
|
864
|
+
}
|
|
865
|
+
catch (e) {
|
|
866
|
+
console.error(e);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
if (reportAction?.action !== 'upsert') {
|
|
872
|
+
dashboardConfigDispatch({
|
|
873
|
+
type: 'UPDATE_DASHBOARD',
|
|
874
|
+
id: dashboardName,
|
|
875
|
+
data: { config: curDashboardConfig, loading: false },
|
|
876
|
+
});
|
|
770
877
|
}
|
|
771
|
-
dashboardConfigDispatch({
|
|
772
|
-
type: 'UPDATE_DASHBOARD',
|
|
773
|
-
id: dashboardName,
|
|
774
|
-
data: { config: curDashboardConfig, loading: false },
|
|
775
|
-
});
|
|
776
878
|
return curDashboardConfig;
|
|
777
879
|
}
|
|
778
880
|
if (!fetchFromServer &&
|
|
@@ -796,7 +898,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
796
898
|
id: dashboardName,
|
|
797
899
|
data: true,
|
|
798
900
|
});
|
|
799
|
-
const resp = await requestGetDashboard(dashboardName, populatedClient, tenants, flags);
|
|
901
|
+
const resp = await requestGetDashboard(dashboardName, populatedClient, getAuthorizationToken, tenants, flags);
|
|
800
902
|
// if dashboard has changed
|
|
801
903
|
if (!equal(resp, curDashboardConfig)) {
|
|
802
904
|
dashboardConfigDispatch({
|
|
@@ -844,6 +946,7 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
844
946
|
tenants,
|
|
845
947
|
caller,
|
|
846
948
|
abortSignal: fetchSchemaAbortController.current.signal,
|
|
949
|
+
getToken: getAuthorizationToken,
|
|
847
950
|
});
|
|
848
951
|
if (currentProcessId === fetchSchemaProcessId.current) {
|
|
849
952
|
setSchemaData({
|
|
@@ -877,74 +980,112 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
877
980
|
fetchDashboardsAbortController.current = new AbortController();
|
|
878
981
|
dashboardConfigDispatch({ type: 'CLEAR_DASHBOARDS' });
|
|
879
982
|
try {
|
|
880
|
-
const
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
983
|
+
const result = await quillFetch({
|
|
984
|
+
client: {
|
|
985
|
+
clientId: publicKey,
|
|
986
|
+
queryEndpoint,
|
|
987
|
+
queryHeaders,
|
|
988
|
+
withCredentials: !!withCredentials,
|
|
885
989
|
},
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
}),
|
|
894
|
-
credentials: withCredentials ? 'include' : 'omit',
|
|
895
|
-
signal: fetchDashboardsAbortController.current.signal,
|
|
990
|
+
task: 'dashboards',
|
|
991
|
+
metadata: {
|
|
992
|
+
clientId: publicKey,
|
|
993
|
+
// getSections: true, // skip fetching reports since 'dashboard' always does anyway
|
|
994
|
+
},
|
|
995
|
+
abortSignal: fetchDashboardsAbortController.current.signal,
|
|
996
|
+
getToken: getAuthorizationToken,
|
|
896
997
|
});
|
|
897
|
-
const result = await response.json();
|
|
898
998
|
dashboardConfigDispatch({
|
|
899
999
|
type: 'SET_DASHBOARD_DATA',
|
|
900
1000
|
data: result.data.dashboards.map((dashboard) => ({
|
|
901
1001
|
...dashboard,
|
|
1002
|
+
dateFilter: dashboard.dateFilter
|
|
1003
|
+
? {
|
|
1004
|
+
...dashboard.dateFilter,
|
|
1005
|
+
presetOptions: dashboard.dateFilter.presetOptions?.map((preset) => ({
|
|
1006
|
+
...preset,
|
|
1007
|
+
loopStart: preset.loopStart
|
|
1008
|
+
? new Date(preset.loopStart)
|
|
1009
|
+
: undefined,
|
|
1010
|
+
loopEnd: preset.loopEnd
|
|
1011
|
+
? new Date(preset.loopEnd)
|
|
1012
|
+
: undefined,
|
|
1013
|
+
})),
|
|
1014
|
+
defaultPresetRanges: dashboard.dateFilter.defaultPresetRanges?.map((preset) => ({
|
|
1015
|
+
...preset,
|
|
1016
|
+
loopStart: preset.loopStart
|
|
1017
|
+
? new Date(preset.loopStart)
|
|
1018
|
+
: undefined,
|
|
1019
|
+
loopEnd: preset.loopEnd
|
|
1020
|
+
? new Date(preset.loopEnd)
|
|
1021
|
+
: undefined,
|
|
1022
|
+
})),
|
|
1023
|
+
}
|
|
1024
|
+
: undefined,
|
|
902
1025
|
createdAt: new Date(dashboard.createdAt),
|
|
903
1026
|
})),
|
|
904
1027
|
});
|
|
905
1028
|
dashboardFiltersDispatch({
|
|
906
1029
|
type: 'SET_INITIAL_DASHBOARD_FILTERS',
|
|
907
1030
|
data: result.data.dashboards.reduce((acc, dashboard) => {
|
|
908
|
-
let
|
|
909
|
-
if (dashboard.dateFilter?.
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
});
|
|
1031
|
+
let presetOptions = defaultOptionsV2;
|
|
1032
|
+
if (dashboard.dateFilter?.presetOptions ||
|
|
1033
|
+
dashboard.dateFilter?.defaultPresetRanges) {
|
|
1034
|
+
presetOptions = convertPresetOptionsToSelectableList((dashboard.dateFilter.presetOptions ?? []).map((preset) => ({
|
|
1035
|
+
...preset,
|
|
1036
|
+
loopStart: preset.loopStart
|
|
1037
|
+
? new Date(preset.loopStart)
|
|
1038
|
+
: undefined,
|
|
1039
|
+
loopEnd: preset.loopEnd
|
|
1040
|
+
? new Date(preset.loopEnd)
|
|
1041
|
+
: undefined,
|
|
1042
|
+
})), (dashboard.dateFilter.defaultPresetRanges ?? []).map((preset) => ({
|
|
1043
|
+
...preset,
|
|
1044
|
+
loopStart: preset.loopStart
|
|
1045
|
+
? new Date(preset.loopStart)
|
|
1046
|
+
: undefined,
|
|
1047
|
+
loopEnd: preset.loopEnd
|
|
1048
|
+
? new Date(preset.loopEnd)
|
|
1049
|
+
: undefined,
|
|
1050
|
+
})));
|
|
928
1051
|
}
|
|
929
|
-
acc[dashboard.name] =
|
|
930
|
-
acc[filter.label] = {
|
|
931
|
-
filter: { ...filter, options: undefined },
|
|
932
|
-
loading: true,
|
|
933
|
-
};
|
|
934
|
-
return acc;
|
|
935
|
-
}, {});
|
|
1052
|
+
acc[dashboard.name] = {};
|
|
936
1053
|
if (dashboard.dateFilter) {
|
|
937
1054
|
dashboard.dateFilter = {
|
|
938
1055
|
...dashboard.dateFilter,
|
|
939
|
-
startDate:
|
|
940
|
-
endDate:
|
|
1056
|
+
startDate: presetOptions.find((elem) => elem.value === dashboard.dateFilter.primaryRange?.value)?.startDate,
|
|
1057
|
+
endDate: presetOptions.find((elem) => elem.value === dashboard.dateFilter.primaryRange?.value)?.endDate,
|
|
941
1058
|
filterType: 'date_range',
|
|
1059
|
+
presetOptions: dashboard.dateFilter.presetOptions?.map((preset) => ({
|
|
1060
|
+
...preset,
|
|
1061
|
+
loopStart: preset.loopStart
|
|
1062
|
+
? new Date(preset.loopStart)
|
|
1063
|
+
: undefined,
|
|
1064
|
+
loopEnd: preset.loopEnd
|
|
1065
|
+
? new Date(preset.loopEnd)
|
|
1066
|
+
: undefined,
|
|
1067
|
+
})),
|
|
1068
|
+
defaultPresetRanges: dashboard.dateFilter.defaultPresetRanges?.map((preset) => ({
|
|
1069
|
+
...preset,
|
|
1070
|
+
loopStart: preset.loopStart
|
|
1071
|
+
? new Date(preset.loopStart)
|
|
1072
|
+
: undefined,
|
|
1073
|
+
loopEnd: preset.loopEnd
|
|
1074
|
+
? new Date(preset.loopEnd)
|
|
1075
|
+
: undefined,
|
|
1076
|
+
})),
|
|
942
1077
|
};
|
|
943
1078
|
acc[dashboard.name][dashboard.dateFilter.label] = {
|
|
944
1079
|
filter: dashboard.dateFilter,
|
|
945
1080
|
loading: true,
|
|
946
1081
|
};
|
|
947
1082
|
}
|
|
1083
|
+
dashboard.filters.forEach((filter) => {
|
|
1084
|
+
acc[dashboard.name][filter.label] = {
|
|
1085
|
+
filter: { ...filter, options: undefined },
|
|
1086
|
+
loading: true,
|
|
1087
|
+
};
|
|
1088
|
+
});
|
|
948
1089
|
return acc;
|
|
949
1090
|
}, {}),
|
|
950
1091
|
});
|
|
@@ -963,6 +1104,33 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
963
1104
|
}
|
|
964
1105
|
}
|
|
965
1106
|
}
|
|
1107
|
+
async function quillFetchWithToken({ client, task, method = 'POST', metadata, abortSignal, credentials = 'omit', urlParameters, includeFlags = false, includeTenants = false, adminMode, }) {
|
|
1108
|
+
try {
|
|
1109
|
+
const result = await quillFetch({
|
|
1110
|
+
client,
|
|
1111
|
+
task,
|
|
1112
|
+
method,
|
|
1113
|
+
metadata: {
|
|
1114
|
+
flags: includeFlags ? flags : undefined,
|
|
1115
|
+
tenants: includeTenants ? tenants : undefined,
|
|
1116
|
+
adminMode,
|
|
1117
|
+
...metadata,
|
|
1118
|
+
},
|
|
1119
|
+
abortSignal,
|
|
1120
|
+
credentials,
|
|
1121
|
+
urlParameters,
|
|
1122
|
+
getToken: getAuthorizationToken,
|
|
1123
|
+
});
|
|
1124
|
+
return result;
|
|
1125
|
+
}
|
|
1126
|
+
catch (e) {
|
|
1127
|
+
if (e instanceof Error && e.name === 'AbortError') {
|
|
1128
|
+
throw e;
|
|
1129
|
+
}
|
|
1130
|
+
console.error('Failed to fetch:', e);
|
|
1131
|
+
return { error: 'Failed to fetch data' };
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
966
1134
|
useEffect(() => {
|
|
967
1135
|
async function updateClientAndSchema(publicKey) {
|
|
968
1136
|
if (populatedClient?.clientId === publicKey &&
|
|
@@ -970,8 +1138,8 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
970
1138
|
return;
|
|
971
1139
|
setIsClientLoading(true);
|
|
972
1140
|
setSchemaData({ ...schemaData, isSchemaLoading: true });
|
|
973
|
-
const newClient = await fetchClient(publicKey, queryEndpoint, withCredentials, queryHeaders);
|
|
974
|
-
if (!newClient.allTenantTypes?.every((t) => t.defaultId)) {
|
|
1141
|
+
const newClient = await fetchClient(publicKey, queryEndpoint, withCredentials, getAuthorizationToken, queryHeaders, isAdmin);
|
|
1142
|
+
if (!newClient.allTenantTypes?.every((t) => t.defaultId || t.scope === 'database')) {
|
|
975
1143
|
console.error('Default organization not found. Please select a default organization for ', newClient.allTenantTypes?.find((t) => !t.defaultId));
|
|
976
1144
|
}
|
|
977
1145
|
setClient({
|
|
@@ -986,69 +1154,89 @@ export const ContextProvider = ({ children, initialTheme, publicKey, queryEndpoi
|
|
|
986
1154
|
featureFlags: newClient.featureFlags,
|
|
987
1155
|
domainName: newClient.domainName,
|
|
988
1156
|
allTenantTypes: newClient.allTenantTypes,
|
|
989
|
-
// @ts-ignore
|
|
990
|
-
maintenanceMode: newClient?.maintenanceMode || false,
|
|
991
1157
|
});
|
|
992
1158
|
setIsClientLoading(false);
|
|
993
1159
|
}
|
|
994
1160
|
updateClientAndSchema(publicKey);
|
|
995
1161
|
}, [publicKey]);
|
|
996
1162
|
useEffect(() => {
|
|
997
|
-
if (populatedClient
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1163
|
+
if (populatedClient?.publicKey &&
|
|
1164
|
+
currentPublicKey.current !== populatedClient?.publicKey) {
|
|
1165
|
+
// CLEAR ALL DASHBOARD DATA AND REPORTS AND THEIR FILTERS
|
|
1166
|
+
dispatch({ type: 'CLEAR_DASHBOARDS' });
|
|
1167
|
+
dashboardFiltersDispatch({ type: 'CLEAR_DASHBOARD_FILTERS' });
|
|
1168
|
+
reportFiltersDispatch({ type: 'CLEAR_REPORT_FILTERS' });
|
|
1169
|
+
reportsDispatch({ type: 'CLEAR_REPORTS' });
|
|
1170
|
+
// TODO: this is yet another unfortunate hack where the answer is to unify the admin and react state
|
|
1171
|
+
// currently, we fetch the dashboards twice if both the client and default org change
|
|
1172
|
+
// because if we didn't, we would fetch 0 times if the client changed but the org didn't
|
|
1173
|
+
if (isAdmin) {
|
|
1174
|
+
setIsDashboardsLoading(true);
|
|
1175
|
+
fetchDashboards(populatedClient?.publicKey);
|
|
1176
|
+
}
|
|
1177
|
+
else {
|
|
1178
|
+
setIsDashboardsLoading(false);
|
|
1179
|
+
}
|
|
1180
|
+
if (typeof window !== 'undefined' && sessionStorage) {
|
|
1181
|
+
sessionStorage.setItem('quill-client', JSON.stringify({
|
|
1182
|
+
...populatedClient,
|
|
1183
|
+
allTenantTypes: undefined,
|
|
1184
|
+
}));
|
|
1185
|
+
}
|
|
1186
|
+
currentPublicKey.current = publicKey;
|
|
1005
1187
|
}
|
|
1006
|
-
}, [populatedClient?.publicKey
|
|
1007
|
-
// FIXME: fetchDashboards needs to rerun every time the tenant changes so that we filter reports on their flags
|
|
1188
|
+
}, [populatedClient?.publicKey]);
|
|
1008
1189
|
useEffect(() => {
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1190
|
+
if (populatedClient?.currentTenants &&
|
|
1191
|
+
!equal(currentTenant.current, populatedClient?.currentTenants)) {
|
|
1192
|
+
dispatch({ type: 'CLEAR_DASHBOARDS' });
|
|
1193
|
+
dashboardFiltersDispatch({ type: 'CLEAR_DASHBOARD_FILTERS' });
|
|
1194
|
+
reportFiltersDispatch({ type: 'CLEAR_REPORT_FILTERS' });
|
|
1195
|
+
reportsDispatch({ type: 'CLEAR_REPORTS' });
|
|
1196
|
+
if (populatedClient) {
|
|
1197
|
+
fetchSchema({
|
|
1198
|
+
client: populatedClient,
|
|
1199
|
+
tenants: populatedClient.currentTenants,
|
|
1200
|
+
caller: 'context',
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
currentTenant.current = populatedClient?.currentTenants ?? null;
|
|
1204
|
+
}
|
|
1205
|
+
}, [populatedClient?.currentTenants]);
|
|
1019
1206
|
if (!theme) {
|
|
1020
1207
|
return null;
|
|
1021
1208
|
}
|
|
1022
1209
|
if (!tenants) {
|
|
1023
1210
|
throw new Error('Quill Error: QuillProvider prop organizationId is deprecated. Please use QuillProvider tenants prop instead');
|
|
1024
1211
|
}
|
|
1025
|
-
if (populatedClient?.maintenanceMode) {
|
|
1026
|
-
return (_jsxs("div", { children: [_jsx("h1", { children: "Dashboard is currently in maintenance mode" }), _jsx("p", { children: "Please check back later or contact your administrator for more information." })] }));
|
|
1027
|
-
}
|
|
1028
1212
|
return (_jsx(ClientContext.Provider, { value: [
|
|
1029
1213
|
isClientLoading || !populatedClient ? null : populatedClient,
|
|
1030
1214
|
isClientLoading,
|
|
1031
1215
|
setClient,
|
|
1032
|
-
], children: _jsx(ThemeContext.Provider, { value: [theme, setTheme], children: _jsx(SchemaDataContext.Provider, { value: [schemaData, setSchemaData], children: _jsx(DashboardContext.Provider, { value: [dashboard, dispatch], children: _jsx(DashboardConfigContext.Provider, { value: {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
}, children: _jsx(
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1216
|
+
], children: _jsx(ThemeContext.Provider, { value: [theme, setTheme], children: _jsx(FetchContext.Provider, { value: { getToken: getAuthorizationToken, quillFetchWithToken }, children: _jsx(SchemaDataContext.Provider, { value: [schemaData, setSchemaData], children: _jsx(DashboardContext.Provider, { value: [dashboard, dispatch], children: _jsx(DashboardConfigContext.Provider, { value: {
|
|
1217
|
+
dashboardConfig: isDashboardsLoading ? {} : dashboardConfig,
|
|
1218
|
+
isLoading: isDashboardsLoading,
|
|
1219
|
+
dashboardConfigDispatch,
|
|
1220
|
+
loadDashboard,
|
|
1221
|
+
}, children: _jsx(DashboardFiltersContext.Provider, { value: {
|
|
1222
|
+
dashboardFilters,
|
|
1223
|
+
dashboardCustomFilters,
|
|
1224
|
+
customFilterDispatch,
|
|
1225
|
+
dispatch: dashboardFiltersDispatch,
|
|
1226
|
+
loadFiltersForDashboard,
|
|
1227
|
+
}, children: _jsx(ReportFiltersContext.Provider, { value: {
|
|
1228
|
+
reportFilters,
|
|
1229
|
+
customReportFilters,
|
|
1230
|
+
reportFiltersDispatch,
|
|
1231
|
+
customReportFiltersDispatch,
|
|
1232
|
+
loadFiltersForReport,
|
|
1233
|
+
abortLoadingFilters,
|
|
1234
|
+
}, children: _jsx(ReportsContext.Provider, { value: {
|
|
1235
|
+
reports,
|
|
1236
|
+
reportsDispatch,
|
|
1237
|
+
fetchIndividualReport,
|
|
1238
|
+
}, children: _jsx(TenantContext.Provider, { value: {
|
|
1239
|
+
tenants: populatedClient?.currentTenants ?? tenants,
|
|
1240
|
+
flags: populatedClient?.currentFlags ?? flags,
|
|
1241
|
+
}, children: children }) }) }) }) }) }) }) }) }) }));
|
|
1054
1242
|
};
|