@quillsql/react 2.16.2 → 2.16.4
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 +484 -185
- package/dist/index.d.cts +61 -7
- package/dist/index.d.ts +61 -7
- package/dist/index.js +484 -185
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -379,7 +379,7 @@ var init_constants = __esm({
|
|
|
379
379
|
"use strict";
|
|
380
380
|
MAX_PIVOT_UNIQUE_VALUES = 250;
|
|
381
381
|
QUILL_SERVER = typeof process !== "undefined" && process.env ? process.env.QUILL_SERVER_HOST ?? "https://quill-344421.uc.r.appspot.com" : "https://quill-344421.uc.r.appspot.com";
|
|
382
|
-
QUILL_QUERY_ENDPOINT = typeof process !== "undefined" && process.env ? process.env.QUILL_QUERY_ENDPOINT ?? "/cloud" : "/cloud";
|
|
382
|
+
QUILL_QUERY_ENDPOINT = typeof process !== "undefined" && process.env ? process.env.QUILL_QUERY_ENDPOINT ?? "/cloud/engine" : "/cloud/engine";
|
|
383
383
|
ALL_TENANTS = "QUILL_ALL_TENANTS";
|
|
384
384
|
SINGLE_TENANT = "QUILL_SINGLE_TENANT";
|
|
385
385
|
SAVED_QUERIES_DASHBOARD = "quill-saved-queries";
|
|
@@ -15946,6 +15946,7 @@ async function generatePivotWithSQL({
|
|
|
15946
15946
|
dateFilter,
|
|
15947
15947
|
distinctStrings,
|
|
15948
15948
|
dashboardName,
|
|
15949
|
+
dashboardFilters,
|
|
15949
15950
|
tenants,
|
|
15950
15951
|
additionalProcessing,
|
|
15951
15952
|
pivotQuery,
|
|
@@ -15989,6 +15990,7 @@ async function generatePivotWithSQL({
|
|
|
15989
15990
|
metadata: {
|
|
15990
15991
|
clientId: client.clientId,
|
|
15991
15992
|
pivot: pivotConfig,
|
|
15993
|
+
reportId: report?.id !== "__quillTempReport" ? report?.id : void 0,
|
|
15992
15994
|
itemQuery: reportBuilderState ? void 0 : report?.queryString,
|
|
15993
15995
|
// Don't send itemQuery if reportBuilderState is present
|
|
15994
15996
|
reportBuilderState,
|
|
@@ -15996,6 +15998,11 @@ async function generatePivotWithSQL({
|
|
|
15996
15998
|
databaseType,
|
|
15997
15999
|
// Required when sending reportBuilderState
|
|
15998
16000
|
dashboardName,
|
|
16001
|
+
filters: !report?.id ? void 0 : dashboardFilters?.map((filter) => ({
|
|
16002
|
+
...filter,
|
|
16003
|
+
options: void 0
|
|
16004
|
+
})),
|
|
16005
|
+
// Only pass dashboard filters in Dashboard context, not ReportBuilder
|
|
15999
16006
|
tenants,
|
|
16000
16007
|
additionalProcessing
|
|
16001
16008
|
},
|
|
@@ -16165,6 +16172,7 @@ async function generatePivotTable({
|
|
|
16165
16172
|
eventTracking,
|
|
16166
16173
|
uniqueValues,
|
|
16167
16174
|
dashboardName,
|
|
16175
|
+
dashboardFilters,
|
|
16168
16176
|
tenants,
|
|
16169
16177
|
additionalProcessing,
|
|
16170
16178
|
caller,
|
|
@@ -16182,6 +16190,7 @@ async function generatePivotTable({
|
|
|
16182
16190
|
dateBucket,
|
|
16183
16191
|
dateFilter,
|
|
16184
16192
|
dashboardName,
|
|
16193
|
+
dashboardFilters,
|
|
16185
16194
|
tenants,
|
|
16186
16195
|
additionalProcessing,
|
|
16187
16196
|
caller,
|
|
@@ -17143,7 +17152,6 @@ var init_astProcessing = __esm({
|
|
|
17143
17152
|
}
|
|
17144
17153
|
if (numRetries === MAX_RETRIES) {
|
|
17145
17154
|
console.error("[Error]: Max retries exceeded.");
|
|
17146
|
-
console.info(`%c[Prompt]: ${aiPrompt}`, "color: dimgray");
|
|
17147
17155
|
throw new Error(
|
|
17148
17156
|
"Error: Couldn't process your request, please re-word your prompt."
|
|
17149
17157
|
);
|
|
@@ -17173,27 +17181,6 @@ var init_astProcessing = __esm({
|
|
|
17173
17181
|
if (!tableInfo) {
|
|
17174
17182
|
throw new Error("Table info not found");
|
|
17175
17183
|
}
|
|
17176
|
-
console.log("[astProcessing] Calling report-builder-unique-values", {
|
|
17177
|
-
table: processedName,
|
|
17178
|
-
columnCount: tableInfo.columns.length,
|
|
17179
|
-
reportBuilderState: {
|
|
17180
|
-
tables: [{ name: processedName }],
|
|
17181
|
-
columns: tableInfo.columns.map(
|
|
17182
|
-
(col) => ({
|
|
17183
|
-
field: col.field,
|
|
17184
|
-
table: processedName,
|
|
17185
|
-
label: col.label,
|
|
17186
|
-
format: col.format,
|
|
17187
|
-
aggregate: void 0,
|
|
17188
|
-
customExpression: void 0
|
|
17189
|
-
})
|
|
17190
|
-
),
|
|
17191
|
-
filters: [],
|
|
17192
|
-
sorts: [],
|
|
17193
|
-
groupByColumns: [],
|
|
17194
|
-
limit: void 0
|
|
17195
|
-
}
|
|
17196
|
-
});
|
|
17197
17184
|
const uniqueValues = await getUniqueStringValuesByColumn({
|
|
17198
17185
|
columns: tableInfo.columns,
|
|
17199
17186
|
tableName: processedName,
|
|
@@ -17274,12 +17261,15 @@ var init_astProcessing = __esm({
|
|
|
17274
17261
|
if (!report) {
|
|
17275
17262
|
throw new Error("Report not found");
|
|
17276
17263
|
}
|
|
17277
|
-
const resp =
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17282
|
-
|
|
17264
|
+
const { data: resp } = await quillFetch({
|
|
17265
|
+
client,
|
|
17266
|
+
task: "astify",
|
|
17267
|
+
metadata: {
|
|
17268
|
+
query: report.queryString,
|
|
17269
|
+
useNewNodeSql: true
|
|
17270
|
+
},
|
|
17271
|
+
getToken
|
|
17272
|
+
});
|
|
17283
17273
|
if (resp.success === false) {
|
|
17284
17274
|
throw new Error(resp.message || "Couldn't process report query.");
|
|
17285
17275
|
}
|
|
@@ -17620,7 +17610,15 @@ var init_tableProcessing = __esm({
|
|
|
17620
17610
|
baseQuery = withMatch[1];
|
|
17621
17611
|
}
|
|
17622
17612
|
const dbType = client.databaseType || "postgresql";
|
|
17623
|
-
const astResponse =
|
|
17613
|
+
const { data: astResponse } = await quillFetch({
|
|
17614
|
+
client,
|
|
17615
|
+
task: "astify",
|
|
17616
|
+
metadata: {
|
|
17617
|
+
query: baseQuery,
|
|
17618
|
+
useNewNodeSql: true
|
|
17619
|
+
},
|
|
17620
|
+
getToken
|
|
17621
|
+
});
|
|
17624
17622
|
if (astResponse.success && astResponse.ast) {
|
|
17625
17623
|
const selectAst = getSelectFromAST(astResponse.ast);
|
|
17626
17624
|
const tableNames = selectAst.from ? selectAst.from.map((t) => t.as || t.table || t.name).filter(Boolean) : [];
|
|
@@ -17776,7 +17774,7 @@ var init_tableProcessing = __esm({
|
|
|
17776
17774
|
task: "report-builder-unique-values",
|
|
17777
17775
|
metadata: {
|
|
17778
17776
|
reportBuilderState,
|
|
17779
|
-
|
|
17777
|
+
stringColumns: stringColumns.map((col) => col.field),
|
|
17780
17778
|
clientId: client.clientId,
|
|
17781
17779
|
databaseType: client.databaseType?.toLowerCase() || "postgresql",
|
|
17782
17780
|
customFields,
|
|
@@ -17897,7 +17895,6 @@ var init_tableProcessing = __esm({
|
|
|
17897
17895
|
dashboardName,
|
|
17898
17896
|
reportBuilderState
|
|
17899
17897
|
);
|
|
17900
|
-
console.log("dateRanges 1", dateRanges);
|
|
17901
17898
|
if (dateRanges === null) {
|
|
17902
17899
|
throw new Error("Couldn't fetch date ranges");
|
|
17903
17900
|
}
|
|
@@ -18014,7 +18011,7 @@ var init_tableProcessing = __esm({
|
|
|
18014
18011
|
task: "report-builder-unique-values",
|
|
18015
18012
|
metadata: {
|
|
18016
18013
|
reportBuilderState,
|
|
18017
|
-
columns,
|
|
18014
|
+
stringColumns: columns,
|
|
18018
18015
|
clientId: client.clientId,
|
|
18019
18016
|
databaseType: client.databaseType?.toLowerCase() || "postgresql",
|
|
18020
18017
|
customFields,
|
|
@@ -18152,7 +18149,6 @@ var init_tableProcessing = __esm({
|
|
|
18152
18149
|
},
|
|
18153
18150
|
{}
|
|
18154
18151
|
);
|
|
18155
|
-
console.log("what", results);
|
|
18156
18152
|
return results;
|
|
18157
18153
|
}
|
|
18158
18154
|
const distinctValueQuery = generateMinMaxDateRangeQueries(
|
|
@@ -18263,15 +18259,23 @@ var init_tableProcessing = __esm({
|
|
|
18263
18259
|
let parsedSuccessfully = true;
|
|
18264
18260
|
let parsingError = "";
|
|
18265
18261
|
if (!rowCountOnly) {
|
|
18266
|
-
|
|
18267
|
-
|
|
18268
|
-
|
|
18269
|
-
|
|
18270
|
-
|
|
18271
|
-
|
|
18272
|
-
|
|
18262
|
+
try {
|
|
18263
|
+
const { data: results } = await quillFetch({
|
|
18264
|
+
client,
|
|
18265
|
+
task: "astify",
|
|
18266
|
+
metadata: {
|
|
18267
|
+
query,
|
|
18268
|
+
useNewNodeSql: true
|
|
18269
|
+
},
|
|
18270
|
+
getToken
|
|
18271
|
+
});
|
|
18272
|
+
if (!results || results.success == false) {
|
|
18273
|
+
parsedSuccessfully = false;
|
|
18274
|
+
parsingError = results.message || "";
|
|
18275
|
+
}
|
|
18276
|
+
} catch (e) {
|
|
18273
18277
|
parsedSuccessfully = false;
|
|
18274
|
-
parsingError =
|
|
18278
|
+
parsingError = e.message || "Failed to parse query";
|
|
18275
18279
|
}
|
|
18276
18280
|
}
|
|
18277
18281
|
const fetchResp = await quillFetch({
|
|
@@ -19924,6 +19928,7 @@ async function getPivotTable(report, dashboardFilters, dashboardName, getToken,
|
|
|
19924
19928
|
dateBucket,
|
|
19925
19929
|
dateFilter,
|
|
19926
19930
|
dashboardName,
|
|
19931
|
+
dashboardFilters,
|
|
19927
19932
|
tenants,
|
|
19928
19933
|
additionalProcessing,
|
|
19929
19934
|
getToken
|
|
@@ -19952,6 +19957,7 @@ async function getPivotTable(report, dashboardFilters, dashboardName, getToken,
|
|
|
19952
19957
|
client,
|
|
19953
19958
|
uniqueValues: report.distinctStrings,
|
|
19954
19959
|
dashboardName,
|
|
19960
|
+
dashboardFilters,
|
|
19955
19961
|
tenants,
|
|
19956
19962
|
dateFilter,
|
|
19957
19963
|
additionalProcessing,
|
|
@@ -20359,27 +20365,37 @@ async function saveReport({
|
|
|
20359
20365
|
tenants
|
|
20360
20366
|
}) {
|
|
20361
20367
|
const { publicKey, databaseType } = client;
|
|
20362
|
-
const {
|
|
20368
|
+
const {
|
|
20369
|
+
reportBuilderState,
|
|
20370
|
+
queryString,
|
|
20371
|
+
adminMode,
|
|
20372
|
+
...reportWithoutStateAndQuery
|
|
20373
|
+
} = report;
|
|
20363
20374
|
const reportToSave = reportWithoutStateAndQuery;
|
|
20364
|
-
const task = reportBuilderState ? "create-report" : "create";
|
|
20375
|
+
const task = reportBuilderState && !adminMode ? "create-report" : "create";
|
|
20376
|
+
const isCreateTask = task === "create";
|
|
20365
20377
|
const { data } = await quillFetch({
|
|
20366
20378
|
client,
|
|
20367
20379
|
task,
|
|
20368
20380
|
metadata: {
|
|
20369
20381
|
...reportToSave,
|
|
20370
|
-
// Pass reportBuilderState
|
|
20382
|
+
// Pass reportBuilderState if present, queryString otherwise
|
|
20371
20383
|
...reportBuilderState ? {
|
|
20372
20384
|
reportBuilderState,
|
|
20373
|
-
databaseType
|
|
20385
|
+
databaseType
|
|
20374
20386
|
} : {
|
|
20375
20387
|
queryString
|
|
20376
20388
|
},
|
|
20377
20389
|
rows: void 0,
|
|
20378
20390
|
compareRows: void 0,
|
|
20379
20391
|
dashboardItemId,
|
|
20392
|
+
...dashboardItemId ? { reportId: dashboardItemId } : {},
|
|
20380
20393
|
// Remove useNewNodeSql since backend will handle conversion
|
|
20381
20394
|
clientId: publicKey,
|
|
20382
|
-
tenants
|
|
20395
|
+
tenants,
|
|
20396
|
+
// Only include adminMode for 'create' task, not 'create-report'
|
|
20397
|
+
...isCreateTask && { adminMode },
|
|
20398
|
+
section: report.section
|
|
20383
20399
|
},
|
|
20384
20400
|
getToken
|
|
20385
20401
|
});
|
|
@@ -20656,7 +20672,6 @@ var fetchReportBuilderDataFromAST = async ({
|
|
|
20656
20672
|
customFields ?? [],
|
|
20657
20673
|
dashboardName
|
|
20658
20674
|
);
|
|
20659
|
-
console.log("dateRanges 3", dateRanges);
|
|
20660
20675
|
if (dateRanges === null) {
|
|
20661
20676
|
throw new Error("Couldn't fetch date ranges");
|
|
20662
20677
|
}
|
|
@@ -31558,23 +31573,53 @@ function QuillMetricComponent({
|
|
|
31558
31573
|
width: "100%"
|
|
31559
31574
|
}
|
|
31560
31575
|
}
|
|
31561
|
-
) : !report?.rows?.[0] || report.rows[0][report.xAxisField] ===
|
|
31576
|
+
) : !report?.rows || report?.rows?.length === 0 || report.rows[0]?.[report.xAxisField] === null || report.rows[0]?.[report.xAxisField] === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31562
31577
|
"div",
|
|
31563
31578
|
{
|
|
31564
31579
|
style: {
|
|
31565
|
-
|
|
31566
|
-
|
|
31567
|
-
|
|
31568
|
-
|
|
31569
|
-
|
|
31570
|
-
alignItems: "center",
|
|
31571
|
-
fontSize: 13,
|
|
31572
|
-
fontFamily: theme?.fontFamily,
|
|
31573
|
-
color: theme?.secondaryTextColor,
|
|
31574
|
-
maxWidth: "100%",
|
|
31575
|
-
width: "100%"
|
|
31580
|
+
padding: 0,
|
|
31581
|
+
height: "100%",
|
|
31582
|
+
width: "100%",
|
|
31583
|
+
boxSizing: "content-box",
|
|
31584
|
+
flex: 1
|
|
31576
31585
|
},
|
|
31577
|
-
children:
|
|
31586
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31587
|
+
"div",
|
|
31588
|
+
{
|
|
31589
|
+
style: {
|
|
31590
|
+
fontFamily: theme?.fontFamily,
|
|
31591
|
+
fontSize: 32,
|
|
31592
|
+
color: theme?.primaryTextColor,
|
|
31593
|
+
fontWeight: "600",
|
|
31594
|
+
textOverflow: "ellipsis",
|
|
31595
|
+
margin: 0,
|
|
31596
|
+
whiteSpace: "nowrap",
|
|
31597
|
+
boxSizing: "content-box",
|
|
31598
|
+
maxWidth: "100%",
|
|
31599
|
+
textAlign: "left",
|
|
31600
|
+
overflow: "hidden",
|
|
31601
|
+
height: "100%",
|
|
31602
|
+
minHeight: "80px",
|
|
31603
|
+
display: "flex",
|
|
31604
|
+
width: "100%",
|
|
31605
|
+
flexDirection: "row",
|
|
31606
|
+
justifyContent: "center",
|
|
31607
|
+
alignItems: "center"
|
|
31608
|
+
},
|
|
31609
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31610
|
+
"span",
|
|
31611
|
+
{
|
|
31612
|
+
style: {
|
|
31613
|
+
fontFamily: theme?.fontFamily,
|
|
31614
|
+
fontSize: 13,
|
|
31615
|
+
color: theme?.secondaryTextColor,
|
|
31616
|
+
fontWeight: "normal"
|
|
31617
|
+
},
|
|
31618
|
+
children: "No results"
|
|
31619
|
+
}
|
|
31620
|
+
)
|
|
31621
|
+
}
|
|
31622
|
+
)
|
|
31578
31623
|
}
|
|
31579
31624
|
) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
31580
31625
|
MetricDisplay,
|
|
@@ -32802,6 +32847,29 @@ function USMap({
|
|
|
32802
32847
|
const hoveredValue = (0, import_react26.useMemo)(() => {
|
|
32803
32848
|
return !hoveredState ? void 0 : mappedData[fipsToNames[hoveredState]?.abbreviation ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.name ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.abbreviation?.toLowerCase() ?? ""]?.[measureField] ?? mappedData[fipsToNames[hoveredState]?.name?.toLowerCase() ?? ""]?.[measureField];
|
|
32804
32849
|
}, [hoveredState, mappedData, measureField]);
|
|
32850
|
+
if (!measureField) {
|
|
32851
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
32852
|
+
"div",
|
|
32853
|
+
{
|
|
32854
|
+
style: {
|
|
32855
|
+
display: "flex",
|
|
32856
|
+
flex: "1 0 auto",
|
|
32857
|
+
marginLeft: "auto",
|
|
32858
|
+
marginRight: "auto",
|
|
32859
|
+
marginTop: "auto",
|
|
32860
|
+
marginBottom: "auto",
|
|
32861
|
+
justifyContent: "center",
|
|
32862
|
+
alignItems: "center",
|
|
32863
|
+
fontSize: 13,
|
|
32864
|
+
color: theme?.secondaryTextColor,
|
|
32865
|
+
fontFamily: theme?.fontFamily,
|
|
32866
|
+
...containerStyle
|
|
32867
|
+
},
|
|
32868
|
+
className,
|
|
32869
|
+
children: "No results"
|
|
32870
|
+
}
|
|
32871
|
+
);
|
|
32872
|
+
}
|
|
32805
32873
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
32806
32874
|
"div",
|
|
32807
32875
|
{
|
|
@@ -32970,6 +33038,29 @@ function WorldMap({
|
|
|
32970
33038
|
const hoveredValue = (0, import_react26.useMemo)(() => {
|
|
32971
33039
|
return !hoveredCountry ? void 0 : mappedData[isoToNames[hoveredCountry]?.abbreviation ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.name ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.abbreviation?.toLowerCase() ?? ""]?.[measureField] ?? mappedData[isoToNames[hoveredCountry]?.name?.toLowerCase() ?? ""]?.[measureField];
|
|
32972
33040
|
}, [hoveredCountry, mappedData, measureField]);
|
|
33041
|
+
if (!measureField) {
|
|
33042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
|
|
33043
|
+
"div",
|
|
33044
|
+
{
|
|
33045
|
+
style: {
|
|
33046
|
+
display: "flex",
|
|
33047
|
+
flex: "1 0 auto",
|
|
33048
|
+
marginLeft: "auto",
|
|
33049
|
+
marginRight: "auto",
|
|
33050
|
+
marginTop: "auto",
|
|
33051
|
+
marginBottom: "auto",
|
|
33052
|
+
justifyContent: "center",
|
|
33053
|
+
alignItems: "center",
|
|
33054
|
+
fontSize: 13,
|
|
33055
|
+
color: theme?.secondaryTextColor,
|
|
33056
|
+
fontFamily: theme?.fontFamily,
|
|
33057
|
+
...containerStyle
|
|
33058
|
+
},
|
|
33059
|
+
className,
|
|
33060
|
+
children: "No results"
|
|
33061
|
+
}
|
|
33062
|
+
);
|
|
33063
|
+
}
|
|
32973
33064
|
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
32974
33065
|
"div",
|
|
32975
33066
|
{
|
|
@@ -35184,7 +35275,7 @@ function Chart({
|
|
|
35184
35275
|
index
|
|
35185
35276
|
)) }),
|
|
35186
35277
|
loading || !report ? /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(LoadingComponent, {}) : /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_jsx_runtime48.Fragment, { children: [
|
|
35187
|
-
("table" === report.chartType || "metric" === report.chartType) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
35278
|
+
("table" === report.chartType || "metric" === report.chartType) && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_jsx_runtime48.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
35188
35279
|
DataLoader,
|
|
35189
35280
|
{
|
|
35190
35281
|
item: report,
|
|
@@ -35219,13 +35310,17 @@ function Chart({
|
|
|
35219
35310
|
error: error2,
|
|
35220
35311
|
rowCount: rowCount ?? data?.rowCount ?? data?.rows?.length ?? 0,
|
|
35221
35312
|
rowCountIsLoading,
|
|
35222
|
-
onPageChange: (page) =>
|
|
35223
|
-
|
|
35313
|
+
onPageChange: (page) => {
|
|
35314
|
+
onPageChange(page);
|
|
35315
|
+
},
|
|
35316
|
+
onSortChange: (sort) => {
|
|
35317
|
+
onSortChange(sort);
|
|
35318
|
+
},
|
|
35224
35319
|
hideName: true
|
|
35225
35320
|
}
|
|
35226
35321
|
)
|
|
35227
35322
|
}
|
|
35228
|
-
),
|
|
35323
|
+
) }),
|
|
35229
35324
|
report.chartType !== "table" && report.chartType !== "metric" && /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
35230
35325
|
ChartDataLoader,
|
|
35231
35326
|
{
|
|
@@ -35355,7 +35450,7 @@ var ChartDisplay = ({
|
|
|
35355
35450
|
{
|
|
35356
35451
|
className,
|
|
35357
35452
|
containerStyle,
|
|
35358
|
-
data: config?.rows?.map((row) => {
|
|
35453
|
+
data: !config?.pivot ? config?.rows?.map((row) => {
|
|
35359
35454
|
return {
|
|
35360
35455
|
...row,
|
|
35361
35456
|
count: (
|
|
@@ -35363,7 +35458,7 @@ var ChartDisplay = ({
|
|
|
35363
35458
|
parseInt(row[config?.yAxisFields[0]?.field]) / sumByKey(config?.rows, config?.yAxisFields[0]?.field)
|
|
35364
35459
|
)
|
|
35365
35460
|
};
|
|
35366
|
-
}) || [],
|
|
35461
|
+
}) || [] : config?.rows || [],
|
|
35367
35462
|
category: config?.yAxisFields?.[0]?.field,
|
|
35368
35463
|
index: config?.xAxisField,
|
|
35369
35464
|
colors: chartColors,
|
|
@@ -35478,27 +35573,41 @@ var ChartDisplay = ({
|
|
|
35478
35573
|
);
|
|
35479
35574
|
}
|
|
35480
35575
|
if (config?.chartType?.toLowerCase() === "metric") {
|
|
35481
|
-
if (!config?.rows || config?.rows?.length === 0 ||
|
|
35482
|
-
config?.rows[0][config?.xAxisField] === null) {
|
|
35576
|
+
if (!config?.rows || config?.rows?.length === 0 || config?.rows[0]?.[config?.xAxisField] === null || config?.rows[0]?.[config?.xAxisField] === void 0) {
|
|
35483
35577
|
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
35484
35578
|
"div",
|
|
35485
35579
|
{
|
|
35486
35580
|
style: {
|
|
35487
|
-
display: "flex",
|
|
35488
|
-
flex: "1 0 auto",
|
|
35489
|
-
// height: containerStyle?.height || '100%',
|
|
35490
|
-
margin: "auto",
|
|
35491
|
-
justifyContent: "center",
|
|
35492
|
-
alignItems: "center",
|
|
35493
|
-
fontSize: 13,
|
|
35494
35581
|
fontFamily: theme?.fontFamily,
|
|
35495
|
-
|
|
35582
|
+
fontSize: 32,
|
|
35583
|
+
color: theme?.primaryTextColor,
|
|
35584
|
+
fontWeight: "600",
|
|
35585
|
+
textOverflow: "ellipsis",
|
|
35586
|
+
margin: 0,
|
|
35587
|
+
whiteSpace: "nowrap",
|
|
35588
|
+
boxSizing: "content-box",
|
|
35496
35589
|
maxWidth: "100%",
|
|
35590
|
+
textAlign: "left",
|
|
35591
|
+
overflow: "hidden",
|
|
35592
|
+
height: containerStyle?.height || "100%",
|
|
35593
|
+
display: "flex",
|
|
35497
35594
|
width: "100%",
|
|
35595
|
+
flexDirection: "row",
|
|
35596
|
+
alignItems: "center",
|
|
35498
35597
|
...containerStyle
|
|
35499
35598
|
},
|
|
35500
35599
|
className,
|
|
35501
|
-
children:
|
|
35600
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
35601
|
+
"span",
|
|
35602
|
+
{
|
|
35603
|
+
style: {
|
|
35604
|
+
fontFamily: theme?.fontFamily,
|
|
35605
|
+
fontSize: 13,
|
|
35606
|
+
color: theme?.secondaryTextColor
|
|
35607
|
+
},
|
|
35608
|
+
children: "No results"
|
|
35609
|
+
}
|
|
35610
|
+
)
|
|
35502
35611
|
}
|
|
35503
35612
|
);
|
|
35504
35613
|
}
|
|
@@ -38366,7 +38475,7 @@ function Dashboard({
|
|
|
38366
38475
|
data: data2,
|
|
38367
38476
|
rowCount,
|
|
38368
38477
|
rowCountIsLoading
|
|
38369
|
-
}) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
38478
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(import_jsx_runtime57.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
38370
38479
|
TableComponent,
|
|
38371
38480
|
{
|
|
38372
38481
|
report: data2,
|
|
@@ -38391,10 +38500,14 @@ function Dashboard({
|
|
|
38391
38500
|
hoverActions,
|
|
38392
38501
|
rowCount: rowCount ?? data2?.rowCount ?? data2?.rows?.length ?? 0,
|
|
38393
38502
|
rowCountIsLoading,
|
|
38394
|
-
onPageChange: (page) =>
|
|
38395
|
-
|
|
38503
|
+
onPageChange: (page) => {
|
|
38504
|
+
onPageChange(page);
|
|
38505
|
+
},
|
|
38506
|
+
onSortChange: (sort) => {
|
|
38507
|
+
onSortChange(sort);
|
|
38508
|
+
}
|
|
38396
38509
|
}
|
|
38397
|
-
)
|
|
38510
|
+
) })
|
|
38398
38511
|
},
|
|
38399
38512
|
`${name2}${item.id}`
|
|
38400
38513
|
)) })
|
|
@@ -38414,7 +38527,11 @@ function Dashboard({
|
|
|
38414
38527
|
children: ({
|
|
38415
38528
|
isLoading: isLoading2,
|
|
38416
38529
|
error,
|
|
38417
|
-
|
|
38530
|
+
onPageChange,
|
|
38531
|
+
onSortChange,
|
|
38532
|
+
data: data2,
|
|
38533
|
+
rowCount,
|
|
38534
|
+
rowCountIsLoading
|
|
38418
38535
|
}) => item.chartType === "metric" ? /* @__PURE__ */ (0, import_jsx_runtime57.jsx)(
|
|
38419
38536
|
MetricComponent,
|
|
38420
38537
|
{
|
|
@@ -38461,7 +38578,14 @@ function Dashboard({
|
|
|
38461
38578
|
});
|
|
38462
38579
|
} : void 0,
|
|
38463
38580
|
hoverActions,
|
|
38464
|
-
rowCount: data2.rowCount ?? data2.rows?.length ?? 0
|
|
38581
|
+
rowCount: rowCount ?? data2.rowCount ?? data2.rows?.length ?? 0,
|
|
38582
|
+
rowCountIsLoading,
|
|
38583
|
+
onPageChange: (page) => {
|
|
38584
|
+
onPageChange(page);
|
|
38585
|
+
},
|
|
38586
|
+
onSortChange: (sort) => {
|
|
38587
|
+
onSortChange(sort);
|
|
38588
|
+
}
|
|
38465
38589
|
}
|
|
38466
38590
|
)
|
|
38467
38591
|
},
|
|
@@ -39411,11 +39535,6 @@ var PivotModal = ({
|
|
|
39411
39535
|
dashboardName,
|
|
39412
39536
|
reportBuilderState
|
|
39413
39537
|
);
|
|
39414
|
-
console.log("[PivotModal] Calling report-builder-unique-values", {
|
|
39415
|
-
columnCount: smallStringColumns.length,
|
|
39416
|
-
hasReportBuilderState: !!reportBuilderState,
|
|
39417
|
-
reportBuilderState
|
|
39418
|
-
});
|
|
39419
39538
|
newUniqueValues = await getUniqueValuesByQuery({
|
|
39420
39539
|
columns: smallStringColumns,
|
|
39421
39540
|
query: query || "",
|
|
@@ -41646,6 +41765,7 @@ function InternalChart({
|
|
|
41646
41765
|
// src/ChartBuilder.tsx
|
|
41647
41766
|
init_paginationProcessing();
|
|
41648
41767
|
init_tableProcessing();
|
|
41768
|
+
init_dataFetcher();
|
|
41649
41769
|
init_dates();
|
|
41650
41770
|
|
|
41651
41771
|
// src/components/QuillMultiSelectSectionList.tsx
|
|
@@ -42486,15 +42606,19 @@ function ChartBuilderWithModal(props) {
|
|
|
42486
42606
|
title: title || "Add to dashboard",
|
|
42487
42607
|
width: isHorizontalView ? modalWidth : void 0,
|
|
42488
42608
|
height: isHorizontalView ? modalHeight : void 0,
|
|
42489
|
-
children: (
|
|
42490
|
-
|
|
42491
|
-
|
|
42492
|
-
|
|
42493
|
-
|
|
42494
|
-
|
|
42495
|
-
|
|
42496
|
-
|
|
42497
|
-
|
|
42609
|
+
children: (() => {
|
|
42610
|
+
const resolvedReport = props.tempReport ?? (props.reportId ? dashboard[props.reportId] : void 0);
|
|
42611
|
+
return resolvedReport ? /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
42612
|
+
ChartBuilder,
|
|
42613
|
+
{
|
|
42614
|
+
...props,
|
|
42615
|
+
tempReport: resolvedReport,
|
|
42616
|
+
filtersEnabled: filtersEnabledState,
|
|
42617
|
+
onFiltersEnabledChanged: setFiltersEnabledState,
|
|
42618
|
+
runQueryOnMount: filtersEnabledState
|
|
42619
|
+
}
|
|
42620
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime65.jsx)("div", { style: { padding: 20 }, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(QuillLoadingComponent, {}) });
|
|
42621
|
+
})()
|
|
42498
42622
|
}
|
|
42499
42623
|
) });
|
|
42500
42624
|
}
|
|
@@ -42574,8 +42698,9 @@ function ChartBuilder({
|
|
|
42574
42698
|
const { dashboardConfig } = (0, import_react43.useContext)(DashboardConfigContext);
|
|
42575
42699
|
const { tenants, flags } = (0, import_react43.useContext)(TenantContext);
|
|
42576
42700
|
const report = (0, import_react43.useMemo)(() => {
|
|
42577
|
-
|
|
42578
|
-
|
|
42701
|
+
const resolvedReport = reportId && !tempReport ? allReportsById[reportId] : tempReport;
|
|
42702
|
+
return resolvedReport;
|
|
42703
|
+
}, [reportId, tempReport, allReportsById]);
|
|
42579
42704
|
const [windowWidth, setWindowWidth] = (0, import_react43.useState)(1200);
|
|
42580
42705
|
const [rows, setRows] = (0, import_react43.useState)(report?.rows ?? []);
|
|
42581
42706
|
const [itemQuery, setItemQuery] = (0, import_react43.useState)(report?.itemQuery);
|
|
@@ -42584,8 +42709,9 @@ function ChartBuilder({
|
|
|
42584
42709
|
const [isLoading, setIsLoading] = (0, import_react43.useState)(false);
|
|
42585
42710
|
const [rowCountIsLoading, setRowCountIsLoading] = (0, import_react43.useState)(false);
|
|
42586
42711
|
const [isSubmitting, setIsSubmitting] = (0, import_react43.useState)(false);
|
|
42587
|
-
const
|
|
42588
|
-
const [
|
|
42712
|
+
const MIN_FORM_WIDTH = 710;
|
|
42713
|
+
const [pivotCardWidth, setPivotCardWidth] = (0, import_react43.useState)(MIN_FORM_WIDTH);
|
|
42714
|
+
const [formWidth, setFormWidth] = (0, import_react43.useState)(MIN_FORM_WIDTH);
|
|
42589
42715
|
const inputRef = (0, import_react43.useRef)(null);
|
|
42590
42716
|
const selectRef = (0, import_react43.useRef)(null);
|
|
42591
42717
|
const processColumns = (columns2) => {
|
|
@@ -42655,10 +42781,10 @@ function ChartBuilder({
|
|
|
42655
42781
|
const spaceBetween = selectSize.left - inputSize.right;
|
|
42656
42782
|
const gap = showDash ? (spaceBetween - selectWidth) / 2 : spaceBetween;
|
|
42657
42783
|
const width = inputSize.width + 2 * gap + 2 * selectWidth;
|
|
42658
|
-
setPivotCardWidth(width);
|
|
42784
|
+
setPivotCardWidth(Math.max(width, MIN_FORM_WIDTH));
|
|
42659
42785
|
const deleteSize = deleteRef.current?.getBoundingClientRect();
|
|
42660
42786
|
const deleteWidth = deleteSize?.width ?? 0;
|
|
42661
|
-
setFormWidth(width + deleteWidth);
|
|
42787
|
+
setFormWidth(Math.max(width + deleteWidth, MIN_FORM_WIDTH));
|
|
42662
42788
|
}
|
|
42663
42789
|
};
|
|
42664
42790
|
handleResize();
|
|
@@ -42773,7 +42899,7 @@ function ChartBuilder({
|
|
|
42773
42899
|
};
|
|
42774
42900
|
const [currentProcessing, setCurrentProcessing] = (0, import_react43.useState)(baseProcessing);
|
|
42775
42901
|
const [customTenantAccess, setCustomTenantAccess] = (0, import_react43.useState)(
|
|
42776
|
-
!!Object.values(report?.flags ?? {}).length
|
|
42902
|
+
report?.flags === null ? false : !!Object.values(report?.flags ?? {}).length
|
|
42777
42903
|
);
|
|
42778
42904
|
const [dateFieldOptions, setDateFieldOptions] = (0, import_react43.useState)([]);
|
|
42779
42905
|
const [allTables, setAllTables] = (0, import_react43.useState)([]);
|
|
@@ -42923,23 +43049,40 @@ function ChartBuilder({
|
|
|
42923
43049
|
return result;
|
|
42924
43050
|
};
|
|
42925
43051
|
const getReferencedTables = async (client2, dbTables, sqlQuery, reportBuilderState2, skipStar) => {
|
|
42926
|
-
const
|
|
42927
|
-
|
|
42928
|
-
|
|
42929
|
-
|
|
42930
|
-
|
|
42931
|
-
|
|
42932
|
-
|
|
42933
|
-
|
|
42934
|
-
|
|
42935
|
-
|
|
42936
|
-
|
|
43052
|
+
const metadata = reportBuilderState2 ? {
|
|
43053
|
+
reportBuilderState: reportBuilderState2,
|
|
43054
|
+
clientId: client2.clientId,
|
|
43055
|
+
useNewNodeSql: true
|
|
43056
|
+
} : {
|
|
43057
|
+
query: sqlQuery,
|
|
43058
|
+
clientId: client2.clientId,
|
|
43059
|
+
useNewNodeSql: true
|
|
43060
|
+
};
|
|
43061
|
+
try {
|
|
43062
|
+
const { data: resp } = await quillFetchWithToken({
|
|
43063
|
+
client: client2,
|
|
43064
|
+
task: "astify",
|
|
43065
|
+
metadata
|
|
43066
|
+
});
|
|
43067
|
+
if (resp.success === false) {
|
|
43068
|
+
return getTablesHelper(getSelectFromAST({}), dbTables, skipStar);
|
|
42937
43069
|
}
|
|
42938
|
-
|
|
42939
|
-
|
|
42940
|
-
|
|
43070
|
+
return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
|
|
43071
|
+
} catch (error) {
|
|
43072
|
+
console.error(
|
|
43073
|
+
"[ChartBuilder#getReferencedTables] Failed to fetch referenced tables",
|
|
43074
|
+
{
|
|
43075
|
+
error,
|
|
43076
|
+
hasReportBuilderState: !!reportBuilderState2,
|
|
43077
|
+
hasSqlQuery: !!sqlQuery,
|
|
43078
|
+
skipStar: !!skipStar
|
|
43079
|
+
}
|
|
43080
|
+
);
|
|
43081
|
+
return {
|
|
43082
|
+
referencedTablesAndColumns: [],
|
|
43083
|
+
dateFields: []
|
|
43084
|
+
};
|
|
42941
43085
|
}
|
|
42942
|
-
return getTablesHelper(getSelectFromAST(resp.ast), dbTables, skipStar);
|
|
42943
43086
|
};
|
|
42944
43087
|
const getCurrentSection = () => {
|
|
42945
43088
|
let id2 = report?.id ?? "";
|
|
@@ -43486,16 +43629,6 @@ function ChartBuilder({
|
|
|
43486
43629
|
fetchRowCount(processing, overrideFilters);
|
|
43487
43630
|
if (formData.pivot) {
|
|
43488
43631
|
try {
|
|
43489
|
-
console.log(
|
|
43490
|
-
"[ChartBuilder] Calling report-builder-unique-values for pivot",
|
|
43491
|
-
{
|
|
43492
|
-
columns: tableInfo.columns.filter(
|
|
43493
|
-
(column) => column.field === formData.pivot?.columnField
|
|
43494
|
-
).map((c) => c.field),
|
|
43495
|
-
hasReportBuilderState: !!reportBuilderState,
|
|
43496
|
-
reportBuilderState
|
|
43497
|
-
}
|
|
43498
|
-
);
|
|
43499
43632
|
const uniqueValues = await getUniqueValuesByQuery({
|
|
43500
43633
|
reportBuilderState,
|
|
43501
43634
|
columns: tableInfo.columns.filter(
|
|
@@ -43883,9 +44016,46 @@ function ChartBuilder({
|
|
|
43883
44016
|
event.preventDefault();
|
|
43884
44017
|
};
|
|
43885
44018
|
const deleteChart = async () => {
|
|
43886
|
-
if (
|
|
43887
|
-
|
|
43888
|
-
|
|
44019
|
+
if (!client || !reportId) {
|
|
44020
|
+
console.error("Cannot delete: missing client or reportId");
|
|
44021
|
+
return;
|
|
44022
|
+
}
|
|
44023
|
+
try {
|
|
44024
|
+
const { status, error } = await quillFetch({
|
|
44025
|
+
client,
|
|
44026
|
+
task: "delete",
|
|
44027
|
+
metadata: {
|
|
44028
|
+
dashboardItemId: reportId,
|
|
44029
|
+
tenants
|
|
44030
|
+
},
|
|
44031
|
+
getToken
|
|
44032
|
+
});
|
|
44033
|
+
if (status !== "success") {
|
|
44034
|
+
throw new Error(`Error deleting report: ${error}`);
|
|
44035
|
+
} else {
|
|
44036
|
+
if (onDelete) {
|
|
44037
|
+
onDelete();
|
|
44038
|
+
}
|
|
44039
|
+
reloadDashboard(destinationDashboard, true, {
|
|
44040
|
+
report: { id: reportId },
|
|
44041
|
+
action: "delete"
|
|
44042
|
+
});
|
|
44043
|
+
setIsOpen(false);
|
|
44044
|
+
setIsSubmitting(false);
|
|
44045
|
+
}
|
|
44046
|
+
} catch (err) {
|
|
44047
|
+
console.error("Error deleting chart:", err);
|
|
44048
|
+
eventTracking?.logError?.({
|
|
44049
|
+
type: "bug",
|
|
44050
|
+
severity: "high",
|
|
44051
|
+
message: "Error deleting chart",
|
|
44052
|
+
errorMessage: err.message,
|
|
44053
|
+
errorStack: err.stack,
|
|
44054
|
+
errorData: {
|
|
44055
|
+
caller: "ChartBuilder",
|
|
44056
|
+
function: "deleteChart"
|
|
44057
|
+
}
|
|
44058
|
+
});
|
|
43889
44059
|
}
|
|
43890
44060
|
};
|
|
43891
44061
|
const editChart = async () => {
|
|
@@ -43902,7 +44072,7 @@ function ChartBuilder({
|
|
|
43902
44072
|
return;
|
|
43903
44073
|
}
|
|
43904
44074
|
let dashboardItemId = reportId ? reportId : void 0;
|
|
43905
|
-
if (report && !isAdmin && formData.template) {
|
|
44075
|
+
if (report && !isAdmin && formData.template && !isEditingMode) {
|
|
43906
44076
|
dashboardItemId = void 0;
|
|
43907
44077
|
}
|
|
43908
44078
|
const newReport = {
|
|
@@ -43924,14 +44094,17 @@ function ChartBuilder({
|
|
|
43924
44094
|
includeCustomFields: includeCustomFields || containsCustomFields,
|
|
43925
44095
|
template: tenants ? void 0 : report && !isAdmin && formData.template ? false : formData.template,
|
|
43926
44096
|
adminMode: isAdmin,
|
|
43927
|
-
|
|
43928
|
-
|
|
43929
|
-
|
|
43930
|
-
|
|
43931
|
-
|
|
43932
|
-
|
|
43933
|
-
|
|
43934
|
-
|
|
44097
|
+
reportBuilderState,
|
|
44098
|
+
...isAdmin && {
|
|
44099
|
+
reportFlags: !customTenantAccess && !containsCustomFields ? null : containsCustomFields && customTenantAccess ? currentTenantAsFormFlags : formFlags ? Object.fromEntries(
|
|
44100
|
+
Object.entries(formFlags).filter(([, value]) => value.length > 0).map(([key, value]) => {
|
|
44101
|
+
return [
|
|
44102
|
+
key,
|
|
44103
|
+
Object.keys(allTenantMap).length > 1 && allTenantMap[key]?.length === value.length ? ALL_TENANTS : value
|
|
44104
|
+
];
|
|
44105
|
+
})
|
|
44106
|
+
) : void 0
|
|
44107
|
+
},
|
|
43935
44108
|
referenceLines: formData.referenceLines.map((line) => {
|
|
43936
44109
|
return {
|
|
43937
44110
|
label: line.label,
|
|
@@ -45300,7 +45473,7 @@ function ChartBuilder({
|
|
|
45300
45473
|
right: 16
|
|
45301
45474
|
},
|
|
45302
45475
|
children: [
|
|
45303
|
-
!hideDeleteButton &&
|
|
45476
|
+
!hideDeleteButton && report && /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
|
|
45304
45477
|
SecondaryButtonComponent,
|
|
45305
45478
|
{
|
|
45306
45479
|
onClick: deleteChart,
|
|
@@ -46056,6 +46229,7 @@ function SQLEditor({
|
|
|
46056
46229
|
CheckboxComponent = QuillChartBuilderCheckboxComponent,
|
|
46057
46230
|
defaultQuery,
|
|
46058
46231
|
destinationDashboard,
|
|
46232
|
+
destinationSection,
|
|
46059
46233
|
onChangeQuery,
|
|
46060
46234
|
onChangeData,
|
|
46061
46235
|
onChangeColumns,
|
|
@@ -46065,12 +46239,16 @@ function SQLEditor({
|
|
|
46065
46239
|
onCloseChartBuilder,
|
|
46066
46240
|
isChartBuilderEnabled = false,
|
|
46067
46241
|
isAdminEnabled = false,
|
|
46242
|
+
chartBuilderOptions,
|
|
46068
46243
|
chartBuilderTitle,
|
|
46069
46244
|
runQueryOnMount = false,
|
|
46070
46245
|
onAddToDashboardComplete,
|
|
46246
|
+
onSubmitCreateReport,
|
|
46247
|
+
onSubmitEditReport,
|
|
46071
46248
|
onSaveQueryComplete,
|
|
46072
46249
|
addToDashboardButtonLabel = "Add to dashboard",
|
|
46073
46250
|
report = void 0,
|
|
46251
|
+
reportId = void 0,
|
|
46074
46252
|
organizationName = void 0,
|
|
46075
46253
|
isChartBuilderHorizontalView = true,
|
|
46076
46254
|
containerStyle = { height: "100vh" },
|
|
@@ -46078,10 +46256,11 @@ function SQLEditor({
|
|
|
46078
46256
|
onClickChartElement,
|
|
46079
46257
|
onRequestAddVirtualTable
|
|
46080
46258
|
}) {
|
|
46259
|
+
const computedButtonLabel = addToDashboardButtonLabel === "Add to dashboard" ? reportId || report?.id ? "Save changes" : "Add to dashboard" : addToDashboardButtonLabel;
|
|
46081
46260
|
const [sqlPrompt, setSqlPrompt] = (0, import_react45.useState)("");
|
|
46082
46261
|
const [client] = (0, import_react45.useContext)(ClientContext);
|
|
46083
46262
|
const [theme] = (0, import_react45.useContext)(ThemeContext);
|
|
46084
|
-
const { tenants } = (0, import_react45.useContext)(TenantContext);
|
|
46263
|
+
const { tenants, flags } = (0, import_react45.useContext)(TenantContext);
|
|
46085
46264
|
const { dashboards } = useDashboards();
|
|
46086
46265
|
const {
|
|
46087
46266
|
data,
|
|
@@ -46090,6 +46269,7 @@ function SQLEditor({
|
|
|
46090
46269
|
} = useDashboardInternal(destinationDashboard);
|
|
46091
46270
|
const { getToken, quillFetchWithToken } = (0, import_react45.useContext)(FetchContext);
|
|
46092
46271
|
const { eventTracking } = (0, import_react45.useContext)(EventTrackingContext);
|
|
46272
|
+
const { allReportsById } = useAllReports();
|
|
46093
46273
|
const destinationDashboardConfig = (0, import_react45.useMemo)(() => {
|
|
46094
46274
|
return dashboards?.find((d) => d.name === destinationDashboard);
|
|
46095
46275
|
}, [dashboards, destinationDashboard]);
|
|
@@ -46157,6 +46337,46 @@ function SQLEditor({
|
|
|
46157
46337
|
reload();
|
|
46158
46338
|
}
|
|
46159
46339
|
}, [data, dashboardIsLoading]);
|
|
46340
|
+
(0, import_react45.useEffect)(() => {
|
|
46341
|
+
const loadReport = async () => {
|
|
46342
|
+
let reportToLoad;
|
|
46343
|
+
if (!client) {
|
|
46344
|
+
return;
|
|
46345
|
+
}
|
|
46346
|
+
try {
|
|
46347
|
+
if (!reportId) {
|
|
46348
|
+
throw new Error("Report ID is required");
|
|
46349
|
+
}
|
|
46350
|
+
reportToLoad = allReportsById[reportId];
|
|
46351
|
+
if (!reportToLoad) {
|
|
46352
|
+
throw new Error("Report not found");
|
|
46353
|
+
}
|
|
46354
|
+
setQuery(reportToLoad.queryString || "");
|
|
46355
|
+
setTempReport(reportToLoad);
|
|
46356
|
+
if (reportToLoad.rows && reportToLoad.rows.length > 0) {
|
|
46357
|
+
setRows(reportToLoad.rows);
|
|
46358
|
+
setDisplayTable(true);
|
|
46359
|
+
}
|
|
46360
|
+
} catch (err) {
|
|
46361
|
+
console.error(err);
|
|
46362
|
+
eventTracking?.logError?.({
|
|
46363
|
+
type: "bug",
|
|
46364
|
+
severity: "high",
|
|
46365
|
+
message: "Error loading report",
|
|
46366
|
+
errorMessage: err.message,
|
|
46367
|
+
errorStack: err.stack,
|
|
46368
|
+
errorData: {
|
|
46369
|
+
caller: "SQLEditor",
|
|
46370
|
+
function: "loadReport"
|
|
46371
|
+
}
|
|
46372
|
+
});
|
|
46373
|
+
setErrorMessage("Error when loading report");
|
|
46374
|
+
}
|
|
46375
|
+
};
|
|
46376
|
+
if (reportId && client) {
|
|
46377
|
+
loadReport();
|
|
46378
|
+
}
|
|
46379
|
+
}, [allReportsById[reportId || ""], client]);
|
|
46160
46380
|
const dynamicHeight = tableRef.current ? tableRef.current.clientHeight : cachedHeight;
|
|
46161
46381
|
const rowsPerPage = Math.max(
|
|
46162
46382
|
DEFAULT_ROWS_PER_PAGE,
|
|
@@ -46360,25 +46580,35 @@ function SQLEditor({
|
|
|
46360
46580
|
onChangeFields(tableInfo.columns);
|
|
46361
46581
|
}
|
|
46362
46582
|
const formData = report ? report : createInitialFormData(tableInfo.columns);
|
|
46363
|
-
const
|
|
46583
|
+
const baseReport = reportId ? tempReport : {
|
|
46364
46584
|
...tempReport,
|
|
46365
|
-
...formData
|
|
46585
|
+
...formData
|
|
46586
|
+
};
|
|
46587
|
+
const newReport = {
|
|
46588
|
+
...baseReport,
|
|
46589
|
+
// In edit mode, preserve critical fields that shouldn't be overwritten
|
|
46590
|
+
...reportId && tempReport.name ? { name: tempReport.name } : {},
|
|
46366
46591
|
itemQuery: tableInfo.itemQuery,
|
|
46367
46592
|
rowCount: tableInfo.rowCount ?? tableInfo.rows.length,
|
|
46368
46593
|
rows: tempRows,
|
|
46369
46594
|
columns: tableInfo.columns,
|
|
46370
|
-
referencedTables: tableInfo.referencedTables
|
|
46595
|
+
referencedTables: tableInfo.referencedTables,
|
|
46596
|
+
queryString: query ?? tempReport.queryString ?? ""
|
|
46371
46597
|
};
|
|
46372
|
-
|
|
46373
|
-
|
|
46374
|
-
|
|
46375
|
-
|
|
46376
|
-
|
|
46377
|
-
|
|
46378
|
-
|
|
46379
|
-
|
|
46380
|
-
|
|
46381
|
-
|
|
46598
|
+
if (reportId) {
|
|
46599
|
+
setTempReport(newReport);
|
|
46600
|
+
} else {
|
|
46601
|
+
const cleaned = await cleanDashboardItem({
|
|
46602
|
+
item: newReport,
|
|
46603
|
+
dashboardFilters: newReport.filtersApplied,
|
|
46604
|
+
client,
|
|
46605
|
+
customFields: schemaData.customFields,
|
|
46606
|
+
getToken,
|
|
46607
|
+
tenants,
|
|
46608
|
+
eventTracking
|
|
46609
|
+
});
|
|
46610
|
+
setTempReport(cleaned);
|
|
46611
|
+
}
|
|
46382
46612
|
setLastSuccessfulQuery(query);
|
|
46383
46613
|
} catch (e) {
|
|
46384
46614
|
eventTracking?.logError?.({
|
|
@@ -46685,7 +46915,7 @@ function SQLEditor({
|
|
|
46685
46915
|
height: 70
|
|
46686
46916
|
},
|
|
46687
46917
|
children: /* @__PURE__ */ (0, import_jsx_runtime66.jsxs)("div", { style: { display: "flex", gap: 12 }, children: [
|
|
46688
|
-
|
|
46918
|
+
computedButtonLabel === "Add to dashboard" ? /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
46689
46919
|
SecondaryButtonComponent,
|
|
46690
46920
|
{
|
|
46691
46921
|
onClick: () => {
|
|
@@ -46775,7 +47005,7 @@ function SQLEditor({
|
|
|
46775
47005
|
label: "Clear query"
|
|
46776
47006
|
}
|
|
46777
47007
|
),
|
|
46778
|
-
|
|
47008
|
+
computedButtonLabel === "Add to dashboard" && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
46779
47009
|
ButtonComponent,
|
|
46780
47010
|
{
|
|
46781
47011
|
onClick: async () => {
|
|
@@ -46799,9 +47029,9 @@ function SQLEditor({
|
|
|
46799
47029
|
return (schemaData.customFields?.[table] ?? []).map((field) => field.field);
|
|
46800
47030
|
}).flat();
|
|
46801
47031
|
}
|
|
46802
|
-
|
|
47032
|
+
const newTempReport = {
|
|
46803
47033
|
...tempReport,
|
|
46804
|
-
id: TEMP_REPORT_ID,
|
|
47034
|
+
id: reportId || report?.id || TEMP_REPORT_ID,
|
|
46805
47035
|
rows,
|
|
46806
47036
|
columns: isSelectStar ? (
|
|
46807
47037
|
// so Automatic Custom Fields can be applied
|
|
@@ -46818,10 +47048,11 @@ function SQLEditor({
|
|
|
46818
47048
|
rowCount: rowCount ?? 0,
|
|
46819
47049
|
queryString: query ?? "",
|
|
46820
47050
|
dashboardName: report?.dashboardName ?? destinationDashboard
|
|
46821
|
-
}
|
|
47051
|
+
};
|
|
47052
|
+
setTempReport(newTempReport);
|
|
46822
47053
|
setIsChartBuilderOpen(true);
|
|
46823
47054
|
},
|
|
46824
|
-
label:
|
|
47055
|
+
label: computedButtonLabel,
|
|
46825
47056
|
disabled: !!errorMessage || !(lastSuccessfulQuery === query) || !query,
|
|
46826
47057
|
tooltipText: !!errorMessage || !(lastSuccessfulQuery === query) ? "Please run a query" : ""
|
|
46827
47058
|
}
|
|
@@ -46934,25 +47165,14 @@ function SQLEditor({
|
|
|
46934
47165
|
label: "Discard changes"
|
|
46935
47166
|
}
|
|
46936
47167
|
),
|
|
46937
|
-
|
|
47168
|
+
computedButtonLabel !== "Add to dashboard" && /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
|
|
46938
47169
|
ButtonComponent,
|
|
46939
47170
|
{
|
|
46940
47171
|
onClick: async () => {
|
|
46941
47172
|
onSaveChanges && onSaveChanges();
|
|
46942
|
-
setTempReport({
|
|
46943
|
-
...tempReport,
|
|
46944
|
-
id: TEMP_REPORT_ID,
|
|
46945
|
-
rows,
|
|
46946
|
-
columns,
|
|
46947
|
-
columnInternal: columns,
|
|
46948
|
-
rowCount: rowCount ?? 0,
|
|
46949
|
-
queryString: query ?? "",
|
|
46950
|
-
dashboardName: report?.dashboardName ?? destinationDashboard
|
|
46951
|
-
// flags: flagsToAdd,
|
|
46952
|
-
});
|
|
46953
47173
|
setIsChartBuilderOpen(true);
|
|
46954
47174
|
},
|
|
46955
|
-
label:
|
|
47175
|
+
label: computedButtonLabel,
|
|
46956
47176
|
disabled: !!errorMessage || !(lastSuccessfulQuery === query)
|
|
46957
47177
|
}
|
|
46958
47178
|
)
|
|
@@ -46975,13 +47195,38 @@ function SQLEditor({
|
|
|
46975
47195
|
isHorizontalView: isChartBuilderHorizontalView,
|
|
46976
47196
|
isOpen: isChartBuilderOpen,
|
|
46977
47197
|
setIsOpen: setIsChartBuilderOpen,
|
|
46978
|
-
onAddToDashboardComplete
|
|
47198
|
+
onAddToDashboardComplete: reportId || report?.id ? (data2) => {
|
|
47199
|
+
if (onSubmitEditReport) {
|
|
47200
|
+
onSubmitEditReport(data2);
|
|
47201
|
+
} else if (onAddToDashboardComplete) {
|
|
47202
|
+
onAddToDashboardComplete(data2);
|
|
47203
|
+
}
|
|
47204
|
+
if (!isAdminEnabled && destinationDashboard) {
|
|
47205
|
+
reload(destinationDashboard, false, {
|
|
47206
|
+
report: data2,
|
|
47207
|
+
action: "upsert"
|
|
47208
|
+
});
|
|
47209
|
+
}
|
|
47210
|
+
} : (data2) => {
|
|
47211
|
+
if (onSubmitCreateReport) {
|
|
47212
|
+
onSubmitCreateReport(data2);
|
|
47213
|
+
} else if (onAddToDashboardComplete) {
|
|
47214
|
+
onAddToDashboardComplete(data2);
|
|
47215
|
+
}
|
|
47216
|
+
if (!isAdminEnabled && destinationDashboard) {
|
|
47217
|
+
reload(destinationDashboard, false, {
|
|
47218
|
+
report: data2,
|
|
47219
|
+
action: "upsert"
|
|
47220
|
+
});
|
|
47221
|
+
}
|
|
47222
|
+
},
|
|
46979
47223
|
destinationDashboard,
|
|
47224
|
+
destinationSection,
|
|
46980
47225
|
isAdmin: isAdminEnabled,
|
|
46981
47226
|
title: chartBuilderTitle,
|
|
46982
|
-
buttonLabel:
|
|
47227
|
+
buttonLabel: computedButtonLabel,
|
|
46983
47228
|
tempReport,
|
|
46984
|
-
reportId: report?.id,
|
|
47229
|
+
reportId: reportId || report?.id,
|
|
46985
47230
|
organizationName,
|
|
46986
47231
|
CardComponent,
|
|
46987
47232
|
TableComponent,
|
|
@@ -47006,6 +47251,8 @@ function SQLEditor({
|
|
|
47006
47251
|
CheckboxComponent,
|
|
47007
47252
|
hideDateRangeFilter: true,
|
|
47008
47253
|
hideDeleteButton: true,
|
|
47254
|
+
showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions,
|
|
47255
|
+
showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields,
|
|
47009
47256
|
onClickChartElement,
|
|
47010
47257
|
isEditingMode: true
|
|
47011
47258
|
}
|
|
@@ -47025,7 +47272,7 @@ function SQLEditor({
|
|
|
47025
47272
|
isAdmin: false,
|
|
47026
47273
|
title: "Save query",
|
|
47027
47274
|
buttonLabel: "Save query",
|
|
47028
|
-
tempReport,
|
|
47275
|
+
tempReport: { ...tempReport, dashboardName: SAVED_QUERIES_DASHBOARD },
|
|
47029
47276
|
reportId: report?.id,
|
|
47030
47277
|
organizationName,
|
|
47031
47278
|
CardComponent,
|
|
@@ -51328,7 +51575,10 @@ var SaveReport = ({
|
|
|
51328
51575
|
chartBuilderTitle,
|
|
51329
51576
|
onSubmitEditReport = () => void 0,
|
|
51330
51577
|
onSubmitCreateReport = () => void 0,
|
|
51578
|
+
onDiscardChanges = () => void 0,
|
|
51331
51579
|
destinationSection,
|
|
51580
|
+
showTableFormatOptions,
|
|
51581
|
+
showDashboardFilterFields,
|
|
51332
51582
|
SelectComponent = QuillSelectComponent,
|
|
51333
51583
|
TextInputComponent = QuillTextInput,
|
|
51334
51584
|
ButtonComponent = MemoizedButton,
|
|
@@ -51361,6 +51611,9 @@ var SaveReport = ({
|
|
|
51361
51611
|
),
|
|
51362
51612
|
submitButtonLabel
|
|
51363
51613
|
}) => {
|
|
51614
|
+
const { reload } = useDashboardInternal(
|
|
51615
|
+
reportBuilder.destinationDashboard ?? null
|
|
51616
|
+
);
|
|
51364
51617
|
return /* @__PURE__ */ (0, import_jsx_runtime79.jsxs)("div", { children: [
|
|
51365
51618
|
SaveTrigger,
|
|
51366
51619
|
/* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
|
|
@@ -51374,7 +51627,24 @@ var SaveReport = ({
|
|
|
51374
51627
|
isHorizontalView: true,
|
|
51375
51628
|
isOpen,
|
|
51376
51629
|
setIsOpen,
|
|
51377
|
-
onAddToDashboardComplete: reportBuilder.reportId ?
|
|
51630
|
+
onAddToDashboardComplete: reportBuilder.reportId ? (data) => {
|
|
51631
|
+
onSubmitEditReport(data);
|
|
51632
|
+
if (!isAdminEnabled && reportBuilder.destinationDashboard) {
|
|
51633
|
+
reload(reportBuilder.destinationDashboard, false, {
|
|
51634
|
+
report: data,
|
|
51635
|
+
action: "upsert"
|
|
51636
|
+
});
|
|
51637
|
+
}
|
|
51638
|
+
} : (data) => {
|
|
51639
|
+
onSubmitCreateReport(data);
|
|
51640
|
+
if (!isAdminEnabled && reportBuilder.destinationDashboard) {
|
|
51641
|
+
reload(reportBuilder.destinationDashboard, false, {
|
|
51642
|
+
report: data,
|
|
51643
|
+
action: "upsert"
|
|
51644
|
+
});
|
|
51645
|
+
}
|
|
51646
|
+
},
|
|
51647
|
+
onDiscardChanges,
|
|
51378
51648
|
destinationDashboard: reportBuilder.destinationDashboard,
|
|
51379
51649
|
destinationSection,
|
|
51380
51650
|
initialUniqueValues: reportBuilder.columnUniqueValues,
|
|
@@ -51403,6 +51673,8 @@ var SaveReport = ({
|
|
|
51403
51673
|
FormContainer: ChartBuilderFormContainer,
|
|
51404
51674
|
hideDateRangeFilter: true,
|
|
51405
51675
|
hideDeleteButton: true,
|
|
51676
|
+
showTableFormatOptions,
|
|
51677
|
+
showDashboardFilterFields,
|
|
51406
51678
|
buttonLabel: submitButtonLabel ?? (!!reportBuilder.reportId ? "Save changes" : "Add to dashboard"),
|
|
51407
51679
|
onClickChartElement,
|
|
51408
51680
|
isEditingMode: true
|
|
@@ -51499,6 +51771,7 @@ function ReportBuilder({
|
|
|
51499
51771
|
containerStyle,
|
|
51500
51772
|
className,
|
|
51501
51773
|
pivotRecommendationsEnabled = true,
|
|
51774
|
+
chartBuilderOptions,
|
|
51502
51775
|
reportId,
|
|
51503
51776
|
hideCopySQL = true,
|
|
51504
51777
|
isChartBuilderHorizontalView = true,
|
|
@@ -51955,6 +52228,9 @@ function ReportBuilder({
|
|
|
51955
52228
|
ErrorMessageComponent,
|
|
51956
52229
|
PivotRowContainer,
|
|
51957
52230
|
PivotColumnContainer,
|
|
52231
|
+
showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions,
|
|
52232
|
+
showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields,
|
|
52233
|
+
onDiscardChanges,
|
|
51958
52234
|
onClickChartElement,
|
|
51959
52235
|
submitButtonLabel
|
|
51960
52236
|
}
|
|
@@ -51975,7 +52251,7 @@ function ReportBuilder({
|
|
|
51975
52251
|
isAdmin: false,
|
|
51976
52252
|
title: "Save query",
|
|
51977
52253
|
buttonLabel: "Save query",
|
|
51978
|
-
tempReport,
|
|
52254
|
+
tempReport: { ...tempReport, dashboardName: SAVED_QUERIES_DASHBOARD },
|
|
51979
52255
|
reportId,
|
|
51980
52256
|
organizationName,
|
|
51981
52257
|
CardComponent,
|
|
@@ -52023,7 +52299,10 @@ function ChartEditor({
|
|
|
52023
52299
|
chartBuilderTitle = "Edit chart",
|
|
52024
52300
|
chartBuilderButtonLabel,
|
|
52025
52301
|
onAddToDashboardComplete,
|
|
52302
|
+
onSubmitEditReport,
|
|
52303
|
+
onDiscardChanges,
|
|
52026
52304
|
destinationDashboard,
|
|
52305
|
+
destinationSection,
|
|
52027
52306
|
organizationName,
|
|
52028
52307
|
isHorizontalView = true,
|
|
52029
52308
|
onDelete,
|
|
@@ -52051,6 +52330,9 @@ function ChartEditor({
|
|
|
52051
52330
|
ErrorComponent = QuillChartErrorWithAction,
|
|
52052
52331
|
hideDeleteButton = false,
|
|
52053
52332
|
hideSubmitButton = false,
|
|
52333
|
+
showTableFormatOptions,
|
|
52334
|
+
showDashboardFilterFields,
|
|
52335
|
+
chartBuilderOptions,
|
|
52054
52336
|
onClickChartElement,
|
|
52055
52337
|
onClickChartError
|
|
52056
52338
|
}) {
|
|
@@ -52139,7 +52421,12 @@ function ChartEditor({
|
|
|
52139
52421
|
ModalComponent,
|
|
52140
52422
|
{
|
|
52141
52423
|
isOpen,
|
|
52142
|
-
setIsOpen
|
|
52424
|
+
setIsOpen: (value) => {
|
|
52425
|
+
if (!value) {
|
|
52426
|
+
setChartBuilderKey(chartBuilderKey + 1);
|
|
52427
|
+
}
|
|
52428
|
+
setIsOpen(value);
|
|
52429
|
+
},
|
|
52143
52430
|
title: chartBuilderTitle || "Add to dashboard",
|
|
52144
52431
|
width: isHorizontalView ? modalWidth : void 0,
|
|
52145
52432
|
height: isHorizontalView ? modalHeight : void 0,
|
|
@@ -52152,8 +52439,15 @@ function ChartEditor({
|
|
|
52152
52439
|
isComparison: dateFilter?.comparisonRange,
|
|
52153
52440
|
setIsOpen,
|
|
52154
52441
|
showDashboardDropdown: isAdmin,
|
|
52155
|
-
onAddToDashboardComplete
|
|
52442
|
+
onAddToDashboardComplete: (data) => {
|
|
52443
|
+
if (onSubmitEditReport) {
|
|
52444
|
+
onSubmitEditReport(data);
|
|
52445
|
+
} else if (onAddToDashboardComplete) {
|
|
52446
|
+
onAddToDashboardComplete(data);
|
|
52447
|
+
}
|
|
52448
|
+
},
|
|
52156
52449
|
destinationDashboard,
|
|
52450
|
+
destinationSection,
|
|
52157
52451
|
dateRange,
|
|
52158
52452
|
SelectComponent,
|
|
52159
52453
|
TextInputComponent,
|
|
@@ -52179,13 +52473,18 @@ function ChartEditor({
|
|
|
52179
52473
|
onClickChartError,
|
|
52180
52474
|
onDelete,
|
|
52181
52475
|
onDiscardChanges: () => {
|
|
52476
|
+
if (onDiscardChanges) {
|
|
52477
|
+
onDiscardChanges();
|
|
52478
|
+
}
|
|
52182
52479
|
setChartBuilderKey(chartBuilderKey + 1);
|
|
52183
52480
|
},
|
|
52184
52481
|
title: chartBuilderTitle,
|
|
52185
52482
|
buttonLabel: chartBuilderButtonLabel,
|
|
52186
52483
|
organizationName,
|
|
52187
52484
|
hideSubmitButton,
|
|
52188
|
-
hideDeleteButton,
|
|
52485
|
+
hideDeleteButton: chartBuilderOptions?.showDeleteButton !== void 0 ? !chartBuilderOptions.showDeleteButton : hideDeleteButton,
|
|
52486
|
+
showTableFormatOptions: chartBuilderOptions?.showTableFormatOptions ?? showTableFormatOptions,
|
|
52487
|
+
showDashboardFilterFields: chartBuilderOptions?.showDashboardFilterFields ?? showDashboardFilterFields,
|
|
52189
52488
|
filtersEnabled,
|
|
52190
52489
|
onFiltersEnabledChanged: (value) => {
|
|
52191
52490
|
setFiltersEnabled(value);
|