mirror of https://github.com/MISP/MISP
fix: [UI] Template for group attributes into object
parent
f50cad2a41
commit
ac4d8d064f
|
@ -59,22 +59,22 @@ echo $this->Form->create('Object', array('url' => $baseurl . '/objects/groupAttr
|
||||||
<th><?php echo __('Distribution'); ?></th>
|
<th><?php echo __('Distribution'); ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody id='attributeMappingBody'>
|
<tbody id="attributeMappingBody">
|
||||||
<?php foreach ($attributes as $attribute): ?>
|
<?php foreach ($attributes as $attribute): ?>
|
||||||
<tr>
|
<tr>
|
||||||
<td id="isAttributeId"><?php echo h($attribute['Attribute']['id']); ?></td>
|
<td class="attributeId"><?= intval($attribute['Attribute']['id']); ?></td>
|
||||||
<td>
|
<td>
|
||||||
<span style="display: block;">
|
<span style="display: block;">
|
||||||
<select id="isAttributeMapping" style="margin-bottom: 5px;" onchange="updateObjectRelationDescription(this);">
|
<select class="attributeMapping" style="margin-bottom: 5px;">
|
||||||
<?php foreach ($object_relations[$attribute['Attribute']['type']] as $object_relation): ?>
|
<?php foreach ($object_relations[$attribute['Attribute']['type']] as $object_relation): ?>
|
||||||
<option value="<?php echo h($object_relation['object_relation']); ?>" title="<?php echo h($object_relation['description']); ?>"><?php echo h($object_relation['object_relation']); ?></option>
|
<option value="<?php echo h($object_relation['object_relation']); ?>" title="<?php echo h($object_relation['description']); ?>"><?php echo h($object_relation['object_relation']); ?></option>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
:: <?php echo h($attribute['Attribute']['type']); ?>
|
:: <?php echo h($attribute['Attribute']['type']); ?>
|
||||||
</span>
|
</span>
|
||||||
<i id="objectRelationDescription" class="apply_css_arrow"><?php echo h($object_relations[$attribute['Attribute']['type']][0]['description']); ?></i>
|
<i class="objectRelationDescription apply_css_arrow"><?php echo h($object_relations[$attribute['Attribute']['type']][0]['description']); ?></i>
|
||||||
</td>
|
</td>
|
||||||
<td style="min-width: 75px;"><?php echo h(date('Y-m-d', $attribute['Attribute']['timestamp'])); ?></td>
|
<td style="min-width: 75px;"><?= $this->Time->date($attribute['Attribute']['timestamp']); ?></td>
|
||||||
<td><?php echo h($attribute['Attribute']['category']); ?></td>
|
<td><?php echo h($attribute['Attribute']['category']); ?></td>
|
||||||
<td style="white-space: nowrap;"><?php echo h($attribute['Attribute']['value']); ?></td>
|
<td style="white-space: nowrap;"><?php echo h($attribute['Attribute']['value']); ?></td>
|
||||||
<td><?php echo h($distributionLevels[$attribute['Attribute']['distribution']]); ?></td>
|
<td><?php echo h($distributionLevels[$attribute['Attribute']['distribution']]); ?></td>
|
||||||
|
@ -126,7 +126,7 @@ echo $this->Form->create('Object', array('url' => $baseurl . '/objects/groupAttr
|
||||||
<button class="btn btn-primary" onclick="submitMergeAttributeIntoObjectForm(this);"><?php echo __('Merge above Attributes into an Object'); ?></button>
|
<button class="btn btn-primary" onclick="submitMergeAttributeIntoObjectForm(this);"><?php echo __('Merge above Attributes into an Object'); ?></button>
|
||||||
</div>
|
</div>
|
||||||
<span class="red bold" data-original-title="" title="">
|
<span class="red bold" data-original-title="" title="">
|
||||||
<?php echo sprintf(__('Selected Attributes will be %s deleted'), '<strong style="font-size: medium">' . ($hard_delete_attribute ? __('hard') : __('soft')) . '</strong>'); ?>
|
<?php echo __('Selected Attributes will be %s deleted', '<strong style="font-size: medium">' . ($hard_delete_attribute ? __('hard') : __('soft')) . '</strong>'); ?>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -135,25 +135,31 @@ $(".Object_distribution_select").change(function() {
|
||||||
checkAndEnable($(this).parent().find('.Object_sharing_group_id_select'), $(this).val() == 4);
|
checkAndEnable($(this).parent().find('.Object_sharing_group_id_select'), $(this).val() == 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(".attributeMapping").change(function() {
|
||||||
|
var $select = $(this);
|
||||||
|
var text = $select.find(":selected").attr('title');
|
||||||
|
$select.parent().parent().find('.objectRelationDescription').text(text);
|
||||||
|
});
|
||||||
|
|
||||||
function submitMergeAttributeIntoObjectForm(btn) {
|
function submitMergeAttributeIntoObjectForm(btn) {
|
||||||
var $btn = $(btn);
|
var $btn = $(btn);
|
||||||
var $form = $('#ObjectGroupAttributesIntoObjectForm');
|
var $form = $('#ObjectGroupAttributesIntoObjectForm');
|
||||||
var attribute_mapping = {};
|
var attribute_mapping = {};
|
||||||
$('#attributeMappingBody').find('tr').each(function() {
|
$('#attributeMappingBody').find('tr').each(function() {
|
||||||
var $tr = $(this);
|
var $tr = $(this);
|
||||||
var attr_id = $tr.find('#isAttributeId').text();
|
var attr_id = $tr.find('.attributeId').text();
|
||||||
var attr_mapping = $tr.find('#isAttributeMapping').val();
|
var attr_mapping = $tr.find('.attributeMapping').val();
|
||||||
attribute_mapping[attr_id] = attr_mapping;
|
attribute_mapping[attr_id] = attr_mapping;
|
||||||
});
|
});
|
||||||
$('#ObjectSelectedObjectRelationMapping').val(JSON.stringify(attribute_mapping));
|
$('#ObjectSelectedObjectRelationMapping').val(JSON.stringify(attribute_mapping));
|
||||||
var btn_text_backup = '';
|
var btn_text_backup = '';
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: $form.serialize(),
|
data: $form.serialize(),
|
||||||
beforeSend: function (XMLHttpRequest) {
|
beforeSend: function () {
|
||||||
btn_text_backup = $btn.text();
|
btn_text_backup = $btn.text();
|
||||||
$btn.html('<it class="fa fa-spinner fa-spin"></it>');
|
$btn.html('<it class="fa fa-spinner fa-spin"></it>');
|
||||||
},
|
},
|
||||||
success:function (data, textStatus) {
|
success: function (data) {
|
||||||
if (data.errors !== undefined) {
|
if (data.errors !== undefined) {
|
||||||
showMessage('fail', responseArray.errors);
|
showMessage('fail', responseArray.errors);
|
||||||
$btn.text(btn_text_backup);
|
$btn.text(btn_text_backup);
|
||||||
|
@ -162,18 +168,12 @@ function submitMergeAttributeIntoObjectForm(btn) {
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error:function() {
|
error: function() {
|
||||||
showMessage('fail', 'Could not merge Attributes into an Object.');
|
showMessage('fail', 'Could not merge Attributes into an Object.');
|
||||||
showObjectProposition();
|
showObjectProposition();
|
||||||
},
|
},
|
||||||
type:"post",
|
type: "post",
|
||||||
url: $form.attr('action')
|
url: $form.attr('action')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateObjectRelationDescription(changed) {
|
|
||||||
var $select = $(changed);
|
|
||||||
var text = $select.find(":selected").attr('title');
|
|
||||||
$select.parent().parent().find('#objectRelationDescription').text(text);
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue