Skip to content

Commit 49c0973

Browse files
Added download buttons (#26)
1 parent 408ae51 commit 49c0973

File tree

4 files changed

+51
-12
lines changed

4 files changed

+51
-12
lines changed

src/main/java/com/ericsson/ei/frontend/EIRequestsController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public ResponseEntity<String> getAuthRequests(Model model, HttpServletRequest re
124124
*/
125125
@CrossOrigin
126126
@RequestMapping(value = { "/subscriptions", "/subscriptions/*", "/information", "/auth",
127-
"/auth/checkStatus", "/auth/logout", "/download/subscriptiontemplate" }, method = RequestMethod.GET)
127+
"/auth/checkStatus", "/auth/logout", "/download/*" }, method = RequestMethod.GET)
128128
public ResponseEntity<String> getRequests(Model model, HttpServletRequest request) {
129129
String eiBackendAddressSuffix = request.getServletPath();
130130
String newRequestUrl = getEIBackendSubscriptionAddress() + eiBackendAddressSuffix;

src/main/resources/static/js/subscription.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,15 +465,16 @@ jQuery(document).ready(function() {
465465
$('.container').on( 'click', 'button.get_subscription_template', function (event) {
466466
event.stopPropagation();
467467
event.preventDefault();
468-
function getTemplate(){
468+
function getTemplate() {
469469
var req = new XMLHttpRequest();
470-
req.open("GET", '/download/subscriptiontemplate', true);
470+
req.open("GET", '/download/subscriptionsTemplate', true);
471471
req.responseType = "application/json;charset=utf-8";
472472
req.onload = function (event) {
473473
var jsonData = JSON.stringify(JSON.parse(req.response), null, 2);
474474
downloadFile(jsonData, "application/json;charset=utf-8", "subscriptionsTemplate.json");
475475
};
476-
req.send();}
476+
req.send();
477+
}
477478
getTemplate();
478479
});
479480
// /END ## get_subscription_template #################################################

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,4 +343,31 @@ jQuery(document).ready(
343343
}
344344

345345
});
346-
});
346+
347+
function getTemplate(name) {
348+
var request = new XMLHttpRequest();
349+
request.open("GET", '/download/' + name, true);
350+
request.responseType = "application/json;charset=utf-8";
351+
request.onload = function (event) {
352+
var jsonData = JSON.stringify(JSON.parse(request.response), null, 2);
353+
downloadFile(jsonData, "application/json;charset=utf-8", name + ".json");
354+
};
355+
request.send();
356+
}
357+
358+
// Download the rules template
359+
$('.container').on('click', 'button.download_rules_template', function(event) {
360+
event.stopPropagation();
361+
event.preventDefault();
362+
getTemplate("rulesTemplate");
363+
});
364+
365+
// Download the events template
366+
$('.container').on('click', 'button.download_events_template', function(event) {
367+
event.stopPropagation();
368+
event.preventDefault();
369+
getTemplate("eventsTemplate");
370+
});
371+
372+
}
373+
);

src/main/resources/templates/testRules.html

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@
1616
<h1>Test Rules</h1>
1717
</div>
1818
<p>
19-
<span style="color: #333333; background-color: #ffff00;">Upload Rules and events are in json list, Ex
20-
: [{},{}]</span>
19+
<span style="color: #333333; background-color: #ffff00;">Upload Rules and events are in json list, Ex: [{},{}]</span>
2120
</p>
2221
<div class="row" style="max-height: 950; padding: 10px">
2322
<div class="col-6 border border-right border-success" id="testRulesDOMObject" style="padding: 10px">
2423
<div class="row butt divpad">
25-
<div class="col-3">
24+
<div style="padding: 10px">
2625
<button data-toggle="tooltip" title="Upload List of Rules" class="btn btn-primary upload_rules">
2726
Upload Rules <i class="fa fa-fw fa-upload"></i>
2827
</button>
2928
<input class="hidden" type='file' id='upload_rules_file' name='file' style="display: none" />
3029
</div>
31-
<div class="col-6">
30+
<div style="padding: 10px">
31+
<button data-toggle="tooltip" title="Download rules template"
32+
class="btn btn-primary download_rules_template">
33+
Get Template <i class="fa fa-fw fa-download"></i>
34+
</button>
35+
</div>
36+
<div style="padding: 10px">
3237
<button data-toggle="tooltip" title="Find the aggregated object" class="btn btn-primary"
3338
data-bind="click : $root.addRule.bind()">
3439
Add Rule<i class="fa fa-fw fa-plus"></i>
@@ -56,14 +61,20 @@ <h3>Rules</h3>
5661
<div class="col-6 border border-right border-success" id="testEventsDOMObject"
5762
style="max-height: 100%; padding: 10px">
5863
<div class="row butt divpad">
59-
<div class="col-4">
64+
<div style="padding: 10px">
6065
<button data-toggle="tooltip" title="Upload List of events"
6166
class="btn btn-primary upload_events">
6267
Upload Events <i class="fa fa-fw fa-upload"></i>
6368
</button>
64-
<input class="hidden" type='file' id='upload_rules_file' name='file' style="display: none" />
69+
<input class="hidden" type='file' id='upload_events_file' name='file' style="display: none" />
70+
</div>
71+
<div style="padding: 10px">
72+
<button data-toggle="tooltip" title="Download events template"
73+
class="btn btn-primary download_events_template">
74+
Get Template <i class="fa fa-fw fa-download"></i>
75+
</button>
6576
</div>
66-
<div class="col-6">
77+
<div style="padding: 10px">
6778
<button data-toggle="tooltip" title="Find the aggregated object" class="btn btn-primary"
6879
data-bind="click : $root.addEvent.bind()">
6980
Add Event<i class="fa fa-fw fa-plus"></i>

0 commit comments

Comments
 (0)