9
9
10
10
import "@finos/perspective-viewer" ;
11
11
12
- import { Table , TableData } from "@finos/perspective" ;
12
+ import { Table , TableData , Aggregate , Sort , Expression , Filter , ColumnName } from "@finos/perspective" ;
13
13
import { Message } from "@lumino/messaging" ;
14
14
import { Widget } from "@lumino/widgets" ;
15
15
import { MIME_TYPE , PSP_CLASS , PSP_CONTAINER_CLASS , PSP_CONTAINER_CLASS_DARK } from "./utils" ;
16
16
17
- import { HTMLPerspectiveViewerElement , Pivots , Aggregates , Sort , Expressions , PerspectiveViewerOptions , Filters , Columns } from "@finos/perspective-viewer" ;
17
+ import { PerspectiveViewerElement , PerspectiveViewerConfig } from "@finos/perspective-viewer" ;
18
18
19
19
let _increment = 0 ;
20
20
21
- export interface PerspectiveWidgetOptions extends PerspectiveViewerOptions {
21
+ export interface PerspectiveWidgetOptions extends PerspectiveViewerConfig {
22
22
dark ?: boolean ;
23
23
client ?: boolean ;
24
24
server ?: boolean ;
@@ -27,9 +27,9 @@ export interface PerspectiveWidgetOptions extends PerspectiveViewerOptions {
27
27
28
28
// these shouldn't exist, PerspectiveViewerOptions should be sufficient e.g.
29
29
// ["row-pivots"]
30
- column_pivots ?: Pivots ;
31
- row_pivots ?: Pivots ;
32
- expressions ?: Expressions ;
30
+ column_pivots ?: Array < ColumnName > ;
31
+ row_pivots ?: Array < ColumnName > ;
32
+ expressions ?: Array < Expression > ;
33
33
editable ?: boolean ;
34
34
}
35
35
@@ -56,21 +56,21 @@ export class PerspectiveWidget extends Widget {
56
56
*
57
57
* @param options
58
58
*/
59
- _set_attributes ( options : PerspectiveViewerOptions & PerspectiveWidgetOptions ) : void {
59
+ _set_attributes ( options : PerspectiveViewerConfig & PerspectiveWidgetOptions ) : void {
60
60
const plugin : string = options . plugin || "datagrid" ;
61
- const columns : Columns = options . columns || [ ] ;
62
- const row_pivots : Pivots = options . row_pivots || options . row_pivots || [ ] ;
63
- const column_pivots : Pivots = options . column_pivots || options . column_pivots || [ ] ;
64
- const aggregates : Aggregates = options . aggregates || { } ;
65
- const sort : Sort = options . sort || [ ] ;
66
- const filter : Filters = options . filter || [ ] ;
67
- const expressions : Expressions = options . expressions || options . expressions || [ ] ;
61
+ const columns : ColumnName [ ] = options . columns || [ ] ;
62
+ const row_pivots : ColumnName [ ] = options . row_pivots || options . row_pivots || [ ] ;
63
+ const column_pivots : ColumnName [ ] = options . column_pivots || options . column_pivots || [ ] ;
64
+ const aggregates : { [ column : string ] : Aggregate } = options . aggregates || { } ;
65
+ const sort : Sort [ ] = options . sort || [ ] ;
66
+ const filter : Filter [ ] = options . filter || [ ] ;
67
+ const expressions : Expression [ ] = options . expressions || options . expressions || [ ] ;
68
68
const plugin_config : object = options . plugin_config || { } ;
69
69
const dark : boolean = options . dark || false ;
70
70
const editable : boolean = options . editable || false ;
71
71
const server : boolean = options . server || false ;
72
72
const client : boolean = options . client || false ;
73
- const selectable : boolean = options . selectable || false ;
73
+ // const selectable: boolean = options.selectable || false;
74
74
75
75
this . server = server ;
76
76
this . client = client ;
@@ -89,7 +89,7 @@ export class PerspectiveWidget extends Widget {
89
89
} ;
90
90
91
91
// this.plugin_config = plugin_config;
92
- this . selectable = selectable ;
92
+ // this.selectable = selectable;
93
93
}
94
94
95
95
/**********************/
@@ -122,22 +122,18 @@ export class PerspectiveWidget extends Widget {
122
122
}
123
123
124
124
async notifyResize ( ) : Promise < void > {
125
- if ( this . isVisible ) {
126
- await this . viewer . notifyResize ( ) ;
127
- }
125
+ await this . viewer . notifyResize ( ) ;
128
126
}
129
127
130
128
async toggleConfig ( ) : Promise < void > {
131
- if ( this . isVisible ) {
132
- await this . viewer . toggleConfig ( ) ;
133
- }
129
+ await this . viewer . toggleConfig ( ) ;
134
130
}
135
131
136
- async save ( ) : Promise < PerspectiveViewerOptions > {
132
+ async save ( ) : Promise < PerspectiveViewerConfig > {
137
133
return await this . viewer . save ( ) ;
138
134
}
139
135
140
- async restore ( config : PerspectiveViewerOptions ) : Promise < void > {
136
+ async restore ( config : PerspectiveViewerConfig ) : Promise < void > {
141
137
return await this . viewer . restore ( config ) ;
142
138
}
143
139
@@ -156,15 +152,17 @@ export class PerspectiveWidget extends Widget {
156
152
*
157
153
* @param data
158
154
*/
159
- _update ( data : TableData ) : void {
160
- this . viewer . table . update ( data ) ;
155
+ async _update ( data : TableData ) : Promise < void > {
156
+ const table = await this . viewer . getTable ( ) ;
157
+ await table . update ( data ) ;
161
158
}
162
159
163
160
/**
164
161
* Removes all rows from the viewer's table. Does not reset viewer state.
165
162
*/
166
163
async clear ( ) : Promise < void > {
167
- await this . viewer . table . clear ( ) ;
164
+ const table = await this . viewer . getTable ( ) ;
165
+ await table . clear ( ) ;
168
166
}
169
167
170
168
/**
@@ -174,7 +172,8 @@ export class PerspectiveWidget extends Widget {
174
172
* @param data
175
173
*/
176
174
async replace ( data : TableData ) : Promise < void > {
177
- await this . viewer . table . replace ( data ) ;
175
+ const table = await this . viewer . getTable ( ) ;
176
+ await table . replace ( data ) ;
178
177
}
179
178
180
179
/**
@@ -194,8 +193,8 @@ export class PerspectiveWidget extends Widget {
194
193
return await this . viewer . getEditPort ( ) ;
195
194
}
196
195
197
- get table ( ) : Table {
198
- return this . viewer . table ;
196
+ async getTable ( ) : Promise < Table > {
197
+ return await this . viewer . getTable ( ) ;
199
198
}
200
199
201
200
/***************************************************************************
@@ -209,7 +208,7 @@ export class PerspectiveWidget extends Widget {
209
208
*
210
209
* @returns {PerspectiveViewer } The widget's viewer instance.
211
210
*/
212
- get viewer ( ) : HTMLPerspectiveViewerElement {
211
+ get viewer ( ) : PerspectiveViewerElement {
213
212
return this . _viewer ;
214
213
}
215
214
@@ -306,7 +305,7 @@ export class PerspectiveWidget extends Widget {
306
305
}
307
306
}
308
307
309
- static createNode ( node : HTMLDivElement ) : HTMLPerspectiveViewerElement {
308
+ static createNode ( node : HTMLDivElement ) : PerspectiveViewerElement {
310
309
node . classList . add ( "p-Widget" ) ;
311
310
node . classList . add ( PSP_CONTAINER_CLASS ) ;
312
311
const viewer = document . createElement ( "perspective-viewer" ) ;
@@ -342,11 +341,11 @@ export class PerspectiveWidget extends Widget {
342
341
return viewer ;
343
342
}
344
343
345
- private _viewer : HTMLPerspectiveViewerElement ;
344
+ private _viewer : PerspectiveViewerElement ;
346
345
private _plugin_config : object ;
347
346
private _client : boolean ;
348
347
private _server : boolean ;
349
348
private _dark : boolean ;
350
349
private _editable : boolean ;
351
- private _viewer_config : PerspectiveViewerOptions ;
350
+ private _viewer_config : PerspectiveViewerConfig ;
352
351
}
0 commit comments