DomGarguilo commented on code in PR #2685:
URL: https://github.com/apache/accumulo/pull/2685#discussion_r870367542


##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/tservers.js:
##########
@@ -16,165 +16,115 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+/* JSLint global definitions */
+/*global
+    $, document, sessionStorage, getTServers, clearDeadServers, refreshNavBar,
+    getRecoveryList, bigNumberForQuantity, timeDuration, dateFormat
+*/
 "use strict";
 
-var tserversTable;
+var tserversTable, deadTServersTable, badTServersTable;
 var recoveryList = [];
 
 /**
- * Creates tservers initial table
+ * Checks if the given server is in the global recoveryList variable
+ * 
+ * @param {JSON} server json server object
+ * @returns true if the server is in the recoveryList, else false
  */
-$(document).ready(function() {
-
-  refreshRecoveryList();
-    
-    // Create a table for tserver list
-    tserversTable = $('#tservers').DataTable({
-      "ajax": {
-        "url": '/rest/tservers',
-        "dataSrc": "servers"
-      },
-      "stateSave": true,
-      "columnDefs": [
-          { "targets": "big-num",
-            "render": function ( data, type, row ) {
-              if(type === 'display') data = bigNumberForQuantity(data);
-              return data;
-            }
-          },
-          { "targets": "duration",
-            "render": function ( data, type, row ) {
-              if(type === 'display') data = timeDuration(data);
-              return data;
-            }
-          },
-          { "targets": "percent",
-            "render": function ( data, type, row ) {
-              if(type === 'display') data = Math.round(data * 100) + '%';
-              return data;
-            }
-          }
-        ],
-      "columns": [
-        { "data": "hostname",
-          "type": "html",
-          "render": function ( data, type, row, meta ) {
-            if(type === 'display') data = '<a href="/tservers?s=' + row.id + 
'">' + row.hostname + '</a>';
-            return data;
-          }
-        },
-        { "data": "tablets" },
-        { "data": "lastContact" },
-        { "data": "responseTime" },
-        { "data": "entries" },
-        { "data": "ingest" },
-        { "data": "query" },
-        { "data": "holdtime" },
-        { "data": "scansCombo" },
-        { "data": "minorCombo" },
-        { "data": "majorCombo" },
-        { "data": "indexCacheHitRate" },
-        { "data": "dataCacheHitRate" },
-        { "data": "osload" }
-      ],
-      "rowCallback": function (row, data, index) {
-        // reset background of each row
-        $(row).css('background-color', '');
-
-        // return if the current row's tserver is not recovering
-        if (!recoveryList.includes(data.hostname))
-          return;
-
-        // only show the caption if we know there are rows in the tservers 
table
-        $('#recovery-caption').show();
-
-        // highlight current row
-        console.log('Highlighting row index:' + index + ' tserver:' + 
data.hostname);
-        $(row).css('background-color', 'gold');
-      }
-    });
-    refreshTServers();
-});
+function serverIsInRecoveryList(server) {
+    return recoveryList.includes(server.hostname);
+}
 
 /**
- * Makes the REST calls, generates the tables with the new information
+ * Refreshes the list of recovering tservers and shows/hides the recovery 
caption
  */
-function refreshTServers() {
-  getTServers().then(function() {
-    refreshBadTServersTable();
-    refreshDeadTServersTable();
-    refreshRecoveryList();
-    refreshTServersTable();
-  });
+function refreshRecoveryList() {
+    getRecoveryList().then(function () {
+        // get list of recovering servers
+        recoveryList = [];
+        var data = sessionStorage.recoveryList === undefined ?
+                    [] : JSON.parse(sessionStorage.recoveryList);
+        data.recoveryList.forEach(function (entry) {
+            recoveryList.push(entry.server);
+        });
+
+        // get list of online tservers
+        data = sessionStorage.tservers === undefined ?
+                    [] : JSON.parse(sessionStorage.tservers).servers;
+
+        // show the recovery caption if its in the list of recovering servers
+        if (data.some(serverIsInRecoveryList)) {

Review Comment:
   Thanks. I'll go ahead and mess with the variable names then merge this in.



-- 
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]

Reply via email to