Fix tag population and date formatting
This commit is contained in:
parent
54f82f772b
commit
86ec95ab6c
|
@ -1,5 +1,6 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load index %}
|
{% load index %}
|
||||||
|
{% load joinsep %}
|
||||||
{% include 'partials/notify.html' %}
|
{% include 'partials/notify.html' %}
|
||||||
{% if table %}
|
{% if table %}
|
||||||
<div style="display: none" id="jsonData" data-json="{{ data }}">
|
<div style="display: none" id="jsonData" data-json="{{ data }}">
|
||||||
|
@ -36,3 +37,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% 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 django_tables2 %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% load django_tables2_bulma_template %}
|
{% load django_tables2_bulma_template %}
|
||||||
{% load joinsep %}
|
|
||||||
|
|
||||||
{% block table-wrapper %}
|
{% block table-wrapper %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
@ -13,6 +12,8 @@
|
||||||
{% block table.thead.row %}
|
{% block table.thead.row %}
|
||||||
<tr>
|
<tr>
|
||||||
{% for column in table.columns %}
|
{% for column in table.columns %}
|
||||||
|
|
||||||
|
{% if column.name not in hide %}
|
||||||
{% block table.thead.th %}
|
{% block table.thead.th %}
|
||||||
<th {% render_attrs column.attrs.th class="" %}>
|
<th {% render_attrs column.attrs.th class="" %}>
|
||||||
{% if column.orderable %}
|
{% if column.orderable %}
|
||||||
|
@ -41,6 +42,8 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
{% endblock table.thead.th %}
|
{% endblock table.thead.th %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endblock table.thead.row %}
|
{% endblock table.thead.row %}
|
||||||
|
@ -65,6 +68,7 @@
|
||||||
has-background-info-light
|
has-background-info-light
|
||||||
{% endif %}">
|
{% endif %}">
|
||||||
{% for column, cell in row.items %}
|
{% for column, cell in row.items %}
|
||||||
|
{% if column.name not in hide %}
|
||||||
{% block table.tbody.td %}
|
{% block table.tbody.td %}
|
||||||
{% if column.name == 'src' %}
|
{% if column.name == 'src' %}
|
||||||
<td>
|
<td>
|
||||||
|
@ -81,6 +85,11 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
{% elif column.name == 'ts' %}
|
||||||
|
<td>
|
||||||
|
<p>{{ row.cells.date }}</p>
|
||||||
|
<p>{{ row.cells.time }}</p>
|
||||||
|
</td>
|
||||||
{% elif column.name == 'type' %}
|
{% elif column.name == 'type' %}
|
||||||
<td>
|
<td>
|
||||||
<a class="has-text-link is-underlined"
|
<a class="has-text-link is-underlined"
|
||||||
|
@ -203,6 +212,7 @@
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock table.tbody.td %}
|
{% endblock table.tbody.td %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endblock table.tbody.row %}
|
{% endblock table.tbody.row %}
|
||||||
|
@ -309,24 +319,4 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock pagination %}
|
{% endblock pagination %}
|
||||||
</div>
|
</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 %}
|
{% endblock table-wrapper %}
|
|
@ -190,6 +190,7 @@ class DrilldownTableView(SingleTableView):
|
||||||
for k, v in self.context.items():
|
for k, v in self.context.items():
|
||||||
if k not in context:
|
if k not in context:
|
||||||
context[k] = v
|
context[k] = v
|
||||||
|
context["hide"] = ["date", "time", "id", "num", "channel_nsfw", "num_users", "num_chans", "exemption", "version_sentiment"]
|
||||||
|
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
if not request.htmx:
|
if not request.htmx:
|
||||||
|
|
|
@ -5,9 +5,8 @@ from django_tables2.columns.base import BoundColumn
|
||||||
# Make the table column headings lowercase
|
# Make the table column headings lowercase
|
||||||
orig_Column_header = BoundColumn.header
|
orig_Column_header = BoundColumn.header
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def lower_header(self):
|
def format_header(self):
|
||||||
header = orig_Column_header.__get__(self)
|
header = orig_Column_header.__get__(self)
|
||||||
header = header.lower()
|
header = header.lower()
|
||||||
header = header.title()
|
header = header.title()
|
||||||
|
@ -20,8 +19,7 @@ def lower_header(self):
|
||||||
|
|
||||||
return header
|
return header
|
||||||
|
|
||||||
|
BoundColumn.header = format_header
|
||||||
BoundColumn.header = lower_header
|
|
||||||
|
|
||||||
|
|
||||||
class DrilldownTable(Table):
|
class DrilldownTable(Table):
|
||||||
|
@ -38,8 +36,8 @@ class DrilldownTable(Table):
|
||||||
num = Column()
|
num = Column()
|
||||||
src = Column()
|
src = Column()
|
||||||
ts = Column()
|
ts = Column()
|
||||||
# date = Column()
|
date = Column()
|
||||||
# time = Column()
|
time = Column()
|
||||||
type = Column()
|
type = Column()
|
||||||
bot = Column()
|
bot = Column()
|
||||||
channel = Column()
|
channel = Column()
|
||||||
|
|
Loading…
Reference in New Issue