Browse Source

Update template

pull/10/head
Hironsan 6 years ago
parent
commit
387582e7e2
5 changed files with 38 additions and 10 deletions
  1. BIN
      doccano/app/db.sqlite3
  2. 18
      doccano/app/server/static/annotation.js
  3. 13
      doccano/app/server/templates/annotation.html
  4. 3
      doccano/app/server/urls.py
  5. 14
      doccano/app/server/views.py

BIN
doccano/app/db.sqlite3

18
doccano/app/server/static/annotation.js

@ -97,7 +97,9 @@ var vm = new Vue({
labels: [],
guideline: 'Here is the Annotation Guideline Text',
total: 0,
remaining: 0
remaining: 0,
searchQuery: '',
history: []
},
methods: {
@ -149,8 +151,20 @@ var vm = new Vue({
this.cur = Math.max(this.cur - 1, 0);
this.remaining += 1;
},
activeLearn: function() {
activeLearn: function () {
alert('Active Learning!');
},
submit: function () {
console.log('submit' + this.searchQuery);
var self = this;
axios.get('/' + base_url + '/apis/search?keyword=' + this.searchQuery)
.then(function (response) {
console.log('search response');
self.history = response.data['data'];
})
.catch(function (error) {
console.log('ERROR!! happend by Backend.')
});
}
},
created: function () {

13
doccano/app/server/templates/annotation.html

@ -100,7 +100,7 @@
</a>
</div>
<div class="buttons has-addons is-right">
<a class="button is-small" v-on:click="nextPage" :disabled="cur + done == total">
<a class="button is-small" v-on:click="nextPage" :disabled="remaining == 1">
<span>Next</span>
<span class="icon">
<i class="fas fa-chevron-circle-right"></i>
@ -149,7 +149,7 @@
</p>
</aside>
<aside class="menu" style="padding-top:1rem;">
<aside class="menu" style="padding-top:1.5rem;">
<p class="menu-label" style="padding-left:0;">
Progress
</p>
@ -160,7 +160,7 @@
</p>
</aside>
<aside class="menu" style="padding-top:1rem;">
<aside class="menu" style="padding-top:1.5rem;">
<p class="menu-label" style="padding-left:0;">
Tags
</p>
@ -181,18 +181,17 @@
<div class="field">
<label class="label">Search</label>
<div class="control">
<input class="input" type="text" placeholder="Text input">
<input class="input" type="text" placeholder="Text input" v-model="searchQuery" @keyup.enter="submit">
</div>
</div>
<div class="card" v-for="item in items.slice(0, cur)">
<div class="card" v-for="item in history">
<div class="card-content">
<div class="content">
<p>
[[ item['text'] ]]
[[ item['text'].slice(0, 100) ]]
</p>
<div class="tags">
<a class="tag is-grey" v-for="label in item.labels">[[ label.text ]]</a>
<!--<a class="tag is-grey">Label2</a>-->
</div>
</div>
</div>

3
doccano/app/server/urls.py

@ -1,9 +1,10 @@
from django.urls import path
from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI
from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI, SearchAPI
urlpatterns = [
path('<int:project_id>/docs', AnnotationView.as_view()),
path('<int:project_id>/apis/data', AnnotationAPIView.as_view()),
path('<int:project_id>/apis/label', MetaInfoAPI.as_view()),
path('<int:project_id>/apis/search', SearchAPI.as_view()),
]

14
doccano/app/server/views.py

@ -58,3 +58,17 @@ class MetaInfoAPI(View):
remaining = RawData.objects.filter(annotation__isnull=True).count()
return JsonResponse({'labels': labels, 'total': total, 'remaining': remaining})
class SearchAPI(View):
def get(self, request, *args, **kwargs):
keyword = request.GET.get('keyword')
docs = RawData.objects.filter(text__contains=keyword)
labels = [[a.as_dict() for a in Annotation.objects.filter(data=d.id)] for d in docs]
# print(annotations)
# print(docs)
docs = [{**d.as_dict(), **{'labels': []}} for d in docs]
# Annotation.objects.select_related('data').all().filter(data__text__contains=keyword)
return JsonResponse({'data': docs})
Loading…
Cancel
Save