Skip to content

Commit 5d51a4e

Browse files
Fixed few ajax calls regarding to improves in REST API (#44)
1 parent d7b2296 commit 5d51a4e

File tree

3 files changed

+28
-27
lines changed

3 files changed

+28
-27
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
@@ -190,7 +190,7 @@ private ResponseEntity<String> getResponse(HttpRequestBase request) {
190190
try (CloseableHttpResponse eiResponse = client.execute(request)) {
191191
responseBody = StringUtils.defaultIfBlank(EntityUtils.toString(eiResponse.getEntity(), "utf-8"), "[]");
192192
statusCode = eiResponse.getStatusLine().getStatusCode();
193-
LOG.info("EI Http response status code: " + eiResponse.getStatusLine().getStatusCode()
193+
LOG.info("EI Http response status code: " + statusCode
194194
+ "\nEI Received response body:\n" + responseBody
195195
+ "\nForwarding response back to EI Frontend WebUI.");
196196
} catch (IOException e) {

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,36 +131,35 @@ jQuery(document).ready(function() {
131131
}
132132

133133
function getInstanceInfo() {
134-
var eiInfoContainer = document.getElementById('eiInfoContainer');
135134
$.ajax({
136135
url: frontendServiceUrl + "/information",
137136
contentType : 'application/json;charset=UTF-8',
138137
type: 'GET',
139138
error : function (XMLHttpRequest, textStatus, errorThrown) {
140-
document.getElementById('info_text').innerHTML = errorThrown;
139+
if (XMLHttpRequest.responseText == "") {
140+
document.getElementById("eiPageFrame").innerHTML = "<h3 style=\"text-align: center;\">There is no response from backend</h3>";
141+
} else {
142+
document.getElementById("eiPageFrame").innerHTML = "<h3 style=\"text-align: center;\">" + XMLHttpRequest.responseText + "</h3>";
143+
}
141144
},
142145
success : function (data, textStatus, xhr) {
143-
146+
var eiInfoContainer = document.getElementById('eiInfoContainer');
147+
var data = JSON.parse(xhr.responseText);
148+
generateGeneralEiInfo(data);
149+
generateEIInformationBasedOnList(data.rabbitmq, "Eiffel Intelligence Connected RabbitMq Instances");
150+
generateEIInformationBasedOnList(data.mongodb, "Eiffel Intelligence Connected MongoDb Instances");
151+
generateEIInformationBasedOnList(data.threads, "Eiffel Intelligence Backend Java Threads Settings");
152+
generateEIInformationBasedOnList(data.email, "Eiffel Intelligence Backend E-Mail Settings");
153+
generateEIInformationBasedOnList(data.mailServerValues, "Eiffel Intelligence Backend SMTP Settings");
154+
generateEIInformationBasedOnList(data.waitList, "Eiffel Intelligence Backend WaitList settings");
155+
generateEIInformationBasedOnList([data.objectHandler], "Eiffel Intelligence Backend ObjectHandler Settings");
156+
generateEIInformationBasedOnList([data.subscriptionHandler], "Eiffel Intelligence Backend SubscriptionHandler Settings");
157+
generateEIInformationBasedOnList([data.informSubscription], "Eiffel Intelligence Backend InformSubscription Settings");
158+
generateEIInformationBasedOnList([data.erUrl], "Eiffel Intelligence Backend EventRepository Url");
159+
generateEIInformationBasedOnList([data.ldap], "Eiffel Intelligence Backend LDAP Settings");
144160
},
145-
complete: function (XMLHttpRequest, textStatus) {
146-
var data = JSON.parse(XMLHttpRequest.responseText);
147-
148-
generateGeneralEiInfo(data);
149-
150-
generateEIInformationBasedOnList(data.rabbitmq, "Eiffel Intelligence Connected RabbitMq Instances");
151-
generateEIInformationBasedOnList(data.mongodb, "Eiffel Intelligence Connected MongoDb Instances");
152-
generateEIInformationBasedOnList(data.threads, "Eiffel Intelligence Backend Java Threads Settings");
153-
generateEIInformationBasedOnList(data.email, "Eiffel Intelligence Backend E-Mail Settings");
154-
generateEIInformationBasedOnList(data.mailServerValues, "Eiffel Intelligence Backend SMTP Settings");
155-
generateEIInformationBasedOnList(data.waitList, "Eiffel Intelligence Backend WaitList settings");
156-
generateEIInformationBasedOnList([data.objectHandler], "Eiffel Intelligence Backend ObjectHandler Settings");
157-
generateEIInformationBasedOnList([data.subscriptionHandler], "Eiffel Intelligence Backend SubscriptionHandler Settings");
158-
generateEIInformationBasedOnList([data.informSubscription], "Eiffel Intelligence Backend InformSubscription Settings");
159-
generateEIInformationBasedOnList([data.erUrl], "Eiffel Intelligence Backend EventRepository Url");
160-
generateEIInformationBasedOnList([data.ldap], "Eiffel Intelligence Backend LDAP Settings");
161-
}
161+
complete: function (XMLHttpRequest, textStatus) {}
162162
});
163-
164163
}
165164

166165
getInstanceInfo();

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ jQuery(document).ready(function() {
5151
var green="#00ff00";
5252
$.ajax({
5353
url: frontendServiceUrl + "/auth/checkStatus",
54-
contentType: 'application/json; charset=utf-8',
55-
type: 'GET',
56-
error: function (XMLHttpRequest) {
57-
if(XMLHttpRequest.status == 401) {
54+
type: "GET",
55+
contentType: "application/string; charset=utf-8",
56+
dataType: "text",
57+
cache: false,
58+
error: function (XMLHttpRequest, textStatus, errorThrown) {
59+
if (XMLHttpRequest.status == 401) {
5860
doIfUserLoggedOut();
5961
EIConnBtn.style.background = green;
6062
backendStatus = true;
@@ -63,7 +65,7 @@ jQuery(document).ready(function() {
6365
backendStatus = false;
6466
}
6567
},
66-
success: function () {
68+
success: function (data, textStatus) {
6769
EIConnBtn.style.background = green;
6870
backendStatus = true;
6971
}

0 commit comments

Comments
 (0)