mirror of https://github.com/MISP/MISP
chg: [clusters:view] Added Cluster relation index table
parent
595006f6af
commit
f06e3f18c7
|
@ -125,7 +125,8 @@ class GalaxyClusterRelationsController extends AppController
|
|||
} else {
|
||||
if (empty($errors)) {
|
||||
$this->Flash->success($message);
|
||||
$this->redirect(array('action' => 'index'));
|
||||
// $this->redirect(array('action' => 'index'));
|
||||
$this->redirect($this->referer());
|
||||
} else {
|
||||
$message .= __(' Reason: %s', json_encode($this->GalaxyClusterRelation->validationErrors, true));
|
||||
$this->Flash->error($message);
|
||||
|
@ -182,7 +183,8 @@ class GalaxyClusterRelationsController extends AppController
|
|||
} else {
|
||||
if (empty($errors)) {
|
||||
$this->Flash->success($message);
|
||||
$this->redirect(array('action' => 'index'));
|
||||
// $this->redirect(array('action' => 'index'));
|
||||
$this->redirect($this->referer());
|
||||
} else {
|
||||
$message .= __(' Reason: %s', json_encode($this->GalaxyClusterRelation->validationErrors, true));
|
||||
$this->Flash->error($message);
|
||||
|
@ -206,14 +208,14 @@ class GalaxyClusterRelationsController extends AppController
|
|||
if (empty($relation)) {
|
||||
throw new NotFoundException('Target cluster not found.');
|
||||
}
|
||||
$result = $this->GalaxyCluster->delete($id, true);
|
||||
$result = $this->GalaxyClusterRelation->delete($id, true);
|
||||
if ($result) {
|
||||
$message = 'Galaxy cluster relationship successfuly deleted.';
|
||||
if ($this->_isRest()) {
|
||||
return $this->RestResponse->saveSuccessResponse('GalaxyClusterRelation', 'delete', $id, $this->response->type());
|
||||
} else {
|
||||
$this->Flash->success($message);
|
||||
$this->redirect($this->here);
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
} else {
|
||||
$message = 'Galaxy cluster relationship could not be deleted.';
|
||||
|
@ -221,7 +223,7 @@ class GalaxyClusterRelationsController extends AppController
|
|||
return $this->RestResponse->saveFailResponse('GalaxyClusterRelation', 'delete', $id, $message, $this->response->type());
|
||||
} else {
|
||||
$this->Flash->error($message);
|
||||
$this->redirect($this->here);
|
||||
$this->redirect($this->referer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -871,6 +871,13 @@ class GalaxyClustersController extends AppController
|
|||
);
|
||||
$this->set('existingRelations', $existingRelations);
|
||||
$this->set('cluster', $cluster);
|
||||
$relations = $this->GalaxyCluster->GalaxyClusterRelation->fetchRelations($this->Auth->user(), array(
|
||||
'conditions' => array(
|
||||
'GalaxyClusterRelation.galaxy_cluster_id' => $cluster['GalaxyCluster']['id']
|
||||
),
|
||||
'contain' => array('Org', 'Orgc', 'SharingGroup', 'ReferencedGalaxyCluster')
|
||||
));
|
||||
$this->set('relations', $relations);
|
||||
$this->set('tree', $tree);
|
||||
$this->loadModel('Attribute');
|
||||
$distributionLevels = $this->Attribute->distributionLevels;
|
||||
|
|
|
@ -424,6 +424,7 @@ class GalaxyCluster extends AppModel
|
|||
);
|
||||
if ($full) {
|
||||
$params['contain'] = array(
|
||||
'Galaxy',
|
||||
'GalaxyElement',
|
||||
'GalaxyClusterRelation' => array('GalaxyClusterRelationTag' => array('Tag')),
|
||||
'Orgc',
|
||||
|
|
|
@ -98,7 +98,9 @@ echo $this->element('genericElements/assetLoader', array(
|
|||
$.ajax({
|
||||
data: $('#GalaxyClusterRelationAddForm').serialize(),
|
||||
success:function (data) {
|
||||
console.log(data);
|
||||
$.get("/galaxy_clusters/viewRelations/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
|
||||
$("#relations_container").html(data);
|
||||
});
|
||||
},
|
||||
error:function(jqXHR, textStatus, errorThrown) {
|
||||
showMessage('fail', textStatus + ": " + errorThrown);
|
||||
|
@ -118,7 +120,11 @@ echo $this->element('genericElements/assetLoader', array(
|
|||
}
|
||||
|
||||
function toggleLoadingButton(loading) {
|
||||
|
||||
if (loading) {
|
||||
$('#buttonAddRelationship > i').removeClass('fa-plus').addClass('fa-spinner fa-spin');
|
||||
} else {
|
||||
$('#buttonAddRelationship > i').removeClass('fa-spinner fa-spin').addClass('fa-plus');
|
||||
}
|
||||
}
|
||||
|
||||
function buildTree() {
|
||||
|
|
|
@ -1,8 +1,119 @@
|
|||
<button class="btn btn-inverse" onclick="toggleClusterRelations()"><span class="fa fa-eye-slash"> <?php echo __('Toggle Cluster relationships'); ?></span></button>
|
||||
<?php
|
||||
$relationTable = $this->element('/genericElements/IndexTable/index_table', array(
|
||||
'data' => array(
|
||||
'skip_pagination' => true,
|
||||
'data' => $relations,
|
||||
'fields' => array(
|
||||
array(
|
||||
'name' => __('Id'),
|
||||
'sort' => 'id',
|
||||
'class' => 'short',
|
||||
'data_path' => 'GalaxyClusterRelation.id',
|
||||
),
|
||||
array(
|
||||
'name' => __('Owner Org'),
|
||||
'class' => 'short',
|
||||
'element' => 'org',
|
||||
'data_path' => 'Org',
|
||||
'fields' => array(
|
||||
'allow_picture' => true,
|
||||
'default_org' => 'MISP'
|
||||
),
|
||||
'requirement' => $isSiteAdmin || (Configure::read('MISP.showorgalternate') && Configure::read('MISP.showorg'))
|
||||
),
|
||||
array(
|
||||
'name' => __('Creator Org'),
|
||||
'class' => 'short',
|
||||
'element' => 'org',
|
||||
'data_path' => 'Orgc',
|
||||
'fields' => array(
|
||||
'allow_picture' => true,
|
||||
'default_org' => 'MISP'
|
||||
),
|
||||
'requirement' => (Configure::read('MISP.showorg') || $isAdmin) || (Configure::read('MISP.showorgalternate') && Configure::read('MISP.showorg'))
|
||||
),
|
||||
array(
|
||||
'name' => __('Default'),
|
||||
'class' => 'short',
|
||||
'element' => 'boolean',
|
||||
'data_path' => 'default',
|
||||
),
|
||||
array(
|
||||
'name' => __('Galaxy Cluster Target'),
|
||||
'sort' => 'ReferencedGalaxyCluster.tag_name',
|
||||
'element' => 'links',
|
||||
'data_path' => 'ReferencedGalaxyCluster.tag_name',
|
||||
'url_params_data_paths' => 'ReferencedGalaxyCluster.id',
|
||||
'url' => $baseurl . '/galaxy_clusters/view'
|
||||
),
|
||||
array(
|
||||
'name' => __('Relationship Type'),
|
||||
'sort' => 'type',
|
||||
'class' => 'short',
|
||||
'data_path' => 'GalaxyClusterRelation.referenced_galaxy_cluster_type',
|
||||
),
|
||||
// array(
|
||||
// 'name' => __('Relationship Tag'),
|
||||
// 'class' => 'short',
|
||||
// 'data_path' => 'Tag',
|
||||
// 'element' => 'GalaxyClusterRelationTag'
|
||||
// ),
|
||||
array(
|
||||
'name' => __('Distribution'),
|
||||
'sort' => 'distribution',
|
||||
'data_path' => 'GalaxyClusterRelation.distribution',
|
||||
'element' => 'distribution_levels'
|
||||
),
|
||||
),
|
||||
'title' => __('Galaxy Cluster Relationships'),
|
||||
'actions' => array(
|
||||
array(
|
||||
'title' => 'Edit',
|
||||
'url' => '/galaxy_cluster_relations/edit',
|
||||
'url_params_data_paths' => array(
|
||||
'GalaxyClusterRelation.id'
|
||||
),
|
||||
'icon' => 'edit',
|
||||
'complex_requirement' => array(
|
||||
'function' => function($row, $options) {
|
||||
return ($options['me']['org_id'] == $options['datapath']['org']);
|
||||
},
|
||||
'options' => array(
|
||||
'me' => $me,
|
||||
'datapath' => array(
|
||||
'org' => 'GalaxyClusterRelation.org_id'
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
array(
|
||||
'title' => 'Delete',
|
||||
'url' => '/galaxy_cluster_relations/delete',
|
||||
'url_params_data_paths' => array(
|
||||
'GalaxyClusterRelation.id'
|
||||
),
|
||||
'postLink' => true,
|
||||
'postLinkConfirm' => __('Are you sure you want to delete the Relationship?'),
|
||||
'icon' => 'trash'
|
||||
),
|
||||
)
|
||||
)
|
||||
));
|
||||
?>
|
||||
|
||||
<form class="form-inline">
|
||||
<button type="button" class="btn btn-inverse" onclick="toggleClusterRelations()"><span class="fa fa-eye-slash"> <?php echo __('Toggle Cluster relationships'); ?></span></button>
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" onclick="toggleRelationTable()"> <?= __('Show relation table') ?>
|
||||
</label>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div id="references_div" style="position: relative; border: solid 1px;" class="statistics_attack_matrix hidden">
|
||||
<?php
|
||||
echo $this->element('GalaxyClusters/view_relations');
|
||||
?>
|
||||
<?php echo $this->element('GalaxyClusters/view_relations'); ?>
|
||||
</div>
|
||||
<div id="referencesTable_div" style="position: relative;" class="statistics_attack_matrix hidden">
|
||||
<?= $relationTable ?>
|
||||
</div>
|
||||
<script>
|
||||
function toggleClusterRelations() {
|
||||
|
@ -16,4 +127,11 @@ function toggleClusterRelations() {
|
|||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
function toggleRelationTable() {
|
||||
$('#referencesTable_div').toggle({
|
||||
effect: 'blind',
|
||||
duration: 300,
|
||||
});
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue