2022-07-21 12:45:28 +00:00
|
|
|
{% extends "base.html" %}
|
2022-07-21 12:46:48 +00:00
|
|
|
{% load static %}
|
2022-07-21 12:45:28 +00:00
|
|
|
{% block content %}
|
2022-07-21 12:51:01 +00:00
|
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
2022-08-03 06:20:30 +00:00
|
|
|
<script>
|
2022-08-03 06:20:30 +00:00
|
|
|
function addTag(value) {
|
|
|
|
var inputTags = document.getElementById('tags');
|
|
|
|
var btiInstance = inputTags.BulmaTagsInput();
|
|
|
|
btiInstance.add(value);
|
|
|
|
}
|
|
|
|
function delTag(value) {
|
|
|
|
var inputTags = document.getElementById('tags');
|
|
|
|
var btiInstance = inputTags.BulmaTagsInput();
|
|
|
|
btiInstance.remove(value);
|
|
|
|
}
|
|
|
|
function toggleTag(field, value) {
|
|
|
|
var queryElement = document.getElementById('query');
|
|
|
|
var tagText = `${field}: ${value}`;
|
|
|
|
var present = true;
|
|
|
|
if (present == true) {
|
|
|
|
var toAppend = ` AND ${field}: "${value}"`;
|
|
|
|
var toRemove = `${field}: "${value}"`;
|
|
|
|
var tagText = `${field}: ${value}`;
|
|
|
|
} else {
|
|
|
|
var toAppend = ` AND NOT ${field}: "${value}"`;
|
|
|
|
var toRemove = `NOT ${field}: "${value}"`;
|
|
|
|
}
|
|
|
|
if (!queryElement.value.includes(toAppend) && !queryElement.value.includes(toRemove)) {
|
|
|
|
addTag(tagText);
|
|
|
|
} else {
|
|
|
|
delTag(tagText);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function populateSearch(field, value, fromTag=false) {
|
2022-08-03 06:20:30 +00:00
|
|
|
var queryElement = document.getElementById('query');
|
2022-08-03 06:20:30 +00:00
|
|
|
var present = true;
|
|
|
|
if (present == true) {
|
|
|
|
var toAppend = ` AND ${field}: "${value}"`;
|
2022-08-03 06:20:30 +00:00
|
|
|
var toRemove = `${field}: "${value}"`;
|
2022-08-03 06:20:30 +00:00
|
|
|
var tagText = `${field}: ${value}`;
|
2022-08-03 06:20:30 +00:00
|
|
|
} else {
|
|
|
|
var toAppend = ` AND NOT ${field}: "${value}"`;
|
2022-08-03 06:20:30 +00:00
|
|
|
var toRemove = `NOT ${field}: "${value}"`;
|
2022-08-03 06:20:30 +00:00
|
|
|
}
|
2022-08-03 06:20:30 +00:00
|
|
|
if (!queryElement.value.includes(toAppend) && !queryElement.value.includes(toRemove)) {
|
2022-08-03 06:20:30 +00:00
|
|
|
|
|
|
|
if (fromTag) {
|
|
|
|
queryElement.value+=toAppend;
|
|
|
|
} else {
|
|
|
|
queryElement.value+=toAppend;
|
|
|
|
}
|
2022-08-03 06:20:30 +00:00
|
|
|
} else {
|
2022-08-03 06:20:30 +00:00
|
|
|
if (fromTag) {
|
|
|
|
queryElement.value = queryElement.value.replaceAll(toAppend, "");
|
|
|
|
queryElement.value = queryElement.value.replaceAll(toRemove, "");
|
|
|
|
} else {
|
|
|
|
}
|
2022-08-03 06:20:30 +00:00
|
|
|
}
|
|
|
|
if (field == "src") {
|
|
|
|
document.getElementById("source").selectedIndex = 0;
|
|
|
|
}
|
2022-08-03 06:20:30 +00:00
|
|
|
if (queryElement.value.startsWith(" AND ")) {
|
|
|
|
queryElement.value = queryElement.value.replace(" AND ", "");
|
|
|
|
}
|
2022-08-03 06:20:30 +00:00
|
|
|
htmx.trigger("#search", "click");
|
|
|
|
}
|
|
|
|
</script>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<form method="POST" hx-post="{% url 'search_drilldown' %}"
|
|
|
|
hx-trigger="change"
|
|
|
|
hx-target="#results"
|
2022-08-03 06:20:30 +00:00
|
|
|
hx-swap="innerHTML"
|
|
|
|
hx-indicator="#spinner">
|
2022-07-21 12:49:11 +00:00
|
|
|
{% csrf_token %}
|
2022-08-03 06:20:30 +00:00
|
|
|
|
|
|
|
<div class="columns">
|
|
|
|
<div class="column">
|
|
|
|
<div class="field has-addons">
|
2022-07-21 12:49:11 +00:00
|
|
|
<div class="control is-expanded has-icons-left">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input
|
|
|
|
hx-post="{% url 'search_drilldown' %}"
|
|
|
|
hx-trigger="keyup changed delay:200ms"
|
|
|
|
hx-target="#results"
|
2022-08-03 06:20:30 +00:00
|
|
|
hx-swap="innerHTML" id="query" name="query" class="input" type="text" placeholder="msg: science AND nick: BillNye AND channel: #science">
|
2022-07-21 12:49:11 +00:00
|
|
|
<span class="icon is-small is-left">
|
|
|
|
<i class="fas fa-magnifying-glass"></i>
|
|
|
|
</span>
|
2022-07-21 12:47:16 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="control">
|
|
|
|
<div class="field">
|
|
|
|
<button
|
2022-08-03 06:20:30 +00:00
|
|
|
id="search"
|
2022-08-03 06:20:30 +00:00
|
|
|
class="button is-info is-fullwidth"
|
2022-08-03 06:20:30 +00:00
|
|
|
hx-post="{% url 'search_drilldown' %}"
|
|
|
|
hx-trigger="click"
|
|
|
|
hx-target="#results"
|
|
|
|
hx-swap="innerHTML">
|
|
|
|
Search
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-21 12:46:48 +00:00
|
|
|
</div>
|
2022-07-21 12:49:01 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="column is-3">
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="nowrap-parent">
|
|
|
|
<div
|
|
|
|
_="on click toggle .is-hidden on #options"
|
|
|
|
class="button is-light has-text-link is-right nowrap-child">
|
|
|
|
Options
|
|
|
|
</div>
|
|
|
|
<div class="nowrap-child">
|
|
|
|
<span id="spinner" class="button is-light has-text-link is-loading htmx-indicator">Static</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div id="options" class="box is-hidden">
|
|
|
|
<div class="columns is-multiline">
|
|
|
|
<div class="column is-narrow">
|
|
|
|
<div class="field has-addons">
|
|
|
|
<div class="control has-icons-left">
|
|
|
|
<span class="select">
|
|
|
|
<select name="size">
|
|
|
|
{% for size in sizes %}
|
|
|
|
<option value="{{ size }}">{{ size }}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
<span class="icon is-small is-left">
|
|
|
|
<i class="fas fa-magnifying-glass"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
|
|
|
<p class="control">
|
|
|
|
<a class="button is-static">
|
|
|
|
results
|
|
|
|
</a>
|
|
|
|
</p>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="column is-narrow">
|
2022-08-03 22:54:48 +00:00
|
|
|
<div class="field has-addons">
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="control has-icons-left">
|
|
|
|
<span class="select">
|
|
|
|
<select id="source" name="source">
|
|
|
|
<option selected value="all">All</option>
|
|
|
|
<option value="irc">IRC</option>
|
|
|
|
<option value="dis">Discord</option>
|
|
|
|
</select>
|
|
|
|
<span class="icon is-small is-left">
|
|
|
|
<i class="fas fa-magnifying-glass"></i>
|
|
|
|
</span>
|
|
|
|
</span>
|
2022-08-03 22:54:48 +00:00
|
|
|
</div>
|
|
|
|
<p class="control">
|
|
|
|
<a class="button is-static">
|
2022-08-03 06:20:30 +00:00
|
|
|
source
|
2022-08-03 22:54:48 +00:00
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
|
|
|
<div class="column is-narrow">
|
|
|
|
<div id="sentiment">
|
|
|
|
<div class="field has-addons">
|
|
|
|
<div class="control">
|
|
|
|
<input disabled="undefined" name="sentiment" id="sliderWithValue" class="slider has-output-tooltip is-fullwidth" min="-1" max="1" value="0" step="0.05" type="range">
|
|
|
|
<output for="sliderWithValue" class="slider-output">0</output>
|
|
|
|
<script>bulmaSlider.attach();</script>
|
|
|
|
</div>
|
|
|
|
<p class="control">
|
|
|
|
<a class="button is-static">
|
|
|
|
sentiment
|
|
|
|
</a>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button has-text-link">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="below" name="sentiment-method">
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="Below">
|
|
|
|
<i class="fa-solid fa-face-frown"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button has-text-link is-hidden">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="exact" name="sentiment-method">
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="Exact">
|
|
|
|
<i class="fa-solid fa-face-smile"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button has-text-link">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="above" name="sentiment-method">
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="Above">
|
|
|
|
<i class="fa-solid fa-face-smile"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button has-text-link">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="nonzero" name="sentiment-method">
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="Nonzero">
|
|
|
|
<i class="fa-solid fa-face-meh-blank"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
|
|
|
|
<label class="checkbox">
|
|
|
|
<input type="checkbox" name="check-sentiment"
|
|
|
|
_="on click toggle @disabled on #sliderWithValue then toggle @disabled on #sentiment">
|
|
|
|
Check sentiment
|
|
|
|
</label>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="column is-narrow">
|
|
|
|
<div id="date">
|
|
|
|
<div class="field">
|
|
|
|
<div class="control">
|
|
|
|
<input type="date" name="dates">
|
|
|
|
<script>
|
|
|
|
var options = {
|
|
|
|
"type": "datetime",
|
|
|
|
"isRange": true,
|
|
|
|
"color": "info",
|
|
|
|
"validateLabel": "Save",
|
|
|
|
"dateFormat": "yyyy-MM-dd",
|
|
|
|
};
|
|
|
|
// Initialize all input of type date
|
|
|
|
var calendars = bulmaCalendar.attach('[type="date"]', options);
|
2022-08-03 22:54:48 +00:00
|
|
|
|
2022-08-03 06:20:30 +00:00
|
|
|
// Loop on each calendar initialized
|
|
|
|
for(var i = 0; i < calendars.length; i++) {
|
|
|
|
// Add listener to select event
|
|
|
|
calendars[i].on('save', date => {
|
|
|
|
htmx.trigger("#search", "click");
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button has-text-link">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="desc" name="sorting" checked>
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="Sort descending">
|
|
|
|
<i class="fa-solid fa-sort-down"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="asc" name="sorting">
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="Sort ascending">
|
|
|
|
<i class="fa-solid fa-sort-up"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
2022-08-03 06:20:30 +00:00
|
|
|
<label class="radio button">
|
2022-08-03 06:20:30 +00:00
|
|
|
<input type="radio" value="none" name="sorting">
|
2022-08-03 06:20:30 +00:00
|
|
|
<span class="icon" data-tooltip="No sort">
|
|
|
|
<i class="fa-solid fa-sort"></i>
|
|
|
|
</span>
|
2022-08-03 06:20:30 +00:00
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
</div>
|
2022-07-21 12:49:01 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="is-hidden"></div>
|
2022-07-21 12:49:11 +00:00
|
|
|
</form>
|
2022-07-21 12:46:05 +00:00
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="block">
|
|
|
|
<input id="tags" class="input" type="tags" placeholder="Add query" value="">
|
|
|
|
<script>
|
|
|
|
var inputTags = document.getElementById('tags');
|
|
|
|
new BulmaTagsInput(inputTags);
|
|
|
|
inputTags.BulmaTagsInput().on('before.add', function(item) {
|
2022-08-03 06:20:30 +00:00
|
|
|
if (item.includes(": ")) {
|
|
|
|
var spl = item.split(": ");
|
|
|
|
} else {
|
|
|
|
var spl = item.split(":");
|
|
|
|
}
|
2022-08-03 06:20:30 +00:00
|
|
|
var field = spl[0];
|
|
|
|
try {
|
|
|
|
var value = JSON.parse(spl[1]);
|
|
|
|
} catch {
|
|
|
|
var value = spl[1];
|
|
|
|
}
|
|
|
|
populateSearch(field, value, fromTag=true);
|
|
|
|
return `${field}: ${value}`;
|
|
|
|
});
|
|
|
|
inputTags.BulmaTagsInput().on('after.remove', function(item) {
|
|
|
|
var spl = item.split(": ");
|
|
|
|
var field = spl[0];
|
|
|
|
try {
|
|
|
|
var value = JSON.parse(spl[1]);
|
|
|
|
} catch {
|
|
|
|
var value = spl[1];
|
|
|
|
}
|
|
|
|
populateSearch(field, value, fromTag=true);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</div>
|
2022-08-03 06:20:30 +00:00
|
|
|
<div class="block">
|
2022-08-03 22:26:22 +00:00
|
|
|
<div id="results">
|
|
|
|
</div>
|
2022-07-21 12:50:51 +00:00
|
|
|
</div>
|
2022-07-21 12:52:06 +00:00
|
|
|
<div id="modals-here">
|
|
|
|
</div>
|
2022-07-21 12:45:28 +00:00
|
|
|
{% endblock %}
|