Skip to content

Commit 59009e4

Browse files
Add button to download events (#98)
1 parent 719683a commit 59009e4

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/main/resources/static/js/testrules.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,25 @@ jQuery(document).ready(
282282
}
283283
});
284284

285+
// Download the modified events
286+
$('.container').on('click', 'button.download_events', function() {
287+
var formEvents = [];
288+
$('.formEvents').each(function() {
289+
try {
290+
formEvents.push(JSON.parse($(this).val()));
291+
} catch (e) {
292+
window.logMessages("Invalid json format :\n" + $(this).val());
293+
return false;
294+
}
295+
});
296+
if (formEvents.length !== 0) {
297+
var jsonData = JSON.stringify(formEvents, null, 2);
298+
downloadFile(jsonData, "application/json;charset=utf-8", "events.json");
299+
} else {
300+
window.logMessages("Data not available for download!");
301+
}
302+
});
303+
285304
function getTemplate(name) {
286305
var request = new XMLHttpRequest();
287306
request.open("GET", frontendServiceUrl + '/download/' + name, true);

src/main/resources/templates/testRules.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,21 @@ <h6>
102102
</div>
103103
<div class="row-fluid divpad" id="submitButton">
104104
<div class="row">
105-
<div class="col-5">
105+
<div class="col-4">
106106
<button class="btn btn-success download_rules white-space-normal">
107107
Download Rules
108108
<i class="fa fa-fw fa-download"></i>
109109
</button>
110110
</div>
111-
<div class="col-7">
111+
<div class="col-4 text-center">
112112
<button class="btn btn-success find_aggregated_object white-space-normal" data-bind="click : $root.submit.bind($data)">Find Aggregated Object</button>
113113
</div>
114+
<div class="col-4">
115+
<button class="btn btn-success download_events white-space-normal float-right">
116+
Download Events
117+
<i class="fa fa-fw fa-download"></i>
118+
</button>
119+
</div>
114120
</div>
115121
</div>
116122
</div>

0 commit comments

Comments
 (0)