2019-01-25 16:54:44 +01:00
|
|
|
<div id="eventFilteringQBWrapper" style="padding: 5px; display: none; border: 1px solid #dddddd; border-bottom: 0px;">
|
|
|
|
<div id="eventFilteringQB"></div>
|
2019-01-30 11:58:16 +01:00
|
|
|
<div style="display: flex; justify-content: flex-end">
|
2019-02-13 14:59:49 +01:00
|
|
|
<input id="eventFilteringQBLinkInput" class="form-control" style="width: 66%;"></input>
|
|
|
|
<button id="eventFilteringQBLinkCopy" type="button" class="btn btn-inverse" style="margin-right: 5px; margin-left: 5px;" onclick="clickMessage(this);"> <i class="fa fa-clipboard"></i> <?php echo h('Copy to clipboard'); ?> </button>
|
2019-02-13 15:39:41 +01:00
|
|
|
<button id="eventFilteringQBSubmit" type="button" class="btn btn-success" style="margin-right: 5px;"> <i class="fa fa-filter"></i> <?php echo h('Filter'); ?> </button>
|
2019-02-13 14:59:49 +01:00
|
|
|
<button id="eventFilteringQBClear" type="button" class="btn btn-xs btn-danger" style="" title="<?php echo h('Clear filtering rules'); ?>"> <i class="fa fa-times"></i> <?php echo h('Clear'); ?> </button>
|
2019-01-30 11:58:16 +01:00
|
|
|
</div>
|
2019-01-25 16:54:44 +01:00
|
|
|
</div>
|
2019-01-29 11:49:06 +01:00
|
|
|
<?php
|
|
|
|
?>
|
2019-01-25 16:54:44 +01:00
|
|
|
|
|
|
|
<script>
|
|
|
|
function triggerEventFilteringTool(clicked) {
|
2019-02-13 14:59:49 +01:00
|
|
|
var defaultFilteringRules = <?php echo json_encode($defaultFilteringRules); ?>;
|
2019-01-29 11:49:06 +01:00
|
|
|
var qbOptions = {
|
|
|
|
plugins: {
|
|
|
|
'filter-description' : {
|
|
|
|
mode: 'inline'
|
|
|
|
},
|
|
|
|
'unique-filter': null,
|
|
|
|
'bt-tooltip-errors': null,
|
|
|
|
},
|
|
|
|
allow_empty: true,
|
|
|
|
lang: {
|
|
|
|
operators: {
|
|
|
|
equal: 'show',
|
|
|
|
in: 'show'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
"input": "select",
|
|
|
|
"type": "string",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "attributeFilter",
|
|
|
|
"label": "Category",
|
|
|
|
"values": {
|
|
|
|
"file": "File",
|
|
|
|
"network": "Network",
|
|
|
|
"financial": "Financial",
|
|
|
|
"all": "All"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "proposal",
|
|
|
|
"label": "Proposal",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Proposal only",
|
|
|
|
2: "Exclude proposal"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "correlation",
|
|
|
|
"label": "Correlation",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Correlation only",
|
|
|
|
2: "Exclude correlation"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "warning",
|
|
|
|
"label": "Warning",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Warning only",
|
|
|
|
2: "Exclude warning"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "deleted",
|
|
|
|
"label": "Deleted",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Deleted only",
|
|
|
|
2: "Exclude deleted"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "includeRelatedTags",
|
|
|
|
"label": "Related Tags",
|
|
|
|
"values": {
|
|
|
|
0: "None",
|
|
|
|
1: "Yes"
|
|
|
|
}
|
|
|
|
},
|
2019-02-15 16:28:04 +01:00
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "toIDS",
|
|
|
|
"label": "IDS Flag",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Set only",
|
|
|
|
2: "Exclude Unset"
|
|
|
|
}
|
|
|
|
},
|
2019-02-13 11:30:05 +01:00
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "feed",
|
|
|
|
"label": "Feeds",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Feed hits only",
|
|
|
|
2: "Exclude feed hits"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"input": "radio",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "server",
|
|
|
|
"label": "Servers",
|
|
|
|
"values": {
|
|
|
|
0: "Both",
|
|
|
|
1: "Server hits only",
|
|
|
|
2: "Exclude server hits"
|
|
|
|
}
|
|
|
|
},
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
"input": "checkbox",
|
|
|
|
"type": "integer",
|
|
|
|
"operators": [
|
|
|
|
"in"
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "distribution",
|
|
|
|
"label": "Distribution",
|
|
|
|
"values": {
|
|
|
|
0: "Your orginisation only",
|
|
|
|
1: "This community only",
|
|
|
|
2: "Connected community",
|
|
|
|
3: "All communities",
|
|
|
|
4: "Sharing group",
|
2019-01-31 16:22:11 +01:00
|
|
|
5: "Inherit",
|
2019-01-29 11:49:06 +01:00
|
|
|
}
|
|
|
|
},
|
2019-02-13 11:30:05 +01:00
|
|
|
<?php if (!empty($attributeTags)): ?>
|
2019-02-08 10:21:21 +01:00
|
|
|
{
|
|
|
|
"input": "select",
|
|
|
|
"type": "string",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "taggedAttributes",
|
|
|
|
"label": "Tags",
|
2019-02-13 11:30:05 +01:00
|
|
|
"values": <?php echo json_encode($attributeTags); ?>
|
2019-02-08 10:21:21 +01:00
|
|
|
},
|
2019-02-13 11:30:05 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($attributeClusters)): ?>
|
2019-02-08 10:21:21 +01:00
|
|
|
{
|
|
|
|
"input": "select",
|
|
|
|
"type": "string",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
|
|
|
"unique": true,
|
|
|
|
"id": "galaxyAttachedAttributes",
|
|
|
|
"label": "Galaxies",
|
2019-02-13 11:30:05 +01:00
|
|
|
"values": <?php echo json_encode($attributeClusters); ?>
|
2019-02-08 10:21:21 +01:00
|
|
|
},
|
2019-02-13 11:30:05 +01:00
|
|
|
<?php endif; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
"input": "text",
|
|
|
|
"type": "string",
|
|
|
|
"operators": [
|
|
|
|
"equal",
|
|
|
|
],
|
2019-02-04 13:28:41 +01:00
|
|
|
"unique": true,
|
2019-01-29 11:49:06 +01:00
|
|
|
"id": "searchFor",
|
|
|
|
"label": "Search in Attribute",
|
|
|
|
<?php
|
|
|
|
$searchableFields = array('id', 'uuid', 'value', 'comment', 'type', 'category', 'Tag.name');
|
|
|
|
$searchableFields = implode(', ', $searchableFields);
|
|
|
|
?>
|
2019-02-04 08:31:18 +01:00
|
|
|
"description": "Searchable Attribute fields: <b><?php echo h($searchableFields); ?></b>",
|
2019-01-29 11:49:06 +01:00
|
|
|
"validation": {
|
|
|
|
"allow_empty_value": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
],
|
2019-01-30 14:15:05 +01:00
|
|
|
rules: {
|
2019-01-29 11:49:06 +01:00
|
|
|
condition: 'AND',
|
|
|
|
not: false,
|
|
|
|
rules: [
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['searchFor'])): ?>
|
2019-01-30 14:37:07 +01:00
|
|
|
{
|
|
|
|
field: 'searchFor',
|
2019-01-31 14:39:24 +01:00
|
|
|
id: 'searchFor',
|
2019-02-04 08:31:18 +01:00
|
|
|
value: $('<div />').html("<?php echo isset($filters['searchFor']) ? h($filters['searchFor']) : ''; ?>").text()
|
2019-01-30 14:37:07 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['attributeFilter'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'attributeFilter',
|
|
|
|
id: 'attributeFilter',
|
2019-01-31 14:39:24 +01:00
|
|
|
<?php if (isset($filters['attributeFilter'])): ?>
|
2019-02-04 08:31:18 +01:00
|
|
|
value: "<?php echo in_array($filters['attributeFilter'], array('all', 'network', 'financial', 'file')) ? h($filters['attributeFilter']) : 'all'; ?>"
|
2019-01-31 14:39:24 +01:00
|
|
|
<?php else: ?>
|
|
|
|
value: "<?php echo 'all'; ?>"
|
|
|
|
<?php endif; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['proposal'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'proposal',
|
|
|
|
id: 'proposal',
|
2019-02-04 08:31:18 +01:00
|
|
|
value: <?php echo isset($filters['proposal']) ? h($filters['proposal']) : 0; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['correlation'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'correlation',
|
|
|
|
id: 'correlation',
|
2019-02-04 08:31:18 +01:00
|
|
|
value: <?php echo isset($filters['correlation']) ? h($filters['correlation']) : 0; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['warning'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'warning',
|
|
|
|
id: 'warning',
|
2019-02-04 08:31:18 +01:00
|
|
|
value: <?php echo isset($filters['warning']) ? h($filters['warning']) : 0; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['deleted'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'deleted',
|
|
|
|
id: 'deleted',
|
2019-02-04 08:31:18 +01:00
|
|
|
value: <?php echo isset($filters['deleted']) ? h($filters['deleted']) : 2; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['includeRelatedTags'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'includeRelatedTags',
|
|
|
|
id: 'includeRelatedTags',
|
2019-02-04 08:31:18 +01:00
|
|
|
value: <?php echo isset($filters['includeRelatedTags']) ? h($filters['includeRelatedTags']) : 0; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
2019-02-15 16:28:04 +01:00
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['toIDS'])): ?>
|
|
|
|
{
|
|
|
|
field: 'toIDS',
|
|
|
|
id: 'toIDS',
|
|
|
|
value: <?php echo isset($filters['toIDS']) ? h($filters['toIDS']) : 0; ?>
|
|
|
|
},
|
|
|
|
<?php endif; ?>
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['feed'])): ?>
|
2019-02-13 11:30:05 +01:00
|
|
|
{
|
|
|
|
field: 'feed',
|
|
|
|
id: 'feed',
|
|
|
|
value: <?php echo isset($filters['feed']) ? h($filters['feed']) : 0; ?>
|
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['server'])): ?>
|
2019-02-13 11:30:05 +01:00
|
|
|
{
|
|
|
|
field: 'server',
|
|
|
|
id: 'server',
|
|
|
|
value: <?php echo isset($filters['server']) ? h($filters['server']) : 0; ?>
|
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['distribution'])): ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
{
|
|
|
|
field: 'distribution',
|
|
|
|
id: 'distribution',
|
|
|
|
operator: 'in',
|
2019-01-31 16:22:11 +01:00
|
|
|
value: <?php echo isset($filters['distribution']) ? json_encode($filters['distribution']) : json_encode(array(0, 1, 2, 3, 4, 5)); ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
},
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($attributeTags) && (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['taggedAttributes']))): ?>
|
2019-02-08 10:21:21 +01:00
|
|
|
{
|
|
|
|
field: 'taggedAttributes',
|
|
|
|
id: 'taggedAttributes',
|
2019-02-13 14:59:49 +01:00
|
|
|
value: '<?php echo isset($filters['taggedAttributes']) ? h($filters['taggedAttributes']) : $attributeTags[0]; ?>'
|
2019-02-08 10:21:21 +01:00
|
|
|
},
|
2019-02-13 11:30:05 +01:00
|
|
|
<?php endif; ?>
|
2019-02-13 14:59:49 +01:00
|
|
|
<?php if (!empty($attributeClusters) && (count($advancedFilteringActiveRules) == 0 || isset($advancedFilteringActiveRules['galaxyAttachedAttributes']))): ?>
|
2019-02-08 10:21:21 +01:00
|
|
|
{
|
|
|
|
field: 'galaxyAttachedAttributes',
|
|
|
|
id: 'galaxyAttachedAttributes',
|
2019-02-13 14:59:49 +01:00
|
|
|
value: '<?php echo isset($filters['galaxyAttachedAttributes']) ? h($filters['galaxyAttachedAttributes']) : $attributeClusters[0]; ?>'
|
2019-02-08 10:21:21 +01:00
|
|
|
},
|
2019-02-13 11:30:05 +01:00
|
|
|
<?php endif; ?>
|
2019-01-29 11:49:06 +01:00
|
|
|
],
|
|
|
|
flags: {
|
2019-01-30 14:15:05 +01:00
|
|
|
no_add_group: true,
|
|
|
|
condition_readonly: true,
|
2019-01-29 11:49:06 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
icons: {
|
|
|
|
add_group: 'fa fa-plus-square',
|
|
|
|
add_rule: 'fa fa-plus-circle',
|
|
|
|
remove_group: 'fa fa-minus-square',
|
|
|
|
remove_rule: 'fa fa-minus-circle',
|
|
|
|
error: 'fa fa-exclamation-triangle'
|
|
|
|
},
|
|
|
|
};
|
2019-01-25 16:54:44 +01:00
|
|
|
|
2019-01-31 14:39:24 +01:00
|
|
|
var filters = <?php echo json_encode($filters); ?>;
|
2019-01-29 11:49:06 +01:00
|
|
|
var $wrapper = $('#eventFilteringQBWrapper');
|
|
|
|
var $ev = $('#eventFilteringQB');
|
|
|
|
var querybuilderTool = $ev.queryBuilder(qbOptions);
|
|
|
|
querybuilderTool = querybuilderTool[0].queryBuilder;
|
2019-01-30 11:58:16 +01:00
|
|
|
|
|
|
|
querybuilderTool.on('rulesChanged', function() {
|
|
|
|
updateURL();
|
|
|
|
});
|
2019-01-29 11:49:06 +01:00
|
|
|
$wrapper.toggle('blind', 100, { direction: 'up' });
|
|
|
|
|
|
|
|
$('#eventFilteringQBSubmit').off('click').on('click', function() {
|
|
|
|
$button = $(this);
|
2019-01-30 14:38:24 +01:00
|
|
|
var rules = querybuilderTool.getRules({ skip_empty: true, allow_invalid: true });
|
2019-01-29 11:49:06 +01:00
|
|
|
performQuery(rules);
|
|
|
|
});
|
|
|
|
|
2019-01-30 11:58:16 +01:00
|
|
|
$('#eventFilteringQBLinkCopy').off('click').on('click', function() {
|
|
|
|
copyToClipboard($('#eventFilteringQBLinkInput'));
|
|
|
|
});
|
2019-02-01 11:47:10 +01:00
|
|
|
|
2019-02-13 14:59:49 +01:00
|
|
|
$('#eventFilteringQBClear').off('click').on('click', function() {
|
|
|
|
// querybuilderTool.setRules({condition: "AND", rules: []});
|
|
|
|
querybuilderTool.reset();
|
|
|
|
$('#eventFilteringQB').queryBuilder('reset');
|
|
|
|
});
|
|
|
|
|
2019-02-01 11:47:10 +01:00
|
|
|
$ev.off('keyup').on('keyup', function(e){
|
|
|
|
if(e.keyCode == 13) {
|
|
|
|
$('#eventFilteringQBSubmit').trigger("click");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-01-30 11:58:16 +01:00
|
|
|
updateURL();
|
2019-01-29 11:49:06 +01:00
|
|
|
|
2019-01-30 11:58:16 +01:00
|
|
|
function updateURL() {
|
2019-01-30 14:37:07 +01:00
|
|
|
var rules = querybuilderTool.getRules({ skip_empty: true, allow_invalid: true });
|
2019-01-30 11:58:16 +01:00
|
|
|
var res = cleanRules(rules);
|
2019-02-01 16:22:18 +01:00
|
|
|
var url = "<?php echo $baseurl; ?>/events/view/<?php echo h($event['Event']['id']); ?>" + buildURL(res);
|
2019-01-30 11:58:16 +01:00
|
|
|
$('#eventFilteringQBLinkInput').val(url);
|
|
|
|
}
|
|
|
|
|
2019-01-29 11:49:06 +01:00
|
|
|
function buildURL(res) {
|
2019-01-30 11:58:16 +01:00
|
|
|
var url = "";
|
2019-01-29 11:49:06 +01:00
|
|
|
Object.keys(res).forEach(function(k) {
|
|
|
|
var v = res[k];
|
2019-01-31 14:39:24 +01:00
|
|
|
if (Array.isArray(v)) {
|
|
|
|
// v = JSON.stringify(v);
|
|
|
|
v = v.join('||');
|
|
|
|
}
|
2019-02-13 14:59:49 +01:00
|
|
|
if (!Array.isArray(defaultFilteringRules[k]) && defaultFilteringRules[k] != v) {
|
|
|
|
url += "/" + k + ":" + v;
|
|
|
|
} else {
|
|
|
|
if (Array.isArray(defaultFilteringRules[k]) && defaultFilteringRules[k].join('||') != v) {
|
|
|
|
url += "/" + k + ":" + v;
|
|
|
|
}
|
|
|
|
}
|
2019-01-29 11:49:06 +01:00
|
|
|
});
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2019-02-04 16:19:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function recursiveInject(result, rules) {
|
|
|
|
if (rules.rules === undefined) { // add to result
|
|
|
|
var field = rules.field;
|
|
|
|
var value = rules.value;
|
|
|
|
if (result.hasOwnProperty(field)) {
|
|
|
|
if (Array.isArray(result[field])) {
|
|
|
|
result[field].push(value);
|
|
|
|
} else {
|
|
|
|
result[field] = [result[field], value];
|
2019-01-29 11:49:06 +01:00
|
|
|
}
|
2019-02-04 16:19:11 +01:00
|
|
|
} else {
|
|
|
|
result[field] = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Array.isArray(rules.rules)) {
|
|
|
|
rules.rules.forEach(function(subrules) {
|
|
|
|
recursiveInject(result, subrules) ;
|
2019-01-29 11:49:06 +01:00
|
|
|
});
|
2019-01-30 11:58:16 +01:00
|
|
|
}
|
2019-02-04 16:19:11 +01:00
|
|
|
}
|
2019-01-29 11:49:06 +01:00
|
|
|
|
2019-02-04 16:19:11 +01:00
|
|
|
function cleanRules(rules) {
|
|
|
|
var res = {};
|
|
|
|
recursiveInject(res, rules);
|
|
|
|
// clean up invalid and unset
|
|
|
|
Object.keys(res).forEach(function(k) {
|
|
|
|
var v = res[k];
|
|
|
|
if (v === undefined || v === '') {
|
|
|
|
delete res[k];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return res;
|
|
|
|
}
|
2019-01-29 11:49:06 +01:00
|
|
|
|
2019-02-04 16:19:11 +01:00
|
|
|
function performQuery(rules) {
|
|
|
|
var res = cleanRules(rules);
|
2019-01-30 11:58:16 +01:00
|
|
|
|
2019-02-04 16:19:11 +01:00
|
|
|
var url = "/events/viewEventAttributes/<?php echo h($event['Event']['id']); ?>";
|
|
|
|
$.ajax({
|
|
|
|
type:"post",
|
|
|
|
url: url,
|
|
|
|
data: res,
|
|
|
|
beforeSend: function (XMLHttpRequest) {
|
|
|
|
$(".loading").show();
|
|
|
|
},
|
|
|
|
success:function (data) {
|
|
|
|
$("#attributes_div").html(data);
|
|
|
|
$(".loading").hide();
|
|
|
|
},
|
|
|
|
error:function() {
|
|
|
|
showMessage('fail', 'Something went wrong - could not fetch attributes.');
|
|
|
|
}
|
|
|
|
});
|
2019-01-30 11:58:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function copyToClipboard(element) {
|
|
|
|
var $temp = $("<input id='xxx'>");
|
|
|
|
$("body").append($temp);
|
|
|
|
$temp.val($(element).val()).select();
|
|
|
|
document.execCommand("copy");
|
|
|
|
$temp.remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
function clickMessage(clicked) {
|
|
|
|
$clicked = $(clicked);
|
|
|
|
$clicked.tooltip({
|
|
|
|
title: 'Copied!',
|
|
|
|
trigger: 'manual',
|
|
|
|
container: 'body'
|
|
|
|
})
|
|
|
|
.tooltip('show');
|
|
|
|
setTimeout(function () {
|
|
|
|
$clicked.tooltip('destroy');
|
|
|
|
}, 2000);
|
2019-01-25 16:54:44 +01:00
|
|
|
}
|
|
|
|
</script>
|