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