@quillsql/react 2.14.11 → 2.14.13
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/ReportBuilder.js +2 -2
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +6 -3
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +2 -2
- package/dist/cjs/hooks/useDashboard.d.ts +2 -4
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +74 -18
- package/dist/cjs/hooks/useExport.d.ts +5 -2
- package/dist/cjs/hooks/useExport.d.ts.map +1 -1
- package/dist/cjs/hooks/useExport.js +12 -5
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/utils/csv.d.ts.map +1 -1
- package/dist/cjs/utils/csv.js +2 -6
- package/dist/esm/ReportBuilder.js +2 -2
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +6 -3
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +2 -2
- package/dist/esm/hooks/useDashboard.d.ts +2 -4
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +74 -18
- package/dist/esm/hooks/useExport.d.ts +5 -2
- package/dist/esm/hooks/useExport.d.ts.map +1 -1
- package/dist/esm/hooks/useExport.js +12 -5
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/utils/csv.d.ts.map +1 -1
- package/dist/esm/utils/csv.js +2 -6
- package/package.json +1 -1
|
@@ -197,7 +197,7 @@ function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void
|
|
|
197
197
|
const [pivotData, setPivotData] = (0, react_1.useState)(null);
|
|
198
198
|
const [numberOfRows, setNumberOfRows] = (0, react_1.useState)(0);
|
|
199
199
|
const [rowCountIsLoading, setRowCountIsLoading] = (0, react_1.useState)(false);
|
|
200
|
-
const reportColumnsToStateColumns = (() => {
|
|
200
|
+
const reportColumnsToStateColumns = (0, react_1.useMemo)(() => {
|
|
201
201
|
const positionMap = {};
|
|
202
202
|
columns.forEach((column, index) => {
|
|
203
203
|
positionMap[column.field] = index;
|
|
@@ -213,7 +213,7 @@ function ReportBuilder({ initialTableName = '', onSubmitEditReport = () => void
|
|
|
213
213
|
const posB = positionMap[b.field];
|
|
214
214
|
return posA && posB ? posA - posB : 0;
|
|
215
215
|
});
|
|
216
|
-
})
|
|
216
|
+
}, [columns, reportColumns]);
|
|
217
217
|
// Pivot form states
|
|
218
218
|
const [pivotRowField, setPivotRowField] = (0, react_1.useState)(undefined);
|
|
219
219
|
const [pivotColumnField, setPivotColumnField] = (0, react_1.useState)(undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/BarChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/BarChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,EAC/B,MAAM,EACN,QAAQ,EACR,WAAW,EACX,IAAI,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,SAAS,EACT,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,UAAkB,EAClB,WAAmB,GACpB,EAAE;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,OAAO,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACtD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,2CAiQA"}
|
|
@@ -13,7 +13,11 @@ const ChartTooltip_1 = __importDefault(require("../../components/Chart/ChartTool
|
|
|
13
13
|
const getDomain_1 = __importDefault(require("../../utils/getDomain"));
|
|
14
14
|
const CustomReferenceLine_1 = __importDefault(require("./CustomReferenceLine"));
|
|
15
15
|
const CustomLegend_1 = require("./CustomLegend");
|
|
16
|
+
const react_1 = require("react");
|
|
16
17
|
function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, className, xAxisField, xAxisFormat, theme, comparison, isStacked, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, onClickChartElement, dateFilter, referenceLines, showLegend = false, stackedMode = false, }) {
|
|
18
|
+
// hack for getting the width of a bar
|
|
19
|
+
const barRef = (0, react_1.useRef)(null);
|
|
20
|
+
const barWidth = barRef.current?.state?.curData?.[0]?.width ?? 0;
|
|
17
21
|
const getCustomColor = (field) => {
|
|
18
22
|
const key = field.startsWith('comparison_') ? 'comparison' : 'primary';
|
|
19
23
|
field = field.replace('comparison_', '');
|
|
@@ -52,7 +56,6 @@ function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, classNa
|
|
|
52
56
|
? event.activePayload[0].payload
|
|
53
57
|
: undefined)
|
|
54
58
|
: undefined, children: [!hideCartesianGrid && ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { verticalAlign: "top", align: "left", fontSize: 11, color: theme.secondaryTextColor, wrapperStyle: {
|
|
55
|
-
paddingLeft: 20,
|
|
56
59
|
paddingBottom: 20,
|
|
57
60
|
}, content: (0, jsx_runtime_1.jsx)(CustomLegend_1.RenderLegend, {}) })), (0, jsx_runtime_1.jsx)(recharts_1.YAxis, { width: 44, hide: hideYAxis, axisLine: false, tickLine: false, type: "number", domain: stackedMode
|
|
58
61
|
? [0, 'auto']
|
|
@@ -106,8 +109,8 @@ function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, classNa
|
|
|
106
109
|
});
|
|
107
110
|
}, xAxisFormat: xAxisFormat, xAxisField: xAxisField, colors: colors, comparison: comparison, dateFilter: dateFilter, hideDot: showLegend }));
|
|
108
111
|
}, position: { y: 0 } }), sortYAxisFields([...yAxisFields]).map((elem, index) => {
|
|
109
|
-
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { radius: stackedMode && index === yAxisFields.length - 1
|
|
110
|
-
? [
|
|
112
|
+
return ((0, jsx_runtime_1.jsx)(recharts_1.Bar, { ref: index === 0 ? barRef : null, radius: stackedMode && index === yAxisFields.length - 1
|
|
113
|
+
? [0.1 * barWidth, 0.1 * barWidth, 0, 0]
|
|
111
114
|
: 0, dataKey: elem.field, stackId: stackedMode
|
|
112
115
|
? 'same_id'
|
|
113
116
|
: isStacked
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA6B7C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,2BAAmC,EACnC,yBAAgC,EAChC,wBAAgC,EAChC,sBAAgC,EAChC,mBAA6B,EAC7B,sBAAsB,EACtB,mBAA8B,EAC9B,UAAU,EACV,cAAc,EACd,UAAkB,GACnB,EAAE;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B,EAAE,OAAO,CAAC;IACrC,yBAAyB,EAAE,OAAO,CAAC;IACnC,wBAAwB,EAAE,OAAO,CAAC;IAClC,sBAAsB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3C,mBAAmB,EAAE,OAAO,GAAG,QAAQ,CAAC;IACxC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACtD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,2CA8TA"}
|
|
@@ -14,6 +14,7 @@ const getDomain_1 = __importDefault(require("../../utils/getDomain"));
|
|
|
14
14
|
const crypto_1 = require("../../utils/crypto");
|
|
15
15
|
const react_1 = require("react");
|
|
16
16
|
const CustomReferenceLine_1 = __importDefault(require("./CustomReferenceLine"));
|
|
17
|
+
const CustomLegend_1 = require("./CustomLegend");
|
|
17
18
|
function createLineForEmptyChart(yAxisFields, dateFilter, xAxisField, xAxisFormat) {
|
|
18
19
|
let lineChartData = [];
|
|
19
20
|
if (dateFilter &&
|
|
@@ -83,10 +84,9 @@ function LineChart({ colors, colorMap = {}, yAxisFields, data, containerStyle, c
|
|
|
83
84
|
return sum;
|
|
84
85
|
}, 0);
|
|
85
86
|
return ((0, jsx_runtime_1.jsx)("div", { style: { ...containerStyle }, className: className, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: '100%', minWidth: 0, minHeight: 0, children: (0, jsx_runtime_1.jsxs)(recharts_1.ComposedChart, { data: formattedData, onClick: (event) => onClickChartElement(event?.activePayload ? event.activePayload[0].payload : undefined), children: [!hideCartesianGrid && ((0, jsx_runtime_1.jsx)(recharts_1.CartesianGrid, { horizontal: !hideHorizontalCartesianGrid, vertical: !hideVerticalCartesianGrid, stroke: cartesianGridLineColor ?? '#e5e7eb', strokeDasharray: cartesianGridLineStyle === 'dashed' ? '5 5' : undefined })), showLegend && ((0, jsx_runtime_1.jsx)(recharts_1.Legend, { verticalAlign: "top", align: "left", fontSize: 11, color: theme.secondaryTextColor, wrapperStyle: {
|
|
86
|
-
paddingLeft: 20,
|
|
87
87
|
paddingBottom: 20,
|
|
88
88
|
fontFamily: theme?.fontFamily,
|
|
89
|
-
} })), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
|
|
89
|
+
}, content: (0, jsx_runtime_1.jsx)(CustomLegend_1.RenderLegend, {}) })), (0, jsx_runtime_1.jsx)(recharts_1.XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
|
|
90
90
|
fontSize: '12px',
|
|
91
91
|
fontFamily: theme?.chartLabelFontFamily ||
|
|
92
92
|
theme?.fontFamily ||
|
|
@@ -65,10 +65,7 @@ export declare const useDashboards: () => {
|
|
|
65
65
|
};
|
|
66
66
|
export declare const useDashboard: (dashboardName: string) => {
|
|
67
67
|
isLoading: boolean;
|
|
68
|
-
sections:
|
|
69
|
-
name: string;
|
|
70
|
-
reports: QuillReport[];
|
|
71
|
-
}[];
|
|
68
|
+
sections: Record<string, QuillReport[]> | null;
|
|
72
69
|
filters: DashboardFilter[];
|
|
73
70
|
applyFilters: (filters: Array<{
|
|
74
71
|
id: string;
|
|
@@ -82,5 +79,6 @@ export declare const useDashboardReport: (reportId: string) => {
|
|
|
82
79
|
report: QuillReport | null;
|
|
83
80
|
loading: boolean;
|
|
84
81
|
applyFilters: (filters: Filter[]) => void;
|
|
82
|
+
deleteReport: () => void;
|
|
85
83
|
};
|
|
86
84
|
//# sourceMappingURL=useDashboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAGL,uBAAuB,EAGvB,MAAM,EACN,cAAc,EAGd,eAAe,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAGL,uBAAuB,EAGvB,MAAM,EACN,cAAc,EAGd,eAAe,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMtD,eAAO,MAAM,oBAAoB,kBAChB,MAAM,GAAG,IAAI,kBACZ,cAAc,EAAE;;;;2CA0Mc,MAAM;qCAtK1B,MAAM,4CAEf;QACb,MAAM,EAAE,WAAW,GAAG;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACrC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC7B,oBACiB;QAChB,OAAO,EAAE,uBAAuB,EAAE,CAAC;QACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B;oCAmFa;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MA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AO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,IAAI,CAAC;CAiI1B,CAAC"}
|
|
@@ -8,6 +8,7 @@ const Filter_1 = require("../models/Filter");
|
|
|
8
8
|
const filterProcessing_1 = require("../utils/filterProcessing");
|
|
9
9
|
const report_1 = require("../utils/report");
|
|
10
10
|
const merge_1 = require("../utils/merge");
|
|
11
|
+
const dataFetcher_1 = require("../utils/dataFetcher");
|
|
11
12
|
const useDashboardInternal = (dashboardName, customFilters) => {
|
|
12
13
|
const [dashboard] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
13
14
|
const { dashboardConfig, isLoading: isDashboardsLoading, loadDashboard, dashboardConfigDispatch, } = (0, react_1.useContext)(Context_1.DashboardConfigContext);
|
|
@@ -518,6 +519,7 @@ const useDashboard = (dashboardName) => {
|
|
|
518
519
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
519
520
|
const { tenants, flags } = (0, react_1.useContext)(Context_1.TenantContext);
|
|
520
521
|
const { getToken } = (0, react_1.useContext)(Context_1.FetchContext);
|
|
522
|
+
const { customReportFilters } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
521
523
|
// If useDashboard is being used before Dashboard Context is set, we need to
|
|
522
524
|
// actively load the dashboard
|
|
523
525
|
(0, react_1.useEffect)(() => {
|
|
@@ -527,20 +529,16 @@ const useDashboard = (dashboardName) => {
|
|
|
527
529
|
}
|
|
528
530
|
}, [isLoading, data]);
|
|
529
531
|
const { allReportsById } = (0, exports.useAllReports)();
|
|
530
|
-
const
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
532
|
+
const sections = (0, react_1.useMemo)(() => {
|
|
533
|
+
if (!data?.sections)
|
|
534
|
+
return null;
|
|
535
|
+
return Object.entries(data.sections).reduce((acc, [name, reports]) => {
|
|
536
|
+
acc[name] = reports
|
|
534
537
|
.map((report) => allReportsById[report.id])
|
|
535
|
-
.filter((v) => v !== undefined)
|
|
536
|
-
|
|
538
|
+
.filter((v) => v !== undefined);
|
|
539
|
+
return acc;
|
|
540
|
+
}, {});
|
|
537
541
|
}, [data?.sections, allReportsById]);
|
|
538
|
-
const sections = (0, react_1.useMemo)(() => {
|
|
539
|
-
return dashboardSections.map((section) => ({
|
|
540
|
-
...section,
|
|
541
|
-
reports: section.reports,
|
|
542
|
-
}));
|
|
543
|
-
}, [dashboardSections]);
|
|
544
542
|
const filters = (0, react_1.useMemo)(() => {
|
|
545
543
|
if (!dashboardFilters)
|
|
546
544
|
return [];
|
|
@@ -645,21 +643,24 @@ const useDashboard = (dashboardName) => {
|
|
|
645
643
|
fetchReports(newCustomFilters, newDashboardFilters);
|
|
646
644
|
};
|
|
647
645
|
const fetchReports = async (customFilters, dashboardFilters) => {
|
|
648
|
-
if (!client)
|
|
646
|
+
if (!client || !sections)
|
|
649
647
|
return;
|
|
650
|
-
const allReportIds = sections.flatMap((
|
|
648
|
+
const allReportIds = Object.values(sections).flatMap((reports) => reports.map((report) => report.id));
|
|
651
649
|
await Promise.all(allReportIds.map(async (reportId) => {
|
|
652
650
|
reportsLoadingStateDispatch({
|
|
653
651
|
type: 'SET_REPORT_LOADING',
|
|
654
652
|
id: reportId,
|
|
655
653
|
data: true,
|
|
656
654
|
});
|
|
655
|
+
const customReportFiltersArray = customReportFilters[reportId] ?? [];
|
|
657
656
|
const { report, error } = await (0, report_1.fetchReport)({
|
|
658
657
|
reportId,
|
|
659
658
|
client,
|
|
660
659
|
tenants,
|
|
661
660
|
flags,
|
|
662
|
-
filters: dashboardFilters
|
|
661
|
+
filters: dashboardFilters
|
|
662
|
+
.concat(customFilters)
|
|
663
|
+
.concat(customReportFiltersArray),
|
|
663
664
|
getToken,
|
|
664
665
|
});
|
|
665
666
|
if (error) {
|
|
@@ -681,7 +682,7 @@ const useDashboard = (dashboardName) => {
|
|
|
681
682
|
};
|
|
682
683
|
return {
|
|
683
684
|
isLoading: !!isLoading,
|
|
684
|
-
sections,
|
|
685
|
+
sections: isLoading ? null : sections,
|
|
685
686
|
filters,
|
|
686
687
|
applyFilters,
|
|
687
688
|
};
|
|
@@ -694,6 +695,9 @@ const useDashboardReport = (reportId) => {
|
|
|
694
695
|
const { tenants, flags } = (0, react_1.useContext)(Context_1.TenantContext);
|
|
695
696
|
const [client] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
696
697
|
const { getToken } = (0, react_1.useContext)(Context_1.FetchContext);
|
|
698
|
+
const { customReportFiltersDispatch } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
699
|
+
const { dashboardCustomFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
700
|
+
const { data: dashboardData, dashboardFilters: dashboardFiltersInternal, reload: reloadDashboard, } = (0, exports.useDashboardInternal)(reports[reportId]?.dashboardName ?? null);
|
|
697
701
|
const processedReport = (0, react_1.useMemo)(() => {
|
|
698
702
|
if (!reports[reportId])
|
|
699
703
|
return null;
|
|
@@ -711,13 +715,23 @@ const useDashboardReport = (reportId) => {
|
|
|
711
715
|
id: reportId,
|
|
712
716
|
data: true,
|
|
713
717
|
});
|
|
714
|
-
|
|
718
|
+
customReportFiltersDispatch({
|
|
719
|
+
type: 'ADD_CUSTOM_REPORT_FILTERS',
|
|
720
|
+
reportId,
|
|
721
|
+
data: filters.map(Filter_1.convertCustomFilter),
|
|
722
|
+
});
|
|
723
|
+
const dashboardFiltersArray = dashboardFiltersInternal ?? [];
|
|
724
|
+
const dashboardCustomFiltersArray = dashboardCustomFilters[processedReport?.dashboardName ?? ''] ?? [];
|
|
725
|
+
const requestFilters = filters
|
|
726
|
+
.map(Filter_1.convertCustomFilter)
|
|
727
|
+
.concat(dashboardCustomFiltersArray)
|
|
728
|
+
.concat(dashboardFiltersArray);
|
|
715
729
|
const { report, error } = await (0, report_1.fetchReport)({
|
|
716
730
|
reportId,
|
|
717
731
|
client,
|
|
718
732
|
tenants,
|
|
719
733
|
flags,
|
|
720
|
-
filters:
|
|
734
|
+
filters: requestFilters,
|
|
721
735
|
getToken,
|
|
722
736
|
});
|
|
723
737
|
if (error) {
|
|
@@ -735,10 +749,52 @@ const useDashboardReport = (reportId) => {
|
|
|
735
749
|
data: false,
|
|
736
750
|
});
|
|
737
751
|
};
|
|
752
|
+
const deleteReport = () => {
|
|
753
|
+
// check if current tenant has access to the report
|
|
754
|
+
// console.log('processedReport', processedReport);
|
|
755
|
+
const report = reports[reportId];
|
|
756
|
+
if (!report) {
|
|
757
|
+
throw new Error('Report not found');
|
|
758
|
+
}
|
|
759
|
+
const dashboardOwners = dashboardData?.tenantKeys;
|
|
760
|
+
// TODO: may need changing with multiple dashboard owners
|
|
761
|
+
const tenantField = dashboardOwners?.[0] ?? null;
|
|
762
|
+
if (!tenantField || dashboardOwners?.length !== 1) {
|
|
763
|
+
throw new Error('Could not determine dashboard owner');
|
|
764
|
+
}
|
|
765
|
+
const reportFlags = report.flags?.[tenantField];
|
|
766
|
+
if (!reportFlags || reportFlags === 'QUILL_ALL_TENANTS') {
|
|
767
|
+
throw new Error('Cannot delete global report');
|
|
768
|
+
}
|
|
769
|
+
handleDeleteRequest(reportId);
|
|
770
|
+
};
|
|
771
|
+
const handleDeleteRequest = async (reportId) => {
|
|
772
|
+
if (!client)
|
|
773
|
+
return;
|
|
774
|
+
const { status, error } = await (0, dataFetcher_1.quillFetch)({
|
|
775
|
+
client,
|
|
776
|
+
task: 'delete',
|
|
777
|
+
metadata: {
|
|
778
|
+
dashboardItemId: reportId,
|
|
779
|
+
tenants,
|
|
780
|
+
},
|
|
781
|
+
getToken,
|
|
782
|
+
});
|
|
783
|
+
if (status !== 'success') {
|
|
784
|
+
throw new Error(`Error deleting report: ${error}`);
|
|
785
|
+
}
|
|
786
|
+
else {
|
|
787
|
+
reloadDashboard(undefined, true, {
|
|
788
|
+
report: { id: reportId },
|
|
789
|
+
action: 'delete',
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
};
|
|
738
793
|
return {
|
|
739
794
|
report: reportsLoadingState[reportId] ? null : processedReport,
|
|
740
795
|
loading: !!reportsLoadingState[reportId],
|
|
741
796
|
applyFilters: setReportFilters,
|
|
797
|
+
deleteReport,
|
|
742
798
|
};
|
|
743
799
|
};
|
|
744
800
|
exports.useDashboardReport = useDashboardReport;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { QuillReport } from '../models/Report';
|
|
2
|
+
interface DownloadOptions {
|
|
3
|
+
usePivotRows?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare const useExport: (reportId?: string, { CustomDocumentComponent, maximumRowsPerPage, sectionField, }?: {
|
|
3
6
|
CustomDocumentComponent?: (props: QuillPDFProps) => JSX.Element;
|
|
4
7
|
maximumRowsPerPage?: number;
|
|
5
8
|
sectionField?: string;
|
|
6
9
|
}) => {
|
|
7
|
-
downloadPDF: () => Promise<void>;
|
|
10
|
+
downloadPDF: (downloadOptions?: DownloadOptions) => Promise<void>;
|
|
8
11
|
isPDFLoading: boolean;
|
|
9
|
-
downloadCSV: () => Promise<void>;
|
|
12
|
+
downloadCSV: (downloadOptions?: DownloadOptions) => Promise<void>;
|
|
10
13
|
isCSVLoading: boolean;
|
|
11
14
|
};
|
|
12
15
|
interface QuillPDFProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExport.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkE/C,eAAO,MAAM,SAAS,cACT,MAAM,mEAMd;IACD,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CAAC;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KACA;IACD,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"useExport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExport.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkE/C,UAAU,eAAe;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,cACT,MAAM,mEAMd;IACD,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CAAC;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KACA;IACD,WAAW,EAAE,CAAC,eAAe,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,CAAC,eAAe,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,YAAY,EAAE,OAAO,CAAC;CA2RvB,CAAC;AAEF,UAAU,aAAa;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -98,7 +98,7 @@ sectionField, } = {}) => {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
return {
|
|
101
|
-
downloadCSV: async () => {
|
|
101
|
+
downloadCSV: async (downloadOptions) => {
|
|
102
102
|
if (!client) {
|
|
103
103
|
return;
|
|
104
104
|
}
|
|
@@ -111,13 +111,17 @@ sectionField, } = {}) => {
|
|
|
111
111
|
dashboardCustomFilters[dashboardReport?.dashboardName ?? ''] ??
|
|
112
112
|
[]), reportId, getToken, tenants, flags, schemaData?.customFields);
|
|
113
113
|
(0, csv_1.downloadCSV)({
|
|
114
|
-
rows: resp.pivot && resp.pivotRows
|
|
115
|
-
|
|
114
|
+
rows: resp.pivot && resp.pivotRows && downloadOptions?.usePivotRows
|
|
115
|
+
? resp.pivotRows
|
|
116
|
+
: resp.rows,
|
|
117
|
+
fields: resp.pivot && resp.pivotColumns && downloadOptions?.usePivotRows
|
|
118
|
+
? resp.pivotColumns
|
|
119
|
+
: resp.columns,
|
|
116
120
|
name: resp.name,
|
|
117
121
|
});
|
|
118
122
|
setIsCSVLoading(false);
|
|
119
123
|
},
|
|
120
|
-
downloadPDF: async () => {
|
|
124
|
+
downloadPDF: async (downloadOptions) => {
|
|
121
125
|
setIsPDFLoading(true);
|
|
122
126
|
const filters = specificReportFilters.length > 0
|
|
123
127
|
? specificReportFilters
|
|
@@ -138,7 +142,10 @@ sectionField, } = {}) => {
|
|
|
138
142
|
return;
|
|
139
143
|
}
|
|
140
144
|
const report = fetchedReport;
|
|
141
|
-
if (report.pivot &&
|
|
145
|
+
if (report.pivot &&
|
|
146
|
+
report.pivotRows &&
|
|
147
|
+
report.pivotColumns &&
|
|
148
|
+
downloadOptions?.usePivotRows) {
|
|
142
149
|
report.rows = report.pivotRows;
|
|
143
150
|
report.columns = report.pivotColumns;
|
|
144
151
|
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type { DateRangePickerComponentProps, DateRangePickerOption, DateRange, }
|
|
|
32
32
|
export type { DashboardSectionComponentProps } from './components/Dashboard/DashboardSection';
|
|
33
33
|
export { Calculation } from './utils/dataProcessing';
|
|
34
34
|
export { StringOperator, NullOperator, DateOperator, NumberOperator, FilterType, DashboardFilterType, type Filter, type InternalFilter, type InternalDashboardDateFilter, type QuillCustomInterval, type QuillCustomRelativeInterval, } from './models/Filter';
|
|
35
|
+
export type { Column } from './models/Columns';
|
|
35
36
|
export { ALL_TENANTS, SINGLE_TENANT } from './utils/constants';
|
|
36
37
|
export { useDashboard, useDashboardInternal, useDashboards, useDashboardReports, useAllReports, useDashboardReport, };
|
|
37
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,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EACV,mBAAmB,EACnB,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,GACjC,MAAM,iBAAiB,CAAC;AACzB,YAAY,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,kBAAkB,GACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/utils/csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,eAAO,MAAM,WAAW,SAAU;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,
|
|
1
|
+
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/utils/csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,eAAO,MAAM,WAAW,SAAU;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,SAuFA,CAAC"}
|
package/dist/cjs/utils/csv.js
CHANGED
|
@@ -3,11 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.downloadCSV = void 0;
|
|
4
4
|
const valueFormatter_1 = require("./valueFormatter");
|
|
5
5
|
const downloadCSV = (data) => {
|
|
6
|
-
const { rows, fields, name } = data;
|
|
7
|
-
// report.rows
|
|
8
|
-
if (rows && !rows.length) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
6
|
+
const { rows = [], fields, name } = data;
|
|
11
7
|
// if table chart, use columns and valueFormatter
|
|
12
8
|
if (fields) {
|
|
13
9
|
const newRows = [];
|
|
@@ -58,7 +54,7 @@ const downloadCSV = (data) => {
|
|
|
58
54
|
return;
|
|
59
55
|
}
|
|
60
56
|
const json = rows; // JSON data passed as a prop
|
|
61
|
-
const fieldsProcessed = Object.keys(json[0]); // Assumes all objects have same keys
|
|
57
|
+
const fieldsProcessed = Object.keys(json[0] ?? {}); // Assumes all objects have same keys
|
|
62
58
|
const csvRows = [];
|
|
63
59
|
// Header row
|
|
64
60
|
csvRows.push(fieldsProcessed.join(','));
|
|
@@ -191,7 +191,7 @@ export default function ReportBuilder({ initialTableName = '', onSubmitEditRepor
|
|
|
191
191
|
const [pivotData, setPivotData] = useState(null);
|
|
192
192
|
const [numberOfRows, setNumberOfRows] = useState(0);
|
|
193
193
|
const [rowCountIsLoading, setRowCountIsLoading] = useState(false);
|
|
194
|
-
const reportColumnsToStateColumns = (() => {
|
|
194
|
+
const reportColumnsToStateColumns = useMemo(() => {
|
|
195
195
|
const positionMap = {};
|
|
196
196
|
columns.forEach((column, index) => {
|
|
197
197
|
positionMap[column.field] = index;
|
|
@@ -207,7 +207,7 @@ export default function ReportBuilder({ initialTableName = '', onSubmitEditRepor
|
|
|
207
207
|
const posB = positionMap[b.field];
|
|
208
208
|
return posA && posB ? posA - posB : 0;
|
|
209
209
|
});
|
|
210
|
-
})
|
|
210
|
+
}, [columns, reportColumns]);
|
|
211
211
|
// Pivot form states
|
|
212
212
|
const [pivotRowField, setPivotRowField] = useState(undefined);
|
|
213
213
|
const [pivotColumnField, setPivotColumnField] = useState(undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/BarChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,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C,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACtD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,2CAiQA"}
|
|
@@ -7,7 +7,11 @@ import ChartTooltip from '../../components/Chart/ChartTooltip';
|
|
|
7
7
|
import getDomain from '../../utils/getDomain';
|
|
8
8
|
import CustomReferenceLine from './CustomReferenceLine';
|
|
9
9
|
import { RenderLegend } from './CustomLegend';
|
|
10
|
+
import { useRef } from 'react';
|
|
10
11
|
export default function BarChart({ colors, colorMap, yAxisFields, data, containerStyle, className, xAxisField, xAxisFormat, theme, comparison, isStacked, isAnimationActive = true, hideXAxis = false, hideYAxis = false, hideCartesianGrid = false, onClickChartElement, dateFilter, referenceLines, showLegend = false, stackedMode = false, }) {
|
|
12
|
+
// hack for getting the width of a bar
|
|
13
|
+
const barRef = useRef(null);
|
|
14
|
+
const barWidth = barRef.current?.state?.curData?.[0]?.width ?? 0;
|
|
11
15
|
const getCustomColor = (field) => {
|
|
12
16
|
const key = field.startsWith('comparison_') ? 'comparison' : 'primary';
|
|
13
17
|
field = field.replace('comparison_', '');
|
|
@@ -46,7 +50,6 @@ export default function BarChart({ colors, colorMap, yAxisFields, data, containe
|
|
|
46
50
|
? event.activePayload[0].payload
|
|
47
51
|
: undefined)
|
|
48
52
|
: undefined, children: [!hideCartesianGrid && (_jsx(CartesianGrid, { horizontal: true, vertical: false, stroke: "#e5e7eb" })), showLegend && (_jsx(Legend, { verticalAlign: "top", align: "left", fontSize: 11, color: theme.secondaryTextColor, wrapperStyle: {
|
|
49
|
-
paddingLeft: 20,
|
|
50
53
|
paddingBottom: 20,
|
|
51
54
|
}, content: _jsx(RenderLegend, {}) })), _jsx(YAxis, { width: 44, hide: hideYAxis, axisLine: false, tickLine: false, type: "number", domain: stackedMode
|
|
52
55
|
? [0, 'auto']
|
|
@@ -100,8 +103,8 @@ export default function BarChart({ colors, colorMap, yAxisFields, data, containe
|
|
|
100
103
|
});
|
|
101
104
|
}, xAxisFormat: xAxisFormat, xAxisField: xAxisField, colors: colors, comparison: comparison, dateFilter: dateFilter, hideDot: showLegend }));
|
|
102
105
|
}, position: { y: 0 } }), sortYAxisFields([...yAxisFields]).map((elem, index) => {
|
|
103
|
-
return (_jsx(Bar, { radius: stackedMode && index === yAxisFields.length - 1
|
|
104
|
-
? [
|
|
106
|
+
return (_jsx(Bar, { ref: index === 0 ? barRef : null, radius: stackedMode && index === yAxisFields.length - 1
|
|
107
|
+
? [0.1 * barWidth, 0.1 * barWidth, 0, 0]
|
|
105
108
|
: 0, dataKey: elem.field, stackId: stackedMode
|
|
106
109
|
? 'same_id'
|
|
107
110
|
: isStacked
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"LineChart.d.ts","sourceRoot":"","sources":["../../../../src/components/Chart/LineChart.tsx"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AA6B7C,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAChC,MAAM,EACN,QAAa,EACb,WAAW,EACX,IAAI,EACJ,cAAc,EACd,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,UAAU,EACV,iBAAwB,EACxB,SAAiB,EACjB,SAAiB,EACjB,iBAAyB,EACzB,2BAAmC,EACnC,yBAAgC,EAChC,wBAAgC,EAChC,sBAAgC,EAChC,mBAA6B,EAC7B,sBAAsB,EACtB,mBAA8B,EAC9B,UAAU,EACV,cAAc,EACd,UAAkB,GACnB,EAAE;IACD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,WAAW,EAAE,GAAG,EAAE,CAAC;IACnB,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC;IACX,UAAU,EAAE,GAAG,CAAC;IAChB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2BAA2B,EAAE,OAAO,CAAC;IACrC,yBAAyB,EAAE,OAAO,CAAC;IACnC,wBAAwB,EAAE,OAAO,CAAC;IAClC,sBAAsB,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC3C,mBAAmB,EAAE,OAAO,GAAG,QAAQ,CAAC;IACxC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,mBAAmB,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,cAAc,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACtD,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,2CA8TA"}
|
|
@@ -8,6 +8,7 @@ import getDomain from '../../utils/getDomain';
|
|
|
8
8
|
import { hashCode } from '../../utils/crypto';
|
|
9
9
|
import { useMemo } from 'react';
|
|
10
10
|
import CustomReferenceLine from './CustomReferenceLine';
|
|
11
|
+
import { RenderLegend } from './CustomLegend';
|
|
11
12
|
function createLineForEmptyChart(yAxisFields, dateFilter, xAxisField, xAxisFormat) {
|
|
12
13
|
let lineChartData = [];
|
|
13
14
|
if (dateFilter &&
|
|
@@ -77,10 +78,9 @@ export default function LineChart({ colors, colorMap = {}, yAxisFields, data, co
|
|
|
77
78
|
return sum;
|
|
78
79
|
}, 0);
|
|
79
80
|
return (_jsx("div", { style: { ...containerStyle }, className: className, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', minWidth: 0, minHeight: 0, children: _jsxs(ComposedChart, { data: formattedData, onClick: (event) => onClickChartElement(event?.activePayload ? event.activePayload[0].payload : undefined), children: [!hideCartesianGrid && (_jsx(CartesianGrid, { horizontal: !hideHorizontalCartesianGrid, vertical: !hideVerticalCartesianGrid, stroke: cartesianGridLineColor ?? '#e5e7eb', strokeDasharray: cartesianGridLineStyle === 'dashed' ? '5 5' : undefined })), showLegend && (_jsx(Legend, { verticalAlign: "top", align: "left", fontSize: 11, color: theme.secondaryTextColor, wrapperStyle: {
|
|
80
|
-
paddingLeft: 20,
|
|
81
81
|
paddingBottom: 20,
|
|
82
82
|
fontFamily: theme?.fontFamily,
|
|
83
|
-
} })), _jsx(XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
|
|
83
|
+
}, content: _jsx(RenderLegend, {}) })), _jsx(XAxis, { dataKey: xAxisField, hide: hideXAxis, tick: { transform: 'translate(0, 6)' }, style: {
|
|
84
84
|
fontSize: '12px',
|
|
85
85
|
fontFamily: theme?.chartLabelFontFamily ||
|
|
86
86
|
theme?.fontFamily ||
|
|
@@ -65,10 +65,7 @@ export declare const useDashboards: () => {
|
|
|
65
65
|
};
|
|
66
66
|
export declare const useDashboard: (dashboardName: string) => {
|
|
67
67
|
isLoading: boolean;
|
|
68
|
-
sections:
|
|
69
|
-
name: string;
|
|
70
|
-
reports: QuillReport[];
|
|
71
|
-
}[];
|
|
68
|
+
sections: Record<string, QuillReport[]> | null;
|
|
72
69
|
filters: DashboardFilter[];
|
|
73
70
|
applyFilters: (filters: Array<{
|
|
74
71
|
id: string;
|
|
@@ -82,5 +79,6 @@ export declare const useDashboardReport: (reportId: string) => {
|
|
|
82
79
|
report: QuillReport | null;
|
|
83
80
|
loading: boolean;
|
|
84
81
|
applyFilters: (filters: Filter[]) => void;
|
|
82
|
+
deleteReport: () => void;
|
|
85
83
|
};
|
|
86
84
|
//# sourceMappingURL=useDashboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAGL,uBAAuB,EAGvB,MAAM,EACN,cAAc,EAGd,eAAe,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAGL,uBAAuB,EAGvB,MAAM,EACN,cAAc,EAGd,eAAe,EAGhB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAMtD,eAAO,MAAM,oBAAoB,kBAChB,MAAM,GAAG,IAAI,kBACZ,cAAc,EAAE;;;;2CA0Mc,MAAM;qCAtK1B,MAAM,4CAEf;QACb,MAAM,EAAE,WAAW,GAAG;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACrC,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;KAC7B,oBACiB;QAChB,OAAO,EAAE,uBAAuB,EAAE,CAAC;QACnC,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B;oCAmFa;QAAE,OAAO,EAAE,M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AI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAC1C,YAAY,EAAE,MAAM,IAAI,CAAC;CAiI1B,CAAC"}
|
|
@@ -5,6 +5,7 @@ import { convertCustomFilter, InternalDashboardFilterType, StringFilterType, con
|
|
|
5
5
|
import { createDefaultDateFilter } from '../utils/filterProcessing';
|
|
6
6
|
import { convertInternalReportToReport, fetchReport } from '../utils/report';
|
|
7
7
|
import { mergeComparisonRange } from '../utils/merge';
|
|
8
|
+
import { quillFetch } from '../utils/dataFetcher';
|
|
8
9
|
export const useDashboardInternal = (dashboardName, customFilters) => {
|
|
9
10
|
const [dashboard] = useContext(DashboardContext);
|
|
10
11
|
const { dashboardConfig, isLoading: isDashboardsLoading, loadDashboard, dashboardConfigDispatch, } = useContext(DashboardConfigContext);
|
|
@@ -511,6 +512,7 @@ export const useDashboard = (dashboardName) => {
|
|
|
511
512
|
const [client] = useContext(ClientContext);
|
|
512
513
|
const { tenants, flags } = useContext(TenantContext);
|
|
513
514
|
const { getToken } = useContext(FetchContext);
|
|
515
|
+
const { customReportFilters } = useContext(ReportFiltersContext);
|
|
514
516
|
// If useDashboard is being used before Dashboard Context is set, we need to
|
|
515
517
|
// actively load the dashboard
|
|
516
518
|
useEffect(() => {
|
|
@@ -520,20 +522,16 @@ export const useDashboard = (dashboardName) => {
|
|
|
520
522
|
}
|
|
521
523
|
}, [isLoading, data]);
|
|
522
524
|
const { allReportsById } = useAllReports();
|
|
523
|
-
const
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
525
|
+
const sections = useMemo(() => {
|
|
526
|
+
if (!data?.sections)
|
|
527
|
+
return null;
|
|
528
|
+
return Object.entries(data.sections).reduce((acc, [name, reports]) => {
|
|
529
|
+
acc[name] = reports
|
|
527
530
|
.map((report) => allReportsById[report.id])
|
|
528
|
-
.filter((v) => v !== undefined)
|
|
529
|
-
|
|
531
|
+
.filter((v) => v !== undefined);
|
|
532
|
+
return acc;
|
|
533
|
+
}, {});
|
|
530
534
|
}, [data?.sections, allReportsById]);
|
|
531
|
-
const sections = useMemo(() => {
|
|
532
|
-
return dashboardSections.map((section) => ({
|
|
533
|
-
...section,
|
|
534
|
-
reports: section.reports,
|
|
535
|
-
}));
|
|
536
|
-
}, [dashboardSections]);
|
|
537
535
|
const filters = useMemo(() => {
|
|
538
536
|
if (!dashboardFilters)
|
|
539
537
|
return [];
|
|
@@ -638,21 +636,24 @@ export const useDashboard = (dashboardName) => {
|
|
|
638
636
|
fetchReports(newCustomFilters, newDashboardFilters);
|
|
639
637
|
};
|
|
640
638
|
const fetchReports = async (customFilters, dashboardFilters) => {
|
|
641
|
-
if (!client)
|
|
639
|
+
if (!client || !sections)
|
|
642
640
|
return;
|
|
643
|
-
const allReportIds = sections.flatMap((
|
|
641
|
+
const allReportIds = Object.values(sections).flatMap((reports) => reports.map((report) => report.id));
|
|
644
642
|
await Promise.all(allReportIds.map(async (reportId) => {
|
|
645
643
|
reportsLoadingStateDispatch({
|
|
646
644
|
type: 'SET_REPORT_LOADING',
|
|
647
645
|
id: reportId,
|
|
648
646
|
data: true,
|
|
649
647
|
});
|
|
648
|
+
const customReportFiltersArray = customReportFilters[reportId] ?? [];
|
|
650
649
|
const { report, error } = await fetchReport({
|
|
651
650
|
reportId,
|
|
652
651
|
client,
|
|
653
652
|
tenants,
|
|
654
653
|
flags,
|
|
655
|
-
filters: dashboardFilters
|
|
654
|
+
filters: dashboardFilters
|
|
655
|
+
.concat(customFilters)
|
|
656
|
+
.concat(customReportFiltersArray),
|
|
656
657
|
getToken,
|
|
657
658
|
});
|
|
658
659
|
if (error) {
|
|
@@ -674,7 +675,7 @@ export const useDashboard = (dashboardName) => {
|
|
|
674
675
|
};
|
|
675
676
|
return {
|
|
676
677
|
isLoading: !!isLoading,
|
|
677
|
-
sections,
|
|
678
|
+
sections: isLoading ? null : sections,
|
|
678
679
|
filters,
|
|
679
680
|
applyFilters,
|
|
680
681
|
};
|
|
@@ -686,6 +687,9 @@ export const useDashboardReport = (reportId) => {
|
|
|
686
687
|
const { tenants, flags } = useContext(TenantContext);
|
|
687
688
|
const [client] = useContext(ClientContext);
|
|
688
689
|
const { getToken } = useContext(FetchContext);
|
|
690
|
+
const { customReportFiltersDispatch } = useContext(ReportFiltersContext);
|
|
691
|
+
const { dashboardCustomFilters } = useContext(DashboardFiltersContext);
|
|
692
|
+
const { data: dashboardData, dashboardFilters: dashboardFiltersInternal, reload: reloadDashboard, } = useDashboardInternal(reports[reportId]?.dashboardName ?? null);
|
|
689
693
|
const processedReport = useMemo(() => {
|
|
690
694
|
if (!reports[reportId])
|
|
691
695
|
return null;
|
|
@@ -703,13 +707,23 @@ export const useDashboardReport = (reportId) => {
|
|
|
703
707
|
id: reportId,
|
|
704
708
|
data: true,
|
|
705
709
|
});
|
|
706
|
-
|
|
710
|
+
customReportFiltersDispatch({
|
|
711
|
+
type: 'ADD_CUSTOM_REPORT_FILTERS',
|
|
712
|
+
reportId,
|
|
713
|
+
data: filters.map(convertCustomFilter),
|
|
714
|
+
});
|
|
715
|
+
const dashboardFiltersArray = dashboardFiltersInternal ?? [];
|
|
716
|
+
const dashboardCustomFiltersArray = dashboardCustomFilters[processedReport?.dashboardName ?? ''] ?? [];
|
|
717
|
+
const requestFilters = filters
|
|
718
|
+
.map(convertCustomFilter)
|
|
719
|
+
.concat(dashboardCustomFiltersArray)
|
|
720
|
+
.concat(dashboardFiltersArray);
|
|
707
721
|
const { report, error } = await fetchReport({
|
|
708
722
|
reportId,
|
|
709
723
|
client,
|
|
710
724
|
tenants,
|
|
711
725
|
flags,
|
|
712
|
-
filters:
|
|
726
|
+
filters: requestFilters,
|
|
713
727
|
getToken,
|
|
714
728
|
});
|
|
715
729
|
if (error) {
|
|
@@ -727,9 +741,51 @@ export const useDashboardReport = (reportId) => {
|
|
|
727
741
|
data: false,
|
|
728
742
|
});
|
|
729
743
|
};
|
|
744
|
+
const deleteReport = () => {
|
|
745
|
+
// check if current tenant has access to the report
|
|
746
|
+
// console.log('processedReport', processedReport);
|
|
747
|
+
const report = reports[reportId];
|
|
748
|
+
if (!report) {
|
|
749
|
+
throw new Error('Report not found');
|
|
750
|
+
}
|
|
751
|
+
const dashboardOwners = dashboardData?.tenantKeys;
|
|
752
|
+
// TODO: may need changing with multiple dashboard owners
|
|
753
|
+
const tenantField = dashboardOwners?.[0] ?? null;
|
|
754
|
+
if (!tenantField || dashboardOwners?.length !== 1) {
|
|
755
|
+
throw new Error('Could not determine dashboard owner');
|
|
756
|
+
}
|
|
757
|
+
const reportFlags = report.flags?.[tenantField];
|
|
758
|
+
if (!reportFlags || reportFlags === 'QUILL_ALL_TENANTS') {
|
|
759
|
+
throw new Error('Cannot delete global report');
|
|
760
|
+
}
|
|
761
|
+
handleDeleteRequest(reportId);
|
|
762
|
+
};
|
|
763
|
+
const handleDeleteRequest = async (reportId) => {
|
|
764
|
+
if (!client)
|
|
765
|
+
return;
|
|
766
|
+
const { status, error } = await quillFetch({
|
|
767
|
+
client,
|
|
768
|
+
task: 'delete',
|
|
769
|
+
metadata: {
|
|
770
|
+
dashboardItemId: reportId,
|
|
771
|
+
tenants,
|
|
772
|
+
},
|
|
773
|
+
getToken,
|
|
774
|
+
});
|
|
775
|
+
if (status !== 'success') {
|
|
776
|
+
throw new Error(`Error deleting report: ${error}`);
|
|
777
|
+
}
|
|
778
|
+
else {
|
|
779
|
+
reloadDashboard(undefined, true, {
|
|
780
|
+
report: { id: reportId },
|
|
781
|
+
action: 'delete',
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
};
|
|
730
785
|
return {
|
|
731
786
|
report: reportsLoadingState[reportId] ? null : processedReport,
|
|
732
787
|
loading: !!reportsLoadingState[reportId],
|
|
733
788
|
applyFilters: setReportFilters,
|
|
789
|
+
deleteReport,
|
|
734
790
|
};
|
|
735
791
|
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { QuillReport } from '../models/Report';
|
|
2
|
+
interface DownloadOptions {
|
|
3
|
+
usePivotRows?: boolean;
|
|
4
|
+
}
|
|
2
5
|
export declare const useExport: (reportId?: string, { CustomDocumentComponent, maximumRowsPerPage, sectionField, }?: {
|
|
3
6
|
CustomDocumentComponent?: (props: QuillPDFProps) => JSX.Element;
|
|
4
7
|
maximumRowsPerPage?: number;
|
|
5
8
|
sectionField?: string;
|
|
6
9
|
}) => {
|
|
7
|
-
downloadPDF: () => Promise<void>;
|
|
10
|
+
downloadPDF: (downloadOptions?: DownloadOptions) => Promise<void>;
|
|
8
11
|
isPDFLoading: boolean;
|
|
9
|
-
downloadCSV: () => Promise<void>;
|
|
12
|
+
downloadCSV: (downloadOptions?: DownloadOptions) => Promise<void>;
|
|
10
13
|
isCSVLoading: boolean;
|
|
11
14
|
};
|
|
12
15
|
interface QuillPDFProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExport.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkE/C,eAAO,MAAM,SAAS,cACT,MAAM,mEAMd;IACD,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CAAC;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KACA;IACD,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"useExport.d.ts","sourceRoot":"","sources":["../../../src/hooks/useExport.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAkE/C,UAAU,eAAe;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,SAAS,cACT,MAAM,mEAMd;IACD,uBAAuB,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,GAAG,CAAC,OAAO,CAAC;IAChE,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,KACA;IACD,WAAW,EAAE,CAAC,eAAe,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,EAAE,CAAC,eAAe,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE,YAAY,EAAE,OAAO,CAAC;CA2RvB,CAAC;AAEF,UAAU,aAAa;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -92,7 +92,7 @@ sectionField, } = {}) => {
|
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
return {
|
|
95
|
-
downloadCSV: async () => {
|
|
95
|
+
downloadCSV: async (downloadOptions) => {
|
|
96
96
|
if (!client) {
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
@@ -105,13 +105,17 @@ sectionField, } = {}) => {
|
|
|
105
105
|
dashboardCustomFilters[dashboardReport?.dashboardName ?? ''] ??
|
|
106
106
|
[]), reportId, getToken, tenants, flags, schemaData?.customFields);
|
|
107
107
|
downloadCSV({
|
|
108
|
-
rows: resp.pivot && resp.pivotRows
|
|
109
|
-
|
|
108
|
+
rows: resp.pivot && resp.pivotRows && downloadOptions?.usePivotRows
|
|
109
|
+
? resp.pivotRows
|
|
110
|
+
: resp.rows,
|
|
111
|
+
fields: resp.pivot && resp.pivotColumns && downloadOptions?.usePivotRows
|
|
112
|
+
? resp.pivotColumns
|
|
113
|
+
: resp.columns,
|
|
110
114
|
name: resp.name,
|
|
111
115
|
});
|
|
112
116
|
setIsCSVLoading(false);
|
|
113
117
|
},
|
|
114
|
-
downloadPDF: async () => {
|
|
118
|
+
downloadPDF: async (downloadOptions) => {
|
|
115
119
|
setIsPDFLoading(true);
|
|
116
120
|
const filters = specificReportFilters.length > 0
|
|
117
121
|
? specificReportFilters
|
|
@@ -132,7 +136,10 @@ sectionField, } = {}) => {
|
|
|
132
136
|
return;
|
|
133
137
|
}
|
|
134
138
|
const report = fetchedReport;
|
|
135
|
-
if (report.pivot &&
|
|
139
|
+
if (report.pivot &&
|
|
140
|
+
report.pivotRows &&
|
|
141
|
+
report.pivotColumns &&
|
|
142
|
+
downloadOptions?.usePivotRows) {
|
|
136
143
|
report.rows = report.pivotRows;
|
|
137
144
|
report.columns = report.pivotColumns;
|
|
138
145
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export type { DateRangePickerComponentProps, DateRangePickerOption, DateRange, }
|
|
|
32
32
|
export type { DashboardSectionComponentProps } from './components/Dashboard/DashboardSection';
|
|
33
33
|
export { Calculation } from './utils/dataProcessing';
|
|
34
34
|
export { StringOperator, NullOperator, DateOperator, NumberOperator, FilterType, DashboardFilterType, type Filter, type InternalFilter, type InternalDashboardDateFilter, type QuillCustomInterval, type QuillCustomRelativeInterval, } from './models/Filter';
|
|
35
|
+
export type { Column } from './models/Columns';
|
|
35
36
|
export { ALL_TENANTS, SINGLE_TENANT } from './utils/constants';
|
|
36
37
|
export { useDashboard, useDashboardInternal, useDashboards, useDashboardReports, useAllReports, useDashboardReport, };
|
|
37
38
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChF,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,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a,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,kBAAkB,GACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/utils/csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,eAAO,MAAM,WAAW,SAAU;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,
|
|
1
|
+
{"version":3,"file":"csv.d.ts","sourceRoot":"","sources":["../../../src/utils/csv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,eAAO,MAAM,WAAW,SAAU;IAChC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,SAuFA,CAAC"}
|
package/dist/esm/utils/csv.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { quillFormat } from './valueFormatter';
|
|
2
2
|
export const downloadCSV = (data) => {
|
|
3
|
-
const { rows, fields, name } = data;
|
|
4
|
-
// report.rows
|
|
5
|
-
if (rows && !rows.length) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
3
|
+
const { rows = [], fields, name } = data;
|
|
8
4
|
// if table chart, use columns and valueFormatter
|
|
9
5
|
if (fields) {
|
|
10
6
|
const newRows = [];
|
|
@@ -55,7 +51,7 @@ export const downloadCSV = (data) => {
|
|
|
55
51
|
return;
|
|
56
52
|
}
|
|
57
53
|
const json = rows; // JSON data passed as a prop
|
|
58
|
-
const fieldsProcessed = Object.keys(json[0]); // Assumes all objects have same keys
|
|
54
|
+
const fieldsProcessed = Object.keys(json[0] ?? {}); // Assumes all objects have same keys
|
|
59
55
|
const csvRows = [];
|
|
60
56
|
// Header row
|
|
61
57
|
csvRows.push(fieldsProcessed.join(','));
|