mirror of https://github.com/MISP/MISP
chg: [decaying:tool] Added table filtering buttons
parent
d31f34fed0
commit
7be53e6b5b
|
@ -386,7 +386,8 @@ class DecayingModelController extends AppController
|
|||
public function getAllDecayingModels()
|
||||
{
|
||||
if ($this->request->is('get') && $this->request->is('ajax')) {
|
||||
$savedDecayingModels = $this->DecayingModel->fetchAllAllowedModels($this->Auth->user());
|
||||
$filters = $this->request->query;
|
||||
$savedDecayingModels = $this->DecayingModel->fetchAllAllowedModels($this->Auth->user(), true, $filters);
|
||||
$associated_models = $this->DecayingModel->DecayingModelMapping->getAssociatedModels($this->Auth->user());
|
||||
$associated_types = array();
|
||||
foreach ($associated_models as $type => $models) {
|
||||
|
|
|
@ -167,7 +167,7 @@ class DecayingModel extends AppModel
|
|||
return !is_null($decaying_model['DecayingModel']['uuid']);
|
||||
}
|
||||
|
||||
public function fetchAllAllowedModels($user, $full=true)
|
||||
public function fetchAllAllowedModels($user, $full=true, $filters=array())
|
||||
{
|
||||
$conditions = array();
|
||||
if (!$user['Role']['perm_site_admin']) {
|
||||
|
@ -176,6 +176,13 @@ class DecayingModel extends AppModel
|
|||
'all_orgs' => 1
|
||||
);
|
||||
}
|
||||
if (!empty($filters)) {
|
||||
if (isset($filters['my_models']) && $filters['my_models']) {
|
||||
$conditions[] = array('DecayingModel.org_id' => $user['Organisation']['id']);
|
||||
} elseif (isset($filters['default_models']) && $filters['default_models']) {
|
||||
$conditions[] = array('not' => array('DecayingModel.uuid' => null));
|
||||
}
|
||||
}
|
||||
$decayingModels = $this->find('all', array(
|
||||
'conditions' => $conditions,
|
||||
'include' => $full ? 'DecayingModelMapping' :''
|
||||
|
|
|
@ -138,6 +138,17 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<span class="tableRadioFilterOptionsContainer">
|
||||
<label class="radio inline">
|
||||
<input type="radio" id="tableRadioFilterAll" name="tableRadioFilterOptions" value="all" checked><?php echo __('All available models');?>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<input type="radio" id="tableRadioFilterMy" name="tableRadioFilterOptions" value="my_models"><?php echo __('My models'); ?>
|
||||
</label>
|
||||
<label class="radio inline">
|
||||
<input type="radio" id="tableRadioFilterDefault" name="tableRadioFilterOptions" value="default_models"><?php echo __('Default models'); ?>
|
||||
</label>
|
||||
</span>
|
||||
<table id="table-model" class="table table-striped table-bordered">
|
||||
<thead id="table-model-head"></thead>
|
||||
<tbody id="table-model-body"></tbody>
|
||||
|
|
|
@ -163,3 +163,14 @@ svg text.axis-label {
|
|||
font: 10px sans-serif;
|
||||
fill: #999;
|
||||
}
|
||||
|
||||
.tableRadioFilterOptionsContainer {
|
||||
display: inline-block;
|
||||
padding: 0 5px;
|
||||
margin-left: 10px;
|
||||
border-top: 1px solid #ddd;
|
||||
border-left: 1px solid #ddd;
|
||||
border-right: 1px solid #ddd;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
|
@ -24,9 +24,7 @@
|
|||
selection_history2: []
|
||||
};
|
||||
this.model_table = new ModelTable();
|
||||
$.getJSON('/decayingModel/getAllDecayingModels/', function(json) {
|
||||
that.model_table.update(json);
|
||||
});
|
||||
this.model_table.refreshTable();
|
||||
this._init();
|
||||
};
|
||||
|
||||
|
@ -889,6 +887,12 @@ ModelTable.prototype = {
|
|||
];
|
||||
this.data = [];
|
||||
this.thead.html(this._get_html_header(this.table_header));
|
||||
|
||||
// bind listener on radio filters
|
||||
var that = this;
|
||||
$('.tableRadioFilterOptionsContainer input[type=\'radio\']').change(function() {
|
||||
that.refreshTable();
|
||||
});
|
||||
},
|
||||
|
||||
update: function(data) {
|
||||
|
@ -897,6 +901,18 @@ ModelTable.prototype = {
|
|||
this._draw();
|
||||
},
|
||||
|
||||
refreshTable: function(data) {
|
||||
var that = this;
|
||||
var $filter_radio = $('.tableRadioFilterOptionsContainer input[type=\'radio\']:checked');
|
||||
var filters = {};
|
||||
if ($filter_radio) {
|
||||
filters[$filter_radio.val()] = 1;
|
||||
}
|
||||
$.getJSON('/decayingModel/getAllDecayingModels/', filters, function(json) {
|
||||
that.update(json);
|
||||
});
|
||||
},
|
||||
|
||||
massage_data: function(data) {
|
||||
var massaged_data = $.extend([], data);
|
||||
|
||||
|
|
Loading…
Reference in New Issue