kevinrr888 commented on code in PR #4986:
URL: https://github.com/apache/accumulo/pull/4986#discussion_r1806733114
##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js:
##########
@@ -142,6 +142,110 @@ $(document).ready(function () {
]
});
+ function handleFilterKeyup(input, feedbackElement, columnIndex) {
+ if (isValidRegex(input) || input === '') { // if valid, apply the filter
+ feedbackElement.hide();
+ $(this).removeClass('is-invalid');
+ const isRegex = true;
+ const smartEnabled = false;
+ runningTable
+ .column(columnIndex)
+ .search(input, isRegex, smartEnabled)
+ .draw();
+ } else { // if invalid, show the warning
+ feedbackElement.show();
+ $(this).addClass('is-invalid');
+ }
+ }
+
+ $('#hostname-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#hostname-feedback'), 0);
+ });
+
+ $('#queue-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#queue-feedback'), 3);
+ });
+
+ $('#tableid-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#tableid-feedback'), 4);
+ });
+
+ $('#duration-filter').on('keyup', function () {
+ runningTable.draw();
+ });
+
+ // Custom filter function for duration
+ $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
+ if (settings.nTable.id !== 'runningTable') {
Review Comment:
So will this function be called on other tables than 'runningTable'? If so,
would there be a simple way to only call this on 'runningTable'?
##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js:
##########
@@ -142,6 +142,110 @@ $(document).ready(function () {
]
});
+ function handleFilterKeyup(input, feedbackElement, columnIndex) {
+ if (isValidRegex(input) || input === '') { // if valid, apply the filter
+ feedbackElement.hide();
+ $(this).removeClass('is-invalid');
+ const isRegex = true;
+ const smartEnabled = false;
+ runningTable
+ .column(columnIndex)
+ .search(input, isRegex, smartEnabled)
+ .draw();
+ } else { // if invalid, show the warning
+ feedbackElement.show();
+ $(this).addClass('is-invalid');
+ }
+ }
+
+ $('#hostname-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#hostname-feedback'), 0);
+ });
+
+ $('#queue-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#queue-feedback'), 3);
+ });
+
+ $('#tableid-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#tableid-feedback'), 4);
+ });
+
+ $('#duration-filter').on('keyup', function () {
+ runningTable.draw();
+ });
+
+ // Custom filter function for duration
+ $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
+ if (settings.nTable.id !== 'runningTable') {
+ return true;
+ }
+
+ const durationStr = data[8]; // duration is in the 9th column (index 8)
+ const durationSeconds = parseDuration(durationStr);
+
+ const input = $('#duration-filter').val().trim();
+ if (input === '') {
+ return true;
+ }
+
+ const match = validateDurationInput(input);
+ if (!match) {
+ $('#duration-feedback').show();
+ return false;
+ }
+
+ $('#duration-feedback').hide();
+ const operator = match[1];
+ const value = parseInt(match[2]);
+ const unit = match[3];
+ const filterSeconds = convertToSeconds(value, unit);
+
+ switch (operator) {
+ case '>':
+ return durationSeconds > filterSeconds;
+ case '>=':
+ return durationSeconds >= filterSeconds;
+ case '<':
+ return durationSeconds < filterSeconds;
+ case '<=':
+ return durationSeconds <= filterSeconds;
+ default:
+ return true;
+ }
+ });
+
+ // Helper function to convert duration strings to seconds
+ function convertToSeconds(value, unit) {
+ switch (unit.toLowerCase()) {
+ case 's':
+ return value;
+ case 'm':
+ return value * 60;
+ case 'h':
+ return value * 3600;
+ case 'd':
+ return value * 86400;
+ default:
+ return value;
Review Comment:
212 and 228
Should these throw an error instead? We wouldn't expect the default to
occur, correct?
##########
server/monitor/src/main/resources/org/apache/accumulo/monitor/resources/js/ec.js:
##########
@@ -142,6 +142,110 @@ $(document).ready(function () {
]
});
+ function handleFilterKeyup(input, feedbackElement, columnIndex) {
+ if (isValidRegex(input) || input === '') { // if valid, apply the filter
+ feedbackElement.hide();
+ $(this).removeClass('is-invalid');
+ const isRegex = true;
+ const smartEnabled = false;
+ runningTable
+ .column(columnIndex)
+ .search(input, isRegex, smartEnabled)
+ .draw();
+ } else { // if invalid, show the warning
+ feedbackElement.show();
+ $(this).addClass('is-invalid');
+ }
+ }
+
+ $('#hostname-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#hostname-feedback'), 0);
+ });
+
+ $('#queue-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#queue-feedback'), 3);
+ });
+
+ $('#tableid-filter').on('keyup', function () {
+ handleFilterKeyup.call(this, this.value, $('#tableid-feedback'), 4);
+ });
+
+ $('#duration-filter').on('keyup', function () {
+ runningTable.draw();
+ });
+
+ // Custom filter function for duration
+ $.fn.dataTable.ext.search.push(function (settings, data, dataIndex) {
+ if (settings.nTable.id !== 'runningTable') {
+ return true;
+ }
+
+ const durationStr = data[8]; // duration is in the 9th column (index 8)
Review Comment:
This is for lines 162, 166, 170, 183
It might be safer/more future proof if a function was added instead to get
the table col index based on some input like "duration", etc. This avoids
tracking down hardcoded values and just involves changing one method if table
is changed in the future.
--
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]