Skip to content

Commit

Permalink
Add filter for largemem and gpu
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennedub committed Oct 30, 2024
1 parent 1085cb1 commit 6af1013
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
6 changes: 4 additions & 2 deletions top/templates/top/compute.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ <h1>{% translate "Top compute users" %}</h1>

<select select data-placeholder="Filter by wasting status" multiple class="chosen-select" id="select-status">
<option value="OK">OK</option>
<option value="Memory">Memory</option>
<option value="Cores">Cores</option>
{% for waste_badge in select_waste_badges %}
<option value="{{ waste_badge }}">{{ waste_badge }}</option>
{% endfor %}
</select>

<table class="table table-striped" id="compute">
<thead class="thead-dark">
<tr>
Expand Down
19 changes: 19 additions & 0 deletions top/templates/top/gpucompute.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ <h1>{% translate "Top GPU compute users" %}</h1>
<dd>{% translate "Show the wasted resource" %}</dd>
</dl>

<select select data-placeholder="Filter by wasting status" multiple class="chosen-select" id="select-status">
<option value="OK">OK</option>
{% for waste_badge in select_waste_badges %}
<option value="{{ waste_badge }}">{{ waste_badge }}</option>
{% endfor %}
</select>

<table class="table table-striped" id="gpucompute">
<thead class="thead-dark">
<tr>
Expand Down Expand Up @@ -146,6 +153,18 @@ <h1>{% translate "Top GPU compute users" %}</h1>
]
});
});

$(".chosen-select").chosen({width:"100%"})
$('#select-status').on('change', function() {
const selectedStatuses = $(this).val();
$('#gpucompute tbody tr').each(function() {
const row = $(this);
const badgeText = row.find('td:last-child .badge').text().trim();

const showRow = selectedStatuses.length === 0 || selectedStatuses.some(status => badgeText.includes(status));
row.toggle(showRow);
});
}).trigger('change');
</script>

{% endblock content %}
19 changes: 19 additions & 0 deletions top/templates/top/largemem.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ <h1>{% translate "Users on largemem" %}</h1>
<dd>{% translate "Show the wasted resource" %}</dd>
</dl>

<select select data-placeholder="Filter by wasting status" multiple class="chosen-select" id="select-status">
<option value="OK">OK</option>
{% for waste_badge in select_waste_badges %}
<option value="{{ waste_badge }}">{{ waste_badge }}</option>
{% endfor %}
</select>

<table class="table table-striped" id="largemem">
<thead class="thead-dark">
<tr>
Expand Down Expand Up @@ -129,6 +136,18 @@ <h1>{% translate "Users on largemem" %}</h1>
]
});
});

$(".chosen-select").chosen({width:"100%"})
$('#select-status').on('change', function() {
const selectedStatuses = $(this).val();
$('#largemem tbody tr').each(function() {
const row = $(this);
const badgeText = row.find('td:last-child .badge').text().trim();

const showRow = selectedStatuses.length === 0 || selectedStatuses.some(status => badgeText.includes(status));
row.toggle(showRow);
});
}).trigger('change');
</script>

{% endblock content %}
3 changes: 3 additions & 0 deletions top/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def compute(request):
context['cpu_users'].append(stats)
except KeyError:
pass
context['select_waste_badges'] = [_('Memory'), _('Cores')]

return render(request, 'top/compute.html', context)

Expand Down Expand Up @@ -213,6 +214,7 @@ def gpucompute(request):
context['gpu_users'].append(stats)
except KeyError:
pass
context['select_waste_badges'] = [_('Memory'), _('Cores'), _('GPU ares totally unused'), _('GPUs')]
return render(request, 'top/gpucompute.html', context)


Expand Down Expand Up @@ -286,6 +288,7 @@ def largemem(request):
context['jobs'].append(stats)
except KeyError:
pass
context['select_waste_badges'] = [_('Memory'), _('Cores')]

# gather all usernames
users = set()
Expand Down

0 comments on commit 6af1013

Please sign in to comment.