From 7c0ff4479bf450eb04cccd32a0b4ed73b7e532c9 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 7 Jun 2018 12:53:46 +0900 Subject: [PATCH] Update admin template --- doccano/app/db.sqlite3 | Bin 180224 -> 184320 bytes doccano/app/server/static/project_admin.js | 42 +++- doccano/app/server/templates/admin.html | 186 ----------------- .../app/server/templates/project_admin.html | 193 ++++++++++++++---- doccano/app/server/urls.py | 3 +- doccano/app/server/views.py | 20 +- 6 files changed, 197 insertions(+), 247 deletions(-) delete mode 100644 doccano/app/server/templates/admin.html diff --git a/doccano/app/db.sqlite3 b/doccano/app/db.sqlite3 index b6bf2e24e24cdcf8059a8a82b417ca058a564142..72c4f2f3c472c6ecea1289d9b8ceaeda3493c9ae 100644 GIT binary patch delta 766 zcmchU%WD%+6vpqJxy`gm=AHz66)8k&L5i8o%$-M)jSyTYRN`6~+o6WGo1~^$R9%=t zHZFupOJ^md6kOIykiiz|LR@rZixwAdDv1;qHi{9HSa4=G*8Tw=IKRzz&UYVQwHm3` zBlBm)4nipDbx@Bkn7H$7Y)iuC!f@&yri~}5n`=A|-x|W+;U;fV*AePCCw`#2^bOsj zujotax>xGhro%lv#=T}hBcL8o3&;Yh0TuV-Djvk1+kqpjd8-fw0XTX{f70*tpm8oS zO9u(xhfN=b58a36gZWT>C~kZcw_~)&yE=xh|9~WP9lDKggzzlxN9zkpY=pCzv-}QU zJ!K?iBO#kvMak++Qkk62FiTz9{a4b`lBt?XCT%IssHdGcvZgUfF_es~x$k%Ic{<=7 zc#(;)fkLo?VGnlTH9UnC_yP}Lu@N7;4foGbf*9;SukF8B{51b?v^n>O2wH7M^Hap zFO+9WMLRAMGz9tbgk7Av8|bC5=R%-`+}^MFcPh$58$lO-KpQ^0u>{x2dy%$WVVe7O zNf5nRhSnWn8{7Zk-;y*+Xbr(K}h&^K$MZ@{Pk delta 319 zcmZozz}?WmJwclHJ_7@T4iqy^)G%kfzcJyY9;3lzE&Xanj?K&T<2Ep}@;}|o{^0L^ zW&^&5)7cj=I&BYMz?i@{ae>A5hwB)X8JP|E1*fxbU`*VssIZc6yWoDt_X2#pKtl}} zuQTxP;xFOXo6dKEF>14+KtAL4>l>ML`M5avr!erp<$u6`aXX&@Qzge{2LWF899|9< z23dZ`qLR$C#N?7}E_N0Maem+Yywu8UPBs<>QGS=ilGJQYRuD5JGdDGxiv^^@za%5I zD4UlVq}eAwIk6-&KQEh`iG@LuKOnWJ7|0Q1WMNR{_b*CM%*(8T$Zz|=$YQ|5%KwCc t{|WzZ{;&M+w+kpReenl+_u_W;0;Zq#B0w*|fEJLU3B(GU1ry%z0{~JnS5g1~ 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)