@deephaven/iris-grid 0.22.3-beta.18 → 0.22.3-beta.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AdvancedFilterCreator.js +7 -65
- package/dist/AdvancedFilterCreator.js.map +1 -1
- package/dist/AdvancedFilterCreatorFilterItem.js +0 -23
- package/dist/AdvancedFilterCreatorFilterItem.js.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValue.js +0 -52
- package/dist/AdvancedFilterCreatorSelectValue.js.map +1 -1
- package/dist/AdvancedFilterCreatorSelectValueList.js +2 -42
- package/dist/AdvancedFilterCreatorSelectValueList.js.map +1 -1
- package/dist/ColumnHeaderGroup.js +0 -11
- package/dist/ColumnHeaderGroup.js.map +1 -1
- package/dist/ColumnStatistics.js +1 -20
- package/dist/ColumnStatistics.js.map +1 -1
- package/dist/CrossColumnSearch.js +2 -23
- package/dist/CrossColumnSearch.js.map +1 -1
- package/dist/FilterInputField.js +2 -36
- package/dist/FilterInputField.js.map +1 -1
- package/dist/GotoRow.d.ts +1 -1
- package/dist/GotoRow.d.ts.map +1 -1
- package/dist/GotoRow.js +2 -7
- package/dist/GotoRow.js.map +1 -1
- package/dist/IrisGrid.d.ts +11 -5
- package/dist/IrisGrid.d.ts.map +1 -1
- package/dist/IrisGrid.js +77 -519
- package/dist/IrisGrid.js.map +1 -1
- package/dist/IrisGridBottomBar.d.ts +1 -1
- package/dist/IrisGridBottomBar.d.ts.map +1 -1
- package/dist/IrisGridBottomBar.js +2 -2
- package/dist/IrisGridBottomBar.js.map +1 -1
- package/dist/IrisGridCellOverflowModal.js +6 -21
- package/dist/IrisGridCellOverflowModal.js.map +1 -1
- package/dist/IrisGridCopyHandler.js +3 -50
- package/dist/IrisGridCopyHandler.js.map +1 -1
- package/dist/IrisGridMetricCalculator.js +2 -12
- package/dist/IrisGridMetricCalculator.js.map +1 -1
- package/dist/IrisGridModel.js +32 -58
- package/dist/IrisGridModel.js.map +1 -1
- package/dist/IrisGridModelFactory.js +0 -7
- package/dist/IrisGridModelFactory.js.map +1 -1
- package/dist/IrisGridModelUpdater.js +0 -4
- package/dist/IrisGridModelUpdater.js.map +1 -1
- package/dist/IrisGridPartitionSelector.js +0 -23
- package/dist/IrisGridPartitionSelector.js.map +1 -1
- package/dist/IrisGridProxyModel.js +9 -153
- package/dist/IrisGridProxyModel.js.map +1 -1
- package/dist/IrisGridRenderer.js +41 -183
- package/dist/IrisGridRenderer.js.map +1 -1
- package/dist/IrisGridShortcuts.js.map +1 -1
- package/dist/IrisGridTableModel.js +7 -86
- package/dist/IrisGridTableModel.js.map +1 -1
- package/dist/IrisGridTableModelTemplate.js +70 -461
- package/dist/IrisGridTableModelTemplate.js.map +1 -1
- package/dist/IrisGridTestUtils.js +0 -23
- package/dist/IrisGridTestUtils.js.map +1 -1
- package/dist/IrisGridTheme.js.map +1 -1
- package/dist/IrisGridTreeTableModel.js +3 -42
- package/dist/IrisGridTreeTableModel.js.map +1 -1
- package/dist/IrisGridUtils.d.ts +8 -2
- package/dist/IrisGridUtils.d.ts.map +1 -1
- package/dist/IrisGridUtils.js +97 -195
- package/dist/IrisGridUtils.js.map +1 -1
- package/dist/MissingKeyError.js +0 -7
- package/dist/MissingKeyError.js.map +1 -1
- package/dist/PartitionSelectorSearch.js +2 -48
- package/dist/PartitionSelectorSearch.js.map +1 -1
- package/dist/PendingDataBottomBar.d.ts +1 -1
- package/dist/PendingDataBottomBar.d.ts.map +1 -1
- package/dist/PendingDataBottomBar.js +2 -7
- package/dist/PendingDataBottomBar.js.map +1 -1
- package/dist/TableViewportUpdater.js +3 -29
- package/dist/TableViewportUpdater.js.map +1 -1
- package/dist/ToastBottomBar.d.ts +1 -1
- package/dist/ToastBottomBar.d.ts.map +1 -1
- package/dist/ToastBottomBar.js +2 -4
- package/dist/ToastBottomBar.js.map +1 -1
- package/dist/TreeTableViewportUpdater.js +0 -21
- package/dist/TreeTableViewportUpdater.js.map +1 -1
- package/dist/format-context-menus/CustomFormatAction.js +4 -25
- package/dist/format-context-menus/CustomFormatAction.js.map +1 -1
- package/dist/format-context-menus/DateTimeFormatContextMenu.js +0 -7
- package/dist/format-context-menus/DateTimeFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/DecimalFormatContextMenu.js +0 -9
- package/dist/format-context-menus/DecimalFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/FormatContextMenuUtils.js +3 -9
- package/dist/format-context-menus/FormatContextMenuUtils.js.map +1 -1
- package/dist/format-context-menus/IntegerFormatContextMenu.js +0 -8
- package/dist/format-context-menus/IntegerFormatContextMenu.js.map +1 -1
- package/dist/format-context-menus/index.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/key-handlers/ClearFilterKeyHandler.js +0 -8
- package/dist/key-handlers/ClearFilterKeyHandler.js.map +1 -1
- package/dist/key-handlers/CopyKeyHandler.js +1 -10
- package/dist/key-handlers/CopyKeyHandler.js.map +1 -1
- package/dist/key-handlers/ReverseKeyHandler.js +0 -11
- package/dist/key-handlers/ReverseKeyHandler.js.map +1 -1
- package/dist/key-handlers/index.js.map +1 -1
- package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js +2 -32
- package/dist/mousehandlers/IrisGridCellOverflowMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js +4 -34
- package/dist/mousehandlers/IrisGridColumnSelectMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js +0 -20
- package/dist/mousehandlers/IrisGridColumnTooltipMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridContextMenuHandler.js +15 -105
- package/dist/mousehandlers/IrisGridContextMenuHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridDataSelectMouseHandler.js +0 -9
- package/dist/mousehandlers/IrisGridDataSelectMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridFilterMouseHandler.js +0 -17
- package/dist/mousehandlers/IrisGridFilterMouseHandler.js.map +1 -1
- package/dist/mousehandlers/IrisGridSortMouseHandler.js +2 -15
- package/dist/mousehandlers/IrisGridSortMouseHandler.js.map +1 -1
- package/dist/mousehandlers/PendingMouseHandler.js +0 -6
- package/dist/mousehandlers/PendingMouseHandler.js.map +1 -1
- package/dist/mousehandlers/index.js.map +1 -1
- package/dist/sidebar/AdvancedSettings.js.map +1 -1
- package/dist/sidebar/AdvancedSettingsMenu.d.ts +4 -4
- package/dist/sidebar/AdvancedSettingsMenu.d.ts.map +1 -1
- package/dist/sidebar/AdvancedSettingsMenu.js +2 -6
- package/dist/sidebar/AdvancedSettingsMenu.js.map +1 -1
- package/dist/sidebar/AdvancedSettingsType.js +0 -2
- package/dist/sidebar/AdvancedSettingsType.js.map +1 -1
- package/dist/sidebar/ChartBuilder.js +2 -46
- package/dist/sidebar/ChartBuilder.js.map +1 -1
- package/dist/sidebar/CustomColumnBuilder.js +6 -58
- package/dist/sidebar/CustomColumnBuilder.js.map +1 -1
- package/dist/sidebar/CustomColumnInput.js +4 -15
- package/dist/sidebar/CustomColumnInput.js.map +1 -1
- package/dist/sidebar/InputEditor.js +5 -36
- package/dist/sidebar/InputEditor.js.map +1 -1
- package/dist/sidebar/OptionType.js +0 -2
- package/dist/sidebar/OptionType.js.map +1 -1
- package/dist/sidebar/RollupRows.js +9 -65
- package/dist/sidebar/RollupRows.js.map +1 -1
- package/dist/sidebar/SelectDistinctBuilder.js +0 -13
- package/dist/sidebar/SelectDistinctBuilder.js.map +1 -1
- package/dist/sidebar/TableCsvExporter.js +0 -52
- package/dist/sidebar/TableCsvExporter.js.map +1 -1
- package/dist/sidebar/TableSaver.js +10 -123
- package/dist/sidebar/TableSaver.js.map +1 -1
- package/dist/sidebar/VisibilityOrderingBuilder.js +37 -116
- package/dist/sidebar/VisibilityOrderingBuilder.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.d.ts +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.d.ts.map +1 -1
- package/dist/sidebar/aggregations/AggregationEdit.js +2 -14
- package/dist/sidebar/aggregations/AggregationEdit.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationOperation.js +0 -2
- package/dist/sidebar/aggregations/AggregationOperation.js.map +1 -1
- package/dist/sidebar/aggregations/AggregationUtils.js +2 -5
- package/dist/sidebar/aggregations/AggregationUtils.js.map +1 -1
- package/dist/sidebar/aggregations/Aggregations.d.ts +1 -1
- package/dist/sidebar/aggregations/Aggregations.d.ts.map +1 -1
- package/dist/sidebar/aggregations/Aggregations.js +2 -12
- package/dist/sidebar/aggregations/Aggregations.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js +2 -16
- package/dist/sidebar/conditional-formatting/ColumnFormatEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ConditionEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionEditor.js +2 -35
- package/dist/sidebar/conditional-formatting/ConditionEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js +2 -12
- package/dist/sidebar/conditional-formatting/ConditionalFormatEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js +0 -3
- package/dist/sidebar/conditional-formatting/ConditionalFormattingAPIUtils.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js +16 -26
- package/dist/sidebar/conditional-formatting/ConditionalFormattingMenu.js.map +1 -1
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js +9 -172
- package/dist/sidebar/conditional-formatting/ConditionalFormattingUtils.js.map +1 -1
- package/dist/sidebar/conditional-formatting/RowFormatEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/RowFormatEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/RowFormatEditor.js +2 -16
- package/dist/sidebar/conditional-formatting/RowFormatEditor.js.map +1 -1
- package/dist/sidebar/conditional-formatting/StyleEditor.d.ts +1 -1
- package/dist/sidebar/conditional-formatting/StyleEditor.d.ts.map +1 -1
- package/dist/sidebar/conditional-formatting/StyleEditor.js +2 -12
- package/dist/sidebar/conditional-formatting/StyleEditor.js.map +1 -1
- package/dist/sidebar/icons/BarIcon.js +0 -3
- package/dist/sidebar/icons/BarIcon.js.map +1 -1
- package/dist/sidebar/icons/FormatColumnWhereIcon.js +2 -5
- package/dist/sidebar/icons/FormatColumnWhereIcon.js.map +1 -1
- package/dist/sidebar/icons/FormatRowWhereIcon.js +2 -5
- package/dist/sidebar/icons/FormatRowWhereIcon.js.map +1 -1
- package/dist/sidebar/icons/HistogramIcon.js +0 -3
- package/dist/sidebar/icons/HistogramIcon.js.map +1 -1
- package/dist/sidebar/icons/LineIcon.js +0 -3
- package/dist/sidebar/icons/LineIcon.js.map +1 -1
- package/dist/sidebar/icons/PieIcon.js +0 -3
- package/dist/sidebar/icons/PieIcon.js.map +1 -1
- package/dist/sidebar/icons/ScatterIcon.js +0 -3
- package/dist/sidebar/icons/ScatterIcon.js.map +1 -1
- package/dist/sidebar/icons/index.js.map +1 -1
- package/dist/sidebar/index.js.map +1 -1
- package/package.json +15 -15
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
|
-
|
|
3
2
|
import { PureComponent } from 'react';
|
|
4
3
|
import { WritableStream as ponyfillWritableStream } from 'web-streams-polyfill/ponyfill';
|
|
5
4
|
import dh from '@deephaven/jsapi-shim';
|
|
@@ -10,83 +9,50 @@ import { PromiseUtils, assertNotNull } from '@deephaven/utils';
|
|
|
10
9
|
import IrisGridUtils from "../IrisGridUtils.js";
|
|
11
10
|
var log = Log.module('TableSaver');
|
|
12
11
|
var UNFORMATTED_DATE_PATTERN = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";
|
|
13
|
-
|
|
14
12
|
function isUpdateEventData(data) {
|
|
15
13
|
return data.added !== undefined;
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
function assertIsUpdateEventData(data) {
|
|
19
16
|
if (!isUpdateEventData(data)) {
|
|
20
17
|
throw new Error('event is not UpdateEventData');
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
export default class TableSaver extends PureComponent {
|
|
25
21
|
static csvEscapeString(str) {
|
|
26
22
|
return "\"".concat(str.replace(/"/g, '""'), "\"");
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
constructor(props) {
|
|
30
25
|
var _window$WritableStrea, _window$WritableStrea2;
|
|
31
|
-
|
|
32
26
|
super(props);
|
|
33
|
-
|
|
34
27
|
_defineProperty(this, "sw", void 0);
|
|
35
|
-
|
|
36
28
|
_defineProperty(this, "port", void 0);
|
|
37
|
-
|
|
38
29
|
_defineProperty(this, "fileWriter", void 0);
|
|
39
|
-
|
|
40
30
|
_defineProperty(this, "table", void 0);
|
|
41
|
-
|
|
42
31
|
_defineProperty(this, "tableSubscription", void 0);
|
|
43
|
-
|
|
44
32
|
_defineProperty(this, "columns", void 0);
|
|
45
|
-
|
|
46
33
|
_defineProperty(this, "fileName", void 0);
|
|
47
|
-
|
|
48
34
|
_defineProperty(this, "includeColumnHeaders", void 0);
|
|
49
|
-
|
|
50
35
|
_defineProperty(this, "useUnformattedValues", void 0);
|
|
51
|
-
|
|
52
36
|
_defineProperty(this, "chunkRows", void 0);
|
|
53
|
-
|
|
54
37
|
_defineProperty(this, "gridRanges", void 0);
|
|
55
|
-
|
|
56
38
|
_defineProperty(this, "gridRangeCounter", void 0);
|
|
57
|
-
|
|
58
39
|
_defineProperty(this, "rangedSnapshotsTotal", void 0);
|
|
59
|
-
|
|
60
40
|
_defineProperty(this, "rangedSnapshotCounter", void 0);
|
|
61
|
-
|
|
62
41
|
_defineProperty(this, "snapshotsTotal", void 0);
|
|
63
|
-
|
|
64
42
|
_defineProperty(this, "snapshotCounter", void 0);
|
|
65
|
-
|
|
66
43
|
_defineProperty(this, "snapshotsBuffer", void 0);
|
|
67
|
-
|
|
68
44
|
_defineProperty(this, "currentSnapshotIndex", void 0);
|
|
69
|
-
|
|
70
45
|
_defineProperty(this, "snapshotPending", void 0);
|
|
71
|
-
|
|
72
46
|
_defineProperty(this, "cancelableSnapshots", void 0);
|
|
73
|
-
|
|
74
47
|
_defineProperty(this, "WritableStream", (_window$WritableStrea = window.WritableStream) !== null && _window$WritableStrea !== void 0 ? _window$WritableStrea : ponyfillWritableStream);
|
|
75
|
-
|
|
76
48
|
_defineProperty(this, "streamTimeout", void 0);
|
|
77
|
-
|
|
78
49
|
_defineProperty(this, "snapshotHandlerTimeout", void 0);
|
|
79
|
-
|
|
80
50
|
_defineProperty(this, "downloadStartTime", void 0);
|
|
81
|
-
|
|
82
51
|
_defineProperty(this, "iframes", void 0);
|
|
83
|
-
|
|
84
52
|
_defineProperty(this, "useBlobFallback", void 0);
|
|
85
|
-
|
|
86
53
|
_defineProperty(this, "getCachedCustomColumnFormatFlag", memoizeClear(FormatterUtils.isCustomColumnFormatDefined, {
|
|
87
54
|
max: 10000
|
|
88
55
|
}));
|
|
89
|
-
|
|
90
56
|
this.handlePortMessage = this.handlePortMessage.bind(this);
|
|
91
57
|
this.handleSnapshotResolved = this.handleSnapshotResolved.bind(this);
|
|
92
58
|
this.handleDownloadTimeout = this.handleDownloadTimeout.bind(this);
|
|
@@ -102,9 +68,12 @@ export default class TableSaver extends PureComponent {
|
|
|
102
68
|
this.snapshotsBuffer = new Map();
|
|
103
69
|
this.currentSnapshotIndex = 0;
|
|
104
70
|
this.snapshotPending = 0;
|
|
105
|
-
this.cancelableSnapshots = [];
|
|
71
|
+
this.cancelableSnapshots = [];
|
|
72
|
+
|
|
73
|
+
// WritableStream is not supported in Firefox (also IE) yet. use ponyfillWritableStream instead
|
|
74
|
+
this.WritableStream = (_window$WritableStrea2 = window.WritableStream) !== null && _window$WritableStrea2 !== void 0 ? _window$WritableStrea2 : ponyfillWritableStream;
|
|
106
75
|
|
|
107
|
-
|
|
76
|
+
// Due to an open issue in Chromium, readableStream.cancel() is never called when a user cancel the stream from Chromium's UI and the stream goes on even it's canceled.
|
|
108
77
|
// Instead, we monitor the pull() behavior from the readableStream called when the stream wants more data to write.
|
|
109
78
|
// If the stream doesn't pull for long enough time, chances are the stream is already canceled, so we stop the stream.
|
|
110
79
|
// Issue ticket on Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=638494
|
|
@@ -112,7 +81,6 @@ export default class TableSaver extends PureComponent {
|
|
|
112
81
|
this.iframes = [];
|
|
113
82
|
this.useBlobFallback = false;
|
|
114
83
|
}
|
|
115
|
-
|
|
116
84
|
componentDidMount() {
|
|
117
85
|
var {
|
|
118
86
|
getDownloadWorker
|
|
@@ -127,46 +95,37 @@ export default class TableSaver extends PureComponent {
|
|
|
127
95
|
this.useBlobFallback = true;
|
|
128
96
|
});
|
|
129
97
|
}
|
|
130
|
-
|
|
131
98
|
componentWillUnmount() {
|
|
132
99
|
if (this.iframes.length > 0) {
|
|
133
100
|
this.iframes.forEach(iframe => {
|
|
134
101
|
iframe.remove();
|
|
135
102
|
});
|
|
136
103
|
}
|
|
137
|
-
|
|
138
104
|
if (this.streamTimeout) clearTimeout(this.streamTimeout);
|
|
139
105
|
if (this.snapshotHandlerTimeout) clearTimeout(this.snapshotHandlerTimeout);
|
|
140
106
|
}
|
|
141
|
-
|
|
142
107
|
createWriterStream(port) {
|
|
143
108
|
// use blob fall back if it's safari
|
|
144
109
|
var useBlob = this.useBlobFallback;
|
|
145
110
|
var chunks = [];
|
|
146
111
|
var encode = null;
|
|
147
|
-
|
|
148
112
|
if (useBlob) {
|
|
149
113
|
encode = TextEncoder.prototype.encode.bind(new TextEncoder());
|
|
150
114
|
}
|
|
151
|
-
|
|
152
115
|
var {
|
|
153
116
|
fileName
|
|
154
117
|
} = this;
|
|
155
118
|
var streamConfig = {};
|
|
156
|
-
|
|
157
119
|
if (useBlob) {
|
|
158
120
|
streamConfig.write = chunk => {
|
|
159
121
|
assertNotNull(encode);
|
|
160
|
-
|
|
161
122
|
if (chunk.header !== undefined) {
|
|
162
123
|
chunks.push(encode(chunk.header));
|
|
163
124
|
}
|
|
164
|
-
|
|
165
125
|
if (chunk.rows !== undefined) {
|
|
166
126
|
chunks.push(encode(chunk.rows));
|
|
167
127
|
}
|
|
168
128
|
};
|
|
169
|
-
|
|
170
129
|
streamConfig.close = () => {
|
|
171
130
|
assertNotNull(fileName);
|
|
172
131
|
var blob = new Blob(chunks, {
|
|
@@ -177,7 +136,6 @@ export default class TableSaver extends PureComponent {
|
|
|
177
136
|
link.download = fileName;
|
|
178
137
|
link.click();
|
|
179
138
|
};
|
|
180
|
-
|
|
181
139
|
streamConfig.abort = () => {
|
|
182
140
|
port.postMessage({
|
|
183
141
|
cancel: true
|
|
@@ -188,14 +146,12 @@ export default class TableSaver extends PureComponent {
|
|
|
188
146
|
streamConfig.write = chunk => {
|
|
189
147
|
port.postMessage(chunk);
|
|
190
148
|
};
|
|
191
|
-
|
|
192
149
|
streamConfig.close = () => {
|
|
193
150
|
port.postMessage({
|
|
194
151
|
end: true
|
|
195
152
|
});
|
|
196
153
|
port.close();
|
|
197
154
|
};
|
|
198
|
-
|
|
199
155
|
streamConfig.abort = () => {
|
|
200
156
|
port.postMessage({
|
|
201
157
|
cancel: true
|
|
@@ -203,20 +159,16 @@ export default class TableSaver extends PureComponent {
|
|
|
203
159
|
port.close();
|
|
204
160
|
};
|
|
205
161
|
}
|
|
206
|
-
|
|
207
162
|
return new this.WritableStream(streamConfig);
|
|
208
163
|
}
|
|
209
|
-
|
|
210
164
|
startDownload(fileName, frozenTable, tableSubscription, snapshotRanges, modelRanges, includeColumnHeaders, useUnformattedValues) {
|
|
211
165
|
// don't trigger another download when a download is ongoing
|
|
212
166
|
var {
|
|
213
167
|
isDownloading
|
|
214
168
|
} = this.props;
|
|
215
|
-
|
|
216
169
|
if (isDownloading) {
|
|
217
170
|
return;
|
|
218
171
|
}
|
|
219
|
-
|
|
220
172
|
this.downloadStartTime = Date.now();
|
|
221
173
|
log.info("start downloading ".concat(fileName));
|
|
222
174
|
this.table = frozenTable;
|
|
@@ -224,66 +176,57 @@ export default class TableSaver extends PureComponent {
|
|
|
224
176
|
this.tableSubscription = tableSubscription;
|
|
225
177
|
this.gridRanges = snapshotRanges;
|
|
226
178
|
this.includeColumnHeaders = includeColumnHeaders;
|
|
227
|
-
this.useUnformattedValues = useUnformattedValues;
|
|
179
|
+
this.useUnformattedValues = useUnformattedValues;
|
|
228
180
|
|
|
181
|
+
// Make filename RFC5987 compatible
|
|
229
182
|
var encodedFileName = encodeURIComponent(fileName.replace(/\//g, ':')).replace(/['()]/g, escape).replace(/\*/g, '%2A');
|
|
230
183
|
var messageChannel = new MessageChannel();
|
|
231
184
|
this.port = messageChannel.port1;
|
|
232
185
|
this.fileName = fileName;
|
|
233
|
-
this.fileWriter = this.createWriterStream(this.port).getWriter();
|
|
186
|
+
this.fileWriter = this.createWriterStream(this.port).getWriter();
|
|
234
187
|
|
|
188
|
+
// if the browser doesn't support stream or there's no active service worker, use blobs for table download
|
|
235
189
|
if (this.useBlobFallback) {
|
|
236
190
|
this.writeCsvTable(includeColumnHeaders);
|
|
237
191
|
return;
|
|
238
192
|
}
|
|
239
|
-
|
|
240
193
|
if (this.sw) {
|
|
241
194
|
// send file name and port to service worker
|
|
242
195
|
this.sw.postMessage({
|
|
243
196
|
encodedFileName
|
|
244
197
|
}, [messageChannel.port2]);
|
|
245
198
|
}
|
|
246
|
-
|
|
247
199
|
this.port.onmessage = this.handlePortMessage;
|
|
248
200
|
}
|
|
249
|
-
|
|
250
201
|
finishDownload() {
|
|
251
202
|
if (this.table) {
|
|
252
203
|
this.table.close();
|
|
253
204
|
}
|
|
254
|
-
|
|
255
205
|
if (this.tableSubscription) {
|
|
256
206
|
this.tableSubscription.close();
|
|
257
207
|
}
|
|
258
|
-
|
|
259
208
|
if (this.fileWriter) {
|
|
260
209
|
this.fileWriter.close();
|
|
261
210
|
}
|
|
262
|
-
|
|
263
211
|
var {
|
|
264
212
|
onDownloadCompleted
|
|
265
213
|
} = this.props;
|
|
266
214
|
onDownloadCompleted();
|
|
267
215
|
this.resetTableSaver();
|
|
268
|
-
|
|
269
216
|
if (this.downloadStartTime !== undefined) {
|
|
270
217
|
log.info("download finished, total elapsed time ".concat((Date.now() - this.downloadStartTime) / 1000, " seconds"));
|
|
271
218
|
}
|
|
272
219
|
}
|
|
273
|
-
|
|
274
220
|
cancelDownload() {
|
|
275
221
|
if (this.table) {
|
|
276
222
|
this.table.close();
|
|
277
223
|
}
|
|
278
|
-
|
|
279
224
|
if (this.tableSubscription) {
|
|
280
225
|
this.tableSubscription.close();
|
|
281
226
|
}
|
|
282
|
-
|
|
283
227
|
if (this.fileWriter) {
|
|
284
228
|
this.fileWriter.abort();
|
|
285
229
|
}
|
|
286
|
-
|
|
287
230
|
this.cancelableSnapshots.forEach(cancelable => {
|
|
288
231
|
if (cancelable) {
|
|
289
232
|
cancelable.catch(() => null);
|
|
@@ -296,7 +239,6 @@ export default class TableSaver extends PureComponent {
|
|
|
296
239
|
onDownloadCanceled();
|
|
297
240
|
this.resetTableSaver();
|
|
298
241
|
}
|
|
299
|
-
|
|
300
242
|
resetTableSaver() {
|
|
301
243
|
this.table = undefined;
|
|
302
244
|
this.tableSubscription = undefined;
|
|
@@ -314,41 +256,32 @@ export default class TableSaver extends PureComponent {
|
|
|
314
256
|
this.currentSnapshotIndex = 0;
|
|
315
257
|
this.snapshotPending = 0;
|
|
316
258
|
this.cancelableSnapshots = [];
|
|
317
|
-
|
|
318
259
|
if (this.streamTimeout != null) {
|
|
319
260
|
clearTimeout(this.streamTimeout);
|
|
320
261
|
}
|
|
321
|
-
|
|
322
262
|
if (this.snapshotHandlerTimeout != null) {
|
|
323
263
|
clearTimeout(this.snapshotHandlerTimeout);
|
|
324
264
|
}
|
|
325
|
-
|
|
326
265
|
this.streamTimeout = undefined;
|
|
327
266
|
this.snapshotHandlerTimeout = undefined;
|
|
328
267
|
}
|
|
329
|
-
|
|
330
268
|
handleDownloadTimeout() {
|
|
331
269
|
log.info('download canceled');
|
|
332
270
|
this.cancelDownload();
|
|
333
271
|
}
|
|
334
|
-
|
|
335
272
|
writeTableHeader() {
|
|
336
273
|
var _this$fileWriter;
|
|
337
|
-
|
|
338
274
|
var headerString = '';
|
|
339
|
-
|
|
340
275
|
if (this.columns) {
|
|
341
276
|
for (var i = 0; i < this.columns.length; i += 1) {
|
|
342
277
|
headerString += this.columns[i].name;
|
|
343
278
|
headerString += i === this.columns.length - 1 ? '\n' : ',';
|
|
344
279
|
}
|
|
345
280
|
}
|
|
346
|
-
|
|
347
281
|
(_this$fileWriter = this.fileWriter) === null || _this$fileWriter === void 0 ? void 0 : _this$fileWriter.write({
|
|
348
282
|
header: headerString
|
|
349
283
|
}).then(() => null);
|
|
350
284
|
}
|
|
351
|
-
|
|
352
285
|
startWriteTableBody() {
|
|
353
286
|
if (this.columns && this.gridRanges != null) {
|
|
354
287
|
this.chunkRows = Math.floor(TableSaver.DOWNLOAD_CELL_CHUNK / this.columns.length);
|
|
@@ -363,15 +296,12 @@ export default class TableSaver extends PureComponent {
|
|
|
363
296
|
this.makeSnapshot(Math.min(TableSaver.SNAPSHOT_BUFFER_SIZE, this.snapshotsTotal));
|
|
364
297
|
}
|
|
365
298
|
}
|
|
366
|
-
|
|
367
299
|
writeCsvTable(includeColumnHeaders) {
|
|
368
300
|
if (includeColumnHeaders) {
|
|
369
301
|
this.writeTableHeader();
|
|
370
302
|
}
|
|
371
|
-
|
|
372
303
|
this.startWriteTableBody();
|
|
373
304
|
}
|
|
374
|
-
|
|
375
305
|
writeSnapshot(snapshotIndex, snapshotStartRow, snapshotEndRow) {
|
|
376
306
|
if (this.currentSnapshotIndex === snapshotIndex && this.fileWriter) {
|
|
377
307
|
while (this.snapshotsBuffer.has(this.currentSnapshotIndex)) {
|
|
@@ -384,19 +314,16 @@ export default class TableSaver extends PureComponent {
|
|
|
384
314
|
this.currentSnapshotIndex += 1;
|
|
385
315
|
this.updateDownloadProgress(snapshotIndex);
|
|
386
316
|
}
|
|
387
|
-
|
|
388
317
|
if (this.snapshotsTotal && this.currentSnapshotIndex >= this.snapshotsTotal) {
|
|
389
318
|
this.finishDownload();
|
|
390
319
|
return;
|
|
391
320
|
}
|
|
392
321
|
}
|
|
393
|
-
|
|
394
322
|
if (this.snapshotCounter && this.snapshotsTotal && this.snapshotCounter < this.snapshotsTotal) {
|
|
395
323
|
log.debug2("\n current range index: ".concat(this.gridRangeCounter, ", \n snapshotIndexCounter: ").concat(this.snapshotCounter, ", \n currentRangedSnapshotIndex : ").concat(this.rangedSnapshotCounter, ", \n snapshotpending: ").concat(this.snapshotPending, ", \n buffered ").concat(this.snapshotsBuffer.size, "\n making ").concat(Math.min(TableSaver.SNAPSHOT_BUFFER_SIZE - this.snapshotsBuffer.size - this.snapshotPending, this.snapshotsTotal - this.snapshotCounter), " more snapshots\n "));
|
|
396
324
|
this.makeSnapshot(Math.min(TableSaver.SNAPSHOT_BUFFER_SIZE - this.snapshotsBuffer.size - this.snapshotPending, this.snapshotsTotal - this.snapshotCounter));
|
|
397
325
|
}
|
|
398
326
|
}
|
|
399
|
-
|
|
400
327
|
updateDownloadProgress(snapshotIndex) {
|
|
401
328
|
if (snapshotIndex != null && this.snapshotsTotal != null && this.downloadStartTime != null) {
|
|
402
329
|
var {
|
|
@@ -407,7 +334,6 @@ export default class TableSaver extends PureComponent {
|
|
|
407
334
|
onDownloadProgressUpdate(downloadProgress, estimateTime);
|
|
408
335
|
}
|
|
409
336
|
}
|
|
410
|
-
|
|
411
337
|
convertSnapshotIntoCsv(snapshot) {
|
|
412
338
|
var csvString = '';
|
|
413
339
|
var snapshotIterator = snapshot.added.iterator();
|
|
@@ -415,76 +341,58 @@ export default class TableSaver extends PureComponent {
|
|
|
415
341
|
formatter
|
|
416
342
|
} = this.props;
|
|
417
343
|
var rows = [];
|
|
418
|
-
|
|
419
344
|
while (snapshotIterator.hasNext()) {
|
|
420
345
|
rows.push(snapshotIterator.next().value);
|
|
421
346
|
}
|
|
422
|
-
|
|
423
347
|
assertNotNull(this.columns);
|
|
424
348
|
var {
|
|
425
349
|
useUnformattedValues
|
|
426
350
|
} = this;
|
|
427
|
-
|
|
428
351
|
for (var i = 0; i < rows.length; i += 1) {
|
|
429
352
|
var rowIdx = rows[i];
|
|
430
|
-
|
|
431
353
|
for (var j = 0; j < this.columns.length; j += 1) {
|
|
432
|
-
var _this$columns;
|
|
433
|
-
|
|
434
354
|
var {
|
|
435
355
|
type,
|
|
436
356
|
name
|
|
437
357
|
} = this.columns[j];
|
|
438
358
|
var cellData = null;
|
|
439
|
-
|
|
440
359
|
if (useUnformattedValues) {
|
|
441
360
|
var _snapshot$getData;
|
|
442
|
-
|
|
443
361
|
var value = (_snapshot$getData = snapshot.getData(rowIdx, this.columns[j])) !== null && _snapshot$getData !== void 0 ? _snapshot$getData : '';
|
|
444
|
-
|
|
445
362
|
if (value !== '' && TableUtils.isDateType(type)) {
|
|
446
363
|
// value is just a long value, we should return the value formatted as a full date string
|
|
447
364
|
value = dh.i18n.DateTimeFormat.format(UNFORMATTED_DATE_PATTERN, value, dh.i18n.TimeZone.getTimeZone(formatter.timeZone));
|
|
448
365
|
}
|
|
449
|
-
|
|
450
366
|
cellData = value.toString();
|
|
451
367
|
} else {
|
|
452
368
|
var hasCustomColumnFormat = this.getCachedCustomColumnFormatFlag(formatter, name, type);
|
|
453
369
|
var formatOverride = null;
|
|
454
|
-
|
|
455
370
|
if (!hasCustomColumnFormat) {
|
|
456
371
|
var cellFormat = snapshot.getFormat(rowIdx, this.columns[j]);
|
|
457
372
|
formatOverride = (cellFormat === null || cellFormat === void 0 ? void 0 : cellFormat.formatString) != null ? cellFormat : null;
|
|
458
373
|
}
|
|
459
|
-
|
|
460
374
|
if (formatOverride) {
|
|
461
375
|
cellData = formatter.getFormattedString(snapshot.getData(rowIdx, this.columns[j]), type, name, formatOverride);
|
|
462
376
|
} else {
|
|
463
377
|
cellData = formatter.getFormattedString(snapshot.getData(rowIdx, this.columns[j]), type, name);
|
|
464
378
|
}
|
|
465
379
|
}
|
|
466
|
-
|
|
467
380
|
csvString += TableSaver.csvEscapeString(cellData);
|
|
468
|
-
csvString += j ===
|
|
381
|
+
csvString += j === this.columns.length - 1 ? '\n' : ',';
|
|
469
382
|
}
|
|
470
383
|
}
|
|
471
|
-
|
|
472
384
|
return csvString;
|
|
473
385
|
}
|
|
474
|
-
|
|
475
386
|
makeSnapshot(n) {
|
|
476
387
|
var _this = this;
|
|
477
|
-
|
|
478
388
|
if (n <= 0) {
|
|
479
389
|
return;
|
|
480
390
|
}
|
|
481
|
-
|
|
482
391
|
assertNotNull(this.gridRangeCounter);
|
|
483
392
|
var i = 0;
|
|
484
393
|
var currentGridRange = this.gridRanges[this.gridRangeCounter];
|
|
485
394
|
assertNotNull(this.tableSubscription);
|
|
486
395
|
assertNotNull(this.columns);
|
|
487
|
-
|
|
488
396
|
var _loop = function _loop() {
|
|
489
397
|
assertNotNull(currentGridRange);
|
|
490
398
|
assertNotNull(currentGridRange.startRow);
|
|
@@ -494,37 +402,29 @@ export default class TableSaver extends PureComponent {
|
|
|
494
402
|
var snapshotStartRow = currentGridRange.startRow + _this.rangedSnapshotCounter * _this.chunkRows;
|
|
495
403
|
var snapshotEndRow = Math.min(snapshotStartRow + _this.chunkRows - 1, currentGridRange.endRow);
|
|
496
404
|
var snapshotIndex = _this.snapshotCounter;
|
|
497
|
-
|
|
498
405
|
_this.cancelableSnapshots.push(PromiseUtils.makeCancelable(_this.tableSubscription.snapshot(dh.RangeSet.ofRange(snapshotStartRow, snapshotEndRow), _this.columns).then(snapshot => {
|
|
499
406
|
assertIsUpdateEventData(snapshot);
|
|
500
|
-
|
|
501
407
|
_this.handleSnapshotResolved(snapshot, snapshotIndex, snapshotStartRow, snapshotEndRow);
|
|
502
|
-
|
|
503
408
|
return snapshotIndex;
|
|
504
409
|
}).catch(err => {
|
|
505
410
|
log.error(err);
|
|
506
411
|
}), val => {
|
|
507
412
|
log.info("snapshot ".concat(val, " has been canceled"));
|
|
508
413
|
}));
|
|
509
|
-
|
|
510
414
|
_this.rangedSnapshotCounter += 1;
|
|
511
415
|
_this.snapshotCounter += 1;
|
|
512
416
|
_this.snapshotPending += 1;
|
|
513
|
-
|
|
514
417
|
if (_this.rangedSnapshotCounter >= _this.rangedSnapshotsTotal[_this.gridRangeCounter]) {
|
|
515
418
|
_this.gridRangeCounter += 1;
|
|
516
419
|
_this.rangedSnapshotCounter = 0;
|
|
517
420
|
currentGridRange = _this.gridRanges[_this.gridRangeCounter];
|
|
518
421
|
}
|
|
519
|
-
|
|
520
422
|
i += 1;
|
|
521
423
|
};
|
|
522
|
-
|
|
523
424
|
while (i < n) {
|
|
524
425
|
_loop();
|
|
525
426
|
}
|
|
526
427
|
}
|
|
527
|
-
|
|
528
428
|
handlePortMessage(_ref) {
|
|
529
429
|
var {
|
|
530
430
|
data
|
|
@@ -533,11 +433,9 @@ export default class TableSaver extends PureComponent {
|
|
|
533
433
|
download,
|
|
534
434
|
readableStreamPulling
|
|
535
435
|
} = data;
|
|
536
|
-
|
|
537
436
|
if (this.useBlobFallback) {
|
|
538
437
|
return;
|
|
539
438
|
}
|
|
540
|
-
|
|
541
439
|
if (download != null) {
|
|
542
440
|
var {
|
|
543
441
|
includeColumnHeaders
|
|
@@ -545,18 +443,15 @@ export default class TableSaver extends PureComponent {
|
|
|
545
443
|
this.makeIframe("".concat(download));
|
|
546
444
|
this.writeCsvTable(includeColumnHeaders);
|
|
547
445
|
}
|
|
548
|
-
|
|
549
446
|
if (readableStreamPulling != null) {
|
|
550
447
|
if (!this.useBlobFallback) {
|
|
551
448
|
if (this.streamTimeout != null) {
|
|
552
449
|
clearTimeout(this.streamTimeout);
|
|
553
450
|
}
|
|
554
|
-
|
|
555
451
|
this.streamTimeout = setTimeout(this.handleDownloadTimeout, TableSaver.STREAM_TIMEOUT);
|
|
556
452
|
}
|
|
557
453
|
}
|
|
558
454
|
}
|
|
559
|
-
|
|
560
455
|
handleSnapshotResolved(snapshot, snapshotIndex, snapshotStartRow, snapshotEndRow) {
|
|
561
456
|
// use time out to break writeSnapshot into an individual task in browser with timeout, so there's window for the browser to update table in needed.
|
|
562
457
|
this.snapshotHandlerTimeout = setTimeout(() => {
|
|
@@ -566,7 +461,6 @@ export default class TableSaver extends PureComponent {
|
|
|
566
461
|
this.cancelableSnapshots[snapshotIndex] = null;
|
|
567
462
|
}, TableSaver.SNAPSHOT_HANDLER_TIMEOUT);
|
|
568
463
|
}
|
|
569
|
-
|
|
570
464
|
makeIframe(src) {
|
|
571
465
|
// make a return value and make it static method
|
|
572
466
|
var iframe = document.createElement('iframe');
|
|
@@ -576,21 +470,14 @@ export default class TableSaver extends PureComponent {
|
|
|
576
470
|
document.body.appendChild(iframe);
|
|
577
471
|
this.iframes.push(iframe);
|
|
578
472
|
}
|
|
579
|
-
|
|
580
473
|
render() {
|
|
581
474
|
return null;
|
|
582
475
|
}
|
|
583
|
-
|
|
584
476
|
}
|
|
585
|
-
|
|
586
477
|
_defineProperty(TableSaver, "DOWNLOAD_CELL_CHUNK", 6000);
|
|
587
|
-
|
|
588
478
|
_defineProperty(TableSaver, "SNAPSHOT_BUFFER_SIZE", 5);
|
|
589
|
-
|
|
590
479
|
_defineProperty(TableSaver, "STREAM_TIMEOUT", 8000);
|
|
591
|
-
|
|
592
480
|
_defineProperty(TableSaver, "SNAPSHOT_HANDLER_TIMEOUT", 5);
|
|
593
|
-
|
|
594
481
|
_defineProperty(TableSaver, "defaultProps", {
|
|
595
482
|
getDownloadWorker: () => Promise.reject(new Error('Download worker not provided')),
|
|
596
483
|
isDownloading: false,
|