Implement toggleable table fields

This commit is contained in:
Mark Veidemanis 2022-08-09 07:20:30 +01:00
parent 89b38111cd
commit d1076ca2b5
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
6 changed files with 574 additions and 308 deletions

View File

@ -0,0 +1,205 @@
// Author: Grzegorz Tężycki
$(document).ready(function(){
// In web storage is saved structure like that:
// localStorage['django_tables2_column_shifter'] = {
// 'table_class_container1' : {
// 'id' : 'on',
// 'col1' : 'off',
// 'col2' : 'on',
// 'col3' : 'on',
// },
// 'table_class_container2' : {
// 'id' : 'on',
// 'col1' : 'on'
// },
// }
// main name for key in web storage
var COLUMN_SHIFTER_STORAGE_ACCESOR = "django_tables2_column_shifter";
// Return storage structure for shifter
// If structure does'n exist in web storage
// will be return empty object
var get_column_shifter_storage = function(){
var storage = localStorage.getItem(COLUMN_SHIFTER_STORAGE_ACCESOR);
if (storage === null) {
storage = {};
} else {
storage = JSON.parse(storage);
}
return storage;
};
// Save structure in web storage
var set_column_shifter_storage = function(storage){
var json_storage = JSON.stringify(storage)
localStorage.setItem(COLUMN_SHIFTER_STORAGE_ACCESOR, json_storage);
};
// Remember state for single button
var save_btn_state = function($btn){
// Take css class for container with table
var table_class_container = $btn.data("table-class-container");
// Take html object with table
var $table_class_container = $("#" + table_class_container);
// Take single button statne ("on" / "off")
var state = $btn.data("state");
// td-class is a real column name in table
var td_class = $btn.data("td-class");
var storage = get_column_shifter_storage();
// Table id
var id = $table_class_container.attr("id");
// Checking if the ID is already in storage
if (id in storage) {
data = storage[id]
} else {
data = {}
storage[id] = data;
}
// Save state for table column in storage
data[td_class] = state;
set_column_shifter_storage(storage);
};
// Load states for buttons from storage for single tabel
var load_states = function($table_class_container) {
var storage = get_column_shifter_storage();
// Table id
var id = $table_class_container.attr("id");
var data = {};
// Checking if the ID is already in storage
if (id in storage) {
data = storage[id]
// For each shifter button set state
$table_class_container.find(".btn-shift-column").each(function(){
var $btn = $(this);
var td_class = $btn.data("td-class");
// If name of column is in store then get state
// and set state
if (td_class in data) {
var state = data[td_class]
set_btn_state($btn, state);
}
});
}
};
// Show table content and hide spiner
var show_table_content = function($table_class_container){
$table_class_container.find("#loader").hide();
$table_class_container.find(".table-container").show();
const event = new Event('restore-scroll');
document.dispatchEvent(event);
};
// Load buttons states for all button in page
var load_state_for_all_containters = function(){
$(".column-shifter-container").each(function(){
$table_class_container = $(this);
// Load states for all buttons in single container
load_states($table_class_container);
// When states was loaded then table must be show and
// loader (spiner) must be hide
show_table_content($table_class_container);
});
};
// change visibility column for single button
// if button has state "on" then show column
// else then column will be hide
shift_column = function( $btn ){
// button state
var state = $btn.data("state");
// td-class is a real column name in table
var td_class = $btn.data("td-class");
var table_class_container = $btn.data("table-class-container");
var $table_class_container = $("#" + table_class_container);
var $table = $table_class_container.find("table");
var $cels = $table.find("." + td_class);
if ( state === "on" ) {
$cels.show();
} else {
$cels.hide();
}
};
// Shift visibility for all columns
shift_columns = function(){
var cols = $(".btn-shift-column");
var i, len = cols.length;
for (i=0; i < len; i++) {
shift_column($(cols[i]));
}
};
// Set icon imgae visibility for button state
var set_icon_for_state = function( $btn, state ) {
if (state === "on") {
$btn.find("span.uncheck").hide();
$btn.find("span.check").show();
} else {
$btn.find("span.check").hide();
$btn.find("span.uncheck").show();
}
};
// Set state for single button
var set_btn_state = function($btn, state){
$btn.data('state', state);
set_icon_for_state($btn, state);
}
// Change state for single button
var change_btn_state = function($btn){
var state = $btn.data("state");
if (state === "on") {
state = "off"
} else {
state = "on"
}
set_btn_state($btn, state);
};
// Run show/hide when click on button
$(".btn-shift-column").on("click", function(event){
var $btn = $(this);
event.stopPropagation();
change_btn_state($btn);
shift_column($btn);
save_btn_state($btn);
});
// Load saved states for all tables
load_state_for_all_containters();
// show or hide columns based on data from web storage
shift_columns();
// Add API method for retrieving non-visible cols for table
// Pass the 0-based index of the table or leave the parameter
// empty to return the hidden cols for the 1st table found
$.django_tables2_column_shifter_hidden = function(idx) {
if(idx==undefined) {
idx = 0;
}
return $('.table-container').eq(idx).find('.btn-shift-column').filter(function(z) {
return $(this).data('state')=='off'
}).map(function(z) {
return $(this).data('td-class')
}).toArray();
}
});

2
core/static/js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -21,6 +21,20 @@
<script defer src="{% static 'js/remove-me.js' %}" integrity="sha384-6fHcFNoQ8QEI3ZDgw9Z/A6Brk64gF7AnFbLgdrumo8/kBbsKQ/wo7wPegj5WkzuG" crossorigin="anonymous"></script> <script defer src="{% static 'js/remove-me.js' %}" integrity="sha384-6fHcFNoQ8QEI3ZDgw9Z/A6Brk64gF7AnFbLgdrumo8/kBbsKQ/wo7wPegj5WkzuG" crossorigin="anonymous"></script>
<script defer src="{% static 'js/hyperscript.min.js' %}" integrity="sha384-6GYN8BDHOJkkru6zcpGOUa//1mn+5iZ/MyT6mq34WFIpuOeLF52kSi721q0SsYF9" crossorigin="anonymous"></script> <script defer src="{% static 'js/hyperscript.min.js' %}" integrity="sha384-6GYN8BDHOJkkru6zcpGOUa//1mn+5iZ/MyT6mq34WFIpuOeLF52kSi721q0SsYF9" crossorigin="anonymous"></script>
<script src="{% static 'js/bulma-tagsinput.min.js' %}" integrity="sha384-GmnKCsPJIPPZbNVXpkGRmKdxOa0PQLnOM/hQLIHvMRERySuyvFqKGc76iHTGUY+d" crossorigin="anonymous"></script> <script src="{% static 'js/bulma-tagsinput.min.js' %}" integrity="sha384-GmnKCsPJIPPZbNVXpkGRmKdxOa0PQLnOM/hQLIHvMRERySuyvFqKGc76iHTGUY+d" crossorigin="anonymous"></script>
<script src="{% static 'js/jquery.min.js' %}"></script>
<script>
document.addEventListener("restore-scroll", function(event) {
var scrollpos = localStorage.getItem('scrollpos');
if (scrollpos) {
window.scrollTo(0, scrollpos)
};
});
document.addEventListener("htmx:beforeSwap", function(event) {
localStorage.setItem('scrollpos', window.scrollY);
});
</script>
<script> <script>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
@ -72,8 +86,10 @@
.htmx-request.htmx-indicator{ .htmx-request.htmx-indicator{
opacity:1 opacity:1
} }
.dropdown-content {
height: 20em;
overflow: auto;
}
</style> </style>
</head> </head>
<body> <body>

View File

@ -3,6 +3,7 @@
{% load joinsep %} {% load joinsep %}
{% include 'partials/notify.html' %} {% include 'partials/notify.html' %}
{% if table %} {% if table %}
<script src="{% static 'js/column-shifter.js' %}"></script>
<div style="display: none" id="jsonData" data-json="{{ data }}"> <div style="display: none" id="jsonData" data-json="{{ data }}">
</div> </div>
@ -31,11 +32,7 @@
</div> </div>
<script src="{% static 'chart.js' %}"></script> <script src="{% static 'chart.js' %}"></script>
</div> </div>
<div class="box"> {% include 'ui/drilldown/table_results_partial.html' %}
<div class="table-container">
{% include 'ui/drilldown/table_results_partial.html' %}
</div>
</div>
{% endif %} {% endif %}
{# Update the tags in case the user changed the query #} {# Update the tags in case the user changed the query #}
{# Check for focus and refocus #} {# Check for focus and refocus #}

View File

@ -1,297 +1,340 @@
{% load django_tables2 %} {% load django_tables2 %}
{% load i18n %} {% load i18n %}
{% load django_tables2_bulma_template %} {% load django_tables2_bulma_template %}
{% load static %}
{% block table-wrapper %} {% block table-wrapper %}
<div class="container"> <div id="drilldown-table" class="container box column-shifter-container" style="position:relative; z-index:1;">
{% block table %} {% block table %}
<table {% render_attrs table.attrs class="table is-striped is-hoverable is-fullwidth" %}> <div class="nowrap-parent">
{% block table.thead %} <div class="nowrap-child">
{% if table.show_header %} <div class="dropdown" id="dropdown">
<thead {% render_attrs table.attrs.thead class="" %}> <div class="dropdown-trigger">
{% block table.thead.row %} <button id="dropdown-trigger" class="button dropdown-toggle" aria-haspopup="true" aria-controls="dropdown-menu">
<tr> <span>Show/hide fields</span>
{% for column in table.columns %} <span class="icon is-small">
<i class="fas fa-angle-down" aria-hidden="true"></i>
</span>
</button>
</div>
<div class="dropdown-menu" id="dropdown-menu" role="menu">
<div class="dropdown-content" style="position:absolute; z-index:10;">
{% for column in table.columns %}
{% if column.name in show %}
<a class="btn-shift-column dropdown-item"
data-td-class="{{ column.name }}"
data-state="on"
{% if not forloop.last %} style="border-bottom:1px solid #ccc;" {%endif %}
data-table-class-container="drilldown-table">
<span class="check icon" data-tooltip="Visible" style="display:none;">
<i class="fa-solid fa-check"></i>
</span>
<span class="uncheck icon" data-tooltip="Hidden" style="display:none;">
<i class="fa-solid fa-xmark"></i>
</span>
{{ column.header }}
</a>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
<div class="nowrap-child">
<span id="loader" class="button is-light has-text-link is-loading">Static</span>
</div>
</div>
<script>
var dropdown_button = document.getElementById("dropdown-trigger");
var dropdown = document.getElementById("dropdown");
dropdown_button.addEventListener('click', function(e) {
// elements[i].preventDefault();
dropdown.classList.toggle('is-active');
});
{% if column.name in show and not column.name in hide %} </script>
{% block table.thead.th %} <div class="table-container" style="display:none;">
<th {% render_attrs column.attrs.th class="" %}> <table {% render_attrs table.attrs class="table is-striped is-hoverable is-fullwidth" %}>
<div class="nowrap-parent"> {% block table.thead %}
{% if column.orderable %} {% if table.show_header %}
<div class="nowrap-child"> <thead {% render_attrs table.attrs.thead class="" %}>
{% if column.is_ordered %} {% block table.thead.row %}
{% is_descending column.order_by as descending %} <tr>
{% if descending %} {% for column in table.columns %}
<span class="icon" aria-hidden="true">{% block table.desc_icon %}<i class="fa-solid fa-sort-down"></i>{% endblock table.desc_icon %}</span> {% if column.name in show and not column.name in hide %}
{% else %} {% block table.thead.th %}
<span class="icon" aria-hidden="true">{% block table.asc_icon %}<i class="fa-solid fa-sort-up"></i>{% endblock table.asc_icon %}</span> <th class="orderable {{ column.name }}"
{% endif %} {% if column.name in invisible %}
{% else %} style="display:none;"
<span class="icon" aria-hidden="true">{% block table.orderable_icon %}<i class="fa-solid fa-sort"></i>{% endblock table.orderable_icon %}</span> {% endif %}>
{% endif %}
</div>
<div class="nowrap-child">
<a
hx-get="search/{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}&{{ uri }}"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click"
hx-target="#results"
hx-swap="innerHTML"
hx-indicator=".progress"
style="cursor: pointer;">
{{ column.header }}
</a>
</div>
{% else %}
<div class="nowrap-child">
{{ column.header }}
</div>
{% endif %}
</div>
</th>
{% endblock table.thead.th %}
{% endif %}
{% endfor %}
</tr>
{% endblock table.thead.row %}
</thead>
{% endif %}
{% endblock table.thead %}
{% block table.tbody %}
<tbody {{ table.attrs.tbody.as_html }}>
{% for row in table.paginated_rows %}
{% block table.tbody.row %}
<tr class="{% if row.cells.exemption == True %}
has-background-grey-lighter
{% elif row.cells.type == 'join' %}
has-background-success-light
{% elif row.cells.type == 'quit' %}
has-background-danger-light
{% elif row.cells.type == 'kick' %}
has-background-danger-light
{% elif row.cells.type == 'part' %}
has-background-warning-light
{% elif row.cells.type == 'mode' %}
has-background-info-light
{% endif %}">
{% for column, cell in row.items %}
{% if column.name in show and not column.name in hide %}
{% block table.tbody.td %}
{% if cell == '—' %}
<td>
<span class="icon">
<i class="fa-solid fa-file-slash"></i>
</span>
</td>
{% elif column.name == 'src' %}
<td>
<a class="has-text-link is-underlined"
onclick="populateSearch('src', '{{ cell|escapejs }}')">
{% if row.cells.src == 'irc' %}
<span class="icon" data-tooltip="IRC">
<i class="fa-solid fa-hashtag" aria-hidden="true"></i>
</span>
{% elif row.cells.src == 'dis' %}
<span class="icon" data-tooltip="Discord">
<i class="fa-brands fa-discord" aria-hidden="true"></i>
</span>
{% 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"
onclick="populateSearch('type', '{{ cell|escapejs }}')">
{% if row.cells.type == 'msg' %}
<span class="icon" data-tooltip="Message">
<i class="fa-solid fa-message"></i>
</span>
{% elif row.cells.type == 'join' %}
<span class="icon" data-tooltip="Join">
<i class="fa-solid fa-person-to-portal"></i>
</span>
{% elif row.cells.type == 'part' %}
<span class="icon" data-tooltip="Part">
<i class="fa-solid fa-person-from-portal"></i>
</span>
{% elif row.cells.type == 'quit' %}
<span class="icon" data-tooltip="Quit">
<i class="fa-solid fa-circle-xmark"></i>
</span>
{% elif row.cells.type == 'kick' %}
<span class="icon" data-tooltip="Kick">
<i class="fa-solid fa-user-slash"></i>
</span>
{% elif row.cells.type == 'nick' %}
<span class="icon" data-tooltip="Nick">
<i class="fa-solid fa-signature"></i>
</span>
{% elif row.cells.type == 'mode' %}
<span class="icon" data-tooltip="Mode">
<i class="fa-solid fa-gear"></i>
</span>
{% elif row.cells.type == 'action' %}
<span class="icon" data-tooltip="Action">
<i class="fa-solid fa-exclamation"></i>
</span>
{% else %}
{{ row.cells.type }}
{% endif %}
</a>
</td>
{% elif column.name == 'msg' %}
<td style="max-width: 10em" class="wrap">{{ row.cells.msg }}</td>
{% elif column.name == 'host' %}
<td>
<a class="has-text-link is-underlined"
onclick="populateSearch('host', '{{ cell|escapejs }}')">
{{ cell }}
</a>
</td>
{% elif column.name == 'nick' %}
<td>
<div class="nowrap-parent"> <div class="nowrap-parent">
<div class="nowrap-child"> {% if column.orderable %}
{% if row.cells.online is True %}
<span class="icon has-text-success has-tooltip-success" data-tooltip="Online">
<i class="fa-solid fa-circle"></i>
</span>
{% elif row.cells.online is False %}
<span class="icon has-text-danger has-tooltip-danger" data-tooltip="Offline">
<i class="fa-solid fa-circle"></i>
</span>
{% else %}
<span class="icon has-text-warning has-tooltip-warning" data-tooltip="Unknown">
<i class="fa-solid fa-circle"></i>
</span>
{% endif %}
</div>
<a class="nowrap-child has-text-link is-underlined" onclick="populateSearch('nick', '{{ cell|escapejs }}')">
{{ cell }}
</a>
<div class="nowrap-child">
{% if row.cells.src == 'irc' %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'modal_drilldown' %}"
hx-vals='{"net": "{{ row.cells.net }}", "nick": "{{ row.cells.nick }}", "channel": "{{ row.cells.channel }}"}'
hx-target="#modals-here"
hx-trigger="click"
class="button is-small">
Information
</button>
{% endif %}
</div>
{% if row.cells.num_chans != '—' %}
<div class="nowrap-child"> <div class="nowrap-child">
<span class="tag"> {% if column.is_ordered %}
{{ row.cells.num_chans }} {% is_descending column.order_by as descending %}
</span> {% if descending %}
<span class="icon" aria-hidden="true">{% block table.desc_icon %}<i class="fa-solid fa-sort-down"></i>{% endblock table.desc_icon %}</span>
{% else %}
<span class="icon" aria-hidden="true">{% block table.asc_icon %}<i class="fa-solid fa-sort-up"></i>{% endblock table.asc_icon %}</span>
{% endif %}
{% else %}
<span class="icon" aria-hidden="true">{% block table.orderable_icon %}<i class="fa-solid fa-sort"></i>{% endblock table.orderable_icon %}</span>
{% endif %}
</div>
<div class="nowrap-child">
<a
hx-get="search/{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}&{{ uri }}"
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click"
hx-target="#results"
hx-swap="innerHTML"
hx-indicator="#spinner"
style="cursor: pointer;">
{{ column.header }}
</a>
</div>
{% else %}
<div class="nowrap-child">
{{ column.header }}
</div> </div>
{% endif %} {% endif %}
</div> </div>
</td> </th>
{% elif column.name == 'channel' %} {% endblock table.thead.th %}
<td> {% endif %}
{% if cell != '—' %}
{% endfor %}
</tr>
{% endblock table.thead.row %}
</thead>
{% endif %}
{% endblock table.thead %}
{% block table.tbody %}
<tbody {{ table.attrs.tbody.as_html }}>
{% for row in table.paginated_rows %}
{% block table.tbody.row %}
<tr class="{% if row.cells.exemption == True %}has-background-grey-lighter{% elif row.cells.type == 'join' %}has-background-success-light{% elif row.cells.type == 'quit' %}has-background-danger-light{% elif row.cells.type == 'kick' %}has-background-danger-light{% elif row.cells.type == 'part' %}has-background-warning-light{% elif row.cells.type == 'mode' %}has-background-info-light{% endif %}">
{% for column, cell in row.items %}
{% if column.name in show and not column.name in hide %}
{% block table.tbody.td %}
{% if column.name in invisible %}
<td class="{{ column.name }}" style="display:none;">
{{ cell }}
</td>
{% elif cell == '—' %}
<td class="{{ column.name }}">
<span class="icon">
<i class="fa-solid fa-file-slash"></i>
</span>
</td>
{% elif column.name == 'src' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('src', '{{ cell|escapejs }}')">
{% if row.cells.src == 'irc' %}
<span class="icon" data-tooltip="IRC">
<i class="fa-solid fa-hashtag" aria-hidden="true"></i>
</span>
{% elif row.cells.src == 'dis' %}
<span class="icon" data-tooltip="Discord">
<i class="fa-brands fa-discord" aria-hidden="true"></i>
</span>
{% endif %}
</a>
</td>
{% elif column.name == 'ts' %}
<td class="{{ column.name }}">
<p>{{ row.cells.date }}</p>
<p>{{ row.cells.time }}</p>
</td>
{% elif column.name == 'type' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('type', '{{ cell|escapejs }}')">
{% if row.cells.type == 'msg' %}
<span class="icon" data-tooltip="Message">
<i class="fa-solid fa-message"></i>
</span>
{% elif row.cells.type == 'join' %}
<span class="icon" data-tooltip="Join">
<i class="fa-solid fa-person-to-portal"></i>
</span>
{% elif row.cells.type == 'part' %}
<span class="icon" data-tooltip="Part">
<i class="fa-solid fa-person-from-portal"></i>
</span>
{% elif row.cells.type == 'quit' %}
<span class="icon" data-tooltip="Quit">
<i class="fa-solid fa-circle-xmark"></i>
</span>
{% elif row.cells.type == 'kick' %}
<span class="icon" data-tooltip="Kick">
<i class="fa-solid fa-user-slash"></i>
</span>
{% elif row.cells.type == 'nick' %}
<span class="icon" data-tooltip="Nick">
<i class="fa-solid fa-signature"></i>
</span>
{% elif row.cells.type == 'mode' %}
<span class="icon" data-tooltip="Mode">
<i class="fa-solid fa-gear"></i>
</span>
{% elif row.cells.type == 'action' %}
<span class="icon" data-tooltip="Action">
<i class="fa-solid fa-exclamation"></i>
</span>
{% else %}
{{ row.cells.type }}
{% endif %}
</a>
</td>
{% elif column.name == 'msg' %}
<td class="{{ column.name }}" style="max-width: 10em" class="wrap">{{ row.cells.msg }}</td>
{% elif column.name == 'host' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('host', '{{ cell|escapejs }}')">
{{ cell }}
</a>
</td>
{% elif column.name == 'nick' %}
<td class="{{ column.name }}">
<div class="nowrap-parent"> <div class="nowrap-parent">
<a class="nowrap-child has-text-link is-underlined" <div class="nowrap-child">
onclick="populateSearch('channel', '{{ cell|escapejs }}')"> {% if row.cells.online is True %}
<span class="icon has-text-success has-tooltip-success" data-tooltip="Online">
<i class="fa-solid fa-circle"></i>
</span>
{% elif row.cells.online is False %}
<span class="icon has-text-danger has-tooltip-danger" data-tooltip="Offline">
<i class="fa-solid fa-circle"></i>
</span>
{% else %}
<span class="icon has-text-warning has-tooltip-warning" data-tooltip="Unknown">
<i class="fa-solid fa-circle"></i>
</span>
{% endif %}
</div>
<a class="nowrap-child has-text-link is-underlined" onclick="populateSearch('nick', '{{ cell|escapejs }}')">
{{ cell }} {{ cell }}
</a> </a>
{% if row.cells.num_users != '—' %} <div class="nowrap-child">
{% if row.cells.src == 'irc' %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-post="{% url 'modal_drilldown' %}"
hx-vals='{"net": "{{ row.cells.net }}", "nick": "{{ row.cells.nick }}", "channel": "{{ row.cells.channel }}"}'
hx-target="#modals-here"
hx-trigger="click"
class="button is-small">
Information
</button>
{% endif %}
</div>
{% if row.cells.num_chans != '—' %}
<div class="nowrap-child"> <div class="nowrap-child">
<span class="tag"> <span class="tag">
{{ row.cells.num_users }} {{ row.cells.num_chans }}
</span> </span>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% else %} </td>
{% elif column.name == 'channel' %}
<td class="{{ column.name }}">
{% if cell != '—' %}
<div class="nowrap-parent">
<a class="nowrap-child has-text-link is-underlined"
onclick="populateSearch('channel', '{{ cell|escapejs }}')">
{{ cell }}
</a>
{% if row.cells.num_users != '—' %}
<div class="nowrap-child">
<span class="tag">
{{ row.cells.num_users }}
</span>
</div>
{% endif %}
</div>
{% else %}
{{ cell }}
{% endif %}
</td>
{% elif column.name == 'net' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('net', '{{ cell|escapejs }}')">
{{ cell }}
</a>
</td>
{% elif column.name == 'nick_id' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('nick_id', '{{ cell|escapejs }}')">
{{ cell }}
</a>
</td>
{% elif column.name == 'user_id' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('user_id', '{{ cell|escapejs }}')">
{{ cell }}
</a>
</td>
{% elif column.name == 'channel_id' %}
<td class="{{ column.name }}">
<a class="has-text-link is-underlined"
onclick="populateSearch('channel_id', '{{ cell|escapejs }}')">
{{ cell }}
</a>
</td>
{% elif cell is True or cell is False %}
<td class="{{ column.name }}">
{% if cell is True %}
<span class="icon has-text-success">
<i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
{% else %}
<td class="{{ column.name }}">
{{ cell }} {{ cell }}
{% endif %} </td>
</td> {% endif %}
{% elif column.name == 'net' %} {% endblock table.tbody.td %}
<td> {% endif %}
<a class="has-text-link is-underlined" {% endfor %}
onclick="populateSearch('net', '{{ cell|escapejs }}')"> </tr>
{{ cell }} {% endblock table.tbody.row %}
</a> {% empty %}
</td> {% if table.empty_text %}
{% elif column.name == 'nick_id' %} {% block table.tbody.empty_text %}
<td> <tr><td class="{{ column.name }}" colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr>
<a class="has-text-link is-underlined" {% endblock table.tbody.empty_text %}
onclick="populateSearch('nick_id', '{{ cell|escapejs }}')"> {% endif %}
{{ cell }} {% endfor %}
</a> </tbody>
</td> {% endblock table.tbody %}
{% elif column.name == 'user_id' %} {% block table.tfoot %}
<td> {% if table.has_footer %}
<a class="has-text-link is-underlined" <tfoot {{ table.attrs.tfoot.as_html }}>
onclick="populateSearch('user_id', '{{ cell|escapejs }}')"> {% block table.tfoot.row %}
{{ cell }} <tr>
</a> {% for column in table.columns %}
</td> {% block table.tfoot.td %}
{% elif column.name == 'channel_id' %} <td class="{{ column.name }}" {{ column.attrs.tf.as_html }}>{{ column.footer }}</td>
<td> {% endblock table.tfoot.td %}
<a class="has-text-link is-underlined" {% endfor %}
onclick="populateSearch('channel_id', '{{ cell|escapejs }}')"> </tr>
{{ cell }} {% endblock table.tfoot.row %}
</a> </tfoot>
</td> {% endif %}
{% elif cell == True or cell == False %} {% endblock table.tfoot %}
<td> </table>
{% if cell == True %} </div>
<span class="icon has-text-success">
<i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
{% else %}
<td>
{{ cell }}
</td>
{% endif %}
{% endblock table.tbody.td %}
{% endif %}
{% endfor %}
</tr>
{% endblock table.tbody.row %}
{% empty %}
{% if table.empty_text %}
{% block table.tbody.empty_text %}
<tr><td colspan="{{ table.columns|length }}">{{ table.empty_text }}</td></tr>
{% endblock table.tbody.empty_text %}
{% endif %}
{% endfor %}
</tbody>
{% endblock table.tbody %}
{% block table.tfoot %}
{% if table.has_footer %}
<tfoot {{ table.attrs.tfoot.as_html }}>
{% block table.tfoot.row %}
<tr>
{% for column in table.columns %}
{% block table.tfoot.td %}
<td {{ column.attrs.tf.as_html }}>{{ column.footer }}</td>
{% endblock table.tfoot.td %}
{% endfor %}
</tr>
{% endblock table.tfoot.row %}
</tfoot>
{% endif %}
{% endblock table.tfoot %}
</table>
{% endblock table %} {% endblock table %}
{% block pagination %} {% block pagination %}
{% if table.page and table.paginator.num_pages > 1 %} {% if table.page and table.paginator.num_pages > 1 %}
@ -305,7 +348,7 @@
hx-trigger="click" hx-trigger="click"
hx-target="#results" hx-target="#results"
hx-swap="innerHTML" hx-swap="innerHTML"
hx-indicator=".progress" hx-indicator="#spinner"
{% else %} {% else %}
href="#" href="#"
disabled disabled
@ -317,19 +360,20 @@
</a> </a>
{% endblock pagination.previous %} {% endblock pagination.previous %}
{% block pagination.next %} {% block pagination.next %}
<a class="pagination-next is-flex-grow-0 {% if not table.page.has_next %}is-hidden-mobile{% endif %}" <a
{% if table.page.has_next %} class="pagination-next is-flex-grow-0 {% if not table.page.has_next %}is-hidden-mobile{% endif %}"
hx-get="search/{% querystring table.prefixed_page_field=table.page.next_page_number %}&{{ uri }}" {% if table.page.has_next %}
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-get="search/{% querystring table.prefixed_page_field=table.page.next_page_number %}&{{ uri }}"
hx-trigger="click" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-target="#results" hx-trigger="click"
hx-swap="innerHTML" hx-target="#results"
hx-indicator=".progress" hx-swap="innerHTML"
{% else %} hx-indicator="#spinner"
href="#" {% else %}
disabled href="#"
{% endif %} disabled
style="order:3;" {% endif %}
style="order:3;"
> >
{% block pagination.next.text %} {% block pagination.next.text %}
<span aria-hidden="true">&raquo;</span> <span aria-hidden="true">&raquo;</span>
@ -341,19 +385,20 @@
<ul class="pagination-list is-flex-grow-0" style="order:2;"> <ul class="pagination-list is-flex-grow-0" style="order:2;">
{% for p in table.page|table_page_range:table.paginator %} {% for p in table.page|table_page_range:table.paginator %}
<li> <li>
<a class="pagination-link {% if p == table.page.number %}is-current{% endif %}" <a
aria-label="Page {{ p }}" block class="pagination-link {% if p == table.page.number %}is-current{% endif %}"
{% if p == table.page.number %}aria-current="page"{% endif %} aria-label="Page {{ p }}" block
{% if p == table.page.number %} {% if p == table.page.number %}aria-current="page"{% endif %}
href="#" {% if p == table.page.number %}
{% else %} href="#"
hx-get="search/{% querystring table.prefixed_page_field=p %}&{{ uri }}" {% else %}
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-get="search/{% querystring table.prefixed_page_field=p %}&{{ uri }}"
hx-trigger="click" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-target="#results" hx-trigger="click"
hx-swap="innerHTML" hx-target="#results"
hx-indicator=".progress" hx-swap="innerHTML"
{% endif %} hx-indicator="#spinner"
{% endif %}
> >
{% if p == '...' %} {% if p == '...' %}
<span class="pagination-ellipsis">&hellip;</span> <span class="pagination-ellipsis">&hellip;</span>

View File

@ -205,7 +205,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"] = [ context["invisible"] = [
"date", "date",
"time", "time",
"id", "id",
@ -215,6 +215,7 @@ class DrilldownTableView(SingleTableView):
"num_chans", "num_chans",
"exemption", "exemption",
"version_sentiment", "version_sentiment",
"num",
] ]
context["show"] = show context["show"] = show
if request.method == "GET": if request.method == "GET":