Browse Source

Update template

show annotation meta info
pull/10/head
Hironsan 7 years ago
parent
commit
31d48f4d5e
4 changed files with 21 additions and 8 deletions
  1. 13
      doccano/app/server/static/annotation.js
  2. 6
      doccano/app/server/templates/annotation.html
  3. 4
      doccano/app/server/urls.py
  4. 6
      doccano/app/server/views.py

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

@ -95,7 +95,9 @@ var vm = new Vue({
"text": 'document' "text": 'document'
}], }],
labels: [], labels: [],
guideline: 'Here is the Annotation Guideline Text'
guideline: 'Here is the Annotation Guideline Text',
total: 0,
remaining: 0
}, },
methods: { methods: {
@ -141,9 +143,11 @@ var vm = new Vue({
}, },
nextPage: function () { nextPage: function () {
this.cur = Math.min(this.cur + 1, this.items.length - 1); this.cur = Math.min(this.cur + 1, this.items.length - 1);
this.remaining -= 1;
}, },
prevPage: function () { prevPage: function () {
this.cur = Math.max(this.cur - 1, 0); this.cur = Math.max(this.cur - 1, 0);
this.remaining += 1;
}, },
activeLearn: function() { activeLearn: function() {
alert('Active Learning!'); alert('Active Learning!');
@ -154,6 +158,8 @@ var vm = new Vue({
axios.get('/' + base_url + '/apis/label') axios.get('/' + base_url + '/apis/label')
.then(function (response) { .then(function (response) {
self.labels = response.data['labels']; self.labels = response.data['labels'];
self.total = response.data['total'];
self.remaining = response.data['remaining'];
}) })
.catch(function (error) { .catch(function (error) {
console.log('ERROR!! happend by Backend.') console.log('ERROR!! happend by Backend.')
@ -166,5 +172,10 @@ var vm = new Vue({
.catch(function (error) { .catch(function (error) {
console.log('ERROR!! happend by Backend.') console.log('ERROR!! happend by Backend.')
}); });
},
computed: {
done: function () {
return this.total - this.remaining
}
} }
}); });

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

@ -152,9 +152,9 @@
Progress Progress
</p> </p>
<p> <p>
<a class="button is-info is-small" style="height:1.5em;">3 in set</a>
<a class="button is-success is-small" style="height:1.5em;">0 done</a>
<a class="button is-danger is-small" style="height:1.5em;">3 remaining</a>
<a class="button is-info is-small" style="height:1.5em;">[[ total ]] in set</a>
<a class="button is-success is-small" style="height:1.5em;">[[ done ]] done</a>
<a class="button is-danger is-small" style="height:1.5em;">[[ remaining ]] remaining</a>
</p> </p>
</aside> </aside>

4
doccano/app/server/urls.py

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

6
doccano/app/server/views.py

@ -49,10 +49,12 @@ class AnnotationAPIView(View):
return JsonResponse({}) return JsonResponse({})
class LabelAPIView(View):
class MetaInfoAPI(View):
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
labels = Label.objects.all() labels = Label.objects.all()
labels = [l.as_dict() for l in labels] labels = [l.as_dict() for l in labels]
total = RawData.objects.count()
remaining = RawData.objects.filter(annotation__isnull=True).count()
return JsonResponse({'labels': labels})
return JsonResponse({'labels': labels, 'total': total, 'remaining': remaining})
Loading…
Cancel
Save