mirror of https://github.com/MISP/MISP
chg: [galaxies:view_relations] Both inbound and outbound relations can be viewed
parent
52d6a2dc02
commit
09b1534302
|
@ -646,7 +646,7 @@ class GalaxiesController extends AppController
|
|||
$this->set('galaxy_id', $galaxyId);
|
||||
}
|
||||
|
||||
public function relationsGraph($galaxyId)
|
||||
public function relationsGraph($galaxyId, $includeInbound=0)
|
||||
{
|
||||
$clusters = $this->Galaxy->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(), array('conditions' => array('GalaxyCluster.galaxy_id' => $galaxyId)), $full=true);
|
||||
if (empty($clusters)) {
|
||||
|
@ -658,13 +658,14 @@ class GalaxiesController extends AppController
|
|||
));
|
||||
App::uses('ClusterRelationsGraphTool', 'Tools');
|
||||
$grapher = new ClusterRelationsGraphTool($this->Auth->user(), $this->Galaxy->GalaxyCluster);
|
||||
$relations = $grapher->getNetwork($clusters);
|
||||
$relations = $grapher->getNetwork($clusters, $includeInbound, $includeInbound);
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->viewData($relations, $this->response->type());
|
||||
}
|
||||
$this->set('relations', $relations);
|
||||
$this->set('galaxy', $galaxy);
|
||||
$this->set('galaxy_id', $galaxyId);
|
||||
$this->set('includeInbound', $includeInbound);
|
||||
$this->loadModel('Attribute');
|
||||
$distributionLevels = $this->Attribute->distributionLevels;
|
||||
$this->set('distributionLevels', $distributionLevels);
|
||||
|
|
|
@ -74,7 +74,7 @@
|
|||
'conditions' => array(
|
||||
'referenced_galaxy_cluster_uuid' => $cluster['GalaxyCluster']['uuid']
|
||||
),
|
||||
'contain' => array('SharingGroup'),
|
||||
'contain' => array('SharingGroup', 'GalaxyClusterRelationTag' => 'Tag'),
|
||||
));
|
||||
if (!empty($referencingRelations)) {
|
||||
foreach ($referencingRelations as $relation) {
|
||||
|
@ -92,9 +92,9 @@
|
|||
$nodes[$referencingClusterUuid]['group'] = $referencingCluster['GalaxyCluster']['type'];
|
||||
$links[] = array(
|
||||
'source' => $referencingClusterUuid,
|
||||
'target' => $relation['GalaxyClusterRelation']['referenced_galaxy_cluster_uuid'],
|
||||
'target' => $relation['GalaxyClusterRelation']['referenced_galaxy_cluster_uuid'],
|
||||
'type' => $relation['GalaxyClusterRelation']['referenced_galaxy_cluster_type'],
|
||||
'tag' => isset($relation['Tag']) ? $relation['Tag'] : array(),
|
||||
'tag' => isset($relation['GalaxyClusterRelationTag']) ? Hash::extract($relation, '{n}.Tag') : array(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<div style="margin-bottom: 10px; position: relative">
|
||||
<label>
|
||||
<input type="checkbox" id="checkbox-include-inbound" <?= !empty($includeInbound) ? "checked=\"checked\"" : "" ?>></input>
|
||||
<?= __('Include inbound relations from other galaxies') ?>
|
||||
</label>
|
||||
<div id="graphContainer" style="height: 70vh; border: 1px solid #ddd; "></div>
|
||||
<div id="tooltipContainer" style="max-height: 450px; min-width: 200px; max-width:300px; position: absolute; top: 10px; right: 10px; border: 1px solid #999; border-radius: 3px; background-color: #f5f5f5ee; overflow: auto;"></div>
|
||||
</div>
|
||||
|
@ -45,8 +49,20 @@ $(document).ready( function() {
|
|||
.text("<?= __('This galaxy does not have any relationships.') ?>")
|
||||
);
|
||||
}
|
||||
$('#checkbox-include-inbound').click(function() {
|
||||
var $container = $(this).parent().parent().parent();
|
||||
var checked = $(this).prop('checked');
|
||||
reloadGraph(checked);
|
||||
})
|
||||
});
|
||||
|
||||
function reloadGraph(checked) {
|
||||
var uri = '<?= $baseurl ?>/galaxies/relationsGraph/<?= h($galaxy['Galaxy']['id']) ?>/' + (checked ? '1' : '0')
|
||||
$.get(uri, function(data) {
|
||||
$("#clusters_content").html(data);
|
||||
})
|
||||
}
|
||||
|
||||
function initGraph() {
|
||||
var groupDomain = {};
|
||||
graph.links.forEach(function(link) {
|
||||
|
|
Loading…
Reference in New Issue