Skip to content

Commit

Permalink
Display client error message in tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Feb 7, 2020
1 parent 6ffb0c7 commit f9e0627
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public JsonElement serialize(LwM2mResponse src, Type typeOfSrc, JsonSerializatio
element.add("location", context.serialize(((CreateResponse) src).getLocation()));
}
}
if (src.isFailure() && src.getErrorMessage() != null && !src.getErrorMessage().isEmpty())
element.addProperty("errormessage", src.getErrorMessage());

return element;
}
Expand Down
19 changes: 11 additions & 8 deletions leshan-server-demo/src/main/resources/webapp/js/helper-services.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,26 @@ myModule.factory('helper', ["$filter", function($filter) {
var serviceInstance = {};

serviceInstance.handleResponse = function (response, lwm2mNode, successCallback) {
lwm2mNode.date = new Date();
lwm2mNode.date = new Date();
var formattedDate = $filter('date')(lwm2mNode.date, 'HH:mm:ss.sss');
if (!response.valid){
lwm2mNode.status = "INVALID";
lwm2mNode.status = "INVALID";
}else if (response.success){
lwm2mNode.status = "SUCCESS";
lwm2mNode.status = "SUCCESS";
}else {
lwm2mNode.status = "ERROR";
lwm2mNode.status = "ERROR";
}

if (response.valid)
lwm2mNode.tooltip = formattedDate + "<br/>" + response.status ;
lwm2mNode.tooltip = formattedDate + "<br/>" + response.status ;
else
lwm2mNode.tooltip = formattedDate + "<br/> Not LWM2M Code <br/>" + response.status;
lwm2mNode.tooltip = formattedDate + "<br/> Not LWM2M Code <br/>" + response.status;

if (response.errormessage)
lwm2mNode.tooltip = lwm2mNode.tooltip + "<br/>" + response.errormessage;

if (successCallback && response.success) {
successCallback(formattedDate);
successCallback(formattedDate);
}
};
return serviceInstance;
Expand Down

0 comments on commit f9e0627

Please sign in to comment.