Fix tag population and date formatting

Mark Veidemanis 2 years ago
parent 54f82f772b
commit 86ec95ab6c
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -1,5 +1,6 @@
{% load static %}
{% load index %}
{% load joinsep %}
{% include 'partials/notify.html' %}
{% if table %}
<div style="display: none" id="jsonData" data-json="{{ data }}">
@ -36,3 +37,23 @@
</div>
</div>
{% endif %}
{# Update the tags in case the user changed the query #}
{# Check for focus and refocus #}
<script>
var inputTags = document.getElementsByClassName('tags-input');
var inputBox = document.querySelector("[placeholder='Add query']");
var isFocused = (document.activeElement === inputBox);
for (index = 0; index < inputTags.length; index++) {
if (index == 0) {
inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">';
} else {
inputTags[index].remove();
}
}
// inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">';
setupTags();
var inputBox = document.querySelector("[placeholder='Add query']");
if (isFocused) {
inputBox.focus();
}
</script>

@ -1,7 +1,6 @@
{% load django_tables2 %}
{% load i18n %}
{% load django_tables2_bulma_template %}
{% load joinsep %}
{% block table-wrapper %}
<div class="container">
@ -13,6 +12,8 @@
{% block table.thead.row %}
<tr>
{% for column in table.columns %}
{% if column.name not in hide %}
{% block table.thead.th %}
<th {% render_attrs column.attrs.th class="" %}>
{% if column.orderable %}
@ -41,6 +42,8 @@
{% endif %}
</th>
{% endblock table.thead.th %}
{% endif %}
{% endfor %}
</tr>
{% endblock table.thead.row %}
@ -65,6 +68,7 @@
has-background-info-light
{% endif %}">
{% for column, cell in row.items %}
{% if column.name not in hide %}
{% block table.tbody.td %}
{% if column.name == 'src' %}
<td>
@ -81,6 +85,11 @@
{% endif %}
</a>
</td>
{% elif column.name == 'ts' %}
<td>
<p>{{ row.cells.date }}</p>
<p>{{ row.cells.time }}</p>
</td>
{% elif column.name == 'type' %}
<td>
<a class="has-text-link is-underlined"
@ -203,6 +212,7 @@
</td>
{% endif %}
{% endblock table.tbody.td %}
{% endif %}
{% endfor %}
</tr>
{% endblock table.tbody.row %}
@ -309,24 +319,4 @@
{% endif %}
{% endblock pagination %}
</div>
{# Update the tags in case the user changed the query #}
{# Check for focus and refocus #}
<script>
var inputTags = document.getElementsByClassName('tags-input');
var inputBox = document.querySelector("[placeholder='Add query']");
var isFocused = (document.activeElement === inputBox);
for (index = 0; index < inputTags.length; index++) {
if (index == 0) {
inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">';
} else {
inputTags[index].remove();
}
}
// inputTags[0].outerHTML = '<input id="tags" class="input" type="tags" placeholder="Add query" value="{{ tags|joinsep:',' }}">';
setupTags();
var inputBox = document.querySelector("[placeholder='Add query']");
if (isFocused) {
inputBox.focus();
}
</script>
{% endblock table-wrapper %}

@ -190,6 +190,7 @@ class DrilldownTableView(SingleTableView):
for k, v in self.context.items():
if k not in context:
context[k] = v
context["hide"] = ["date", "time", "id", "num", "channel_nsfw", "num_users", "num_chans", "exemption", "version_sentiment"]
if request.method == "GET":
if not request.htmx:

@ -5,9 +5,8 @@ from django_tables2.columns.base import BoundColumn
# Make the table column headings lowercase
orig_Column_header = BoundColumn.header
@property
def lower_header(self):
def format_header(self):
header = orig_Column_header.__get__(self)
header = header.lower()
header = header.title()
@ -20,8 +19,7 @@ def lower_header(self):
return header
BoundColumn.header = lower_header
BoundColumn.header = format_header
class DrilldownTable(Table):
@ -38,8 +36,8 @@ class DrilldownTable(Table):
num = Column()
src = Column()
ts = Column()
# date = Column()
# time = Column()
date = Column()
time = Column()
type = Column()
bot = Column()
channel = Column()

Loading…
Cancel
Save