@quillsql/react 1.7.1 → 1.7.2
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/AddToDashboardModal.js +369 -249
- package/lib/AddToDashboardModal.js.map +1 -1
- package/lib/BarList.js +109 -92
- package/lib/BarList.js.map +1 -1
- package/lib/Chart.js +414 -364
- package/lib/Chart.js.map +1 -1
- package/lib/Context.js +84 -92
- package/lib/Context.js.map +1 -1
- package/lib/Dashboard.js +209 -181
- package/lib/Dashboard.js.map +1 -1
- package/lib/DateRangePicker/Calendar.js +91 -87
- package/lib/DateRangePicker/Calendar.js.map +1 -1
- package/lib/DateRangePicker/DateRangePicker.js +68 -70
- package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
- package/lib/DateRangePicker/DateRangePickerButton.js +57 -46
- package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
- package/lib/DateRangePicker/dateRangePickerUtils.js +99 -105
- package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
- package/lib/DateRangePicker/index.js +1 -8
- package/lib/DateRangePicker/index.js.map +1 -1
- package/lib/PieChart.js +225 -221
- package/lib/PieChart.js.map +1 -1
- package/lib/QuillProvider.js +18 -8
- package/lib/QuillProvider.js.map +1 -1
- package/lib/ReportBuilder.js +526 -430
- package/lib/ReportBuilder.js.map +1 -1
- package/lib/SQLEditor.js +268 -183
- package/lib/SQLEditor.js.map +1 -1
- package/lib/Table.js +256 -213
- package/lib/Table.js.map +1 -1
- package/lib/TableChart.js +75 -76
- package/lib/TableChart.js.map +1 -1
- package/lib/assets/ArrowDownHeadIcon.js +28 -5
- package/lib/assets/ArrowDownHeadIcon.js.map +1 -1
- package/lib/assets/ArrowDownIcon.js +28 -5
- package/lib/assets/ArrowDownIcon.js.map +1 -1
- package/lib/assets/ArrowDownRightIcon.js +28 -5
- package/lib/assets/ArrowDownRightIcon.js.map +1 -1
- package/lib/assets/ArrowLeftHeadIcon.js +28 -5
- package/lib/assets/ArrowLeftHeadIcon.js.map +1 -1
- package/lib/assets/ArrowRightHeadIcon.js +28 -5
- package/lib/assets/ArrowRightHeadIcon.js.map +1 -1
- package/lib/assets/ArrowRightIcon.js +28 -5
- package/lib/assets/ArrowRightIcon.js.map +1 -1
- package/lib/assets/ArrowUpHeadIcon.js +28 -5
- package/lib/assets/ArrowUpHeadIcon.js.map +1 -1
- package/lib/assets/ArrowUpIcon.js +28 -5
- package/lib/assets/ArrowUpIcon.js.map +1 -1
- package/lib/assets/ArrowUpRightIcon.js +28 -5
- package/lib/assets/ArrowUpRightIcon.js.map +1 -1
- package/lib/assets/CalendarIcon.js +28 -5
- package/lib/assets/CalendarIcon.js.map +1 -1
- package/lib/assets/DoubleArrowLeftHeadIcon.js +28 -5
- package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -1
- package/lib/assets/DoubleArrowRightHeadIcon.js +28 -5
- package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -1
- package/lib/assets/ExclamationFilledIcon.js +28 -5
- package/lib/assets/ExclamationFilledIcon.js.map +1 -1
- package/lib/assets/LoadingSpinner.js +28 -5
- package/lib/assets/LoadingSpinner.js.map +1 -1
- package/lib/assets/SearchIcon.js +28 -5
- package/lib/assets/SearchIcon.js.map +1 -1
- package/lib/assets/XCircleIcon.js +28 -5
- package/lib/assets/XCircleIcon.js.map +1 -1
- package/lib/assets/index.js +16 -38
- package/lib/assets/index.js.map +1 -1
- package/lib/components/BigModal/BigModal.js +43 -45
- package/lib/components/BigModal/BigModal.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.js +53 -57
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownItem.js +40 -43
- package/lib/components/Dropdown/DropdownItem.js.map +1 -1
- package/lib/components/Dropdown/index.js +2 -10
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/Modal/Modal.js +43 -45
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/Modal/index.js +1 -8
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/selectUtils.js +15 -20
- package/lib/components/selectUtils.js.map +1 -1
- package/lib/contexts/BaseColorContext.js +3 -5
- package/lib/contexts/BaseColorContext.js.map +1 -1
- package/lib/contexts/HoveredValueContext.js +3 -5
- package/lib/contexts/HoveredValueContext.js.map +1 -1
- package/lib/contexts/RootStylesContext.js +3 -5
- package/lib/contexts/RootStylesContext.js.map +1 -1
- package/lib/contexts/SelectedValueContext.js +3 -5
- package/lib/contexts/SelectedValueContext.js.map +1 -1
- package/lib/contexts/index.js +4 -14
- package/lib/contexts/index.js.map +1 -1
- package/lib/hooks/index.js +4 -14
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useInternalState.js +7 -9
- package/lib/hooks/useInternalState.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +6 -8
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnWindowResize.js +7 -9
- package/lib/hooks/useOnWindowResize.js.map +1 -1
- package/lib/hooks/useQuill.js +111 -60
- package/lib/hooks/useQuill.js.map +1 -1
- package/lib/hooks/useSelectOnKeyDown.js +15 -17
- package/lib/hooks/useSelectOnKeyDown.js.map +1 -1
- package/lib/index.js +8 -22
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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;
|
|
4
58
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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";
|
|
8
69
|
// @ts-nocheck
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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';
|
|
16
77
|
function convertPostgresColumn(column) {
|
|
17
|
-
|
|
78
|
+
var format;
|
|
18
79
|
switch (column.dataTypeID) {
|
|
19
80
|
case 20: // int8
|
|
20
81
|
case 21: // int2
|
|
@@ -42,248 +103,295 @@ function convertPostgresColumn(column) {
|
|
|
42
103
|
format: format,
|
|
43
104
|
};
|
|
44
105
|
}
|
|
45
|
-
function AddToDashboardModal(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
+
}
|
|
59
136
|
});
|
|
60
|
-
|
|
61
|
-
setSchema(response3.data.tables);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
137
|
+
});
|
|
64
138
|
}
|
|
65
139
|
if (isSubscribed) {
|
|
66
140
|
getSchema();
|
|
67
141
|
}
|
|
68
|
-
return ()
|
|
142
|
+
return function () {
|
|
69
143
|
isSubscribed = false;
|
|
70
144
|
};
|
|
71
145
|
}, [schema]);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
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, withCredentials, 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, withCredentials = client.withCredentials;
|
|
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, withCredentials: withCredentials })];
|
|
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
|
+
}
|
|
137
234
|
});
|
|
138
|
-
}
|
|
139
|
-
if (!response.data) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
// setDashboard((dashboard) => {
|
|
143
|
-
// return {
|
|
144
|
-
// ...dashboard,
|
|
145
|
-
// [response.data._id]: { ...existingVisualization, ...response.data }
|
|
146
|
-
// }
|
|
147
|
-
// })
|
|
148
|
-
setIsOpen(false);
|
|
149
|
-
// TODO: fire callback instead so user can customize action
|
|
150
|
-
// navigate("/dashboards");
|
|
235
|
+
});
|
|
151
236
|
};
|
|
152
237
|
return (
|
|
153
238
|
// <BigModal theme={theme} showModal={isOpen} setShowModal={setIsOpen}>
|
|
154
|
-
(
|
|
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,
|
|
155
240
|
// leave null for now
|
|
156
241
|
report: null, query: query,
|
|
157
242
|
// organizationName={organization?.name}
|
|
158
|
-
SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) })
|
|
243
|
+
SelectComponent: SelectComponent, TextInputComponent: TextInputComponent, ButtonComponent: ButtonComponent, SecondaryButtonComponent: SecondaryButtonComponent, formHeaderStyle: formHeaderStyle, formLabelStyle: formLabelStyle }) }))
|
|
159
244
|
// </BigModal>
|
|
160
245
|
);
|
|
161
246
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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 ({
|
|
167
253
|
value: field,
|
|
168
254
|
label: field,
|
|
169
|
-
}));
|
|
170
|
-
|
|
171
|
-
(
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
+
}); };
|
|
176
270
|
fetchReferencedTables();
|
|
177
271
|
}, [query, schema]);
|
|
178
|
-
return ((
|
|
179
|
-
xAxisField: report
|
|
180
|
-
xAxisLabel: report
|
|
181
|
-
xAxisFormat: report
|
|
182
|
-
yAxisLabel: report
|
|
183
|
-
chartName: report
|
|
184
|
-
chartType: report
|
|
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',
|
|
185
279
|
xAxisFieldLabel: '',
|
|
186
|
-
dashboardName: report
|
|
280
|
+
dashboardName: (report === null || report === void 0 ? void 0 : report.dashboardName) || '',
|
|
187
281
|
dateFieldTable: (dateFieldOptions.length && dateFieldOptions[0].name) || '',
|
|
188
282
|
dateField: (dateFieldOptions.length && dateFieldOptions[0].columns[0].name) ||
|
|
189
283
|
'',
|
|
190
|
-
template: report
|
|
191
|
-
}, onSubmit: ()
|
|
192
|
-
|
|
193
|
-
|
|
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
|
+
} })));
|
|
194
291
|
}
|
|
195
|
-
function isValidDate(d) {
|
|
292
|
+
export function isValidDate(d) {
|
|
196
293
|
return d instanceof Date && !isNaN(d);
|
|
197
294
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
function formatDateBuckets(startDate, endDate) {
|
|
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) {
|
|
202
299
|
// Calculate the distance in hours
|
|
203
|
-
|
|
300
|
+
var distanceInHours = Math.abs(differenceInHours(endDate, startDate));
|
|
204
301
|
// Check if the distance is less than or equal to one hour
|
|
205
302
|
if (distanceInHours <= 1) {
|
|
206
303
|
return {
|
|
207
304
|
unit: 'hour',
|
|
208
305
|
format: 'h a',
|
|
209
|
-
startOf:
|
|
306
|
+
startOf: startOfHour,
|
|
210
307
|
};
|
|
211
308
|
}
|
|
212
309
|
// Calculate the distance in days
|
|
213
|
-
|
|
310
|
+
var distanceInDays = Math.abs(differenceInDays(endDate, startDate));
|
|
214
311
|
// Check if the distance is less than or equal to one day
|
|
215
312
|
if (distanceInDays <= 1) {
|
|
216
313
|
return {
|
|
217
314
|
unit: 'day',
|
|
218
315
|
format: 'MMM d',
|
|
219
|
-
startOf:
|
|
316
|
+
startOf: startOfDay,
|
|
220
317
|
};
|
|
221
318
|
}
|
|
222
319
|
// Calculate the distance in months
|
|
223
|
-
|
|
320
|
+
var distanceInMonths = Math.abs(differenceInMonths(endDate, startDate));
|
|
224
321
|
// Check if the distance is less than or equal to one month
|
|
225
322
|
if (distanceInMonths <= 1) {
|
|
226
323
|
return {
|
|
227
324
|
unit: 'month',
|
|
228
325
|
format: 'MMM yyyy',
|
|
229
|
-
startOf:
|
|
326
|
+
startOf: startOfMonth,
|
|
230
327
|
};
|
|
231
328
|
}
|
|
232
329
|
// Calculate the distance in years
|
|
233
|
-
|
|
330
|
+
var distanceInYears = Math.abs(differenceInYears(endDate, startDate));
|
|
234
331
|
// Check if the distance is less than or equal to one year
|
|
235
332
|
if (distanceInYears <= 1) {
|
|
236
333
|
return {
|
|
237
334
|
unit: 'year',
|
|
238
335
|
format: 'yyyy',
|
|
239
|
-
startOf:
|
|
336
|
+
startOf: startOfYear,
|
|
240
337
|
};
|
|
241
338
|
}
|
|
242
339
|
// Otherwise, the distance is more than one year
|
|
243
340
|
return {
|
|
244
341
|
unit: 'year',
|
|
245
342
|
format: 'yyyy',
|
|
246
|
-
startOf:
|
|
343
|
+
startOf: startOfYear,
|
|
247
344
|
};
|
|
248
345
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return ((
|
|
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)));
|
|
253
350
|
};
|
|
254
|
-
|
|
351
|
+
var POSTGRES_DATE_TYPES = [
|
|
255
352
|
'timestamp',
|
|
256
353
|
'date',
|
|
257
354
|
'timestamptz',
|
|
258
355
|
'time',
|
|
259
356
|
'timetz',
|
|
260
357
|
];
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
+
});
|
|
285
393
|
}
|
|
286
|
-
|
|
394
|
+
var FORMAT_OPTIONS = [
|
|
287
395
|
{ value: 'whole_number', label: 'whole number' },
|
|
288
396
|
{ value: 'one_decimal_place', label: 'one decimal place' },
|
|
289
397
|
{ value: 'dollar_amount', label: 'dollar amount' },
|
|
@@ -295,9 +403,10 @@ const FORMAT_OPTIONS = [
|
|
|
295
403
|
{ value: 'percent', label: 'percent' },
|
|
296
404
|
{ value: 'string', label: 'string' },
|
|
297
405
|
];
|
|
298
|
-
function FormikForm(
|
|
299
|
-
|
|
300
|
-
|
|
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
|
|
301
410
|
? report.yAxisFields
|
|
302
411
|
: [
|
|
303
412
|
{
|
|
@@ -307,157 +416,162 @@ function FormikForm({ values, isSubmitting, data, fieldOptions, dateFieldOptions
|
|
|
307
416
|
label: '',
|
|
308
417
|
format: 'whole_number',
|
|
309
418
|
},
|
|
310
|
-
]);
|
|
311
|
-
|
|
419
|
+
]), yAxisFields = _c[0], setYAxisFields = _c[1];
|
|
420
|
+
var _d = useState(report && report.columns.length
|
|
312
421
|
? report.columns
|
|
313
|
-
: fields
|
|
314
|
-
? fields.map(field
|
|
315
|
-
: []);
|
|
316
|
-
|
|
317
|
-
setYAxisFields([
|
|
318
|
-
...yAxisFields,
|
|
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), [
|
|
319
427
|
{ label: '', field: '', format: 'whole_number' },
|
|
320
|
-
]);
|
|
428
|
+
], false));
|
|
321
429
|
};
|
|
322
|
-
|
|
323
|
-
setYAxisFields(yAxisFields
|
|
430
|
+
var handleDeleteYAxisField = function (index) {
|
|
431
|
+
setYAxisFields(function (yAxisFields) { return yAxisFields.filter(function (_, i) { return index !== i; }); });
|
|
324
432
|
};
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
newYAxisFields[index] = {
|
|
433
|
+
var handleYAxisFieldChange = function (index, value) {
|
|
434
|
+
var newYAxisFields = __spreadArray([], yAxisFields, true);
|
|
435
|
+
newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { field: value });
|
|
328
436
|
setYAxisFields(newYAxisFields);
|
|
329
437
|
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
newYAxisFields[index] = {
|
|
438
|
+
var handleYAxisFieldFormatChange = function (index, value) {
|
|
439
|
+
var newYAxisFields = __spreadArray([], yAxisFields, true);
|
|
440
|
+
newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { format: value });
|
|
333
441
|
setYAxisFields(newYAxisFields);
|
|
334
442
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
newYAxisFields[index] = {
|
|
443
|
+
var handleYAxisFieldLabelChange = function (index, value) {
|
|
444
|
+
var newYAxisFields = __spreadArray([], yAxisFields, true);
|
|
445
|
+
newYAxisFields[index] = __assign(__assign({}, newYAxisFields[index]), { label: value });
|
|
338
446
|
setYAxisFields(newYAxisFields);
|
|
339
447
|
};
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
newColumns[index] = {
|
|
448
|
+
var handleColumnFieldChange = function (index, value) {
|
|
449
|
+
var newColumns = __spreadArray([], columns, true);
|
|
450
|
+
newColumns[index] = __assign(__assign({}, newColumns[index]), { field: value });
|
|
343
451
|
setColumns(newColumns);
|
|
344
452
|
};
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
newColumns[index] = {
|
|
453
|
+
var handleColumnFormatChange = function (index, value) {
|
|
454
|
+
var newColumns = __spreadArray([], columns, true);
|
|
455
|
+
newColumns[index] = __assign(__assign({}, newColumns[index]), { format: value });
|
|
348
456
|
setColumns(newColumns);
|
|
349
457
|
};
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
newColumns[index] = {
|
|
458
|
+
var handleColumnLabelChange = function (index, value) {
|
|
459
|
+
var newColumns = __spreadArray([], columns, true);
|
|
460
|
+
newColumns[index] = __assign(__assign({}, newColumns[index]), { label: value });
|
|
353
461
|
setColumns(newColumns);
|
|
354
462
|
};
|
|
355
|
-
(
|
|
356
|
-
setChartConfig({
|
|
463
|
+
useEffect(function () {
|
|
464
|
+
setChartConfig(__assign(__assign({}, values), { yAxisFields: yAxisFields, rows: data }));
|
|
357
465
|
}, [values, yAxisFields]);
|
|
358
466
|
// console.log('VIBE: ', { report, values, yAxisFields, columns, query });
|
|
359
|
-
return ((
|
|
467
|
+
return (_jsx(Form, __assign({ style: { display: 'inline-block' } }, { children: _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsxs("div", __assign({ style: {
|
|
360
468
|
display: 'flex',
|
|
361
469
|
flexDirection: 'column',
|
|
362
|
-
}, children: [(
|
|
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: {
|
|
363
471
|
width: '100%',
|
|
364
472
|
height: 300,
|
|
365
|
-
} })) }), (
|
|
473
|
+
} })) })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
|
|
366
474
|
fontFamily: theme.fontFamily,
|
|
367
475
|
color: theme.primaryTextColor,
|
|
368
476
|
fontSize: theme.fontSize + 2,
|
|
369
477
|
fontWeight: 600,
|
|
370
478
|
marginTop: 20,
|
|
371
|
-
}, children: 'Chart' }), (
|
|
479
|
+
} }, { children: 'Chart' })), _jsxs("div", __assign({ style: {
|
|
372
480
|
display: 'flex',
|
|
373
481
|
flexDirection: 'row',
|
|
374
482
|
alignItems: 'center',
|
|
375
|
-
}, children: [(
|
|
483
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
376
484
|
fontSize: '14px',
|
|
377
485
|
marginBottom: '6px',
|
|
378
486
|
fontWeight: '600',
|
|
379
487
|
marginTop: 8,
|
|
380
488
|
color: theme.secondaryTextColor,
|
|
381
|
-
fontFamily: theme
|
|
382
|
-
}, children: "Name" }), (
|
|
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 || {
|
|
383
491
|
fontFamily: theme.fontFamily,
|
|
384
492
|
color: theme.secondaryTextColor,
|
|
385
493
|
fontSize: theme.fontSize,
|
|
386
494
|
fontWeight: theme.labelFontWeight,
|
|
387
495
|
marginTop: 8,
|
|
388
496
|
marginBottom: 6,
|
|
389
|
-
}, children: "Dashboard name" }), (
|
|
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 || {
|
|
390
498
|
fontFamily: theme.fontFamily,
|
|
391
499
|
color: theme.secondaryTextColor,
|
|
392
500
|
fontSize: theme.fontSize,
|
|
393
501
|
fontWeight: theme.labelFontWeight,
|
|
394
502
|
marginTop: 8,
|
|
395
|
-
}, children: "Chart type" }), (
|
|
503
|
+
} }, { children: "Chart type" })), _jsx("div", __assign({ style: { minWidth: 200 } }, { children: _jsx(Field, { name: "chartType", component: SelectComponent, theme: theme, options: [
|
|
396
504
|
{ label: 'bar', value: 'bar' },
|
|
397
505
|
{ label: 'line', value: 'line' },
|
|
398
506
|
{ label: 'column', value: 'column' },
|
|
399
507
|
{ label: 'pie', value: 'pie' },
|
|
400
508
|
{ label: 'metric', value: 'metric' },
|
|
401
509
|
{ label: 'table', value: 'table' },
|
|
402
|
-
] }) })] })] })] }), (
|
|
510
|
+
] }) }))] }))] }))] })), _jsx("div", __assign({ style: {
|
|
403
511
|
display: 'flex',
|
|
404
512
|
flexDirection: 'row',
|
|
405
513
|
alignItems: 'center',
|
|
406
514
|
// justifyContent: 'space-between',
|
|
407
515
|
marginTop: 20,
|
|
408
|
-
}, children: values.chartType !== 'table' && ((
|
|
516
|
+
} }, { children: values.chartType !== 'table' && (_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
409
517
|
fontFamily: theme.fontFamily,
|
|
410
518
|
color: theme.secondaryTextColor,
|
|
411
519
|
fontSize: theme.fontSize,
|
|
412
520
|
fontWeight: theme.labelFontWeight,
|
|
413
|
-
}, children: values.chartType === 'pie'
|
|
521
|
+
} }, { children: values.chartType === 'pie'
|
|
414
522
|
? 'Category column'
|
|
415
|
-
: 'x-axis column' }), (
|
|
523
|
+
: 'x-axis column' })), _jsx("div", { style: { height: 6 } }), _jsxs("div", __assign({ style: {
|
|
416
524
|
display: 'flex',
|
|
417
525
|
flexDirection: 'row',
|
|
418
526
|
alignItems: 'center',
|
|
419
|
-
}, children: [(
|
|
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: {
|
|
420
528
|
display: 'flex',
|
|
421
529
|
flexDirection: 'row',
|
|
422
530
|
alignItems: 'flex-start',
|
|
423
531
|
// justifyContent: 'space-between',
|
|
424
532
|
marginTop: 20,
|
|
425
|
-
}, children: [(
|
|
533
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
426
534
|
fontFamily: theme.fontFamily,
|
|
427
535
|
color: theme.secondaryTextColor,
|
|
428
536
|
fontSize: theme.fontSize,
|
|
429
537
|
fontWeight: theme.labelFontWeight,
|
|
430
538
|
minWidth: 200,
|
|
431
|
-
}, children: values.chartType === 'table'
|
|
539
|
+
} }, { children: values.chartType === 'table'
|
|
432
540
|
? 'Columns'
|
|
433
541
|
: values.chartType === 'pie'
|
|
434
542
|
? 'Quantity column'
|
|
435
|
-
: 'y-axis columns' }), (
|
|
543
|
+
: 'y-axis columns' })), _jsxs("div", __assign({ style: {
|
|
436
544
|
display: 'flex',
|
|
437
545
|
flexDirection: 'column',
|
|
438
|
-
}, children: [yAxisFields.map((yAxisField, index)
|
|
546
|
+
} }, { children: [yAxisFields.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
|
|
439
547
|
display: 'flex',
|
|
440
548
|
flexDirection: 'row',
|
|
441
549
|
alignItems: 'center',
|
|
442
550
|
marginTop: index === 0 ? 6 : 10,
|
|
443
|
-
}, children: (
|
|
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: {
|
|
444
552
|
display: 'flex',
|
|
445
553
|
flexDirection: 'column',
|
|
446
554
|
justifyContent: 'flex-start',
|
|
447
|
-
}, children: [(
|
|
555
|
+
} }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
448
556
|
fontFamily: theme.fontFamily,
|
|
449
557
|
color: 'transparent',
|
|
450
558
|
fontSize: theme.fontSize,
|
|
451
559
|
fontWeight: theme.labelFontWeight,
|
|
452
560
|
minWidth: 200,
|
|
453
561
|
// marginBottom: 10,
|
|
454
|
-
}, children: "y-axis label" }), values.chartType !== 'pie' &&
|
|
455
|
-
yAxisFields.map((yAxisField, index)
|
|
562
|
+
} }, { children: "y-axis label" })), values.chartType !== 'pie' &&
|
|
563
|
+
yAxisFields.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
|
|
456
564
|
display: 'flex',
|
|
457
565
|
flexDirection: 'row',
|
|
458
566
|
alignItems: 'center',
|
|
459
567
|
marginTop: index === 0 ? 6 : 10,
|
|
460
|
-
}, children: [(
|
|
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: {
|
|
461
575
|
cursor: index > 0 ? 'pointer' : undefined,
|
|
462
576
|
paddingLeft: 6,
|
|
463
577
|
paddingTop: 12,
|
|
@@ -467,52 +581,58 @@ function FormikForm({ values, isSubmitting, data, fieldOptions, dateFieldOptions
|
|
|
467
581
|
display: 'flex',
|
|
468
582
|
alignItems: 'center',
|
|
469
583
|
justifyContent: 'center',
|
|
470
|
-
}, children: (
|
|
584
|
+
} }, { children: _jsx(XMarkIcon, { style: {
|
|
471
585
|
height: '20px',
|
|
472
586
|
width: '20px',
|
|
473
587
|
color: index > 0
|
|
474
|
-
? theme
|
|
588
|
+
? theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor
|
|
475
589
|
: 'rgba(0,0,0,0)',
|
|
476
|
-
}, "aria-hidden": "true" }) })] },
|
|
590
|
+
}, "aria-hidden": "true" }) }))] }), "yAxisField-".concat(index))); })] }))] })), _jsx("div", { style: { height: 20 } }), _jsx("div", __assign({ style: formHeaderStyle || {
|
|
477
591
|
fontFamily: theme.fontFamily,
|
|
478
592
|
color: theme.primaryTextColor,
|
|
479
593
|
fontSize: theme.fontSize + 2,
|
|
480
594
|
fontWeight: 600,
|
|
481
|
-
}, children: 'Table' }), (
|
|
595
|
+
} }, { children: 'Table' })), _jsxs("div", __assign({ style: {
|
|
482
596
|
display: 'flex',
|
|
483
597
|
flexDirection: 'row',
|
|
484
598
|
alignItems: 'flex-start',
|
|
485
599
|
// justifyContent: 'space-between',
|
|
486
600
|
// marginTop: 8,
|
|
487
|
-
}, children: [(
|
|
601
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
488
602
|
fontFamily: theme.fontFamily,
|
|
489
603
|
color: theme.secondaryTextColor,
|
|
490
604
|
fontSize: theme.fontSize,
|
|
491
605
|
fontWeight: theme.labelFontWeight,
|
|
492
|
-
}, children: 'Columns' }), (
|
|
606
|
+
} }, { children: 'Columns' })), _jsxs("div", __assign({ style: {
|
|
493
607
|
display: 'flex',
|
|
494
608
|
flexDirection: 'column',
|
|
495
|
-
}, children: [columns.map((yAxisField, index)
|
|
609
|
+
} }, { children: [columns.map(function (yAxisField, index) { return (_jsx("div", __assign({ style: {
|
|
496
610
|
display: 'flex',
|
|
497
611
|
flexDirection: 'row',
|
|
498
612
|
alignItems: 'center',
|
|
499
613
|
marginTop: index === 0 ? 6 : 10,
|
|
500
|
-
}, children: (
|
|
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: {
|
|
501
617
|
display: 'flex',
|
|
502
618
|
flexDirection: 'column',
|
|
503
619
|
justifyContent: 'flex-start',
|
|
504
|
-
}, children: [(
|
|
620
|
+
} }, { children: [_jsx("div", __assign({ style: formLabelStyle || {
|
|
505
621
|
fontFamily: theme.fontFamily,
|
|
506
622
|
color: 'transparent',
|
|
507
623
|
fontSize: theme.fontSize,
|
|
508
624
|
fontWeight: theme.labelFontWeight,
|
|
509
625
|
minWidth: 200,
|
|
510
626
|
// marginBottom: 10,
|
|
511
|
-
}, children: "label" }), columns.map((yAxisField, index)
|
|
627
|
+
} }, { children: "label" })), columns.map(function (yAxisField, index) { return (_jsxs("div", __assign({ style: {
|
|
512
628
|
display: 'flex',
|
|
513
629
|
flexDirection: 'row',
|
|
514
630
|
alignItems: 'center',
|
|
515
631
|
marginTop: index === 0 ? 6 : 10,
|
|
516
|
-
}, children: [(
|
|
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' })] })) })));
|
|
517
637
|
}
|
|
518
638
|
//# sourceMappingURL=AddToDashboardModal.js.map
|