Skip to content

Commit 5061946

Browse files
Selected and not selected list of nodes implementation
1 parent 9631af8 commit 5061946

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iknow-entity-browser",
3-
"version": "0.5.11",
3+
"version": "0.5.12",
44
"description": "Visualizer for iKnow entities",
55
"main": "gulpfile.babel.js",
66
"scripts": {

src/static/js/selection.js

+8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import * as model from "./model";
22

33
let selection = [],
4+
others = [],
45
callbacks = [];
56

67
export function updateSelection () {
78

89
let tree = model.getGraphData();
910
selection = [];
11+
others = [];
1012

1113
function findSelected (node) {
1214
if (node.selected)
1315
selection.push(node);
16+
else
17+
others.push(node);
1418
if (node.children)
1519
for (let n of node.children) findSelected(n);
1620
}
@@ -24,6 +28,10 @@ export function getSelection () {
2428
return selection;
2529
}
2630

31+
export function getOthers () {
32+
return others;
33+
}
34+
2735
export function selectAll (node) {
2836
if (!node)
2937
return;

src/static/js/tabular/index.js

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { csv } from "./export";
22
import * as model from "../model";
3-
import { onSelectionUpdate, updateSelection, getSelection } from "../selection";
3+
import { onSelectionUpdate, updateSelection, getSelection, getOthers } from "../selection";
44

55
let sorting = {
66
properties: ["entities", "0", "score"],
@@ -34,7 +34,22 @@ function updateSelected () {
3434
}
3535

3636
function updateOthers () {
37-
37+
let data = getOthers().filter(node => node.type === "entity").sort(sorter),
38+
table = document.querySelector("#tabular-others");
39+
table.textContent = "";
40+
for (let i = 0; i < data.length; i++) {
41+
let row = table.insertRow(i),
42+
node = data[i],
43+
c;
44+
row.insertCell(0).textContent = node.id;
45+
row.insertCell(1).textContent = node.label;
46+
row.insertCell(2).textContent = node.entities[0].score;
47+
row.insertCell(3).textContent = node.entities[0].frequency;
48+
row.insertCell(4).textContent = node.entities[0].spread;
49+
(c = row.insertCell(5)).textContent = node.edgeType || "";
50+
c.className = `${ node.edgeType }Item`;
51+
row.insertCell(6).textContent = (node.parent || { label: "root" }).label || "?";
52+
}
3853
}
3954

4055
function updateAll () {
@@ -45,7 +60,7 @@ function updateAll () {
4560
onSelectionUpdate(() => {
4661
if (!model.uiState.tabularToggled)
4762
return;
48-
updateSelected();
63+
updateAll();
4964
});
5065

5166
/**

src/static/scss/tabular.scss

+20
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ $headerHeight: 36px;
4444

4545
#tabular th {
4646

47+
@include user-select(none);
48+
cursor: pointer;
49+
4750
&.sort-up:after {
4851
content: "";
4952
}
@@ -52,4 +55,21 @@ $headerHeight: 36px;
5255
content: "";
5356
}
5457

58+
}
59+
60+
#tabular td {
61+
max-width: 150px;
62+
white-space: pre;
63+
overflow: hidden;
64+
text-overflow: ellipsis;
65+
}
66+
67+
#tabular-others {
68+
69+
opacity: 0.6;
70+
71+
tr:first-child td {
72+
border-top: 1px solid black;
73+
}
74+
5575
}

0 commit comments

Comments
 (0)