@deephaven/console 0.5.2-matplotlib.2 → 0.6.1-demo.8

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.
Files changed (114) hide show
  1. package/dist/Console.d.ts +3 -0
  2. package/dist/Console.d.ts.map +1 -1
  3. package/dist/Console.js +807 -871
  4. package/dist/Console.js.map +1 -1
  5. package/dist/ConsoleInput.d.ts +1 -38
  6. package/dist/ConsoleInput.d.ts.map +1 -1
  7. package/dist/ConsoleInput.js +331 -436
  8. package/dist/ConsoleInput.js.map +1 -1
  9. package/dist/ConsoleMenu.js +159 -215
  10. package/dist/ConsoleMenu.js.map +1 -1
  11. package/dist/ConsolePropTypes.js +1 -1
  12. package/dist/ConsolePropTypes.js.map +1 -1
  13. package/dist/ConsoleShortcuts.js +2 -2
  14. package/dist/ConsoleShortcuts.js.map +1 -1
  15. package/dist/ConsoleStatusBar.js +85 -125
  16. package/dist/ConsoleStatusBar.js.map +1 -1
  17. package/dist/StoragePropTypes.js +2 -2
  18. package/dist/StoragePropTypes.js.map +1 -1
  19. package/dist/command-history/CommandHistory.css +5 -2
  20. package/dist/command-history/CommandHistory.css.map +1 -1
  21. package/dist/command-history/CommandHistory.d.ts +5 -0
  22. package/dist/command-history/CommandHistory.d.ts.map +1 -1
  23. package/dist/command-history/CommandHistory.js +303 -391
  24. package/dist/command-history/CommandHistory.js.map +1 -1
  25. package/dist/command-history/CommandHistoryActions.css +4 -0
  26. package/dist/command-history/CommandHistoryActions.css.map +1 -1
  27. package/dist/command-history/CommandHistoryActions.d.ts.map +1 -1
  28. package/dist/command-history/CommandHistoryActions.js +40 -79
  29. package/dist/command-history/CommandHistoryActions.js.map +1 -1
  30. package/dist/command-history/CommandHistoryItem.css +1 -1
  31. package/dist/command-history/CommandHistoryItem.d.ts +5 -0
  32. package/dist/command-history/CommandHistoryItem.d.ts.map +1 -1
  33. package/dist/command-history/CommandHistoryItem.js +15 -9
  34. package/dist/command-history/CommandHistoryItem.js.map +1 -1
  35. package/dist/command-history/CommandHistoryItemTooltip.d.ts +1 -40
  36. package/dist/command-history/CommandHistoryItemTooltip.d.ts.map +1 -1
  37. package/dist/command-history/CommandHistoryItemTooltip.js +139 -189
  38. package/dist/command-history/CommandHistoryItemTooltip.js.map +1 -1
  39. package/dist/command-history/CommandHistoryViewportUpdater.js +30 -35
  40. package/dist/command-history/CommandHistoryViewportUpdater.js.map +1 -1
  41. package/dist/command-history/index.js +5 -5
  42. package/dist/command-history/index.js.map +1 -1
  43. package/dist/common/Code.js +34 -70
  44. package/dist/common/Code.js.map +1 -1
  45. package/dist/common/ConsoleConstants.js +3 -24
  46. package/dist/common/ConsoleConstants.js.map +1 -1
  47. package/dist/common/ConsoleUtils.d.ts +1 -3
  48. package/dist/common/ConsoleUtils.d.ts.map +1 -1
  49. package/dist/common/ConsoleUtils.js +60 -94
  50. package/dist/common/ConsoleUtils.js.map +1 -1
  51. package/dist/common/ObjectIcon.js +4 -2
  52. package/dist/common/ObjectIcon.js.map +1 -1
  53. package/dist/common/index.d.js +1 -34
  54. package/dist/common/index.d.js.map +1 -1
  55. package/dist/common/index.js +4 -4
  56. package/dist/common/index.js.map +1 -1
  57. package/dist/console-history/ConsoleHistory.js +27 -63
  58. package/dist/console-history/ConsoleHistory.js.map +1 -1
  59. package/dist/console-history/ConsoleHistoryItem.js +116 -154
  60. package/dist/console-history/ConsoleHistoryItem.js.map +1 -1
  61. package/dist/console-history/ConsoleHistoryItemResult.js +4 -2
  62. package/dist/console-history/ConsoleHistoryItemResult.js.map +1 -1
  63. package/dist/console-history/ConsoleHistoryResultErrorMessage.js +94 -132
  64. package/dist/console-history/ConsoleHistoryResultErrorMessage.js.map +1 -1
  65. package/dist/console-history/ConsoleHistoryResultInProgress.js +42 -76
  66. package/dist/console-history/ConsoleHistoryResultInProgress.js.map +1 -1
  67. package/dist/console-history/index.js +5 -5
  68. package/dist/console-history/index.js.map +1 -1
  69. package/dist/csv/CsvFormats.js +14 -28
  70. package/dist/csv/CsvFormats.js.map +1 -1
  71. package/dist/csv/CsvInputBar.css +25 -23
  72. package/dist/csv/CsvInputBar.css.map +1 -1
  73. package/dist/csv/CsvInputBar.d.ts +2 -45
  74. package/dist/csv/CsvInputBar.d.ts.map +1 -1
  75. package/dist/csv/CsvInputBar.js +298 -372
  76. package/dist/csv/CsvInputBar.js.map +1 -1
  77. package/dist/csv/CsvOverlay.js +197 -243
  78. package/dist/csv/CsvOverlay.js.map +1 -1
  79. package/dist/csv/CsvParser.js +186 -209
  80. package/dist/csv/CsvParser.js.map +1 -1
  81. package/dist/csv/CsvTypeParser.js +185 -210
  82. package/dist/csv/CsvTypeParser.js.map +1 -1
  83. package/dist/csv/NewTableColumnTypes.js +1 -5
  84. package/dist/csv/NewTableColumnTypes.js.map +1 -1
  85. package/dist/index.js +14 -14
  86. package/dist/index.js.map +1 -1
  87. package/dist/log/LogLevelMenuItem.js +24 -58
  88. package/dist/log/LogLevelMenuItem.js.map +1 -1
  89. package/dist/log/LogView.js +429 -484
  90. package/dist/log/LogView.js.map +1 -1
  91. package/dist/monaco/MonacoCompletionProvider.js +92 -124
  92. package/dist/monaco/MonacoCompletionProvider.js.map +1 -1
  93. package/dist/monaco/MonacoUtils.js +315 -331
  94. package/dist/monaco/MonacoUtils.js.map +1 -1
  95. package/dist/monaco/index.js +2 -2
  96. package/dist/monaco/index.js.map +1 -1
  97. package/dist/monaco/lang/db.js +3 -3
  98. package/dist/monaco/lang/db.js.map +1 -1
  99. package/dist/monaco/lang/groovy.js +3 -3
  100. package/dist/monaco/lang/groovy.js.map +1 -1
  101. package/dist/monaco/lang/log.js +3 -3
  102. package/dist/monaco/lang/log.js.map +1 -1
  103. package/dist/monaco/lang/python.js +3 -3
  104. package/dist/monaco/lang/python.js.map +1 -1
  105. package/dist/monaco/lang/scala.js +5 -5
  106. package/dist/monaco/lang/scala.js.map +1 -1
  107. package/dist/notebook/Editor.js +101 -141
  108. package/dist/notebook/Editor.js.map +1 -1
  109. package/dist/notebook/ScriptEditor.js +261 -301
  110. package/dist/notebook/ScriptEditor.js.map +1 -1
  111. package/dist/notebook/ScriptEditorUtils.js +26 -42
  112. package/dist/notebook/ScriptEditorUtils.js.map +1 -1
  113. package/dist/tsconfig.tsbuildinfo +1 -1
  114. package/package.json +26 -56
@@ -1,56 +1,17 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
-
5
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
6
-
7
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
8
-
9
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
-
11
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
12
-
13
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
14
-
15
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
16
-
17
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
22
-
23
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
24
-
25
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
26
-
27
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
28
-
29
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
30
-
31
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
32
-
33
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
34
-
35
1
  import React, { Component } from 'react';
36
2
  import PropTypes from 'prop-types';
37
- import { connect } from 'react-redux';
38
3
  import classNames from 'classnames';
39
4
  import JSZip from 'jszip';
40
- import { Checkbox } from '@deephaven/components';
5
+ import { Button, Checkbox } from '@deephaven/components';
41
6
  import Log from '@deephaven/log';
42
- import { getTimeZone } from '@deephaven/redux';
43
7
  import { DbNameValidator } from '@deephaven/utils';
44
- import CsvOverlay from './CsvOverlay';
45
- import CsvParser from './CsvParser';
46
- import CsvFormats from './CsvFormats';
8
+ import CsvOverlay from "./CsvOverlay.js";
9
+ import CsvParser from "./CsvParser.js";
10
+ import CsvFormats from "./CsvFormats.js";
47
11
  import "./CsvInputBar.css";
48
12
  var log = Log.module('CsvInputBar');
49
- var TYPE_OPTIONS = Object.entries(CsvFormats.TYPES).map(function (_ref) {
50
- var _ref2 = _slicedToArray(_ref, 2),
51
- key = _ref2[0],
52
- value = _ref2[1];
53
-
13
+ var TYPE_OPTIONS = Object.entries(CsvFormats.TYPES).map((_ref) => {
14
+ var [key, value] = _ref;
54
15
  return /*#__PURE__*/React.createElement("option", {
55
16
  key: key,
56
17
  value: key
@@ -60,27 +21,19 @@ var TYPE_OPTIONS = Object.entries(CsvFormats.TYPES).map(function (_ref) {
60
21
  * Input controls for CSV upload.
61
22
  */
62
23
 
63
- var CsvInputBar = /*#__PURE__*/function (_Component) {
64
- _inherits(CsvInputBar, _Component);
65
-
66
- var _super = _createSuper(CsvInputBar);
67
-
68
- function CsvInputBar(props) {
69
- var _this;
70
-
71
- _classCallCheck(this, CsvInputBar);
72
-
73
- _this = _super.call(this, props);
74
- _this.handleUpload = _this.handleUpload.bind(_assertThisInitialized(_this));
75
- _this.handleCancel = _this.handleCancel.bind(_assertThisInitialized(_this));
76
- _this.handleError = _this.handleError.bind(_assertThisInitialized(_this));
77
- _this.handleTableName = _this.handleTableName.bind(_assertThisInitialized(_this));
78
- _this.toggleFirstRowHeaders = _this.toggleFirstRowHeaders.bind(_assertThisInitialized(_this));
79
- _this.handleProgress = _this.handleProgress.bind(_assertThisInitialized(_this));
80
- _this.handleCancelInProgress = _this.handleCancelInProgress.bind(_assertThisInitialized(_this));
81
- _this.handleQueryTypeChange = _this.handleQueryTypeChange.bind(_assertThisInitialized(_this));
82
- _this.inputRef = /*#__PURE__*/React.createRef();
83
- _this.state = {
24
+ class CsvInputBar extends Component {
25
+ constructor(props) {
26
+ super(props);
27
+ this.handleUpload = this.handleUpload.bind(this);
28
+ this.handleCancel = this.handleCancel.bind(this);
29
+ this.handleError = this.handleError.bind(this);
30
+ this.handleTableName = this.handleTableName.bind(this);
31
+ this.toggleFirstRowHeaders = this.toggleFirstRowHeaders.bind(this);
32
+ this.handleProgress = this.handleProgress.bind(this);
33
+ this.handleCancelInProgress = this.handleCancelInProgress.bind(this);
34
+ this.handleQueryTypeChange = this.handleQueryTypeChange.bind(this);
35
+ this.inputRef = /*#__PURE__*/React.createRef();
36
+ this.state = {
84
37
  tableName: '',
85
38
  tableNameSet: false,
86
39
  isFirstRowHeaders: true,
@@ -89,332 +42,312 @@ var CsvInputBar = /*#__PURE__*/function (_Component) {
89
42
  type: CsvFormats.DEFAULT_TYPE,
90
43
  parser: null
91
44
  };
92
- return _this;
93
45
  } // React documentation says it is fine to update state inside an if statment
94
46
 
95
47
  /* eslint-disable react/no-did-update-set-state */
96
48
 
97
49
 
98
- _createClass(CsvInputBar, [{
99
- key: "componentDidUpdate",
100
- value: function componentDidUpdate(prevProps) {
101
- var _this$props = this.props,
102
- file = _this$props.file,
103
- paste = _this$props.paste;
104
- var _this$state = this.state,
105
- tableName = _this$state.tableName,
106
- tableNameSet = _this$state.tableNameSet; // Set the table name from a file
107
-
108
- if (!tableNameSet && file && !tableName) {
109
- var dotIndex = file.name.lastIndexOf('.');
110
- var fileTableName = DbNameValidator.legalizeTableName(file.name.substring(0, dotIndex));
111
- this.setState({
112
- tableName: fileTableName,
113
- tableNameSet: true
114
- });
115
- this.inputRef.current.focus();
116
- } else if (!file && prevProps.file || !paste && prevProps.paste) {
117
- // The file or paste was unstaged
118
- this.setState({
119
- tableName: '',
120
- tableNameSet: false
121
- });
122
- } // Focus the name input field on paste
123
-
124
-
125
- if (paste && !tableName && this.inputRef.current) {
126
- this.inputRef.current.focus();
127
- } // Determine parser type by file extension
128
-
129
-
130
- if (file && file !== prevProps.file) {
131
- this.setState({
132
- type: CsvFormats.fromExtension(file.name)
133
- });
134
- } else if (paste && !prevProps.paste) {
135
- this.setState({
136
- type: CsvFormats.AUTO
137
- });
138
- }
139
- }
140
- }, {
141
- key: "componentWillUnmount",
142
- value: function componentWillUnmount() {
143
- var parser = this.state.parser;
50
+ componentDidUpdate(prevProps) {
51
+ var {
52
+ file,
53
+ paste
54
+ } = this.props;
55
+ var {
56
+ tableName,
57
+ tableNameSet
58
+ } = this.state; // Set the table name from a file
144
59
 
145
- if (parser) {
146
- parser.cancel();
147
- }
148
- }
149
- }, {
150
- key: "handleCancel",
151
- value: function handleCancel() {
152
- var onClose = this.props.onClose;
153
- onClose();
154
- }
155
- }, {
156
- key: "handleError",
157
- value: function handleError(e) {
158
- var _this$props2 = this.props,
159
- onClose = _this$props2.onClose,
160
- onError = _this$props2.onError;
161
- log.error(e);
162
- onError(e);
163
- onClose();
164
- }
165
- }, {
166
- key: "handleTableName",
167
- value: function handleTableName(event) {
60
+ if (!tableNameSet && file && !tableName) {
61
+ var dotIndex = file.name.lastIndexOf('.');
62
+ var fileTableName = DbNameValidator.legalizeTableName(file.name.substring(0, dotIndex));
168
63
  this.setState({
169
- tableName: event.target.value,
64
+ tableName: fileTableName,
170
65
  tableNameSet: true
171
66
  });
172
- }
173
- }, {
174
- key: "toggleFirstRowHeaders",
175
- value: function toggleFirstRowHeaders() {
176
- var isFirstRowHeaders = this.state.isFirstRowHeaders;
67
+ this.inputRef.current.focus();
68
+ } else if (!file && prevProps.file || !paste && prevProps.paste) {
69
+ // The file or paste was unstaged
177
70
  this.setState({
178
- isFirstRowHeaders: !isFirstRowHeaders
71
+ tableName: '',
72
+ tableNameSet: false
179
73
  });
180
- }
181
- }, {
182
- key: "handleUpload",
183
- value: function handleUpload(event) {
184
- var _this2 = this;
74
+ } // Focus the name input field on paste
185
75
 
186
- event.stopPropagation();
187
- event.preventDefault();
188
- var _this$props3 = this.props,
189
- file = _this$props3.file,
190
- paste = _this$props3.paste,
191
- onUpdate = _this$props3.onUpdate;
192
76
 
193
- if (file) {
194
- if (file.name.endsWith('.zip')) {
195
- JSZip.loadAsync(file).then(function (zip) {
196
- var files = zip.files;
197
- var csvFound = false; // Using a for loop instead of forEach in order to break
77
+ if (paste && !tableName && this.inputRef.current) {
78
+ this.inputRef.current.focus();
79
+ } // Determine parser type by file extension
198
80
 
199
- var values = Object.values(files);
200
81
 
201
- for (var i = 0; i < values.length; i += 1) {
202
- var f = values[i];
203
-
204
- if (CsvOverlay.isValidExtension(f.name)) {
205
- onUpdate("Loading ".concat(f.name, " as csv from ").concat(file.name));
206
- csvFound = true;
207
-
208
- _this2.handleFile(f, true);
82
+ if (file && file !== prevProps.file) {
83
+ this.setState({
84
+ type: CsvFormats.fromExtension(file.name)
85
+ });
86
+ } else if (paste && !prevProps.paste) {
87
+ this.setState({
88
+ type: CsvFormats.AUTO
89
+ });
90
+ }
91
+ }
209
92
 
210
- break;
211
- }
212
- }
93
+ componentWillUnmount() {
94
+ var {
95
+ parser
96
+ } = this.state;
213
97
 
214
- if (!csvFound) {
215
- throw new Error("No csv file found in ".concat(file.name));
98
+ if (parser) {
99
+ parser.cancel();
100
+ }
101
+ }
102
+
103
+ handleCancel() {
104
+ var {
105
+ onClose
106
+ } = this.props;
107
+ onClose();
108
+ }
109
+
110
+ handleError(e) {
111
+ var {
112
+ onClose,
113
+ onError
114
+ } = this.props;
115
+ log.error(e);
116
+ onError(e);
117
+ onClose();
118
+ }
119
+
120
+ handleTableName(event) {
121
+ this.setState({
122
+ tableName: event.target.value,
123
+ tableNameSet: true
124
+ });
125
+ }
126
+
127
+ toggleFirstRowHeaders() {
128
+ var {
129
+ isFirstRowHeaders
130
+ } = this.state;
131
+ this.setState({
132
+ isFirstRowHeaders: !isFirstRowHeaders
133
+ });
134
+ }
135
+
136
+ handleUpload(event) {
137
+ event.stopPropagation();
138
+ event.preventDefault();
139
+ var {
140
+ file,
141
+ paste,
142
+ onUpdate
143
+ } = this.props;
144
+
145
+ if (file) {
146
+ if (file.name.endsWith('.zip')) {
147
+ JSZip.loadAsync(file).then(zip => {
148
+ var {
149
+ files
150
+ } = zip;
151
+ var csvFound = false; // Using a for loop instead of forEach in order to break
152
+
153
+ var values = Object.values(files);
154
+
155
+ for (var i = 0; i < values.length; i += 1) {
156
+ var f = values[i];
157
+
158
+ if (CsvOverlay.isValidExtension(f.name)) {
159
+ onUpdate("Loading ".concat(f.name, " as csv from ").concat(file.name));
160
+ csvFound = true;
161
+ this.handleFile(f, true);
162
+ break;
216
163
  }
217
- })["catch"](function (e) {
218
- return _this2.handleError(e);
219
- });
220
- } else {
221
- this.handleFile(file);
222
- }
223
- } else if (paste) {
224
- this.handleFile(new Blob([paste], {
225
- type: 'text/plain'
226
- }));
164
+ }
165
+
166
+ if (!csvFound) {
167
+ throw new Error("No csv file found in ".concat(file.name));
168
+ }
169
+ }).catch(e => this.handleError(e));
170
+ } else {
171
+ this.handleFile(file);
227
172
  }
173
+ } else if (paste) {
174
+ this.handleFile(new Blob([paste], {
175
+ type: 'text/plain'
176
+ }));
228
177
  }
229
- }, {
230
- key: "handleFile",
231
- value: function handleFile(file) {
232
- var _this3 = this;
233
-
234
- var isZip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
235
- log.info("Starting CSV parser for ".concat(file.name, " ").concat(isZip ? '' : "".concat(file.size, " bytes")));
236
- var _this$props4 = this.props,
237
- session = _this$props4.session,
238
- timeZone = _this$props4.timeZone,
239
- onInProgress = _this$props4.onInProgress;
240
- var _this$state2 = this.state,
241
- tableName = _this$state2.tableName,
242
- isFirstRowHeaders = _this$state2.isFirstRowHeaders,
243
- type = _this$state2.type;
244
-
245
- var handleParseDone = function handleParseDone(tables) {
246
- // Do not bother merging just one table
247
- if (tables.length === 1) {
248
- session.bindTableToVariable(tables[0], tableName).then(function () {
249
- return _this3.openTable();
250
- })["catch"](function (e) {
251
- return _this3.handleError(e);
252
- });
253
- } else {
254
- session.mergeTables(tables).then(function (table) {
255
- session.bindTableToVariable(table, tableName).then(function () {
256
- return _this3.openTable();
257
- })["catch"](function (e) {
258
- return _this3.handleError(e);
259
- });
260
- tables.forEach(function (t) {
261
- return t.close();
262
- });
263
- })["catch"](function (e) {
264
- return _this3.handleError(e);
265
- });
266
- }
267
- };
268
-
269
- var parser = new CsvParser({
270
- onFileCompleted: handleParseDone,
271
- session: session,
272
- file: file,
273
- type: CsvFormats.TYPES[type],
274
- readHeaders: isFirstRowHeaders,
275
- onProgress: this.handleProgress,
276
- onError: this.handleError,
277
- timeZone: timeZone,
278
- isZip: isZip
279
- });
280
- parser.parse();
281
- this.setState({
282
- showProgress: true,
283
- parser: parser
284
- }); // Note that calling onClose will set in progress to false
285
-
286
- onInProgress(true);
287
- }
288
- }, {
289
- key: "handleProgress",
290
- value: function handleProgress(progressValue) {
291
- var showProgress = this.state.showProgress;
178
+ }
179
+
180
+ handleFile(file) {
181
+ var isZip = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
182
+ log.info("Starting CSV parser for ".concat(file.name, " ").concat(isZip ? '' : "".concat(file.size, " bytes")));
183
+ var {
184
+ session,
185
+ timeZone,
186
+ onInProgress
187
+ } = this.props;
188
+ var {
189
+ tableName,
190
+ isFirstRowHeaders,
191
+ type
192
+ } = this.state;
193
+
194
+ var handleParseDone = tables => {
195
+ // Do not bother merging just one table
196
+ if (tables.length === 1) {
197
+ session.bindTableToVariable(tables[0], tableName).then(() => this.openTable()).catch(e => this.handleError(e));
198
+ } else {
199
+ session.mergeTables(tables).then(table => {
200
+ session.bindTableToVariable(table, tableName).then(() => this.openTable()).catch(e => this.handleError(e));
201
+ tables.forEach(t => t.close());
202
+ }).catch(e => this.handleError(e));
203
+ }
204
+ };
292
205
 
293
- if (showProgress) {
294
- this.setState({
295
- progressValue: progressValue
296
- });
297
- } // Indicates to the caller that the upload has been cancelled
206
+ var parser = new CsvParser({
207
+ onFileCompleted: handleParseDone,
208
+ session,
209
+ file,
210
+ type: CsvFormats.TYPES[type],
211
+ readHeaders: isFirstRowHeaders,
212
+ onProgress: this.handleProgress,
213
+ onError: this.handleError,
214
+ timeZone,
215
+ isZip
216
+ });
217
+ parser.parse();
218
+ this.setState({
219
+ showProgress: true,
220
+ parser
221
+ }); // Note that calling onClose will set in progress to false
222
+
223
+ onInProgress(true);
224
+ }
225
+
226
+ handleProgress(progressValue) {
227
+ var {
228
+ showProgress
229
+ } = this.state;
230
+
231
+ if (showProgress) {
232
+ this.setState({
233
+ progressValue
234
+ });
235
+ } // Indicates to the caller that the upload has been cancelled
298
236
 
299
237
 
300
- return !showProgress;
301
- } // Cancels an in progress upload
238
+ return !showProgress;
239
+ } // Cancels an in progress upload
302
240
 
303
- }, {
304
- key: "handleCancelInProgress",
305
- value: function handleCancelInProgress() {
306
- var onInProgress = this.props.onInProgress;
307
- var parser = this.state.parser;
308
241
 
309
- if (parser) {
310
- parser.cancel();
311
- }
242
+ handleCancelInProgress() {
243
+ var {
244
+ onInProgress
245
+ } = this.props;
246
+ var {
247
+ parser
248
+ } = this.state;
312
249
 
313
- this.setState({
314
- showProgress: false,
315
- progressValue: 0
316
- });
317
- onInProgress(false);
318
- }
319
- }, {
320
- key: "openTable",
321
- value: function openTable() {
322
- var _this$props5 = this.props,
323
- onOpenTable = _this$props5.onOpenTable,
324
- onClose = _this$props5.onClose;
325
- var tableName = this.state.tableName;
326
- onOpenTable(tableName);
327
- onClose();
328
- }
329
- }, {
330
- key: "handleQueryTypeChange",
331
- value: function handleQueryTypeChange(event) {
332
- this.setState({
333
- type: event.target.value
334
- });
250
+ if (parser) {
251
+ parser.cancel();
335
252
  }
336
- }, {
337
- key: "render",
338
- value: function render() {
339
- var _this$props6 = this.props,
340
- file = _this$props6.file,
341
- paste = _this$props6.paste;
342
- var _this$state3 = this.state,
343
- tableName = _this$state3.tableName,
344
- isFirstRowHeaders = _this$state3.isFirstRowHeaders,
345
- showProgress = _this$state3.showProgress,
346
- progressValue = _this$state3.progressValue,
347
- type = _this$state3.type; // A blank table name is invalid for pasted values
348
-
349
- var isNameInvalid = paste && !tableName;
350
- return /*#__PURE__*/React.createElement("div", null, !showProgress && /*#__PURE__*/React.createElement("form", {
351
- onSubmit: this.handleUpload,
352
- className: "csv-input-bar-container"
353
- }, /*#__PURE__*/React.createElement("div", {
354
- className: "csv-input-form form-inline"
355
- }, /*#__PURE__*/React.createElement("div", {
356
- className: "form-group"
357
- }, /*#__PURE__*/React.createElement("label", {
358
- className: "mr-sm-2 mb-1",
359
- htmlFor: "tableNameInput"
360
- }, "Table name"), /*#__PURE__*/React.createElement("input", {
361
- ref: this.inputRef,
362
- id: "tableNameInput",
363
- type: "text",
364
- className: classNames('form-control mb-2 mr-sm-2', {
365
- 'is-invalid': isNameInvalid
366
- }),
367
- value: tableName,
368
- onChange: this.handleTableName
369
- })), /*#__PURE__*/React.createElement("div", {
370
- className: "form-group"
371
- }, /*#__PURE__*/React.createElement("label", {
372
- className: "mr-sm-2 mb-1",
373
- htmlFor: "formatSelect"
374
- }, "File format"), /*#__PURE__*/React.createElement("select", {
375
- id: "formatSelect",
376
- className: "custom-select mb-2 mr-sm-2",
377
- value: type,
378
- onChange: this.handleQueryTypeChange
379
- }, TYPE_OPTIONS)), /*#__PURE__*/React.createElement(Checkbox, {
380
- className: "firstRowHeaders",
381
- checked: isFirstRowHeaders,
382
- onChange: this.toggleFirstRowHeaders
383
- }, "First row is column headers"), /*#__PURE__*/React.createElement("div", {
384
- className: "csv-input-buttons form-group"
385
- }, /*#__PURE__*/React.createElement("button", {
386
- type: "submit",
387
- className: "btn btn-primary",
388
- disabled: !(file || paste) || !tableName
389
- }, "Upload"), /*#__PURE__*/React.createElement("button", {
390
- type: "button",
391
- className: "btn btn-outline-primary",
392
- onClick: this.handleCancel
393
- }, "Cancel")))), showProgress && /*#__PURE__*/React.createElement("div", {
394
- className: "csv-progress-container"
395
- }, /*#__PURE__*/React.createElement("label", null, "Uploading Table"), /*#__PURE__*/React.createElement("div", {
396
- className: "progress",
397
- style: {
398
- marginBottom: '1rem'
399
- }
400
- }, /*#__PURE__*/React.createElement("div", {
401
- className: "progress-bar bg-primary",
402
- style: {
403
- width: "".concat(progressValue, "%")
404
- },
405
- "aria-valuenow": progressValue,
406
- "aria-valuemin": "0",
407
- "aria-valuemax": "100"
408
- })), /*#__PURE__*/React.createElement("label", null, progressValue, "%"), /*#__PURE__*/React.createElement("button", {
409
- type: "button",
410
- className: "btn btn-primary",
411
- onClick: this.handleCancelInProgress
412
- }, "Cancel")));
413
- }
414
- }]);
415
253
 
416
- return CsvInputBar;
417
- }(Component);
254
+ this.setState({
255
+ showProgress: false,
256
+ progressValue: 0
257
+ });
258
+ onInProgress(false);
259
+ }
260
+
261
+ openTable() {
262
+ var {
263
+ onOpenTable,
264
+ onClose
265
+ } = this.props;
266
+ var {
267
+ tableName
268
+ } = this.state;
269
+ onOpenTable(tableName);
270
+ onClose();
271
+ }
272
+
273
+ handleQueryTypeChange(event) {
274
+ this.setState({
275
+ type: event.target.value
276
+ });
277
+ }
278
+
279
+ render() {
280
+ var {
281
+ file,
282
+ paste
283
+ } = this.props;
284
+ var {
285
+ tableName,
286
+ isFirstRowHeaders,
287
+ showProgress,
288
+ progressValue,
289
+ type
290
+ } = this.state; // A blank table name is invalid for pasted values
291
+
292
+ var isNameInvalid = paste && !tableName;
293
+ return /*#__PURE__*/React.createElement("div", null, !showProgress && /*#__PURE__*/React.createElement("form", {
294
+ onSubmit: this.handleUpload,
295
+ className: "csv-input-bar-container form-inline"
296
+ }, /*#__PURE__*/React.createElement("div", {
297
+ className: "form-group"
298
+ }, /*#__PURE__*/React.createElement("label", {
299
+ htmlFor: "tableNameInput"
300
+ }, "Table name"), /*#__PURE__*/React.createElement("input", {
301
+ ref: this.inputRef,
302
+ id: "tableNameInput",
303
+ type: "text",
304
+ className: classNames('form-control', {
305
+ 'is-invalid': isNameInvalid
306
+ }),
307
+ value: tableName,
308
+ onChange: this.handleTableName
309
+ })), /*#__PURE__*/React.createElement("div", {
310
+ className: "form-group"
311
+ }, /*#__PURE__*/React.createElement("label", {
312
+ htmlFor: "formatSelect"
313
+ }, "File format"), /*#__PURE__*/React.createElement("select", {
314
+ id: "formatSelect",
315
+ className: "custom-select",
316
+ value: type,
317
+ onChange: this.handleQueryTypeChange
318
+ }, TYPE_OPTIONS)), /*#__PURE__*/React.createElement(Checkbox, {
319
+ className: "firstRowHeaders",
320
+ checked: isFirstRowHeaders,
321
+ onChange: this.toggleFirstRowHeaders
322
+ }, "First row is column headers"), /*#__PURE__*/React.createElement("div", {
323
+ className: "csv-input-buttons form-group"
324
+ }, /*#__PURE__*/React.createElement(Button, {
325
+ kind: "secondary",
326
+ onClick: this.handleCancel
327
+ }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
328
+ kind: "primary",
329
+ type: "submit",
330
+ disabled: !(file || paste) || !tableName
331
+ }, "Upload"))), showProgress && /*#__PURE__*/React.createElement("div", {
332
+ className: "csv-progress-container"
333
+ }, /*#__PURE__*/React.createElement("label", null, "Uploading Table"), /*#__PURE__*/React.createElement("div", {
334
+ className: "progress"
335
+ }, /*#__PURE__*/React.createElement("div", {
336
+ className: "progress-bar bg-primary",
337
+ style: {
338
+ width: "".concat(progressValue, "%")
339
+ },
340
+ "aria-valuenow": progressValue,
341
+ "aria-valuemin": "0",
342
+ "aria-valuemax": "100"
343
+ })), /*#__PURE__*/React.createElement("label", null, progressValue, "%"), /*#__PURE__*/React.createElement("button", {
344
+ type: "button",
345
+ className: "btn btn-primary",
346
+ onClick: this.handleCancelInProgress
347
+ }, "Cancel")));
348
+ }
349
+
350
+ }
418
351
 
419
352
  CsvInputBar.propTypes = {
420
353
  session: PropTypes.shape({
@@ -434,12 +367,5 @@ CsvInputBar.defaultProps = {
434
367
  file: null,
435
368
  paste: null
436
369
  };
437
-
438
- var mapStateToProps = function mapStateToProps(state) {
439
- return {
440
- timeZone: getTimeZone(state)
441
- };
442
- };
443
-
444
- export default connect(mapStateToProps)(CsvInputBar);
370
+ export default CsvInputBar;
445
371
  //# sourceMappingURL=CsvInputBar.js.map