fueanta

Automatic Selection of Hangfire Failed Jobs by Job Description

Jul 26th, 2024 (edited)
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.06 KB | Software | 0 0
  1. const selectCheckboxesByJobDescription = (searchText) => {
  2.     const jobDescriptions =
  3.         [...document
  4.             .querySelectorAll('td div.word-break a.job-method')
  5.             .values()];
  6.  
  7.     const selectionCount =
  8.         jobDescriptions.reduce((count, description) => {
  9.             if (description.textContent.trim().includes(searchText)) {
  10.                 const tr         = description.closest('tr');
  11.                 const checkbox   = tr.querySelector('input[type="checkbox"]');
  12.                 checkbox.checked = true;
  13.  
  14.                 count++;
  15.             }
  16.  
  17.             return count;
  18.         }, 0);
  19.  
  20.     if (selectionCount > 0) {
  21.         const actionButtons =
  22.             document.querySelectorAll('button.js-jobs-list-command');
  23.  
  24.         actionButtons.forEach((buttion) => {
  25.             buttion.disabled = false;
  26.         });
  27.     }
  28.  
  29.     return selectionCount;
  30. }
  31.  
  32. const searchText = "TrackAppCrashesJob";
  33.  
  34. const selectedCount = selectCheckboxesByJobDescription(searchText);
  35.  
  36. console.log("Number of selected rows:", selectedCount);
Advertisement
Add Comment
Please, Sign In to add comment