Skip to content

Commit

Permalink
Selected and not selected list of nodes implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Jan 22, 2017
1 parent 9631af8 commit 5061946
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iknow-entity-browser",
"version": "0.5.11",
"version": "0.5.12",
"description": "Visualizer for iKnow entities",
"main": "gulpfile.babel.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/static/js/selection.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import * as model from "./model";

let selection = [],
others = [],
callbacks = [];

export function updateSelection () {

let tree = model.getGraphData();
selection = [];
others = [];

function findSelected (node) {
if (node.selected)
selection.push(node);
else
others.push(node);
if (node.children)
for (let n of node.children) findSelected(n);
}
Expand All @@ -24,6 +28,10 @@ export function getSelection () {
return selection;
}

export function getOthers () {
return others;
}

export function selectAll (node) {
if (!node)
return;
Expand Down
21 changes: 18 additions & 3 deletions src/static/js/tabular/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { csv } from "./export";
import * as model from "../model";
import { onSelectionUpdate, updateSelection, getSelection } from "../selection";
import { onSelectionUpdate, updateSelection, getSelection, getOthers } from "../selection";

let sorting = {
properties: ["entities", "0", "score"],
Expand Down Expand Up @@ -34,7 +34,22 @@ function updateSelected () {
}

function updateOthers () {

let data = getOthers().filter(node => node.type === "entity").sort(sorter),
table = document.querySelector("#tabular-others");
table.textContent = "";
for (let i = 0; i < data.length; i++) {
let row = table.insertRow(i),
node = data[i],
c;
row.insertCell(0).textContent = node.id;
row.insertCell(1).textContent = node.label;
row.insertCell(2).textContent = node.entities[0].score;
row.insertCell(3).textContent = node.entities[0].frequency;
row.insertCell(4).textContent = node.entities[0].spread;
(c = row.insertCell(5)).textContent = node.edgeType || "";
c.className = `${ node.edgeType }Item`;
row.insertCell(6).textContent = (node.parent || { label: "root" }).label || "?";
}
}

function updateAll () {
Expand All @@ -45,7 +60,7 @@ function updateAll () {
onSelectionUpdate(() => {
if (!model.uiState.tabularToggled)
return;
updateSelected();
updateAll();
});

/**
Expand Down
20 changes: 20 additions & 0 deletions src/static/scss/tabular.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ $headerHeight: 36px;

#tabular th {

@include user-select(none);
cursor: pointer;

&.sort-up:after {
content: "";
}
Expand All @@ -52,4 +55,21 @@ $headerHeight: 36px;
content: "";
}

}

#tabular td {
max-width: 150px;
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
}

#tabular-others {

opacity: 0.6;

tr:first-child td {
border-top: 1px solid black;
}

}

0 comments on commit 5061946

Please sign in to comment.