Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweaks:roy tweaks #680

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 6 additions & 22 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion src/server/views/dashboard/queueJobsByState.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async function _html(req, res) {
const page = parseInt(req.query.page, 10) || 1;
const pageSize = parseInt(req.query.pageSize, 10) || 100;
const order = req.query.order || 'desc';
const wildcard = req.query.wildcard || null;

const startId = (page - 1) * pageSize;
const endId = startId + pageSize - 1;
Expand All @@ -123,7 +124,18 @@ async function _html(req, res) {
jobs = jobs.filter((job) => job);
} else {
const stateTypes = state === 'waiting' ? ['wait', 'paused'] : state;
jobs = await queue.getJobs(stateTypes, startId, endId, order === 'asc');
jobs = await queue.getJobs(
stateTypes,
startId,
endId,
order === 'asc',
{},
wildcard
);
if (wildcard) {
const regex = new RegExp(wildcard.replace(/\*/g, '.*'));
jobs = jobs.filter((job) => regex.test(job.id));
}
}

for (let i = 0; i < jobs.length; i++) {
Expand Down Expand Up @@ -178,6 +190,8 @@ async function _html(req, res) {
pageSize,
lastPage: _.last(pages),
order,
totalJobs: _.size(jobs),
wildcard,
});
}

Expand Down
60 changes: 59 additions & 1 deletion src/server/views/dashboard/templates/queueDetails.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,62 @@ window.arenaInitialPayload = {
queueHost: "{{ queueHost }}",
queueName: "{{ queueName }}"
};
{{/contentFor}}
{{/contentFor}}

<div class="col-sm-6 text-right">
<!-- Existing buttons -->
<button id="add-wildcard" type="button" class="btn btn-info">
Add Wildcard Filter
</button>
<!-- Other buttons remain unchanged -->
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const wildcardButton = document.getElementById('add-wildcard');
const wildcardParam = new URL(window.location.href).searchParams.get('wildcard');

// Append wildcard to all relevant links and buttons
function updateLinksWithWildcard() {
if (!wildcardParam) return;

const buttons = document.querySelectorAll('a, button[data-action]');
buttons.forEach(button => {
// If it's an anchor tag, append wildcard to href
if (button.tagName === 'A' && button.href) {
const url = new URL(button.href);
url.searchParams.set('wildcard', wildcardParam);
button.href = url.toString();
}

// For buttons with data-action, handle form-like behavior or custom logic
if (button.dataset.action) {
button.addEventListener('click', (event) => {
event.preventDefault();
const url = new URL(window.location.href);
url.searchParams.set('wildcard', wildcardParam);
url.searchParams.set('action', button.dataset.action); // Append action if needed
window.location.href = url.toString();
});
}
});
}

// Handle the Add Wildcard button
if (wildcardButton) {
wildcardButton.addEventListener('click', () => {
const wildcard = prompt('Enter a wildcard pattern (e.g., job-*)');
if (wildcard !== null) {
// Get current URL parameters
const url = new URL(window.location.href);
url.searchParams.set('wildcard', wildcard);

// Redirect with the new wildcard parameter
window.location.href = url.toString();
}
});
}

// Update links on page load
updateLinksWithWildcard();
});
</script>
Loading