Skip to content

Commit 2856456

Browse files
committed
Resolve TODOs
1 parent 29026f3 commit 2856456

7 files changed

Lines changed: 138 additions & 235 deletions

File tree

packages/dashboard-core-plugins/src/SimplePivotWidgetPlugin.tsx

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { useCallback } from 'react';
22
import { type WidgetComponentProps } from '@deephaven/plugin';
3-
import { type dh as DhType, type Iterator } from '@deephaven/jsapi-types';
4-
import IrisGrid from '@deephaven/iris-grid';
5-
import Log from '@deephaven/log';
3+
import { type dh as DhType } from '@deephaven/jsapi-types';
4+
import IrisGrid, {
5+
getSimplePivotColumnMap,
6+
KEY_TABLE_PIVOT_COLUMN,
7+
type KeyColumnArray,
8+
type KeyTableSubscriptionData,
9+
} from '@deephaven/iris-grid';
610
import { useApi } from '@deephaven/jsapi-bootstrap';
711
import { LoadingOverlay } from '@deephaven/components';
812
import { getErrorMessage } from '@deephaven/utils';
@@ -11,44 +15,25 @@ import {
1115
type SimplePivotFetchResult,
1216
} from './useIrisGridSimplePivotModel';
1317

14-
const log = Log.module('SimplePivotWidgetPlugin');
15-
1618
export function SimplePivotWidgetPlugin({
1719
fetch,
1820
}: WidgetComponentProps<DhType.Widget>): JSX.Element | null {
1921
const dh = useApi();
2022
const loadKeys = useCallback(
21-
(keyTable: DhType.Table): Promise<(readonly [string, string])[]> =>
23+
(keyTable: DhType.Table): Promise<KeyColumnArray> =>
2224
new Promise((resolve, reject) => {
23-
// TODO: use a util method to get the map
24-
const pivotIdColumn = keyTable.findColumn('__PIVOT_COLUMN');
25+
const pivotIdColumn = keyTable.findColumn(KEY_TABLE_PIVOT_COLUMN);
2526
const columns = keyTable.columns.filter(
26-
c => c.name !== '__PIVOT_COLUMN'
27+
c => c.name !== KEY_TABLE_PIVOT_COLUMN
2728
);
2829
const subscription = keyTable.subscribe(keyTable.columns);
29-
subscription.addEventListener<{
30-
fullIndex: { iterator: () => Iterator<DhType.Row> };
31-
getData: (rowKey: DhType.Row, column: DhType.Column) => string;
32-
}>(dh.Table.EVENT_UPDATED, e => {
33-
const columnMap: (readonly [string, string])[] = [];
34-
const data = e.detail;
35-
const rowIter = data.fullIndex.iterator();
36-
while (rowIter.hasNext()) {
37-
const rowKey = rowIter.next().value;
38-
const value = [];
39-
for (let i = 0; i < columns.length; i += 1) {
40-
value.push(data.getData(rowKey, columns[i]));
41-
}
42-
columnMap.push([
43-
`PIVOT_C_${data.getData(rowKey, pivotIdColumn)}`,
44-
value.join(', '),
45-
]);
30+
subscription.addEventListener<KeyTableSubscriptionData>(
31+
dh.Table.EVENT_UPDATED,
32+
e => {
33+
subscription.close();
34+
resolve(getSimplePivotColumnMap(e.detail, columns, pivotIdColumn));
4635
}
47-
log.debug('Column map', columnMap);
48-
subscription.close();
49-
// TODO: set column map in the model
50-
resolve(columnMap);
51-
});
36+
);
5237
}),
5338
[dh]
5439
);

packages/dashboard-core-plugins/src/panels/SimplePivotPanel.tsx

Lines changed: 0 additions & 90 deletions
This file was deleted.

packages/dashboard-core-plugins/src/panels/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export { default as NotebookPanel } from './NotebookPanel';
1818
export { default as PandasPanel } from './PandasPanel';
1919
export * from './PandasPanel';
2020
export { default as Panel } from './Panel';
21-
export { default as SimplePivotPanel } from './SimplePivotPanel';
2221
export * from './WidgetPanelTypes';
2322
export { default as WidgetPanel, type WidgetPanelProps } from './WidgetPanel';
2423
export { default as WidgetPanelTooltip } from './WidgetPanelTooltip';

packages/dashboard-core-plugins/src/useIrisGridSimplePivotModel.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import { useCallback, useEffect, useState } from 'react';
44
import {
55
type IrisGridModel,
66
IrisGridSimplePivotModel,
7+
type KeyColumnArray,
78
type SimplePivotSchema,
89
} from '@deephaven/iris-grid';
910
import Log from '@deephaven/log';
1011

1112
const log = Log.module('useIrisGridSimplePivotModel');
1213

1314
export interface SimplePivotFetchResult {
14-
columnMap: (readonly [string, string])[];
15+
columnMap: KeyColumnArray;
1516
schema: SimplePivotSchema;
1617
table: dh.Table;
1718
keyTable: dh.Table;

0 commit comments

Comments
 (0)