mirror of https://github.com/MISP/MISP
chg: reuse add view for /templates/edit
parent
57bb08d59e
commit
2e8e013cd0
|
@ -106,6 +106,7 @@ class TemplatesController extends AppController
|
|||
$this->set('template', $template);
|
||||
$this->set('tags', $tagArray);
|
||||
$this->set('tagInfo', $tags);
|
||||
$this->render('add');
|
||||
}
|
||||
|
||||
public function view($id)
|
||||
|
|
|
@ -28,7 +28,14 @@
|
|||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var selectedTags = [];
|
||||
var selectedTags = [
|
||||
<?php
|
||||
foreach ($fieldData['selectedTags'] as $k => $t) {
|
||||
if ($k != 0) echo ', ';
|
||||
echo '"' . h($t['Tag']['id']) . '"';
|
||||
}
|
||||
?>
|
||||
];
|
||||
var allTags = [
|
||||
<?php
|
||||
foreach ($fieldData['tagInfo'] as $tag) {
|
||||
|
@ -36,5 +43,10 @@
|
|||
}
|
||||
?>
|
||||
];
|
||||
$(document).ready(function() {
|
||||
for (var i = 0, len = selectedTags.length; i < len; i++) {
|
||||
appendTemplateTag(selectedTags[i], 'yes');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer();
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<div class="eventBlocklists index">
|
||||
<h2><?php echo __('Event Blocklists');?></h2>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
|
||||
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
<?php
|
||||
$data = array(
|
||||
'children' => array(
|
||||
array(
|
||||
'children' => array(
|
||||
array(
|
||||
'class' => 'hidden mass-select',
|
||||
'fa-icon' => 'trash',
|
||||
'onClick' => "multiSelectDeleteEventBlocklist",
|
||||
'onClickParams' => array('1', '0')
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'type' => 'search',
|
||||
'button' => __('Filter'),
|
||||
'placeholder' => __('Enter value to search'),
|
||||
'data' => '',
|
||||
)
|
||||
)
|
||||
);
|
||||
echo $this->element('/genericElements/ListTopBar/scaffold', array('data' => $data));
|
||||
?>
|
||||
</div>
|
||||
<table class="table table-striped table-hover table-condensed">
|
||||
<tr>
|
||||
<th>
|
||||
<input class="select_all select" type="checkbox" title="<?php echo __('Select all');?>" role="button" tabindex="0" aria-label="<?php echo __('Select all events on current page');?>" onClick="toggleAllCheckboxes();" />
|
||||
</th>
|
||||
<th><?php echo $this->Paginator->sort('id');?></th>
|
||||
<th><?php echo $this->Paginator->sort('org');?></th>
|
||||
<th><?php echo $this->Paginator->sort('event_uuid', __('Event UUID'));?></th>
|
||||
<th><?php echo $this->Paginator->sort('created');?></th>
|
||||
<th><?php echo $this->Paginator->sort('event_info');?></th>
|
||||
<th><?php echo $this->Paginator->sort('comment');?></th>
|
||||
<th class="actions"><?php echo __('Actions');?></th>
|
||||
</tr><?php
|
||||
foreach ($response as $item): ?>
|
||||
<tr>
|
||||
<td style="width:10px;">
|
||||
<input class="select" type="checkbox" data-id="<?php echo h($item['EventBlocklist']['id']); ?>" aria-label="select <?php echo h($item['EventBlocklist']['id'])?>" />
|
||||
</td>
|
||||
<td class="short"><?php echo h($item['EventBlocklist']['id']); ?> </td>
|
||||
<td class="short"><?php echo (isset($item['EventBlocklist']['event_orgc']) ? h($item['EventBlocklist']['event_orgc']) : ' '); ?></td>
|
||||
<td class="short"><?php echo h($item['EventBlocklist']['event_uuid']); ?> </td>
|
||||
<td><?php echo h($item['EventBlocklist']['created']); ?> </td>
|
||||
<td class="short"><?php echo (isset($item['EventBlocklist']['event_info']) ? h($item['EventBlocklist']['event_info']) : ' '); ?></td>
|
||||
<td class="short"><?php echo (isset($item['EventBlocklist']['comment']) ? h($item['EventBlocklist']['comment']) : ' '); ?></td>
|
||||
<td class="short action-links">
|
||||
<a href="<?= $baseurl;?>/eventBlocklists/edit/<?= h($item['EventBlocklist']['id']); ?>" class="fa fa-edit" title="<?= __('Edit')?>" role="button" tabindex="0" aria-label="Edit blocklist entry"> </a>
|
||||
<?php echo $this->Form->postLink('', array('action' => 'delete', h($item['EventBlocklist']['id'])), array('class' => 'fa fa-trash', 'title' => __('Delete'), 'aria-label' => __('Delete')), __('Are you sure you want to delete the blocklist entry for the event UUID %s?', h($item['EventBlocklist']['event_uuid']))); ?>
|
||||
</td>
|
||||
</tr><?php
|
||||
endforeach; ?>
|
||||
</table>
|
||||
<p>
|
||||
<?php
|
||||
echo $this->Paginator->counter(array(
|
||||
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
|
||||
));
|
||||
?>
|
||||
</p>
|
||||
<div class="pagination">
|
||||
<ul>
|
||||
<?php
|
||||
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
|
||||
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
|
||||
?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
popoverStartup();
|
||||
$('.select').on('change', function() {
|
||||
listCheckboxesChecked();
|
||||
});
|
||||
$('#quickFilterButton').click(function() {
|
||||
runIndexQuickFilter();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
if ($isSiteAdmin) {
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'admin', 'menuItem' => 'eventBlocklists'));
|
||||
} else {
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'event-collection', 'menuItem' => 'eventBlocklists'));
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
<?php
|
||||
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'templates', 'menuItem' => 'add'));
|
||||
|
||||
$edit = $this->request->params['action'] === 'edit' ? true : false;
|
||||
|
||||
echo $this->element('genericElements/Form/genericForm', [
|
||||
'data' => [
|
||||
'title' => __('Create Template'),
|
||||
'title' => $edit ? __('Edit Template') : __('Create Template'),
|
||||
'fields' => [
|
||||
[
|
||||
'field' => 'name',
|
||||
|
@ -14,6 +17,7 @@ echo $this->element('genericElements/Form/genericForm', [
|
|||
'label' => __('Tags'),
|
||||
'type' => 'tags',
|
||||
'tags' => $tags,
|
||||
'selectedTags' => isset($currentTags) ? $currentTags : [],
|
||||
'tagInfo' => $tagInfo
|
||||
],
|
||||
[
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
<div class="templates form">
|
||||
<?php
|
||||
echo $this->Form->create('Template');
|
||||
?>
|
||||
<fieldset>
|
||||
<legend><?php echo __('Edit Template'); ?></legend>
|
||||
<?php
|
||||
echo ($this->Form->input('name', array('div' => 'clear')));
|
||||
echo ($this->Form->input('tags', array('id' => 'hiddenTags','div' => 'clear', 'label' => false, 'type' => 'text', 'value' => '[]', 'style' => 'display:none;')));
|
||||
?>
|
||||
<div id ="tagList">
|
||||
<label><?php echo __('Tags');?></label>
|
||||
<table>
|
||||
<tr>
|
||||
<td><table><tr id = "tags"></tr></table></td>
|
||||
<td id = "addTagButtonTD">
|
||||
<span role="button" tabindex="0" aria-label="<?php echo __('Add tag');?>" title="<?php echo __('Add tag');?>" onClick="activateTagField()" id="addTagButton" class="btn btn-inverse noPrint" style="line-height:10px; padding: 4px 4px;">+</span>
|
||||
</td>
|
||||
<td id = "addTagFieldTD">
|
||||
<?php
|
||||
echo $this->Form->input('tagsPusher', array(
|
||||
'div' => 'clear',
|
||||
'id' => 'addTagField',
|
||||
'options' => array($tags),
|
||||
'label' => false,
|
||||
'onChange' => 'tagFieldChange()',
|
||||
'style' => "height:22px;padding:0px;margin-bottom:0px;display:none;",
|
||||
'empty' => __('Add a tag'),
|
||||
));
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div><br />
|
||||
<?php
|
||||
echo $this->Form->input('description', array(
|
||||
'label' => __('Template Description'),
|
||||
'div' => 'clear',
|
||||
'type' => 'textarea',
|
||||
'class' => 'form-control span6',
|
||||
'placeholder' => __('A description of the template')
|
||||
));
|
||||
echo $this->Form->input('share', array(
|
||||
'label' => __('Share this template with others'),
|
||||
'type' => 'checkbox'
|
||||
));
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $this->Form->button(__('Edit'), array('class' => 'btn btn-primary'));
|
||||
echo $this->Form->end();?>
|
||||
</div>
|
||||
<?php
|
||||
echo $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'templates', 'menuItem' => 'edit', 'id' => $id, 'mayModify' => $mayModify));
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var selectedTags = [
|
||||
<?php
|
||||
foreach ($currentTags as $k => $t) {
|
||||
if ($k != 0) echo ', ';
|
||||
echo '"' . $t['Tag']['id'] . '"';
|
||||
}
|
||||
?>
|
||||
];
|
||||
var allTags = [
|
||||
<?php
|
||||
foreach ($tagInfo as $tag) {
|
||||
echo "{'id' : '" . h($tag['Tags']['id']) . "', 'name' : '" . h($tag['Tags']['name']) . "', 'colour' : '" . h($tag['Tags']['colour']) . "'},";
|
||||
}
|
||||
?>
|
||||
];
|
||||
$(document).ready( function () {
|
||||
for (var i = 0, len = selectedTags.length; i < len; i++) {
|
||||
appendTemplateTag(selectedTags[i], 'yes');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php echo $this->Js->writeBuffer();
|
Loading…
Reference in New Issue