Skip to content
This repository was archived by the owner on Nov 29, 2022. It is now read-only.

Commit fe39255

Browse files
authored
Merge pull request #108 from alephdata/develop
1.3.0
2 parents c20de6f + 32fa796 commit fe39255

File tree

10 files changed

+1594
-321
lines changed

10 files changed

+1594
-321
lines changed

package-lock.json

Lines changed: 1537 additions & 291 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alephdata/vislib",
3-
"version": "1.2.0",
3+
"version": "1.3.0",
44
"description": "Graph network visualisation tool for aleph/followthemoney ",
55
"keywords": [],
66
"files": [
@@ -83,8 +83,8 @@
8383
"rollup-plugin-commonjs": "^10.1.0",
8484
"rollup-plugin-img": "^1.1.0",
8585
"rollup-plugin-json": "^4.0.0",
86-
"rollup-plugin-node-resolve": "^5.2.0",
87-
"rollup-plugin-sass": "^1.2.2",
86+
"rollup-plugin-node-resolve": "^4.2.1",
87+
"rollup-plugin-postcss": "^2.0.3",
8888
"rollup-plugin-sourcemaps": "^0.4.2",
8989
"rollup-plugin-typescript2": "^0.24.3",
9090
"ts-jest": "^24.1.0",

rollup.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import commonjs from 'rollup-plugin-commonjs'
33
import sourceMaps from 'rollup-plugin-sourcemaps'
44
import typescript from 'rollup-plugin-typescript2'
55
import json from 'rollup-plugin-json'
6-
import sass from 'rollup-plugin-sass'
6+
import postcss from 'rollup-plugin-postcss';
7+
78
import image from 'rollup-plugin-img'
89

910
const pkg = require('./package.json');
@@ -21,15 +22,14 @@ export default {
2122
},
2223
plugins: [
2324
json(),
24-
sass({
25-
output: true,
26-
insert: true
25+
postcss({
26+
extensions: [ '.css', '.scss' ],
2727
}),
2828
image(),
2929
// Allow node_modules resolution, so you can use 'external' to control
3030
// which external modules to include in the bundle
3131
// https://github.com/rollup/rollup-plugin-node-resolve#usage
32-
resolve({browser: true,}),
32+
resolve({browser: true}),
3333
// Compile TypeScript files
3434
typescript({useTsconfigDeclarationDir: true, objectHashIgnoreUnknownHack: true}),
3535
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)

src/VisGraph.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import { Toolbar } from './Toolbar';
99
import { Sidebar } from './Sidebar';
1010
import { History } from './History';
1111
import { EdgeCreateDialog, GroupingCreateDialog, VertexCreateDialog, TableEditor } from "./editor";
12-
import { Model, defaultModel } from '@alephdata/followthemoney'
1312
import { modes } from './interactionModes'
1413

1514
interface IVisGraphProps {
1615
config: GraphConfig,
17-
model: Model,
1816
layout: GraphLayout,
1917
viewport: Viewport,
2018
updateLayout: (layout:GraphLayout, historyModified?: boolean) => void,
@@ -40,7 +38,7 @@ export class VisGraph extends React.Component<IVisGraphProps, IVisGraphState> {
4038

4139
constructor(props: any) {
4240
super(props)
43-
const { config, model, layout, viewport } = props
41+
const { config, layout, viewport } = props
4442

4543
this.history = new History();
4644
this.svgRef = React.createRef()
@@ -91,10 +89,10 @@ export class VisGraph extends React.Component<IVisGraphProps, IVisGraphState> {
9189
}
9290

9391
navigateHistory(factor:number) {
94-
const { config, model } = this.props;
92+
const { config } = this.props;
9593

9694
const nextLayoutData = this.history.go(factor);
97-
this.updateLayout(GraphLayout.fromJSON(config, model, nextLayoutData))
95+
this.updateLayout(GraphLayout.fromJSON(config, nextLayoutData))
9896
}
9997

10098
addVertexToPosition(initialPos?: Point) {

src/editor/TableEditor.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $border-color: rgba(16, 22, 26, 0.15);
2727
.bp3-table-container {
2828
box-shadow: none;
2929
height: inherit;
30+
outline: none !important;
3031
}
3132

3233
.bp3-popover-target {
@@ -59,14 +60,12 @@ $border-color: rgba(16, 22, 26, 0.15);
5960

6061
&__schemaAdd {
6162
margin-top: $table-editor-padding;
62-
padding-top: $table-editor-padding;
63-
border-top: 1px solid $border-color;
6463
}
6564

6665
&__ghostCell.bp3-table-cell {
6766
background-color: white;
6867
box-shadow: none;
69-
pointer-events: none;
68+
pointer-events: none;
7069
}
7170

7271
.bp3-table-cell {

src/editor/TableEditor.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ class TableForSchema extends React.Component<ITableForSchemaProps, ITableForSche
218218
cellRenderer={(i) => {
219219
const entity = entities[i];
220220
return (
221-
<Cell onKeyDown={(e) => console.log('asdasdasda')}>
221+
<Cell>
222222
{entity && (
223223
<Popover
224224
minimal
@@ -244,7 +244,7 @@ class TableForSchema extends React.Component<ITableForSchemaProps, ITableForSche
244244
<Column
245245
id="add-field"
246246
cellRenderer={() => (
247-
<Cell className="TableEditor__ghostCell" />
247+
<Cell className="TableEditor__ghostCell" interactive />
248248
)}
249249
columnHeaderCellRenderer={() => (
250250
<ColumnHeaderCell>

src/index.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1+
body {
2+
padding: 0;
3+
margin: 0;
4+
height: 100%;
5+
display: flex;
16

7+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
8+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
9+
sans-serif;
10+
-webkit-font-smoothing: antialiased;
11+
-moz-osx-font-smoothing: grayscale;
12+
}
13+
14+
#root {
15+
min-width: 100%;
16+
height: 100vh;
17+
}
18+
19+
.vertex--icon {
20+
pointer-events: none;
21+
}
22+
23+
.bp3-tab:focus, .bp3-button:focus {
24+
outline: none;
25+
}

src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
import '@blueprintjs/core/lib/css/blueprint.css';
2+
import '@blueprintjs/select/lib/css/blueprint-select.css';
3+
import '@blueprintjs/datetime/lib/css/blueprint-datetime.css';
4+
import '@blueprintjs/table/lib/css/table.css';
5+
6+
import './index.scss';
7+
18
export * from './layout'
29
export * from './editor'
310
export * from './renderer'

src/layout/GraphLayout.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Entity, Model, IEntityDatum } from '@alephdata/followthemoney'
1+
import { defaultModel, Entity, Model, IEntityDatum } from '@alephdata/followthemoney'
22
import { forceSimulation, forceLink, forceCollide } from 'd3-force';
33
import { DraggableEvent } from 'react-draggable';
44
import { Vertex } from './Vertex'
@@ -31,12 +31,12 @@ export class GraphLayout {
3131
selection = new Array<string>()
3232
private hasDraggedSelection = false
3333

34-
constructor(config: GraphConfig, model: Model) {
34+
constructor(config: GraphConfig) {
3535
this.config = config
36-
this.model = model
36+
this.model = new Model(defaultModel);
3737

38-
this.addVertex = this.addVertex.bind(this)
39-
this.addEdge = this.addEdge.bind(this)
38+
this.addVertex = this.addVertex.bind(this);
39+
this.addEdge = this.addEdge.bind(this);
4040
this.addEntity = this.addEntity.bind(this);
4141
this.removeEntity = this.removeEntity.bind(this);
4242
this.isGroupingSelected = this.isGroupingSelected.bind(this);
@@ -153,11 +153,11 @@ export class GraphLayout {
153153
}
154154

155155
selectVerticesByFilter(predicate: VertexPredicate) {
156-
this.selection = this.getVertices().filter(predicate).map((v) => v.id)
156+
this.selection = this.getVertices().filter((vertex) => !vertex.isHidden()).filter(predicate).map((v) => v.id)
157157
}
158158

159159
selectArea(area: Rectangle) {
160-
const selected = this.getVertices().filter((vertex) => area.contains(vertex.position))
160+
const selected = this.getVertices().filter((vertex) => !vertex.isHidden() && area.contains(vertex.position))
161161
this.selection = selected.map((vertex) => vertex.id)
162162
}
163163

@@ -376,7 +376,7 @@ export class GraphLayout {
376376
}
377377

378378
update(withData:IGraphLayoutData):GraphLayout{
379-
return GraphLayout.fromJSON(this.config, this.model, withData)
379+
return GraphLayout.fromJSON(this.config, withData)
380380
}
381381

382382
toJSON(): IGraphLayoutData {
@@ -389,11 +389,11 @@ export class GraphLayout {
389389
}
390390
}
391391

392-
static fromJSON(config: GraphConfig, model: Model, data: any): GraphLayout {
392+
static fromJSON(config: GraphConfig, data: any): GraphLayout {
393393
const layoutData = data as IGraphLayoutData
394-
const layout = new GraphLayout(config, model)
394+
const layout = new GraphLayout(config)
395395
layoutData.entities.forEach((edata) => {
396-
layout.entities.set(edata.id, model.getEntity(edata))
396+
layout.entities.set(edata.id, layout.model.getEntity(edata))
397397
})
398398
layoutData.vertices.forEach((vdata) => {
399399
const vertex = Vertex.fromJSON(layout, vdata)

src/renderer/GraphRenderer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ export class GraphRenderer extends React.Component<IGraphRendererProps> {
164164
viewport={viewport}
165165
sourcePoint={this.getEdgeCreateSourcePoint()}/>
166166
}
167-
{this.renderSelectionBox()}
168167
{this.renderGroupings()}
169168
{this.renderEdges()}
170169
{this.renderVertices()}

0 commit comments

Comments
 (0)