From d57f776d86809519f68ed288f36e1be0bc4236cc Mon Sep 17 00:00:00 2001
From: Eike Cochu <eike@cochu.com>
Date: Mon, 20 Jun 2016 17:35:53 +0200
Subject: [PATCH] updated network settings

---
 vipra-ui/app/html/entities/show.html |  2 +-
 vipra-ui/app/js/controllers.js       | 73 +++++++++++++++-------------
 2 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/vipra-ui/app/html/entities/show.html b/vipra-ui/app/html/entities/show.html
index 137258bd..a6b2fe07 100644
--- a/vipra-ui/app/html/entities/show.html
+++ b/vipra-ui/app/html/entities/show.html
@@ -31,7 +31,7 @@
             </tr>
             <tr>
               <th class="infocol">Hypernym</th>
-              <td ng-bind-template="{{ entity.isHypernym ? 'yes' : 'no' }}"></td>
+              <td ng-bind-template="{{ entity.isHypernym ? 'Yes' : 'No' }}"></td>
             </tr>
             <tr>
               <th class="infocol">Types</th>
diff --git a/vipra-ui/app/js/controllers.js b/vipra-ui/app/js/controllers.js
index d6c07107..c0f72f89 100644
--- a/vipra-ui/app/js/controllers.js
+++ b/vipra-ui/app/js/controllers.js
@@ -310,8 +310,7 @@
         edges = {};
 
       $scope.colors = {
-        articles: '#BBC9D2',
-        topics: '#DBB234',
+        articles: '#D4D8DF',
         words: '#FFFFFF'
       };
 
@@ -361,7 +360,7 @@
         words: false
       };
 
-      var newNode = function(title, type, show, dbid, color, shape, loader) {
+      var newNode = function(title, type, show, dbid, color, shape, loader, size) {
         ids[dbid] = ++id;
         return {
           id: id,
@@ -372,16 +371,15 @@
           dbid: dbid,
           shape: shape || 'dot',
           loader: loader,
-          borderWidth: 1,
+          size: size || 25,
+          borderWidth: 0,
           origColor: {
-            border: '#000',
             background: color,
             highlight: {
               background: color,
             }
           },
           color: {
-            border: '#000',
             background: color,
             highlight: {
               background: color,
@@ -398,27 +396,28 @@
 
       var newEdge = function(from, to) {
         return {
+          id: from + '-' + to,
           from: from,
           to: to,
-          selectionWidth: 1,
+          selectionWidth: 2,
           color: {
-            color: '#333',
-            highlight: '#f00'
+            color: '#aaa',
+            highlight: '#d9534f'
           }
         };
       };
 
-      var topicNode = function(topic, x, y) {
+      var topicNode = function(topic) {
         topic = topic.topic || topic;
-        return newNode(topic.name, 'topic', 'topics.show', topic.id, topic.color, 'triangle', $scope.loadTopic, x, y);
+        return newNode(topic.name, 'topic', 'topics.show', topic.id, topic.color, 'triangle', $scope.loadTopic, 35);
       };
 
-      var articleNode = function(article, x, y) {
-        return newNode(article.title, 'article', 'articles.show', article.id, $scope.colors.articles, 'square', $scope.loadArticle, x, y);
+      var articleNode = function(article) {
+        return newNode(article.title, 'article', 'articles.show', article.id, $scope.colors.articles, 'square', $scope.loadArticle);
       };
 
-      var wordNode = function(word, x, y) {
-        return newNode(word.word, 'word', 'words.show', word.word, $scope.colors.words, 'box', $scope.loadWord, x, y);
+      var wordNode = function(word) {
+        return newNode(word.word, 'word', 'words.show', word.word, $scope.colors.words, 'box', $scope.loadWord);
       };
 
       var edgeExists = function(idA, idB) {
@@ -436,32 +435,39 @@
           idA = idB;
           idB = tmp;
         }
-        edges[idA + '-' + idB] = 1;
+        var id = idA + '-' + idB;
+        edges[id] = 1;
+        return id;
       };
 
       // construct new nodes
       var constructor = function(result, nodeFunction, node, props) {
         if (result) {
           var newNodes = [],
-            newEdges = [];
+            newEdges = [],
+            newEdgeIds = [];
           for (var i = 0; i < result.length; i++) {
             var current = result[i];
             if (ids.hasOwnProperty(current.id)) {
               if (node && edgeExists(ids[current.id], node.id))
                 continue;
               if(node) {
-                newEdges.push(newEdge(ids[current.id], node.id));
-                addEdge(ids[current.id], node.id);
+                var edge = newEdge(ids[current.id], node.id);
+                newEdges.push(edge);
+                addEdge(edge.from, edge.to);
+                newEdgeIds.push(edge.id);
               }
             } else {
               if(node) {
                 if(props) {
-                  newNodes.push(nodeFunction(current, props.pointer.canvas.x, props.pointer.canvas.y));
+                  newNodes.push(nodeFunction(current));
                 } else {
                   newNodes.push(nodeFunction(current));
                 }
-                newEdges.push(newEdge(id, node.id));
-                addEdge(id, node.id);
+                var edge = newEdge(id, node.id);
+                newEdges.push(edge);
+                addEdge(edge.from, edge.to);
+                newEdgeIds.push(edge.id);
               } else {
                 newNodes.push(nodeFunction(current));
               }
@@ -471,6 +477,8 @@
             $scope.nodes.add(newNodes);
           if (newEdges.length)
             $scope.edges.add(newEdges);
+          if (newEdgeIds.length)
+            $scope.graph.selectEdges(newEdgeIds);
         }
       };
 
@@ -481,12 +489,15 @@
         var node = $scope.nodes.get(props.nodes[0]);
         if (node) {
           nodeLoader = node.loader(node, props);
-          nodeLoader.then(function() {
-            node.loaded = true;
-            $scope.nodes.update(node);
-            if($scope.searchNodes)
-              $scope.search();
-          });
+          if(nodeLoader) {
+            nodeLoader.then(function() {
+              node.loaded = true;
+              $scope.nodes.update(node);
+              if($scope.searchNodes)
+                $scope.search();
+              $scope.neighbourhoodHighlight(props);
+            });
+          }
         }
       };
 
@@ -772,11 +783,7 @@
       $scope.graph.on('doubleClick', $scope.open);
       $scope.graph.on('click', function(params) {
         lastParams = params;
-        if(params.nodes.length > 0) {
-          nodeLoader.then(function() {
-            $scope.neighbourhoodHighlight(params);
-          });
-        } else {
+        if(params.nodes.length <= 0) {
           $scope.neighbourhoodHighlight(params);
         }
       });
-- 
GitLab