Skip to content

Commit

Permalink
Adding and removing nodes from tabular view
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Jan 22, 2017
1 parent 5061946 commit aa27f8b
Show file tree
Hide file tree
Showing 11 changed files with 80 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.12",
"version": "0.6.0",
"description": "Visualizer for iKnow entities",
"main": "gulpfile.babel.js",
"scripts": {
Expand Down
Binary file modified src/static/fonts/iknowentitybrowsericons.eot
Binary file not shown.
1 change: 1 addition & 0 deletions src/static/fonts/iknowentitybrowsericons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/static/fonts/iknowentitybrowsericons.ttf
Binary file not shown.
Binary file modified src/static/fonts/iknowentitybrowsericons.woff
Binary file not shown.
1 change: 1 addition & 0 deletions src/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<th data-prop="entities.0.spread">Spread</th>
<th data-prop="edgeType">Relation</th>
<th data-prop="parent.label">Parent</th>
<th></th>
</tr>
</thead>
<tbody id="tabular-selected">
Expand Down
2 changes: 1 addition & 1 deletion src/static/js/graph/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export function update (g = lastGraph, reset = false) {
node = nodes.selectAll(".node").data(graph.nodes, function (d) { return this._id || d.id; });
node.exit().remove();
let nodeEnter = node.enter().append("g")
.each(function (d) { this._id = d.id; })
.each(function (d) { this._id = d.id; d.element = this; })
.attr("class", d => `node${ d.id === 0 ? " root" : "" } ${ d.type || "unknown" }`)
.classed("selected", (p) => p.selected)
.call(dragger)
Expand Down
21 changes: 20 additions & 1 deletion src/static/js/tabular/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ let sorter = (a, b) => {
return a > b ? sorting.order : a === b ? 0 : -sorting.order;
};

/**
* this: node
*/
function switchSelected () {
if (!this.element)
return;
d3.select(this.element).classed("selected", this.selected = !this.selected);
updateSelection();
}

function updateSelected () {
let data = getSelection().filter(node => node.type === "entity").sort(sorter),
table = document.querySelector("#tabular-selected");
Expand All @@ -30,6 +40,10 @@ function updateSelected () {
(c = row.insertCell(5)).textContent = node.edgeType || "";
c.className = `${ node.edgeType }Item`;
row.insertCell(6).textContent = (node.parent || { label: "root" }).label || "?";
let ee = document.createElement("i");
ee.className = "icon-close";
ee.addEventListener("click", switchSelected.bind(node));
row.insertCell(7).appendChild(ee);
}
}

Expand All @@ -49,6 +63,10 @@ function updateOthers () {
(c = row.insertCell(5)).textContent = node.edgeType || "";
c.className = `${ node.edgeType }Item`;
row.insertCell(6).textContent = (node.parent || { label: "root" }).label || "?";
let ee = document.createElement("i");
ee.className = "icon-add";
ee.addEventListener("click", switchSelected.bind(node));
row.insertCell(7).appendChild(ee);
}
}

Expand Down Expand Up @@ -96,7 +114,8 @@ export function init () {
d.tabularToggled = !d.tabularToggled;
d3.select(this).classed("toggled", d.tabularToggled);
d3.select("#table").classed("active", d.tabularToggled);
updateSelection();
if (d.tabularToggled)
updateAll();
});

d3.select("#exportCSV").on("click", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/static/scss/basic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ table {
box-shadow: $defaultShadow;

td, th {
padding: 3px;
padding: 1px 2px;
}

td:not(:last-child), th:not(:last-child) {
Expand Down
3 changes: 3 additions & 0 deletions src/static/scss/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@
.icon-undo:before {
content: "\75";
}
.icon-add:before {
content: "\62";
}
52 changes: 52 additions & 0 deletions src/static/scss/tabular.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ $headerHeight: 36px;
content: "";
}

&:last-child {
border-left: none;
}

&:nth-last-child(2) {
border-right: none;
}

}

#tabular td {
Expand All @@ -64,6 +72,46 @@ $headerHeight: 36px;
text-overflow: ellipsis;
}

#tabular {

td:last-child {

width: 15px;
border-left: none;

}

tr td:last-child {
overflow: visible;
text-overflow: clip;
& i {
position: relative;
top: 2px;
font-size: 13px;
height: 13px;
display: none;
@include transition(none);
}
}

tr:hover td:last-child i {
display: inline-block;
}

td:nth-last-child(2) {
border-right: none;
}

}

#tabular-selected {

tr td:last-child {
color: red;
}

}

#tabular-others {

opacity: 0.6;
Expand All @@ -72,4 +120,8 @@ $headerHeight: 36px;
border-top: 1px solid black;
}

tr td:last-child {
color: green;
}

}

0 comments on commit aa27f8b

Please sign in to comment.