@jupyterlab/csvviewer
Advanced tools
Comparing version 0.6.0 to 0.7.0
import '../style/index.css'; | ||
export * from './table'; | ||
export * from './toolbar'; | ||
export * from './widget'; |
@@ -9,4 +9,3 @@ "use strict"; | ||
require("../style/index.css"); | ||
__export(require("./table")); | ||
__export(require("./toolbar")); | ||
__export(require("./widget")); |
import { Message } from '@phosphor/messaging'; | ||
import { Widget } from '@phosphor/widgets'; | ||
import { ABCWidgetFactory, DocumentRegistry } from '@jupyterlab/docregistry'; | ||
import { CSVModel } from './table'; | ||
/** | ||
@@ -18,6 +17,2 @@ * A viewer for CSV tables. | ||
/** | ||
* The CSV data model. | ||
*/ | ||
readonly model: CSVModel; | ||
/** | ||
* Dispose of the resources used by the widget. | ||
@@ -31,6 +26,2 @@ */ | ||
/** | ||
* Handle a max exceeded in a csv widget. | ||
*/ | ||
private _onMaxExceeded(sender, overflow); | ||
/** | ||
* Handle a change in delimiter. | ||
@@ -40,15 +31,14 @@ */ | ||
/** | ||
* Handle a change in content. | ||
* Handle a change in path. | ||
*/ | ||
private _onContentChanged(); | ||
private _onPathChanged(); | ||
/** | ||
* Handle a change in path. | ||
* Create the json model for the grid. | ||
*/ | ||
private _onPathChanged(); | ||
private _updateGrid(); | ||
private _context; | ||
private _model; | ||
private _table; | ||
private _grid; | ||
private _toolbar; | ||
private _warning; | ||
private _monitor; | ||
private _delimiter; | ||
} | ||
@@ -55,0 +45,0 @@ /** |
@@ -15,2 +15,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dsv = require("d3-dsv"); | ||
var datagrid_1 = require("@phosphor/datagrid"); | ||
var widgets_1 = require("@phosphor/widgets"); | ||
@@ -20,3 +22,2 @@ var widgets_2 = require("@phosphor/widgets"); | ||
var docregistry_1 = require("@jupyterlab/docregistry"); | ||
var table_1 = require("./table"); | ||
var toolbar_1 = require("./toolbar"); | ||
@@ -28,6 +29,2 @@ /** | ||
/** | ||
* The class name added to a CSV viewer warning. | ||
*/ | ||
var CSV_WARNING_CLASS = 'jp-CSVViewer-warning'; | ||
/** | ||
* The class name added to a CSV viewer toolbar. | ||
@@ -37,2 +34,6 @@ */ | ||
/** | ||
* The class name added to a CSV viewer datagrid. | ||
*/ | ||
var CSV_GRID_CLASS = 'jp-CSVViewer-grid'; | ||
/** | ||
* The timeout to wait for change activity to have ceased before rendering. | ||
@@ -52,7 +53,6 @@ */ | ||
_this._context = null; | ||
_this._model = null; | ||
_this._table = null; | ||
_this._grid = null; | ||
_this._toolbar = null; | ||
_this._warning = null; | ||
_this._monitor = null; | ||
_this._delimiter = ','; | ||
var context = _this._context = options.context; | ||
@@ -62,8 +62,5 @@ var layout = _this.layout = new widgets_1.PanelLayout(); | ||
_this.title.label = context.path.split('/').pop(); | ||
_this._warning = new widgets_2.Widget(); | ||
_this._warning.addClass(CSV_WARNING_CLASS); | ||
_this._model = new table_1.CSVModel({ content: context.model.toString() }); | ||
_this._table = new table_1.CSVTable(); | ||
_this._table.model = _this._model; | ||
_this._model.maxExceeded.connect(_this._onMaxExceeded, _this); | ||
_this._grid = new datagrid_1.DataGrid(); | ||
_this._grid.addClass(CSV_GRID_CLASS); | ||
_this._grid.headerVisibility = 'column'; | ||
_this._toolbar = new toolbar_1.CSVToolbar(); | ||
@@ -73,4 +70,3 @@ _this._toolbar.delimiterChanged.connect(_this._onDelimiterChanged, _this); | ||
layout.addWidget(_this._toolbar); | ||
layout.addWidget(_this._table); | ||
layout.addWidget(_this._warning); | ||
layout.addWidget(_this._grid); | ||
context.pathChanged.connect(_this._onPathChanged, _this); | ||
@@ -82,3 +78,3 @@ // Throttle the rendering rate of the widget. | ||
}); | ||
_this._monitor.activityStopped.connect(_this._onContentChanged, _this); | ||
_this._monitor.activityStopped.connect(_this._updateGrid, _this); | ||
return _this; | ||
@@ -96,12 +92,2 @@ } | ||
}); | ||
Object.defineProperty(CSVViewer.prototype, "model", { | ||
/** | ||
* The CSV data model. | ||
*/ | ||
get: function () { | ||
return this._model; | ||
}, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
/** | ||
@@ -111,19 +97,13 @@ * Dispose of the resources used by the widget. | ||
CSVViewer.prototype.dispose = function () { | ||
if (this._model === null) { | ||
if (this._grid === null) { | ||
return; | ||
} | ||
var model = this._model; | ||
var table = this._table; | ||
var grid = this._grid; | ||
var toolbar = this._toolbar; | ||
var warning = this._warning; | ||
var monitor = this._monitor; | ||
this._model = null; | ||
this._table = null; | ||
this._grid = null; | ||
this._toolbar = null; | ||
this._warning = null; | ||
this._monitor = null; | ||
model.dispose(); | ||
table.dispose(); | ||
grid.dispose(); | ||
toolbar.dispose(); | ||
warning.dispose(); | ||
monitor.dispose(); | ||
@@ -140,22 +120,9 @@ _super.prototype.dispose.call(this); | ||
/** | ||
* Handle a max exceeded in a csv widget. | ||
*/ | ||
CSVViewer.prototype._onMaxExceeded = function (sender, overflow) { | ||
var available = overflow.available, maximum = overflow.maximum; | ||
var message = "Table is too long to render,\n rendering " + maximum + " of " + available + " rows"; | ||
this._warning.node.textContent = message; | ||
}; | ||
/** | ||
* Handle a change in delimiter. | ||
*/ | ||
CSVViewer.prototype._onDelimiterChanged = function (sender, delimiter) { | ||
this._table.model.delimiter = delimiter; | ||
this._delimiter = delimiter; | ||
this._updateGrid(); | ||
}; | ||
/** | ||
* Handle a change in content. | ||
*/ | ||
CSVViewer.prototype._onContentChanged = function () { | ||
this._table.model.content = this._context.model.toString(); | ||
}; | ||
/** | ||
* Handle a change in path. | ||
@@ -166,2 +133,16 @@ */ | ||
}; | ||
/** | ||
* Create the json model for the grid. | ||
*/ | ||
CSVViewer.prototype._updateGrid = function () { | ||
var content = this._context.model.toString(); | ||
var data = dsv.dsvFormat(this._delimiter).parse(content); | ||
var model = new datagrid_1.JSONModel({ | ||
data: data, | ||
schema: { | ||
fields: data.columns.map(function (name) { return { name: name, type: 'string' }; }), | ||
} | ||
}); | ||
this._grid.model = model; | ||
}; | ||
return CSVViewer; | ||
@@ -168,0 +149,0 @@ }(widgets_2.Widget)); |
{ | ||
"name": "@jupyterlab/csvviewer", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "JupyterLab - CSV Widget", | ||
@@ -16,10 +16,10 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@jupyterlab/apputils": "^0.6.0", | ||
"@jupyterlab/coreutils": "^0.6.0", | ||
"@jupyterlab/docregistry": "^0.6.0", | ||
"@phosphor/algorithm": "^1.1.0", | ||
"@phosphor/messaging": "^1.2.0", | ||
"@phosphor/signaling": "^1.2.0", | ||
"@phosphor/virtualdom": "^1.1.0", | ||
"@phosphor/widgets": "^1.2.0", | ||
"@jupyterlab/apputils": "^0.7.0", | ||
"@jupyterlab/coreutils": "^0.7.0", | ||
"@jupyterlab/docregistry": "^0.7.0", | ||
"@phosphor/algorithm": "^1.1.1", | ||
"@phosphor/messaging": "^1.2.1", | ||
"@phosphor/signaling": "^1.2.1", | ||
"@phosphor/virtualdom": "^1.1.1", | ||
"@phosphor/widgets": "^1.3.0", | ||
"@types/d3-dsv": "^1.0.30", | ||
@@ -29,2 +29,3 @@ "d3-dsv": "^1.0.5" | ||
"devDependencies": { | ||
"@phosphor/datagrid": "^0.1.1", | ||
"rimraf": "^2.5.2", | ||
@@ -31,0 +32,0 @@ "typescript": "^2.2.1" |
Sorry, the diff of this file is not supported yet
16070
3
8
470
+ Added@jupyterlab/apputils@0.7.0(transitive)
+ Added@jupyterlab/codeeditor@0.7.0(transitive)
+ Added@jupyterlab/codemirror@0.7.0(transitive)
+ Added@jupyterlab/coreutils@0.7.1(transitive)
+ Added@jupyterlab/docregistry@0.7.0(transitive)
+ Added@jupyterlab/services@0.46.0(transitive)
- Removed@jupyterlab/application@0.6.0(transitive)
- Removed@jupyterlab/apputils@0.6.0(transitive)
- Removed@jupyterlab/codeeditor@0.6.0(transitive)
- Removed@jupyterlab/codemirror@0.6.0(transitive)
- Removed@jupyterlab/coreutils@0.6.0(transitive)
- Removed@jupyterlab/docregistry@0.6.0(transitive)
- Removed@jupyterlab/services@0.45.0(transitive)
- Removed@phosphor/application@1.7.3(transitive)
- Removed@types/semver@5.5.0(transitive)
- Removedsemver@5.7.2(transitive)
Updated@jupyterlab/apputils@^0.7.0
Updated@jupyterlab/coreutils@^0.7.0
Updated@phosphor/algorithm@^1.1.1
Updated@phosphor/messaging@^1.2.1
Updated@phosphor/signaling@^1.2.1
Updated@phosphor/virtualdom@^1.1.1
Updated@phosphor/widgets@^1.3.0