Merge pull request #6781 from JakubOnderka/another-ui-fixes

Another UI fixes
pull/6782/head
Jakub Onderka 2020-12-20 01:07:34 +01:00 committed by GitHub
commit 0ec3853b18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 80 additions and 106 deletions

View File

@ -19,24 +19,25 @@ class ObjectTemplatesController extends AppController
'recursive' => -1
);
public function objectMetaChoice($event_id) {
public function objectMetaChoice($event_id)
{
$metas = $this->ObjectTemplate->find('list', array(
'recursive' => -1,
'conditions' => array('ObjectTemplate.active' => 1),
'fields' => array('meta-category', 'meta-category'),
'fields' => array('meta-category'),
'group' => array('ObjectTemplate.meta-category'),
'order' => array('ObjectTemplate.meta-category asc')
));
$items = array();
$items[] = array(
$eventId = h($event_id);
$items = [[
'name' => __('All Objects'),
'value' => $this->baseurl . "/ObjectTemplates/objectChoice/" . h($event_id) . "/" . "0"
);
foreach($metas as $meta) {
'value' => $this->baseurl . "/ObjectTemplates/objectChoice/$eventId/0"
]];
foreach ($metas as $meta) {
$items[] = array(
'name' => $meta,
'value' => $this->baseurl . "/ObjectTemplates/objectChoice/" . h($event_id) . "/" . h($meta)
'value' => $this->baseurl . "/ObjectTemplates/objectChoice/$eventId/" . h($meta)
);
}

View File

@ -2,7 +2,7 @@
<div id="shortcutsListContainer" class="<?php echo $debugMode ? 'hidden': ''; ?>">
<div id="triangle"></div>
<div id="shortcutsList">
<span> <?php echo __('Keyboard shortcuts for this page'); ?>:</span><br />
<span> <?php echo __('Keyboard shortcuts for this page'); ?>:</span><br>
<div id="shortcuts"><?php echo __('none'); ?></div>
</div>
</div>
@ -12,23 +12,23 @@
<?php
$gpgpath = ROOT.DS.APP_DIR.DS.WEBROOT_DIR.DS.'gpg.asc';
if (Configure::read("MISP.download_gpg_from_homedir")) { ?>
<span>Download: <?= $this->Html->link(__('GnuPG key'), array('controller' => 'users', 'action' => 'getGpgPublicKey')) ?></span>
<?php } else if (file_exists($gpgpath) && (is_file($gpgpath) || is_link($gpgpath))){ ?>
<span>Download: <?php echo $this->Html->link(__('GnuPG key'), $this->webroot.'gpg.asc');?></span>
<span>Download: <?= $this->Html->link(__('PGP public key'), array('controller' => 'users', 'action' => 'getGpgPublicKey')) ?></span>
<?php } else if (file_exists($gpgpath) && (is_file($gpgpath) || is_link($gpgpath))) { ?>
<span>Download: <?php echo $this->Html->link(__('PGP public key'), $this->webroot.'gpg.asc');?></span>
<?php } else { ?>
<span><?php echo __('Could not locate the GnuPG public key.');?></span>
<span><?php echo __('Could not locate the PGP public key.');?></span>
<?php }
if (Configure::read('SMIME.enabled')):
$smimepath = ROOT.DS.APP_DIR.DS.WEBROOT_DIR.DS.'public_certificate.pem';
if (file_exists($smimepath) && (is_file($smimepath) || is_link($gpgpath))){ ?>
<span>Download: <?php echo $this->Html->link('SMIME certificate', $this->webroot.'public_certificate.pem');?></span>
if (file_exists($smimepath) && (is_file($smimepath) || is_link($gpgpath))) { ?>
<span>Download: <?php echo $this->Html->link(__('S/MIME certificate'), $this->webroot.'public_certificate.pem');?></span>
<?php } else { ?>
<span><?php echo __('Could not locate SMIME certificate.');?></span>
<span><?php echo __('Could not locate S/MIME certificate.');?></span>
<?php }
endif;
?>
</div>
<div class = "footerText footerCenterText">
<div class="footerText footerCenterText">
<span><?php echo h(Configure::read('MISP.footermidleft')); ?> Powered by <a href="https://github.com/MISP/MISP">MISP <?php if (isset($me['id'])) echo h($mispVersionFull);?></a> <?php echo h(Configure::read('MISP.footermidright')); ?> - <?php echo date("Y-m-d H:i:s"); ?></span>
</div>
<div class="pull-right" style="position:relative;padding-top:9px;z-index:2;">

View File

@ -113,11 +113,12 @@ function redrawChosenWithTemplate($select, $chosenContainer, eventType) {
} else {
$chosenContainer.find('.generic-picker-wrapper-warning-text').hide(0)
var $matches;
if (eventType == 'chosen:picked' || eventType == 'change') {
if (eventType === 'chosen:picked' || eventType === 'change') {
$matches = $chosenContainer.find('.chosen-single > span, .search-choice > span');
} else {
$matches = $chosenContainer.find('.chosen-results .active-result');
}
var templates = options_templates[$select.attr('id')];
$matches.each(function() {
var $item = $(this);
var index = $item.data('option-array-index');
@ -131,8 +132,7 @@ function redrawChosenWithTemplate($select, $chosenContainer, eventType) {
return temp === text;
});
}
var template = options_templates[$select.attr('id')][$option.val()];
var res = "";
var template = templates[$option.val()];
if (template !== undefined && template !== '') {
$item.html(template);
}
@ -228,7 +228,7 @@ function submitFunction(clicked, callback) {
$flag_addPills = false;
?>
<?php if ($use_select): ?>
<select id="<?php echo $select_id; ?>" style="height: 100px; margin-bottom: 0px;" <?php echo h($this->GenericPicker->add_select_params($defaults)); ?>>
<select id="<?php echo $select_id; ?>" autofocus style="height: 100px; margin-bottom: 0px;" <?php echo h($this->GenericPicker->add_select_params($defaults)); ?>>
<option></option>
<?php
foreach ($items as $k => $param) {
@ -270,14 +270,15 @@ function submitFunction(clicked, callback) {
<?php endif; ?>
<script>
$(document).ready(function() {
$(function() {
setupChosen("<?php echo $select_id; ?>", <?php echo ($defaults['flag_redraw_chosen'] === true ? 'true' : 'false') ?>);
$('#<?= $select_id; ?>').chosen().filter('[autofocus]').trigger('chosen:activate');
});
</script>
<?php elseif (count($items) > 0): ?>
<ul class="nav nav-pills">
<select id="<?php echo $select_id; ?>" style="display: none;" <?php echo h($this->GenericPicker->add_select_params($defaults)); ?>></select>
<select id="<?php echo $select_id; ?>" autofocus style="display: none;" <?php echo h($this->GenericPicker->add_select_params($defaults)); ?>></select>
<?php
foreach ($items as $k => $param) {
echo $this->GenericPicker->add_pill($param, $defaults);

View File

@ -36,11 +36,8 @@
*
*
*/
?>
<?php
echo $this->Html->script('attack_matrix');
echo $this->Html->css('attack_matrix');
echo $this->Html->script('attack_matrix');
echo $this->Html->css('attack_matrix');
?>
<?php
$clusetersNamesMapping = array(); // used to map name with id for the chosen select
@ -88,7 +85,7 @@ foreach($tabs as $tabName => $column):
<span id="matrix-heatmap-maxval"><?php echo h($maxScore); ?></span>
</div>
<?php endif; ?>
<label style="display: inline-block; margin-left: 30px;"><input type="checkbox" id="checkbox_attackMatrix_showAll" checked><span class="fa fa-filter"><?php echo __('Show all');?></span></label>
<label style="display: inline-block; margin-left: 30px;"><input type="checkbox" id="checkbox_attackMatrix_showAll" checked><i class="fa fa-filter"></i><?= __('Show all') ?></label>
</div>
<?php if (isset($eventId)): ?>
@ -102,7 +99,6 @@ foreach($tabs as $tabName => $column):
empty($local) ? '0' : '1'
);
echo $this->Form->create('Galaxy', array('url' => $url, 'style' => 'margin:0px;'));
echo $this->Form->input('target_ids', array('type' => 'text'));
echo $this->Form->end();

View File

@ -487,10 +487,10 @@
<button class="btn btn-inverse toggle qet galaxy-toggle-button" id="eventtimeline_toggle" data-toggle-type="eventtimeline" onclick="enable_timeline();">
<span class="icon-plus icon-white" title="<?php echo __('Toggle Event timeline');?>" role="button" tabindex="0" aria-label="<?php echo __('Toggle Event timeline');?>" style="vertical-align:top;"></span><?php echo __('Event timeline');?>
</button>
<button class="btn btn-inverse toggle qet galaxy-toggle-button" id="correlationgraph_toggle" data-toggle-type="correlationgraph" onclick="enable_correlation_graph();">
<button class="btn btn-inverse toggle qet galaxy-toggle-button" id="correlationgraph_toggle" data-toggle-type="correlationgraph" data-load-url="<?= $baseurl ?>/events/viewGraph/<?= h($event['Event']['id']) ?>">
<span class="icon-plus icon-white" title="<?php echo __('Toggle Correlation graph');?>" role="button" tabindex="0" aria-label="<?php echo __('Toggle Correlation graph');?>" style="vertical-align:top;"></span><?php echo __('Correlation graph');?>
</button>
<button class="btn btn-inverse toggle qet galaxy-toggle-button" id="attackmatrix_toggle" data-toggle-type="attackmatrix" onclick="enable_attack_matrix();">
<button class="btn btn-inverse toggle qet galaxy-toggle-button" id="attackmatrix_toggle" data-toggle-type="attackmatrix" data-load-url="<?= $baseurl; ?>/events/viewGalaxyMatrix/<?= h($event['Event']['id']) ?>/mitre-attack/event/1">
<span class="icon-plus icon-white" title="<?php echo __('Toggle ATT&CK matrix');?>" role="button" tabindex="0" aria-label="<?php echo __('Toggle ATT&CK matrix');?>" style="vertical-align:top;"></span><?php echo __('ATT&CK matrix');?>
</button>
<button class="btn btn-inverse toggle qet galaxy-toggle-button" id="eventreport_toggle" data-toggle-type="eventreport">
@ -536,7 +536,7 @@
</div>
<script type="text/javascript">
var showContext = false;
$(document).ready(function () {
$(function () {
queryEventLock('<?php echo h($event['Event']['id']); ?>', '<?php echo h($me['org_id']); ?>');
popoverStartup();
@ -557,18 +557,5 @@ $(document).ready(function () {
}
});
});
function enable_correlation_graph() {
$.get("<?= $baseurl ?>/events/viewGraph/<?php echo h($event['Event']['id']); ?>", function(data) {
$("#correlationgraph_div").html(data);
});
}
function enable_attack_matrix() {
$.get("<?= $baseurl; ?>/events/viewGalaxyMatrix/<?php echo h($event['Event']['id']); ?>/mitre-attack/event/1", function(data) {
$("#attackmatrix_div").html(data);
});
}
</script>
<input type="hidden" value="/shortcuts/event_view.json" class="keyboardShortcutsConfig" />

View File

@ -2,7 +2,6 @@
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'galaxies', 'menuItem' => 'view_cluster'));
$extendedFromHtml = '';
$extendFromLinks = array();
if (!empty($cluster['GalaxyCluster']['extended_from'])) {
$element = $this->element('genericElements/IndexTable/Fields/links', array(
'url' => $baseurl . '/galaxy_clusters/view/',
@ -12,9 +11,8 @@
'title' => sprintf(__('%s (version: %s)'), $cluster['GalaxyCluster']['extended_from']['GalaxyCluster']['value'], $cluster['GalaxyCluster']['extends_version'])
),
));
$extendFromLinks[] = sprintf('<li>%s</li>', $element);
$extendedFromHtml = sprintf('<ul><li>%s</li></ul>', $element);
}
$extendedFromHtml = sprintf('<ul>%s</ul>', implode('', $extendFromLinks));
if ($newVersionAvailable) {
$extendedFromHtml .= sprintf('<div class="alert alert-warning">%s</div>', sprintf(__('New version available! <a href="%s">Update cluster to version <b>%s</b></a>'),
'/galaxy_clusters/updateCluster/' . $cluster['GalaxyCluster']['id'],
@ -24,7 +22,7 @@
$extendedByHtml = '';
$extendByLinks = array();
foreach($cluster['GalaxyCluster']['extended_by'] as $extendCluster) {
foreach ($cluster['GalaxyCluster']['extended_by'] as $extendCluster) {
$element = $this->element('genericElements/IndexTable/Fields/links', array(
'url' => '/galaxy_clusters/view/',
'row' => $extendCluster,
@ -35,7 +33,10 @@
));
$extendByLinks[] = sprintf('<li>%s</li>', $element);
}
$extendedByHtml = sprintf('<ul>%s</ul>', implode('', $extendByLinks));
if (!empty($extendByLinks)) {
$extendedByHtml = sprintf('<ul>%s</ul>', implode('', $extendByLinks));
}
$table_data = array();
$table_data[] = array('key' => __('Cluster ID'), 'value' => $cluster['GalaxyCluster']['id']);
$table_data[] = array('key' => __('Name'), 'value' => $cluster['GalaxyCluster']['value']);
@ -71,7 +72,7 @@
sprintf('%s/events/index/searchtag:%s', $baseurl, h($cluster['GalaxyCluster']['tag_id'])),
__n('%s event', '%s events', $cluster['GalaxyCluster']['tag_count'], h($cluster['GalaxyCluster']['tag_count']))
):
'0'
'<span>0</span>'
);
if (!empty($extendedFromHtml)) {
$table_data[] = array('key' => __('Forked From'), 'html' => $extendedFromHtml);
@ -80,7 +81,6 @@
$table_data[] = array('key' => __('Forked By'), 'html' => $extendedByHtml);
}
?>
<div class='view'>
<div class="row-fluid">
<div class="span8">
@ -102,13 +102,13 @@
</div>
<script type="text/javascript">
$(function () {
$.get("<?php echo $baseurl; ?>/galaxy_elements/index/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
$.get("<?= $baseurl ?>/galaxy_elements/index/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
$("#elements_div").html(data);
});
$.get("<?php echo $baseurl; ?>/galaxy_clusters/viewGalaxyMatrix/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
$.get("<?= $baseurl ?>/galaxy_clusters/viewGalaxyMatrix/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
$("#matrix_container").html(data);
});
$.get("/galaxy_clusters/viewRelations/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
$.get("<?= $baseurl ?>/galaxy_clusters/viewRelations/<?php echo $cluster['GalaxyCluster']['id']; ?>", function(data) {
$("#relations_container").html(data);
});
});

View File

@ -1,42 +1,26 @@
<div class="taxonomy view">
<h2><?php echo h(strtoupper($taxonomy['namespace'])) . ' ' . __('Taxonomy Library');?></h2>
<dl>
<dt><?php echo __('Id');?></dt>
<dd>
<?php echo h($taxonomy['id']); ?>
&nbsp;
</dd>
<dt><?php echo __('Namespace');?></dt>
<dd>
<?php echo h($taxonomy['namespace']); ?>
&nbsp;
</dd>
<dt><?php echo __('Description');?></dt>
<dd>
<?php echo h($taxonomy['description']); ?>
&nbsp;
</dd>
<dt><?php echo __('Version');?></dt>
<dd>
<?php echo h($taxonomy['version']); ?>
&nbsp;
</dd>
<dt><?php echo __('Enabled');?></dt>
<dd>
<?php echo $taxonomy['enabled'] ? '<span class="green">'. __('Yes') . '</span>&nbsp;&nbsp;' : '<span class="red">' . __('No') . '</span>&nbsp;&nbsp;';
if ($isSiteAdmin) {
if ($taxonomy['enabled']) {
echo $this->Form->postLink(__('(disable)'), array('action' => 'disable', h($taxonomy['id'])), array('title' => __('Disable')), (__('Are you sure you want to disable this taxonomy library?')));
} else {
echo $this->Form->postLink(__('(enable)'), array('action' => 'enable', h($taxonomy['id'])), array('title' => __('Enable')), (__('Are you sure you want to enable this taxonomy library?')));
}
}
?>
&nbsp;
</dd>
</dl>
<br />
<h2><?php echo h(strtoupper($taxonomy['namespace'])) . ' ' . __('Taxonomy Library');?></h2>
<div class="row-fluid"><div class="span8" style="margin:0">
<?php
$enabled = $taxonomy['enabled'] ? '<span class="green">'. __('Yes') . '</span>&nbsp;&nbsp;' : '<span class="red">' . __('No') . '</span>&nbsp;&nbsp;';
if ($isSiteAdmin) {
if ($taxonomy['enabled']) {
$enabled .= $this->Form->postLink(__('(disable)'), array('action' => 'disable', h($taxonomy['id'])), array('title' => __('Disable')), (__('Are you sure you want to disable this taxonomy library?')));
} else {
$enabled .= $this->Form->postLink(__('(enable)'), array('action' => 'enable', h($taxonomy['id'])), array('title' => __('Enable')), (__('Are you sure you want to enable this taxonomy library?')));
}
}
$tableData = [
['key' => __('ID'), 'value' => $taxonomy['id']],
['key' => __('Namespace'), 'value' => $taxonomy['namespace']],
['key' => __('Description'), 'value' => $taxonomy['description']],
['key' => __('Version'), 'value' => $taxonomy['version']],
['key' => __('Enabled'), 'html' => $enabled],
];
echo $this->element('genericElements/viewMetaTable', ['table_data' => $tableData]);
?>
</div></div>
<br>
<div class="pagination">
<ul>
<?php
@ -102,7 +86,7 @@
<?php if(isset($item['original_numerical_value'])): ?>
<i
class="<?= $this->FontAwesome->getClass('exclamation-triangle') ?> fa-exclamation-triangle"
title="<?= __('Numerical value overriden by userSetting.&#10;Original numerical_value = %s', h($item['original_numerical_value'])) ?>"
title="<?= __('Numerical value overridden by userSetting.&#10;Original numerical_value = %s', h($item['original_numerical_value'])) ?>"
data-value-overriden="1"
></i>
<?php endif; ?>
@ -143,7 +127,7 @@
<a href="<?php echo $url;?>" class="<?php echo $isAclTagger ? 'tagFirstHalf' : 'tag' ?>" style="background-color:<?php echo h($item['existing_tag']['Tag']['colour']);?>;color:<?php echo $this->TextColour->getTextColour($item['existing_tag']['Tag']['colour']);?>"><?php echo h($item['existing_tag']['Tag']['name']); ?></a>
<?php
endif;
echo '&nbsp;' . $this->Html->link('', array('controller' => 'tags', 'action' => 'viewGraph', $item['existing_tag']['Tag']['id']), array('class' => 'fa fa-share-alt black', 'title' => __('View graph'), 'aria-label' => __('View graph')));
echo '&nbsp;' . $this->Html->link('', array('controller' => 'tags', 'action' => 'viewGraph', $item['existing_tag']['Tag']['id']), array('class' => 'fa fa-share-alt black', 'title' => __('View correlation graph'), 'aria-label' => __('View correlation graph')));
endif;
?>
</td>
@ -196,7 +180,7 @@
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$(function(){
$('input:checkbox').removeAttr('checked');
$('.mass-select').hide();
$('.select_taxonomy, .select_all').click(function(){
@ -205,6 +189,4 @@
$('[data-value-overriden="1"]').tooltip();
});
</script>
<?php
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'taxonomies', 'menuItem' => 'view'));
?>
<?= $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'taxonomies', 'menuItem' => 'view'));

View File

@ -4365,18 +4365,25 @@ function selectAllInbetween(last, current) {
$('.galaxy-toggle-button').click(function() {
var element = $(this).data('toggle-type');
if ($(this).children('span').hasClass('icon-minus')) {
$(this).children('span').addClass('icon-plus');
$(this).children('span').removeClass('icon-minus');
var $button = $(this).children('span');
if ($button.hasClass('icon-minus')) {
$button.addClass('icon-plus');
$button.removeClass('icon-minus');
$('#' + element + '_div').hide();
} else {
$(this).children('span').removeClass('icon-plus');
$(this).children('span').addClass('icon-minus');
$button.removeClass('icon-plus');
$button.addClass('icon-minus');
$('#' + element + '_div').show();
var loadUrl = $(this).data('load-url');
if (loadUrl) {
$.get(loadUrl, function(data) {
$('#' + element + '_div').html(data);
});
}
}
});
function addGalaxyListener(id) {
var target_type = $(id).data('target-type');
var target_id = $(id).data('target-id');