|
|
|
@ -3,21 +3,58 @@
|
|
|
|
|
{% block content %}
|
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
|
|
|
<script>
|
|
|
|
|
function populateSearch(field, value) {
|
|
|
|
|
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) {
|
|
|
|
|
var queryElement = document.getElementById('query');
|
|
|
|
|
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)) {
|
|
|
|
|
queryElement.value+=toAppend;
|
|
|
|
|
|
|
|
|
|
if (fromTag) {
|
|
|
|
|
queryElement.value+=toAppend;
|
|
|
|
|
} else {
|
|
|
|
|
queryElement.value+=toAppend;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
queryElement.value = queryElement.value.replaceAll(toAppend, "");
|
|
|
|
|
queryElement.value = queryElement.value.replaceAll(toRemove, "");
|
|
|
|
|
if (fromTag) {
|
|
|
|
|
queryElement.value = queryElement.value.replaceAll(toAppend, "");
|
|
|
|
|
queryElement.value = queryElement.value.replaceAll(toRemove, "");
|
|
|
|
|
} else {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (field == "src") {
|
|
|
|
|
document.getElementById("source").selectedIndex = 0;
|
|
|
|
@ -181,34 +218,30 @@
|
|
|
|
|
for(var i = 0; i < calendars.length; i++) {
|
|
|
|
|
// Add listener to select event
|
|
|
|
|
calendars[i].on('save', date => {
|
|
|
|
|
console.log(date);
|
|
|
|
|
htmx.trigger("#search", "click");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// To access to bulmaCalendar instance of an element
|
|
|
|
|
var element = document.querySelector('#my-element');
|
|
|
|
|
if (element) {
|
|
|
|
|
// bulmaCalendar instance is available as element.bulmaCalendar
|
|
|
|
|
element.bulmaCalendar.on('select', function(datepicker) {
|
|
|
|
|
console.log(datepicker.data.value());
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="control">
|
|
|
|
|
<label class="radio">
|
|
|
|
|
<label class="radio button has-text-link">
|
|
|
|
|
<input type="radio" value="desc" name="sorting" checked>
|
|
|
|
|
Desc
|
|
|
|
|
<span class="icon" data-tooltip="Sort descending">
|
|
|
|
|
<i class="fa-solid fa-sort-down"></i>
|
|
|
|
|
</span>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="radio">
|
|
|
|
|
<label class="radio button">
|
|
|
|
|
<input type="radio" value="asc" name="sorting">
|
|
|
|
|
Asc
|
|
|
|
|
<span class="icon" data-tooltip="Sort ascending">
|
|
|
|
|
<i class="fa-solid fa-sort-up"></i>
|
|
|
|
|
</span>
|
|
|
|
|
</label>
|
|
|
|
|
<label class="radio">
|
|
|
|
|
<label class="radio button">
|
|
|
|
|
<input type="radio" value="none" name="sorting">
|
|
|
|
|
None
|
|
|
|
|
<span class="icon" data-tooltip="No sort">
|
|
|
|
|
<i class="fa-solid fa-sort"></i>
|
|
|
|
|
</span>
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -218,6 +251,34 @@
|
|
|
|
|
<div class="is-hidden"></div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
|
|
|
|
<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) {
|
|
|
|
|
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);
|
|
|
|
|
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>
|
|
|
|
|
<div class="block">
|
|
|
|
|
<div id="results">
|
|
|
|
|
</div>
|
|
|
|
|