ctubbsii commented on code in PR #2679:
URL: https://github.com/apache/accumulo/pull/2679#discussion_r868313863
##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js:
##########
@@ -256,24 +256,50 @@ function createTableCell(index, sortValue, showValue) {
'">' + showValue + '</td>';
}
+/**
+ * Builds console logging message for REST GET calls
+ * @param {string} REST url called
+ * @param {object} data returned from REST call
+ * @param {string} session storage/global variable to hold REST data
+ */
+ function createRestGetLog(call, data, sessionDataVar){
+ var jsonDataStr = JSON.stringify(data);
+
+ //Handle data to be stored in global variable instead of session storage
+ if (sessionDataVar==="NAMESPACES") {
+ NAMESPACES = jsonDataStr;
+ console.debug("REST GET call to " + call +
+ " stored in " + sessionDataVar + " = " + NAMESPACES);
+ }
+ else {
+ sessionStorage[sessionDataVar] = jsonDataStr;
+ console.debug("REST GET request to " + call +
+ " stored in sessionStorage." + sessionDataVar + " = " +
sessionStorage[sessionDataVar]);
+ }
+ }
+
///// REST Calls /////////////
/**
* REST GET call for the manager information,
* stores it on a sessionStorage variable
*/
function getManager() {
- return $.getJSON('/rest/manager', function(data) {
- sessionStorage.manager = JSON.stringify(data);
+ var call = '/rest/manager';
+ console.info("Retrieving " + call);
+ return $.getJSON(call, function(data) {
+ createRestGetLog(call, data, 'manager');
});
}
Review Comment:
Since the same pattern is used repeatedly, this code could be simplified
even further, by replacing it with a new function, something like
`getJSONforTable('/rest/manager', 'manager');`
##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/functions.js:
##########
@@ -507,20 +563,25 @@ function getProblemDetails() {
* stores it on a sessionStorage variable
*/
function getReplication() {
- return $.getJSON('/rest/replication', function(data) {
- sessionStorage.replication = JSON.stringify(data);
+ var call = '/rest/replication';
+ console.info("Retrieving " + call);
+ return $.getJSON(call, function(data) {
+ createRestGetLog(call, data, 'replication');
});
}
//// Overview Plots Rest Calls
+//// Note: console.debug messages may not show by default in some browsers
Review Comment:
I think the logging level concept is pretty standard, so you probably don't
need this comment here.
```suggestion
```
Or, you could clarify that the choice of using debug was intentional:
```suggestion
//// Note: console.debug avoids spamming the console by default in browsers
that support it
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]