mirror of https://github.com/MISP/MISP
chg: [UI] Allow filter enabled/disabled warninglists
parent
7563fb4a61
commit
26d55557e7
|
@ -9,20 +9,20 @@ class WarninglistsController extends AppController
|
|||
public $components = array('Session', 'RequestHandler');
|
||||
|
||||
public $paginate = array(
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user can view/page.
|
||||
'contain' => array(
|
||||
'WarninglistType'
|
||||
),
|
||||
'order' => array(
|
||||
'Warninglist.id' => 'DESC'
|
||||
),
|
||||
'limit' => 60,
|
||||
'maxLimit' => 9999, // LATER we will bump here on a problem once we have more than 9999 events <- no we won't, this is the max a user can view/page.
|
||||
'contain' => array(
|
||||
'WarninglistType'
|
||||
),
|
||||
'order' => array(
|
||||
'Warninglist.id' => 'DESC'
|
||||
),
|
||||
'recursive' => -1,
|
||||
);
|
||||
|
||||
public function index()
|
||||
{
|
||||
$filters = $this->IndexFilter->harvestParameters(['value']);
|
||||
$this->paginate['recursive'] = -1;
|
||||
$filters = $this->IndexFilter->harvestParameters(['value', 'enabled']);
|
||||
if (!empty($filters['value'])) {
|
||||
$this->paginate['conditions'] = [
|
||||
'OR' => [
|
||||
|
@ -32,20 +32,20 @@ class WarninglistsController extends AppController
|
|||
]
|
||||
];
|
||||
}
|
||||
if (isset($filters['enabled'])) {
|
||||
$this->paginate['conditions'][] = ['Warninglist.enabled' => $filters['enabled']];
|
||||
}
|
||||
$warninglists = $this->paginate();
|
||||
foreach ($warninglists as &$warninglist) {
|
||||
$warninglist['Warninglist']['valid_attributes'] = array();
|
||||
foreach ($warninglist['WarninglistType'] as $type) {
|
||||
$warninglist['Warninglist']['valid_attributes'][] = $type['type'];
|
||||
}
|
||||
$warninglist['Warninglist']['valid_attributes'] = implode(', ', $warninglist['Warninglist']['valid_attributes']);
|
||||
$validAttributes = array_column($warninglist['WarninglistType'], 'type');
|
||||
$warninglist['Warninglist']['valid_attributes'] = implode(', ', $validAttributes);
|
||||
unset($warninglist['WarninglistType']);
|
||||
}
|
||||
if ($this->_isRest()) {
|
||||
$this->set('Warninglists', $warninglists);
|
||||
$this->set('_serialize', array('Warninglists'));
|
||||
return $this->RestResponse->viewData(['Warninglists' => $warninglists], $this->response->type());
|
||||
} else {
|
||||
$this->set('warninglists', $warninglists);
|
||||
$this->set('passedArgsArray', $filters);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,26 @@
|
|||
'data' => $warninglists,
|
||||
'top_bar' => array(
|
||||
'children' => array(
|
||||
array(
|
||||
'type' => 'simple',
|
||||
'children' => array(
|
||||
array(
|
||||
'url' => $baseurl . '/warninglists/index',
|
||||
'text' => __('All'),
|
||||
'active' => !isset($passedArgsArray['enabled']),
|
||||
),
|
||||
array(
|
||||
'url' => $baseurl . '/warninglists/index/enabled:1',
|
||||
'text' => __('Enabled'),
|
||||
'active' => isset($passedArgsArray['enabled']) && $passedArgsArray['enabled'] === "1",
|
||||
),
|
||||
array(
|
||||
'url' => $baseurl . '/warninglists/index/enabled:0',
|
||||
'text' => __('Disabled'),
|
||||
'active' => isset($passedArgsArray['enabled']) && $passedArgsArray['enabled'] === "0",
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'search',
|
||||
'button' => __('Filter'),
|
||||
|
@ -55,7 +75,6 @@
|
|||
),
|
||||
array(
|
||||
'name' => __('Valid attributes'),
|
||||
'class' => 'short',
|
||||
'data_path' => 'Warninglist.valid_attributes',
|
||||
),
|
||||
array(
|
||||
|
@ -130,14 +149,9 @@
|
|||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$(function() {
|
||||
$('#quickFilterButton').click(function() {
|
||||
runIndexQuickFilter();
|
||||
});
|
||||
$('#quickFilterField').on('keypress', function (e) {
|
||||
if(e.which === 13) {
|
||||
runIndexQuickFilter();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue