From 31d48f4d5e13e0e385b87df04e5e96a7e647e618 Mon Sep 17 00:00:00 2001
From: Hironsan
Date: Mon, 21 May 2018 10:22:25 +0900
Subject: [PATCH] Update template
show annotation meta info
---
doccano/app/server/static/annotation.js | 13 ++++++++++++-
doccano/app/server/templates/annotation.html | 6 +++---
doccano/app/server/urls.py | 4 ++--
doccano/app/server/views.py | 6 ++++--
4 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/doccano/app/server/static/annotation.js b/doccano/app/server/static/annotation.js
index d5b79e84..e0a34c75 100644
--- a/doccano/app/server/static/annotation.js
+++ b/doccano/app/server/static/annotation.js
@@ -95,7 +95,9 @@ var vm = new Vue({
"text": 'document'
}],
labels: [],
- guideline: 'Here is the Annotation Guideline Text'
+ guideline: 'Here is the Annotation Guideline Text',
+ total: 0,
+ remaining: 0
},
methods: {
@@ -141,9 +143,11 @@ var vm = new Vue({
},
nextPage: function () {
this.cur = Math.min(this.cur + 1, this.items.length - 1);
+ this.remaining -= 1;
},
prevPage: function () {
this.cur = Math.max(this.cur - 1, 0);
+ this.remaining += 1;
},
activeLearn: function() {
alert('Active Learning!');
@@ -154,6 +158,8 @@ var vm = new Vue({
axios.get('/' + base_url + '/apis/label')
.then(function (response) {
self.labels = response.data['labels'];
+ self.total = response.data['total'];
+ self.remaining = response.data['remaining'];
})
.catch(function (error) {
console.log('ERROR!! happend by Backend.')
@@ -166,5 +172,10 @@ var vm = new Vue({
.catch(function (error) {
console.log('ERROR!! happend by Backend.')
});
+ },
+ computed: {
+ done: function () {
+ return this.total - this.remaining
+ }
}
});
\ No newline at end of file
diff --git a/doccano/app/server/templates/annotation.html b/doccano/app/server/templates/annotation.html
index 80be9054..a9748f2f 100644
--- a/doccano/app/server/templates/annotation.html
+++ b/doccano/app/server/templates/annotation.html
@@ -152,9 +152,9 @@
Progress
- 3 in set
- 0 done
- 3 remaining
+ [[ total ]] in set
+ [[ done ]] done
+ [[ remaining ]] remaining
diff --git a/doccano/app/server/urls.py b/doccano/app/server/urls.py
index 5738317c..3da91af0 100644
--- a/doccano/app/server/urls.py
+++ b/doccano/app/server/urls.py
@@ -1,9 +1,9 @@
from django.urls import path
-from .views import AnnotationView, AnnotationAPIView, LabelAPIView
+from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI
urlpatterns = [
path('/docs', AnnotationView.as_view()),
path('/apis/data', AnnotationAPIView.as_view()),
- path('/apis/label', LabelAPIView.as_view()),
+ path('/apis/label', MetaInfoAPI.as_view()),
]
diff --git a/doccano/app/server/views.py b/doccano/app/server/views.py
index 3b30e4a9..44af694a 100644
--- a/doccano/app/server/views.py
+++ b/doccano/app/server/views.py
@@ -49,10 +49,12 @@ class AnnotationAPIView(View):
return JsonResponse({})
-class LabelAPIView(View):
+class MetaInfoAPI(View):
def get(self, request, *args, **kwargs):
labels = Label.objects.all()
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})