Browse Source

Update search

pull/10/head
Hironsan 6 years ago
parent
commit
a57f6f39d8
3 changed files with 5 additions and 11 deletions
  1. 5
      doccano/app/server/static/annotation.1.js
  2. 9
      doccano/app/server/templates/annotation.1.html
  3. 2
      doccano/app/server/views.py

5
doccano/app/server/static/annotation.1.js

@ -26,7 +26,6 @@ var vm = new Vue({
total: 0, total: 0,
remaining: 0, remaining: 0,
searchQuery: '', searchQuery: '',
history: []
}, },
methods: { methods: {
@ -90,7 +89,9 @@ var vm = new Vue({
axios.get('/' + base_url + '/apis/search?keyword=' + this.searchQuery) axios.get('/' + base_url + '/apis/search?keyword=' + this.searchQuery)
.then(function (response) { .then(function (response) {
console.log('search response'); console.log('search response');
self.history = response.data['data'];
console.log(response.data['data']);
self.items = response.data['data'];
self.searchQuery = '';
}) })
.catch(function (error) { .catch(function (error) {
console.log('ERROR!! happend by Backend.') console.log('ERROR!! happend by Backend.')

9
doccano/app/server/templates/annotation.1.html

@ -8,15 +8,6 @@
<span class="compose">Active Learn</span> <span class="compose">Active Learn</span>
</a> </a>
</div> </div>
<!--
<div class="main">
<a href="#" class="item active">
<span class="icon">
<i class="fa fa-inbox"></i>
</span>
<span class="name">Inbox</span>
</a>
</div>-->
<aside class="menu"> <aside class="menu">
<p class="menu-label" style="color:#f2f2f2;"> <p class="menu-label" style="color:#f2f2f2;">
Progress Progress

2
doccano/app/server/views.py

@ -82,6 +82,8 @@ class SearchAPI(View):
docs = Document.objects.filter(text__contains=keyword) docs = Document.objects.filter(text__contains=keyword)
labels = [[a.as_dict() for a in Annotation.objects.filter(data=d.id)] for d in docs] labels = [[a.as_dict() for a in Annotation.objects.filter(data=d.id)] for d in docs]
docs = [{**d.as_dict(), **{'labels': []}} for d in docs] docs = [{**d.as_dict(), **{'labels': []}} for d in docs]
if not docs:
docs = [{'id': None, 'labels': [], 'text': ''}]
# Annotation.objects.select_related('data').all().filter(data__text__contains=keyword) # Annotation.objects.select_related('data').all().filter(data__text__contains=keyword)
return JsonResponse({'data': docs}) return JsonResponse({'data': docs})

Loading…
Cancel
Save