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