mirror of https://github.com/doccano/doccano.git
8 changed files with 153 additions and 145 deletions
Split View
Diff Options
-
BINapp/db.sqlite3
-
6app/server/package-lock.json
-
2app/server/package.json
-
8app/server/static/js/http.js
-
102app/server/static/js/mixin.js
-
127app/server/static/js/sequence_labeling.js
-
17app/server/templates/annotation/sequence_labeling.html
-
36app/server/webpack.config.js
@ -0,0 +1,8 @@ |
|||
axios.defaults.xsrfCookieName = 'csrftoken'; |
|||
axios.defaults.xsrfHeaderName = 'X-CSRFToken'; |
|||
var base_url = window.location.href.split('/').slice(3, 5).join('/'); |
|||
let HTTP = axios.create({ |
|||
baseURL: `/api/${base_url}/` |
|||
}); |
|||
|
|||
export default HTTP; |
@ -0,0 +1,102 @@ |
|||
import HTTP from './http.js'; |
|||
|
|||
var annotationMixin = { |
|||
data: function () { |
|||
return { |
|||
cur: 0, |
|||
items: [{ |
|||
id: null, |
|||
text: '', |
|||
labels: [] |
|||
}], |
|||
labels: [], |
|||
guideline: 'Here is the Annotation Guideline Text', |
|||
total: 0, |
|||
remaining: 0, |
|||
searchQuery: '', |
|||
url: '', |
|||
} |
|||
}, |
|||
methods: { |
|||
nextPage: async function () { |
|||
this.cur += 1; |
|||
if (this.cur == this.items.length) { |
|||
if (this.next) { |
|||
this.url = this.next; |
|||
await this.search(); |
|||
this.cur = 0; |
|||
} else { |
|||
this.cur = this.items.length - 1; |
|||
} |
|||
} |
|||
this.showMessage(this.cur); |
|||
}, |
|||
prevPage: async function () { |
|||
this.cur -= 1; |
|||
if (this.cur == -1) { |
|||
if (this.prev) { |
|||
this.url = this.prev; |
|||
await this.search(); |
|||
this.cur = this.items.length - 1; |
|||
} else { |
|||
this.cur = 0; |
|||
} |
|||
} |
|||
this.showMessage(this.cur); |
|||
}, |
|||
search: async function () { |
|||
await HTTP.get(this.url).then(response => { |
|||
this.items = response.data['results']; |
|||
this.next = response.data['next']; |
|||
this.prev = response.data['previous']; |
|||
}) |
|||
}, |
|||
showMessage: function (index) { |
|||
this.cur = index; |
|||
}, |
|||
submit: async function () { |
|||
this.url = `docs/?q=${this.searchQuery}`; |
|||
await this.search(); |
|||
this.cur = 0; |
|||
}, |
|||
updateProgress: function () { |
|||
HTTP.get('progress').then(response => { |
|||
this.total = response.data['total']; |
|||
this.remaining = response.data['remaining']; |
|||
}) |
|||
}, |
|||
deleteLabel: async function (index) { |
|||
var doc_id = this.items[this.cur].id; |
|||
var annotation_id = this.items[this.cur]['labels'][index].id; |
|||
HTTP.delete(`docs/${doc_id}/annotations/${annotation_id}`).then(response => { |
|||
this.items[this.cur]['labels'].splice(index, 1) |
|||
}); |
|||
this.updateProgress(); |
|||
} |
|||
}, |
|||
created: function () { |
|||
HTTP.get('labels').then(response => { |
|||
this.labels = response.data |
|||
}); |
|||
this.updateProgress(); |
|||
this.submit(); |
|||
}, |
|||
computed: { |
|||
achievement: function () { |
|||
var done = this.total - this.remaining; |
|||
var percentage = Math.round(done / this.total * 100); |
|||
return this.total > 0 ? percentage : 0; |
|||
}, |
|||
progressColor: function () { |
|||
if (this.achievement < 30) { |
|||
return 'is-danger' |
|||
} else if (this.achievement < 70) { |
|||
return 'is-warning' |
|||
} else { |
|||
return 'is-primary' |
|||
} |
|||
} |
|||
} |
|||
}; |
|||
|
|||
export default annotationMixin; |
@ -1,23 +1,29 @@ |
|||
const VueLoaderPlugin = require('vue-loader/lib/plugin') |
|||
|
|||
module.exports = { |
|||
module.exports = { |
|||
mode: 'development', |
|||
entry: { |
|||
'sequence_labeling': './static/js/sequence_labeling.js' |
|||
}, |
|||
output: { |
|||
path: __dirname + '/static/dist', |
|||
filename: '[name].js' |
|||
}, |
|||
module: { |
|||
rules: [ |
|||
// ... other rules
|
|||
{ |
|||
test: /\.vue$/, |
|||
loader: 'vue-loader' |
|||
} |
|||
] |
|||
rules: [ |
|||
{ |
|||
test: /\.vue$/, |
|||
loader: 'vue-loader' |
|||
} |
|||
] |
|||
}, |
|||
plugins: [ |
|||
// make sure to include the plugin!
|
|||
new VueLoaderPlugin() |
|||
], |
|||
new VueLoaderPlugin() |
|||
], |
|||
resolve: { |
|||
extensions: ['.js', '.vue'], |
|||
alias: { |
|||
vue$: 'vue/dist/vue.esm.js', //webpack使う場合はこっちを指定する https://jp.vuejs.org/v2/guide/installation.html#%E7%94%A8%E8%AA%9E
|
|||
}, |
|||
extensions: ['.js', '.vue'], |
|||
alias: { |
|||
vue$: 'vue/dist/vue.esm.js', |
|||
}, |
|||
}, |
|||
} |
Write
Preview
Loading…
Cancel
Save