From 3acf2bd4cf6b9cb6ebd4d53d638ed3c4e8de209d Mon Sep 17 00:00:00 2001 From: mokaddem Date: Mon, 11 May 2020 15:13:38 +0200 Subject: [PATCH] chg: [clusterRelations:networkGraphs] Improved UI by highlighting root nodes --- app/Controller/EventsController.php | 3 ++- app/Controller/GalaxiesController.php | 3 ++- app/Model/GalaxyClusterRelation.php | 8 +++++++- .../Elements/GalaxyClusters/relations_graph.ctp | 14 ++++++++++++-- .../Elements/GalaxyClusters/view_relations.ctp | 10 +++++++++- 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/Controller/EventsController.php b/app/Controller/EventsController.php index f1086ef10..c71fb3adb 100644 --- a/app/Controller/EventsController.php +++ b/app/Controller/EventsController.php @@ -4803,9 +4803,10 @@ class EventsController extends AppController } } } + $rootNodeIds = $clusterIds; $this->loadModel('GalaxyCluster'); $clusters = $this->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(), array('conditions' => array('GalaxyCluster.id' => $clusterIds)), $full=true); - $relations = $this->GalaxyCluster->GalaxyClusterRelation->generateRelationsGraph($this->Auth->user(), $clusters, $keepNotLinkedClusters=true); + $relations = $this->GalaxyCluster->GalaxyClusterRelation->generateRelationsGraph($this->Auth->user(), $clusters, $rootNodeIds=$rootNodeIds, $keepNotLinkedClusters=true); if ($this->_isRest()) { return $this->RestResponse->viewData($relations, $this->response->type()); } diff --git a/app/Controller/GalaxiesController.php b/app/Controller/GalaxiesController.php index 4d95522a2..0bd93d486 100644 --- a/app/Controller/GalaxiesController.php +++ b/app/Controller/GalaxiesController.php @@ -536,7 +536,8 @@ class GalaxiesController extends AppController 'recursive' => -1, 'conditions' => array('Galaxy.id' => $galaxyId) )); - $relations = $this->Galaxy->GalaxyCluster->GalaxyClusterRelation->generateRelationsGraph($this->Auth->user(), $clusters); // moved this to Lib/Tool + $rootNodeIds = Hash::combine($clusters, '{n}.GalaxyCluster.id', '{n}.GalaxyCluster.id'); + $relations = $this->Galaxy->GalaxyCluster->GalaxyClusterRelation->generateRelationsGraph($this->Auth->user(), $clusters, $rootNodeIds=$rootNodeIds); // moved this to Lib/Tool if ($this->_isRest()) { return $this->RestResponse->viewData($relations, $this->response->type()); } diff --git a/app/Model/GalaxyClusterRelation.php b/app/Model/GalaxyClusterRelation.php index 52753d82d..c6596a353 100644 --- a/app/Model/GalaxyClusterRelation.php +++ b/app/Model/GalaxyClusterRelation.php @@ -275,7 +275,7 @@ class GalaxyClusterRelation extends AppModel return $errors; } - function generateRelationsGraph($user, $clusters, $keepNotLinkedClusters=false) + function generateRelationsGraph($user, $clusters, $rootNodeIds=array(), $keepNotLinkedClusters=false) { $nodes = array(); $links = array(); @@ -301,6 +301,9 @@ class GalaxyClusterRelation extends AppModel $nodes[$referencedClusterId]['group'] = $referencedCluster['GalaxyCluster']['type']; $nodes[$relation['galaxy_cluster_id']] = $cluster['GalaxyCluster']; $nodes[$relation['galaxy_cluster_id']]['group'] = $cluster['GalaxyCluster']['type']; + if (isset($rootNodeIds[$relation['galaxy_cluster_id']])) { + $nodes[$relation['galaxy_cluster_id']]['isRoot'] = true; + } if (true) { $links[] = array( 'source' => $relation['galaxy_cluster_id'], @@ -323,6 +326,9 @@ class GalaxyClusterRelation extends AppModel if (!isset($nodes[$cluster['GalaxyCluster']['id']])) { $nodes[$cluster['GalaxyCluster']['id']] = $cluster['GalaxyCluster']; $nodes[$cluster['GalaxyCluster']['id']]['group'] = $cluster['GalaxyCluster']['type']; + if (isset($rootNodeIds[$cluster['GalaxyCluster']['id']])) { + $nodes[$cluster['GalaxyCluster']['id']]['isRoot'] = true; + } } } } diff --git a/app/View/Elements/GalaxyClusters/relations_graph.ctp b/app/View/Elements/GalaxyClusters/relations_graph.ctp index 9b03fdce5..3bf246b1e 100644 --- a/app/View/Elements/GalaxyClusters/relations_graph.ctp +++ b/app/View/Elements/GalaxyClusters/relations_graph.ctp @@ -10,6 +10,9 @@ echo $this->element('genericElements/assetLoader', array( ?>