mirror of https://github.com/MISP/MISP
chg: [clusterRelations:add] Added target cluster and tags picker
parent
b54edc0c3a
commit
cef90e854e
|
@ -358,7 +358,7 @@ class GalaxiesController extends AppController
|
|||
$local = !empty($this->params['named']['local']) ? $this->params['named']['local'] : '0';
|
||||
$data = $this->Galaxy->GalaxyCluster->fetchGalaxyClusters($this->Auth->user(), array(
|
||||
'conditions' => $conditions,
|
||||
'fields' => array('value', 'description', 'source', 'type', 'id'),
|
||||
'fields' => array('value', 'description', 'source', 'type', 'id', 'uuid'),
|
||||
'order' => array('value asc'),
|
||||
), false);
|
||||
$clusters = array();
|
||||
|
@ -411,6 +411,9 @@ class GalaxiesController extends AppController
|
|||
'template' => array(
|
||||
'name' => $name,
|
||||
'infoExtra' => $cluster['description'],
|
||||
),
|
||||
'additionalData' => array(
|
||||
'uuid' => $cluster['uuid']
|
||||
)
|
||||
);
|
||||
if ($cluster['synonyms_string'] !== '') {
|
||||
|
@ -427,7 +430,7 @@ class GalaxiesController extends AppController
|
|||
$this->set('items', $items);
|
||||
$this->set('options', array( // set chosen (select picker) options
|
||||
'functionName' => $onClickForm,
|
||||
'multiple' => '-1',
|
||||
'multiple' => $target_type == 'galaxyClusterRelation' ? 0 : '-1',
|
||||
'select_options' => array(
|
||||
'additionalData' => array(
|
||||
'target_id' => $target_id,
|
||||
|
|
|
@ -784,6 +784,9 @@ class TagsController extends AppController
|
|||
)
|
||||
),
|
||||
'infoExtra' => $expanded[$tag['id']]
|
||||
),
|
||||
'additionalData' => array(
|
||||
'tag_name' => $tagName
|
||||
)
|
||||
);
|
||||
if ($taxonomy_id === 'collections') {
|
||||
|
|
|
@ -194,12 +194,21 @@ function submitFunction(clicked, callback) {
|
|||
} else {
|
||||
additionalData = {};
|
||||
}
|
||||
additionalDataOption = options_additionalData[$select.attr('id')][selected];
|
||||
additionalDataOption = options_additionalData[$select.attr('id')];
|
||||
if (additionalData !== undefined) {
|
||||
$.extend(additionalData, additionalDataOption);
|
||||
additionalData['itemOptions'] = additionalDataOption;
|
||||
// check needed if the function name is not defined in the controller but in the JS
|
||||
var dismissId = $clicked.closest('.popover[data-dismissid]').data('dismissid');
|
||||
var callingButton = $('button[data-dismissid="' + dismissId + '"]');
|
||||
if (callingButton.data('popover-no-submit') && callingButton.data('popover-callback-function') !== undefined) {
|
||||
callbackFunction = callingButton.data('popover-callback-function');
|
||||
execAndClose(clicked);
|
||||
callbackFunction(selected, additionalData);
|
||||
} else {
|
||||
execAndClose(clicked);
|
||||
callback(selected, additionalData);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
'field' => 'referenced_galaxy_cluster_uuid',
|
||||
'label' => __('Target UUID'),
|
||||
'type' => 'text',
|
||||
'stayInLine' => 1
|
||||
),
|
||||
sprintf('<button id="btnPickTarget" type="button" style="margin-top: 25px;">%s</button>', __('Pick target cluster')),
|
||||
array(
|
||||
'field' => 'referenced_galaxy_cluster_type',
|
||||
'label' => __('Relationship Type'),
|
||||
|
@ -35,8 +37,10 @@
|
|||
'field' => 'tags',
|
||||
'label' => __('Tag list'),
|
||||
'type' => 'textarea',
|
||||
'placeholder' => 'estimative-language:likelihood-probability="very-likely", false-positive:risk="low"'
|
||||
'placeholder' => 'estimative-language:likelihood-probability="very-likely", false-positive:risk="low"',
|
||||
'stayInLine' => 1
|
||||
),
|
||||
sprintf('<button id="btnPickTag" type="button" style="margin-top: 25px;">%s</button>', __('Pick tags')),
|
||||
),
|
||||
'submit' => array(
|
||||
'ajaxSubmit' => ''
|
||||
|
@ -57,6 +61,31 @@
|
|||
$(this).attr('data-toggle', '')
|
||||
.html(syntaxHighlightJson($(this).text().trim()));
|
||||
});
|
||||
$('#btnPickTarget').click(function() {
|
||||
$(this).data('popover-no-submit', true);
|
||||
$(this).data('popover-callback-function', setTargetUUIDAfterSelect);
|
||||
var target_id = 0;
|
||||
var target_type = 'galaxyClusterRelation';
|
||||
popoverPopup(this, target_id + '/' + target_type, 'galaxies', 'selectGalaxyNamespace');
|
||||
});
|
||||
$('#btnPickTag').click(function() {
|
||||
$(this).data('popover-no-submit', true);
|
||||
$(this).data('popover-callback-function', setTagsAfterSelect);
|
||||
var target_id = 0;
|
||||
var target_type = 'galaxyClusterRelation';
|
||||
popoverPopup(this, target_id + '/' + target_type, 'tags', 'selectTaxonomy')
|
||||
});
|
||||
});
|
||||
function setTargetUUIDAfterSelect(selected, additionalData){
|
||||
selectedUUID = additionalData.itemOptions[selected].uuid;
|
||||
$('#GalaxyClusterRelationReferencedGalaxyClusterUuid').val(selectedUUID);
|
||||
}
|
||||
function setTagsAfterSelect(selected, additionalData){
|
||||
selectedTags = [];
|
||||
selected.forEach(function(selection) {
|
||||
selectedTags.push(additionalData.itemOptions[selection].tag_name);
|
||||
});
|
||||
$('#GalaxyClusterRelationTags').val(selectedTags.join(', '));
|
||||
}
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer(); // Write cached scripts
|
|
@ -4138,7 +4138,6 @@ function addGalaxyListener(id) {
|
|||
var target_type = $(id).data('target-type');
|
||||
var target_id = $(id).data('target-id');
|
||||
var local = $(id).data('local');
|
||||
console.log(local);
|
||||
if (local) {
|
||||
local = 1;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue