diff --git a/doccano/app/db.sqlite3 b/doccano/app/db.sqlite3 index b6bf2e24..72c4f2f3 100644 Binary files a/doccano/app/db.sqlite3 and b/doccano/app/db.sqlite3 differ diff --git a/doccano/app/server/static/project_admin.js b/doccano/app/server/static/project_admin.js index 860c1e3c..0e370c2f 100644 --- a/doccano/app/server/static/project_admin.js +++ b/doccano/app/server/static/project_admin.js @@ -15,21 +15,14 @@ var vm = new Vue({ el: '#root', delimiters: ['[[', ']]'], data: { - cur: 0, - items: [{ - "id": 10, - "labels": [{ - "text": "Prefecture", - "prob": 0.98 - }], - "text": 'document' - }], todos: [], labels: [], file: null, file_name: '', newTodo: '', editedTodo: null, + newLabel: '', + newShortcut: '', }, methods: { @@ -53,6 +46,37 @@ var vm = new Vue({ console.log('FAILURE!!'); }); }, + addLabel: function () { + var payload = { + 'text': this.newLabel, + 'shortcut': this.newShortcut + }; + var self = this; + axios.post('/' + base_url + '/apis/labels', payload) + .then(function (response) { + console.log('post data'); + self.newShortcut = ''; + self.newLabel = ''; + self.labels.push(response.data); + }) + .catch(function (error) { + console.log('ERROR!! happend by Backend.') + }); + }, + removeLabel: function (index) { + var payload = this.labels[index]; + var self = this; + axios.delete('/' + base_url + '/apis/labels', { + data: payload + }) + .then(function (response) { + self.labels.splice(index, 1); + console.log('delete data'); + }) + .catch(function (error) { + console.log('ERROR!! happend by Backend.') + }); + }, addTodo: function () { var value = this.newTodo && this.newTodo.trim(); if (!value) { diff --git a/doccano/app/server/templates/admin.html b/doccano/app/server/templates/admin.html deleted file mode 100644 index 629d8377..00000000 --- a/doccano/app/server/templates/admin.html +++ /dev/null @@ -1,186 +0,0 @@ -{% extends "base.html" %} {% load static %} {% block header %} {% endblock %} {% block content %} -
-
- -
-
-
-

Learning Curve

-
-
-
- -
-
-
-
-
-
- -
-
-
-

Stats

-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-

Label Management

-
-
-
- -
-

- -

-

- -

-

- - Add - -

-
- - - - - - - - - - - - - - - - - -
- Id - Label nameShortcut keyDeletion
[[ label.id ]][[ label.text ]][[ label.shortcut ]]Delete
-
-
-
-
-
-
- -
-
-
-

Data Management

-
-
-
-

Data upload

-
- -
-
-
-
-
-
-
-
- -
- - - -{% endblock %} \ No newline at end of file diff --git a/doccano/app/server/templates/project_admin.html b/doccano/app/server/templates/project_admin.html index ca145b9a..57f7fa15 100644 --- a/doccano/app/server/templates/project_admin.html +++ b/doccano/app/server/templates/project_admin.html @@ -1,19 +1,96 @@ -{% extends "base.html" %} {% load static %} -{% block header %} - -{% endblock %} -{% block content %} +{% extends "base.html" %} {% load static %} {% block header %} {% endblock %} {% block content %}
-
+
-

Project Dataset

+

Learning Curve

-
+ +
+
+
+
+
+
+ +
+
+
+

Stats

+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+
+

Label Management

+
+
+
+ +
+

+ +

+

+ +

+

+ + Add + +

+
+ + + + + + + + + + + + + + + + + +
+ Id + Label nameShortcut keyDeletion
[[ index + 1 ]][[ label.text ]][[ label.shortcut ]]Delete
+
+
+
+
+
+
+ +
+
+
+

Data Management

+
+
+
+

Data upload

+
-
-
- -
-
- - - - -
-
-

Label Settings

- -
-
-
    -
  • -
    - - -
    - -
  • -
-
-
-
+
+ + {% endblock %} \ No newline at end of file diff --git a/doccano/app/server/urls.py b/doccano/app/server/urls.py index f709950e..f8347b21 100644 --- a/doccano/app/server/urls.py +++ b/doccano/app/server/urls.py @@ -1,13 +1,12 @@ from django.urls import path -from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI, SearchAPI, TestView +from .views import AnnotationView, AnnotationAPIView, MetaInfoAPI, SearchAPI from .views import ProjectListView, ProjectDetailView, ProjectAdminView, RawDataAPI, LabelAPI urlpatterns = [ path('', ProjectListView.as_view(), name='project-list'), path('/', ProjectDetailView.as_view(), name='project-detail'), path('/admin', ProjectAdminView.as_view()), - path('/test', TestView.as_view()), path('/docs', AnnotationView.as_view()), path('/apis/data', AnnotationAPIView.as_view()), path('/apis/raw_data', RawDataAPI.as_view(), name='data_api'), diff --git a/doccano/app/server/views.py b/doccano/app/server/views.py index 783cbdd6..a47c3517 100644 --- a/doccano/app/server/views.py +++ b/doccano/app/server/views.py @@ -87,11 +87,16 @@ class LabelAPI(View): def post(self, request, *args, **kwargs): """Create labels.""" - text = request.POST.get('text') - shortcut = request.POST.get('shortcut') - Label(text=text, shortcut=shortcut).save() + #text = request.POST.get('text') + #shortcut = request.POST.get('shortcut') + body = request.body.decode('utf-8').replace("'", '"') + body = json.loads(body) + text = body.get('text') + shortcut = body.get('shortcut') + label = Label(text=text, shortcut=shortcut) + label.save() - return JsonResponse({'status': 'ok'}) + return JsonResponse(label.as_dict()) def put(self, request, *args, **kwargs): """Update labels.""" @@ -163,10 +168,3 @@ class ProjectAdminView(DetailView): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) return context - - -class TestView(View): - template_name = 'admin.html' - - def get(self, request, *args, **kwargs): - return render(request, self.template_name)