From 104eb27a1dc4b3c52835eb06ce69d72adbaf3a83 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 26 Jul 2018 16:20:16 +0900 Subject: [PATCH] Add filter by annotation state --- app/db.sqlite3 | Bin 258048 -> 258048 bytes .../static/bundle/document_classification.js | 2 +- app/server/static/bundle/seq2seq.js | 2 +- app/server/static/bundle/sequence_labeling.js | 2 +- app/server/static/js/mixin.js | 18 +++++++++++++++++- .../templates/annotation/annotation_base.html | 10 +++++----- app/server/views.py | 13 +++++++++++++ 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/db.sqlite3 b/app/db.sqlite3 index efebae8798b161b89cc4bd4d3edab427a5cd9982..478aad3a0c6151a2f3155a4e38f5c4f40369241b 100644 GIT binary patch delta 606 zcmb7=L1+_E5Qg`?x5@gF?2J_m8bev>LA0nlM+M%QYl!12ttdtQ1K+yO@!W^!@v*!$N$fin^$qum3@@YC!w8|=Zfy6|j%u(X;5M$|4NSv#_y!;0Ev&+d6Ivt>p>35kXY~b% z6Q;qgCDllt!mfQHavQAbA9~UWy&;=(ED;D>Qj%81z^Opkjw&<$P(UJ_xWheNYH43k z9~K>LkiIuq0+N>W!DS!?Ntbyg2U^v5slAKN;0Aq4!mdleclaC^@fP->iX!a6JXByB zQdVb^W+^0{a+B8o(VjLl!=FS;Akjq;sq)`tSQI?tMRfopOl_?Vs=iT`Kp;#eL~RPMv2L z+0_~F$g=`kI0UcdEqT@jP5JDI#s$ptZo=dJ|5?W(4RWkQQzEf}Nbf*zj~dfrkx0L@ J^_d+x^cRMCt3m(( delta 345 zcmZp8z~AtIe}Xh);Y1l{#=?yWVR~Za!u-tIjK!%%WvNB+Df!8zxv6<29Fx!JO=2|N z9IwB0g9r!zB?kUK{NMOL@IT?d$A5$W6922sf(g6$rw80)V%dD{z1{{fQ@+Ct{O|d% z^B3~R^S$MJ&UcmXB;VofG7A_N@=Xlj0IS@7d>x}LBeN;rkLm0i7_&Dk8np3k|FMse zXCkv3kJ)tg0H)r}h6;y!ab%Xj8Z@e2L4n0Yxo!N z*YKP0>+!Sj{o|X&*TYveUEu*!()N}IOlNo}E)am~c?Z-3G;Gmy_77mg`1rOj`p1-H zD8j*Zi-G?U|0ez_{s=xN?pQ7swp*JW1rD)ozh%a(#mVf(y=pqU12f1`V%*zTc{4|~ c@UZZ{X5gRBAIrCs_cc)bHt+V=cbP?n0MPAutN;K2 diff --git a/app/server/static/bundle/document_classification.js b/app/server/static/bundle/document_classification.js index 1caff8c4..28c41c82 100644 --- a/app/server/static/bundle/document_classification.js +++ b/app/server/static/bundle/document_classification.js @@ -185,7 +185,7 @@ eval("__webpack_require__.r(__webpack_exports__);\naxios.defaults.xsrfCookieName /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n submit: async function () {\n this.url = `docs/?q=${this.searchQuery}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n watch: {\n picked: function (){\n this.submit();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?"); /***/ }) diff --git a/app/server/static/bundle/seq2seq.js b/app/server/static/bundle/seq2seq.js index 99de5f0e..624f6ef7 100644 --- a/app/server/static/bundle/seq2seq.js +++ b/app/server/static/bundle/seq2seq.js @@ -173,7 +173,7 @@ eval("__webpack_require__.r(__webpack_exports__);\naxios.defaults.xsrfCookieName /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n submit: async function () {\n this.url = `docs/?q=${this.searchQuery}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n watch: {\n picked: function (){\n this.submit();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?"); /***/ }), diff --git a/app/server/static/bundle/sequence_labeling.js b/app/server/static/bundle/sequence_labeling.js index b01b3346..d897e43a 100644 --- a/app/server/static/bundle/sequence_labeling.js +++ b/app/server/static/bundle/sequence_labeling.js @@ -173,7 +173,7 @@ eval("__webpack_require__.r(__webpack_exports__);\naxios.defaults.xsrfCookieName /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n submit: async function () {\n this.url = `docs/?q=${this.searchQuery}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _http_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./http.js */ \"./static/js/http.js\");\n\n\nvar annotationMixin = {\n data: function () {\n return {\n cur: 0,\n items: [{\n id: null,\n text: '',\n labels: []\n }],\n labels: [],\n guideline: 'Here is the Annotation Guideline Text',\n total: 0,\n remaining: 0,\n searchQuery: '',\n url: '',\n picked: 'all',\n }\n },\n methods: {\n nextPage: async function () {\n this.cur += 1;\n if (this.cur == this.items.length) {\n if (this.next) {\n this.url = this.next;\n await this.search();\n this.cur = 0;\n } else {\n this.cur = this.items.length - 1;\n }\n }\n this.showMessage(this.cur);\n },\n prevPage: async function () {\n this.cur -= 1;\n if (this.cur == -1) {\n if (this.prev) {\n this.url = this.prev;\n await this.search();\n this.cur = this.items.length - 1;\n } else {\n this.cur = 0;\n }\n }\n this.showMessage(this.cur);\n },\n search: async function () {\n await _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get(this.url).then(response => {\n this.items = response.data['results'];\n this.next = response.data['next'];\n this.prev = response.data['previous'];\n })\n },\n showMessage: function (index) {\n this.cur = index;\n },\n getState: function () {\n if (this.picked == 'all') {\n return ''\n } else if (this.picked == 'active') {\n return 'true'\n } else {\n return 'false'\n }\n },\n submit: async function () {\n var state = this.getState();\n this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`;\n await this.search();\n this.cur = 0;\n },\n updateProgress: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('progress').then(response => {\n this.total = response.data['total'];\n this.remaining = response.data['remaining'];\n })\n },\n deleteLabel: async function (index) {\n var doc_id = this.items[this.cur].id;\n var annotation_id = this.items[this.cur]['labels'][index].id;\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => {\n this.items[this.cur]['labels'].splice(index, 1)\n });\n this.updateProgress();\n }\n },\n watch: {\n picked: function (){\n this.submit();\n }\n },\n created: function () {\n _http_js__WEBPACK_IMPORTED_MODULE_0__[\"default\"].get('labels').then(response => {\n this.labels = response.data\n });\n this.updateProgress();\n this.submit();\n },\n computed: {\n achievement: function () {\n var done = this.total - this.remaining;\n var percentage = Math.round(done / this.total * 100);\n return this.total > 0 ? percentage : 0;\n },\n progressColor: function () {\n if (this.achievement < 30) {\n return 'is-danger'\n } else if (this.achievement < 70) {\n return 'is-warning'\n } else {\n return 'is-primary'\n }\n }\n }\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (annotationMixin);\n\n//# sourceURL=webpack:///./static/js/mixin.js?"); /***/ }), diff --git a/app/server/static/js/mixin.js b/app/server/static/js/mixin.js index 531c3321..0285bc74 100644 --- a/app/server/static/js/mixin.js +++ b/app/server/static/js/mixin.js @@ -15,6 +15,7 @@ var annotationMixin = { remaining: 0, searchQuery: '', url: '', + picked: 'all', } }, methods: { @@ -54,8 +55,18 @@ var annotationMixin = { showMessage: function (index) { this.cur = index; }, + getState: function () { + if (this.picked == 'all') { + return '' + } else if (this.picked == 'active') { + return 'true' + } else { + return 'false' + } + }, submit: async function () { - this.url = `docs/?q=${this.searchQuery}`; + var state = this.getState(); + this.url = `docs/?q=${this.searchQuery}&is_checked=${state}`; await this.search(); this.cur = 0; }, @@ -74,6 +85,11 @@ var annotationMixin = { this.updateProgress(); } }, + watch: { + picked: function (){ + this.submit(); + } + }, created: function () { HTTP.get('labels').then(response => { this.labels = response.data diff --git a/app/server/templates/annotation/annotation_base.html b/app/server/templates/annotation/annotation_base.html index 4349d457..0c86a12d 100644 --- a/app/server/templates/annotation/annotation_base.html +++ b/app/server/templates/annotation/annotation_base.html @@ -25,19 +25,19 @@