Skip to content

Commit

Permalink
Merge branch '2.4' of github.com:MISP/MISP into 2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
iglocska committed Mar 25, 2020
2 parents d7e3674 + e166f74 commit a424221
Show file tree
Hide file tree
Showing 33 changed files with 1,081 additions and 429 deletions.
5 changes: 4 additions & 1 deletion app/Controller/DashboardsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public function getForm($action = 'edit')
$dashboardWidget = $this->Dashboard->loadWidget($this->Auth->user(), $data['widget']);
$data['description'] = empty($dashboardWidget->description) ? '' : $dashboardWidget->description;
$data['params'] = empty($dashboardWidget->params) ? array() : $dashboardWidget->params;
$data['params'] = array_merge($data['params'], array('widget_config' => __('Configuration of the widget that will be passed to the render. Check the view for more information')));
$data['params'] = array_merge(array('alias' => __('Alias to use as the title of the widget')), $data['params']);
}
$this->set('data', $data);
Expand Down Expand Up @@ -174,9 +175,11 @@ public function renderWidget($widget_id, $force = false)
} else {
$data = json_decode($data, true)['data'];
}
$valueConfig = json_decode($value['config'], true);
$config = array(
'render' => $dashboardWidget->render,
'autoRefreshDelay' => empty($dashboardWidget->autoRefreshDelay) ? false : $dashboardWidget->autoRefreshDelay
'autoRefreshDelay' => empty($dashboardWidget->autoRefreshDelay) ? false : $dashboardWidget->autoRefreshDelay,
'widget_config' => empty($valueConfig['widget_config']) ? array() : $valueConfig['widget_config']
);
$this->set('widget_id', $widget_id);
$this->set('data', $data);
Expand Down
37 changes: 35 additions & 2 deletions app/Controller/GalaxiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,45 @@ class GalaxiesController extends AppController

public function index()
{
$aclConditions = array();
$filters = $this->IndexFilter->harvestParameters(array('context', 'value'));
$contextConditions = array();
if (empty($filters['context'])) {
$filters['context'] = 'all';
}
$searchConditions = array();
if (empty($filters['value'])) {
$filters['value'] = '';
} else {
$searchall = '%' . strtolower($filters['value']) . '%';
$searchConditions = array(
'OR' => array(
'LOWER(Galaxy.name) LIKE' => $searchall,
'LOWER(Galaxy.namespace) LIKE' => $searchall,
'LOWER(Galaxy.description) LIKE' => $searchall,
'LOWER(Galaxy.kill_chain_order) LIKE' => $searchall,
'Galaxy.uuid LIKE' => $searchall
)
);
}
if ($this->_isRest()) {
$galaxies = $this->Galaxy->find('all', array('recursive' => -1));
$galaxies = $this->Galaxy->find('all',
array(
'recursive' => -1,
'conditions' => array(
'AND' => array($contextConditions, $searchConditions, $aclConditions)
)
)
);
return $this->RestResponse->viewData($galaxies, $this->response->type());
} else {
$this->paginate['conditions']['AND'][] = $contextConditions;
$this->paginate['conditions']['AND'][] = $searchConditions;
$this->paginate['conditions']['AND'][] = $aclConditions;
$galaxies = $this->paginate();
$this->set('list', $galaxies);
$this->set('galaxyList', $galaxies);
$this->set('context', $filters['context']);
$this->set('searchall', $filters['value']);
}
}

Expand Down
19 changes: 14 additions & 5 deletions app/Controller/GalaxyClustersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ class GalaxyClustersController extends AppController

public function index($id)
{
$filters = $this->IndexFilter->harvestParameters(array('context', 'searchall'));
$contextConditions = array();
if (empty($filters['context'])) {
$filters['context'] = 'all';
}
$this->set('context', $filters['context']);
$this->set('searchall', isset($filters['searchall']) ? $filters['searchall'] : '');
$this->paginate['conditions'] = array('GalaxyCluster.galaxy_id' => $id);
if (isset($this->params['named']['searchall']) && strlen($this->params['named']['searchall']) > 0) {
if (isset($filters['searchall']) && strlen($filters['searchall']) > 0) {
$synonym_hits = $this->GalaxyCluster->GalaxyElement->find(
'list',
array(
'recursive' => -1,
'conditions' => array(
'LOWER(GalaxyElement.value) LIKE' => '%' . strtolower($this->params['named']['searchall']) . '%',
'LOWER(GalaxyElement.value) LIKE' => '%' . strtolower($filters['searchall']) . '%',
'GalaxyElement.key' => 'synonyms' ),
'fields' => array(
'GalaxyElement.galaxy_cluster_id')
Expand All @@ -49,19 +56,21 @@ public function index($id)
$this->paginate['conditions'] =
array("AND" => array(
'OR' => array(
"LOWER(GalaxyCluster.value) LIKE" => '%'. strtolower($this->params['named']['searchall']) .'%',
"LOWER(GalaxyCluster.description) LIKE" => '%'. strtolower($this->params['named']['searchall']) .'%',
"LOWER(GalaxyCluster.value) LIKE" => '%'. strtolower($filters['searchall']) .'%',
"LOWER(GalaxyCluster.description) LIKE" => '%'. strtolower($filters['searchall']) .'%',
"GalaxyCluster.id" => array_values($synonym_hits)
),
"GalaxyCluster.galaxy_id" => $id
));
$this->set('passedArgsArray', array('all'=>$this->params['named']['searchall']));
$this->set('passedArgsArray', array('all'=>$filters['searchall']));
}
$clusters = $this->paginate();
$sgs = $this->GalaxyCluster->Tag->EventTag->Event->SharingGroup->fetchAllAuthorised($this->Auth->user());
foreach ($clusters as $k => $cluster) {
if (!empty($cluster['Tag']['id'])) {
$clusters[$k]['GalaxyCluster']['event_count'] = $this->GalaxyCluster->Tag->EventTag->countForTag($cluster['Tag']['id'], $this->Auth->user(), $sgs);
} else {
$clusters[$k]['GalaxyCluster']['event_count'] = 0;
}
}
$tagIds = array();
Expand Down
3 changes: 3 additions & 0 deletions app/View/Dashboards/index.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@ $(document).ready(function () {
grid.on('added', function(event, items) {
resetDashboardGrid(grid);
});
grid.on('gsresizestop', function(event, element) {
$(element).find('.widgetContentInner').trigger('widget-resized')
});
});
</script>
2 changes: 1 addition & 1 deletion app/View/Dashboards/widget_loader.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
$widgetHtml = $this->element('/dashboard/Widgets/' . $config['render']);
$scopedHtml = $this->ScopedCSS->createScopedCSS($widgetHtml);
?>
<div id="widgetContentInner_<?= h($widget_id) ?>">
<div id="widgetContentInner_<?= h($widget_id) ?>" class="widgetContentInner">
<?php
echo $scopedHtml['bundle'];
?>
Expand Down
Loading

0 comments on commit a424221

Please sign in to comment.