Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JupyterLab enhancements #570

Merged
merged 3 commits into from
May 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion packages/perspective-jupyterlab/src/ts/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class PerspectiveModel extends DOMWidgetModel {
index: '',
limit: -1,
computedcolumns: [],
filters: [],
plugin_config: {},
settings: false,
embed: false,
dark: false
Expand Down Expand Up @@ -86,6 +88,8 @@ class PerspectiveView extends DOMWidgetView {
index: this.model.get('index'),
limit: this.model.get('limit'),
computedcolumns: this.model.get('computedcolumns'),
filters: this.model.get('filters'),
plugin_config: this.model.get('plugin_config'),
settings: this.model.get('settings'),
embed: this.model.get('embed'),
dark: this.model.get('dark'),
Expand All @@ -106,6 +110,8 @@ class PerspectiveView extends DOMWidgetView {
this.model.on('change:aggregates', this.aggregates_changed, this);
this.model.on('change:sort', this.sort_changed, this);
this.model.on('change:computedcolumns', this.computedcolumns_changed, this);
this.model.on('change:filters', this.filters_changed, this);
this.model.on('change:plugin_config', this.plugin_config_changed, this);
this.model.on('change:settings', this.settings_changed, this);
this.model.on('change:embed', this.embed_changed, this);
this.model.on('change:dark', this.dark_changed, this);
Expand Down Expand Up @@ -177,7 +183,15 @@ class PerspectiveView extends DOMWidgetView {
computedcolumns_changed(){
this.psp.computedcolumns = this.model.get('computedcolumns');
}


filters_changed(){
this.psp.filters = this.model.get('filters');
}

plugin_config_changed(){
this.psp.plugin_config = this.model.get('plugin_config');
}

limit_changed(){
this.psp.limit = this.model.get('limit');
}
Expand Down
1 change: 1 addition & 0 deletions packages/perspective-phosphor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@finos/perspective-viewer": "^0.3.0-rc.1",
"@finos/perspective-viewer-highcharts": "^0.3.0-rc.1",
"@finos/perspective-viewer-hypergrid": "^0.3.0-rc.1",
"@finos/perspective-viewer-d3fc": "^0.3.0-rc.1",
"@phosphor/application": "^1.5.0",
"@phosphor/widgets": "^1.6.0"
},
Expand Down
29 changes: 29 additions & 0 deletions packages/perspective-phosphor/src/ts/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import "@finos/perspective-viewer";
import "@finos/perspective-viewer-hypergrid";
import "@finos/perspective-viewer-highcharts";
import "@finos/perspective-viewer-d3fc";

import { Message } from '@phosphor/messaging';
import { Widget } from '@phosphor/widgets';
Expand All @@ -33,6 +34,8 @@ export type PerspectiveWidgetOptions = {
index?: string;
limit?: number;
computedcolumns?: { [colname: string]: string }[];
filters?: string[][];
plugin_config?: any;
settings?: boolean;
embed?: boolean;
dark?: boolean;
Expand Down Expand Up @@ -60,6 +63,8 @@ export type PerspectiveWidgetOptions = {
* @param {string} index - Primary key column name
* @param {number} limit - limit to this many records
* @param {{[colname: string]: string}[]} computedcolumns - Computed columns to use
* @param {string[][]} filters - list of filters to use
* @param {any} filters - configuration for plugin restore
* @param {boolean} settings - show settings
* @param {boolean} embed - Embed mode TODO
* @param {boolean} dark - use dark CSS
Expand Down Expand Up @@ -121,6 +126,8 @@ export
let index: string = options.index || '';
let limit: number = options.limit || -1;
let computedcolumns: { [colname: string]: string }[] = options.computedcolumns || [];
let filters: string[][] = options.filters || [];
let plugin_config: any = options.plugin_config || {};
let settings: boolean = options.settings || false;
let embed: boolean = options.embed || false;
let dark: boolean = options.dark || false;
Expand All @@ -132,6 +139,7 @@ export
this.dark = dark;
this._schema = schema; // dont trigger setter
this.view = view;
this.plugin_config = plugin_config;
this.rowpivots = rowpivots;
this.columnpivots = columnpivots;
this.sort = sort;
Expand All @@ -148,6 +156,7 @@ export

// do computed last
this.computedcolumns = computedcolumns;
this.filters = filters;

this._key = key;
this._wrap = wrap;
Expand Down Expand Up @@ -399,6 +408,24 @@ export
}
}

get filters() { return this._filters; }
set filters(filters: string[][]) {
this._filters = filters;
if (this._filters.length > 0) {
this.pspNode.setAttribute('filters', JSON.stringify(this._filters));
} else {
this.pspNode.removeAttribute('filters');
}
}

get plugin_config() { return this._plugin_config; }
set plugin_config(plugin_config: any) {
this._plugin_config = plugin_config;
if (this._plugin_config) {
this.pspNode.restore(this._plugin_config);
}
}

get limit() { return this._limit; }
set limit(limit: number) {
this._limit = limit;
Expand Down Expand Up @@ -449,6 +476,8 @@ export
private _index: string;
private _limit: number;
private _computedcolumns: { [colname: string]: string }[];
private _filters: string[][];
private _plugin_config: any;

private _settings: boolean;
private _embed: boolean;
Expand Down
25 changes: 17 additions & 8 deletions packages/perspective-viewer/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ declare module '@finos/perspective-viewer' {
load(data: TableData): void;
load(schema: Schema, options: TableOptions): void;
update(data: TableData): void;
delete(): void;

notifyResize(): void;
delete(): Promise<void>;
flush(): Promise<void>;
toggleConfig(): void;
save(): any;
restore(x: any): Promise<void>;


schema?: Schema;
row_pivots?: Array<string>;
column_pivots?: Array<string>;
sort?: Array<string>;
filter?: Array<Array<string>>;
aggregate: Array<AggregateConfig>;
index: string;
columns?: Array<string>;
aggregates?: Array<AggregateConfig>;
filters?: Array<Array<string>>;
view?: string;
column_pivots?: Array<string>;
row_pivots?: Array<string>;

schema?: Schema;
index?: string;
limit?: number;

} & HTMLElement;

}
Expand Down