Skip to content

Commit c736f3a

Browse files
Updated regarding to updates in REST API (#42)
1 parent 143b02a commit c736f3a

File tree

4 files changed

+31
-30
lines changed

4 files changed

+31
-30
lines changed

src/main/resources/static/js/eiInfo.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ jQuery(document).ready(function() {
108108
tbdy = document.createElement('tbody');
109109
tbl = createTable();
110110

111-
console.log(dataSubList);
112111
Object.keys(dataSubList).forEach(function(dataKey) {
113-
console.log(dataKey + " : " + dataSubList[dataKey]);
114112
var tr = document.createElement('tr');
115113
var tdKey = document.createElement('td');
116114
tdKey.setAttribute('width', tableTdKeyWidth);
@@ -146,8 +144,7 @@ jQuery(document).ready(function() {
146144
},
147145
complete: function (XMLHttpRequest, textStatus) {
148146
var data = JSON.parse(XMLHttpRequest.responseText);
149-
console.log(data);
150-
147+
151148
generateGeneralEiInfo(data);
152149

153150
generateEIInformationBasedOnList(data.rabbitmq, "Eiffel Intelligence Connected RabbitMq Instances");

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -420,23 +420,23 @@ jQuery(document).ready(function() {
420420

421421
// /Start ## Bulk delete#################################################
422422
$('.container').on( 'click', 'button.bulk_delete', function (event) {
423-
var subScriptionsToDelete = [];
423+
var subscriptionsToDelete = [];
424424
var data = table.rows().nodes();
425425
$.each(data, function (index, value) {
426426
if ($(this).find('input').prop('checked') == true){
427-
subScriptionsToDelete.push(table.row(index).data().subscriptionName)
427+
subscriptionsToDelete.push(table.row(index).data().subscriptionName)
428428
}
429429
});
430430

431431
// Check if no Subscription has been marked to be deleted.
432-
if ( subScriptionsToDelete.length < 1 ){
432+
if ( subscriptionsToDelete.length < 1 ){
433433
$.alert("No subscriptions has been marked to be deleted.");
434434
return;
435435
}
436436

437-
var subScriptionsToDeleteString = "";
438-
for (i=0; i < subScriptionsToDelete.length; i++) {
439-
subScriptionsToDeleteString += subScriptionsToDelete[i] + "\n";
437+
var subscriptionsToDeleteString = "";
438+
for (i=0; i < subscriptionsToDelete.length; i++) {
439+
subscriptionsToDeleteString += subscriptionsToDelete[i] + "\n";
440440
}
441441

442442
var callback = {
@@ -452,24 +452,25 @@ jQuery(document).ready(function() {
452452
reload_table();
453453
},
454454
error : function (XMLHttpRequest, textStatus, errorThrown) {
455-
$.jGrowl("Error: " + XMLHttpRequest.responseText, {
456-
sticky : true,
457-
theme : 'Error'
458-
});
455+
reload_table();
456+
var responseJSON = JSON.parse(XMLHttpRequest.responseText);
457+
for (var i = 0; i < responseJSON.length; i++) {
458+
$.jGrowl(responseJSON[i].subscription + " :: " + responseJSON[i].reason, {sticky: true, theme: 'Error'});
459+
}
459460
},
460461
complete : function () {
461462
}
462463
};
463464

464465
$.confirm({
465466
title: 'Confirm!',
466-
content: 'Are you sure you want to delete these subscriptions?<pre>' + subScriptionsToDeleteString,
467+
content: 'Are you sure you want to delete these subscriptions?<pre>' + subscriptionsToDeleteString,
467468
buttons: {
468469
confirm: function () {
469470
var ajaxHttpSender = new AjaxHttpSender();
470-
for (i=0; i < subScriptionsToDelete.length; i++){
471-
ajaxHttpSender.sendAjax(frontendServiceUrl + "/subscriptions/"+subScriptionsToDelete[i], "DELETE", null, callback);
472-
}
471+
// replace all /n with comma
472+
subscriptionsToDeleteString = subscriptionsToDeleteString.replace(new RegExp('\n', 'g'), ',').slice(0, -1);
473+
ajaxHttpSender.sendAjax(frontendServiceUrl + "/subscriptions/"+subscriptionsToDeleteString, "DELETE", null, callback);
473474
},
474475
cancel: function () {
475476
}
@@ -511,18 +512,20 @@ jQuery(document).ready(function() {
511512
success : function (data, textStatus) {
512513
var returnData = [data];
513514
if (returnData.length > 0) {
514-
$.jGrowl("Successful created subscription " + subscriptionJson.subscriptionName, {
515+
$.jGrowl("Subscriptions are successfully created", {
515516
sticky : false,
516517
theme : 'Error'
517518
});
518519
reload_table();
519520
}
520521
},
521522
error : function (XMLHttpRequest, textStatus, errorThrown) {
522-
$.jGrowl("Failed to create Subscription: " + subscriptionJson.subscriptionName + " Error: " + XMLHttpRequest.responseText, {
523-
sticky : false,
524-
theme : 'Error'
525-
});
523+
reload_table();
524+
$.jGrowl("Failed to create next Subscriptions", {sticky: false, theme: 'Error'});
525+
var responseJSON = JSON.parse(XMLHttpRequest.responseText);
526+
for (var i = 0; i < responseJSON.length; i++) {
527+
$.jGrowl(responseJSON[i].subscription + " :: " + responseJSON[i].reason, {sticky: true, theme: 'Error'});
528+
}
526529
},
527530
complete : function () {
528531
}
@@ -548,7 +551,7 @@ jQuery(document).ready(function() {
548551
theme : 'Notify'
549552
});
550553
var subscriptionJsonList = JSON.parse(fileContent);
551-
tryToCreateSubscription(subscriptionJsonList);
554+
tryToCreateSubscription(subscriptionJsonList);
552555
};
553556
reader.readAsText(subscriptionFile);
554557
}
@@ -653,6 +656,9 @@ jQuery(document).ready(function() {
653656
vm.subscription([]);
654657
// Map JSON to Model and observableArray
655658
var mappedPackageInfo = $.map(returnData, function (item) {
659+
if (item.foundSubscriptions != null) {
660+
item = item.foundSubscriptions;
661+
}
656662
// Defining Observable on all parameters in Requirements array(which is defined as ObservableArray)
657663
for (i=0; i < item[0].requirements.length; i++) {
658664
var conditions_array = [];
@@ -847,10 +853,10 @@ jQuery(document).ready(function() {
847853
}
848854
},
849855
error : function (XMLHttpRequest, textStatus, errorThrown) {
850-
$.jGrowl("Error: " + XMLHttpRequest.responseText, {
851-
sticky : true,
852-
theme : 'Error'
853-
});
856+
var responseJSON = JSON.parse(XMLHttpRequest.responseText);
857+
for (var i = 0; i < responseJSON.length; i++) {
858+
$.jGrowl(responseJSON[i].subscription + " :: " + responseJSON[i].reason, {sticky: true, theme: 'Error'});
859+
}
854860
},
855861
complete : function () {
856862
$('#btnSave').text('save'); //change button text

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ jQuery(document).ready(
161161
};
162162

163163
var ajaxHttpSender = new AjaxHttpSender();
164-
//console.log(JSON.stringify(JSON.parse('{"listRulesJson":' + JSON.stringify(formRules) + ',"listEventsJson":' + events.toString() + '}')));
165164
ajaxHttpSender.sendAjax(frontendServiceUrl + "/rules/rule-check/aggregation", "POST", JSON.stringify(JSON.parse('{"listRulesJson":'
166165
+ JSON.stringify(formRules) + ',"listEventsJson":' + JSON.stringify(formEvents) + '}')), callback);
167166
};

src/test/java/com/ericsson/ei/frontend/WebControllerTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ private void testGet(String path) throws Exception {
9191
.andExpect(status().isOk())
9292
.andExpect(content().contentType("text/html;charset=UTF-8"))
9393
.andExpect(model().attribute("frontendServiceUrl", "http://localhost:9090/somePath"))
94-
.andDo(print())
9594
.andReturn();
9695
}
9796

0 commit comments

Comments
 (0)