chg: [internal] Speedup sending module results

pull/6446/head
Jakub Onderka 2020-10-15 19:01:01 +02:00
parent 6fb78f8b77
commit 240b3434e0
2 changed files with 22 additions and 16 deletions

View File

@ -4909,8 +4909,8 @@ class EventsController extends AppController
throw new ForbiddenException(__('You don\'t have permission to do that.'));
}
$resolved_data = json_decode($this->request->data['Event']['JsonObject'], true);
$data = json_decode($this->request->data['Event']['data'], true);
$resolved_data = $this->Event->jsonDecode($this->request->data['Event']['JsonObject']);
$data = $this->Event->jsonDecode($this->request->data['Event']['data']);
if (!empty($data['initialObject'])) {
$resolved_data['initialObject'] = $data['initialObject'];
}
@ -4918,7 +4918,12 @@ class EventsController extends AppController
$default_comment = $this->request->data['Event']['default_comment'];
$flashMessage = $this->Event->processModuleResultsDataRouter($this->Auth->user(), $resolved_data, $event['Event']['id'], $default_comment);
$this->Flash->info($flashMessage);
$this->redirect(array('controller' => 'events', 'action' => 'view', $event['Event']['id']));
if ($this->request->is('ajax')) {
return $this->RestResponse->viewData($flashMessage, $this->response->type());
} else {
$this->redirect(array('controller' => 'events', 'action' => 'view', $event['Event']['id']));
}
}
public function importModule($module, $eventId)

View File

@ -2805,7 +2805,7 @@ function moduleResultsSubmit(id) {
}
if ($('.MISPAttribute').length) {
var attributes = [];
$('.MISPAttribute').each(function(a) {
$('.MISPAttribute').each(function() {
var category_value;
var type_value;
if ($(this).find('.AttributeCategorySelect').length) {
@ -2865,32 +2865,33 @@ function moduleResultsSubmit(id) {
cache: false,
url: baseurl + "/events/handleModuleResults/" + id,
data: formData,
beforeSend: function (XMLHttpRequest) {
beforeSend: function () {
$(".loading").show();
},
success:function (data, textStatus) {
success: function () {
window.location = baseurl + '/events/view/' + id;
},
complete:function() {
complete: function() {
$(".loading").hide();
}
},
error: xhrFailCallback,
});
}
function objectTemplateViewContent(context, id) {
var url = baseurl + "/objectTemplateElements/viewElements/" + id + "/" + context;
$.ajax({
url: url,
type:'GET',
url: url,
type:'GET',
beforeSend: function (XMLHttpRequest) {
$(".loading").show();
},
error: function(){
$('#ajaxContent').html('An error has occured, please reload the page.');
},
success: function(response){
$('#ajaxContent').html(response);
},
error: function(){
$('#ajaxContent').html('An error has occured, please reload the page.');
},
success: function(response){
$('#ajaxContent').html(response);
},
complete: function() {
$(".loading").hide();
},