mirror of https://github.com/MISP/MISP
new: Automatic cateory switching based on currently selected types for the freetext import/module triage screen
parent
12604debd5
commit
23adc990b9
|
@ -3353,6 +3353,10 @@ class EventsController extends AppController {
|
||||||
$this->set('typeList', array_keys($this->Event->Attribute->typeDefinitions));
|
$this->set('typeList', array_keys($this->Event->Attribute->typeDefinitions));
|
||||||
$this->set('defaultCategories', $this->Event->Attribute->defaultCategories);
|
$this->set('defaultCategories', $this->Event->Attribute->defaultCategories);
|
||||||
$this->set('typeCategoryMapping', $typeCategoryMapping);
|
$this->set('typeCategoryMapping', $typeCategoryMapping);
|
||||||
|
foreach ($typeCategoryMapping as $k => $v) {
|
||||||
|
$typeCategoryMapping[$k] = array_values($v);
|
||||||
|
}
|
||||||
|
$this->set('mapping', $typeCategoryMapping);
|
||||||
$this->set('resultArray', $resultArray);
|
$this->set('resultArray', $resultArray);
|
||||||
$this->set('importComment', '');
|
$this->set('importComment', '');
|
||||||
$this->set('title', 'Freetext Import Results');
|
$this->set('title', 'Freetext Import Results');
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<td class="short context hidden">
|
<td class="short context hidden">
|
||||||
<?php echo h($object['uuid']); ?>
|
<?php echo h($object['uuid']); ?>
|
||||||
</td>
|
</td>
|
||||||
<td colspan="<?php echo $fieldCount; ?>" style="font-weight:bold;text-align:left;width:100%;">DELETE</td>
|
<td colspan="<?php echo $fieldCount+2; ?>" style="font-weight:bold;text-align:left;width:100%;">DELETE</td>
|
||||||
<td class="short action-links">
|
<td class="short action-links">
|
||||||
<?php
|
<?php
|
||||||
if (($event['Orgc']['id'] == $me['org_id'] && $mayModify) || $isSiteAdmin) {
|
if (($event['Orgc']['id'] == $me['org_id'] && $mayModify) || $isSiteAdmin) {
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<select id="<?php echo 'Attribute' . $k . 'Category'; ?>" style='padding:0px;height:20px;margin-bottom:0px;'>
|
<select id="<?php echo 'Attribute' . $k . 'Category'; ?>" style='padding:0px;height:20px;margin-bottom:0px;' class="categoryToggle">
|
||||||
<?php
|
<?php
|
||||||
foreach ($typeCategoryMapping[$item['default_type']] as $category) {
|
foreach ($typeCategoryMapping[$item['default_type']] as $category) {
|
||||||
if (isset($item['categories']) && !in_array($category, $item['categories'])) {
|
if (isset($item['categories']) && !in_array($category, $item['categories'])) {
|
||||||
|
@ -231,8 +231,34 @@
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
var options = <?php echo json_encode($optionsRearranged);?>;
|
var options = <?php echo json_encode($optionsRearranged);?>;
|
||||||
|
var typeCategoryMapping = <?php echo json_encode($typeCategoryMapping); ?>;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
popoverStartup();
|
popoverStartup();
|
||||||
|
$('.typeToggle').on('change', function() {
|
||||||
|
var currentId = $(this).attr('id');
|
||||||
|
var selected = $(this).val();
|
||||||
|
currentId = currentId.replace('Type', 'Category');
|
||||||
|
var currentOptions = typeCategoryMapping[selected];
|
||||||
|
/*
|
||||||
|
// Coming soon - restrict further if a list of categories is passed by the modules / freetext import tool
|
||||||
|
if ($('#' + currentId)).data('category-restrictions') {
|
||||||
|
var category_restrictions = $('#' + currentId)).data('category-restrictions');
|
||||||
|
currentOptions.forEach(function(category) {
|
||||||
|
var found = False;
|
||||||
|
category_restrictions.forEach(function(restricted_category) {
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
currentOptions.forEach() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
$('#' + currentId).empty();
|
||||||
|
for (var category in currentOptions) {
|
||||||
|
$('#' + currentId).append($("<option></option>").attr("value", category).text(category));
|
||||||
|
}
|
||||||
|
});
|
||||||
<?php
|
<?php
|
||||||
if (!empty($optionsRearranged)):
|
if (!empty($optionsRearranged)):
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue