@deephaven/dashboard-core-plugins 0.43.0 → 0.44.1-beta.0

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 (181) hide show
  1. package/dist/ChartBuilderPlugin.js +54 -0
  2. package/dist/ChartBuilderPlugin.js.map +1 -0
  3. package/dist/ChartPlugin.js +66 -0
  4. package/dist/ChartPlugin.js.map +1 -0
  5. package/dist/ConsolePlugin.js +396 -0
  6. package/dist/ConsolePlugin.js.map +1 -0
  7. package/dist/FilterPlugin.js +205 -0
  8. package/dist/FilterPlugin.js.map +1 -0
  9. package/dist/GridPlugin.js +74 -0
  10. package/dist/GridPlugin.js.map +1 -0
  11. package/dist/LinkerPlugin.js +18 -0
  12. package/dist/LinkerPlugin.js.map +1 -0
  13. package/dist/MarkdownPlugin.js +87 -0
  14. package/dist/MarkdownPlugin.js.map +1 -0
  15. package/dist/PandasPlugin.js +66 -0
  16. package/dist/PandasPlugin.js.map +1 -0
  17. package/dist/controls/ControlType.js +10 -0
  18. package/dist/controls/ControlType.js.map +1 -0
  19. package/dist/controls/dropdown-filter/DropdownFilter.css +86 -0
  20. package/dist/controls/dropdown-filter/DropdownFilter.css.map +1 -0
  21. package/dist/controls/dropdown-filter/DropdownFilter.js +417 -0
  22. package/dist/controls/dropdown-filter/DropdownFilter.js.map +1 -0
  23. package/dist/controls/input-filter/InputFilter.css +75 -0
  24. package/dist/controls/input-filter/InputFilter.css.map +1 -0
  25. package/dist/controls/input-filter/InputFilter.js +291 -0
  26. package/dist/controls/input-filter/InputFilter.js.map +1 -0
  27. package/dist/controls/markdown/MarkdownContainer.js +30 -0
  28. package/dist/controls/markdown/MarkdownContainer.js.map +1 -0
  29. package/dist/controls/markdown/MarkdownEditor.js +52 -0
  30. package/dist/controls/markdown/MarkdownEditor.js.map +1 -0
  31. package/dist/controls/markdown/MarkdownStartPage.js +109 -0
  32. package/dist/controls/markdown/MarkdownStartPage.js.map +1 -0
  33. package/dist/controls/markdown/MarkdownUtils.js +23 -0
  34. package/dist/controls/markdown/MarkdownUtils.js.map +1 -0
  35. package/dist/events/ChartEvent.js +9 -0
  36. package/dist/events/ChartEvent.js.map +1 -0
  37. package/dist/events/ConsoleEvent.js +11 -0
  38. package/dist/events/ConsoleEvent.js.map +1 -0
  39. package/dist/events/InputFilterEvent.js +14 -0
  40. package/dist/events/InputFilterEvent.js.map +1 -0
  41. package/dist/events/IrisGridEvent.js +12 -0
  42. package/dist/events/IrisGridEvent.js.map +1 -0
  43. package/dist/events/MarkdownEvent.js +4 -0
  44. package/dist/events/MarkdownEvent.js.map +1 -0
  45. package/dist/events/NotebookEvent.js +15 -0
  46. package/dist/events/NotebookEvent.js.map +1 -0
  47. package/dist/events/PQEvent.js +9 -0
  48. package/dist/events/PQEvent.js.map +1 -0
  49. package/dist/events/PandasEvent.js +8 -0
  50. package/dist/events/PandasEvent.js.map +1 -0
  51. package/dist/events/TabEvent.js +12 -0
  52. package/dist/events/TabEvent.js.map +1 -0
  53. package/dist/events/index.js +9 -0
  54. package/dist/events/index.js.map +1 -0
  55. package/dist/index.js +17 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/linker/ColumnSelectionValidator.js +2 -0
  58. package/dist/linker/ColumnSelectionValidator.js.map +1 -0
  59. package/dist/linker/Linker.js +736 -0
  60. package/dist/linker/Linker.js.map +1 -0
  61. package/dist/linker/LinkerLink.css +142 -0
  62. package/dist/linker/LinkerLink.css.map +1 -0
  63. package/dist/linker/LinkerLink.js +314 -0
  64. package/dist/linker/LinkerLink.js.map +1 -0
  65. package/dist/linker/LinkerOverlayContent.css +63 -0
  66. package/dist/linker/LinkerOverlayContent.css.map +1 -0
  67. package/dist/linker/LinkerOverlayContent.js +343 -0
  68. package/dist/linker/LinkerOverlayContent.js.map +1 -0
  69. package/dist/linker/LinkerUtils.js +139 -0
  70. package/dist/linker/LinkerUtils.js.map +1 -0
  71. package/dist/linker/ToolType.js +5 -0
  72. package/dist/linker/ToolType.js.map +1 -0
  73. package/dist/linker/index.js +2 -0
  74. package/dist/linker/index.js.map +1 -0
  75. package/dist/panels/ChartColumnSelectorOverlay.css +11 -0
  76. package/dist/panels/ChartColumnSelectorOverlay.css.map +1 -0
  77. package/dist/panels/ChartColumnSelectorOverlay.js +38 -0
  78. package/dist/panels/ChartColumnSelectorOverlay.js.map +1 -0
  79. package/dist/panels/ChartFilterOverlay.css +22 -0
  80. package/dist/panels/ChartFilterOverlay.css.map +1 -0
  81. package/dist/panels/ChartFilterOverlay.js +90 -0
  82. package/dist/panels/ChartFilterOverlay.js.map +1 -0
  83. package/dist/panels/ChartPanel.css +38 -0
  84. package/dist/panels/ChartPanel.css.map +1 -0
  85. package/dist/panels/ChartPanel.js +971 -0
  86. package/dist/panels/ChartPanel.js.map +1 -0
  87. package/dist/panels/ChartPanelUtils.js +5 -0
  88. package/dist/panels/ChartPanelUtils.js.map +1 -0
  89. package/dist/panels/CommandHistoryPanel.css +19 -0
  90. package/dist/panels/CommandHistoryPanel.css.map +1 -0
  91. package/dist/panels/CommandHistoryPanel.js +195 -0
  92. package/dist/panels/CommandHistoryPanel.js.map +1 -0
  93. package/dist/panels/ConsolePanel.css +19 -0
  94. package/dist/panels/ConsolePanel.css.map +1 -0
  95. package/dist/panels/ConsolePanel.js +365 -0
  96. package/dist/panels/ConsolePanel.js.map +1 -0
  97. package/dist/panels/DropdownFilterPanel.css +6 -0
  98. package/dist/panels/DropdownFilterPanel.css.map +1 -0
  99. package/dist/panels/DropdownFilterPanel.js +685 -0
  100. package/dist/panels/DropdownFilterPanel.js.map +1 -0
  101. package/dist/panels/FileExplorerPanel.css +6 -0
  102. package/dist/panels/FileExplorerPanel.css.map +1 -0
  103. package/dist/panels/FileExplorerPanel.js +252 -0
  104. package/dist/panels/FileExplorerPanel.js.map +1 -0
  105. package/dist/panels/FilterSetManager.css +112 -0
  106. package/dist/panels/FilterSetManager.css.map +1 -0
  107. package/dist/panels/FilterSetManager.js +689 -0
  108. package/dist/panels/FilterSetManager.js.map +1 -0
  109. package/dist/panels/FilterSetManagerPanel.css +34 -0
  110. package/dist/panels/FilterSetManagerPanel.css.map +1 -0
  111. package/dist/panels/FilterSetManagerPanel.js +345 -0
  112. package/dist/panels/FilterSetManagerPanel.js.map +1 -0
  113. package/dist/panels/InputFilterPanel.js +232 -0
  114. package/dist/panels/InputFilterPanel.js.map +1 -0
  115. package/dist/panels/IrisGridPanel.css +24 -0
  116. package/dist/panels/IrisGridPanel.css.map +1 -0
  117. package/dist/panels/IrisGridPanel.js +1018 -0
  118. package/dist/panels/IrisGridPanel.js.map +1 -0
  119. package/dist/panels/IrisGridPanelTooltip.js +39 -0
  120. package/dist/panels/IrisGridPanelTooltip.js.map +1 -0
  121. package/dist/panels/LogPanel.css +15 -0
  122. package/dist/panels/LogPanel.css.map +1 -0
  123. package/dist/panels/LogPanel.js +110 -0
  124. package/dist/panels/LogPanel.js.map +1 -0
  125. package/dist/panels/MarkdownNotebook.css +107 -0
  126. package/dist/panels/MarkdownNotebook.css.map +1 -0
  127. package/dist/panels/MarkdownNotebook.js +232 -0
  128. package/dist/panels/MarkdownNotebook.js.map +1 -0
  129. package/dist/panels/MarkdownPanel.css +90 -0
  130. package/dist/panels/MarkdownPanel.css.map +1 -0
  131. package/dist/panels/MarkdownPanel.js +202 -0
  132. package/dist/panels/MarkdownPanel.js.map +1 -0
  133. package/dist/panels/MockFileStorage.js +70 -0
  134. package/dist/panels/MockFileStorage.js.map +1 -0
  135. package/dist/panels/MockFileStorageTable.js +80 -0
  136. package/dist/panels/MockFileStorageTable.js.map +1 -0
  137. package/dist/panels/NotebookPanel.css +44 -0
  138. package/dist/panels/NotebookPanel.css.map +1 -0
  139. package/dist/panels/NotebookPanel.js +1224 -0
  140. package/dist/panels/NotebookPanel.js.map +1 -0
  141. package/dist/panels/PandasPanel.css +15 -0
  142. package/dist/panels/PandasPanel.css.map +1 -0
  143. package/dist/panels/PandasPanel.js +86 -0
  144. package/dist/panels/PandasPanel.js.map +1 -0
  145. package/dist/panels/Panel.js +314 -0
  146. package/dist/panels/Panel.js.map +1 -0
  147. package/dist/panels/PanelContextMenu.js +126 -0
  148. package/dist/panels/PanelContextMenu.js.map +1 -0
  149. package/dist/panels/RenameDialog.js +156 -0
  150. package/dist/panels/RenameDialog.js.map +1 -0
  151. package/dist/panels/WidgetPanel.css +17 -0
  152. package/dist/panels/WidgetPanel.css.map +1 -0
  153. package/dist/panels/WidgetPanel.js +189 -0
  154. package/dist/panels/WidgetPanel.js.map +1 -0
  155. package/dist/panels/WidgetPanelTooltip.css +40 -0
  156. package/dist/panels/WidgetPanelTooltip.css.map +1 -0
  157. package/dist/panels/WidgetPanelTooltip.js +49 -0
  158. package/dist/panels/WidgetPanelTooltip.js.map +1 -0
  159. package/dist/panels/index.js +22 -0
  160. package/dist/panels/index.js.map +1 -0
  161. package/dist/prop-types/CommonPropTypes.js +9 -0
  162. package/dist/prop-types/CommonPropTypes.js.map +1 -0
  163. package/dist/prop-types/UIPropTypes.js +42 -0
  164. package/dist/prop-types/UIPropTypes.js.map +1 -0
  165. package/dist/prop-types/index.js +3 -0
  166. package/dist/prop-types/index.js.map +1 -0
  167. package/dist/redux/actionTypes.js +3 -0
  168. package/dist/redux/actionTypes.js.map +1 -0
  169. package/dist/redux/actions.js +88 -0
  170. package/dist/redux/actions.js.map +1 -0
  171. package/dist/redux/index.js +10 -0
  172. package/dist/redux/index.js.map +1 -0
  173. package/dist/redux/reducers/connection.js +7 -0
  174. package/dist/redux/reducers/connection.js.map +1 -0
  175. package/dist/redux/reducers/index.js +5 -0
  176. package/dist/redux/reducers/index.js.map +1 -0
  177. package/dist/redux/reducers/sessionWrapper.js +7 -0
  178. package/dist/redux/reducers/sessionWrapper.js.map +1 -0
  179. package/dist/redux/selectors.js +92 -0
  180. package/dist/redux/selectors.js.map +1 -0
  181. package/package.json +22 -22
@@ -0,0 +1,685 @@
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
4
+ import React, { Component } from 'react';
5
+ import { connect } from 'react-redux';
6
+ import debounce from 'lodash.debounce';
7
+ import deepEqual from 'deep-equal';
8
+ import memoize from 'memoizee';
9
+ import { LayoutUtils } from '@deephaven/dashboard';
10
+ import { DateTimeColumnFormatter, Formatter, FormatterUtils, TableUtils } from '@deephaven/jsapi-utils';
11
+ import Log from '@deephaven/log';
12
+ import { getActiveTool, getApi, getSettings } from '@deephaven/redux';
13
+ import { Pending, PromiseUtils } from '@deephaven/utils';
14
+ import DropdownFilter from "../controls/dropdown-filter/DropdownFilter.js";
15
+ import { InputFilterEvent } from "../events/index.js";
16
+ import { getColumnsForDashboard, getColumnSelectionValidatorForDashboard, getIsolatedLinkerPanelIdForDashboard, getLinksForDashboard, getTableMapForDashboard } from "../redux/index.js";
17
+ import "./DropdownFilterPanel.css";
18
+ import ToolType from "../linker/ToolType.js";
19
+ import WidgetPanel from "./WidgetPanel.js";
20
+ var log = Log.module('DropdownFilterPanel');
21
+ var DROPDOWN_FILTER_DEBOUNCE = 250;
22
+ var mapStateToProps = (state, ownProps) => {
23
+ var {
24
+ localDashboardId
25
+ } = ownProps;
26
+ var panelId = LayoutUtils.getIdFromPanel({
27
+ props: ownProps
28
+ });
29
+ var panelTableMap = getTableMapForDashboard(state, localDashboardId);
30
+ var dashboardLinks = getLinksForDashboard(state, localDashboardId);
31
+ var activeTool = getActiveTool(state);
32
+ var isolatedLinkerPanelId = getIsolatedLinkerPanelIdForDashboard(state, localDashboardId);
33
+ var isLinkerActive = activeTool === ToolType.LINKER && (isolatedLinkerPanelId === undefined || isolatedLinkerPanelId === panelId);
34
+ // Disable linking if linker is in isolated mode for a different panel
35
+ var disableLinking = activeTool === ToolType.LINKER && isolatedLinkerPanelId !== undefined && isolatedLinkerPanelId !== panelId;
36
+ return {
37
+ columns: getColumnsForDashboard(state, localDashboardId),
38
+ columnSelectionValidator: getColumnSelectionValidatorForDashboard(state, localDashboardId),
39
+ dh: getApi(state),
40
+ isLinkerActive,
41
+ disableLinking,
42
+ settings: getSettings(state),
43
+ panelTableMap,
44
+ dashboardLinks
45
+ };
46
+ };
47
+ var connector = connect(mapStateToProps, null, null, {
48
+ forwardRef: true
49
+ });
50
+ export class DropdownFilterPanel extends Component {
51
+ constructor(props) {
52
+ super(props);
53
+ _defineProperty(this, "dateTimeFormatter", void 0);
54
+ _defineProperty(this, "dropdownFilterRef", void 0);
55
+ _defineProperty(this, "panelContainer", void 0);
56
+ _defineProperty(this, "pending", void 0);
57
+ _defineProperty(this, "cleanup", void 0);
58
+ _defineProperty(this, "columnFormats", void 0);
59
+ _defineProperty(this, "getCachedValues", memoize((rawValues, _ref, formatter) => {
60
+ var {
61
+ type,
62
+ name
63
+ } = _ref;
64
+ if (type !== undefined && TableUtils.isDateType(type)) {
65
+ return rawValues.map(value => this.dateTimeFormatter.format(value));
66
+ }
67
+ return rawValues.map(value =>
68
+ // Skip formatting for nulls so they don't get converted to ''
69
+ value != null && type != null ? formatter.getFormattedString(value, type, name) : null);
70
+ }));
71
+ _defineProperty(this, "getCachedPanelLinks", memoize((dashboardLinks, panel) => {
72
+ var panelId = LayoutUtils.getIdFromPanel(panel);
73
+ log.debug('getCachedPanelLinks', dashboardLinks, panelId);
74
+ return dashboardLinks.filter(link => {
75
+ var _link$end;
76
+ return ((_link$end = link.end) === null || _link$end === void 0 ? void 0 : _link$end.panelId) === panelId;
77
+ });
78
+ }));
79
+ _defineProperty(this, "getCachedSource", memoize(links => {
80
+ log.debug('getCachedSource', links);
81
+ var source;
82
+ if (links.length > 0) {
83
+ var [link] = links;
84
+ source = link.start;
85
+ if (links.length > 1) {
86
+ log.error('Filter has more that one link', links);
87
+ }
88
+ }
89
+ return source;
90
+ }));
91
+ _defineProperty(this, "getCachedSourceTable", memoize((panelTableMap, source) => {
92
+ var _panelTableMap$get;
93
+ log.debug('getCachedSourceTable', panelTableMap, source);
94
+ if (source == null) {
95
+ return null;
96
+ }
97
+ var {
98
+ panelId
99
+ } = source;
100
+ return (_panelTableMap$get = panelTableMap.get(panelId)) !== null && _panelTableMap$get !== void 0 ? _panelTableMap$get : null;
101
+ }));
102
+ _defineProperty(this, "getCachedSourceColumn", memoize((table, source) => {
103
+ var _table$columns$find;
104
+ log.debug('getCachedSourceColumn', table, source);
105
+ if (table == null || source == null) {
106
+ return null;
107
+ }
108
+ return (_table$columns$find = table.columns.find(_ref2 => {
109
+ var {
110
+ name,
111
+ type
112
+ } = _ref2;
113
+ return name === source.columnName && type === source.columnType;
114
+ })) !== null && _table$columns$find !== void 0 ? _table$columns$find : null;
115
+ }));
116
+ this.handleChange = debounce(this.handleChange.bind(this), DROPDOWN_FILTER_DEBOUNCE);
117
+ this.handleClearAllFilters = this.handleClearAllFilters.bind(this);
118
+ this.handleDisconnect = this.handleDisconnect.bind(this);
119
+ this.handleReconnect = this.handleReconnect.bind(this);
120
+ this.handleColumnSelected = this.handleColumnSelected.bind(this);
121
+ this.handleSourceFilterChange = this.handleSourceFilterChange.bind(this);
122
+ this.handleSourceSortChange = this.handleSourceSortChange.bind(this);
123
+ this.handleSourceSizeChange = this.handleSourceSizeChange.bind(this);
124
+ this.handleSourceMouseEnter = this.handleSourceMouseEnter.bind(this);
125
+ this.handleSourceMouseLeave = this.handleSourceMouseLeave.bind(this);
126
+ this.handleValuesTableUpdate = this.handleValuesTableUpdate.bind(this);
127
+ this.dropdownFilterRef = /*#__PURE__*/React.createRef();
128
+ this.panelContainer = /*#__PURE__*/React.createRef();
129
+ this.pending = new Pending();
130
+ var {
131
+ dh,
132
+ panelState,
133
+ settings
134
+ } = props;
135
+ this.columnFormats = FormatterUtils.getColumnFormats(settings);
136
+ // Filter dropdown needs to show and send full timestamp format with nanoseconds
137
+ this.dateTimeFormatter = new DateTimeColumnFormatter(dh, {
138
+ showTimeZone: false,
139
+ showTSeparator: true,
140
+ defaultDateTimeFormatString: "yyyy-MM-dd HH:mm:ss.SSSSSSSSS"
141
+ });
142
+ var {
143
+ value: _value = '',
144
+ isValueShown = false,
145
+ name: _name,
146
+ type: _type,
147
+ timestamp
148
+ } = panelState !== null && panelState !== void 0 ? panelState : {};
149
+ var column = _name != null && _type != null ? {
150
+ name: _name,
151
+ type: _type
152
+ } : undefined;
153
+ this.state = {
154
+ column,
155
+ formatter: new Formatter(dh, this.columnFormats),
156
+ valuesTable: undefined,
157
+ valuesColumn: undefined,
158
+ sourceSize: 0,
159
+ value: _value,
160
+ timestamp,
161
+ values: [],
162
+ isValueShown,
163
+ wasFlipped: false,
164
+ skipUpdate: false,
165
+ // eslint-disable-next-line react/no-unused-state
166
+ panelState,
167
+ // Dehydrated panel state that can load this panel
168
+
169
+ isDisconnected: false,
170
+ isLoading: false,
171
+ isLoaded: false,
172
+ error: null
173
+ };
174
+ }
175
+ componentDidMount() {
176
+ this.updateValuesTable();
177
+ var {
178
+ dashboardLinks,
179
+ panelTableMap
180
+ } = this.props;
181
+ var {
182
+ column,
183
+ value,
184
+ timestamp
185
+ } = this.state;
186
+ var sourceTable = this.getSourceTable(panelTableMap, dashboardLinks);
187
+ if (sourceTable !== null) {
188
+ this.startListeningToSource(sourceTable);
189
+ }
190
+ if (column != null) {
191
+ var {
192
+ name,
193
+ type
194
+ } = column;
195
+ this.sendUpdate(name, type, value, timestamp);
196
+ }
197
+ }
198
+ componentDidUpdate(prevProps, prevState) {
199
+ var {
200
+ dashboardLinks,
201
+ panelTableMap,
202
+ settings
203
+ } = this.props;
204
+ var {
205
+ valuesTable
206
+ } = this.state;
207
+ var source = this.getSource(dashboardLinks);
208
+ var sourceTable = this.getSourceTable(panelTableMap, dashboardLinks);
209
+ var prevSource = this.getSource(prevProps.dashboardLinks);
210
+ var prevSourceTable = this.getSourceTable(prevProps.panelTableMap, prevProps.dashboardLinks);
211
+ if (settings !== prevProps.settings && settings !== undefined) {
212
+ this.updateFormatterSettings(settings);
213
+ }
214
+ if (valuesTable !== prevState.valuesTable && prevState.valuesTable != null) {
215
+ log.debug('Table in state modified, closing the old table.');
216
+ prevState.valuesTable.close();
217
+ }
218
+
219
+ // Checking source change in addition to table change
220
+ // in case a different column is selected in the same table
221
+ if (sourceTable !== prevSourceTable || source !== prevSource) {
222
+ this.updateValuesTable();
223
+ }
224
+ if (sourceTable !== prevSourceTable) {
225
+ if (prevSourceTable !== null) {
226
+ this.stopListeningToSource(prevSourceTable);
227
+ }
228
+ if (sourceTable !== null) {
229
+ this.startListeningToSource(sourceTable);
230
+ }
231
+ }
232
+ }
233
+ componentWillUnmount() {
234
+ var {
235
+ dashboardLinks,
236
+ panelTableMap
237
+ } = this.props;
238
+ var {
239
+ valuesTable
240
+ } = this.state;
241
+ var sourceTable = this.getSourceTable(panelTableMap, dashboardLinks);
242
+ this.pending.cancel();
243
+ if (sourceTable !== null) {
244
+ this.stopListeningToSource(sourceTable);
245
+ }
246
+ if (this.cleanup) {
247
+ this.cleanup();
248
+ }
249
+ if (valuesTable != null) {
250
+ valuesTable.close();
251
+ }
252
+ }
253
+ getCoordinateForColumn() {
254
+ var _element$getBoundingC;
255
+ if (this.panelContainer.current == null) {
256
+ return null;
257
+ }
258
+ var element = this.panelContainer.current.querySelector(".".concat(DropdownFilter.SOURCE_BUTTON_CLASS_NAME));
259
+ var rect = (_element$getBoundingC = element === null || element === void 0 ? void 0 : element.getBoundingClientRect()) !== null && _element$getBoundingC !== void 0 ? _element$getBoundingC : null;
260
+ if (rect == null || rect.width <= 0 || rect.height <= 0) {
261
+ return null;
262
+ }
263
+ var x = rect.left + rect.width / 2;
264
+ var y = rect.bottom;
265
+ return [x, y];
266
+ }
267
+ getSettingsErrorMessage() {
268
+ var {
269
+ sourceSize
270
+ } = this.state;
271
+ if (sourceSize > DropdownFilterPanel.MAX_TABLE_SIZE) {
272
+ return "Table too large, must have fewer than ".concat(DropdownFilterPanel.MAX_TABLE_SIZE, " options.");
273
+ }
274
+ return undefined;
275
+ }
276
+ getPanelErrorMessage() {
277
+ var {
278
+ error
279
+ } = this.state;
280
+ return error != null ? "".concat(error) : undefined;
281
+ }
282
+ getSource(links) {
283
+ var panelLinks = this.getCachedPanelLinks(links, this);
284
+ return this.getCachedSource(panelLinks);
285
+ }
286
+ getSourceTable(panelTableMap, links) {
287
+ var source = this.getSource(links);
288
+ return this.getCachedSourceTable(panelTableMap, source);
289
+ }
290
+ getValuesColumn(valuesTable, links) {
291
+ var source = this.getSource(links);
292
+ return this.getCachedSourceColumn(valuesTable, source);
293
+ }
294
+ startListeningToSource(sourceTable) {
295
+ var {
296
+ dh
297
+ } = this.props;
298
+ log.debug('startListeningToSource');
299
+ sourceTable.addEventListener(dh.Table.EVENT_FILTERCHANGED, this.handleSourceFilterChange);
300
+ sourceTable.addEventListener(dh.Table.EVENT_SORTCHANGED, this.handleSourceSortChange);
301
+ sourceTable.addEventListener(dh.Table.EVENT_SIZECHANGED, this.handleSourceSizeChange);
302
+ sourceTable.addEventListener(dh.Table.EVENT_DISCONNECT, this.handleDisconnect);
303
+ sourceTable.addEventListener(dh.Table.EVENT_RECONNECT, this.handleReconnect);
304
+ }
305
+ stopListeningToSource(sourceTable) {
306
+ var {
307
+ dh
308
+ } = this.props;
309
+ log.debug('stopListeningToSource');
310
+ sourceTable.removeEventListener(dh.Table.EVENT_FILTERCHANGED, this.handleSourceFilterChange);
311
+ sourceTable.removeEventListener(dh.Table.EVENT_SORTCHANGED, this.handleSourceSortChange);
312
+ sourceTable.removeEventListener(dh.Table.EVENT_SIZECHANGED, this.handleSourceSizeChange);
313
+ sourceTable.removeEventListener(dh.Table.EVENT_DISCONNECT, this.handleDisconnect);
314
+ sourceTable.removeEventListener(dh.Table.EVENT_RECONNECT, this.handleReconnect);
315
+ }
316
+ handleChange(_ref3) {
317
+ var {
318
+ column,
319
+ isValueShown = false,
320
+ value
321
+ } = _ref3;
322
+ var {
323
+ name = undefined,
324
+ type = undefined
325
+ } = column !== null && column !== void 0 ? column : {};
326
+ var sendUpdate = true;
327
+ var timestamp = Date.now();
328
+ this.setState(_ref4 => {
329
+ var _ref5, _timestamp;
330
+ var {
331
+ panelState,
332
+ timestamp: prevTimestamp,
333
+ wasFlipped,
334
+ skipUpdate
335
+ } = _ref4;
336
+ // If the user had a value set, and they flip the card over and flip it back without changing any settings, ignore it
337
+ var isFlip = panelState != null && isValueShown !== panelState.isValueShown && name === panelState.name && type === panelState.type && value === panelState.value;
338
+ sendUpdate = (_ref5 = !skipUpdate && isValueShown && (!isFlip || !wasFlipped)) !== null && _ref5 !== void 0 ? _ref5 : false;
339
+ if (!sendUpdate) {
340
+ timestamp = prevTimestamp;
341
+ }
342
+ return {
343
+ panelState: {
344
+ isValueShown,
345
+ name,
346
+ type,
347
+ value,
348
+ timestamp: (_timestamp = timestamp) !== null && _timestamp !== void 0 ? _timestamp : undefined
349
+ },
350
+ timestamp,
351
+ wasFlipped: isFlip,
352
+ skipUpdate: false
353
+ };
354
+ }, () => {
355
+ if (sendUpdate) {
356
+ this.sendUpdate(name !== null && name !== void 0 ? name : null, type, value, timestamp);
357
+ }
358
+ });
359
+ }
360
+ handleDisconnect() {
361
+ this.setState({
362
+ error: new Error('Table disconnected'),
363
+ isDisconnected: true,
364
+ isLoading: false
365
+ });
366
+ }
367
+ handleReconnect() {
368
+ this.setState({
369
+ isDisconnected: false,
370
+ error: null
371
+ });
372
+ }
373
+ handleSourceFilterChange() {
374
+ this.applySourceFilters();
375
+ }
376
+ handleSourceSortChange() {
377
+ this.applySourceSorts();
378
+ }
379
+ handleSourceSizeChange(_ref6) {
380
+ var {
381
+ detail
382
+ } = _ref6;
383
+ this.setState({
384
+ sourceSize: detail
385
+ });
386
+ }
387
+ handleColumnSelected() {
388
+ log.debug('handleColumnSelected');
389
+ var {
390
+ glEventHub
391
+ } = this.props;
392
+ glEventHub.emit(InputFilterEvent.COLUMN_SELECTED, this, DropdownFilterPanel.SOURCE_COLUMN);
393
+ }
394
+ handleClearAllFilters() {
395
+ var _this$dropdownFilterR, _this$dropdownFilterR2;
396
+ (_this$dropdownFilterR = this.dropdownFilterRef) === null || _this$dropdownFilterR === void 0 ? void 0 : (_this$dropdownFilterR2 = _this$dropdownFilterR.current) === null || _this$dropdownFilterR2 === void 0 ? void 0 : _this$dropdownFilterR2.clearFilter();
397
+ }
398
+
399
+ /**
400
+ * Set the filter value, card side, selected column
401
+ * @param state Filter state to set
402
+ * @param sendUpdate Emit filters changed event if true
403
+ */
404
+ setPanelState(state) {
405
+ var _this$dropdownFilterR3, _this$dropdownFilterR4;
406
+ var sendUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
407
+ var {
408
+ dashboardLinks
409
+ } = this.props;
410
+ if (this.getSource(dashboardLinks) == null) {
411
+ log.debug('Ignore state update for unlinked filter', state);
412
+ return;
413
+ }
414
+ // Set the skipUpdate flag so the next onChange handler call doesn't emit the FILTERS_CHANGED event
415
+ this.setState({
416
+ skipUpdate: !sendUpdate
417
+ });
418
+
419
+ // Changing the inputFilter state via props doesn't quite work because of the delays on manual input changes
420
+ // Setting the ref state directly triggers the onChange handler and updates the panelState
421
+ (_this$dropdownFilterR3 = this.dropdownFilterRef) === null || _this$dropdownFilterR3 === void 0 ? void 0 : (_this$dropdownFilterR4 = _this$dropdownFilterR3.current) === null || _this$dropdownFilterR4 === void 0 ? void 0 : _this$dropdownFilterR4.setFilterState(state);
422
+ }
423
+ sendUpdate(name, type, value, timestamp) {
424
+ var _this$getSource;
425
+ var {
426
+ dashboardLinks,
427
+ glEventHub
428
+ } = this.props;
429
+ var sourcePanelId = (_this$getSource = this.getSource(dashboardLinks)) === null || _this$getSource === void 0 ? void 0 : _this$getSource.panelId;
430
+ var excludePanelIds = sourcePanelId === null ? [] : [sourcePanelId];
431
+ log.debug('sendUpdate', {
432
+ name,
433
+ type,
434
+ value,
435
+ timestamp,
436
+ excludePanelIds
437
+ });
438
+ glEventHub.emit(InputFilterEvent.FILTERS_CHANGED, this, {
439
+ name,
440
+ type,
441
+ value: value != null ? value : '=null',
442
+ timestamp,
443
+ excludePanelIds
444
+ });
445
+ }
446
+ updateValuesTable() {
447
+ var {
448
+ dashboardLinks,
449
+ panelTableMap
450
+ } = this.props;
451
+ var source = this.getSource(dashboardLinks);
452
+ var sourceTable = this.getSourceTable(panelTableMap, dashboardLinks);
453
+ log.debug('updateValuesTable', source, sourceTable);
454
+ this.setState({
455
+ values: [],
456
+ valuesTable: undefined,
457
+ error: null
458
+ });
459
+ if (source == null) {
460
+ log.debug('Filter unlinked.');
461
+ this.setState({
462
+ isLoading: false,
463
+ isLoaded: true,
464
+ isValueShown: false,
465
+ sourceSize: 0
466
+ });
467
+ return;
468
+ }
469
+ this.setState({
470
+ isLoading: true
471
+ });
472
+ if (sourceTable == null) {
473
+ return;
474
+ }
475
+ this.setState({
476
+ isLoaded: false,
477
+ sourceSize: sourceTable.size
478
+ });
479
+ this.pending.add(sourceTable.copy(), resolved => resolved.close()).then(valuesTable => {
480
+ // Loading/loaded will be set when values array is actually populated
481
+ this.updateViewportListener(valuesTable);
482
+ this.setState({
483
+ valuesTable
484
+ });
485
+ }).catch(error => {
486
+ if (PromiseUtils.isCanceled(error)) {
487
+ return;
488
+ }
489
+ log.error(error);
490
+ this.setState({
491
+ isLoading: false,
492
+ error
493
+ });
494
+ });
495
+ }
496
+ applySourceSorts() {
497
+ var {
498
+ dashboardLinks,
499
+ panelTableMap
500
+ } = this.props;
501
+ var {
502
+ valuesTable
503
+ } = this.state;
504
+ var sourceTable = this.getSourceTable(panelTableMap, dashboardLinks);
505
+ log.debug('applySourceSorts', sourceTable === null || sourceTable === void 0 ? void 0 : sourceTable.sort);
506
+ if (valuesTable == null || sourceTable == null) {
507
+ log.debug('Table not initialized');
508
+ return;
509
+ }
510
+ var sorts = [...sourceTable.sort];
511
+ valuesTable.applySort(sorts);
512
+ this.setViewport(valuesTable);
513
+ }
514
+ applySourceFilters() {
515
+ var {
516
+ dashboardLinks,
517
+ panelTableMap
518
+ } = this.props;
519
+ var {
520
+ valuesTable
521
+ } = this.state;
522
+ var sourceTable = this.getSourceTable(panelTableMap, dashboardLinks);
523
+ log.debug('applySourceFilters', sourceTable === null || sourceTable === void 0 ? void 0 : sourceTable.filter);
524
+ if (valuesTable == null || sourceTable == null) {
525
+ log.debug('Table not initialized');
526
+ return;
527
+ }
528
+ var filters = [...sourceTable.filter];
529
+ valuesTable.applyFilter(filters);
530
+ this.setViewport(valuesTable);
531
+ }
532
+ updateViewportListener(valuesTable) {
533
+ var {
534
+ dh
535
+ } = this.props;
536
+ log.debug('updateViewportListener', valuesTable === null || valuesTable === void 0 ? void 0 : valuesTable.size);
537
+ if (this.cleanup) {
538
+ this.cleanup();
539
+ }
540
+ if (valuesTable == null) {
541
+ this.cleanup = undefined;
542
+ return;
543
+ }
544
+ this.cleanup = valuesTable.addEventListener(dh.Table.EVENT_UPDATED, this.handleValuesTableUpdate);
545
+ this.setViewport(valuesTable);
546
+ }
547
+ setViewport(valuesTable) {
548
+ var {
549
+ dashboardLinks
550
+ } = this.props;
551
+ var valuesColumn = this.getValuesColumn(valuesTable, dashboardLinks);
552
+ if (!valuesColumn) {
553
+ log.error('values column is null');
554
+ return;
555
+ }
556
+ valuesTable.setViewport(0, DropdownFilterPanel.MAX_TABLE_SIZE - 1, [valuesColumn]);
557
+ }
558
+ updateFormatterSettings(settings) {
559
+ var {
560
+ dh
561
+ } = this.props;
562
+ var columnFormats = FormatterUtils.getColumnFormats(settings);
563
+ if (!deepEqual(this.columnFormats, columnFormats)) {
564
+ this.columnFormats = columnFormats;
565
+ this.setState({
566
+ formatter: new Formatter(dh, columnFormats)
567
+ });
568
+ }
569
+ }
570
+ handleValuesTableUpdate(_ref7) {
571
+ var {
572
+ detail
573
+ } = _ref7;
574
+ var {
575
+ rows
576
+ } = detail;
577
+ var {
578
+ dashboardLinks
579
+ } = this.props;
580
+ var {
581
+ valuesTable
582
+ } = this.state;
583
+ if (!valuesTable) {
584
+ log.error('valuesTable is null');
585
+ return;
586
+ }
587
+ var valuesColumn = this.getValuesColumn(valuesTable, dashboardLinks);
588
+ if (!valuesColumn) {
589
+ log.error('Values column not found');
590
+ return;
591
+ }
592
+ var values = rows.map(row => row.get(valuesColumn));
593
+ this.setState({
594
+ values,
595
+ isLoading: false,
596
+ isLoaded: true,
597
+ valuesColumn
598
+ });
599
+ }
600
+ handleSourceMouseEnter() {
601
+ var {
602
+ columnSelectionValidator
603
+ } = this.props;
604
+ if (!columnSelectionValidator) {
605
+ return;
606
+ }
607
+ columnSelectionValidator(this, DropdownFilterPanel.SOURCE_COLUMN);
608
+ }
609
+ handleSourceMouseLeave() {
610
+ var {
611
+ columnSelectionValidator
612
+ } = this.props;
613
+ if (!columnSelectionValidator) {
614
+ return;
615
+ }
616
+ columnSelectionValidator(this, undefined);
617
+ }
618
+ render() {
619
+ var {
620
+ columns,
621
+ dashboardLinks,
622
+ disableLinking,
623
+ glContainer,
624
+ glEventHub,
625
+ isLinkerActive
626
+ } = this.props;
627
+ var {
628
+ column,
629
+ formatter,
630
+ isDisconnected,
631
+ isValueShown,
632
+ value,
633
+ values,
634
+ valuesColumn,
635
+ isLoading,
636
+ isLoaded
637
+ } = this.state;
638
+ var source = this.getSource(dashboardLinks);
639
+ var settingsErrorMessage = this.getSettingsErrorMessage();
640
+ var panelErrorMessage = this.getPanelErrorMessage();
641
+ var formattedValues = isLoaded && valuesColumn != null ? this.getCachedValues(values, valuesColumn, formatter) : [];
642
+ return /*#__PURE__*/React.createElement(WidgetPanel, {
643
+ errorMessage: panelErrorMessage,
644
+ isLoading: isLoading,
645
+ isLoaded: isLoaded,
646
+ isDisconnected: isDisconnected,
647
+ className: "iris-dropdown-filter-panel",
648
+ componentPanel: this,
649
+ glContainer: glContainer,
650
+ glEventHub: glEventHub,
651
+ onClearAllFilters: this.handleClearAllFilters,
652
+ widgetName: "Dropdown Filter",
653
+ widgetType: "DropdownFilter"
654
+ }, /*#__PURE__*/React.createElement("div", {
655
+ ref: this.panelContainer,
656
+ className: "dropdown-filter-container h-100 w-100 container"
657
+ }, /*#__PURE__*/React.createElement(DropdownFilter, {
658
+ ref: this.dropdownFilterRef,
659
+ column: column,
660
+ columns: columns,
661
+ isValueShown: isValueShown,
662
+ isLinkerActive: isLinkerActive,
663
+ disableLinking: disableLinking,
664
+ isLoaded: isLoaded,
665
+ settingsError: settingsErrorMessage,
666
+ source: source,
667
+ value: value,
668
+ values: formattedValues,
669
+ onChange: this.handleChange,
670
+ onColumnSelected: this.handleColumnSelected,
671
+ onSourceMouseEnter: this.handleSourceMouseEnter,
672
+ onSourceMouseLeave: this.handleSourceMouseLeave
673
+ })));
674
+ }
675
+ }
676
+ _defineProperty(DropdownFilterPanel, "displayName", 'DropdownFilterPanel');
677
+ _defineProperty(DropdownFilterPanel, "COMPONENT", 'DropdownFilterPanel');
678
+ _defineProperty(DropdownFilterPanel, "MAX_TABLE_SIZE", 256);
679
+ _defineProperty(DropdownFilterPanel, "SOURCE_COLUMN", Object.freeze({
680
+ name: 'FilterSource',
681
+ type: null
682
+ }));
683
+ var ConnectedDropdownFilterPanel = connector(DropdownFilterPanel);
684
+ export default ConnectedDropdownFilterPanel;
685
+ //# sourceMappingURL=DropdownFilterPanel.js.map