@quillsql/react 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AddToDashboardModal.js +369 -249
- package/lib/AddToDashboardModal.js.map +1 -1
- package/lib/BarList.js +109 -92
- package/lib/BarList.js.map +1 -1
- package/lib/Chart.js +414 -364
- package/lib/Chart.js.map +1 -1
- package/lib/Context.js +84 -92
- package/lib/Context.js.map +1 -1
- package/lib/Dashboard.js +209 -181
- package/lib/Dashboard.js.map +1 -1
- package/lib/DateRangePicker/Calendar.js +91 -87
- package/lib/DateRangePicker/Calendar.js.map +1 -1
- package/lib/DateRangePicker/DateRangePicker.js +68 -70
- package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
- package/lib/DateRangePicker/DateRangePickerButton.js +57 -46
- package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
- package/lib/DateRangePicker/dateRangePickerUtils.js +99 -105
- package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
- package/lib/DateRangePicker/index.js +1 -8
- package/lib/DateRangePicker/index.js.map +1 -1
- package/lib/PieChart.js +225 -221
- package/lib/PieChart.js.map +1 -1
- package/lib/QuillProvider.js +18 -8
- package/lib/QuillProvider.js.map +1 -1
- package/lib/ReportBuilder.js +526 -430
- package/lib/ReportBuilder.js.map +1 -1
- package/lib/SQLEditor.js +268 -183
- package/lib/SQLEditor.js.map +1 -1
- package/lib/Table.js +256 -213
- package/lib/Table.js.map +1 -1
- package/lib/TableChart.js +75 -76
- package/lib/TableChart.js.map +1 -1
- package/lib/assets/ArrowDownHeadIcon.js +28 -5
- package/lib/assets/ArrowDownHeadIcon.js.map +1 -1
- package/lib/assets/ArrowDownIcon.js +28 -5
- package/lib/assets/ArrowDownIcon.js.map +1 -1
- package/lib/assets/ArrowDownRightIcon.js +28 -5
- package/lib/assets/ArrowDownRightIcon.js.map +1 -1
- package/lib/assets/ArrowLeftHeadIcon.js +28 -5
- package/lib/assets/ArrowLeftHeadIcon.js.map +1 -1
- package/lib/assets/ArrowRightHeadIcon.js +28 -5
- package/lib/assets/ArrowRightHeadIcon.js.map +1 -1
- package/lib/assets/ArrowRightIcon.js +28 -5
- package/lib/assets/ArrowRightIcon.js.map +1 -1
- package/lib/assets/ArrowUpHeadIcon.js +28 -5
- package/lib/assets/ArrowUpHeadIcon.js.map +1 -1
- package/lib/assets/ArrowUpIcon.js +28 -5
- package/lib/assets/ArrowUpIcon.js.map +1 -1
- package/lib/assets/ArrowUpRightIcon.js +28 -5
- package/lib/assets/ArrowUpRightIcon.js.map +1 -1
- package/lib/assets/CalendarIcon.js +28 -5
- package/lib/assets/CalendarIcon.js.map +1 -1
- package/lib/assets/DoubleArrowLeftHeadIcon.js +28 -5
- package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -1
- package/lib/assets/DoubleArrowRightHeadIcon.js +28 -5
- package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -1
- package/lib/assets/ExclamationFilledIcon.js +28 -5
- package/lib/assets/ExclamationFilledIcon.js.map +1 -1
- package/lib/assets/LoadingSpinner.js +28 -5
- package/lib/assets/LoadingSpinner.js.map +1 -1
- package/lib/assets/SearchIcon.js +28 -5
- package/lib/assets/SearchIcon.js.map +1 -1
- package/lib/assets/XCircleIcon.js +28 -5
- package/lib/assets/XCircleIcon.js.map +1 -1
- package/lib/assets/index.js +16 -38
- package/lib/assets/index.js.map +1 -1
- package/lib/components/BigModal/BigModal.js +43 -45
- package/lib/components/BigModal/BigModal.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.js +53 -57
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownItem.js +40 -43
- package/lib/components/Dropdown/DropdownItem.js.map +1 -1
- package/lib/components/Dropdown/index.js +2 -10
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/Modal/Modal.js +43 -45
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/Modal/index.js +1 -8
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/selectUtils.js +15 -20
- package/lib/components/selectUtils.js.map +1 -1
- package/lib/contexts/BaseColorContext.js +3 -5
- package/lib/contexts/BaseColorContext.js.map +1 -1
- package/lib/contexts/HoveredValueContext.js +3 -5
- package/lib/contexts/HoveredValueContext.js.map +1 -1
- package/lib/contexts/RootStylesContext.js +3 -5
- package/lib/contexts/RootStylesContext.js.map +1 -1
- package/lib/contexts/SelectedValueContext.js +3 -5
- package/lib/contexts/SelectedValueContext.js.map +1 -1
- package/lib/contexts/index.js +4 -14
- package/lib/contexts/index.js.map +1 -1
- package/lib/hooks/index.js +4 -14
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useInternalState.js +7 -9
- package/lib/hooks/useInternalState.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +6 -8
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnWindowResize.js +7 -9
- package/lib/hooks/useOnWindowResize.js.map +1 -1
- package/lib/hooks/useQuill.js +111 -60
- package/lib/hooks/useQuill.js.map +1 -1
- package/lib/hooks/useSelectOnKeyDown.js +15 -17
- package/lib/hooks/useSelectOnKeyDown.js.map +1 -1
- package/lib/index.js +8 -22
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/Dashboard.js
CHANGED
|
@@ -1,45 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
24
20
|
};
|
|
25
|
-
var
|
|
26
|
-
|
|
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
|
+
}
|
|
27
47
|
};
|
|
28
|
-
|
|
29
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
30
49
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
31
50
|
// @ts-nocheck
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
51
|
+
import React, { useContext, useEffect, useState, useRef } from 'react';
|
|
52
|
+
import Chart from './Chart';
|
|
53
|
+
import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, } from './Context';
|
|
54
|
+
import { startOfToday, sub } from 'date-fns';
|
|
55
|
+
import { DateRangePicker } from './DateRangePicker/index';
|
|
56
|
+
import axios from 'axios';
|
|
57
|
+
import Modal from './components/Modal/Modal';
|
|
58
|
+
import { HoveredValueContext, SelectedValueContext } from './contexts';
|
|
59
|
+
import { DropdownItem } from './components/Dropdown';
|
|
60
|
+
import { ArrowDownHeadIcon } from './assets';
|
|
61
|
+
import { useInternalState, useSelectOnKeyDown } from './hooks';
|
|
43
62
|
// const theme = {
|
|
44
63
|
// fontFamily: 'Inter; Helvetica',
|
|
45
64
|
// primaryTextColor: '#212121',
|
|
@@ -48,83 +67,93 @@ const hooks_1 = require("./hooks");
|
|
|
48
67
|
// chartTickColor: '#CCCCCC',
|
|
49
68
|
// chartColors: ['#6269E9', '#E14F62'],
|
|
50
69
|
// };
|
|
51
|
-
function Dashboard(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
export default function Dashboard(_a) {
|
|
71
|
+
var name = _a.name, containerStyle = _a.containerStyle, maxColumnWidth = _a.maxColumnWidth, rowHeight = _a.rowHeight, onClickDashboardItem = _a.onClickDashboardItem, hideDateFilter = _a.hideDateFilter;
|
|
72
|
+
var _b = useState(null), dashboardSections = _b[0], setDashboardSections = _b[1];
|
|
73
|
+
var dashboard = useContext(DashboardContext).dashboard;
|
|
74
|
+
var client = useContext(ClientContext)[0];
|
|
75
|
+
var theme = useContext(ThemeContext)[0];
|
|
76
|
+
var dashboardFiltersDispatch = useContext(DashboardFiltersContext).dashboardFiltersDispatch;
|
|
77
|
+
var _c = useState([]), configFilters = _c[0], setConfigFilters = _c[1];
|
|
78
|
+
React.useEffect(function () {
|
|
79
|
+
function getDashboards() {
|
|
80
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
+
var publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, response_1, response, error_1;
|
|
82
|
+
return __generator(this, function (_a) {
|
|
83
|
+
switch (_a.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
publicKey = client.publicKey, customerId = client.customerId, environment = client.environment, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders, withCredentials = client.withCredentials;
|
|
86
|
+
_a.label = 1;
|
|
87
|
+
case 1:
|
|
88
|
+
_a.trys.push([1, 5, , 6]);
|
|
89
|
+
if (!queryEndpoint) return [3 /*break*/, 3];
|
|
90
|
+
return [4 /*yield*/, axios.post(queryEndpoint, {
|
|
91
|
+
metadata: { name: name, task: 'config' },
|
|
92
|
+
}, {
|
|
93
|
+
headers: queryHeaders,
|
|
94
|
+
withCredentials: withCredentials,
|
|
95
|
+
})];
|
|
96
|
+
case 2:
|
|
97
|
+
response_1 = _a.sent();
|
|
98
|
+
if (response_1.status !== 200) {
|
|
99
|
+
throw new Error("HTTP error! Status: ".concat(response_1.status));
|
|
100
|
+
}
|
|
101
|
+
setDashboardSections(response_1.data.sections);
|
|
102
|
+
setConfigFilters(response_1.data.filters || []);
|
|
103
|
+
return [2 /*return*/];
|
|
104
|
+
case 3: return [4 /*yield*/, axios.get('https://quill-344421.uc.r.appspot.com/dashconfig', {
|
|
105
|
+
params: {
|
|
106
|
+
publicKey: publicKey,
|
|
107
|
+
orgId: customerId,
|
|
108
|
+
name: name,
|
|
109
|
+
task: 'dashconfig',
|
|
110
|
+
},
|
|
111
|
+
headers: {
|
|
112
|
+
environment: environment || undefined,
|
|
113
|
+
},
|
|
114
|
+
})];
|
|
115
|
+
case 4:
|
|
116
|
+
response = _a.sent();
|
|
117
|
+
if (response.status !== 200) {
|
|
118
|
+
throw new Error("HTTP error! Status: ".concat(response.status));
|
|
119
|
+
}
|
|
120
|
+
setDashboardSections(response.data.sections);
|
|
121
|
+
setConfigFilters(response.data.filters || []);
|
|
122
|
+
return [3 /*break*/, 6];
|
|
123
|
+
case 5:
|
|
124
|
+
error_1 = _a.sent();
|
|
125
|
+
console.error('Error fetching data:', error_1);
|
|
126
|
+
return [3 /*break*/, 6];
|
|
127
|
+
case 6: return [2 /*return*/];
|
|
75
128
|
}
|
|
76
|
-
setDashboardSections(response.data.sections);
|
|
77
|
-
setConfigFilters(response.data.filters || []);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const response = await axios_1.default.get('https://quill-344421.uc.r.appspot.com/dashconfig', {
|
|
81
|
-
params: {
|
|
82
|
-
publicKey: publicKey,
|
|
83
|
-
orgId: customerId,
|
|
84
|
-
name: name,
|
|
85
|
-
task: 'dashconfig',
|
|
86
|
-
},
|
|
87
|
-
headers: {
|
|
88
|
-
environment: environment || undefined,
|
|
89
|
-
},
|
|
90
129
|
});
|
|
91
|
-
|
|
92
|
-
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
93
|
-
}
|
|
94
|
-
setDashboardSections(response.data.sections);
|
|
95
|
-
setConfigFilters(response.data.filters || []);
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
console.error('Error fetching data:', error);
|
|
99
|
-
}
|
|
130
|
+
});
|
|
100
131
|
}
|
|
101
132
|
getDashboards();
|
|
102
133
|
}, [name]);
|
|
103
|
-
(
|
|
134
|
+
useEffect(function () {
|
|
104
135
|
// change to be set on the dashboard / section as default date range
|
|
105
|
-
|
|
106
|
-
startDate:
|
|
136
|
+
var filter = {
|
|
137
|
+
startDate: sub(startOfToday(), { days: 90 }),
|
|
107
138
|
endDate: new Date(),
|
|
108
139
|
filterType: 'DATE_RANGE',
|
|
109
140
|
};
|
|
110
141
|
dashboardFiltersDispatch({
|
|
111
142
|
type: 'ADD_DASHBOARD_FILTER',
|
|
112
143
|
id: 'date_range',
|
|
113
|
-
data: {
|
|
114
|
-
...filter,
|
|
115
|
-
},
|
|
144
|
+
data: __assign({}, filter),
|
|
116
145
|
});
|
|
117
146
|
}, []);
|
|
118
|
-
|
|
147
|
+
var handleOnClickDashboardItem = function (id) {
|
|
119
148
|
if (dashboard[id]) {
|
|
120
149
|
onClickDashboardItem(dashboard[id]);
|
|
121
150
|
}
|
|
122
151
|
};
|
|
123
|
-
|
|
152
|
+
var onChangeDateFilter = function (dateFilter) {
|
|
124
153
|
setGlobalDateFilter(dateFilter[0], dateFilter[1]);
|
|
125
154
|
};
|
|
126
|
-
|
|
127
|
-
|
|
155
|
+
var setGlobalDateFilter = function (startDate, endDate) {
|
|
156
|
+
var filter = {
|
|
128
157
|
startDate: startDate,
|
|
129
158
|
endDate: endDate,
|
|
130
159
|
filterType: 'DATE_RANGE',
|
|
@@ -132,53 +161,48 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
132
161
|
dashboardFiltersDispatch({
|
|
133
162
|
type: 'ADD_DASHBOARD_FILTER',
|
|
134
163
|
id: 'date_range',
|
|
135
|
-
data: {
|
|
136
|
-
...filter,
|
|
137
|
-
},
|
|
164
|
+
data: __assign({}, filter),
|
|
138
165
|
});
|
|
139
166
|
};
|
|
140
|
-
|
|
167
|
+
var onChangeFilter = function (value, filter) {
|
|
141
168
|
dashboardFiltersDispatch({
|
|
142
169
|
type: 'ADD_DASHBOARD_FILTER',
|
|
143
170
|
id: 'date_range',
|
|
144
|
-
data: {
|
|
145
|
-
...filter,
|
|
146
|
-
selectedValue: filter.options.find(elem => elem[removeQuotes(filter.field)] === value[2])[removeQuotes(filter.field)],
|
|
147
|
-
},
|
|
171
|
+
data: __assign(__assign({}, filter), { selectedValue: filter.options.find(function (elem) { return elem[removeQuotes(filter.field)] === value[2]; })[removeQuotes(filter.field)] }),
|
|
148
172
|
});
|
|
149
173
|
};
|
|
150
174
|
if (!dashboardSections) {
|
|
151
175
|
return null;
|
|
152
176
|
}
|
|
153
|
-
return ((
|
|
177
|
+
return (_jsxs("div", __assign({ style: containerStyle }, { children: [_jsxs("div", __assign({ style: {
|
|
154
178
|
display: 'flex',
|
|
155
179
|
boxSizing: 'content-box',
|
|
156
180
|
flexDirection: 'row',
|
|
157
181
|
alignItems: 'center',
|
|
158
|
-
}, children: [!hideDateFilter ? ((
|
|
182
|
+
} }, { children: [!hideDateFilter ? (_jsxs("div", __assign({ style: { width: 420, marginBottom: 25, marginLeft: 25 } }, { children: [_jsx("div", __assign({ style: {
|
|
159
183
|
marginBottom: 6,
|
|
160
184
|
fontWeight: '600',
|
|
161
185
|
color: theme.secondaryTextColor,
|
|
162
186
|
fontFamily: theme.fontFamily,
|
|
163
187
|
fontSize: 14,
|
|
164
|
-
}, children: "Date" }), (
|
|
188
|
+
} }, { children: "Date" })), _jsx(DateRangePicker
|
|
165
189
|
// change to be set on the dashboard / section as default date range
|
|
166
190
|
, {
|
|
167
191
|
// change to be set on the dashboard / section as default date range
|
|
168
|
-
defaultValue: [undefined, undefined, '90d'], onValueChange: onChangeDateFilter, theme: theme })] })) : null, (
|
|
192
|
+
defaultValue: [undefined, undefined, '90d'], onValueChange: onChangeDateFilter, theme: theme })] }))) : null, _jsx("div", __assign({ style: { width: 280, marginBottom: 25, marginLeft: 25 } }, { children: configFilters.map(function (elem, index) { return (_jsx(Filter, { onValueChange: function (value) { return onChangeFilter(value, elem); }, defaultValue: [
|
|
169
193
|
undefined,
|
|
170
194
|
undefined,
|
|
171
195
|
elem.options[removeQuotes(elem.field)],
|
|
172
|
-
], theme: theme, filter: elem }, 'filter' + configFilters.field + index))) })] }), Object.keys(dashboardSections)
|
|
196
|
+
], theme: theme, filter: elem }, 'filter' + configFilters.field + index)); }) }))] })), Object.keys(dashboardSections)
|
|
173
197
|
.sort(function (a, b) {
|
|
174
198
|
return a.length - b.length;
|
|
175
199
|
})
|
|
176
|
-
.map((section, sectionIndex)
|
|
177
|
-
return ((
|
|
200
|
+
.map(function (section, sectionIndex) {
|
|
201
|
+
return (_jsxs("div", __assign({ style: {
|
|
178
202
|
width: '100%',
|
|
179
203
|
display: 'flex',
|
|
180
204
|
flexDirection: 'column',
|
|
181
|
-
}, children: [(
|
|
205
|
+
} }, { children: [_jsxs("div", __assign({ style: { display: 'flex', flexDirection: 'column' } }, { children: [_jsx("div", { style: { height: sectionIndex > 0 ? 25 : 0 } }), section && (_jsx("h1", __assign({ style: {
|
|
182
206
|
fontSize: 22,
|
|
183
207
|
color: theme.primaryTextColor,
|
|
184
208
|
fontFamily: theme.fontFamily,
|
|
@@ -188,20 +212,20 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
188
212
|
marginLeft: 25,
|
|
189
213
|
textAlign: 'left',
|
|
190
214
|
marginTop: 12,
|
|
191
|
-
}, children: section }))] }), dashboardSections[section].filter(elem
|
|
215
|
+
} }, { children: section })))] })), dashboardSections[section].filter(function (elem) { return elem.chartType === 'metric'; }).length ? (_jsx("div", __assign({ style: {
|
|
192
216
|
boxSizing: 'content-box',
|
|
193
|
-
width:
|
|
217
|
+
width: "100%",
|
|
194
218
|
listStyleType: 'none',
|
|
195
219
|
marginBottom: 50,
|
|
196
220
|
display: 'grid',
|
|
197
221
|
gridGap: 25,
|
|
198
|
-
gridTemplateColumns:
|
|
199
|
-
gridTemplateRows:
|
|
200
|
-
}, children: dashboardSections[section]
|
|
201
|
-
.filter(elem
|
|
202
|
-
.map((elem, index)
|
|
203
|
-
return ((
|
|
204
|
-
? ()
|
|
222
|
+
gridTemplateColumns: "repeat(auto-fill,minmax(".concat(maxColumnWidth || 400, "px, 1fr))"),
|
|
223
|
+
gridTemplateRows: "repeat(".concat(170, "px)"),
|
|
224
|
+
} }, { children: dashboardSections[section]
|
|
225
|
+
.filter(function (elem) { return elem.chartType === 'metric'; })
|
|
226
|
+
.map(function (elem, index) {
|
|
227
|
+
return (_jsx("div", __assign({ onClick: onClickDashboardItem
|
|
228
|
+
? function () { return handleOnClickDashboardItem(elem._id); }
|
|
205
229
|
: undefined, style: {
|
|
206
230
|
// background: theme.elevatedCardColor,
|
|
207
231
|
// borderRadius: theme.borderRadius,
|
|
@@ -212,22 +236,22 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
212
236
|
height: '100%',
|
|
213
237
|
cursor: 'pointer',
|
|
214
238
|
width: '100%',
|
|
215
|
-
}, children: (
|
|
239
|
+
} }, { children: _jsx("div", __assign({
|
|
216
240
|
// className="group-hover:bg-black"
|
|
217
241
|
style: {
|
|
218
242
|
width: '100%',
|
|
219
243
|
boxSizing: 'content-box',
|
|
220
244
|
height: '100%',
|
|
221
|
-
}, children: (
|
|
245
|
+
} }, { children: _jsx("div", __assign({ style: {
|
|
222
246
|
width: '100%',
|
|
223
247
|
boxSizing: 'content-box',
|
|
224
248
|
height: '100%',
|
|
225
|
-
}, children: (
|
|
249
|
+
} }, { children: _jsxs("div", __assign({ style: {
|
|
226
250
|
display: 'flex',
|
|
227
251
|
flexDirection: 'column',
|
|
228
252
|
justifyContent: 'space-between',
|
|
229
253
|
boxSizing: 'content-box',
|
|
230
|
-
}, children: [(
|
|
254
|
+
} }, { children: [_jsxs("div", __assign({
|
|
231
255
|
// className="group-hover:bg-black"
|
|
232
256
|
style: {
|
|
233
257
|
display: 'flex',
|
|
@@ -238,7 +262,7 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
238
262
|
// paddingLeft: theme.padding,
|
|
239
263
|
paddingRight: 25,
|
|
240
264
|
// paddingTop: theme.padding,
|
|
241
|
-
}, children: [(
|
|
265
|
+
} }, { children: [_jsx("div", __assign({ title: elem.name, style: {
|
|
242
266
|
fontFamily: theme.fontFamily,
|
|
243
267
|
color: theme.primaryTextColor,
|
|
244
268
|
boxSizing: 'content-box',
|
|
@@ -257,7 +281,7 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
257
281
|
display: 'block',
|
|
258
282
|
maxWidth: '100%',
|
|
259
283
|
overflow: 'hidden',
|
|
260
|
-
}, children: elem.name }), onClickDashboardItem ? ((
|
|
284
|
+
} }, { children: elem.name })), onClickDashboardItem ? (_jsx("div", __assign({
|
|
261
285
|
// className="hover:bg-black"
|
|
262
286
|
style: {
|
|
263
287
|
fontFamily: theme.fontFamily,
|
|
@@ -270,26 +294,27 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
270
294
|
display: 'flex',
|
|
271
295
|
alignItems: 'center',
|
|
272
296
|
justifyContent: 'flex-end',
|
|
273
|
-
}, children: 'view report →' })) : null] }), (
|
|
297
|
+
} }, { children: 'view report →' }))) : null] })), _jsx("div", __assign({ style: { padding: 0 } }, { children: _jsx(Chart, { containerStyle: {
|
|
274
298
|
display: 'flex',
|
|
275
299
|
// width: '100%',
|
|
276
300
|
height: 30,
|
|
277
301
|
// marginBottom: 50,
|
|
278
302
|
marginTop: 20,
|
|
279
|
-
}, dateFilter: true, chartId: elem._id, query: elem.queryString }) })] }) }) }) }, elem.name + '' + index));
|
|
280
|
-
}) })) : null, (
|
|
303
|
+
}, dateFilter: true, chartId: elem._id, query: elem.queryString }) }))] })) })) })) }), elem.name + '' + index));
|
|
304
|
+
}) }))) : null, _jsx("div", __assign({ style: {
|
|
281
305
|
// width: `100%`,
|
|
282
306
|
listStyleType: 'none',
|
|
283
307
|
display: 'grid',
|
|
284
308
|
gridGap: 25,
|
|
285
309
|
boxSizing: 'content-box',
|
|
286
|
-
gridTemplateColumns:
|
|
287
|
-
gridTemplateRows:
|
|
288
|
-
}, children: dashboardSections[section]
|
|
289
|
-
.filter(elem
|
|
290
|
-
.map((elem, index)
|
|
291
|
-
|
|
292
|
-
|
|
310
|
+
gridTemplateColumns: "repeat(auto-fill,minmax(".concat(maxColumnWidth || 400, "px, 1fr))"),
|
|
311
|
+
gridTemplateRows: "repeat(auto-fill, ".concat(rowHeight || 400, "px)"),
|
|
312
|
+
} }, { children: dashboardSections[section]
|
|
313
|
+
.filter(function (elem) { return elem.chartType !== 'metric'; })
|
|
314
|
+
.map(function (elem, index) {
|
|
315
|
+
var _a;
|
|
316
|
+
return (_jsx("div", __assign({ onClick: onClickDashboardItem
|
|
317
|
+
? function () { return handleOnClickDashboardItem(elem._id); }
|
|
293
318
|
: undefined,
|
|
294
319
|
// onClick={() => handleEditDashboardItem(elem)}
|
|
295
320
|
// className="qq-shadow"
|
|
@@ -305,21 +330,21 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
305
330
|
minHeight: rowHeight || 400,
|
|
306
331
|
borderRadius: 8,
|
|
307
332
|
paddingTop: 20,
|
|
308
|
-
}, children: (
|
|
333
|
+
} }, { children: _jsx("div", __assign({ style: {
|
|
309
334
|
width: '100%',
|
|
310
335
|
height: '100%',
|
|
311
336
|
boxSizing: 'content-box',
|
|
312
|
-
}, children: (
|
|
337
|
+
} }, { children: _jsx("div", __assign({ style: {
|
|
313
338
|
width: '100%',
|
|
314
339
|
height: '100%',
|
|
315
340
|
boxSizing: 'content-box',
|
|
316
|
-
}, children: (
|
|
341
|
+
} }, { children: _jsxs("div", __assign({ style: {
|
|
317
342
|
display: 'flex',
|
|
318
343
|
flexDirection: 'column',
|
|
319
344
|
justifyContent: 'space-between',
|
|
320
345
|
height: '100%',
|
|
321
346
|
boxSizing: 'content-box',
|
|
322
|
-
}, children: [(
|
|
347
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
323
348
|
display: 'flex',
|
|
324
349
|
flexDirection: 'row',
|
|
325
350
|
justifyContent: 'space-between',
|
|
@@ -328,7 +353,7 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
328
353
|
// paddingLeft: theme.padding,
|
|
329
354
|
// paddingRight: theme.padding,
|
|
330
355
|
// paddingTop: theme.padding,
|
|
331
|
-
}, children: [(
|
|
356
|
+
} }, { children: [_jsx("div", __assign({ style: {
|
|
332
357
|
fontFamily: theme.fontFamily,
|
|
333
358
|
color: theme.primaryTextColor,
|
|
334
359
|
boxSizing: 'content-box',
|
|
@@ -345,7 +370,7 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
345
370
|
display: 'block',
|
|
346
371
|
maxWidth: '100%',
|
|
347
372
|
overflow: 'hidden',
|
|
348
|
-
}, children: elem.name }), onClickDashboardItem ? ((
|
|
373
|
+
} }, { children: elem.name })), onClickDashboardItem ? (_jsx("div", __assign({
|
|
349
374
|
// className="hover:bg-black"
|
|
350
375
|
style: {
|
|
351
376
|
fontFamily: theme.fontFamily,
|
|
@@ -358,27 +383,28 @@ function Dashboard({ name, containerStyle, maxColumnWidth, rowHeight, onClickDas
|
|
|
358
383
|
display: 'flex',
|
|
359
384
|
alignItems: 'center',
|
|
360
385
|
justifyContent: 'flex-end',
|
|
361
|
-
}, children: 'view report →' })) : null] }), (
|
|
386
|
+
} }, { children: 'view report →' }))) : null] })), _jsx("div", __assign({ style: {
|
|
362
387
|
padding: 0,
|
|
363
388
|
height: '100%',
|
|
364
389
|
boxSizing: 'content-box',
|
|
365
|
-
}, children: (
|
|
390
|
+
} }, { children: _jsx(Chart, { containerStyle: {
|
|
366
391
|
display: 'flex',
|
|
367
392
|
width: '100%',
|
|
368
393
|
// TODO: fix fixed height
|
|
369
394
|
height: 300,
|
|
370
395
|
marginBottom: 50,
|
|
371
396
|
marginTop: 30,
|
|
372
|
-
}, isDateFilter: true, chartId: elem._id, colors: theme.chartColors
|
|
397
|
+
}, isDateFilter: true, chartId: elem._id, colors: ((_a = theme.chartColors) === null || _a === void 0 ? void 0 : _a.length)
|
|
373
398
|
? theme.chartColors
|
|
374
|
-
: undefined }) })] }) }) }) }, elem.name + '' + index));
|
|
375
|
-
}) })] }, section + '' + sectionIndex));
|
|
376
|
-
})] }));
|
|
399
|
+
: undefined }) }))] })) })) })) }), elem.name + '' + index));
|
|
400
|
+
}) }))] }), section + '' + sectionIndex));
|
|
401
|
+
})] })));
|
|
377
402
|
}
|
|
378
|
-
|
|
379
|
-
|
|
403
|
+
function Filter(_a) {
|
|
404
|
+
var _b;
|
|
405
|
+
var defaultValue = _a.defaultValue, theme = _a.theme, onValueChange = _a.onValueChange, filter = _a.filter;
|
|
380
406
|
//should be date as well as strings
|
|
381
|
-
|
|
407
|
+
var dropdownOptions = [
|
|
382
408
|
{ value: 'popupbagelsmardens', text: 'popupbagelsmardens' },
|
|
383
409
|
{ value: 'popupbagelswestport', text: 'popupbagelswestport' },
|
|
384
410
|
{ value: 'popupbagelseasthampton', text: 'popupbagelseasthampton' },
|
|
@@ -386,23 +412,23 @@ function Filter({ defaultValue, theme, onValueChange, filter }) {
|
|
|
386
412
|
{ value: 'popupbagelsredding', text: 'popupbagelsredding' },
|
|
387
413
|
{ value: 'popupbagelsthompson', text: 'popupbagelsthompson' },
|
|
388
414
|
];
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
415
|
+
var dropdownRef = useRef(null);
|
|
416
|
+
var _c = useState(false), showDropdown = _c[0], setShowDropdown = _c[1];
|
|
417
|
+
var _d = useInternalState(defaultValue, undefined), selectedValue = _d[0], setSelectedValue = _d[1];
|
|
418
|
+
var selectedDropdownValue = selectedValue ? (_b = selectedValue[2]) !== null && _b !== void 0 ? _b : null : null;
|
|
419
|
+
var handleDropdownOptionClick = function (dropdownValue) {
|
|
394
420
|
setSelectedValue([undefined, undefined, dropdownValue]);
|
|
395
|
-
onValueChange
|
|
421
|
+
onValueChange === null || onValueChange === void 0 ? void 0 : onValueChange([undefined, undefined, dropdownValue]);
|
|
396
422
|
setShowDropdown(false);
|
|
397
423
|
};
|
|
398
|
-
|
|
399
|
-
return ((
|
|
424
|
+
var _e = useSelectOnKeyDown(handleDropdownOptionClick, dropdownOptions.map(function (option) { return option.value; }), showDropdown, setShowDropdown, selectedDropdownValue), hoveredDropdownValue = _e[0], handleDropdownKeyDown = _e[1];
|
|
425
|
+
return (_jsxs("div", __assign({ style: { position: 'relative', width: '100%' } }, { children: [_jsx("div", __assign({ style: {
|
|
400
426
|
marginBottom: 6,
|
|
401
427
|
fontWeight: '600',
|
|
402
428
|
color: theme.secondaryTextColor,
|
|
403
429
|
fontSize: 14,
|
|
404
430
|
fontFamily: theme.fontFamily,
|
|
405
|
-
}, children: filter.label }), (
|
|
431
|
+
} }, { children: filter.label })), _jsx(FilterDropdown, { showDropdown: showDropdown, setShowDropdown: setShowDropdown, handleDropdownKeyDown: handleDropdownKeyDown, dropdownRef: dropdownRef, theme: theme, selectedDropdownValue: selectedDropdownValue, dropdownOptions: filter.options, field: filter.field, label: filter.labelField }), _jsx(FilterModal, { showDropdown: showDropdown, setShowDropdown: setShowDropdown, dropdownRef: dropdownRef, theme: theme, hoveredDropdownValue: hoveredDropdownValue, selectedDropdownValue: selectedDropdownValue, dropdownOptions: filter.options, handleDropdownOptionClick: handleDropdownOptionClick, field: filter.field, label: filter.labelField })] })));
|
|
406
432
|
}
|
|
407
433
|
function removeQuotes(str) {
|
|
408
434
|
if (str.startsWith('"') && str.endsWith('"')) {
|
|
@@ -412,21 +438,22 @@ function removeQuotes(str) {
|
|
|
412
438
|
return str;
|
|
413
439
|
}
|
|
414
440
|
}
|
|
415
|
-
function FilterDropdown(
|
|
416
|
-
|
|
417
|
-
|
|
441
|
+
function FilterDropdown(_a) {
|
|
442
|
+
var setShowDropdown = _a.setShowDropdown, dropdownRef = _a.dropdownRef, showDropdown = _a.showDropdown, handleDropdownKeyDown = _a.handleDropdownKeyDown, theme = _a.theme, _b = _a.dropdownPlaceholder, dropdownPlaceholder = _b === void 0 ? 'Select' : _b, selectedDropdownValue = _a.selectedDropdownValue, dropdownOptions = _a.dropdownOptions, field = _a.field, label = _a.label;
|
|
443
|
+
var dropdownText = selectedDropdownValue
|
|
444
|
+
? String(dropdownOptions.find(function (option) { return option[removeQuotes(field)] === selectedDropdownValue; })[removeQuotes(label)])
|
|
418
445
|
: dropdownPlaceholder;
|
|
419
|
-
return ((
|
|
446
|
+
return (_jsx("div", __assign({ style: {
|
|
420
447
|
display: 'flex',
|
|
421
448
|
alignItems: 'center',
|
|
422
449
|
justifyContent: 'space-between',
|
|
423
450
|
borderRadius: '0.375rem',
|
|
424
|
-
background: theme
|
|
425
|
-
fontFamily: theme
|
|
451
|
+
background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
|
|
452
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
426
453
|
boxShadow: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
|
|
427
|
-
}, children: (
|
|
454
|
+
} }, { children: _jsxs("button", __assign({ type: "button", style: {
|
|
428
455
|
// fontFamily: theme?.fontFamily,
|
|
429
|
-
borderColor: theme
|
|
456
|
+
borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E5E7EB',
|
|
430
457
|
borderStyle: 'solid',
|
|
431
458
|
borderWidth: 1,
|
|
432
459
|
cursor: 'pointer',
|
|
@@ -443,30 +470,31 @@ function FilterDropdown({ setShowDropdown, dropdownRef, showDropdown, handleDrop
|
|
|
443
470
|
minHeight: 38,
|
|
444
471
|
justifyContent: 'space-between',
|
|
445
472
|
alignItems: 'center',
|
|
446
|
-
background: theme
|
|
447
|
-
fontSize: theme
|
|
473
|
+
background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
|
|
474
|
+
fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '0.875rem',
|
|
448
475
|
// fontWeight: theme?.fontWeightMedium || '800',
|
|
449
|
-
}, ref: dropdownRef, onClick: ()
|
|
476
|
+
}, ref: dropdownRef, onClick: function () { return setShowDropdown(!showDropdown); }, onKeyDown: handleDropdownKeyDown }, { children: [_jsx("p", __assign({ style: {
|
|
450
477
|
margin: 0,
|
|
451
|
-
fontFamily: theme
|
|
452
|
-
color: theme
|
|
478
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
479
|
+
color: (theme === null || theme === void 0 ? void 0 : theme.primaryTextColor) || '#364153',
|
|
453
480
|
overflow: 'hidden',
|
|
454
481
|
textOverflow: 'ellipsis',
|
|
455
482
|
whiteSpace: 'nowrap',
|
|
456
|
-
fontWeight: theme
|
|
457
|
-
fontSize: theme
|
|
458
|
-
}, children: dropdownText }), (
|
|
483
|
+
fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightMedium) || '500',
|
|
484
|
+
fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '0.875rem',
|
|
485
|
+
} }, { children: dropdownText })), _jsx(ArrowDownHeadIcon, { style: {
|
|
459
486
|
height: '1.25rem',
|
|
460
487
|
width: '1.25rem',
|
|
461
488
|
flex: 'none',
|
|
462
|
-
color: theme
|
|
489
|
+
color: theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor,
|
|
463
490
|
marginRight: '-0.25rem',
|
|
464
|
-
}, "aria-hidden": "true" })] }) }));
|
|
491
|
+
}, "aria-hidden": "true" })] })) })));
|
|
465
492
|
}
|
|
466
|
-
function FilterModal(
|
|
467
|
-
|
|
493
|
+
function FilterModal(_a) {
|
|
494
|
+
var setShowDropdown = _a.setShowDropdown, dropdownRef = _a.dropdownRef, showDropdown = _a.showDropdown, theme = _a.theme, selectedDropdownValue = _a.selectedDropdownValue, hoveredDropdownValue = _a.hoveredDropdownValue, dropdownOptions = _a.dropdownOptions, handleDropdownOptionClick = _a.handleDropdownOptionClick, field = _a.field, label = _a.label;
|
|
495
|
+
return (_jsx(Modal, __assign({ showModal: showDropdown, setShowModal: setShowDropdown, parentRef: dropdownRef, theme: theme }, { children: _jsx(SelectedValueContext.Provider, __assign({ value: {
|
|
468
496
|
selectedValue: selectedDropdownValue,
|
|
469
497
|
handleValueChange: handleDropdownOptionClick,
|
|
470
|
-
}, children: (
|
|
498
|
+
} }, { children: _jsx(HoveredValueContext.Provider, __assign({ value: { hoveredValue: hoveredDropdownValue } }, { children: dropdownOptions.map(function (row, index) { return (_jsx(DropdownItem, { value: row[removeQuotes(field)], text: row[removeQuotes(label)], theme: theme, lastItem: dropdownOptions.length - 1 === index }, row[removeQuotes(field)])); }) })) })) })));
|
|
471
499
|
}
|
|
472
500
|
//# sourceMappingURL=Dashboard.js.map
|