Commit ce56069d authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

WebUI component:

- Permanently show labels of nodes in topology
parent a433e23e
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ const svg = d3.select('#topology')
        ;

// svg objects
var link, node, optical_link;
var link, node, optical_link, labels;

// values for all forces
forceProperties = {
@@ -115,7 +115,18 @@ d3.json("{{ url_for('main.topology') }}", function(data) {
        .call(d3.drag().on("start", dragstarted).on("drag", dragged).on("end", dragended));

    // node tooltip
    node.append("title").text(function(n) { return n.name; });
    //node.append("title").text(function(n) { return n.name; });
    // persistent node labels
    labels = svg.append("g").attr("class", "labels")
        .selectAll("text")
        .data(data.devices)
        .enter()
        .append("text")
        .text(function(d) { return d.name; })
        .attr("font-family", "sans-serif")
        .attr("font-size", 12)
        .attr("text-anchor", "middle")
        .attr("pointer-events", "none");
    // link tooltip
    link.append("title").text(function(l) { return l.name; });
    // optical link tooltip
@@ -183,6 +194,11 @@ function ticked() {
    node
        .attr('x', function(d) { return d.x-icon_width/2; })
        .attr('y', function(d) { return d.y-icon_height/2; });
    if (labels) {
        labels
            .attr('x', function(d) { return d.x; })
            .attr('y', function(d) { return d.y + icon_height/2 + 12; });
    }
}

/******************** UI EVENTS ********************/