javascript debugging
This commit is contained in:
parent
04684c5f65
commit
99131374cd
@ -52,6 +52,25 @@ def search_user():
|
||||
data = queries.do_user_search(searchword, terms)
|
||||
|
||||
# filter sensitive stuff
|
||||
# we only need. objectID, full_name, username
|
||||
hits = data.get('hits')
|
||||
|
||||
new_hits = []
|
||||
|
||||
for hit in hits.get('hits'):
|
||||
source = hit['_source']
|
||||
single_hit = {
|
||||
'_source': {
|
||||
'objectID': source.get('objectID'),
|
||||
'username': source.get('username'),
|
||||
'full_name': source.get('full_name'),
|
||||
}
|
||||
}
|
||||
|
||||
new_hits.append(single_hit)
|
||||
|
||||
# replace search result with safe subset
|
||||
data['hits']['hits'] = new_hits
|
||||
|
||||
return jsonify(data)
|
||||
|
||||
|
@ -42,7 +42,7 @@ $(document).ready(function() {
|
||||
toggleIconEmptyInput(!query.trim());
|
||||
// what could be like "/users"
|
||||
search.setQuery(query, what);
|
||||
//setURLParams(search);
|
||||
// setURLParams(search);
|
||||
search.execute();
|
||||
}).focus();
|
||||
|
||||
|
@ -125,15 +125,17 @@ var elasticSearch = (function($, url) {
|
||||
url = '';
|
||||
}
|
||||
|
||||
console.log('searching! '+ url + q);
|
||||
console.log('searching! '+ url + ' q= ' + q);
|
||||
|
||||
$.getJSON("/api/newsearch" + url + "?q=" + q, function( data ) {
|
||||
let hits = data.hits.hits;
|
||||
newhits = hits.map(function(hit){
|
||||
return hit._source;
|
||||
});
|
||||
//cb(newhits.slice(0));
|
||||
cb(newhits.slice(0));
|
||||
if(async !== undefined){
|
||||
async(newhits.slice(0));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -155,6 +157,7 @@ $(document).ready(function() {
|
||||
minLength: 0,
|
||||
templates: {
|
||||
suggestion: function(hit) {
|
||||
console.log('hit!');
|
||||
var hitMedia = (hit.media ? ' · <span class="media">'+hit.media+'</span>' : '');
|
||||
var hitFree = (hit.is_free ? '<div class="search-hit-ribbon"><span>free</span></div>' : '');
|
||||
var hitPicture;
|
||||
|
@ -7,9 +7,9 @@
|
||||
{
|
||||
source: elasticSearch($, '/user'),
|
||||
displayKey: 'full_name',
|
||||
async: true,
|
||||
//async: true,
|
||||
minLength: 1,
|
||||
limit: 10,
|
||||
limit: 9,
|
||||
templates: {
|
||||
suggestion: function (hit) {
|
||||
var suggestion = hit.full_name + ' (' + hit.username + ')';
|
||||
|
Loading…
x
Reference in New Issue
Block a user