mirror of https://github.com/MISP/MISP
Next step in the ajaxification
parent
b8c21364f9
commit
ba91f4dc5f
|
@ -1,9 +1,9 @@
|
|||
<div class="attributes <? if (!$ajax) echo 'form';?>">
|
||||
<?php echo $this->Form->create('Attribute', array('id'));?>
|
||||
<legend><?php echo __('Add Attribute'); ?></legend>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Add Attribute'); ?></legend>
|
||||
<div id="formWarning" class="message ajaxMessage"></div>
|
||||
<div class="add_attribute_fields">
|
||||
<div style="width:200px" id="formError"></div>
|
||||
<?php
|
||||
echo $this->Form->hidden('event_id');
|
||||
echo $this->Form->input('category', array(
|
||||
|
@ -63,61 +63,7 @@
|
|||
<table>
|
||||
<tr>
|
||||
<td style="vertical-align:top">
|
||||
<span id="submitButton" class="btn btn-primary" onClick="submitForm()">Submit</span>
|
||||
<?php
|
||||
//echo $this->Form->button('Submit', array('class' => 'btn btn-primary', 'id' => 'submit-button'));
|
||||
//($this->Js->get('#attributes_add_form')->serializeForm(array('isForm' => true, 'inline' => true)));
|
||||
/*
|
||||
echo $this->Js->submit('Submit', array(
|
||||
'class'=>'btn btn-primary',
|
||||
'url' => '/attributes/add/' . $event_id,
|
||||
'success' => "handleAjaxResponse(data);",
|
||||
'complete' => $this->Js->request(
|
||||
array(
|
||||
'controller' => 'events',
|
||||
'action' => 'view',
|
||||
$event_id,
|
||||
'attributesPage:1'
|
||||
),
|
||||
array(
|
||||
'update' => '#attributes_div',
|
||||
'before' => '$(".loading").show();',
|
||||
'success' => '$(".loading").hide();',
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
*/
|
||||
|
||||
/*
|
||||
echo $this->Js->submit('Submit', array(
|
||||
'complete'=> $this->Js->request(
|
||||
array('controller' => 'events', 'action' => 'view', $event_id, 'attributesPage:1'),
|
||||
array(
|
||||
'update' => '#attributes_div',
|
||||
'before' => '$(".loading").show();',
|
||||
'success' => '$(".loading").hide();',
|
||||
|
||||
{
|
||||
$("#gray_out").hide();
|
||||
$("#attribute_add_form").hide();
|
||||
$(".loading").hide();
|
||||
}',
|
||||
|
||||
//'success' => 'ajaxResponse(data);',
|
||||
)
|
||||
),
|
||||
'class'=>'btn btn-primary',
|
||||
//'success' => 'submitResponse(data);',
|
||||
'success' => "function(data) {
|
||||
alert(data);
|
||||
}",
|
||||
'url' => '/attributes/add/' . $event_id,
|
||||
//'update' => '#attribute_add_form'
|
||||
));
|
||||
*/
|
||||
|
||||
?>
|
||||
<span id="submitButton" class="btn btn-primary" onClick="submitForm()">Submit</span>
|
||||
</td>
|
||||
<td style="width:540px;">
|
||||
<p style="color:red;font-weight:bold;display:none;text-align:center" id="warning-message">Warning: You are about to share data that is of a classified nature (Attribution / targeting data). Make sure that you are authorised to share this.</p>
|
||||
|
@ -282,18 +228,25 @@ function handleAjaxResponse(response) {
|
|||
$("#attribute_add_form").html(data);
|
||||
responseArray = JSON.parse(response);
|
||||
handleValidationErrors(responseArray);
|
||||
//$("#formError").html(responseArray['value']);
|
||||
if (!isEmpty(responseArray)) {
|
||||
$("#formWarning").show();
|
||||
$("#formWarning").html('The attribute could not be saved. Please, try again.');
|
||||
}
|
||||
recoverValuesFromPersistance(savedArray);
|
||||
},
|
||||
url:"/attributes/add/<?php echo $event_id; ?>"
|
||||
});
|
||||
//$.get("/attributes/add/<?php //echo $event_id; ?>", function(data) {
|
||||
//$("#attribute_add_form").html(data);
|
||||
//responseArray = JSON.parse(response);
|
||||
//});
|
||||
}
|
||||
}
|
||||
|
||||
function isEmpty(obj) {
|
||||
var name;
|
||||
for (name in obj) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function updateAttributeIndexOnSuccess() {
|
||||
$.ajax({
|
||||
beforeSend: function (XMLHttpRequest) {
|
||||
|
|
|
@ -238,6 +238,31 @@
|
|||
);
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
function deleteObject(type, id) {
|
||||
$.ajax({
|
||||
success:function (data, textStatus) {
|
||||
updateAttributeIndexOnSuccess();
|
||||
},
|
||||
type:"post",
|
||||
url:"/" + type + "/delete/" + id,
|
||||
});
|
||||
}
|
||||
|
||||
function updateAttributeIndexOnSuccess() {
|
||||
$.ajax({
|
||||
beforeSend: function (XMLHttpRequest) {
|
||||
$(".loading").show();
|
||||
},
|
||||
dataType:"html",
|
||||
success:function (data, textStatus) {
|
||||
$(".loading").hide();
|
||||
$("#attributes_div").html(data);
|
||||
},
|
||||
url:"/events/view/<?php echo $event['Event']['id']; ?>/attributesPage:1",
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
endif;
|
||||
echo $this->Js->writeBuffer();
|
||||
|
|
|
@ -201,19 +201,9 @@ $mayPublish = ($isAclPublish && $event['Event']['orgc'] == $me['org']);
|
|||
<?php if (sizeOf($allPivots) > 1) echo $this->element('pivot'); ?>
|
||||
</div>
|
||||
<div id="create_object_div">
|
||||
<button id="create-button" class="btn btn-inverse">Add Attribute</button>
|
||||
<?php
|
||||
$this->Js->get('#create-button')->event(
|
||||
'click',
|
||||
$this->Js->request(
|
||||
array('controller' => 'attributes', 'action' => 'add', $event['Event']['id']),
|
||||
array(
|
||||
'before' => '$("#gray_out").show();$("#attribute_add_form").show();',
|
||||
'update' => '#attribute_add_form',
|
||||
'async' => true,
|
||||
)));
|
||||
?>
|
||||
<span id="create-button" class="btn btn-inverse" onClick="clickCreateButton();">Add Attribute</span>
|
||||
</div>
|
||||
<br />
|
||||
<div id="attribute_add_form" class="attribute_add_form"></div>
|
||||
<div id="attribute_creation_div" style="display:none;">
|
||||
<?php
|
||||
|
@ -276,4 +266,11 @@ $(document).ready(function () {
|
|||
});
|
||||
});
|
||||
|
||||
function clickCreateButton() {
|
||||
$.get( "/attributes/add/<?php echo $event['Event']['id']; ?>", function(data) {
|
||||
$("#attribute_add_form").show();
|
||||
$("#gray_out").show();
|
||||
$("#attribute_add_form").html(data);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -704,6 +704,7 @@ a.proposal_link_red:hover {
|
|||
.attribute_add_form legend {
|
||||
border-radius: 10px 10px 0px 0px;
|
||||
padding-left:10px;
|
||||
margin-bottom:5px;
|
||||
width:690px;
|
||||
background-color:black;
|
||||
color:white;
|
||||
|
@ -740,6 +741,12 @@ a.proposal_link_red:hover {
|
|||
z-index:4;
|
||||
}
|
||||
|
||||
.ajaxMessage {
|
||||
display:none;
|
||||
margin-left:10px;
|
||||
width:665px;
|
||||
}
|
||||
|
||||
@-webkit-keyframes rotation {
|
||||
from {-webkit-transform: rotate(0deg);}
|
||||
to {-webkit-transform: rotate(359deg);}
|
||||
|
|
Loading…
Reference in New Issue