mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
add dropdown channel agg for download page
This commit is contained in:
parent
3f1075d0b2
commit
a5788117de
@ -41,6 +41,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="view-icons">
|
<div class="view-icons">
|
||||||
|
{% if channel_agg_list|length > 1 %}
|
||||||
|
<span>Filter:</span>
|
||||||
|
<select name="channel_filter" id="channel_filter" onchange="channelFilterDownload(this.value)">
|
||||||
|
<option value="all" {% if not channel_filter_id %}selected{% endif %}>all</option>
|
||||||
|
{% for channel in channel_agg_list %}
|
||||||
|
<option {% if channel_filter_id == channel.id %}selected{% endif %} value="{{ channel.id }}">{{ channel.name }} ({{channel.count}})</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
{% endif %}
|
||||||
{% if view_style == "grid" %}
|
{% if view_style == "grid" %}
|
||||||
<div class="grid-count">
|
<div class="grid-count">
|
||||||
{% if grid_items < 7 %}
|
{% if grid_items < 7 %}
|
||||||
|
@ -364,6 +364,7 @@ class DownloadView(ArchivistResultsView):
|
|||||||
{
|
{
|
||||||
"title": "Downloads",
|
"title": "Downloads",
|
||||||
"add_form": AddToQueueForm(),
|
"add_form": AddToQueueForm(),
|
||||||
|
"channel_agg_list": self._get_channel_agg(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
return render(request, "home/downloads.html", self.context)
|
return render(request, "home/downloads.html", self.context)
|
||||||
@ -399,6 +400,38 @@ class DownloadView(ArchivistResultsView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def _get_channel_agg(self):
|
||||||
|
"""get pending channel with count"""
|
||||||
|
data = {
|
||||||
|
"size": 0,
|
||||||
|
"query": {"term": {"status": {"value": "pending"}}},
|
||||||
|
"aggs": {
|
||||||
|
"channel_downloads": {
|
||||||
|
"multi_terms": {
|
||||||
|
"size": 30,
|
||||||
|
"terms": [
|
||||||
|
{"field": "channel_name.keyword"},
|
||||||
|
{"field": "channel_id"},
|
||||||
|
],
|
||||||
|
"order": {"_count": "desc"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
response, _ = ElasticWrap(self.es_search).get(data=data)
|
||||||
|
buckets = response["aggregations"]["channel_downloads"]["buckets"]
|
||||||
|
|
||||||
|
buckets_sorted = []
|
||||||
|
for i in buckets:
|
||||||
|
bucket = {
|
||||||
|
"name": i["key"][0],
|
||||||
|
"id": i["key"][1],
|
||||||
|
"count": i["doc_count"],
|
||||||
|
}
|
||||||
|
buckets_sorted.append(bucket)
|
||||||
|
|
||||||
|
return buckets_sorted
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def post(request):
|
def post(request):
|
||||||
"""handle post requests"""
|
"""handle post requests"""
|
||||||
|
@ -344,6 +344,7 @@ button:hover {
|
|||||||
.grid-count {
|
.grid-count {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: end;
|
justify-content: end;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.view-icons img {
|
.view-icons img {
|
||||||
|
@ -1147,6 +1147,14 @@ function showForm() {
|
|||||||
animate('animate-icon', 'pulse-img');
|
animate('animate-icon', 'pulse-img');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function channelFilterDownload(value) {
|
||||||
|
if (value === "all") {
|
||||||
|
window.location = "/downloads/";
|
||||||
|
} else {
|
||||||
|
window.location.search = "?channel=" + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showOverwrite() {
|
function showOverwrite() {
|
||||||
var overwriteDiv = document.getElementById("overwrite-form");
|
var overwriteDiv = document.getElementById("overwrite-form");
|
||||||
if (overwriteDiv.classList.contains("hidden-overwrite")) {
|
if (overwriteDiv.classList.contains("hidden-overwrite")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user