@quillsql/react 2.15.6 → 2.15.7
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/index.cjs +195 -15
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +516 -336
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20501,6 +20501,8 @@ function extractAllReportValuesFromQuillInternalReport(reportInternal) {
|
|
|
20501
20501
|
name: reportInternal.name,
|
|
20502
20502
|
dashboardName: reportInternal.dashboardName,
|
|
20503
20503
|
// section: reportInternal.section,
|
|
20504
|
+
pagination: reportInternal.pagination,
|
|
20505
|
+
sort: reportInternal.sort,
|
|
20504
20506
|
rows: reportInternal.rows,
|
|
20505
20507
|
columns: reportInternal.columns,
|
|
20506
20508
|
chartType: reportInternal.chartType,
|
|
@@ -23645,7 +23647,7 @@ var useDashboards = () => {
|
|
|
23645
23647
|
deleteDashboard
|
|
23646
23648
|
};
|
|
23647
23649
|
};
|
|
23648
|
-
var useDashboard = (dashboardName) => {
|
|
23650
|
+
var useDashboard = (dashboardName, config) => {
|
|
23649
23651
|
const { data, dashboardFilters, reload, isLoading } = useDashboardInternal(dashboardName);
|
|
23650
23652
|
const { customFilterDispatch } = (0, import_react2.useContext)(DashboardFiltersContext);
|
|
23651
23653
|
const { reportsDispatch, reportsLoadingStateDispatch } = (0, import_react2.useContext)(ReportsContext);
|
|
@@ -23686,7 +23688,7 @@ var useDashboard = (dashboardName) => {
|
|
|
23686
23688
|
(0, import_react2.useEffect)(() => {
|
|
23687
23689
|
if (!fetchedInitialReports.current && data) {
|
|
23688
23690
|
fetchedInitialReports.current = true;
|
|
23689
|
-
fetchReports([], dashboardFilters ?? []);
|
|
23691
|
+
fetchReports([], dashboardFilters ?? [], config?.pageSize);
|
|
23690
23692
|
}
|
|
23691
23693
|
}, [fetchedInitialReports, data, dashboardFilters]);
|
|
23692
23694
|
const applyDashboardFilters = (filtersToUpdate) => {
|
|
@@ -23793,24 +23795,39 @@ var useDashboard = (dashboardName) => {
|
|
|
23793
23795
|
}
|
|
23794
23796
|
return [];
|
|
23795
23797
|
};
|
|
23796
|
-
const fetchReports = async (customFilters, dashboardFilters2) => {
|
|
23798
|
+
const fetchReports = async (customFilters, dashboardFilters2, pageSize) => {
|
|
23797
23799
|
if (!client || !sections) return;
|
|
23798
|
-
const
|
|
23799
|
-
(reports) => reports.map((report) => report.id)
|
|
23800
|
-
);
|
|
23800
|
+
const allReports = Object.values(sections).flat();
|
|
23801
23801
|
await Promise.all(
|
|
23802
|
-
|
|
23802
|
+
allReports.map(async (reportInfo) => {
|
|
23803
|
+
const reportId = reportInfo.id;
|
|
23803
23804
|
reportsLoadingStateDispatch({
|
|
23804
23805
|
type: "SET_REPORT_LOADING",
|
|
23805
23806
|
id: reportId,
|
|
23806
23807
|
data: true
|
|
23807
23808
|
});
|
|
23808
23809
|
const customReportFiltersArray = await waitForCustomFilters(reportId);
|
|
23810
|
+
let rowsPerRequest = pageSize || 600;
|
|
23811
|
+
if (!pageSize) {
|
|
23812
|
+
if (reportInfo.chartType === "table") {
|
|
23813
|
+
rowsPerRequest = 10;
|
|
23814
|
+
} else if (reportInfo.chartType === "metric") {
|
|
23815
|
+
rowsPerRequest = 1;
|
|
23816
|
+
}
|
|
23817
|
+
}
|
|
23818
|
+
const pagination = {
|
|
23819
|
+
rowsPerRequest,
|
|
23820
|
+
rowsPerPage: rowsPerRequest
|
|
23821
|
+
};
|
|
23822
|
+
const additionalProcessing = rowsPerRequest ? {
|
|
23823
|
+
page: pagination
|
|
23824
|
+
} : void 0;
|
|
23809
23825
|
const { report, error } = await fetchReport({
|
|
23810
23826
|
reportId,
|
|
23811
23827
|
client,
|
|
23812
23828
|
tenants,
|
|
23813
23829
|
flags,
|
|
23830
|
+
additionalProcessing,
|
|
23814
23831
|
filters: dashboardFilters2.concat(customFilters).concat(customReportFiltersArray),
|
|
23815
23832
|
getToken,
|
|
23816
23833
|
eventTracking
|
|
@@ -23822,7 +23839,10 @@ var useDashboard = (dashboardName) => {
|
|
|
23822
23839
|
reportsDispatch({
|
|
23823
23840
|
type: "UPDATE_REPORT",
|
|
23824
23841
|
id: reportId,
|
|
23825
|
-
data:
|
|
23842
|
+
data: {
|
|
23843
|
+
...report,
|
|
23844
|
+
pagination
|
|
23845
|
+
}
|
|
23826
23846
|
});
|
|
23827
23847
|
reportsLoadingStateDispatch({
|
|
23828
23848
|
type: "SET_REPORT_LOADING",
|
|
@@ -23840,7 +23860,7 @@ var useDashboard = (dashboardName) => {
|
|
|
23840
23860
|
applyFilters
|
|
23841
23861
|
};
|
|
23842
23862
|
};
|
|
23843
|
-
var
|
|
23863
|
+
var useDashboardReportInternal = (reportId, config) => {
|
|
23844
23864
|
const {
|
|
23845
23865
|
reports,
|
|
23846
23866
|
reportsLoadingState,
|
|
@@ -23852,13 +23872,15 @@ var useDashboardReport = (reportId, config) => {
|
|
|
23852
23872
|
const [client] = (0, import_react2.useContext)(ClientContext);
|
|
23853
23873
|
const { getToken } = (0, import_react2.useContext)(FetchContext);
|
|
23854
23874
|
const { eventTracking } = (0, import_react2.useContext)(EventTrackingContext);
|
|
23855
|
-
const { customReportFiltersDispatch } = (0, import_react2.useContext)(ReportFiltersContext);
|
|
23875
|
+
const { customReportFilters, customReportFiltersDispatch } = (0, import_react2.useContext)(ReportFiltersContext);
|
|
23856
23876
|
const { dashboardCustomFilters } = (0, import_react2.useContext)(DashboardFiltersContext);
|
|
23857
23877
|
const {
|
|
23858
23878
|
data: dashboardData,
|
|
23859
23879
|
dashboardFilters: dashboardFiltersInternal,
|
|
23860
23880
|
reload: reloadDashboard
|
|
23861
23881
|
} = useDashboardInternal(reports[reportId]?.dashboardName ?? null);
|
|
23882
|
+
const [pageLoading, setPageLoading] = (0, import_react2.useState)(false);
|
|
23883
|
+
const [maxPage, setMaxPage] = (0, import_react2.useState)(0);
|
|
23862
23884
|
(0, import_react2.useEffect)(() => {
|
|
23863
23885
|
if (config?.initialFilters) {
|
|
23864
23886
|
customReportFiltersDispatch({
|
|
@@ -23896,11 +23918,16 @@ var useDashboardReport = (reportId, config) => {
|
|
|
23896
23918
|
const dashboardFiltersArray = dashboardFiltersInternal ?? [];
|
|
23897
23919
|
const dashboardCustomFiltersArray = dashboardCustomFilters[processedReport?.dashboardName ?? ""] ?? [];
|
|
23898
23920
|
const requestFilters = filters.map(convertCustomFilter).concat(dashboardCustomFiltersArray).concat(dashboardFiltersArray);
|
|
23921
|
+
const pagination = processedReport?.pagination;
|
|
23922
|
+
const additionalProcessing = {
|
|
23923
|
+
page: pagination
|
|
23924
|
+
};
|
|
23899
23925
|
const { report, error } = await fetchReport({
|
|
23900
23926
|
reportId,
|
|
23901
23927
|
client,
|
|
23902
23928
|
tenants,
|
|
23903
23929
|
flags,
|
|
23930
|
+
additionalProcessing,
|
|
23904
23931
|
filters: requestFilters,
|
|
23905
23932
|
getToken,
|
|
23906
23933
|
eventTracking
|
|
@@ -23956,11 +23983,138 @@ var useDashboardReport = (reportId, config) => {
|
|
|
23956
23983
|
});
|
|
23957
23984
|
}
|
|
23958
23985
|
};
|
|
23986
|
+
const updateReportTableRows = async (processing, appendRows) => {
|
|
23987
|
+
if (!client) {
|
|
23988
|
+
return;
|
|
23989
|
+
}
|
|
23990
|
+
setPageLoading(true);
|
|
23991
|
+
const dashboardFiltersArray = dashboardFiltersInternal ?? [];
|
|
23992
|
+
const dashboardCustomFiltersArray = dashboardCustomFilters[processedReport?.dashboardName ?? ""] ?? [];
|
|
23993
|
+
const reportCustomFiltersArray = customReportFilters[reportId] ?? [];
|
|
23994
|
+
const filters = reportCustomFiltersArray.concat(dashboardFiltersArray).concat(dashboardCustomFiltersArray);
|
|
23995
|
+
const pivot = processedReport?.pivot;
|
|
23996
|
+
const pivotQuery = reports[reportId]?.pivotQuery;
|
|
23997
|
+
const { rows } = await fetchResultsByReport({
|
|
23998
|
+
reportId,
|
|
23999
|
+
client,
|
|
24000
|
+
tenants,
|
|
24001
|
+
processing,
|
|
24002
|
+
filters,
|
|
24003
|
+
getToken,
|
|
24004
|
+
eventTracking,
|
|
24005
|
+
pivot,
|
|
24006
|
+
pivotQuery
|
|
24007
|
+
});
|
|
24008
|
+
if (pivot && pivotQuery) {
|
|
24009
|
+
const currRows = reports[reportId]?.pivotRows || [];
|
|
24010
|
+
const updatedRows = appendRows ? [...currRows, ...rows] : rows;
|
|
24011
|
+
reportsDispatch({
|
|
24012
|
+
type: "UPDATE_REPORT",
|
|
24013
|
+
id: reportId,
|
|
24014
|
+
data: {
|
|
24015
|
+
pivotRows: updatedRows,
|
|
24016
|
+
pagination: processing.page,
|
|
24017
|
+
sort: processing.sort
|
|
24018
|
+
}
|
|
24019
|
+
});
|
|
24020
|
+
} else {
|
|
24021
|
+
const currRows = reports[reportId]?.rows || [];
|
|
24022
|
+
const updatedRows = appendRows ? [...currRows, ...rows] : rows;
|
|
24023
|
+
reportsDispatch({
|
|
24024
|
+
type: "UPDATE_REPORT",
|
|
24025
|
+
id: reportId,
|
|
24026
|
+
data: {
|
|
24027
|
+
rows: updatedRows,
|
|
24028
|
+
pagination: processing.page,
|
|
24029
|
+
sort: processing.sort
|
|
24030
|
+
}
|
|
24031
|
+
});
|
|
24032
|
+
}
|
|
24033
|
+
setMaxPage(processing.page?.page || 0);
|
|
24034
|
+
setPageLoading(false);
|
|
24035
|
+
};
|
|
24036
|
+
const handleNextPage = async () => {
|
|
24037
|
+
if (!processedReport?.pagination) {
|
|
24038
|
+
return;
|
|
24039
|
+
}
|
|
24040
|
+
const currPage = processedReport.pagination.page || 0;
|
|
24041
|
+
const updatedPage = {
|
|
24042
|
+
...processedReport.pagination,
|
|
24043
|
+
page: currPage + 1
|
|
24044
|
+
};
|
|
24045
|
+
if (shouldFetchMore(updatedPage, currPage + 1, maxPage)) {
|
|
24046
|
+
const sort = processedReport?.sort;
|
|
24047
|
+
updateReportTableRows({ page: updatedPage, sort }, true);
|
|
24048
|
+
} else {
|
|
24049
|
+
reportsDispatch({
|
|
24050
|
+
type: "UPDATE_REPORT",
|
|
24051
|
+
id: reportId,
|
|
24052
|
+
data: {
|
|
24053
|
+
pagination: updatedPage
|
|
24054
|
+
}
|
|
24055
|
+
});
|
|
24056
|
+
}
|
|
24057
|
+
};
|
|
24058
|
+
const handlePrevPage = async () => {
|
|
24059
|
+
if (!processedReport?.pagination) {
|
|
24060
|
+
return;
|
|
24061
|
+
}
|
|
24062
|
+
const currPage = processedReport.pagination.page || 0;
|
|
24063
|
+
const updatedPage = {
|
|
24064
|
+
...processedReport.pagination,
|
|
24065
|
+
page: currPage - 1
|
|
24066
|
+
};
|
|
24067
|
+
reportsDispatch({
|
|
24068
|
+
type: "UPDATE_REPORT",
|
|
24069
|
+
id: reportId,
|
|
24070
|
+
data: {
|
|
24071
|
+
pagination: updatedPage
|
|
24072
|
+
}
|
|
24073
|
+
});
|
|
24074
|
+
};
|
|
24075
|
+
const handleSort = async (sort) => {
|
|
24076
|
+
const currSort = processedReport?.sort;
|
|
24077
|
+
const currPagination = processedReport?.pagination;
|
|
24078
|
+
const newPagination = currPagination ? { ...currPagination, page: 0 } : void 0;
|
|
24079
|
+
if (currSort?.field !== sort.field || currSort?.direction?.toLowerCase() !== sort?.direction?.toLowerCase()) {
|
|
24080
|
+
updateReportTableRows({ page: newPagination, sort }, false);
|
|
24081
|
+
}
|
|
24082
|
+
};
|
|
23959
24083
|
return {
|
|
23960
24084
|
report: reportsLoadingState[reportId] ? null : processedReport,
|
|
23961
24085
|
loading: !!reportsLoadingState[reportId],
|
|
23962
24086
|
applyFilters: setReportFilters,
|
|
23963
|
-
deleteReport
|
|
24087
|
+
deleteReport,
|
|
24088
|
+
pageNumber: processedReport?.pagination?.page || 0,
|
|
24089
|
+
pageLoading,
|
|
24090
|
+
nextPage: handleNextPage,
|
|
24091
|
+
prevPage: handlePrevPage,
|
|
24092
|
+
sortRows: handleSort
|
|
24093
|
+
};
|
|
24094
|
+
};
|
|
24095
|
+
var useDashboardReport = (reportId, config) => {
|
|
24096
|
+
const { report, loading, applyFilters, deleteReport, nextPage } = useDashboardReportInternal(reportId, config);
|
|
24097
|
+
const fetchingRef = (0, import_react2.useRef)(false);
|
|
24098
|
+
const fetchNextPage = async () => {
|
|
24099
|
+
if (fetchingRef.current) {
|
|
24100
|
+
return;
|
|
24101
|
+
}
|
|
24102
|
+
try {
|
|
24103
|
+
fetchingRef.current = true;
|
|
24104
|
+
await nextPage();
|
|
24105
|
+
} catch (error) {
|
|
24106
|
+
console.error("Error fetching page:", error.message);
|
|
24107
|
+
} finally {
|
|
24108
|
+
fetchingRef.current = false;
|
|
24109
|
+
}
|
|
24110
|
+
};
|
|
24111
|
+
return {
|
|
24112
|
+
report,
|
|
24113
|
+
isLoading: loading || fetchingRef.current,
|
|
24114
|
+
loading: loading || fetchingRef.current,
|
|
24115
|
+
applyFilters,
|
|
24116
|
+
deleteReport,
|
|
24117
|
+
fetchNextPage
|
|
23964
24118
|
};
|
|
23965
24119
|
};
|
|
23966
24120
|
|
|
@@ -35166,7 +35320,8 @@ var ChartDisplay = ({
|
|
|
35166
35320
|
onClickChartElement,
|
|
35167
35321
|
overrideTheme,
|
|
35168
35322
|
referenceLines,
|
|
35169
|
-
showLegend = false
|
|
35323
|
+
showLegend = false,
|
|
35324
|
+
tableRowsLoading = false
|
|
35170
35325
|
}) => {
|
|
35171
35326
|
const { downloadCSV: downloadCSV2 } = useExport(reportId);
|
|
35172
35327
|
const [theme] = (0, import_react29.useContext)(ThemeContext);
|
|
@@ -35261,7 +35416,8 @@ var ChartDisplay = ({
|
|
|
35261
35416
|
},
|
|
35262
35417
|
onSortChange: (sort) => {
|
|
35263
35418
|
onSortChange && onSortChange(sort);
|
|
35264
|
-
}
|
|
35419
|
+
},
|
|
35420
|
+
isLoading: tableRowsLoading
|
|
35265
35421
|
}
|
|
35266
35422
|
);
|
|
35267
35423
|
}
|
|
@@ -51748,11 +51904,32 @@ function StaticChart({
|
|
|
51748
51904
|
containerStyle,
|
|
51749
51905
|
showLegend = false
|
|
51750
51906
|
}) {
|
|
51751
|
-
const {
|
|
51907
|
+
const {
|
|
51908
|
+
report,
|
|
51909
|
+
loading,
|
|
51910
|
+
pageNumber,
|
|
51911
|
+
pageLoading,
|
|
51912
|
+
nextPage,
|
|
51913
|
+
prevPage,
|
|
51914
|
+
sortRows
|
|
51915
|
+
} = useDashboardReportInternal(reportId);
|
|
51752
51916
|
const mergedStyle = {
|
|
51753
51917
|
...report?.chartType ? CHART_TYPE_STYLES[report.chartType] || DEFAULT_STYLE : DEFAULT_STYLE,
|
|
51754
51918
|
...containerStyle
|
|
51755
51919
|
};
|
|
51920
|
+
const onPageChange = (page) => {
|
|
51921
|
+
if (page == pageNumber - 1) {
|
|
51922
|
+
prevPage();
|
|
51923
|
+
} else if (page == pageNumber + 1) {
|
|
51924
|
+
nextPage();
|
|
51925
|
+
}
|
|
51926
|
+
};
|
|
51927
|
+
const onSortChange = (sort) => {
|
|
51928
|
+
sortRows({
|
|
51929
|
+
field: sort.field,
|
|
51930
|
+
direction: sort.direction
|
|
51931
|
+
});
|
|
51932
|
+
};
|
|
51756
51933
|
return /* @__PURE__ */ (0, import_jsx_runtime83.jsx)(
|
|
51757
51934
|
ChartDisplay,
|
|
51758
51935
|
{
|
|
@@ -51764,7 +51941,10 @@ function StaticChart({
|
|
|
51764
51941
|
onClickChartElement,
|
|
51765
51942
|
loading,
|
|
51766
51943
|
containerStyle: mergedStyle,
|
|
51767
|
-
showLegend
|
|
51944
|
+
showLegend,
|
|
51945
|
+
onPageChange,
|
|
51946
|
+
tableRowsLoading: pageLoading,
|
|
51947
|
+
onSortChange
|
|
51768
51948
|
}
|
|
51769
51949
|
);
|
|
51770
51950
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -2483,7 +2483,9 @@ declare const useDashboards: () => {
|
|
|
2483
2483
|
}) => Promise<void>;
|
|
2484
2484
|
deleteDashboard: (name: string) => Promise<void>;
|
|
2485
2485
|
};
|
|
2486
|
-
declare const useDashboard: (dashboardName: string
|
|
2486
|
+
declare const useDashboard: (dashboardName: string, config?: {
|
|
2487
|
+
pageSize?: number;
|
|
2488
|
+
}) => {
|
|
2487
2489
|
isLoading: boolean;
|
|
2488
2490
|
sections: Record<string, QuillReport[]> | null;
|
|
2489
2491
|
filters: DashboardFilter[];
|
|
@@ -2499,9 +2501,11 @@ declare const useDashboardReport: (reportId: string, config?: {
|
|
|
2499
2501
|
initialFilters?: Filter[];
|
|
2500
2502
|
}) => {
|
|
2501
2503
|
report: QuillReport | null;
|
|
2504
|
+
isLoading: boolean;
|
|
2502
2505
|
loading: boolean;
|
|
2503
2506
|
applyFilters: (filters: Filter[]) => void;
|
|
2504
2507
|
deleteReport: () => void;
|
|
2508
|
+
fetchNextPage: () => Promise<void>;
|
|
2505
2509
|
};
|
|
2506
2510
|
|
|
2507
2511
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -2483,7 +2483,9 @@ declare const useDashboards: () => {
|
|
|
2483
2483
|
}) => Promise<void>;
|
|
2484
2484
|
deleteDashboard: (name: string) => Promise<void>;
|
|
2485
2485
|
};
|
|
2486
|
-
declare const useDashboard: (dashboardName: string
|
|
2486
|
+
declare const useDashboard: (dashboardName: string, config?: {
|
|
2487
|
+
pageSize?: number;
|
|
2488
|
+
}) => {
|
|
2487
2489
|
isLoading: boolean;
|
|
2488
2490
|
sections: Record<string, QuillReport[]> | null;
|
|
2489
2491
|
filters: DashboardFilter[];
|
|
@@ -2499,9 +2501,11 @@ declare const useDashboardReport: (reportId: string, config?: {
|
|
|
2499
2501
|
initialFilters?: Filter[];
|
|
2500
2502
|
}) => {
|
|
2501
2503
|
report: QuillReport | null;
|
|
2504
|
+
isLoading: boolean;
|
|
2502
2505
|
loading: boolean;
|
|
2503
2506
|
applyFilters: (filters: Filter[]) => void;
|
|
2504
2507
|
deleteReport: () => void;
|
|
2508
|
+
fetchNextPage: () => Promise<void>;
|
|
2505
2509
|
};
|
|
2506
2510
|
|
|
2507
2511
|
/**
|