mirror of https://github.com/MISP/MISP
chg: add sightings cols and actions.
parent
01ec762045
commit
89a074cd5a
|
@ -116,12 +116,74 @@ echo $this->element('/genericElements/IndexTable/index_table', [
|
|||
],
|
||||
'quickedit' => true
|
||||
],
|
||||
[
|
||||
'name' => __('Sightings'),
|
||||
'element' => 'sightings',
|
||||
'class' => 'short',
|
||||
'data' => [
|
||||
'object' => [
|
||||
'value_path' => 'Attribute'
|
||||
],
|
||||
],
|
||||
'sightings' => $sightingsData
|
||||
],
|
||||
[
|
||||
'name' => __('Activity'),
|
||||
'element' => 'sightingsActivity',
|
||||
'class' => 'short',
|
||||
'data' => [
|
||||
'object' => [
|
||||
'value_path' => 'Attribute'
|
||||
],
|
||||
],
|
||||
'sightings' => $sightingsData
|
||||
],
|
||||
],
|
||||
'actions' => array(
|
||||
[
|
||||
'url' => $baseurl . '/shadow_attributes/edit',
|
||||
'url_params_data_paths' => array(
|
||||
'Attribute.id'
|
||||
),
|
||||
'icon' => 'comment'
|
||||
],
|
||||
[
|
||||
'onclick' => "deleteObject('shadow_attributes', 'delete', '[onclick_params_data_path]');",
|
||||
'onclick_params_data_path' => 'Attribute.id',
|
||||
'icon' => 'trash',
|
||||
'title' => __('Propose deletion'),
|
||||
'requirement' => $isSiteAdmin,
|
||||
],
|
||||
[
|
||||
'url' => $baseurl . '/attributes',
|
||||
'icon' => 'grip-lines-vertical'
|
||||
],
|
||||
[
|
||||
'url' => $baseurl . '/attributes/edit',
|
||||
'url_params_data_paths' => array(
|
||||
'Attribute.id'
|
||||
),
|
||||
'icon' => 'edit'
|
||||
],
|
||||
[
|
||||
'onclick' => "deleteObject('attributes', 'delete', '[onclick_params_data_path]/true');",
|
||||
'onclick_params_data_path' => 'Attribute.id',
|
||||
'icon' => 'trash',
|
||||
'title' => __('Permanently delete attribute'),
|
||||
'requirement' => $isSiteAdmin,
|
||||
]
|
||||
)
|
||||
]
|
||||
]);
|
||||
|
||||
echo '</div>';
|
||||
|
||||
// Generate form for adding sighting just once, generation for every attribute is surprisingly too slow
|
||||
echo $this->Form->create('Sighting', ['id' => 'SightingForm', 'url' => $baseurl . '/sightings/add/', 'style' => 'display:none;']);
|
||||
echo $this->Form->input('id', ['label' => false, 'type' => 'number']);
|
||||
echo $this->Form->input('type', ['label' => false]);
|
||||
echo $this->Form->end();
|
||||
|
||||
$class = $isSearch == 1 ? 'searchAttributes2' : 'listAttributes';
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event-collection', 'menuItem' => $class));
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
$object = Hash::extract($row, $field['data']['object']['value_path']);
|
||||
$objectId = intval($object['id']);
|
||||
$sightings = $field['sightings'];
|
||||
|
||||
$html = '';
|
||||
if (isset($sightings['data'][$objectId])) {
|
||||
$objectSighting = $sightings['data'][$objectId];
|
||||
foreach ($objectSighting as $type => $typeData) {
|
||||
$name = $type !== 'expiration' ? Inflector::pluralize($type) : $type;
|
||||
$html .= '<span class="blue bold">' . ucfirst(h($name)) . '</span><br>';
|
||||
foreach ($typeData['orgs'] as $org => $orgData) {
|
||||
$extra = $org === $me['Organisation']['name'] ? ' class="bold"' : "";
|
||||
if ($type == 'expiration') {
|
||||
$html .= '<span' . $extra . '>' . h($org) . '</span>: <span class="orange bold">' . $this->Time->time($orgData['date']) . '</span><br>';
|
||||
} else {
|
||||
$html .= '<span' . $extra . '>' . h($org) . '</span>: <span class="' . ($type === 'sighting' ? 'green' : 'red') . ' bold">' . h($orgData['count']) . ' (' . $this->Time->time($orgData['date']) . ')</span><br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$s = isset($objectSighting['sighting']['count']) ? intval($objectSighting['sighting']['count']) : 0;
|
||||
$f = isset($objectSighting['false-positive']['count']) ? intval($objectSighting['false-positive']['count']) : 0;
|
||||
$e = isset($objectSighting['expiration']['count']) ? intval($objectSighting['expiration']['count']) : 0;
|
||||
} else {
|
||||
$s = $f = $e = 0;
|
||||
}
|
||||
|
||||
if ($isAclSighting) :
|
||||
?>
|
||||
<i class="far fa-thumbs-up useCursorPointer" title="<?php echo __('Add sighting'); ?>" role="button" tabindex="0" aria-label="<?php echo __('Add sighting'); ?>" onmouseover="flexibleAddSighting(this, '0', '<?= $objectId ?>', '<?php echo h($object['event_id']); ?>', 'top');" onclick="addSighting('0', '<?= $objectId ?>', '<?php echo h($object['event_id']); ?>');"> </i>
|
||||
<i class="far fa-thumbs-down useCursorPointer" title="<?php echo __('Mark as false-positive'); ?>" role="button" tabindex="0" aria-label="<?php echo __('Mark as false-positive'); ?>" onmouseover="flexibleAddSighting(this, '1', '<?= $objectId ?>', '<?php echo h($object['event_id']); ?>', 'bottom');" onclick="addSighting('1', '<?= $objectId ?>', '<?php echo h($object['event_id']); ?>');"> </i>
|
||||
<i class="fas fa-wrench useCursorPointer sightings_advanced_add" title="<?php echo __('Advanced sightings'); ?>" role="button" tabindex="0" aria-label="<?php echo __('Advanced sightings'); ?>" data-object-id="<?= $objectId ?>" data-object-context="attribute"> </i>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
<span id="sightingCount_<?php echo $objectId; ?>" class="bold" data-placement="top" data-toggle="popover" data-trigger="hover" data-content="<?= h($html) ?>">
|
||||
(<span class="green"><?= $s ?></span>/<span class="red"><?= $f ?></span>/<span class="orange"><?= $e ?></span>)
|
||||
</span>
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
$object = Hash::extract($row, $field['data']['object']['value_path']);
|
||||
$objectId = intval($object['id']);
|
||||
$sightings = $field['sightings'];
|
||||
|
||||
if (!empty($sightings['csv'][$objectId])) {
|
||||
echo $this->element('sparkline', array('scope' => 'object', 'id' => $objectId, 'csv' => $sightings['csv'][$objectId]));
|
||||
}
|
Loading…
Reference in New Issue