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

Filter wasting status #2

Open
wants to merge 2 commits into
base: main
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
22 changes: 22 additions & 0 deletions top/templates/top/compute.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% load humanize %}
{% load i18n %}


{% block title %}{% translate "Top compute users" %}{% endblock title %}

{% block content %}
Expand All @@ -22,6 +23,14 @@ <h1>{% translate "Top compute users" %}</h1>
<dt>{% translate "Wasting" %}</dt>
<dd>{% translate "Show the wasted resource. The normal amount of memory per cores is taken into account to remove the memory flag when a user seems to use full nodes" %}</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="compute">
<thead class="thead-dark">
<tr>
Expand Down Expand Up @@ -108,6 +117,19 @@ <h1>{% translate "Top compute users" %}</h1>
]
});
});

$(".chosen-select").chosen({width:"100%"})
$('#select-status').on('change', function() {
const selectedStatuses = $(this).val();
$('#compute 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/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
Loading