@quillsql/react 1.6.1 → 1.6.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/lib/AddToDashboardButton.d.ts +1 -0
- package/lib/AddToDashboardButton.js +2 -0
- package/lib/AddToDashboardButton.js.map +1 -0
- package/lib/AddToDashboardModal.d.ts +22 -0
- package/lib/AddToDashboardModal.js +638 -0
- package/lib/AddToDashboardModal.js.map +1 -0
- package/lib/BarList.js +28 -28
- package/lib/BarList.js.map +1 -1
- package/lib/Chart.js +30 -114
- package/lib/Chart.js.map +1 -1
- package/lib/Context.d.ts +3 -3
- package/lib/Context.js +3 -3
- package/lib/Context.js.map +1 -1
- package/lib/Dashboard.js +31 -16
- package/lib/Dashboard.js.map +1 -1
- package/lib/Dialog.d.ts +68 -0
- package/lib/Dialog.js +407 -0
- package/lib/Dialog.js.map +1 -0
- package/lib/Portal.d.ts +32 -0
- package/lib/Portal.js +171 -0
- package/lib/Portal.js.map +1 -0
- package/lib/Props.d.ts +0 -0
- package/lib/Props.js +2 -0
- package/lib/Props.js.map +1 -0
- package/lib/QuillProvider.d.ts +32 -14
- package/lib/QuillProvider.js +15 -2
- package/lib/QuillProvider.js.map +1 -1
- package/lib/ReportBuilder.d.ts +26 -2
- package/lib/ReportBuilder.js +210 -486
- package/lib/ReportBuilder.js.map +1 -1
- package/lib/SQLEditor.d.ts +38 -1
- package/lib/SQLEditor.js +385 -210
- package/lib/SQLEditor.js.map +1 -1
- package/lib/Table.js +12 -14
- package/lib/Table.js.map +1 -1
- package/lib/components/BigModal/BigModal.d.ts +14 -0
- package/lib/components/BigModal/BigModal.js +85 -0
- package/lib/components/BigModal/BigModal.js.map +1 -0
- package/lib/components/BigModal/Modal.d.ts +14 -0
- package/lib/components/BigModal/Modal.js +109 -0
- package/lib/components/BigModal/Modal.js.map +1 -0
- package/lib/components/Modal/Modal.d.ts +1 -1
- package/lib/hooks/useQuill.js +14 -24
- package/lib/hooks/useQuill.js.map +1 -1
- package/lib/hooks/useSyncRefs.d.ts +5 -0
- package/lib/hooks/useSyncRefs.js +38 -0
- package/lib/hooks/useSyncRefs.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/types/Props.d.ts +0 -0
- package/lib/types/Props.js +2 -0
- package/lib/types/Props.js.map +1 -0
- package/lib/types.d.ts +27 -0
- package/lib/types.js +6 -0
- package/lib/types.js.map +1 -0
- package/package.json +2 -1
- package/src/AddToDashboardModal.tsx +1213 -0
- package/src/BarList.tsx +28 -28
- package/src/Chart.tsx +31 -107
- package/src/Context.tsx +8 -5
- package/src/Dashboard.tsx +29 -2
- package/src/QuillProvider.tsx +52 -10
- package/src/ReportBuilder.tsx +420 -649
- package/src/SQLEditor.tsx +805 -235
- package/src/Table.tsx +20 -26
- package/src/components/BigModal/BigModal.tsx +108 -0
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/continue_logs.txt +75 -0
- package/src/hooks/useQuill.ts +2 -16
- package/src/index.ts +1 -0
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
+
var t = {};
|
|
50
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
+
t[p] = s[p];
|
|
52
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
+
t[p[i]] = s[p[i]];
|
|
56
|
+
}
|
|
57
|
+
return t;
|
|
58
|
+
};
|
|
59
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
|
+
if (ar || !(i in from)) {
|
|
62
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
63
|
+
ar[i] = from[i];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
|
+
};
|
|
68
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
69
|
+
// @ts-nocheck
|
|
70
|
+
import { useContext, useEffect, useState } from 'react';
|
|
71
|
+
import { ClientContext, SchemaContext, ThemeContext } from './Context';
|
|
72
|
+
import { Formik, Form, Field } from 'formik';
|
|
73
|
+
import { differenceInDays, differenceInHours, differenceInMonths, differenceInYears, startOfDay, startOfHour, startOfMonth, startOfYear, } from 'date-fns';
|
|
74
|
+
import axios from 'axios';
|
|
75
|
+
import Chart from './Chart';
|
|
76
|
+
import { XMarkIcon } from '@heroicons/react/20/solid';
|
|
77
|
+
function convertPostgresColumn(column) {
|
|
78
|
+
var format;
|
|
79
|
+
switch (column.dataTypeID) {
|
|
80
|
+
case 20: // int8
|
|
81
|
+
case 21: // int2
|
|
82
|
+
case 23: // int4
|
|
83
|
+
format = 'whole_number';
|
|
84
|
+
break;
|
|
85
|
+
case 700: // float4
|
|
86
|
+
case 701: // float8
|
|
87
|
+
case 1700: // numeric
|
|
88
|
+
format = 'two_decimal_places';
|
|
89
|
+
break;
|
|
90
|
+
case 1082: // date
|
|
91
|
+
case 1083: // time
|
|
92
|
+
case 1184: // timestamptz
|
|
93
|
+
case 1114: // timestamp
|
|
94
|
+
format = 'MMM_dd_yyyy';
|
|
95
|
+
break;
|
|
96
|
+
case 1043: // varchar
|
|
97
|
+
default:
|
|
98
|
+
format = 'string';
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
label: column.name,
|
|
102
|
+
field: column.name,
|
|
103
|
+
format: format,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export default function AddToDashboardModal(_a) {
|
|
107
|
+
var _this = this;
|
|
108
|
+
var isOpen = _a.isOpen, setIsOpen = _a.setIsOpen, SelectComponent = _a.SelectComponent, TextInputComponent = _a.TextInputComponent, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, rows = _a.rows, columns = _a.columns, query = _a.query, ModalComponent = _a.ModalComponent, formHeaderStyle = _a.formHeaderStyle, formLabelStyle = _a.formLabelStyle;
|
|
109
|
+
var theme = useContext(ThemeContext)[0];
|
|
110
|
+
var client = useContext(ClientContext)[0];
|
|
111
|
+
var _b = useContext(SchemaContext), schema = _b[0], setSchema = _b[1];
|
|
112
|
+
useEffect(function () {
|
|
113
|
+
var isSubscribed = true;
|
|
114
|
+
function getSchema() {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var publicKey, environment, response3;
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
publicKey = client.publicKey, environment = client.environment;
|
|
121
|
+
if (!!schema.length) return [3 /*break*/, 2];
|
|
122
|
+
return [4 /*yield*/, axios.get("https://quill-344421.uc.r.appspot.com/schema2/".concat(publicKey, "/"), {
|
|
123
|
+
headers: {
|
|
124
|
+
Authorization: "Bearer ",
|
|
125
|
+
environment: environment || undefined,
|
|
126
|
+
},
|
|
127
|
+
})];
|
|
128
|
+
case 1:
|
|
129
|
+
response3 = _a.sent();
|
|
130
|
+
if (isSubscribed) {
|
|
131
|
+
setSchema(response3.data.tables);
|
|
132
|
+
}
|
|
133
|
+
_a.label = 2;
|
|
134
|
+
case 2: return [2 /*return*/];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
if (isSubscribed) {
|
|
140
|
+
getSchema();
|
|
141
|
+
}
|
|
142
|
+
return function () {
|
|
143
|
+
isSubscribed = false;
|
|
144
|
+
};
|
|
145
|
+
}, [schema]);
|
|
146
|
+
var editChart = function (_a) {
|
|
147
|
+
var report = _a.report, values = _a.values, yAxisFields = _a.yAxisFields, columns = _a.columns, query = _a.query;
|
|
148
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
149
|
+
var publicKey, orgId, authToken, queryEndpoint, queryHeaders, xAxisLabel, yAxisLabel, chartName, chartType, xAxisField, xAxisFormat, dashboardName, dateFieldTable, dateField, i, response;
|
|
150
|
+
return __generator(this, function (_b) {
|
|
151
|
+
switch (_b.label) {
|
|
152
|
+
case 0:
|
|
153
|
+
publicKey = client.publicKey, orgId = client.orgId, authToken = client.authToken, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders;
|
|
154
|
+
xAxisLabel = values.xAxisLabel, yAxisLabel = values.yAxisLabel, chartName = values.chartName, chartType = values.chartType, xAxisField = values.xAxisField, xAxisFormat = values.xAxisFormat, dashboardName = values.dashboardName, dateFieldTable = values.dateFieldTable, dateField = values.dateField;
|
|
155
|
+
if (!chartName) {
|
|
156
|
+
alert('Please enter a chart name');
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
// if (!dashboardName) {
|
|
160
|
+
// alert("Please choose a dashboard name");
|
|
161
|
+
// return;
|
|
162
|
+
// }
|
|
163
|
+
// if (!xAxisLabel && chartType !== "pie" && chartType !== "table") {
|
|
164
|
+
// alert("Please enter a label for the x-axis");
|
|
165
|
+
// return;
|
|
166
|
+
// }
|
|
167
|
+
// if (!yAxisLabel && chartType !== "pie" && chartType !== "table") {
|
|
168
|
+
// alert("Please enter a label for the y-axis");
|
|
169
|
+
// return;
|
|
170
|
+
// }
|
|
171
|
+
for (i = 0; i < yAxisFields.length; i++) {
|
|
172
|
+
if (!yAxisFields[i].label && chartType !== 'pie') {
|
|
173
|
+
alert("Please enter a label for column '".concat(yAxisFields[i].field, "'"));
|
|
174
|
+
return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
if (!client || !organization) {
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
}
|
|
180
|
+
if (!queryEndpoint) return [3 /*break*/, 2];
|
|
181
|
+
return [4 /*yield*/, axios.post(queryEndpoint, {
|
|
182
|
+
metadata: {
|
|
183
|
+
name: chartName,
|
|
184
|
+
xAxisField: xAxisField,
|
|
185
|
+
yAxisFields: yAxisFields,
|
|
186
|
+
xAxisLabel: xAxisLabel,
|
|
187
|
+
xAxisFormat: xAxisFormat,
|
|
188
|
+
yAxisLabel: yAxisLabel,
|
|
189
|
+
chartType: chartType,
|
|
190
|
+
dashboardName: dashboardName,
|
|
191
|
+
columns: columns,
|
|
192
|
+
dateField: { table: dateFieldTable, field: dateField },
|
|
193
|
+
query: query,
|
|
194
|
+
task: 'create',
|
|
195
|
+
},
|
|
196
|
+
}, { headers: queryHeaders })];
|
|
197
|
+
case 1:
|
|
198
|
+
response = _b.sent();
|
|
199
|
+
return [3 /*break*/, 4];
|
|
200
|
+
case 2: return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashedit/".concat(publicKey, "/").concat(orgId, "/"), {
|
|
201
|
+
name: chartName,
|
|
202
|
+
xAxisField: xAxisField,
|
|
203
|
+
yAxisFields: yAxisFields,
|
|
204
|
+
xAxisLabel: xAxisLabel,
|
|
205
|
+
xAxisFormat: xAxisFormat,
|
|
206
|
+
yAxisLabel: yAxisLabel,
|
|
207
|
+
chartType: chartType,
|
|
208
|
+
dashboardName: dashboardName,
|
|
209
|
+
columns: columns,
|
|
210
|
+
dateField: { table: dateFieldTable, field: dateField },
|
|
211
|
+
query: query,
|
|
212
|
+
}, {
|
|
213
|
+
headers: {
|
|
214
|
+
Authorization: "Bearer ".concat(authToken),
|
|
215
|
+
environment: environment || undefined,
|
|
216
|
+
},
|
|
217
|
+
})];
|
|
218
|
+
case 3:
|
|
219
|
+
response = _b.sent();
|
|
220
|
+
_b.label = 4;
|
|
221
|
+
case 4:
|
|
222
|
+
if (!response.data) {
|
|
223
|
+
return [2 /*return*/];
|
|
224
|
+
}
|
|
225
|
+
// setDashboard((dashboard) => {
|
|
226
|
+
// return {
|
|
227
|
+
// ...dashboard,
|
|
228
|
+
// [response.data._id]: { ...existingVisualization, ...response.data }
|
|
229
|
+
// }
|
|
230
|
+
// })
|
|
231
|
+
setIsOpen(false);
|
|
232
|
+
return [2 /*return*/];
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
return (
|
|
238
|
+
// <BigModal theme={theme} showModal={isOpen} setShowModal={setIsOpen}>
|
|
239
|
+
_jsx(ModalComponent, __assign({ isOpen: isOpen, title: 'Add to dashboard', onClose: function () { return setIsOpen(false); } }, { children: _jsx(ChartForm, { editChart: editChart, theme: theme, schema: schema, data: rows, fields: columns,
|
|
240
|
+
// leave null for now
|
|
241
|
+
report: null, query: query,
|
|
242
|
+
// organizationName={organization?.name}
|
|
243
|
+
SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) }))
|
|
244
|
+
// </BigModal>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function ChartForm(_a) {
|
|
248
|
+
var _this = this;
|
|
249
|
+
var data = _a.data, fields = _a.fields, theme = _a.theme, saveVisualization = _a.saveVisualization, report = _a.report, editChart = _a.editChart, schema = _a.schema, query = _a.query,
|
|
250
|
+
// organizationName,
|
|
251
|
+
SelectComponent = _a.SelectComponent, TextInputComponent = _a.TextInputComponent, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, formHeaderStyle = _a.formHeaderStyle, formLabelStyle = _a.formLabelStyle;
|
|
252
|
+
var fieldOptions = Object.keys(data[0]).map(function (field) { return ({
|
|
253
|
+
value: field,
|
|
254
|
+
label: field,
|
|
255
|
+
}); });
|
|
256
|
+
var _b = useState([]), dateFieldOptions = _b[0], setDateFieldOptions = _b[1];
|
|
257
|
+
useEffect(function () {
|
|
258
|
+
var fetchReferencedTables = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
259
|
+
var result;
|
|
260
|
+
return __generator(this, function (_a) {
|
|
261
|
+
switch (_a.label) {
|
|
262
|
+
case 0: return [4 /*yield*/, getReferencedTables(query, 'PostgresQL', schema)];
|
|
263
|
+
case 1:
|
|
264
|
+
result = _a.sent();
|
|
265
|
+
setDateFieldOptions(result);
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}); };
|
|
270
|
+
fetchReferencedTables();
|
|
271
|
+
}, [query, schema]);
|
|
272
|
+
return (_jsx(Formik, __assign({ initialValues: {
|
|
273
|
+
xAxisField: (report === null || report === void 0 ? void 0 : report.xAxisField) || fieldOptions[0].value,
|
|
274
|
+
xAxisLabel: (report === null || report === void 0 ? void 0 : report.xAxisLabel) || '',
|
|
275
|
+
xAxisFormat: (report === null || report === void 0 ? void 0 : report.xAxisFormat) || FORMAT_OPTIONS[0].value,
|
|
276
|
+
yAxisLabel: (report === null || report === void 0 ? void 0 : report.yAxisLabel) || '',
|
|
277
|
+
chartName: report === null || report === void 0 ? void 0 : report.name,
|
|
278
|
+
chartType: (report === null || report === void 0 ? void 0 : report.chartType) || 'bar',
|
|
279
|
+
xAxisFieldLabel: '',
|
|
280
|
+
dashboardName: (report === null || report === void 0 ? void 0 : report.dashboardName) || '',
|
|
281
|
+
dateFieldTable: (dateFieldOptions.length && dateFieldOptions[0].name) || '',
|
|
282
|
+
dateField: (dateFieldOptions.length && dateFieldOptions[0].columns[0].name) ||
|
|
283
|
+
'',
|
|
284
|
+
template: (report === null || report === void 0 ? void 0 : report.template) || false,
|
|
285
|
+
}, onSubmit: function () { } }, { children: function (_a) {
|
|
286
|
+
var values = _a.values, isSubmitting = _a.isSubmitting, setFieldValue = _a.setFieldValue;
|
|
287
|
+
return (_jsx(FormikForm, { values: values, isSubmitting: isSubmitting, data: data, fieldOptions: fieldOptions, dateFieldOptions: dateFieldOptions, theme: theme, saveVisualization: saveVisualization, report: report, editChart: editChart, fields: fields, query: query, setFieldValue: setFieldValue,
|
|
288
|
+
// organizationName={organizationName}
|
|
289
|
+
SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }));
|
|
290
|
+
} })));
|
|
291
|
+
}
|
|
292
|
+
export function isValidDate(d) {
|
|
293
|
+
return d instanceof Date && !isNaN(d);
|
|
294
|
+
}
|
|
295
|
+
export var isArrayOfValidDates = function (arr, field) {
|
|
296
|
+
return arr.every(function (d) { return new Date(d[field]) instanceof Date && !isNaN(new Date(d[field])); });
|
|
297
|
+
};
|
|
298
|
+
export function formatDateBuckets(startDate, endDate) {
|
|
299
|
+
// Calculate the distance in hours
|
|
300
|
+
var distanceInHours = Math.abs(differenceInHours(endDate, startDate));
|
|
301
|
+
// Check if the distance is less than or equal to one hour
|
|
302
|
+
if (distanceInHours <= 1) {
|
|
303
|
+
return {
|
|
304
|
+
unit: 'hour',
|
|
305
|
+
format: 'h a',
|
|
306
|
+
startOf: startOfHour,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
// Calculate the distance in days
|
|
310
|
+
var distanceInDays = Math.abs(differenceInDays(endDate, startDate));
|
|
311
|
+
// Check if the distance is less than or equal to one day
|
|
312
|
+
if (distanceInDays <= 1) {
|
|
313
|
+
return {
|
|
314
|
+
unit: 'day',
|
|
315
|
+
format: 'MMM d',
|
|
316
|
+
startOf: startOfDay,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
// Calculate the distance in months
|
|
320
|
+
var distanceInMonths = Math.abs(differenceInMonths(endDate, startDate));
|
|
321
|
+
// Check if the distance is less than or equal to one month
|
|
322
|
+
if (distanceInMonths <= 1) {
|
|
323
|
+
return {
|
|
324
|
+
unit: 'month',
|
|
325
|
+
format: 'MMM yyyy',
|
|
326
|
+
startOf: startOfMonth,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
// Calculate the distance in years
|
|
330
|
+
var distanceInYears = Math.abs(differenceInYears(endDate, startDate));
|
|
331
|
+
// Check if the distance is less than or equal to one year
|
|
332
|
+
if (distanceInYears <= 1) {
|
|
333
|
+
return {
|
|
334
|
+
unit: 'year',
|
|
335
|
+
format: 'yyyy',
|
|
336
|
+
startOf: startOfYear,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
// Otherwise, the distance is more than one year
|
|
340
|
+
return {
|
|
341
|
+
unit: 'year',
|
|
342
|
+
format: 'yyyy',
|
|
343
|
+
startOf: startOfYear,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
var FormTextInput = function (_a) {
|
|
347
|
+
var field = _a.field, form = _a.form, props = __rest(_a, ["field", "form"]);
|
|
348
|
+
var theme = props.theme, wider = props.wider;
|
|
349
|
+
return (_jsx("input", __assign({ className: "px-[12px] text-sm h-[38px] py-1.5 shadow-sm w-[245px] border-[#E7E7E7] ".concat('text-[#212121]', " border-[1px] bg-[white] rounded-md"), type: "text" }, field, props)));
|
|
350
|
+
};
|
|
351
|
+
var POSTGRES_DATE_TYPES = [
|
|
352
|
+
'timestamp',
|
|
353
|
+
'date',
|
|
354
|
+
'timestamptz',
|
|
355
|
+
'time',
|
|
356
|
+
'timetz',
|
|
357
|
+
];
|
|
358
|
+
function getReferencedTables(sqlQuery, databaseType, dbTables) {
|
|
359
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
360
|
+
var tables, withAliases, response, ast, i, j, tablesInQuery;
|
|
361
|
+
return __generator(this, function (_a) {
|
|
362
|
+
switch (_a.label) {
|
|
363
|
+
case 0:
|
|
364
|
+
tables = [];
|
|
365
|
+
withAliases = [];
|
|
366
|
+
return [4 /*yield*/, axios.post('https://quill-344421.uc.r.appspot.com/astify', { query: sqlQuery })];
|
|
367
|
+
case 1:
|
|
368
|
+
response = _a.sent();
|
|
369
|
+
ast = response.data.ast;
|
|
370
|
+
ast = ast.length ? ast[0] : ast;
|
|
371
|
+
if (ast.with && ast.with.length) {
|
|
372
|
+
for (i = 0; i < ast.with.length; i++) {
|
|
373
|
+
withAliases.push(ast.with[i].name.value);
|
|
374
|
+
for (j = 0; j < ast.with[i].stmt.from.length; j++)
|
|
375
|
+
tables.push(ast.with[i].stmt.from[j].table);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
tablesInQuery = __spreadArray(__spreadArray([], tables, true), ast.from.map(function (elem) { return elem.table; }), true).filter(function (elem) { return !withAliases.includes(elem); });
|
|
379
|
+
return [2 /*return*/, dbTables
|
|
380
|
+
.filter(function (table) { return tablesInQuery.includes(table.displayName); })
|
|
381
|
+
.map(function (table) {
|
|
382
|
+
return {
|
|
383
|
+
name: table.displayName,
|
|
384
|
+
columns: table.columns.filter(function (column) {
|
|
385
|
+
return POSTGRES_DATE_TYPES.includes(column.fieldType);
|
|
386
|
+
}),
|
|
387
|
+
};
|
|
388
|
+
})
|
|
389
|
+
.filter(function (table) { return table.columns.length > 0; })];
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
var FORMAT_OPTIONS = [
|
|
395
|
+
{ value: 'whole_number', label: 'whole number' },
|
|
396
|
+
{ value: 'one_decimal_place', label: 'one decimal place' },
|
|
397
|
+
{ value: 'dollar_amount', label: 'dollar amount' },
|
|
398
|
+
{ value: 'MMM_yyyy', label: 'month' },
|
|
399
|
+
{ value: 'MMM_dd-MMM_dd', label: 'week' },
|
|
400
|
+
{ value: 'MMM_dd_yyyy', label: 'day' },
|
|
401
|
+
{ value: 'MMM_dd_hh:mm_ap_pm', label: 'day and time' },
|
|
402
|
+
{ value: 'hh_ap_pm', label: 'hour' },
|
|
403
|
+
{ value: 'percent', label: 'percent' },
|
|
404
|
+
{ value: 'string', label: 'string' },
|
|
405
|
+
];
|
|
406
|
+
function FormikForm(_a) {
|
|
407
|
+
var values = _a.values, isSubmitting = _a.isSubmitting, data = _a.data, fieldOptions = _a.fieldOptions, dateFieldOptions = _a.dateFieldOptions, theme = _a.theme, report = _a.report, editChart = _a.editChart, fields = _a.fields, query = _a.query, SelectComponent = _a.SelectComponent, TextInputComponent = _a.TextInputComponent, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, setFieldValue = _a.setFieldValue, organizationName = _a.organizationName, formHeaderStyle = _a.formHeaderStyle, formLabelStyle = _a.formLabelStyle;
|
|
408
|
+
var _b = useState({}), chartConfig = _b[0], setChartConfig = _b[1];
|
|
409
|
+
var _c = useState(report
|
|
410
|
+
? report.yAxisFields
|
|
411
|
+
: [
|
|
412
|
+
{
|
|
413
|
+
field: fieldOptions.length > 1
|
|
414
|
+
? fieldOptions[1].value
|
|
415
|
+
: fieldOptions[0].value,
|
|
416
|
+
label: '',
|
|
417
|
+
format: 'whole_number',
|
|
418
|
+
},
|
|
419
|
+
]), yAxisFields = _c[0], setYAxisFields = _c[1];
|
|
420
|
+
var _d = useState(report && report.columns.length
|
|
421
|
+
? report.columns
|
|
422
|
+
: (fields === null || fields === void 0 ? void 0 : fields.length)
|
|
423
|
+
? fields.map(function (field) { return convertPostgresColumn(field); })
|
|
424
|
+
: []), columns = _d[0], setColumns = _d[1];
|
|
425
|
+
var handleAddYAxisField = function () {
|
|
426
|
+
setYAxisFields(__spreadArray(__spreadArray([], yAxisFields, true), [
|
|
427
|
+
{ label: '', field: '', format: 'whole_number' },
|
|
428
|
+
], false));
|
|
429
|
+
};
|
|
430
|
+
var handleDeleteYAxisField = function (index) {
|
|
431
|
+
setYAxisFields(function (yAxisFields) { return yAxisFields.filter(function (_, i) { return index !== i; }); });
|
|
432
|
+
};
|
|
433
|
+
var handleYAxisFieldChange = function (index, value) {
|
|
434
|
+
var newYAxisFields = __spreadArray([], yAxisFields, true);
|
|
435
|
+
newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { field: value });
|
|
436
|
+
setYAxisFields(newYAxisFields);
|
|
437
|
+
};
|
|
438
|
+
var handleYAxisFieldFormatChange = function (index, value) {
|
|
439
|
+
var newYAxisFields = __spreadArray([], yAxisFields, true);
|
|
440
|
+
newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { format: value });
|
|
441
|
+
setYAxisFields(newYAxisFields);
|
|
442
|
+
};
|
|
443
|
+
var handleYAxisFieldLabelChange = function (index, value) {
|
|
444
|
+
var newYAxisFields = __spreadArray([], yAxisFields, true);
|
|
445
|
+
newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { label: value });
|
|
446
|
+
setYAxisFields(newYAxisFields);
|
|
447
|
+
};
|
|
448
|
+
var handleColumnFieldChange = function (index, value) {
|
|
449
|
+
var newColumns = __spreadArray([], columns, true);
|
|
450
|
+
newColumns[index] = __assign(__assign({}, newColumns[index]), { field: value });
|
|
451
|
+
setColumns(newColumns);
|
|
452
|
+
};
|
|
453
|
+
var handleColumnFormatChange = function (index, value) {
|
|
454
|
+
var newColumns = __spreadArray([], columns, true);
|
|
455
|
+
newColumns[index] = __assign(__assign({}, newColumns[index]), { format: value });
|
|
456
|
+
setColumns(newColumns);
|
|
457
|
+
};
|
|
458
|
+
var handleColumnLabelChange = function (index, value) {
|
|
459
|
+
var newColumns = __spreadArray([], columns, true);
|
|
460
|
+
newColumns[index] = __assign(__assign({}, newColumns[index]), { label: value });
|
|
461
|
+
setColumns(newColumns);
|
|
462
|
+
};
|
|
463
|
+
useEffect(function () {
|
|
464
|
+
setChartConfig(__assign(__assign({}, values), { yAxisFields: yAxisFields, rows: data }));
|
|
465
|
+
}, [values, yAxisFields]);
|
|
466
|
+
// console.log('VIBE: ', { report, values, yAxisFields, columns, query });
|
|
467
|
+
return (_jsx(Form, __assign({ style: { display: 'inline-block' } }, { children: _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsxs("div", __assign({ style: {
|
|
468
|
+
display: 'flex',
|
|
469
|
+
flexDirection: 'column',
|
|
470
|
+
} }, { children: [_jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: { marginLeft: -25 } }, { children: Object.keys(chartConfig).length > 0 && (_jsx(Chart, { chartId: "646e37a660feef000be67a93", config: chartConfig, colors: theme.chartColors, containerStyle: {
|
|
471
|
+
width: '100%',
|
|
472
|
+
height: 300,
|
|
473
|
+
} })) })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
|
|
474
|
+
fontFamily: theme.fontFamily,
|
|
475
|
+
color: theme.primaryTextColor,
|
|
476
|
+
fontSize: theme.fontSize + 2,
|
|
477
|
+
fontWeight: 600,
|
|
478
|
+
marginTop: 20,
|
|
479
|
+
} }, { children: 'Chart' })), _jsxs("div", __assign({ style: {
|
|
480
|
+
display: 'flex',
|
|
481
|
+
flexDirection: 'row',
|
|
482
|
+
alignItems: 'center',
|
|
483
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
484
|
+
fontSize: '14px',
|
|
485
|
+
marginBottom: '6px',
|
|
486
|
+
fontWeight: '600',
|
|
487
|
+
marginTop: 8,
|
|
488
|
+
color: theme.secondaryTextColor,
|
|
489
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
490
|
+
} }, { children: "Name" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "chartName", component: TextInputComponent, theme: theme, wider: true }) }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
491
|
+
fontFamily: theme.fontFamily,
|
|
492
|
+
color: theme.secondaryTextColor,
|
|
493
|
+
fontSize: theme.fontSize,
|
|
494
|
+
fontWeight: theme.labelFontWeight,
|
|
495
|
+
marginTop: 8,
|
|
496
|
+
marginBottom: 6,
|
|
497
|
+
} }, { children: "Dashboard name" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "dashboardName", component: TextInputComponent, theme: theme, wider: true }) }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
498
|
+
fontFamily: theme.fontFamily,
|
|
499
|
+
color: theme.secondaryTextColor,
|
|
500
|
+
fontSize: theme.fontSize,
|
|
501
|
+
fontWeight: theme.labelFontWeight,
|
|
502
|
+
marginTop: 8,
|
|
503
|
+
} }, { children: "Chart type" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "chartType", component: SelectComponent, theme: theme, options: [
|
|
504
|
+
{ label: 'bar', value: 'bar' },
|
|
505
|
+
{ label: 'line', value: 'line' },
|
|
506
|
+
{ label: 'column', value: 'column' },
|
|
507
|
+
{ label: 'pie', value: 'pie' },
|
|
508
|
+
{ label: 'metric', value: 'metric' },
|
|
509
|
+
{ label: 'table', value: 'table' },
|
|
510
|
+
] }) }))] }))] }))] })), _jsx("div", __assign({ style: {
|
|
511
|
+
display: 'flex',
|
|
512
|
+
flexDirection: 'row',
|
|
513
|
+
alignItems: 'center',
|
|
514
|
+
// justifyContent: 'space-between',
|
|
515
|
+
marginTop: 20,
|
|
516
|
+
} }, { children: values.chartType !== 'table' && (_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
517
|
+
fontFamily: theme.fontFamily,
|
|
518
|
+
color: theme.secondaryTextColor,
|
|
519
|
+
fontSize: theme.fontSize,
|
|
520
|
+
fontWeight: theme.labelFontWeight,
|
|
521
|
+
} }, { children: values.chartType === 'pie'
|
|
522
|
+
? 'Category column'
|
|
523
|
+
: 'x-axis column' })), _jsx("div", { style: { height: 6 } }), _jsxs("div", __assign({ style: {
|
|
524
|
+
display: 'flex',
|
|
525
|
+
flexDirection: 'row',
|
|
526
|
+
alignItems: 'center',
|
|
527
|
+
} }, { children: [_jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "xAxisField", component: SelectComponent, theme: theme, options: fieldOptions }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "xAxisLabel", component: TextInputComponent, theme: theme }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "xAxisFormat", component: SelectComponent, theme: theme, options: FORMAT_OPTIONS }) }))] }))] }))) })), _jsxs("div", __assign({ style: {
|
|
528
|
+
display: 'flex',
|
|
529
|
+
flexDirection: 'row',
|
|
530
|
+
alignItems: 'flex-start',
|
|
531
|
+
// justifyContent: 'space-between',
|
|
532
|
+
marginTop: 20,
|
|
533
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
534
|
+
fontFamily: theme.fontFamily,
|
|
535
|
+
color: theme.secondaryTextColor,
|
|
536
|
+
fontSize: theme.fontSize,
|
|
537
|
+
fontWeight: theme.labelFontWeight,
|
|
538
|
+
minWidth: 200,
|
|
539
|
+
} }, { children: values.chartType === 'table'
|
|
540
|
+
? 'Columns'
|
|
541
|
+
: values.chartType === 'pie'
|
|
542
|
+
? 'Quantity column'
|
|
543
|
+
: 'y-axis columns' })), _jsxs("div", __assign({ style: {
|
|
544
|
+
display: 'flex',
|
|
545
|
+
flexDirection: 'column',
|
|
546
|
+
} }, { children: [yAxisFields.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
|
|
547
|
+
display: 'flex',
|
|
548
|
+
flexDirection: 'row',
|
|
549
|
+
alignItems: 'center',
|
|
550
|
+
marginTop: index === 0 ? 6 : 10,
|
|
551
|
+
} }, { children: _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "yAxisField-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.field, onChange: function (option) { return handleYAxisFieldChange(index, option); }, options: fieldOptions }) })) }), "yAxisField-".concat(index))); }), values.chartType !== 'pie' && (_jsx("div", __assign({ style: { marginTop: 12 } }, { children: _jsx(SecondaryButtonComponent, { onClick: handleAddYAxisField, label: "Add column +" }) }))), _jsx("div", { style: { height: 10 } })] }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: {
|
|
552
|
+
display: 'flex',
|
|
553
|
+
flexDirection: 'column',
|
|
554
|
+
justifyContent: 'flex-start',
|
|
555
|
+
} }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
556
|
+
fontFamily: theme.fontFamily,
|
|
557
|
+
color: 'transparent',
|
|
558
|
+
fontSize: theme.fontSize,
|
|
559
|
+
fontWeight: theme.labelFontWeight,
|
|
560
|
+
minWidth: 200,
|
|
561
|
+
// marginBottom: 10,
|
|
562
|
+
} }, { children: "y-axis label" })), values.chartType !== 'pie' &&
|
|
563
|
+
yAxisFields.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
|
|
564
|
+
display: 'flex',
|
|
565
|
+
flexDirection: 'row',
|
|
566
|
+
alignItems: 'center',
|
|
567
|
+
marginTop: index === 0 ? 6 : 10,
|
|
568
|
+
} }, { children: [_jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "yAxisField-".concat(index), component: TextInputComponent, theme: theme, placeholder: "Enter column label", value: yAxisField.label, onChange: function (event) {
|
|
569
|
+
return handleYAxisFieldLabelChange(index, event.target.value);
|
|
570
|
+
} }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "yAxisFieldFormat-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.format, onChange: function (option) {
|
|
571
|
+
return handleYAxisFieldFormatChange(index, option);
|
|
572
|
+
}, options: FORMAT_OPTIONS }) })), _jsx("div", __assign({ onClick: function () {
|
|
573
|
+
return index > 0 ? handleDeleteYAxisField(index) : undefined;
|
|
574
|
+
}, style: {
|
|
575
|
+
cursor: index > 0 ? 'pointer' : undefined,
|
|
576
|
+
paddingLeft: 6,
|
|
577
|
+
paddingTop: 12,
|
|
578
|
+
paddingBottom: 12,
|
|
579
|
+
paddingRight: 6,
|
|
580
|
+
maxHeight: 38,
|
|
581
|
+
display: 'flex',
|
|
582
|
+
alignItems: 'center',
|
|
583
|
+
justifyContent: 'center',
|
|
584
|
+
} }, { children: _jsx(XMarkIcon, { style: {
|
|
585
|
+
height: '20px',
|
|
586
|
+
width: '20px',
|
|
587
|
+
color: index > 0
|
|
588
|
+
? theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor
|
|
589
|
+
: 'rgba(0,0,0,0)',
|
|
590
|
+
}, "aria-hidden": "true" }) }))] }), "yAxisField-".concat(index))); })] }))] })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
|
|
591
|
+
fontFamily: theme.fontFamily,
|
|
592
|
+
color: theme.primaryTextColor,
|
|
593
|
+
fontSize: theme.fontSize + 2,
|
|
594
|
+
fontWeight: 600,
|
|
595
|
+
} }, { children: 'Table' })), _jsxs("div", __assign({ style: {
|
|
596
|
+
display: 'flex',
|
|
597
|
+
flexDirection: 'row',
|
|
598
|
+
alignItems: 'flex-start',
|
|
599
|
+
// justifyContent: 'space-between',
|
|
600
|
+
// marginTop: 8,
|
|
601
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
602
|
+
fontFamily: theme.fontFamily,
|
|
603
|
+
color: theme.secondaryTextColor,
|
|
604
|
+
fontSize: theme.fontSize,
|
|
605
|
+
fontWeight: theme.labelFontWeight,
|
|
606
|
+
} }, { children: 'Columns' })), _jsxs("div", __assign({ style: {
|
|
607
|
+
display: 'flex',
|
|
608
|
+
flexDirection: 'column',
|
|
609
|
+
} }, { children: [columns.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
|
|
610
|
+
display: 'flex',
|
|
611
|
+
flexDirection: 'row',
|
|
612
|
+
alignItems: 'center',
|
|
613
|
+
marginTop: index === 0 ? 6 : 10,
|
|
614
|
+
} }, { children: _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "column-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.field, onChange: function (option) {
|
|
615
|
+
return handleColumnFieldChange(index, option);
|
|
616
|
+
}, options: fieldOptions }) })) }), "column-".concat(index))); }), _jsx("div", { style: { height: 10 } })] }))] })), _jsx("div", { style: { width: 20 } }), _jsxs("div", __assign({ style: {
|
|
617
|
+
display: 'flex',
|
|
618
|
+
flexDirection: 'column',
|
|
619
|
+
justifyContent: 'flex-start',
|
|
620
|
+
} }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
621
|
+
fontFamily: theme.fontFamily,
|
|
622
|
+
color: 'transparent',
|
|
623
|
+
fontSize: theme.fontSize,
|
|
624
|
+
fontWeight: theme.labelFontWeight,
|
|
625
|
+
minWidth: 200,
|
|
626
|
+
// marginBottom: 10,
|
|
627
|
+
} }, { children: "label" })), columns.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
|
|
628
|
+
display: 'flex',
|
|
629
|
+
flexDirection: 'row',
|
|
630
|
+
alignItems: 'center',
|
|
631
|
+
marginTop: index === 0 ? 6 : 10,
|
|
632
|
+
} }, { children: [_jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "columnlabel-".concat(index), component: TextInputComponent, theme: theme, placeholder: "Enter column label", value: yAxisField.label, onChange: function (event) {
|
|
633
|
+
return handleColumnLabelChange(index, event.target.value);
|
|
634
|
+
} }) })), _jsx("div", { style: { width: 20 } }), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "columnFormat-".concat(index), component: SelectComponent, theme: theme, value: yAxisField.format, onChange: function (option) { return handleColumnFormatChange(index, option); }, options: FORMAT_OPTIONS }) }))] }), "column-".concat(index))); })] }))] })), _jsx("div", { style: { height: 20 } }), _jsx("div", { style: { height: 20 } }), _jsx(ButtonComponent, { onClick: function () {
|
|
635
|
+
return editChart({ report: report, values: values, yAxisFields: yAxisFields, columns: columns, query: query });
|
|
636
|
+
}, label: report ? 'Save changes' : 'Add to dashboard' })] })) })));
|
|
637
|
+
}
|
|
638
|
+
//# sourceMappingURL=AddToDashboardModal.js.map
|