UI tweaks, path autocomplete

This commit is contained in:
simon 2019-10-31 08:26:19 -04:00
parent 5661573b06
commit f8b081a3f4
7 changed files with 23 additions and 26 deletions

View File

@ -10,7 +10,7 @@
#define EPILOG "Made by simon987 <me@simon987.net>. Released under GPL-3.0"
static const char *const Version = "1.0.11";
static const char *const Version = "1.0.12";
static const char *const usage[] = {
"sist2 scan [OPTION]... PATH",
"sist2 index [OPTION]... INDEX",

File diff suppressed because one or more lines are too long

View File

@ -15,6 +15,8 @@ body {
margin-top: 1em;
background: #212121;
color: #e0e0e0;
border-radius: 1px;
border: none;
}
.navbar-brand {

View File

@ -6,6 +6,7 @@ body {overflow-y:scroll;}
.card {
margin-top: 1em;
box-shadow: 0 .125rem .25rem rgba(0,0,0,.075) !important;
}
.navbar-brand {
font-size: 1.75rem;

View File

@ -82,7 +82,7 @@ function shouldPlayVideo(hit) {
*/
function createDocCard(hit) {
let docCard = document.createElement("div");
docCard.setAttribute("class", "card shadow-sm");
docCard.setAttribute("class", "card");
let docCardBody = document.createElement("div");
docCardBody.setAttribute("class", "card-body document");
@ -257,7 +257,7 @@ function makePreloader() {
function makePageIndicator(searchResult) {
let pageIndicator = document.createElement("div");
pageIndicator.setAttribute("class", "page-indicator shadow-sm font-weight-light");
pageIndicator.setAttribute("class", "page-indicator font-weight-light");
const totalHits = searchResult["hits"]["total"].hasOwnProperty("value")
? searchResult["hits"]["total"]["value"] : searchResult["hits"]["total"];
pageIndicator.appendChild(document.createTextNode(docCount + " / " + totalHits));

View File

@ -116,7 +116,7 @@ $.jsonPost("es", {
new autoComplete({
selector: '#pathBar',
minChars: 1,
delay: 75,
delay: 400,
renderItem: function (item) {
return '<div class="autocomplete-suggestion" data-val="' + item + '">' + item + '</div>';
},
@ -279,14 +279,6 @@ function search() {
//Search stats
searchResults.appendChild(makeStatsCard(searchResult));
//Autocomplete
if (searchResult.hasOwnProperty("suggest") && searchResult["suggest"].hasOwnProperty("path")) {
pathAutoComplete = [];
for (let i = 0; i < searchResult["suggest"]["path"][0]["options"].length; i++) {
pathAutoComplete.push(searchResult["suggest"]["path"][0]["options"][i].text)
}
}
//Setup page
let resultContainer = makeResultContainer();
searchResults.appendChild(resultContainer);
@ -298,7 +290,6 @@ function search() {
});
}
let pathAutoComplete = [];
let size_min = 0;
let size_max = 10000000000000;
@ -306,8 +297,8 @@ let searchDebounced = _.debounce(function () {
coolingDown = false;
search()
}, 500);
searchBar.addEventListener("keyup", searchDebounced);
document.getElementById("pathBar").addEventListener("keyup", searchDebounced);
//Size slider
$("#sizeSlider").ionRangeSlider({
@ -358,15 +349,18 @@ updateIndices();
//Suggest
function getPathChoices() {
return new Promise(getPaths => {
let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
getPaths(JSON.parse(xhttp.responseText))
$.jsonPost("es", {
suggest: {
path: {
prefix: pathBar.value,
completion: {
field: "suggest-path",
skip_duplicates: true,
size: 10000
}
}
}
};
xhttp.open("GET", "suggest?prefix=" + pathBar.value, true);
xhttp.send();
});
}).then(resp => getPaths(resp["suggest"]["path"][0]["options"].map(opt => opt["_source"]["path"])));
})
}