@quillsql/react 1.5.4 → 1.5.5
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/ReportBuilder.d.ts +21 -1
- package/lib/ReportBuilder.js +1045 -221
- package/lib/ReportBuilder.js.map +1 -1
- package/lib/SQLEditor.d.ts +11 -0
- package/lib/SQLEditor.js +597 -0
- package/lib/SQLEditor.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/package.json +4 -1
- package/src/ReportBuilder.tsx +2208 -0
- package/src/SQLEditor.tsx +841 -0
- package/src/index.ts +2 -0
package/lib/ReportBuilder.js
CHANGED
|
@@ -45,17 +45,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
49
|
-
var t = {};
|
|
50
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
51
|
-
t[p] = s[p];
|
|
52
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
53
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
54
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
55
|
-
t[p[i]] = s[p[i]];
|
|
56
|
-
}
|
|
57
|
-
return t;
|
|
58
|
-
};
|
|
59
48
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
60
49
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
61
50
|
if (ar || !(i in from)) {
|
|
@@ -65,40 +54,43 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
65
54
|
}
|
|
66
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
67
56
|
};
|
|
68
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
57
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
58
|
+
import { useState, useContext, useCallback, useEffect, useRef, } from 'react';
|
|
59
|
+
// import './nightOwlLight.css';
|
|
72
60
|
import axios from 'axios';
|
|
73
|
-
import { ClientContext, } from './Context';
|
|
74
|
-
|
|
61
|
+
import { ClientContext, SchemaContext, ThemeContext } from './Context';
|
|
62
|
+
import { XMarkIcon, CheckIcon, } from '@heroicons/react/20/solid';
|
|
63
|
+
import { convertPostgresColumn } from './SQLEditor';
|
|
64
|
+
import { format } from 'date-fns';
|
|
65
|
+
export default function ReportBuilder(_a) {
|
|
75
66
|
var _this = this;
|
|
76
|
-
var
|
|
67
|
+
var onChangeQuery = _a.onChangeQuery, onChangeData = _a.onChangeData, onChangeColumns = _a.onChangeColumns, onChangeLoading = _a.onChangeLoading, onError = _a.onError, SelectComponent = _a.SelectComponent;
|
|
77
68
|
var _b = useState([]), data = _b[0], setData = _b[1];
|
|
78
69
|
var client = useContext(ClientContext)[0];
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
var
|
|
70
|
+
var _c = useContext(SchemaContext), schema = _c[0], setSchema = _c[1];
|
|
71
|
+
var theme = useContext(ThemeContext)[0];
|
|
72
|
+
var _d = useState([]), columns = _d[0], setColumns = _d[1];
|
|
73
|
+
var _e = useState([]), fields = _e[0], setFields = _e[1];
|
|
83
74
|
useEffect(function () {
|
|
84
75
|
function getData(schema) {
|
|
85
76
|
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
-
var
|
|
77
|
+
var publicKey, customerId, environment, response;
|
|
87
78
|
return __generator(this, function (_a) {
|
|
88
79
|
switch (_a.label) {
|
|
89
80
|
case 0:
|
|
90
81
|
if (!(schema.length && !data.length)) return [3 /*break*/, 2];
|
|
91
|
-
|
|
92
|
-
return [4 /*yield*/, axios.post(
|
|
93
|
-
query: "select * from ".concat(schema[0].
|
|
82
|
+
publicKey = client.publicKey, customerId = client.customerId, environment = client.environment;
|
|
83
|
+
return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashquery", {
|
|
84
|
+
query: "select * from ".concat(schema[0].displayName, " limit 10;"),
|
|
94
85
|
}, {
|
|
95
|
-
params:
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
:
|
|
101
|
-
|
|
86
|
+
params: {
|
|
87
|
+
orgId: customerId,
|
|
88
|
+
publicKey: publicKey,
|
|
89
|
+
},
|
|
90
|
+
headers: {
|
|
91
|
+
Authorization: "Bearer ",
|
|
92
|
+
environment: environment || undefined,
|
|
93
|
+
},
|
|
102
94
|
})];
|
|
103
95
|
case 1:
|
|
104
96
|
response = _a.sent();
|
|
@@ -111,42 +103,132 @@ function ReportBuilder(_a) {
|
|
|
111
103
|
}
|
|
112
104
|
getData(schema);
|
|
113
105
|
}, [schema]);
|
|
106
|
+
useEffect(function () {
|
|
107
|
+
var isSubscribed = true;
|
|
108
|
+
function getSchema() {
|
|
109
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
110
|
+
var publicKey, environment, response3;
|
|
111
|
+
return __generator(this, function (_a) {
|
|
112
|
+
switch (_a.label) {
|
|
113
|
+
case 0:
|
|
114
|
+
publicKey = client.publicKey, environment = client.environment;
|
|
115
|
+
return [4 /*yield*/, axios.get("https://quill-344421.uc.r.appspot.com/schema2/".concat(publicKey, "/"), {
|
|
116
|
+
headers: {
|
|
117
|
+
Authorization: "Bearer ",
|
|
118
|
+
environment: environment || undefined,
|
|
119
|
+
},
|
|
120
|
+
})];
|
|
121
|
+
case 1:
|
|
122
|
+
response3 = _a.sent();
|
|
123
|
+
if (isSubscribed) {
|
|
124
|
+
setSchema(response3.data.tables);
|
|
125
|
+
}
|
|
126
|
+
return [2 /*return*/];
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
if (isSubscribed) {
|
|
132
|
+
getSchema();
|
|
133
|
+
}
|
|
134
|
+
return function () {
|
|
135
|
+
isSubscribed = false;
|
|
136
|
+
};
|
|
137
|
+
}, []);
|
|
114
138
|
var runQuery = function (query) { return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
-
var
|
|
139
|
+
var publicKey, customerId, environment, response;
|
|
116
140
|
return __generator(this, function (_a) {
|
|
117
141
|
switch (_a.label) {
|
|
118
142
|
case 0:
|
|
119
|
-
|
|
120
|
-
return [4 /*yield*/, axios.post(
|
|
143
|
+
publicKey = client.publicKey, customerId = client.customerId, environment = client.environment;
|
|
144
|
+
return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashquery", {
|
|
121
145
|
query: query,
|
|
122
146
|
}, {
|
|
123
147
|
params: {
|
|
124
|
-
orgId:
|
|
125
|
-
publicKey:
|
|
148
|
+
orgId: customerId,
|
|
149
|
+
publicKey: publicKey,
|
|
150
|
+
},
|
|
151
|
+
headers: {
|
|
152
|
+
Authorization: "Bearer ",
|
|
153
|
+
environment: environment || undefined,
|
|
126
154
|
},
|
|
127
|
-
headers: queryHeaders,
|
|
128
155
|
})];
|
|
129
156
|
case 1:
|
|
130
157
|
response = _a.sent();
|
|
158
|
+
if (response && response.data && response.data.errorMessage) {
|
|
159
|
+
onError(response.data.errorMessage);
|
|
160
|
+
setData([]);
|
|
161
|
+
onChangeData([]);
|
|
162
|
+
setColumns([]);
|
|
163
|
+
onChangeColumns([]);
|
|
164
|
+
setFields([]);
|
|
165
|
+
return [2 /*return*/];
|
|
166
|
+
}
|
|
131
167
|
setData(response.data.rows);
|
|
168
|
+
onChangeData(response.data.rows);
|
|
132
169
|
setColumns(response.data.fields.map(function (elem) { return convertPostgresColumn(elem); }));
|
|
170
|
+
onChangeColumns(response.data.fields.map(function (elem) { return convertPostgresColumn(elem); }));
|
|
133
171
|
setFields(response.data.fields);
|
|
134
172
|
return [2 /*return*/];
|
|
135
173
|
}
|
|
136
174
|
});
|
|
137
175
|
}); };
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
176
|
+
if (!schema.length) {
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
return (_jsx(ReportingTool, { theme: theme, data: data, schema: schema, onChangeQuery: onChangeQuery, runQuery: runQuery, SelectComponent: SelectComponent }));
|
|
180
|
+
}
|
|
181
|
+
export function getPostgresBasicType(column) {
|
|
182
|
+
var format;
|
|
183
|
+
// first check if column.dataTypeID exists
|
|
184
|
+
if (column.dataTypeID) {
|
|
185
|
+
switch (column.dataTypeID) {
|
|
186
|
+
case 20: // int8
|
|
187
|
+
case 21: // int2
|
|
188
|
+
case 23: // int4
|
|
189
|
+
case 700: // float4
|
|
190
|
+
case 701: // float8
|
|
191
|
+
case 1700: // numeric
|
|
192
|
+
format = 'number';
|
|
193
|
+
break;
|
|
194
|
+
case 1082: // date
|
|
195
|
+
case 1083: // time
|
|
196
|
+
case 1184: // timestamptz
|
|
197
|
+
case 1114: // timestamp
|
|
198
|
+
format = 'date';
|
|
199
|
+
break;
|
|
200
|
+
case 1043: // varchar
|
|
201
|
+
default:
|
|
202
|
+
format = 'string';
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (column.fieldType) {
|
|
206
|
+
// if column.dataTypeID doesn't exist, check column.fieldType
|
|
207
|
+
switch (column.fieldType) {
|
|
208
|
+
case 'int8':
|
|
209
|
+
case 'int2':
|
|
210
|
+
case 'int4':
|
|
211
|
+
case 'float4':
|
|
212
|
+
case 'float8':
|
|
213
|
+
case 'numeric':
|
|
214
|
+
format = 'number';
|
|
215
|
+
break;
|
|
216
|
+
case 'date':
|
|
217
|
+
case 'time':
|
|
218
|
+
case 'timestamptz':
|
|
219
|
+
case 'timestamp':
|
|
220
|
+
format = 'date';
|
|
221
|
+
break;
|
|
222
|
+
case 'varchar':
|
|
223
|
+
default:
|
|
224
|
+
format = 'string';
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return format;
|
|
146
228
|
}
|
|
147
229
|
function ReportingTool(_a) {
|
|
148
230
|
var _this = this;
|
|
149
|
-
var schema = _a.schema, data = _a.data, runQuery = _a.runQuery;
|
|
231
|
+
var schema = _a.schema, data = _a.data, runQuery = _a.runQuery, SelectComponent = _a.SelectComponent, onChangeQuery = _a.onChangeQuery, theme = _a.theme;
|
|
150
232
|
var _b = useState(schema[0]), selectedTable = _b[0], setSelectedTable = _b[1];
|
|
151
233
|
var _c = useState(schema[0].columns[0]), selectedColumn = _c[0], setSelectedColumn = _c[1];
|
|
152
234
|
var _d = useState([]), filters = _d[0], setFilters = _d[1];
|
|
@@ -157,7 +239,7 @@ function ReportingTool(_a) {
|
|
|
157
239
|
distinct: { type: null },
|
|
158
240
|
columns: '*',
|
|
159
241
|
into: { position: null },
|
|
160
|
-
from: [{ db: null, table: schema[0].
|
|
242
|
+
from: [{ db: null, table: schema[0].displayName, as: null }],
|
|
161
243
|
where: null,
|
|
162
244
|
groupby: null,
|
|
163
245
|
having: null,
|
|
@@ -172,24 +254,29 @@ function ReportingTool(_a) {
|
|
|
172
254
|
var _k = useState({}), computedColumns = _k[0], setComputedColumns = _k[1];
|
|
173
255
|
var _l = useState([]), stringFilterValues = _l[0], setStringFilterValues = _l[1];
|
|
174
256
|
var _m = useState(getPostgresBasicType(schema[0].columns[0])), columnType = _m[0], setColumnType = _m[1];
|
|
257
|
+
var _o = useState(''), sqlQuery = _o[0], setSqlQuery = _o[1];
|
|
175
258
|
// month | week | day | quarter
|
|
176
|
-
var
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
var
|
|
180
|
-
var
|
|
181
|
-
var
|
|
182
|
-
var
|
|
183
|
-
var
|
|
184
|
-
var
|
|
259
|
+
var _p = useState('month'), dateBucket = _p[0], setDateBucket = _p[1];
|
|
260
|
+
var _q = useState(-1), indexBeingEdited = _q[0], setIndexBeingEdited = _q[1];
|
|
261
|
+
var _r = useState([]), groupBys = _r[0], setGroupBys = _r[1];
|
|
262
|
+
var _s = useState([]), aggregations = _s[0], setAggregations = _s[1];
|
|
263
|
+
var _t = useState(schema[0].columns[0]), selectedGroupByColumn = _t[0], setSelectedGroupByColumn = _t[1];
|
|
264
|
+
var _u = useState(getPostgresBasicType(schema[0].columns[0])), groupByColumnType = _u[0], setGroupByColumnType = _u[1];
|
|
265
|
+
var _v = useState(schema[0].columns[0].name), selectedSortByColumn = _v[0], setSelectedSortByColumn = _v[1];
|
|
266
|
+
var _w = useState([]), sortBys = _w[0], setSortBys = _w[1];
|
|
267
|
+
var _x = useState('ascending'), selectedSortByDirection = _x[0], setSelectedSortByDirection = _x[1];
|
|
268
|
+
var _y = useState(-1), groupByIndexBeingEdited = _y[0], setGroupByIndexBeingEdited = _y[1];
|
|
269
|
+
var _z = useState(-1), sortByIndexBeingEdited = _z[0], setSortByIndexBeingEdited = _z[1];
|
|
270
|
+
var _0 = useState(schema[0].columns.map(function (col) { return col.name; })), sortableColumns = _0[0], setSortableColumns = _0[1];
|
|
185
271
|
var addGroupBy = function () {
|
|
186
272
|
if (selectedGroupByColumn && groupByColumnType) {
|
|
187
273
|
if (groupByColumnType === 'string') {
|
|
188
274
|
setGroupBys(function (groupBys) {
|
|
189
275
|
return __spreadArray(__spreadArray([], groupBys, true), [
|
|
190
276
|
{
|
|
191
|
-
column:
|
|
192
|
-
columnType:
|
|
277
|
+
column: selectedGroupByColumn.name,
|
|
278
|
+
columnType: groupByColumnType,
|
|
279
|
+
tag: selectedGroupByColumn.name,
|
|
193
280
|
},
|
|
194
281
|
], false);
|
|
195
282
|
});
|
|
@@ -203,28 +290,65 @@ function ReportingTool(_a) {
|
|
|
203
290
|
setGroupBys(function (groupBys) {
|
|
204
291
|
return __spreadArray(__spreadArray([], groupBys, true), [
|
|
205
292
|
{
|
|
206
|
-
column:
|
|
207
|
-
columnType:
|
|
293
|
+
column: selectedGroupByColumn.name,
|
|
294
|
+
columnType: groupByColumnType,
|
|
208
295
|
bucket: dateBucket,
|
|
296
|
+
tag: dateBucket,
|
|
209
297
|
},
|
|
210
298
|
], false);
|
|
211
299
|
});
|
|
212
|
-
setDateBucket('month');
|
|
213
300
|
return;
|
|
214
301
|
}
|
|
215
302
|
}
|
|
216
303
|
};
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
304
|
+
var addSortBy = function () {
|
|
305
|
+
setSortBys(function (sortBys) {
|
|
306
|
+
return __spreadArray(__spreadArray([], sortBys, true), [
|
|
307
|
+
{
|
|
308
|
+
column: selectedSortByColumn,
|
|
309
|
+
direction: selectedSortByDirection,
|
|
310
|
+
},
|
|
311
|
+
], false);
|
|
224
312
|
});
|
|
225
|
-
}
|
|
313
|
+
};
|
|
314
|
+
var removeSortBy = function (index) {
|
|
315
|
+
setSortBys(function (oldSortBys) {
|
|
316
|
+
var newSortBys = __spreadArray([], oldSortBys, true);
|
|
317
|
+
newSortBys.splice(index, 1);
|
|
318
|
+
return newSortBys;
|
|
319
|
+
});
|
|
320
|
+
setSortByIndexBeingEdited(-1);
|
|
321
|
+
};
|
|
322
|
+
var removeGroupBy = function (index) {
|
|
323
|
+
var columnBeingDeleted = groupBys[index].tag;
|
|
324
|
+
setSortBys(function (oldSortBys) {
|
|
325
|
+
var newSortBys = __spreadArray([], oldSortBys.filter(function (sortBy) { return sortBy.column !== columnBeingDeleted; }), true);
|
|
326
|
+
return newSortBys;
|
|
327
|
+
});
|
|
328
|
+
setGroupBys(function (oldGroupBys) {
|
|
329
|
+
var newGroupBys = __spreadArray([], oldGroupBys, true);
|
|
330
|
+
newGroupBys.splice(index, 1);
|
|
331
|
+
return newGroupBys;
|
|
332
|
+
});
|
|
333
|
+
setGroupByIndexBeingEdited(-1);
|
|
334
|
+
};
|
|
335
|
+
var updateSortBy = function (index) {
|
|
336
|
+
if (selectedSortByColumn && selectedSortByDirection) {
|
|
337
|
+
setSortBys(function (sortBys) {
|
|
338
|
+
var newSortBys = __spreadArray([], sortBys, true);
|
|
339
|
+
newSortBys[index] = {
|
|
340
|
+
column: selectedSortByColumn,
|
|
341
|
+
direction: selectedSortByDirection,
|
|
342
|
+
};
|
|
343
|
+
return newSortBys;
|
|
344
|
+
});
|
|
345
|
+
setSortByIndexBeingEdited(-1);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
};
|
|
226
349
|
useEffect(function () {
|
|
227
350
|
setColumnType(getPostgresBasicType(selectedColumn));
|
|
351
|
+
// console.log("WTF: ", selectedColumn);
|
|
228
352
|
}, [selectedColumn]);
|
|
229
353
|
useEffect(function () {
|
|
230
354
|
setGroupByColumnType(getPostgresBasicType(selectedGroupByColumn));
|
|
@@ -247,12 +371,57 @@ function ReportingTool(_a) {
|
|
|
247
371
|
setDateEnd(filter.dateEnd);
|
|
248
372
|
setIndexBeingEdited(index);
|
|
249
373
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
374
|
+
};
|
|
375
|
+
var selectSortBy = function (index) {
|
|
376
|
+
var sortBy = sortBys[index];
|
|
377
|
+
setSelectedSortByColumn(sortBy.column);
|
|
378
|
+
setSelectedSortByDirection(sortBy.direction);
|
|
379
|
+
setSortByIndexBeingEdited(index);
|
|
380
|
+
};
|
|
381
|
+
var selectGroupBy = function (index) {
|
|
382
|
+
var groupBy = groupBys[index];
|
|
383
|
+
var matchingColumn = selectedTable.columns.find(function (column) { return column.name === groupBy.column; });
|
|
384
|
+
setSelectedGroupByColumn(matchingColumn);
|
|
385
|
+
if (groupBy.bucket) {
|
|
386
|
+
setDateBucket(groupBy.bucket);
|
|
387
|
+
}
|
|
388
|
+
setGroupByIndexBeingEdited(index);
|
|
389
|
+
};
|
|
390
|
+
var updateGroupBy = function (index) {
|
|
391
|
+
if (selectedGroupByColumn && groupByColumnType) {
|
|
392
|
+
// if column changed, then auto delete the sort using that column
|
|
393
|
+
var columnBeingDeleted_1 = selectedGroupByColumn.name !== groupBys[index].column
|
|
394
|
+
? groupBys[index].tag
|
|
395
|
+
: 'nocolumnbeingdeleted';
|
|
396
|
+
setSortBys(function (oldSortBys) {
|
|
397
|
+
var newSortBys = __spreadArray([], oldSortBys.filter(function (sortBy) { return sortBy.column !== columnBeingDeleted_1; }), true);
|
|
398
|
+
return newSortBys;
|
|
399
|
+
});
|
|
400
|
+
if (groupByColumnType === 'date') {
|
|
401
|
+
setGroupBys(function (groupBys) {
|
|
402
|
+
var newGroupBys = __spreadArray([], groupBys, true);
|
|
403
|
+
newGroupBys[index] = {
|
|
404
|
+
column: selectedGroupByColumn.name,
|
|
405
|
+
columnType: groupByColumnType,
|
|
406
|
+
bucket: dateBucket,
|
|
407
|
+
tag: dateBucket,
|
|
408
|
+
};
|
|
409
|
+
return newGroupBys;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
setGroupBys(function (groupBys) {
|
|
414
|
+
var newGroupBys = __spreadArray([], groupBys, true);
|
|
415
|
+
newGroupBys[index] = {
|
|
416
|
+
column: selectedGroupByColumn.name,
|
|
417
|
+
columnType: groupByColumnType,
|
|
418
|
+
tag: selectedGroupByColumn.name,
|
|
419
|
+
};
|
|
420
|
+
return newGroupBys;
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
setGroupByIndexBeingEdited(-1);
|
|
424
|
+
return;
|
|
256
425
|
}
|
|
257
426
|
};
|
|
258
427
|
var updateFilter = function (index) {
|
|
@@ -260,7 +429,6 @@ function ReportingTool(_a) {
|
|
|
260
429
|
if (columnType === 'string') {
|
|
261
430
|
setFilters(function (filters) {
|
|
262
431
|
var newFilters = __spreadArray([], filters, true);
|
|
263
|
-
console.log('INDEX: ', index);
|
|
264
432
|
newFilters[index] = {
|
|
265
433
|
column: selectedColumn.name,
|
|
266
434
|
columnType: columnType,
|
|
@@ -273,7 +441,6 @@ function ReportingTool(_a) {
|
|
|
273
441
|
else if (columnType === 'number') {
|
|
274
442
|
setFilters(function (filters) {
|
|
275
443
|
var newFilters = __spreadArray([], filters, true);
|
|
276
|
-
console.log('INDEX: ', index);
|
|
277
444
|
newFilters[index] = {
|
|
278
445
|
column: selectedColumn.name,
|
|
279
446
|
columnType: columnType,
|
|
@@ -368,22 +535,88 @@ function ReportingTool(_a) {
|
|
|
368
535
|
}
|
|
369
536
|
}
|
|
370
537
|
};
|
|
538
|
+
var setAggregationColumn = function (column, index) {
|
|
539
|
+
// ex
|
|
540
|
+
setAggregations(function (aggregations) {
|
|
541
|
+
var newAggregations = __spreadArray([], aggregations, true);
|
|
542
|
+
newAggregations[index] = __assign(__assign({}, newAggregations[index]), { column: column });
|
|
543
|
+
return newAggregations;
|
|
544
|
+
});
|
|
545
|
+
};
|
|
546
|
+
var setAggregationType = function (aggregationType, index) {
|
|
547
|
+
// ex
|
|
548
|
+
setAggregations(function (aggregations) {
|
|
549
|
+
var newAggregations = __spreadArray([], aggregations, true);
|
|
550
|
+
newAggregations[index] = __assign(__assign({}, newAggregations[index]), { aggregationType: aggregationType });
|
|
551
|
+
return newAggregations;
|
|
552
|
+
});
|
|
553
|
+
};
|
|
554
|
+
var addAggregation = function () {
|
|
555
|
+
// setAggregations([
|
|
556
|
+
// {
|
|
557
|
+
// column: selectedTable.columns.filter(
|
|
558
|
+
// (col) => getPostgresBasicType(col) === "number"
|
|
559
|
+
// )[0],
|
|
560
|
+
// aggregationType: "sum",
|
|
561
|
+
// },
|
|
562
|
+
// ]);
|
|
563
|
+
setAggregations(function (aggregations) {
|
|
564
|
+
var newAggregations = __spreadArray(__spreadArray([], aggregations, true), [
|
|
565
|
+
{
|
|
566
|
+
column: selectedTable.columns.filter(function (col) {
|
|
567
|
+
return getPostgresBasicType(col) === 'number' &&
|
|
568
|
+
!aggregations.map(function (elem) { return elem.name; }).includes(col.name);
|
|
569
|
+
})[0],
|
|
570
|
+
aggregationType: 'sum',
|
|
571
|
+
},
|
|
572
|
+
], false);
|
|
573
|
+
return newAggregations;
|
|
574
|
+
});
|
|
575
|
+
};
|
|
576
|
+
useEffect(function () {
|
|
577
|
+
// if selected table changes, clear everything
|
|
578
|
+
if (selectedTable.displayName !== AST.from.table) {
|
|
579
|
+
setSelectedColumn(selectedTable.columns[0]);
|
|
580
|
+
setSortableColumns(selectedTable.columns.map(function (col) { return col.name; }));
|
|
581
|
+
setGroupBys([]);
|
|
582
|
+
setSortBys([]);
|
|
583
|
+
setFilters([]);
|
|
584
|
+
// setAST((AST) => {
|
|
585
|
+
// return {
|
|
586
|
+
// with: null,
|
|
587
|
+
// type: "select",
|
|
588
|
+
// options: null,
|
|
589
|
+
// distinct: { type: null },
|
|
590
|
+
// columns: "*",
|
|
591
|
+
// into: { position: null },
|
|
592
|
+
// where: null,
|
|
593
|
+
// groupby: null,
|
|
594
|
+
// having: null,
|
|
595
|
+
// orderby: null,
|
|
596
|
+
// limit: { seperator: "", value: [] },
|
|
597
|
+
// window: null,
|
|
598
|
+
// from: [{ db: null, table: selectedTable.displayName, as: null }],
|
|
599
|
+
// };
|
|
600
|
+
// });
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
}, [selectedTable]);
|
|
371
604
|
// USE EFFECT HOOK THAT TRANSFORMS "FILTERS ARRAY INTO AST"
|
|
372
605
|
useEffect(function () {
|
|
373
|
-
if (filters.length ||
|
|
606
|
+
if (filters.length || groupBys.length || aggregations.length) {
|
|
374
607
|
var newAST = {
|
|
375
608
|
with: null,
|
|
376
609
|
type: 'select',
|
|
377
610
|
options: null,
|
|
378
|
-
distinct:
|
|
379
|
-
columns:
|
|
611
|
+
distinct: null,
|
|
612
|
+
columns: null,
|
|
380
613
|
into: { position: null },
|
|
381
|
-
from: [{ db: null, table:
|
|
614
|
+
from: [{ db: null, table: selectedTable.displayName, as: null }],
|
|
382
615
|
where: null,
|
|
383
616
|
groupby: null,
|
|
384
617
|
having: null,
|
|
385
618
|
orderby: null,
|
|
386
|
-
limit:
|
|
619
|
+
limit: null,
|
|
387
620
|
window: null,
|
|
388
621
|
};
|
|
389
622
|
// FILTERS
|
|
@@ -452,31 +685,166 @@ function ReportingTool(_a) {
|
|
|
452
685
|
};
|
|
453
686
|
}
|
|
454
687
|
if (!newAST.where) {
|
|
455
|
-
newAST =
|
|
688
|
+
newAST.where = newCondition;
|
|
456
689
|
}
|
|
457
690
|
else {
|
|
458
|
-
newAST =
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
691
|
+
newAST.where = {
|
|
692
|
+
type: 'binary_expr',
|
|
693
|
+
operator: 'AND',
|
|
694
|
+
left: newAST.where,
|
|
695
|
+
right: newCondition,
|
|
696
|
+
};
|
|
464
697
|
}
|
|
465
698
|
}
|
|
699
|
+
// GROUP BYS and AGGREGATIONS
|
|
700
|
+
// if (groupBys.length > 0) {
|
|
701
|
+
// newAST.groupby = groupBys.map((groupBy) => ({
|
|
702
|
+
// type: "column_ref",
|
|
703
|
+
// table: null,
|
|
704
|
+
// column: groupBy.column,
|
|
705
|
+
// }));
|
|
706
|
+
// if (aggregations.length > 0) {
|
|
707
|
+
// newAST.columns = [
|
|
708
|
+
// ...groupBys.map((groupBy) => ({
|
|
709
|
+
// expr: {
|
|
710
|
+
// type: "column_ref",
|
|
711
|
+
// table: null,
|
|
712
|
+
// column: groupBy.column,
|
|
713
|
+
// },
|
|
714
|
+
// as: null,
|
|
715
|
+
// })),
|
|
716
|
+
// ...aggregations.map((aggregation) => ({
|
|
717
|
+
// expr: {
|
|
718
|
+
// type: "aggr_func",
|
|
719
|
+
// name: aggregation.aggregationType.toUpperCase(),
|
|
720
|
+
// args: {
|
|
721
|
+
// expr: {
|
|
722
|
+
// type: "column_ref",
|
|
723
|
+
// table: null,
|
|
724
|
+
// column: aggregation.column.name,
|
|
725
|
+
// },
|
|
726
|
+
// },
|
|
727
|
+
// over: null,
|
|
728
|
+
// },
|
|
729
|
+
// as: null,
|
|
730
|
+
// })),
|
|
731
|
+
// ];
|
|
732
|
+
// } else {
|
|
733
|
+
// newAST.columns = groupBys.map((groupBy) => ({
|
|
734
|
+
// expr: {
|
|
735
|
+
// type: "column_ref",
|
|
736
|
+
// table: null,
|
|
737
|
+
// column: groupBy.column,
|
|
738
|
+
// },
|
|
739
|
+
// as: null,
|
|
740
|
+
// }));
|
|
741
|
+
// }
|
|
742
|
+
// } else {
|
|
743
|
+
// newAST.columns = "*";
|
|
744
|
+
// newAST.groupby = null;
|
|
745
|
+
// }
|
|
466
746
|
// GROUP BYS
|
|
747
|
+
if (groupBys.length > 0) {
|
|
748
|
+
newAST.columns = [];
|
|
749
|
+
newAST.groupby = [];
|
|
750
|
+
for (var i = 0; i < groupBys.length; i++) {
|
|
751
|
+
var groupBy = groupBys[i];
|
|
752
|
+
if (groupBy.columnType === 'date') {
|
|
753
|
+
newAST.columns.push({
|
|
754
|
+
expr: {
|
|
755
|
+
type: 'function',
|
|
756
|
+
name: 'date_trunc',
|
|
757
|
+
args: {
|
|
758
|
+
type: 'expr_list',
|
|
759
|
+
value: [
|
|
760
|
+
{
|
|
761
|
+
type: 'single_quote_string',
|
|
762
|
+
value: groupBy.bucket,
|
|
763
|
+
},
|
|
764
|
+
{
|
|
765
|
+
type: 'column_ref',
|
|
766
|
+
table: null,
|
|
767
|
+
column: groupBy.column,
|
|
768
|
+
},
|
|
769
|
+
],
|
|
770
|
+
},
|
|
771
|
+
over: null,
|
|
772
|
+
},
|
|
773
|
+
as: groupBy.bucket,
|
|
774
|
+
});
|
|
775
|
+
newAST.groupby.push({
|
|
776
|
+
type: 'column_ref',
|
|
777
|
+
table: null,
|
|
778
|
+
column: groupBy.bucket,
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
newAST.columns.push({
|
|
783
|
+
expr: {
|
|
784
|
+
type: 'column_ref',
|
|
785
|
+
table: null,
|
|
786
|
+
column: groupBy.column,
|
|
787
|
+
},
|
|
788
|
+
as: null,
|
|
789
|
+
});
|
|
790
|
+
newAST.groupby.push({
|
|
791
|
+
type: 'column_ref',
|
|
792
|
+
table: null,
|
|
793
|
+
column: groupBy.column,
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
// AGGREGATIONS
|
|
798
|
+
if (aggregations.length > 0) {
|
|
799
|
+
for (var i = 0; i < aggregations.length; i++) {
|
|
800
|
+
var aggregation = aggregations[i];
|
|
801
|
+
newAST.columns.push({
|
|
802
|
+
expr: {
|
|
803
|
+
type: 'aggr_func',
|
|
804
|
+
name: aggregation.aggregationType.toUpperCase(),
|
|
805
|
+
args: {
|
|
806
|
+
expr: {
|
|
807
|
+
type: 'column_ref',
|
|
808
|
+
table: null,
|
|
809
|
+
column: aggregation.column.name,
|
|
810
|
+
},
|
|
811
|
+
},
|
|
812
|
+
over: null,
|
|
813
|
+
},
|
|
814
|
+
as: null,
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
else {
|
|
820
|
+
newAST.columns = '*';
|
|
821
|
+
newAST.groupby = null;
|
|
822
|
+
}
|
|
823
|
+
if (sortBys.length > 0) {
|
|
824
|
+
newAST.orderby = [];
|
|
825
|
+
for (var i = 0; i < sortBys.length; i++) {
|
|
826
|
+
var sortBy = sortBys[i];
|
|
827
|
+
newAST.orderby.push({
|
|
828
|
+
expr: { type: 'column_ref', table: null, column: sortBy.column },
|
|
829
|
+
type: sortBy.direction === 'descending' ? 'DESC' : 'ASC',
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
// "orderby":[{"expr":{"type":"column_ref","table":null,"column":"amount"},"type":"DESC"},{"expr":{"type":"column_ref","table":null,"column":"month"},"type":"ASC"}]
|
|
833
|
+
}
|
|
467
834
|
setAST(newAST);
|
|
468
835
|
}
|
|
469
|
-
}, [filters, groupBys, aggregations]);
|
|
836
|
+
}, [filters, groupBys, aggregations, sortBys]);
|
|
470
837
|
var removeFilter = function (index) {
|
|
471
838
|
setFilters(function (oldFilters) {
|
|
472
839
|
var newFilters = __spreadArray([], oldFilters, true);
|
|
473
840
|
newFilters.splice(index, 1);
|
|
474
841
|
return newFilters;
|
|
475
842
|
});
|
|
843
|
+
setIndexBeingEdited(-1);
|
|
476
844
|
};
|
|
477
845
|
var computeStats = useCallback(function (column) {
|
|
478
846
|
var _a;
|
|
479
|
-
if (!computedColumns[column.name]) {
|
|
847
|
+
if (!computedColumns[column.name] && data) {
|
|
480
848
|
var basicType = getPostgresBasicType(column);
|
|
481
849
|
var result = void 0;
|
|
482
850
|
if (basicType === 'number') {
|
|
@@ -524,9 +892,19 @@ function ReportingTool(_a) {
|
|
|
524
892
|
// }
|
|
525
893
|
// }
|
|
526
894
|
// }, [AST]);
|
|
895
|
+
useEffect(function () {
|
|
896
|
+
if (!aggregations.length) {
|
|
897
|
+
setAggregations([
|
|
898
|
+
{
|
|
899
|
+
column: selectedTable.columns.filter(function (col) { return getPostgresBasicType(col) === 'number'; })[0],
|
|
900
|
+
aggregationType: 'sum',
|
|
901
|
+
},
|
|
902
|
+
]);
|
|
903
|
+
}
|
|
904
|
+
}, [selectedGroupByColumn]);
|
|
527
905
|
useEffect(function () {
|
|
528
906
|
var getSqlQueryFromAST = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
529
|
-
var response,
|
|
907
|
+
var response, sqlQuery_1, err_1;
|
|
530
908
|
return __generator(this, function (_a) {
|
|
531
909
|
switch (_a.label) {
|
|
532
910
|
case 0:
|
|
@@ -535,9 +913,18 @@ function ReportingTool(_a) {
|
|
|
535
913
|
return [4 /*yield*/, axios.post('https://quill-344421.uc.r.appspot.com/sqlify', { ast: AST })];
|
|
536
914
|
case 1:
|
|
537
915
|
response = _a.sent();
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
916
|
+
sqlQuery_1 = response.data.query;
|
|
917
|
+
// alert(sqlQuery);
|
|
918
|
+
if (sqlQuery_1) {
|
|
919
|
+
onChangeQuery(sqlQuery_1);
|
|
920
|
+
runQuery(sqlQuery_1);
|
|
921
|
+
setSqlQuery(sqlQuery_1);
|
|
922
|
+
if (AST.columns === '*') {
|
|
923
|
+
setSortableColumns(selectedTable.columns.map(function (col) { return col.name; }));
|
|
924
|
+
}
|
|
925
|
+
else if (AST.columns.length) {
|
|
926
|
+
setSortableColumns(AST.columns.map(function (elem) { return elem.as || elem.expr.name; }));
|
|
927
|
+
}
|
|
541
928
|
}
|
|
542
929
|
_a.label = 2;
|
|
543
930
|
case 2: return [3 /*break*/, 4];
|
|
@@ -551,133 +938,577 @@ function ReportingTool(_a) {
|
|
|
551
938
|
}); };
|
|
552
939
|
getSqlQueryFromAST();
|
|
553
940
|
}, [AST]);
|
|
554
|
-
|
|
555
|
-
|
|
941
|
+
useEffect(function () {
|
|
942
|
+
if (sortableColumns.length) {
|
|
943
|
+
setSelectedSortByColumn(sortableColumns[0]);
|
|
944
|
+
}
|
|
945
|
+
}, [sortableColumns]);
|
|
946
|
+
if (!schema || !schema.length) {
|
|
947
|
+
return null;
|
|
948
|
+
}
|
|
949
|
+
return (_jsxs("div", __assign({ style: { marginLeft: '25px' } }, { children: [_jsx("div", __assign({ style: {
|
|
950
|
+
fontSize: '0.8rem',
|
|
951
|
+
marginBottom: '6px',
|
|
952
|
+
fontWeight: 'bold',
|
|
953
|
+
color: theme.secondaryTextColor,
|
|
954
|
+
} }, { children: "Table" })), _jsx(SelectComponent, { value: selectedTable.displayName, onChange: function (e) {
|
|
955
|
+
var table = schema.find(function (t) { return t.displayName === e; });
|
|
556
956
|
setSelectedTable(table);
|
|
557
|
-
}, options: schema.
|
|
558
|
-
|
|
559
|
-
|
|
957
|
+
}, options: (schema === null || schema === void 0 ? void 0 : schema.length)
|
|
958
|
+
? schema.map(function (elem) {
|
|
959
|
+
return { label: elem.displayName, value: elem.displayName };
|
|
960
|
+
})
|
|
961
|
+
: [] }), _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column', marginTop: '12px' } }, { children: [_jsx(AddFilterModal2, { filters: filters, selectedColumn: selectedColumn, numberStart: numberStart, numberEnd: numberEnd, dateStart: dateStart, setDateStart: setDateStart, columnStats: columnStats, stringFilterValues: stringFilterValues, setStringFilterValues: setStringFilterValues, addFilter: addFilter, setSelectedColumn: setSelectedColumn, setNumberStart: setNumberStart, setNumberEnd: setNumberEnd, selectedTable: selectedTable, columnType: columnType, dateEnd: dateEnd, setDateEnd: setDateEnd, removeFilter: removeFilter, selectFilter: selectFilter, indexBeingEdited: indexBeingEdited, updateFilter: updateFilter, SelectComponent: SelectComponent, theme: theme }), _jsx(GroupByModal2, { selectedTable: selectedTable, groupBys: groupBys, selectedGroupByColumn: selectedGroupByColumn, setSelectedGroupByColumn: setSelectedGroupByColumn, addGroupBy: addGroupBy, groupByColumnType: groupByColumnType, removeGroupBy: removeGroupBy, selectGroupBy: selectGroupBy, groupByIndexBeingEdited: groupByIndexBeingEdited, updateGroupBy: updateGroupBy, aggregations: aggregations, setAggregationColumn: setAggregationColumn, setAggregationType: setAggregationType, SelectComponent: SelectComponent, addAggregation: addAggregation, dateBucket: dateBucket, setDateBucket: setDateBucket, theme: theme }), _jsx(SortByModal, { selectedTable: selectedTable, sortableColumns: sortableColumns, sortBys: sortBys, selectedSortByColumn: selectedSortByColumn, setSelectedSortByColumn: setSelectedSortByColumn, selectedSortByDirection: selectedSortByDirection, setSelectedSortByDirection: setSelectedSortByDirection, addSortBy: addSortBy, removeSortBy: removeSortBy, selectSortBy: selectSortBy, sortByIndexBeingEdited: sortByIndexBeingEdited, updateSortBy: updateSortBy, SelectComponent: SelectComponent, theme: theme })] }))] })));
|
|
560
962
|
}
|
|
561
963
|
function FilterTag(_a) {
|
|
562
|
-
var label = _a.label, removeFilter = _a.removeFilter, index = _a.index, selectFilter = _a.selectFilter;
|
|
964
|
+
var id = _a.id, label = _a.label, removeFilter = _a.removeFilter, index = _a.index, selectFilter = _a.selectFilter, theme = _a.theme;
|
|
563
965
|
var handleRemoveFilter = function () {
|
|
564
966
|
removeFilter(index);
|
|
565
967
|
};
|
|
566
968
|
var handleSelectFilter = function () {
|
|
567
969
|
selectFilter(index);
|
|
568
970
|
};
|
|
569
|
-
return (_jsxs("div", __assign({
|
|
971
|
+
return (_jsxs("div", __assign({ id: id, onClick: handleSelectFilter, style: {
|
|
972
|
+
marginLeft: '12px',
|
|
973
|
+
cursor: 'pointer',
|
|
974
|
+
border: '1px',
|
|
975
|
+
borderColor: '#EFF0FC',
|
|
976
|
+
borderRadius: 6,
|
|
977
|
+
backgroundColor: '#EFF0FC',
|
|
978
|
+
paddingLeft: '1rem',
|
|
979
|
+
paddingRight: '0.5rem',
|
|
980
|
+
// paddingTop: "0.44rem",
|
|
981
|
+
// paddingBottom: "0.44rem",
|
|
982
|
+
height: 35,
|
|
983
|
+
display: 'flex',
|
|
984
|
+
alignItems: 'center',
|
|
985
|
+
fontSize: 14,
|
|
986
|
+
fontWeight: 'medium',
|
|
987
|
+
color: theme.primaryTextColor,
|
|
988
|
+
outline: 'none',
|
|
989
|
+
// ring: "2",
|
|
990
|
+
// ringColor: "white",
|
|
991
|
+
// ringOpacity: "75",
|
|
992
|
+
} }, { children: [_jsx("div", __assign({ id: id, style: { textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: label })), _jsx("div", __assign({
|
|
570
993
|
// onClick={handleRemoveFilter}
|
|
571
994
|
onClick: function (e) {
|
|
572
995
|
e.stopPropagation(); // Prevents the event from bubbling up to the parent
|
|
573
996
|
handleRemoveFilter();
|
|
574
|
-
},
|
|
997
|
+
}, style: {
|
|
998
|
+
display: 'flex',
|
|
999
|
+
flexDirection: 'row',
|
|
1000
|
+
alignItems: 'center',
|
|
1001
|
+
cursor: 'pointer',
|
|
1002
|
+
paddingLeft: '0.375rem',
|
|
1003
|
+
} }, { children: _jsx(XMarkIcon, { style: {
|
|
1004
|
+
height: '1.25rem',
|
|
1005
|
+
width: '1.25rem',
|
|
1006
|
+
color: theme.primaryTextColor,
|
|
1007
|
+
}, "aria-hidden": "true" }) }))] })));
|
|
575
1008
|
}
|
|
576
|
-
|
|
577
|
-
var
|
|
578
|
-
var
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
1009
|
+
var SortByModal = function (_a) {
|
|
1010
|
+
var selectedSortByColumn = _a.selectedSortByColumn, selectedSortByDirection = _a.selectedSortByDirection, setSelectedSortByColumn = _a.setSelectedSortByColumn, setSelectedSortByDirection = _a.setSelectedSortByDirection, selectedTable = _a.selectedTable, sortableColumns = _a.sortableColumns, removeSortBy = _a.removeSortBy, selectSortBy = _a.selectSortBy, updateSortBy = _a.updateSortBy, addSortBy = _a.addSortBy, sortBys = _a.sortBys, SelectComponent = _a.SelectComponent, sortByIndexBeingEdited = _a.sortByIndexBeingEdited, theme = _a.theme;
|
|
1011
|
+
var dropdownRef = useRef(null);
|
|
1012
|
+
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
1013
|
+
useEffect(function () {
|
|
1014
|
+
// Event listener to close the dropdown menu when clicking outside
|
|
1015
|
+
var handleOutsideClick = function (event) {
|
|
1016
|
+
if (event.target.id === 'sort-toggle-button' ||
|
|
1017
|
+
event.target.id === 'sort-tag') {
|
|
1018
|
+
setIsOpen(function (isOpen) { return !isOpen; });
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1022
|
+
setIsOpen(false);
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
// Attach the event listener to the document
|
|
1026
|
+
document.addEventListener('click', handleOutsideClick);
|
|
1027
|
+
// Clean up the event listener on component unmount
|
|
1028
|
+
return function () {
|
|
1029
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
1030
|
+
};
|
|
1031
|
+
}, []);
|
|
1032
|
+
return (_jsx("div", __assign({ style: { display: 'flex', flexDirection: 'column', marginTop: 12 } }, { children: _jsxs("div", __assign({ style: {
|
|
1033
|
+
position: 'relative',
|
|
1034
|
+
display: 'inline-block',
|
|
1035
|
+
textAlign: 'left',
|
|
1036
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
1037
|
+
display: 'flex',
|
|
1038
|
+
flexDirection: 'row',
|
|
1039
|
+
alignItems: 'center',
|
|
1040
|
+
} }, { children: [_jsx("button", __assign({ id: "sort-toggle-button",
|
|
1041
|
+
// onClick={() => setIsOpen((isOpen) => !isOpen)}
|
|
1042
|
+
type: "button", "aria-haspopup": "menu", "aria-expanded": "true", "data-headlessui-state": "open", style: {
|
|
1043
|
+
display: 'inline-flex',
|
|
1044
|
+
boxShadow: 'rgba(231, 231, 231, 0.5) 0px 1px 2px 0px',
|
|
1045
|
+
borderRadius: '0.375rem',
|
|
1046
|
+
backgroundColor: 'rgba(0, 0, 0, 0)',
|
|
1047
|
+
padding: '0.375rem 0.75rem',
|
|
1048
|
+
fontSize: '0.875rem',
|
|
1049
|
+
fontWeight: '500',
|
|
1050
|
+
color: theme.primaryTextColor,
|
|
1051
|
+
borderWidth: 1,
|
|
1052
|
+
borderStyle: 'solid',
|
|
1053
|
+
borderColor: theme.borderColor,
|
|
1054
|
+
} }, { children: "Sort" })), _jsx("div", __assign({ style: {
|
|
1055
|
+
overflowX: 'scroll',
|
|
1056
|
+
display: 'flex',
|
|
1057
|
+
flexDirection: 'row',
|
|
1058
|
+
alignItems: 'center',
|
|
1059
|
+
} }, { children: sortBys.map(function (elem, index) { return (_jsx(FilterTag, { id: "sort-tag", label: elem.column, removeFilter: removeSortBy, selectFilter: selectSortBy, index: index, theme: theme })); }) }))] })), isOpen && (_jsxs("div", __assign({ ref: dropdownRef, role: "menu", tabindex: "0", "data-headlessui-state": "open", style: {
|
|
1060
|
+
zIndex: 120,
|
|
1061
|
+
position: 'absolute',
|
|
1062
|
+
left: '0px',
|
|
1063
|
+
marginTop: '12px',
|
|
1064
|
+
transformOrigin: 'right top',
|
|
1065
|
+
display: 'flex',
|
|
1066
|
+
flexDirection: 'column',
|
|
1067
|
+
padding: '1rem',
|
|
1068
|
+
borderRadius: '0.375rem',
|
|
1069
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
1070
|
+
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 1px 5px 0px',
|
|
1071
|
+
}, className: "transform opacity-100 scale-100" }, { children: [_jsx("div", __assign({ style: {
|
|
1072
|
+
display: 'flex',
|
|
1073
|
+
flexDirection: 'row',
|
|
1074
|
+
alignItems: 'center',
|
|
1075
|
+
} }, { children: _jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: {
|
|
1076
|
+
fontSize: '0.875rem',
|
|
1077
|
+
marginBottom: '6px',
|
|
1078
|
+
fontWeight: '600',
|
|
1079
|
+
color: '#384151',
|
|
1080
|
+
opacity: 0.7,
|
|
1081
|
+
} }, { children: "Column" })), _jsx(SelectComponent, { value: selectedSortByColumn, onChange: function (e) {
|
|
1082
|
+
setSelectedSortByColumn(e);
|
|
1083
|
+
}, options: sortableColumns.map(function (elem) {
|
|
1084
|
+
return { label: elem, value: elem };
|
|
1085
|
+
}) })] })) })), _jsx("div", __assign({ style: {
|
|
1086
|
+
fontSize: '0.875rem',
|
|
1087
|
+
marginBottom: '6px',
|
|
1088
|
+
fontWeight: '600',
|
|
1089
|
+
color: '#384151',
|
|
1090
|
+
opacity: 0.7,
|
|
1091
|
+
marginTop: 20,
|
|
1092
|
+
} }, { children: "Direction" })), _jsx(SelectComponent, { value: selectedSortByDirection, onChange: function (e) {
|
|
1093
|
+
setSelectedSortByDirection(e);
|
|
1094
|
+
}, options: [
|
|
1095
|
+
{ label: 'ascending', value: 'ascending' },
|
|
1096
|
+
{ label: 'descending', value: 'descending' },
|
|
1097
|
+
] }), _jsx("button", __assign({ style: {
|
|
1098
|
+
width: '15.3125rem',
|
|
1099
|
+
marginTop: '1.25rem',
|
|
1100
|
+
paddingTop: '0.5rem',
|
|
1101
|
+
paddingBottom: '0.5rem',
|
|
1102
|
+
paddingLeft: '0.75rem',
|
|
1103
|
+
paddingRight: '0.75rem',
|
|
1104
|
+
backgroundColor: '#384151',
|
|
1105
|
+
// hover: { opacity: "90" },
|
|
1106
|
+
color: 'white',
|
|
1107
|
+
fontWeight: '500',
|
|
1108
|
+
borderRadius: '0.375rem',
|
|
1109
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
1110
|
+
}, onClick: function () {
|
|
1111
|
+
if (sortByIndexBeingEdited > -1) {
|
|
1112
|
+
updateSortBy(sortByIndexBeingEdited);
|
|
1113
|
+
setIsOpen(false);
|
|
1114
|
+
// close();
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
addSortBy();
|
|
1118
|
+
setIsOpen(false);
|
|
1119
|
+
// close();
|
|
1120
|
+
} }, { children: sortByIndexBeingEdited > -1 ? 'Edit sort' : 'Add sort' }))] })))] })) })));
|
|
1121
|
+
};
|
|
1122
|
+
var GroupByModal2 = function (_a) {
|
|
1123
|
+
var selectedGroupByColumn = _a.selectedGroupByColumn, addGroupBy = _a.addGroupBy, setSelectedGroupByColumn = _a.setSelectedGroupByColumn, selectedTable = _a.selectedTable, groupByColumnType = _a.groupByColumnType, groupByIndexBeingEdited = _a.groupByIndexBeingEdited, updateGroupBy = _a.updateGroupBy, groupBys = _a.groupBys, removeGroupBy = _a.removeGroupBy, selectGroupBy = _a.selectGroupBy, SelectComponent = _a.SelectComponent, aggregations = _a.aggregations, setAggregationColumn = _a.setAggregationColumn, setAggregationType = _a.setAggregationType, addAggregation = _a.addAggregation, dateBucket = _a.dateBucket, setDateBucket = _a.setDateBucket, theme = _a.theme;
|
|
1124
|
+
var dropdownRef = useRef(null);
|
|
1125
|
+
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
1126
|
+
useEffect(function () {
|
|
1127
|
+
// Event listener to close the dropdown menu when clicking outside
|
|
1128
|
+
var handleOutsideClick = function (event) {
|
|
1129
|
+
if (event.target.id === 'group-toggle-button' ||
|
|
1130
|
+
event.target.id === 'group-tag') {
|
|
1131
|
+
setIsOpen(function (isOpen) { return !isOpen; });
|
|
1132
|
+
return;
|
|
1133
|
+
}
|
|
1134
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1135
|
+
setIsOpen(false);
|
|
1136
|
+
}
|
|
1137
|
+
};
|
|
1138
|
+
// Attach the event listener to the document
|
|
1139
|
+
document.addEventListener('click', handleOutsideClick);
|
|
1140
|
+
// Clean up the event listener on component unmount
|
|
1141
|
+
return function () {
|
|
1142
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
1143
|
+
};
|
|
1144
|
+
}, []);
|
|
1145
|
+
return (_jsx("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: _jsxs("div", __assign({ style: {
|
|
1146
|
+
position: 'relative',
|
|
1147
|
+
display: 'inline-block',
|
|
1148
|
+
textAlign: 'left',
|
|
1149
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
1150
|
+
display: 'flex',
|
|
1151
|
+
flexDirection: 'row',
|
|
1152
|
+
alignItems: 'center',
|
|
1153
|
+
} }, { children: [_jsx("button", __assign({ id: "group-toggle-button",
|
|
1154
|
+
// onClick={() => setIsOpen((isOpen) => !isOpen)}
|
|
1155
|
+
type: "button", "aria-haspopup": "menu", "aria-expanded": "true", "data-headlessui-state": "open", style: {
|
|
1156
|
+
display: 'inline-flex',
|
|
1157
|
+
boxShadow: 'rgba(231, 231, 231, 0.5) 0px 1px 2px 0px',
|
|
1158
|
+
borderRadius: '0.375rem',
|
|
1159
|
+
backgroundColor: 'rgba(0, 0, 0, 0)',
|
|
1160
|
+
padding: '0.375rem 0.75rem',
|
|
1161
|
+
fontSize: '0.875rem',
|
|
1162
|
+
fontWeight: '500',
|
|
1163
|
+
color: theme.primaryTextColor,
|
|
1164
|
+
borderWidth: 1,
|
|
1165
|
+
borderStyle: 'solid',
|
|
1166
|
+
borderColor: theme.borderColor,
|
|
1167
|
+
} }, { children: "Groups" })), _jsx("div", __assign({ style: {
|
|
1168
|
+
overflowX: 'scroll',
|
|
1169
|
+
display: 'flex',
|
|
1170
|
+
flexDirection: 'row',
|
|
1171
|
+
alignItems: 'center',
|
|
1172
|
+
} }, { children: groupBys.map(function (elem, index) { return (_jsx(FilterTag, { id: "group-tag", label: elem.tag, removeFilter: removeGroupBy, selectFilter: selectGroupBy, index: index })); }) }))] })), isOpen && (_jsxs("div", __assign({ ref: dropdownRef, role: "menu", tabindex: "0", "data-headlessui-state": "open", style: {
|
|
1173
|
+
zIndex: 120,
|
|
1174
|
+
position: 'absolute',
|
|
1175
|
+
left: '0px',
|
|
1176
|
+
marginTop: '12px',
|
|
1177
|
+
transformOrigin: 'right top',
|
|
1178
|
+
padding: '1rem',
|
|
1179
|
+
borderRadius: '0.375rem',
|
|
1180
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
1181
|
+
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 1px 5px 0px',
|
|
1182
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
1183
|
+
display: 'flex',
|
|
1184
|
+
flexDirection: 'row',
|
|
1185
|
+
alignItems: 'center',
|
|
1186
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", __assign({ style: {
|
|
1187
|
+
fontSize: '0.875rem',
|
|
1188
|
+
marginBottom: '6px',
|
|
1189
|
+
fontWeight: '600',
|
|
1190
|
+
color: '#384151',
|
|
1191
|
+
opacity: 0.7,
|
|
1192
|
+
} }, { children: "Column" })), _jsx(SelectComponent, { value: selectedGroupByColumn.name, onChange: function (e) {
|
|
1193
|
+
var column = selectedTable.columns.find(function (c) { return c.name === e; });
|
|
1194
|
+
setSelectedGroupByColumn(column);
|
|
1195
|
+
}, options: selectedTable.columns.map(function (elem) {
|
|
1196
|
+
return { label: elem.name, value: elem.name };
|
|
1197
|
+
}) })] })), groupByColumnType === 'date' && (_jsxs("div", __assign({ style: {
|
|
1198
|
+
display: 'flex',
|
|
1199
|
+
flexDirection: 'column',
|
|
1200
|
+
marginLeft: 12,
|
|
1201
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
1202
|
+
fontSize: '0.875rem',
|
|
1203
|
+
marginBottom: '6px',
|
|
1204
|
+
fontWeight: '600',
|
|
1205
|
+
color: '#384151',
|
|
1206
|
+
opacity: 0.7,
|
|
1207
|
+
} }, { children: "Bucket" })), _jsx(SelectComponent, { value: dateBucket, onChange: function (e) {
|
|
1208
|
+
setDateBucket(e);
|
|
1209
|
+
}, options: [
|
|
1210
|
+
{ label: 'month', value: 'month' },
|
|
1211
|
+
{ label: 'day', value: 'day' },
|
|
1212
|
+
{ label: 'week', value: 'week' },
|
|
1213
|
+
] })] })))] })), _jsx("div", __assign({ style: {
|
|
1214
|
+
fontSize: '0.875rem',
|
|
1215
|
+
marginBottom: '6px',
|
|
1216
|
+
fontWeight: '600',
|
|
1217
|
+
color: '#384151',
|
|
1218
|
+
opacity: 0.7,
|
|
1219
|
+
marginTop: 20,
|
|
1220
|
+
} }, { children: "Aggregations" })), aggregations.map(function (aggregation, index) {
|
|
1221
|
+
var _a;
|
|
1222
|
+
return (
|
|
1223
|
+
// setAggregationType
|
|
1224
|
+
_jsxs("div", __assign({ style: {
|
|
1225
|
+
display: 'flex',
|
|
1226
|
+
flexDirection: 'row',
|
|
1227
|
+
alignItems: 'center',
|
|
1228
|
+
} }, { children: [_jsx(SelectComponent, { value: (_a = aggregation.column) === null || _a === void 0 ? void 0 : _a.name, onChange: function (e) {
|
|
1229
|
+
var column = selectedTable.columns.find(function (c) { return c.name === e; });
|
|
1230
|
+
setAggregationColumn(column, index);
|
|
1231
|
+
}, options: selectedTable.columns.map(function (elem) {
|
|
1232
|
+
return { label: elem.name, value: elem.name };
|
|
1233
|
+
}) }), _jsx("div", { style: { width: 12 } }), _jsx(SelectComponent, { value: aggregation.aggregationType, onChange: function (e) {
|
|
1234
|
+
setAggregationType(e, index);
|
|
1235
|
+
}, options: [
|
|
1236
|
+
{ label: 'sum', value: 'sum' },
|
|
1237
|
+
{ label: 'average', value: 'average' },
|
|
1238
|
+
{ label: 'count', value: 'count' },
|
|
1239
|
+
] })] })));
|
|
1240
|
+
}), _jsx("button", __assign({ style: {
|
|
1241
|
+
width: '100%',
|
|
1242
|
+
marginTop: '1.25rem',
|
|
1243
|
+
paddingTop: '0.5rem',
|
|
1244
|
+
paddingBottom: '0.5rem',
|
|
1245
|
+
paddingLeft: '0.75rem',
|
|
1246
|
+
paddingRight: '0.75rem',
|
|
1247
|
+
backgroundColor: '#384151',
|
|
1248
|
+
// hover: { opacity: "90" },
|
|
1249
|
+
color: 'white',
|
|
1250
|
+
fontWeight: '500',
|
|
1251
|
+
borderRadius: '0.375rem',
|
|
1252
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
1253
|
+
}, onClick: function () {
|
|
1254
|
+
if (groupByIndexBeingEdited > -1) {
|
|
1255
|
+
updateGroupBy(groupByIndexBeingEdited);
|
|
1256
|
+
setIsOpen(false);
|
|
1257
|
+
// close();
|
|
1258
|
+
return;
|
|
1259
|
+
}
|
|
1260
|
+
addGroupBy();
|
|
1261
|
+
setIsOpen(false);
|
|
1262
|
+
// close();
|
|
1263
|
+
} }, { children: groupByIndexBeingEdited > -1 ? 'Edit group by' : 'Add group by' }))] })))] })) })));
|
|
1264
|
+
};
|
|
1265
|
+
var AddFilterModal2 = function (_a) {
|
|
1266
|
+
var filters = _a.filters, selectedColumn = _a.selectedColumn, numberStart = _a.numberStart, numberEnd = _a.numberEnd, dateStart = _a.dateStart, setDateStart = _a.setDateStart, columnStats = _a.columnStats, stringFilterValues = _a.stringFilterValues, setStringFilterValues = _a.setStringFilterValues, addFilter = _a.addFilter, setSelectedColumn = _a.setSelectedColumn, setNumberStart = _a.setNumberStart, setNumberEnd = _a.setNumberEnd, selectedTable = _a.selectedTable, columnType = _a.columnType, setDateEnd = _a.setDateEnd, dateEnd = _a.dateEnd, removeFilter = _a.removeFilter, selectFilter = _a.selectFilter, indexBeingEdited = _a.indexBeingEdited, updateFilter = _a.updateFilter, SelectComponent = _a.SelectComponent, theme = _a.theme;
|
|
1267
|
+
var dropdownRef = useRef(null);
|
|
1268
|
+
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
1269
|
+
useEffect(function () {
|
|
1270
|
+
// Event listener to close the dropdown menu when clicking outside
|
|
1271
|
+
var handleOutsideClick = function (event) {
|
|
1272
|
+
if (event.target.id === 'toggle-button' ||
|
|
1273
|
+
event.target.id === 'filter-tag') {
|
|
1274
|
+
setIsOpen(function (isOpen) { return !isOpen; });
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
|
1278
|
+
setIsOpen(false);
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
// Attach the event listener to the document
|
|
1282
|
+
document.addEventListener('click', handleOutsideClick);
|
|
1283
|
+
// Clean up the event listener on component unmount
|
|
1284
|
+
return function () {
|
|
1285
|
+
document.removeEventListener('click', handleOutsideClick);
|
|
1286
|
+
};
|
|
1287
|
+
}, []);
|
|
1288
|
+
return (_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsxs("div", __assign({ style: {
|
|
1289
|
+
position: 'relative',
|
|
1290
|
+
display: 'inline-block',
|
|
1291
|
+
textAlign: 'left',
|
|
1292
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
1293
|
+
display: 'flex',
|
|
1294
|
+
flexDirection: 'row',
|
|
1295
|
+
alignItems: 'center',
|
|
1296
|
+
} }, { children: [_jsx("button", __assign({ id: "toggle-button",
|
|
1297
|
+
// onClick={() => setIsOpen((isOpen) => !isOpen)}
|
|
1298
|
+
type: "button", "aria-haspopup": "menu", "aria-expanded": "true", "data-headlessui-state": "open", style: {
|
|
1299
|
+
display: 'inline-flex',
|
|
1300
|
+
borderWidth: '1px',
|
|
1301
|
+
borderStyle: 'solid',
|
|
1302
|
+
borderColor: theme.borderColor,
|
|
1303
|
+
boxShadow: 'rgba(231, 231, 231, 0.5) 0px 1px 2px 0px',
|
|
1304
|
+
borderRadius: '0.375rem',
|
|
1305
|
+
backgroundColor: theme.backgroundColor,
|
|
1306
|
+
padding: '0.375rem 0.75rem',
|
|
1307
|
+
fontSize: '0.875rem',
|
|
1308
|
+
fontWeight: '500',
|
|
1309
|
+
color: theme.primaryTextColor,
|
|
1310
|
+
} }, { children: "Filters" })), _jsx("div", __assign({ style: {
|
|
1311
|
+
overflowX: 'scroll',
|
|
1312
|
+
display: 'flex',
|
|
1313
|
+
flexDirection: 'row',
|
|
1314
|
+
alignItems: 'center',
|
|
1315
|
+
} }, { children: filters.map(function (elem, index) { return (_jsx(FilterTag, { id: "filter-tag", label: elem.tag, removeFilter: removeFilter, selectFilter: selectFilter, index: index })); }) }))] })), isOpen && (_jsxs("div", __assign({ ref: dropdownRef, role: "menu", tabindex: "0", "data-headlessui-state": "open", style: {
|
|
1316
|
+
zIndex: 120,
|
|
1317
|
+
position: 'absolute',
|
|
1318
|
+
left: '0px',
|
|
1319
|
+
marginTop: '12px',
|
|
1320
|
+
transformOrigin: 'right top',
|
|
1321
|
+
padding: '1rem',
|
|
1322
|
+
borderRadius: '0.375rem',
|
|
1323
|
+
backgroundColor: 'rgb(255, 255, 255)',
|
|
1324
|
+
boxShadow: 'rgba(0, 0, 0, 0.2) 0px 1px 5px 0px',
|
|
1325
|
+
display: 'flex',
|
|
1326
|
+
flexDirection: 'column',
|
|
1327
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
1328
|
+
fontSize: '0.875rem',
|
|
1329
|
+
marginBottom: '6px',
|
|
1330
|
+
fontWeight: '600',
|
|
1331
|
+
color: theme.secondaryFontColor,
|
|
1332
|
+
// opacity: 0.7,
|
|
1333
|
+
} }, { children: "Column" })), _jsx(SelectComponent, { value: selectedColumn.name, onChange: function (e) {
|
|
1334
|
+
var column = selectedTable.columns.find(function (c) { return c.name === e; });
|
|
1335
|
+
setSelectedColumn(column);
|
|
1336
|
+
}, options: selectedTable.columns.map(function (elem) {
|
|
1337
|
+
return { label: elem.name, value: elem.name };
|
|
1338
|
+
}) }), columnType === 'number' && (_jsx("div", __assign({ style: {
|
|
1339
|
+
width: '245px',
|
|
1340
|
+
maxWidth: '245px',
|
|
1341
|
+
zIndex: 50,
|
|
1342
|
+
} }, { children: _jsxs("div", __assign({ style: {
|
|
1343
|
+
display: 'flex',
|
|
1344
|
+
flexDirection: 'row',
|
|
1345
|
+
alignItems: 'center',
|
|
1346
|
+
justifyContent: 'space-between',
|
|
1347
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
1348
|
+
display: 'flex',
|
|
1349
|
+
flexDirection: 'column',
|
|
1350
|
+
marginTop: '20px',
|
|
1351
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
1352
|
+
fontSize: '0.875rem',
|
|
1353
|
+
fontWeight: '600',
|
|
1354
|
+
color: '#384151',
|
|
1355
|
+
opacity: 0.75,
|
|
1356
|
+
} }, { children: "Minimum" })), _jsx("input", {
|
|
1357
|
+
// type="number"
|
|
1358
|
+
value: numberStart, onChange: function (e) { return setNumberStart(e.target.value); }, placeholder: "", style: {
|
|
1359
|
+
textAlign: 'right',
|
|
1360
|
+
width: '100px',
|
|
1361
|
+
border: '1px solid #E7E7E7',
|
|
1362
|
+
color: '#384151',
|
|
1363
|
+
marginTop: '4px',
|
|
1364
|
+
height: 38,
|
|
1365
|
+
paddingRight: 8,
|
|
1366
|
+
backgroundColor: 'white',
|
|
1367
|
+
borderRadius: '0.375rem',
|
|
1368
|
+
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 0.1)',
|
|
1369
|
+
} })] })), _jsxs("div", __assign({ style: {
|
|
1370
|
+
display: 'flex',
|
|
1371
|
+
flexDirection: 'column',
|
|
1372
|
+
marginTop: '20px',
|
|
1373
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
1374
|
+
fontSize: '0.875rem',
|
|
1375
|
+
fontWeight: '600',
|
|
1376
|
+
color: '#384151',
|
|
1377
|
+
opacity: 0.75,
|
|
1378
|
+
} }, { children: "Maximum" })), _jsx("input", {
|
|
1379
|
+
// type="number"
|
|
1380
|
+
value: numberEnd, onChange: function (e) { return setNumberEnd(e.target.value); }, placeholder: "", style: {
|
|
1381
|
+
textAlign: 'right',
|
|
1382
|
+
width: '100px',
|
|
1383
|
+
border: '1px solid #E7E7E7',
|
|
1384
|
+
color: '#384151',
|
|
1385
|
+
marginTop: '4px',
|
|
1386
|
+
paddingRight: 8,
|
|
1387
|
+
height: 38,
|
|
1388
|
+
backgroundColor: 'white',
|
|
1389
|
+
borderRadius: '0.375rem',
|
|
1390
|
+
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 0.1)',
|
|
1391
|
+
} })] }))] })) }))), columnType === 'date' && (_jsxs("div", __assign({ style: {
|
|
1392
|
+
display: 'flex',
|
|
1393
|
+
flexDirection: 'row',
|
|
1394
|
+
alignItems: 'center',
|
|
1395
|
+
justifyContent: 'space-between',
|
|
1396
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
1397
|
+
display: 'flex',
|
|
1398
|
+
flexDirection: 'column',
|
|
1399
|
+
marginTop: '20px',
|
|
1400
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
1401
|
+
fontSize: '0.8rem',
|
|
1402
|
+
fontWeight: '600',
|
|
1403
|
+
color: 'rgba(56, 65, 81, 0.7)',
|
|
1404
|
+
} }, { children: "Start date" })), _jsx("input", { type: "date", value: dateStart, onChange: function (e) { return setDateStart(e.target.value); }, placeholder: "Start date", style: {
|
|
1405
|
+
width: '115px',
|
|
1406
|
+
fontSize: '0.8rem',
|
|
1407
|
+
color: '#384151',
|
|
1408
|
+
borderWidth: '1px',
|
|
1409
|
+
marginTop: '4px',
|
|
1410
|
+
borderColor: '#E7E7E7',
|
|
1411
|
+
backgroundColor: 'white',
|
|
1412
|
+
borderRadius: '0.375rem',
|
|
1413
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
1414
|
+
paddingLeft: '0.5rem',
|
|
1415
|
+
paddingRight: '0.5rem',
|
|
1416
|
+
paddingTop: '0.375rem',
|
|
1417
|
+
paddingBottom: '0.375rem',
|
|
1418
|
+
} })] })), _jsxs("div", __assign({ style: {
|
|
1419
|
+
display: 'flex',
|
|
1420
|
+
flexDirection: 'column',
|
|
1421
|
+
marginTop: '20px',
|
|
1422
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
1423
|
+
fontSize: '0.8rem',
|
|
1424
|
+
fontWeight: '600',
|
|
1425
|
+
color: 'rgba(56, 65, 81, 0.7)',
|
|
1426
|
+
} }, { children: "End date" })), _jsx("input", { type: "date", value: dateEnd, onChange: function (e) { return setDateEnd(e.target.value); }, placeholder: "End date", style: {
|
|
1427
|
+
width: '115px',
|
|
1428
|
+
fontSize: '0.8rem',
|
|
1429
|
+
color: '#384151',
|
|
1430
|
+
borderWidth: '1px',
|
|
1431
|
+
marginTop: '4px',
|
|
1432
|
+
borderColor: '#E7E7E7',
|
|
1433
|
+
backgroundColor: 'white',
|
|
1434
|
+
borderRadius: '0.375rem',
|
|
1435
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
1436
|
+
paddingLeft: '0.5rem',
|
|
1437
|
+
paddingRight: '0.5rem',
|
|
1438
|
+
paddingTop: '0.375rem',
|
|
1439
|
+
paddingBottom: '0.375rem',
|
|
1440
|
+
} })] }))] }))), columnType === 'string' &&
|
|
1441
|
+
columnStats &&
|
|
1442
|
+
columnStats.length > 0 && (_jsx("div", __assign({ style: {
|
|
1443
|
+
flex: 'flex',
|
|
1444
|
+
flexDirection: 'column',
|
|
1445
|
+
marginTop: '14px',
|
|
1446
|
+
} }, { children: columnStats.map(function (value) { return (_jsx("div", __assign({ style: {
|
|
1447
|
+
display: 'flex',
|
|
1448
|
+
flexDirection: 'row',
|
|
1449
|
+
alignItems: 'center',
|
|
1450
|
+
} }, { children: _jsxs("div", __assign({ style: {
|
|
1451
|
+
display: 'flex',
|
|
1452
|
+
flexDirection: 'row',
|
|
1453
|
+
alignItems: 'center',
|
|
1454
|
+
} }, { children: [_jsx(DivCheckbox
|
|
1455
|
+
// type="checkbox"
|
|
1456
|
+
// style={{
|
|
1457
|
+
// border: "1px solid red",
|
|
1458
|
+
// borderRadius: "4px",
|
|
1459
|
+
// boxSizing: "border-box",
|
|
1460
|
+
// color: "#fff",
|
|
1461
|
+
// height: "18px",
|
|
1462
|
+
// minWidth: "18px",
|
|
1463
|
+
// position: "relative",
|
|
1464
|
+
// width: "18px",
|
|
1465
|
+
// }}
|
|
1466
|
+
// className="border-[#E7E7E7] border-[1px] shadow-sm rounded-sm bg-white cursor-pointer"
|
|
1467
|
+
, {
|
|
1468
|
+
// type="checkbox"
|
|
1469
|
+
// style={{
|
|
1470
|
+
// border: "1px solid red",
|
|
1471
|
+
// borderRadius: "4px",
|
|
1472
|
+
// boxSizing: "border-box",
|
|
1473
|
+
// color: "#fff",
|
|
1474
|
+
// height: "18px",
|
|
1475
|
+
// minWidth: "18px",
|
|
1476
|
+
// position: "relative",
|
|
1477
|
+
// width: "18px",
|
|
1478
|
+
// }}
|
|
1479
|
+
// className="border-[#E7E7E7] border-[1px] shadow-sm rounded-sm bg-white cursor-pointer"
|
|
1480
|
+
checked: stringFilterValues.includes(value), onChange: function () {
|
|
1481
|
+
setStringFilterValues(function (prev) {
|
|
1482
|
+
return prev.includes(value)
|
|
1483
|
+
? prev.filter(function (v) { return v !== value; })
|
|
1484
|
+
: __spreadArray(__spreadArray([], prev, true), [value], false);
|
|
1485
|
+
});
|
|
1486
|
+
} }), _jsx("div", __assign({ style: {
|
|
1487
|
+
marginLeft: 6,
|
|
1488
|
+
display: 'block',
|
|
1489
|
+
overflow: 'hidden',
|
|
1490
|
+
textOverflow: 'ellipsis',
|
|
1491
|
+
whiteSpace: 'nowrap',
|
|
1492
|
+
color: '#384151',
|
|
1493
|
+
} }, { children: value }))] }), value) }), value)); }) }))), _jsx("button", __assign({ style: {
|
|
1494
|
+
width: '245px',
|
|
1495
|
+
marginTop: '20px',
|
|
1496
|
+
padding: '0.5rem 0.75rem',
|
|
1497
|
+
backgroundColor: 'rgb(56, 65, 81)',
|
|
1498
|
+
color: 'rgb(255, 255, 255)',
|
|
1499
|
+
fontWeight: '500',
|
|
1500
|
+
borderRadius: '0.375rem',
|
|
1501
|
+
boxShadow: 'rgba(0, 0, 0, 0.05) 0px 1px 2px 0px',
|
|
1502
|
+
}, onClick: function () {
|
|
1503
|
+
if (indexBeingEdited > -1) {
|
|
1504
|
+
updateFilter(indexBeingEdited);
|
|
1505
|
+
setIsOpen(false);
|
|
1506
|
+
return;
|
|
1507
|
+
}
|
|
1508
|
+
addFilter();
|
|
1509
|
+
setIsOpen(false);
|
|
1510
|
+
} }, { children: indexBeingEdited > -1 ? 'Edit filter' : 'Add filter' }))] })))] })), _jsx("div", { style: { height: '12px' } })] })));
|
|
1511
|
+
};
|
|
681
1512
|
var DivCheckbox = function (_a) {
|
|
682
1513
|
var onChange = _a.onChange, checked = _a.checked;
|
|
683
1514
|
var toggleCheckbox = function () {
|
|
@@ -694,17 +1525,10 @@ var DivCheckbox = function (_a) {
|
|
|
694
1525
|
borderRadius: '4px',
|
|
695
1526
|
position: 'relative',
|
|
696
1527
|
cursor: 'pointer',
|
|
1528
|
+
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
697
1529
|
};
|
|
698
|
-
return (_jsx("div", __assign({ style: style, onClick: toggleCheckbox, "aria-checked": checked,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
var _b;
|
|
702
|
-
var field = _a.field, form = _a.form, children = _a.children, props = __rest(_a, ["field", "form", "children"]);
|
|
703
|
-
var options = props.options, onChange = props.onChange, value = props.value;
|
|
704
|
-
return (_jsx(Listbox, __assign({ value: value, onChange: onChange }, { children: _jsxs("div", __assign({ className: "relative" }, { children: [_jsxs(Listbox.Button, __assign({ className: "relative w-[245px] cursor-pointer border-[1px] border-[#E7E7E7] rounded-md shadow-sm bg-white py-2 pl-3 pr-10 text-left focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 sm:text-sm" }, { children: [_jsx("span", __assign({ className: "block truncate" }, { children: (_b = options.find(function (elem) { return value === elem.value; })) === null || _b === void 0 ? void 0 : _b.label })), _jsx("span", __assign({ className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2" }, { children: _jsx(ChevronDownIcon, { className: "h-5 w-5 text-gray-400", "aria-hidden": "true" }) }))] })), _jsx(Transition, __assign({ as: Fragment, leave: "transition ease-in duration-100", leaveFrom: "opacity-100", leaveTo: "opacity-0" }, { children: _jsx(Listbox.Options, __assign({ style: { zIndex: 120 }, className: "absolute mt-1 max-h-60 w-[245px] overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm" }, { children: options.map(function (person, personIdx) { return (_jsx(Listbox.Option, __assign({ className: function (_a) {
|
|
705
|
-
var active = _a.active;
|
|
706
|
-
return "relative cursor-pointer select-none py-2 pl-4 pr-4 ".concat(active ? 'bg-[#212121]/[0.05]' : 'text-gray-900');
|
|
707
|
-
}, value: person.value }, { children: _jsx(_Fragment, { children: _jsx("span", __assign({ className: "block truncate ".concat(value === person.value ? 'font-medium' : 'font-normal') }, { children: person.label })) }) }), personIdx)); }) })) }))] })) })));
|
|
1530
|
+
return (_jsx("div", __assign({ style: style, onClick: toggleCheckbox, "aria-checked": checked,
|
|
1531
|
+
// className="shadow-sm"
|
|
1532
|
+
role: "checkbox" }, { children: checked && _jsx(CheckIcon, { className: "text-white", "aria-hidden": "true" }) })));
|
|
708
1533
|
};
|
|
709
|
-
export default Table;
|
|
710
1534
|
//# sourceMappingURL=ReportBuilder.js.map
|