Skip to content

Commit

Permalink
add job filter
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhleviet committed Dec 13, 2024
1 parent 4bdba8f commit 6f63cb3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
19 changes: 16 additions & 3 deletions src/main/html/webapp/components/core/job/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,26 @@ export default Control.extend({
},

'.job-search keyup': function(el, ev) {
const searchText = $(el).val().trim().toLowerCase();

this.filterJobs();
},

'.job-state-filter change': function(el, ev) {
this.filterJobs();
},

filterJobs: function() {
const searchText = $('.job-search').val().trim().toLowerCase();
const selectedState = $('.job-state-filter').val();

$('.card').each(function() {
const job = domData.get.call(this, 'job');
const jobId = job.attr('id').toString().toLowerCase();
const jobState = job.attr('state').toString();

const matchesSearch = searchText === '' || jobId.includes(searchText);
const matchesState = selectedState === 'all' || jobState === selectedState;

if (searchText === '' || jobId.includes(searchText)) {
if (matchesSearch && matchesState) {
$(this).show();
} else {
$(this).hide();
Expand Down
11 changes: 10 additions & 1 deletion src/main/html/webapp/components/core/job/list/list.stache
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
<div class="py-1 container">
<h2>Jobs</h2>
<b>{{jobs.count}}</b> jobs submitted.
<div class="mt-2">
<div class="mt-2 d-flex gap-2 justify-content-between">
<input type="text" class="form-control job-search" placeholder="Search by Job ID..." style="max-width: 300px;">
<select class="form-control job-state-filter" style="max-width: 200px;">
<option value="all">All States</option>
<option value="1">Running</option>
<option value="2">Waiting</option>
<option value="7">Retired</option>
<option value="4">Success</option>
<option value="5">Failed</option>
<option value="-1">Pending</option>
</select>
</div>
</div>
</div>
Expand Down

0 comments on commit 6f63cb3

Please sign in to comment.