@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/SQLEditor.js
CHANGED
|
@@ -1,22 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
});
|
|
4
20
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
49
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
9
50
|
// @ts-ignore
|
|
10
|
-
|
|
11
|
-
|
|
51
|
+
import { useState, useContext, useEffect } from 'react';
|
|
52
|
+
import MonacoEditor from '@monaco-editor/react';
|
|
12
53
|
// import './nightOwlLight.css';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
function convertPostgresColumn(column) {
|
|
19
|
-
|
|
54
|
+
import axios from 'axios';
|
|
55
|
+
import { ClientContext, SchemaContext, ThemeContext } from './Context';
|
|
56
|
+
import { ChevronDownIcon, ChevronRightIcon, } from '@heroicons/react/20/solid';
|
|
57
|
+
import { SpecialTable } from './Table';
|
|
58
|
+
import { TailSpin } from 'react-loader-spinner';
|
|
59
|
+
export function convertPostgresColumn(column) {
|
|
60
|
+
var format;
|
|
20
61
|
switch (column.dataTypeID) {
|
|
21
62
|
case 20: // int8
|
|
22
63
|
case 21: // int2
|
|
@@ -44,7 +85,6 @@ function convertPostgresColumn(column) {
|
|
|
44
85
|
format: format,
|
|
45
86
|
};
|
|
46
87
|
}
|
|
47
|
-
exports.convertPostgresColumn = convertPostgresColumn;
|
|
48
88
|
function defineEditorTheme(monaco, theme) {
|
|
49
89
|
monaco.editor.defineTheme('onedark', {
|
|
50
90
|
base: theme.darkMode ? 'vs-dark' : 'vs',
|
|
@@ -70,26 +110,30 @@ function setEditorTheme(editor, monaco) {
|
|
|
70
110
|
console.log('ERROR: ', e);
|
|
71
111
|
}
|
|
72
112
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
:
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
113
|
+
var QuillButton = function (_a) {
|
|
114
|
+
var onClick = _a.onClick, label = _a.label, theme = _a.theme, secondary = _a.secondary;
|
|
115
|
+
return (_jsx("button", __assign({ style: {
|
|
116
|
+
borderRadius: '6px',
|
|
117
|
+
backgroundColor: secondary
|
|
118
|
+
? (theme === null || theme === void 0 ? void 0 : theme.secondaryButtonColor) || '#FFFFFF'
|
|
119
|
+
: theme === null || theme === void 0 ? void 0 : theme.primaryButtonColor,
|
|
120
|
+
opacity: 1,
|
|
121
|
+
paddingLeft: '16px',
|
|
122
|
+
paddingRight: '16px',
|
|
123
|
+
paddingTop: '10px',
|
|
124
|
+
paddingBottom: '10px',
|
|
125
|
+
fontSize: '14px',
|
|
126
|
+
fontWeight: 600,
|
|
127
|
+
color: secondary ? theme === null || theme === void 0 ? void 0 : theme.primaryTextColor : '#FFFFFF',
|
|
128
|
+
cursor: 'pointer',
|
|
129
|
+
outline: 'none',
|
|
130
|
+
border: 'none',
|
|
131
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
132
|
+
}, onClick: onClick }, { children: label })));
|
|
133
|
+
};
|
|
134
|
+
var QuillTextInput = function (_a) {
|
|
135
|
+
var onChange = _a.onChange, value = _a.value, id = _a.id, placeholder = _a.placeholder, theme = _a.theme;
|
|
136
|
+
return (_jsx("input", { style: {
|
|
93
137
|
display: 'flex',
|
|
94
138
|
flexDirection: 'row',
|
|
95
139
|
alignItems: 'center',
|
|
@@ -99,134 +143,173 @@ const QuillTextInput = ({ onChange, value, id, placeholder, theme, }) => {
|
|
|
99
143
|
height: 36,
|
|
100
144
|
boxShadow: 'rgba(0, 0, 0, 0.1) 0px 1px 5px 0px',
|
|
101
145
|
width: '445px',
|
|
102
|
-
backgroundColor: theme
|
|
103
|
-
color: theme
|
|
146
|
+
backgroundColor: (theme === null || theme === void 0 ? void 0 : theme.backgroundColor) || 'white',
|
|
147
|
+
color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
|
|
104
148
|
borderWidth: '1px',
|
|
105
|
-
borderColor: theme
|
|
149
|
+
borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E7E7E7',
|
|
106
150
|
borderStyle: 'solid',
|
|
107
151
|
borderRadius: '6px',
|
|
108
152
|
}, id: id, onChange: onChange, value: value, placeholder: placeholder }));
|
|
109
153
|
};
|
|
110
|
-
function QueryEditor(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
(0,
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
154
|
+
export default function QueryEditor(_a) {
|
|
155
|
+
var _this = this;
|
|
156
|
+
var _b = _a.containerStyle, containerStyle = _b === void 0 ? { height: '100vh' } : _b, ButtonComponent = _a.ButtonComponent, SecondaryButtonComponent = _a.SecondaryButtonComponent, TextInputComponent = _a.TextInputComponent, TableComponent = _a.TableComponent, AddToDashboardButton = _a.AddToDashboardButton, LoadingComponent = _a.LoadingComponent;
|
|
157
|
+
var _c = useState(''), sqlPrompt = _c[0], setSqlPrompt = _c[1];
|
|
158
|
+
var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
|
|
159
|
+
var client = useContext(ClientContext)[0];
|
|
160
|
+
var theme = useContext(ThemeContext)[0];
|
|
161
|
+
var _e = useState(''), query = _e[0], setQuery = _e[1];
|
|
162
|
+
var _f = useState([]), rows = _f[0], setRows = _f[1];
|
|
163
|
+
var _g = useState([]), columns = _g[0], setColumns = _g[1];
|
|
164
|
+
var _h = useState([]), fields = _h[0], setFields = _h[1];
|
|
165
|
+
var _j = useContext(SchemaContext), schema = _j[0], setSchema = _j[1];
|
|
166
|
+
var _k = useState(''), errorMessage = _k[0], setErrorMessage = _k[1];
|
|
167
|
+
var _l = useState(false), sqlResponseLoading = _l[0], setSqlResponseLoading = _l[1];
|
|
168
|
+
var _m = useState(false), sqlQueryLoading = _m[0], setSqlQueryLoading = _m[1];
|
|
169
|
+
var _o = useState(false), schemaLoading = _o[0], setSchemaLoading = _o[1];
|
|
170
|
+
useEffect(function () {
|
|
171
|
+
var isSubscribed = true;
|
|
172
|
+
function getSchema() {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
174
|
+
var publicKey, environment, response3;
|
|
175
|
+
return __generator(this, function (_a) {
|
|
176
|
+
switch (_a.label) {
|
|
177
|
+
case 0:
|
|
178
|
+
publicKey = client.publicKey, environment = client.environment;
|
|
179
|
+
setSchemaLoading(true);
|
|
180
|
+
return [4 /*yield*/, axios.get("https://quill-344421.uc.r.appspot.com/schema2/".concat(publicKey, "/"), {
|
|
181
|
+
headers: {
|
|
182
|
+
Authorization: "Bearer ",
|
|
183
|
+
environment: environment || undefined,
|
|
184
|
+
},
|
|
185
|
+
})];
|
|
186
|
+
case 1:
|
|
187
|
+
response3 = _a.sent();
|
|
188
|
+
if (isSubscribed) {
|
|
189
|
+
setSchema(response3.data.tables);
|
|
190
|
+
setSchemaLoading(false);
|
|
191
|
+
}
|
|
192
|
+
return [2 /*return*/];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
134
195
|
});
|
|
135
|
-
if (isSubscribed) {
|
|
136
|
-
setSchema(response3.data.tables);
|
|
137
|
-
setSchemaLoading(false);
|
|
138
|
-
}
|
|
139
196
|
}
|
|
140
197
|
if (isSubscribed) {
|
|
141
198
|
getSchema();
|
|
142
199
|
}
|
|
143
|
-
return ()
|
|
200
|
+
return function () {
|
|
144
201
|
isSubscribed = false;
|
|
145
202
|
};
|
|
146
203
|
}, []);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
response = await axios_1.default.post(queryEndpoint, { metadata: { query, task: 'query' } }, { headers: queryHeaders, withCredentials });
|
|
204
|
+
var handleRunSqlPrompt = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
205
|
+
var publicKey, environment, response;
|
|
206
|
+
return __generator(this, function (_a) {
|
|
207
|
+
switch (_a.label) {
|
|
208
|
+
case 0:
|
|
209
|
+
publicKey = client.publicKey, environment = client.environment;
|
|
210
|
+
setSqlResponseLoading(true);
|
|
211
|
+
return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/quillai", {
|
|
212
|
+
initialQuestion: sqlPrompt,
|
|
213
|
+
publicKey: publicKey,
|
|
214
|
+
}, {
|
|
215
|
+
headers: {
|
|
216
|
+
Authorization: "Bearer ",
|
|
217
|
+
environment: environment || undefined,
|
|
218
|
+
},
|
|
219
|
+
})];
|
|
220
|
+
case 1:
|
|
221
|
+
response = _a.sent();
|
|
222
|
+
setQuery(response.data.message);
|
|
223
|
+
setSqlResponseLoading(false);
|
|
224
|
+
return [2 /*return*/];
|
|
169
225
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
226
|
+
});
|
|
227
|
+
}); };
|
|
228
|
+
var handleRunQuery = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
229
|
+
var publicKey, customerId, environment, queryEndpoint, queryHeaders, withCredentials, response, e_1;
|
|
230
|
+
return __generator(this, function (_a) {
|
|
231
|
+
switch (_a.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
publicKey = client.publicKey, customerId = client.customerId, environment = client.environment, queryEndpoint = client.queryEndpoint, queryHeaders = client.queryHeaders, withCredentials = client.withCredentials;
|
|
234
|
+
_a.label = 1;
|
|
235
|
+
case 1:
|
|
236
|
+
_a.trys.push([1, 6, , 7]);
|
|
237
|
+
response = void 0;
|
|
238
|
+
setSqlQueryLoading(true);
|
|
239
|
+
if (!queryEndpoint) return [3 /*break*/, 3];
|
|
240
|
+
return [4 /*yield*/, axios.post(queryEndpoint, { metadata: { query: query, task: 'query' } }, { headers: queryHeaders, withCredentials: withCredentials })];
|
|
241
|
+
case 2:
|
|
242
|
+
response = _a.sent();
|
|
243
|
+
return [3 /*break*/, 5];
|
|
244
|
+
case 3: return [4 /*yield*/, axios.post("https://quill-344421.uc.r.appspot.com/dashquery", {
|
|
245
|
+
query: query,
|
|
246
|
+
}, {
|
|
247
|
+
params: {
|
|
248
|
+
orgId: customerId,
|
|
249
|
+
publicKey: publicKey,
|
|
250
|
+
},
|
|
251
|
+
headers: {
|
|
252
|
+
Authorization: "Bearer ",
|
|
253
|
+
environment: environment || undefined,
|
|
254
|
+
},
|
|
255
|
+
})];
|
|
256
|
+
case 4:
|
|
257
|
+
response = _a.sent();
|
|
258
|
+
_a.label = 5;
|
|
259
|
+
case 5:
|
|
260
|
+
if (response && response.data && response.data.errorMessage) {
|
|
261
|
+
setSqlQueryLoading(false);
|
|
262
|
+
setErrorMessage('Failed to run SQL query: ' + response.data.errorMessage);
|
|
263
|
+
setRows([]);
|
|
264
|
+
setColumns([]);
|
|
265
|
+
setFields([]);
|
|
266
|
+
return [2 /*return*/];
|
|
267
|
+
}
|
|
268
|
+
setSqlQueryLoading(false);
|
|
269
|
+
setErrorMessage('');
|
|
270
|
+
setRows(response.data.rows && response.data.rows.length
|
|
271
|
+
? response.data.rows
|
|
272
|
+
: []);
|
|
273
|
+
setColumns(response.data.fields.map(function (elem) { return convertPostgresColumn(elem); }));
|
|
274
|
+
setFields(response.data.fields);
|
|
275
|
+
return [3 /*break*/, 7];
|
|
276
|
+
case 6:
|
|
277
|
+
e_1 = _a.sent();
|
|
278
|
+
console.log('ERROR: ', e_1);
|
|
279
|
+
return [2 /*return*/];
|
|
280
|
+
case 7: return [2 /*return*/];
|
|
191
281
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
? response.data.rows
|
|
196
|
-
: []);
|
|
197
|
-
setColumns(response.data.fields.map(elem => convertPostgresColumn(elem)));
|
|
198
|
-
setFields(response.data.fields);
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
console.log('ERROR: ', e);
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
const handleAddToDashboard = () => {
|
|
282
|
+
});
|
|
283
|
+
}); };
|
|
284
|
+
var handleAddToDashboard = function () {
|
|
206
285
|
setIsOpen(true);
|
|
207
286
|
};
|
|
208
287
|
/* all your useState and useContext calls and your useEffect hooks */
|
|
209
|
-
|
|
288
|
+
var downloadCSV = function () {
|
|
210
289
|
// report.rows
|
|
211
290
|
if (!rows.length) {
|
|
212
291
|
return;
|
|
213
292
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
293
|
+
var json = rows; // JSON data passed as a prop
|
|
294
|
+
var fields = Object.keys(json[0]); // Assumes all objects have same keys
|
|
295
|
+
var csvRows = [];
|
|
217
296
|
// Header row
|
|
218
297
|
csvRows.push(fields.join(','));
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const values = fields.map(field => JSON.stringify(row[field] || ''));
|
|
298
|
+
var _loop_1 = function (row) {
|
|
299
|
+
var values = fields.map(function (field) { return JSON.stringify(row[field] || ''); });
|
|
222
300
|
csvRows.push(values.join(','));
|
|
301
|
+
};
|
|
302
|
+
// Data rows
|
|
303
|
+
for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
|
|
304
|
+
var row = json_1[_i];
|
|
305
|
+
_loop_1(row);
|
|
223
306
|
}
|
|
224
307
|
// Create CSV string and create a 'blob' with it
|
|
225
|
-
|
|
226
|
-
|
|
308
|
+
var csvString = csvRows.join('\r\n');
|
|
309
|
+
var csvBlob = new Blob([csvString], { type: 'text/csv' });
|
|
227
310
|
// Create a download link and click it
|
|
228
|
-
|
|
229
|
-
downloadLink.download =
|
|
311
|
+
var downloadLink = document.createElement('a');
|
|
312
|
+
downloadLink.download = "".concat(query, ".csv");
|
|
230
313
|
downloadLink.href = URL.createObjectURL(csvBlob);
|
|
231
314
|
downloadLink.style.display = 'none';
|
|
232
315
|
document.body.appendChild(downloadLink);
|
|
@@ -234,28 +317,28 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
234
317
|
document.body.removeChild(downloadLink);
|
|
235
318
|
};
|
|
236
319
|
/* rest of your methods */
|
|
237
|
-
return ((
|
|
320
|
+
return (_jsx("div", __assign({ style: containerStyle }, { children: _jsx("div", __assign({ style: {
|
|
238
321
|
height: 'calc(100%)',
|
|
239
322
|
display: 'flex',
|
|
240
323
|
flexDirection: 'column',
|
|
241
324
|
padding: 0,
|
|
242
|
-
}, children: (
|
|
325
|
+
} }, { children: _jsx("div", __assign({ style: { height: '100%', display: 'flex', flexDirection: 'column' } }, { children: _jsxs("div", __assign({ style: {
|
|
243
326
|
width: '100%',
|
|
244
327
|
display: 'flex',
|
|
245
328
|
height: '100%',
|
|
246
329
|
flexDirection: 'row',
|
|
247
|
-
}, children: [(
|
|
330
|
+
} }, { children: [_jsx(SchemaListComponent, { schema: schema, theme: theme, LoadingComponent: LoadingComponent, loading: schemaLoading }), _jsxs("div", __assign({ style: {
|
|
248
331
|
display: 'flex',
|
|
249
332
|
flexDirection: 'column',
|
|
250
333
|
width: 'calc(100% - 250px)',
|
|
251
|
-
}, children: [(
|
|
334
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
252
335
|
// TODO: change color
|
|
253
336
|
height: 80,
|
|
254
337
|
background: 'white',
|
|
255
338
|
display: 'flex',
|
|
256
339
|
flexDirection: 'row',
|
|
257
340
|
alignItems: 'center',
|
|
258
|
-
}, children: [(
|
|
341
|
+
} }, { children: [_jsx("div", __assign({ style: { minWidth: 440, marginRight: 10 } }, { children: (TextInputComponent && (_jsx(TextInputComponent, { id: "ai-search", value: sqlPrompt, onChange: function (e) { return setSqlPrompt(e.target.value); }, placeholder: "Ask a question..." }))) || (_jsx(QuillTextInput, { id: "ai-search", value: sqlPrompt, onChange: function (e) { return setSqlPrompt(e.target.value); }, placeholder: "Ask a question...", theme: theme })) })), (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunSqlPrompt, label: "Ask AI" }))) || (_jsx(QuillButton, { theme: theme, onClick: handleRunSqlPrompt, label: "Ask AI" }))] })), _jsx("div", __assign({ style: { height: 'calc(50% - 40px)' } }, { children: _jsx(SQLEditorComponent, { query: query, setQuery: setQuery, handleRunQuery: handleRunQuery, theme: theme, defineEditorTheme: defineEditorTheme, setEditorTheme: setEditorTheme, ButtonComponent: ButtonComponent, loading: sqlResponseLoading, LoadingComponent: LoadingComponent }) })), _jsxs("div", __assign({ style: {
|
|
259
342
|
height: 'calc(50% - 40px)',
|
|
260
343
|
display: 'flex',
|
|
261
344
|
flexDirection: 'column',
|
|
@@ -263,52 +346,52 @@ function QueryEditor({ containerStyle = { height: '100vh' }, ButtonComponent, Se
|
|
|
263
346
|
margin: 0,
|
|
264
347
|
border: 'none',
|
|
265
348
|
outline: 'none',
|
|
266
|
-
}, children: [errorMessage && ((
|
|
267
|
-
fontFamily: theme
|
|
268
|
-
color: theme
|
|
349
|
+
} }, { children: [errorMessage && (_jsx("div", __assign({ style: {
|
|
350
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
351
|
+
color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
|
|
269
352
|
fontSize: 15,
|
|
270
353
|
fontWeight: '400',
|
|
271
|
-
}, children: (
|
|
354
|
+
} }, { children: _jsx("div", __assign({ style: {
|
|
272
355
|
padding: 30,
|
|
273
356
|
// TODO: change color
|
|
274
357
|
background: 'rgba(0,0,0,0.02)',
|
|
275
358
|
display: 'inline-block',
|
|
276
359
|
flex: 0,
|
|
277
360
|
borderRadius: 6,
|
|
278
|
-
color: theme
|
|
279
|
-
fontFamily: theme
|
|
280
|
-
}, children: errorMessage }) })), errorMessage
|
|
361
|
+
color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
|
|
362
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
363
|
+
} }, { children: errorMessage })) }))), errorMessage
|
|
281
364
|
? null
|
|
282
|
-
: (TableComponent && ((
|
|
365
|
+
: (TableComponent && (_jsx(TableComponent, { rows: rows, columns: columns, height: "calc(100% - 70px)" }))) || (_jsx(SpecialTable, { rows: rows, columns: columns, height: "calc(100% - 70px)", LoadingComponent: LoadingComponent, loading: sqlQueryLoading, theme: theme })), _jsx("div", __assign({ style: {
|
|
283
366
|
height: 70,
|
|
284
367
|
// TODO: change color
|
|
285
|
-
background: theme
|
|
286
|
-
}, children: rows.length ? ((
|
|
368
|
+
background: theme === null || theme === void 0 ? void 0 : theme.backgroundColor,
|
|
369
|
+
} }, { children: rows.length ? (_jsxs("div", __assign({ style: {
|
|
287
370
|
display: 'flex',
|
|
288
371
|
flexDirection: 'column',
|
|
289
372
|
height: 70,
|
|
290
373
|
border: 'none',
|
|
291
|
-
}, children: [(
|
|
374
|
+
} }, { children: [_jsx("div", { style: {
|
|
292
375
|
height: 1,
|
|
293
376
|
width: '100%',
|
|
294
377
|
// TODO: change color
|
|
295
378
|
// background: theme.borderColor,
|
|
296
|
-
} }), (
|
|
379
|
+
} }), _jsxs("div", __assign({ style: {
|
|
297
380
|
marginLeft: 0,
|
|
298
381
|
height: 69,
|
|
299
382
|
display: 'flex',
|
|
300
383
|
alignItems: 'center',
|
|
301
384
|
justifyContent: 'flex-end',
|
|
302
385
|
paddingRight: 20,
|
|
303
|
-
}, children: [(SecondaryButtonComponent && ((
|
|
386
|
+
} }, { children: [(SecondaryButtonComponent && (_jsx(SecondaryButtonComponent, { onClick: downloadCSV, label: "Download CSV" }))) || (_jsx(QuillButton, { theme: theme, onClick: downloadCSV, label: "Download CSV", secondary: true })), AddToDashboardButton && _jsx("div", { style: { width: 10 } }), AddToDashboardButton && (_jsx(AddToDashboardButton
|
|
304
387
|
// @ts-ignore
|
|
305
388
|
, {
|
|
306
389
|
// @ts-ignore
|
|
307
|
-
rows: rows, columns: columns, query: query })), (
|
|
390
|
+
rows: rows, columns: columns, query: query })), _jsx("div", {})] }))] }))) : null }))] }))] }))] })) })) })) })));
|
|
308
391
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return ((
|
|
392
|
+
var SQLEditorComponent = function (_a) {
|
|
393
|
+
var query = _a.query, setQuery = _a.setQuery, handleRunQuery = _a.handleRunQuery, defineEditorTheme = _a.defineEditorTheme, setEditorTheme = _a.setEditorTheme, ButtonComponent = _a.ButtonComponent, theme = _a.theme, loading = _a.loading, LoadingComponent = _a.LoadingComponent;
|
|
394
|
+
return (_jsxs("div", __assign({ style: {
|
|
312
395
|
background: theme.backgroundColor,
|
|
313
396
|
// maxHeight: 700,
|
|
314
397
|
width: '100%',
|
|
@@ -322,27 +405,27 @@ const SQLEditorComponent = ({ query, setQuery, handleRunQuery, defineEditorTheme
|
|
|
322
405
|
borderTopRightRadius: 0,
|
|
323
406
|
borderBottomRightRadius: 0,
|
|
324
407
|
overflow: 'hidden',
|
|
325
|
-
}, children: [loading ? ((
|
|
408
|
+
} }, { children: [loading ? (_jsxs("div", __assign({ style: {
|
|
326
409
|
height: 'calc(100% - 70px)',
|
|
327
410
|
width: '100%',
|
|
328
411
|
display: 'flex',
|
|
329
412
|
alignItems: 'center',
|
|
330
413
|
justifyContent: 'center',
|
|
331
414
|
background: '#F9F9F9',
|
|
332
|
-
}, children: [LoadingComponent && (
|
|
415
|
+
} }, { children: [LoadingComponent && _jsx(LoadingComponent, {}), !LoadingComponent && (_jsx(TailSpin, { height: 36, width: 36, color: "#364153" }))] }))) : (_jsx(MonacoEditor, { height: "calc(100% - 70px)", width: "100%", defaultLanguage: "pgsql", defaultValue: "", value: query, loading: _jsx("div", {}), options: {
|
|
333
416
|
wordWrap: 'on',
|
|
334
417
|
minimap: {
|
|
335
418
|
enabled: false,
|
|
336
419
|
},
|
|
337
420
|
padding: { top: 16 },
|
|
338
|
-
}, onChange: query
|
|
421
|
+
}, onChange: function (query) { return setQuery(query); }, beforeMount: function (monaco) { return defineEditorTheme(monaco, theme); }, onMount: setEditorTheme })), _jsx("div", __assign({ style: {
|
|
339
422
|
display: 'flex',
|
|
340
423
|
flexDirection: 'row',
|
|
341
424
|
alignItems: 'center',
|
|
342
425
|
height: 70,
|
|
343
|
-
}, children: (ButtonComponent && ((
|
|
426
|
+
} }, { children: (ButtonComponent && (_jsx(ButtonComponent, { onClick: handleRunQuery, label: "Run query" }))) || (_jsx(QuillButton, { onClick: handleRunQuery, label: "Run query", theme: theme })) }))] })));
|
|
344
427
|
};
|
|
345
|
-
|
|
428
|
+
var styles = {
|
|
346
429
|
columnHeader: {
|
|
347
430
|
boxSizing: 'border-box',
|
|
348
431
|
flex: '150 0 auto',
|
|
@@ -374,9 +457,10 @@ const styles = {
|
|
|
374
457
|
overflow: 'hidden',
|
|
375
458
|
},
|
|
376
459
|
};
|
|
377
|
-
|
|
460
|
+
var SchemaListComponent = function (_a) {
|
|
461
|
+
var schema = _a.schema, theme = _a.theme, loading = _a.loading, LoadingComponent = _a.LoadingComponent;
|
|
378
462
|
if (loading) {
|
|
379
|
-
return ((
|
|
463
|
+
return (_jsxs("div", __assign({ style: {
|
|
380
464
|
background: theme.backgroundColor,
|
|
381
465
|
// maxHeight: 700,
|
|
382
466
|
width: 250,
|
|
@@ -390,9 +474,9 @@ const SchemaListComponent = ({ schema, theme, loading, LoadingComponent }) => {
|
|
|
390
474
|
display: 'flex',
|
|
391
475
|
// alignItems: 'center',
|
|
392
476
|
justifyContent: 'center',
|
|
393
|
-
}, children: [(
|
|
477
|
+
} }, { children: [_jsx("div", { style: { height: 100 } }), LoadingComponent && _jsx(LoadingComponent, {}), !LoadingComponent && (_jsx(TailSpin, { height: 36, width: 36, color: "#364153" }))] })));
|
|
394
478
|
}
|
|
395
|
-
return ((
|
|
479
|
+
return (_jsx("div", __assign({ style: {
|
|
396
480
|
background: theme.backgroundColor,
|
|
397
481
|
// maxHeight: 700,
|
|
398
482
|
width: 250,
|
|
@@ -402,11 +486,12 @@ const SchemaListComponent = ({ schema, theme, loading, LoadingComponent }) => {
|
|
|
402
486
|
// maxHeight: "100%",
|
|
403
487
|
paddingLeft: 20,
|
|
404
488
|
paddingRight: 30,
|
|
405
|
-
}, children: schema.map((elem, index)
|
|
489
|
+
} }, { children: schema.map(function (elem, index) { return (_jsx(SchemaItem, { elem: elem, theme: theme, index: index }, elem.displayName + index)); }) })));
|
|
406
490
|
};
|
|
407
|
-
function SchemaItem(
|
|
408
|
-
|
|
409
|
-
|
|
491
|
+
function SchemaItem(_a) {
|
|
492
|
+
var elem = _a.elem, theme = _a.theme, index = _a.index;
|
|
493
|
+
var _b = useState(index === 0), isOpen = _b[0], setIsOpen = _b[1];
|
|
494
|
+
var schemaContainerStyle = {
|
|
410
495
|
display: 'flex',
|
|
411
496
|
flexDirection: 'column',
|
|
412
497
|
// WebkitTouchCallout: "none",
|
|
@@ -416,7 +501,7 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
416
501
|
// msUserSelect: "none",
|
|
417
502
|
// userSelect: "none",
|
|
418
503
|
};
|
|
419
|
-
|
|
504
|
+
var schemaRowStyle = {
|
|
420
505
|
display: 'flex',
|
|
421
506
|
flexDirection: 'row',
|
|
422
507
|
alignItems: 'center',
|
|
@@ -424,10 +509,10 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
424
509
|
justifyContent: 'space-between',
|
|
425
510
|
cursor: 'pointer',
|
|
426
511
|
};
|
|
427
|
-
|
|
512
|
+
var schemaRowHoverStyle = {
|
|
428
513
|
background: theme.selectUnderlayColor,
|
|
429
514
|
};
|
|
430
|
-
return ((
|
|
515
|
+
return (_jsxs("div", __assign({ style: schemaContainerStyle }, { children: [_jsxs("div", __assign({ style: __assign(__assign({}, schemaRowStyle), (isOpen && schemaRowHoverStyle)), onClick: function () { return setIsOpen(!isOpen); } }, { children: [_jsx("p", __assign({ style: {
|
|
431
516
|
marginLeft: theme.padding,
|
|
432
517
|
fontSize: 13,
|
|
433
518
|
color: '#384151',
|
|
@@ -437,8 +522,8 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
437
522
|
margin: 0,
|
|
438
523
|
textOverflow: 'ellipsis',
|
|
439
524
|
overflow: 'hidden',
|
|
440
|
-
fontFamily: theme
|
|
441
|
-
}, title: elem.displayName, children: elem.displayName }), (
|
|
525
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
526
|
+
}, title: elem.displayName }, { children: elem.displayName })), _jsx("div", __assign({ style: {
|
|
442
527
|
display: 'flex',
|
|
443
528
|
alignItems: 'center',
|
|
444
529
|
justifyContent: 'center',
|
|
@@ -447,19 +532,19 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
447
532
|
paddingBottom: 12,
|
|
448
533
|
paddingLeft: 0,
|
|
449
534
|
cursor: 'pointer',
|
|
450
|
-
}, children: isOpen ? ((
|
|
535
|
+
} }, { children: isOpen ? (_jsx(ChevronDownIcon, { style: { height: 13, width: 13, color: theme.secondaryTextColor }, "aria-hidden": "true" })) : (_jsx(ChevronRightIcon, { style: { height: 13, width: 13, color: theme.secondaryTextColor }, "aria-hidden": "true" })) }))] })), isOpen ? (_jsx("div", __assign({ style: {
|
|
451
536
|
paddingBottom: theme.padding,
|
|
452
537
|
display: 'flex',
|
|
453
538
|
flexDirection: 'column',
|
|
454
539
|
paddingLeft: theme.padding,
|
|
455
540
|
paddingRight: theme.padding,
|
|
456
|
-
}, children: elem.columns.map((elem, index)
|
|
541
|
+
} }, { children: elem.columns.map(function (elem, index) { return (_jsxs("div", __assign({ style: {
|
|
457
542
|
paddingTop: theme.padding,
|
|
458
543
|
display: 'flex',
|
|
459
544
|
flexDirection: 'row',
|
|
460
545
|
alignItems: 'center',
|
|
461
546
|
justifyContent: 'space-between',
|
|
462
|
-
}, children: [(
|
|
547
|
+
} }, { children: [_jsx("div", __assign({ title: elem.displayName,
|
|
463
548
|
// className="text-gray-500"
|
|
464
549
|
style: {
|
|
465
550
|
fontSize: 12,
|
|
@@ -473,8 +558,8 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
473
558
|
overflow: 'hidden',
|
|
474
559
|
width: 200,
|
|
475
560
|
maxWidth: 200,
|
|
476
|
-
fontFamily: theme
|
|
477
|
-
}, children: elem.displayName }), (
|
|
561
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
562
|
+
} }, { children: elem.displayName })), _jsx("div", __assign({
|
|
478
563
|
// className="text-gray-500"
|
|
479
564
|
title: elem.displayName, style: {
|
|
480
565
|
fontSize: 12,
|
|
@@ -482,7 +567,7 @@ function SchemaItem({ elem, theme, index }) {
|
|
|
482
567
|
color: theme.secondaryTextColor,
|
|
483
568
|
padding: 0,
|
|
484
569
|
margin: 0,
|
|
485
|
-
fontFamily: theme
|
|
486
|
-
}, children: elem.fieldType })] }, elem.displayName + elem.index))) })) : null] }));
|
|
570
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
571
|
+
} }, { children: elem.fieldType }))] }), elem.displayName + elem.index)); }) }))) : null] })));
|
|
487
572
|
}
|
|
488
573
|
//# sourceMappingURL=SQLEditor.js.map
|