mirror of https://github.com/MISP/MISP
new: [galaxyClusters:add] Added UI to create/edit GalaxyClusterElements
parent
d82f5ec1c7
commit
d74116ac0c
|
@ -0,0 +1,79 @@
|
|||
<div style="margin-top: -12px; margin-bottom: 12px;">
|
||||
<button id="toggleElementUI" type="button" class="btn btn-primary"><?= __('Toggle Cluster Elements UI'); ?></button>
|
||||
</div>
|
||||
|
||||
<div id="genericModal" class="modal hide fade">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h3><?= __('Edit Cluster\'s Elements') ?></h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="elementTableBody">
|
||||
<?php if (false): ?>
|
||||
<tr>
|
||||
<td><input type="text" value="<?= h($element['key']) ?>"></input></td>
|
||||
<td><input type="text" value="<?= h($element['value']) ?>"></input></td>
|
||||
<td><buton type="button" class="btn btn-danger btn-small" onclick="deleteCurrentRow(this)">×</buton></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<button onclick="addNewRow()" type="button" class="btn btn-primary btn-small bold">+ <?= __('Add Element'); ?></button>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="injectElements" type="button" class="btn btn-primary btn-small" data-dismiss="modal"><?= __('Save changes'); ?></button>
|
||||
<a href="#" class="btn" data-dismiss="modal"><?= __('Close'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var originalElements = <?= json_encode($elements) ?>;
|
||||
$(document).ready(function() {
|
||||
$('#injectElements').click(function() {
|
||||
$('#GalaxyClusterElements').text(JSON.stringify(parseTable()))
|
||||
});
|
||||
$('#toggleElementUI').click(function() {
|
||||
$('#genericModal').modal();
|
||||
fillTable(originalElements);
|
||||
});
|
||||
});
|
||||
|
||||
function addNewRow(key, value) {
|
||||
key = key === undefined ? '' : key;
|
||||
value = value === undefined ? '' : value;
|
||||
$('#elementTableBody').append($('<tr></tr>').append(
|
||||
$('<td></td>').append($('<input type="text" class="elementKey"></input>').val(key)),
|
||||
$('<td></td>').append($('<input type="text" class="elementValue"></input>').val(value)),
|
||||
$('<td></td>').append('<buton type="button" class="btn btn-danger btn-small" onclick="deleteCurrentRow(this)">×</buton>'),
|
||||
))
|
||||
}
|
||||
|
||||
function deleteCurrentRow(clicked) {
|
||||
$(clicked).closest('tr').remove();
|
||||
}
|
||||
|
||||
function parseTable() {
|
||||
var elements = [];
|
||||
$('#elementTableBody > tr').each(function(i, row) {
|
||||
row = $(row);
|
||||
elements.push({
|
||||
key: row.find('.elementKey').val(),
|
||||
value: row.find('.elementValue').val()
|
||||
});
|
||||
})
|
||||
return elements;
|
||||
}
|
||||
|
||||
function fillTable(dict) {
|
||||
dict.forEach(function(entry) {
|
||||
addNewRow(entry.key, entry.value);
|
||||
})
|
||||
}
|
||||
</script>
|
|
@ -73,6 +73,9 @@
|
|||
'label' => __("Galaxy Cluster Elements"),
|
||||
'type' => 'textarea',
|
||||
),
|
||||
),
|
||||
'metaFields' => array(
|
||||
$this->element('/GalaxyClusters/clusterElementUI', array('elements' => $this->request->data['GalaxyCluster']['elementsDict']))
|
||||
)
|
||||
)
|
||||
));
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
$extendedFromHtml = sprintf('<ul>%s</ul>', implode('', $extendFromLinks));
|
||||
if ($newVersionAvailable) {
|
||||
$extendedFromHtml .= sprintf('<div class="alert alert-danger">%s</div>', sprintf(__('New version available! <a href="%s">Update cluster to version <b>%s</b></a>'),
|
||||
'/galaxy_cluster/updateCluster/' . $cluster['GalaxyCluster']['id'],
|
||||
'/galaxy_clusters/updateCluster/' . $cluster['GalaxyCluster']['id'],
|
||||
h($cluster['GalaxyCluster']['extended_from']['GalaxyCluster']['version'])
|
||||
));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue