@quillsql/react 2.8.5 → 2.8.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddToDashboardModal.js +146 -180
- package/dist/BarList.js +36 -43
- package/dist/Chart.js +99 -131
- package/dist/ChartBuilder.js +80 -88
- package/dist/ChartEditor.js +14 -20
- package/dist/Context.js +52 -56
- package/dist/Dashboard.d.ts.map +1 -1
- package/dist/Dashboard.js +246 -305
- package/dist/DateRangePicker/Calendar.js +41 -45
- package/dist/DateRangePicker/DateRangePicker.js +32 -60
- package/dist/DateRangePicker/DateRangePickerButton.js +14 -16
- package/dist/DateRangePicker/dateRangePickerUtils.d.ts +6 -0
- package/dist/DateRangePicker/dateRangePickerUtils.d.ts.map +1 -1
- package/dist/DateRangePicker/dateRangePickerUtils.js +89 -89
- package/dist/DateRangePicker/index.js +1 -8
- package/dist/PieChart.js +35 -69
- package/dist/QuillProvider.js +4 -6
- package/dist/ReportBuilder.js +120 -128
- package/dist/SQLEditor.js +56 -64
- package/dist/Table.d.ts +2 -1
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +64 -68
- package/dist/TableChart.js +17 -44
- package/dist/assets/ArrowDownHeadIcon.js +3 -5
- package/dist/assets/ArrowDownIcon.js +3 -5
- package/dist/assets/ArrowDownRightIcon.js +3 -5
- package/dist/assets/ArrowLeftHeadIcon.js +3 -5
- package/dist/assets/ArrowRightHeadIcon.js +3 -5
- package/dist/assets/ArrowRightIcon.js +3 -5
- package/dist/assets/ArrowUpHeadIcon.js +3 -5
- package/dist/assets/ArrowUpIcon.js +3 -5
- package/dist/assets/ArrowUpRightIcon.js +3 -5
- package/dist/assets/CalendarIcon.js +3 -5
- package/dist/assets/CalendarNormalIcon.js +3 -5
- package/dist/assets/DoubleArrowLeftHeadIcon.js +3 -5
- package/dist/assets/DoubleArrowRightHeadIcon.js +3 -5
- package/dist/assets/ExclamationFilledIcon.js +3 -5
- package/dist/assets/FilterIcon.js +3 -5
- package/dist/assets/LoadingSpinner.js +3 -5
- package/dist/assets/RefreshIcon.js +3 -5
- package/dist/assets/SearchIcon.js +3 -5
- package/dist/assets/UpLeftArrowsIcon.js +3 -5
- package/dist/assets/XCircleIcon.js +3 -5
- package/dist/assets/XIcon.js +3 -5
- package/dist/assets/index.js +21 -48
- package/dist/components/BigModal/BigModal.js +13 -38
- package/dist/components/Dropdown/Dropdown.js +24 -52
- package/dist/components/Dropdown/DropdownItem.js +9 -34
- package/dist/components/Dropdown/index.js +2 -10
- package/dist/components/Modal/Modal.js +13 -38
- package/dist/components/Modal/index.js +1 -8
- package/dist/components/QuillCard.js +8 -12
- package/dist/components/SqlTextEditor.d.ts +7 -0
- package/dist/components/SqlTextEditor.d.ts.map +1 -0
- package/dist/components/SqlTextEditor.js +14 -0
- package/dist/components/UiComponents.js +37 -50
- package/dist/components/selectUtils.js +6 -16
- package/dist/contexts/BaseColorContext.js +3 -5
- package/dist/contexts/HoveredValueContext.js +3 -5
- package/dist/contexts/RootStylesContext.js +3 -5
- package/dist/contexts/SelectedValueContext.js +3 -5
- package/dist/contexts/index.js +4 -14
- package/dist/hooks/index.js +4 -14
- package/dist/hooks/useDashboard.d.ts +7 -0
- package/dist/hooks/useDashboard.d.ts.map +1 -0
- package/dist/hooks/useDashboard.js +48 -0
- package/dist/hooks/useInternalState.js +3 -5
- package/dist/hooks/useOnClickOutside.js +3 -5
- package/dist/hooks/useOnWindowResize.js +4 -6
- package/dist/hooks/useQuill.js +11 -15
- package/dist/hooks/useSelectOnKeyDown.js +4 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -28
- package/dist/internals/ReportBuilder/PivotList.js +14 -19
- package/dist/internals/ReportBuilder/PivotModal.js +84 -91
- package/dist/internals/ReportBuilder/PivotModal.spec.js +70 -72
- package/dist/lib/font.js +2 -5
- package/dist/lib/index.js +3 -19
- package/dist/lib/inputTypes.js +1 -2
- package/dist/lib/utils.js +8 -18
- package/dist/utils/aggregate.js +28 -34
- package/dist/utils/colorToHex.js +1 -4
- package/dist/utils/dataFetcher.js +2 -7
- package/dist/utils/downloadCSV.js +1 -5
- package/package.json +2 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
// @ts-nocheck
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { expect } from 'chai';
|
|
3
|
+
import { generatePivotTable } from './PivotModal';
|
|
4
|
+
import { subMonths } from 'date-fns';
|
|
7
5
|
describe('PivotModal', function () {
|
|
8
6
|
describe('generatePivotTable', function () {
|
|
9
7
|
context('non date pivots', function () {
|
|
@@ -27,36 +25,36 @@ describe('PivotModal', function () {
|
|
|
27
25
|
{ merchant: 'm2', amount: 8, user_name: 'u2' },
|
|
28
26
|
];
|
|
29
27
|
it('should return empty table with no data', function () {
|
|
30
|
-
const table =
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const table = generatePivotTable(rowPivot, [], [new Date(), subMonths(new Date(), 3)]);
|
|
29
|
+
expect(table.columns.length).to.equal(2);
|
|
30
|
+
expect(table.rows.length).to.equal(0);
|
|
33
31
|
});
|
|
34
32
|
it('should combine values based on row pivot', function () {
|
|
35
|
-
const table =
|
|
33
|
+
const table = generatePivotTable(rowPivot, rows, [
|
|
36
34
|
new Date(),
|
|
37
|
-
|
|
35
|
+
subMonths(new Date(), 3),
|
|
38
36
|
]);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
expect(table.columns.length).to.equal(2);
|
|
38
|
+
expect(table.columns[0].field).to.equal('merchant');
|
|
39
|
+
expect(table.columns[1].field).to.equal('amount');
|
|
40
|
+
expect(table.rows.length).to.equal(2);
|
|
41
|
+
expect(table.rows[0].amount).to.equal(12);
|
|
42
|
+
expect(table.rows[1].amount).to.equal(21);
|
|
45
43
|
});
|
|
46
44
|
it('should combine values based on row and column pivots', function () {
|
|
47
|
-
const table =
|
|
45
|
+
const table = generatePivotTable(rowColumnPivot, rows, [
|
|
48
46
|
new Date(),
|
|
49
|
-
|
|
47
|
+
subMonths(new Date(), 3),
|
|
50
48
|
]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
expect(table.columns.length).to.equal(3);
|
|
50
|
+
expect(table.columns[0].field).to.equal('merchant');
|
|
51
|
+
expect(table.columns[1].field).to.equal('u1');
|
|
52
|
+
expect(table.columns[2].field).to.equal('u2');
|
|
53
|
+
expect(table.rows.length).to.equal(2);
|
|
54
|
+
expect(table.rows[0].u1).to.equal(8);
|
|
55
|
+
expect(table.rows[0].u2).to.equal(4);
|
|
56
|
+
expect(table.rows[1].u1).to.equal(6);
|
|
57
|
+
expect(table.rows[1].u2).to.equal(15);
|
|
60
58
|
});
|
|
61
59
|
});
|
|
62
60
|
context('date pivots', function () {
|
|
@@ -104,17 +102,17 @@ describe('PivotModal', function () {
|
|
|
104
102
|
valueField: 'amount',
|
|
105
103
|
aggregationType: 'sum',
|
|
106
104
|
};
|
|
107
|
-
const table =
|
|
105
|
+
const table = generatePivotTable(pivot, rows, [
|
|
108
106
|
new Date('October 10, 2023 00:00:00'),
|
|
109
107
|
new Date('October 15, 2023 00:00:00'),
|
|
110
108
|
]);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
109
|
+
expect(table.columns.length).to.equal(2);
|
|
110
|
+
expect(table.columns[0].field).to.equal('date');
|
|
111
|
+
expect(table.columns[1].field).to.equal('amount');
|
|
112
|
+
expect(table.rows.length).to.equal(6);
|
|
113
|
+
expect(table.rows[3].amount).to.equal(9);
|
|
114
|
+
expect(table.rows[4].amount).to.equal(17);
|
|
115
|
+
expect(table.rows[5].amount).to.equal(0);
|
|
118
116
|
});
|
|
119
117
|
it('should handle a row timestamp pivot', function () {
|
|
120
118
|
const pivot = {
|
|
@@ -123,17 +121,17 @@ describe('PivotModal', function () {
|
|
|
123
121
|
valueField: 'amount',
|
|
124
122
|
aggregationType: 'sum',
|
|
125
123
|
};
|
|
126
|
-
const table =
|
|
124
|
+
const table = generatePivotTable(pivot, rows, [
|
|
127
125
|
new Date('October 10, 2023 00:00:00').getTime(),
|
|
128
126
|
new Date('October 15, 2023 00:00:00').getTime(),
|
|
129
127
|
]);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
expect(table.columns.length).to.equal(2);
|
|
129
|
+
expect(table.columns[0].field).to.equal('date');
|
|
130
|
+
expect(table.columns[1].field).to.equal('amount');
|
|
131
|
+
expect(table.rows.length).to.equal(6);
|
|
132
|
+
expect(table.rows[3].amount).to.equal(9);
|
|
133
|
+
expect(table.rows[4].amount).to.equal(17);
|
|
134
|
+
expect(table.rows[5].amount).to.equal(0);
|
|
137
135
|
});
|
|
138
136
|
it('should handle a string row pivot with a date column pivot', function () {
|
|
139
137
|
const pivot = {
|
|
@@ -144,20 +142,20 @@ describe('PivotModal', function () {
|
|
|
144
142
|
rowField: 'user_name',
|
|
145
143
|
rowFieldType: 'varchar',
|
|
146
144
|
};
|
|
147
|
-
const table =
|
|
145
|
+
const table = generatePivotTable(pivot, rows, [
|
|
148
146
|
new Date('October 10, 2023 00:00:00'),
|
|
149
147
|
new Date('October 15, 2023 00:00:00'),
|
|
150
148
|
]);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
149
|
+
expect(table.columns.length).to.equal(7);
|
|
150
|
+
expect(table.columns[0].field).to.equal('user_name');
|
|
151
|
+
expect(table.rows.length).to.equal(2);
|
|
154
152
|
// u1
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
expect(table.rows[0].user_name).to.equal('u1');
|
|
154
|
+
expect(Object.values(table.rows[0])[4]).to.equal(9);
|
|
155
|
+
expect(Object.values(table.rows[0])[5]).to.equal(11);
|
|
158
156
|
// u2
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
expect(table.rows[1].user_name).to.equal('u2');
|
|
158
|
+
expect(Object.values(table.rows[1])[5]).to.equal(6);
|
|
161
159
|
});
|
|
162
160
|
it('should handle a date row pivot with a string column pivot', function () {
|
|
163
161
|
const pivot = {
|
|
@@ -168,23 +166,23 @@ describe('PivotModal', function () {
|
|
|
168
166
|
columnField: 'user_name',
|
|
169
167
|
columnFieldType: 'varchar',
|
|
170
168
|
};
|
|
171
|
-
const table =
|
|
169
|
+
const table = generatePivotTable(pivot, rows, [
|
|
172
170
|
new Date('October 10, 2023 00:00:00'),
|
|
173
171
|
new Date('October 15, 2023 00:00:00'),
|
|
174
172
|
]);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
173
|
+
expect(table.columns.length).to.equal(3);
|
|
174
|
+
expect(table.columns[0].field).to.equal('date');
|
|
175
|
+
expect(table.columns[1].field).to.equal('u1');
|
|
176
|
+
expect(table.columns[2].field).to.equal('u2');
|
|
177
|
+
expect(table.rows.length).to.equal(6);
|
|
180
178
|
// day without transactions
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
expect(table.rows[2].u1).to.equal(0);
|
|
180
|
+
expect(table.rows[2].u2).to.equal(0);
|
|
183
181
|
// days with transactions
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
expect(table.rows[3].u1).to.equal(9);
|
|
183
|
+
expect(table.rows[3].u2).to.equal(0);
|
|
184
|
+
expect(table.rows[4].u1).to.equal(11);
|
|
185
|
+
expect(table.rows[4].u2).to.equal(6);
|
|
188
186
|
});
|
|
189
187
|
it('should handle a date row pivot with a date column pivot', function () {
|
|
190
188
|
const pivot = {
|
|
@@ -195,18 +193,18 @@ describe('PivotModal', function () {
|
|
|
195
193
|
rowField: 'created_at',
|
|
196
194
|
rowFieldType: 'date',
|
|
197
195
|
};
|
|
198
|
-
const table =
|
|
196
|
+
const table = generatePivotTable(pivot, rows, [
|
|
199
197
|
new Date('October 10, 2023 00:00:00'),
|
|
200
198
|
new Date('October 15, 2023 00:00:00'),
|
|
201
199
|
]);
|
|
202
200
|
console.log(table);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
201
|
+
expect(table.columns.length).to.equal(7);
|
|
202
|
+
expect(table.columns[0].field).to.equal('created_at');
|
|
203
|
+
expect(table.rows.length).to.equal(6);
|
|
204
|
+
expect(Object.values(table.rows[3])[4]).to.equal(1);
|
|
205
|
+
expect(Object.values(table.rows[3])[5]).to.equal(2);
|
|
206
|
+
expect(Object.values(table.rows[4])[4]).to.equal(1);
|
|
207
|
+
expect(Object.values(table.rows[4])[5]).to.equal(1);
|
|
210
208
|
});
|
|
211
209
|
});
|
|
212
210
|
});
|
package/dist/lib/font.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fontWeight = exports.fontSize = void 0;
|
|
4
|
-
exports.fontSize = {
|
|
1
|
+
export const fontSize = {
|
|
5
2
|
xs: 'qq-text-xs',
|
|
6
3
|
sm: 'qq-text-sm',
|
|
7
4
|
md: 'qq-text-base',
|
|
@@ -9,7 +6,7 @@ exports.fontSize = {
|
|
|
9
6
|
xl: 'qq-text-xl',
|
|
10
7
|
threeXl: 'qq-text-3xl',
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
export const fontWeight = {
|
|
13
10
|
sm: 'qq-font-normal',
|
|
14
11
|
md: 'qq-font-medium',
|
|
15
12
|
lg: 'qq-font-semibold',
|
package/dist/lib/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./inputTypes"), exports);
|
|
18
|
-
__exportStar(require("./font"), exports);
|
|
19
|
-
__exportStar(require("./utils"), exports);
|
|
1
|
+
export * from './inputTypes';
|
|
2
|
+
export * from './font';
|
|
3
|
+
export * from './utils';
|
package/dist/lib/inputTypes.js
CHANGED
package/dist/lib/utils.js
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const defaultValueFormatter = (value) => value.toString();
|
|
5
|
-
exports.defaultValueFormatter = defaultValueFormatter;
|
|
6
|
-
const sumNumericArray = (arr) => arr.reduce((prefixSum, num) => prefixSum + num, 0);
|
|
7
|
-
exports.sumNumericArray = sumNumericArray;
|
|
8
|
-
const removeValueFromArray = (value, array) => {
|
|
1
|
+
export const defaultValueFormatter = (value) => value.toString();
|
|
2
|
+
export const sumNumericArray = (arr) => arr.reduce((prefixSum, num) => prefixSum + num, 0);
|
|
3
|
+
export const removeValueFromArray = (value, array) => {
|
|
9
4
|
const index = array.indexOf(value);
|
|
10
5
|
if (index > -1) {
|
|
11
6
|
array.splice(index, 1);
|
|
12
7
|
}
|
|
13
8
|
return array;
|
|
14
9
|
};
|
|
15
|
-
|
|
16
|
-
const isValueInArray = (value, array) => {
|
|
10
|
+
export const isValueInArray = (value, array) => {
|
|
17
11
|
for (let i = 0; i < array.length; i++) {
|
|
18
12
|
if (array[i] === value) {
|
|
19
13
|
return true;
|
|
@@ -21,16 +15,13 @@ const isValueInArray = (value, array) => {
|
|
|
21
15
|
}
|
|
22
16
|
return false;
|
|
23
17
|
};
|
|
24
|
-
|
|
25
|
-
const stringIsNumeric = (str) => {
|
|
18
|
+
export const stringIsNumeric = (str) => {
|
|
26
19
|
return !isNaN(Number(str)) && str !== undefined;
|
|
27
20
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return (0, exports.stringIsNumeric)(str.split('-').pop());
|
|
21
|
+
export const stringEndsWithNumber = (str) => {
|
|
22
|
+
return stringIsNumeric(str.split('-').pop());
|
|
31
23
|
};
|
|
32
|
-
|
|
33
|
-
function mergeRefs(refs) {
|
|
24
|
+
export function mergeRefs(refs) {
|
|
34
25
|
return value => {
|
|
35
26
|
refs.forEach(ref => {
|
|
36
27
|
if (typeof ref === 'function') {
|
|
@@ -42,4 +33,3 @@ function mergeRefs(refs) {
|
|
|
42
33
|
});
|
|
43
34
|
};
|
|
44
35
|
}
|
|
45
|
-
exports.mergeRefs = mergeRefs;
|
package/dist/utils/aggregate.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.aggregate = exports.aggregate2 = exports.whatIsProbablyTheType = void 0;
|
|
4
1
|
// @ts-nocheck
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { getPostgresBasicType } from '../ReportBuilder';
|
|
3
|
+
import { COMPARISON_OPTIONS } from '../Dashboard';
|
|
4
|
+
import { add, sub, startOfWeek, startOfDay, startOfMonth, startOfYear, parse, } from 'date-fns';
|
|
8
5
|
function findTimePeriod(dateFilter) {
|
|
9
6
|
if (!dateFilter) {
|
|
10
7
|
return null;
|
|
@@ -53,7 +50,7 @@ function findTimePeriod(dateFilter) {
|
|
|
53
50
|
else
|
|
54
51
|
return 'year';
|
|
55
52
|
}
|
|
56
|
-
function whatIsProbablyTheType(data, fieldName) {
|
|
53
|
+
export function whatIsProbablyTheType(data, fieldName) {
|
|
57
54
|
const counts = {
|
|
58
55
|
date: 0,
|
|
59
56
|
number: 0,
|
|
@@ -87,15 +84,14 @@ function whatIsProbablyTheType(data, fieldName) {
|
|
|
87
84
|
const maxType = Object.keys(counts).reduce((a, b) => counts[a] > counts[b] ? a : b);
|
|
88
85
|
return maxType;
|
|
89
86
|
}
|
|
90
|
-
|
|
91
|
-
function aggregate2(dashboardItem, bucketFields, dateFilter) {
|
|
87
|
+
export function aggregate2(dashboardItem, bucketFields, dateFilter) {
|
|
92
88
|
const timePeriod = findTimePeriod(dateFilter);
|
|
93
89
|
const rows = dashboardItem.rows;
|
|
94
90
|
const xAxisLabel = timePeriod;
|
|
95
91
|
const xAxisField = timePeriod;
|
|
96
92
|
if (!bucketFields.length || !rows.length)
|
|
97
93
|
return { ...dashboardItem, bucketedRows: [] };
|
|
98
|
-
if (
|
|
94
|
+
if (getPostgresBasicType(dashboardItem.fields.find(field => field.name === bucketFields[0].field)) === 'string') {
|
|
99
95
|
const stringField = bucketFields[0].field;
|
|
100
96
|
const aggregation = {};
|
|
101
97
|
// let aggregatedArray;
|
|
@@ -126,7 +122,7 @@ function aggregate2(dashboardItem, bucketFields, dateFilter) {
|
|
|
126
122
|
bucketedRows: aggregatedArray,
|
|
127
123
|
};
|
|
128
124
|
}
|
|
129
|
-
else if (
|
|
125
|
+
else if (getPostgresBasicType(dashboardItem.fields.find(field => field.name === bucketFields[0].field)) === 'date') {
|
|
130
126
|
const dateField = bucketFields[0].field;
|
|
131
127
|
let xAxisFormat;
|
|
132
128
|
switch (timePeriod) {
|
|
@@ -200,8 +196,7 @@ function aggregate2(dashboardItem, bucketFields, dateFilter) {
|
|
|
200
196
|
return dashboardItem;
|
|
201
197
|
}
|
|
202
198
|
}
|
|
203
|
-
|
|
204
|
-
function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
199
|
+
export function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
205
200
|
const timePeriod = dateFilter && Object.keys(dateFilter).length
|
|
206
201
|
? findTimePeriod(dateFilter)
|
|
207
202
|
: 'month';
|
|
@@ -216,7 +211,7 @@ function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
|
216
211
|
//TODO: allow comparison for nonbucketed
|
|
217
212
|
return { ...dashboardItem, bucketedRows: [] };
|
|
218
213
|
}
|
|
219
|
-
if (
|
|
214
|
+
if (getPostgresBasicType(dashboardItem.fields.find(field => field.name === bucketFields[0].field)) === 'string') {
|
|
220
215
|
const stringField = bucketFields[0].field;
|
|
221
216
|
const aggregation = {};
|
|
222
217
|
rows.forEach(row => {
|
|
@@ -245,7 +240,7 @@ function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
|
245
240
|
bucketedRows: aggregatedArray,
|
|
246
241
|
};
|
|
247
242
|
}
|
|
248
|
-
else if (
|
|
243
|
+
else if (getPostgresBasicType(dashboardItem.fields.find(field => field.name === bucketFields[0].field)) === 'date') {
|
|
249
244
|
const dateField = bucketFields[0].field;
|
|
250
245
|
let interval;
|
|
251
246
|
let xAxisFormat;
|
|
@@ -273,19 +268,19 @@ function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
|
273
268
|
let formattedDate;
|
|
274
269
|
switch (timePeriod) {
|
|
275
270
|
case 'day': {
|
|
276
|
-
formattedDate =
|
|
271
|
+
formattedDate = startOfDay(firstEntryDate);
|
|
277
272
|
break;
|
|
278
273
|
}
|
|
279
274
|
case 'week': {
|
|
280
|
-
formattedDate =
|
|
275
|
+
formattedDate = startOfWeek(firstEntryDate, { weekStartsOn: 1 });
|
|
281
276
|
break;
|
|
282
277
|
}
|
|
283
278
|
case 'month': {
|
|
284
|
-
formattedDate =
|
|
279
|
+
formattedDate = startOfMonth(firstEntryDate);
|
|
285
280
|
break;
|
|
286
281
|
}
|
|
287
282
|
case 'year': {
|
|
288
|
-
formattedDate =
|
|
283
|
+
formattedDate = startOfYear(firstEntryDate);
|
|
289
284
|
break;
|
|
290
285
|
}
|
|
291
286
|
default:
|
|
@@ -298,27 +293,27 @@ function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
|
298
293
|
dashboardItem.yAxisFields.forEach(yAxisField => {
|
|
299
294
|
aggregation[iteratedDate][yAxisField.field] = 0;
|
|
300
295
|
});
|
|
301
|
-
iteratedDate =
|
|
296
|
+
iteratedDate = add(iteratedDate, interval);
|
|
302
297
|
}
|
|
303
298
|
// TODO MAKE WORK WITH MULTIPLE Y AXIS FIELDS
|
|
304
299
|
rows.forEach(row => {
|
|
305
|
-
const date =
|
|
300
|
+
const date = parse(row[dateField], 'yyyy-MM-dd', new Date());
|
|
306
301
|
let formattedDate;
|
|
307
302
|
switch (timePeriod) {
|
|
308
303
|
case 'day': {
|
|
309
|
-
formattedDate =
|
|
304
|
+
formattedDate = startOfDay(date);
|
|
310
305
|
break;
|
|
311
306
|
}
|
|
312
307
|
case 'week': {
|
|
313
|
-
formattedDate =
|
|
308
|
+
formattedDate = startOfWeek(date, { weekStartsOn: 1 });
|
|
314
309
|
break;
|
|
315
310
|
}
|
|
316
311
|
case 'month': {
|
|
317
|
-
formattedDate =
|
|
312
|
+
formattedDate = startOfMonth(date);
|
|
318
313
|
break;
|
|
319
314
|
}
|
|
320
315
|
case 'year': {
|
|
321
|
-
formattedDate =
|
|
316
|
+
formattedDate = startOfYear(date);
|
|
322
317
|
break;
|
|
323
318
|
}
|
|
324
319
|
default:
|
|
@@ -348,35 +343,35 @@ function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
|
348
343
|
dateFilter.comparison &&
|
|
349
344
|
dateFilter.comparisonRange.value !== 'NO_COMPARISON' &&
|
|
350
345
|
dashboardItem.compareRows) {
|
|
351
|
-
const offset =
|
|
346
|
+
const offset = COMPARISON_OPTIONS.find(option => {
|
|
352
347
|
return option.value === dateFilter.comparisonRange.value;
|
|
353
348
|
})?.offset;
|
|
354
349
|
aggregatedArray.forEach(row => {
|
|
355
350
|
dashboardItem.yAxisFields.forEach(yAxisField => {
|
|
356
351
|
row[yAxisField.field + '2'] = 0;
|
|
357
352
|
});
|
|
358
|
-
row[xAxisField + '2'] =
|
|
353
|
+
row[xAxisField + '2'] = sub(new Date(row[timePeriod]), offset).toISOString();
|
|
359
354
|
});
|
|
360
355
|
compareRows.sort((a, b) => new Date(a[dateField]) - new Date(b[dateField]));
|
|
361
356
|
compareRows.forEach((row, index) => {
|
|
362
|
-
let date =
|
|
363
|
-
date =
|
|
357
|
+
let date = parse(row[dateField], 'yyyy-MM-dd', new Date());
|
|
358
|
+
date = add(date, offset);
|
|
364
359
|
let formattedDate;
|
|
365
360
|
switch (timePeriod) {
|
|
366
361
|
case 'day': {
|
|
367
|
-
formattedDate =
|
|
362
|
+
formattedDate = startOfDay(date);
|
|
368
363
|
break;
|
|
369
364
|
}
|
|
370
365
|
case 'week': {
|
|
371
|
-
formattedDate =
|
|
366
|
+
formattedDate = startOfWeek(date, { weekStartsOn: 1 });
|
|
372
367
|
break;
|
|
373
368
|
}
|
|
374
369
|
case 'month': {
|
|
375
|
-
formattedDate =
|
|
370
|
+
formattedDate = startOfMonth(date);
|
|
376
371
|
break;
|
|
377
372
|
}
|
|
378
373
|
case 'year': {
|
|
379
|
-
formattedDate =
|
|
374
|
+
formattedDate = startOfYear(date);
|
|
380
375
|
break;
|
|
381
376
|
}
|
|
382
377
|
default:
|
|
@@ -426,4 +421,3 @@ function aggregate(dashboardItem, bucketFields, dateFilter) {
|
|
|
426
421
|
return dashboardItem;
|
|
427
422
|
}
|
|
428
423
|
}
|
|
429
|
-
exports.aggregate = aggregate;
|
package/dist/utils/colorToHex.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDataFromCloud = exports.getData = void 0;
|
|
4
1
|
// this function gets the data either from the self hosted endpoint or
|
|
5
2
|
// our cloud server
|
|
6
|
-
async function getData(client, cloudQueryEndpoint, noCred, hostedRequestBody, cloudRequestBody, method = 'POST') {
|
|
3
|
+
export async function getData(client, cloudQueryEndpoint, noCred, hostedRequestBody, cloudRequestBody, method = 'POST') {
|
|
7
4
|
if (client.queryEndpoint) {
|
|
8
5
|
// self hosted
|
|
9
6
|
const resp = await fetch(client.queryEndpoint, {
|
|
@@ -29,8 +26,7 @@ async function getData(client, cloudQueryEndpoint, noCred, hostedRequestBody, cl
|
|
|
29
26
|
return await getDataFromCloud(client, cloudQueryEndpoint, cloudRequestBody, method);
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
async function getDataFromCloud(client, cloudQueryEndpoint, cloudRequestBody, method = 'POST') {
|
|
29
|
+
export async function getDataFromCloud(client, cloudQueryEndpoint, cloudRequestBody, method = 'POST') {
|
|
34
30
|
const environment = client?.environment;
|
|
35
31
|
const resp = await fetch(`https://quill-344421.uc.r.appspot.com/${cloudQueryEndpoint}`,
|
|
36
32
|
// `http://localhost:8080/${cloudQueryEndpoint}`,
|
|
@@ -60,4 +56,3 @@ async function getDataFromCloud(client, cloudQueryEndpoint, cloudRequestBody, me
|
|
|
60
56
|
return null;
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
|
-
exports.getDataFromCloud = getDataFromCloud;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadCSV = void 0;
|
|
4
1
|
// @ts-nocheck
|
|
5
|
-
function downloadCSV(rows, filename) {
|
|
2
|
+
export function downloadCSV(rows, filename) {
|
|
6
3
|
const json = rows;
|
|
7
4
|
const fields = Object.keys(json[0]);
|
|
8
5
|
const csvRows = [];
|
|
@@ -25,4 +22,3 @@ function downloadCSV(rows, filename) {
|
|
|
25
22
|
downloadLink.click();
|
|
26
23
|
document.body.removeChild(downloadLink);
|
|
27
24
|
}
|
|
28
|
-
exports.downloadCSV = downloadCSV;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillsql/react",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.6",
|
|
4
4
|
"description": "Quill React components for building dashboards and reporting.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
|
+
"dev": "tsc -w",
|
|
11
12
|
"lint": "eslint . --max-warnings 0"
|
|
12
13
|
},
|
|
13
14
|
"dependencies": {
|