diff --git a/app/server/static/js/dataset.js b/app/server/static/js/dataset.js new file mode 100644 index 00000000..89e81f34 --- /dev/null +++ b/app/server/static/js/dataset.js @@ -0,0 +1,8 @@ +import HTTP from './http'; + +document.querySelectorAll('.delete-document-button').forEach((deleteButton) => { + deleteButton.addEventListener('click', () => { + const documentId = deleteButton.getAttribute('data-delete-document-id'); + HTTP.delete(`docs/${documentId}`).then(() => window.location.reload()); + }); +}); diff --git a/app/server/templates/dataset.html b/app/server/templates/dataset.html index 2187ee86..06c11bc5 100644 --- a/app/server/templates/dataset.html +++ b/app/server/templates/dataset.html @@ -17,6 +17,7 @@ # Text + @@ -24,6 +25,16 @@ {{ forloop.counter0|add:page_obj.start_index }} {{ doc.text|truncatechars:200 }} + +

+ +

+ {% endfor %} diff --git a/app/server/views.py b/app/server/views.py index 865defe8..a2df38e3 100644 --- a/app/server/views.py +++ b/app/server/views.py @@ -34,6 +34,9 @@ class ProjectsView(LoginRequiredMixin, TemplateView): class DatasetView(SuperUserMixin, LoginRequiredMixin, ListView): template_name = 'dataset.html' paginate_by = 5 + extra_context = { + 'bundle_name': 'dataset' + } def get_queryset(self): project = get_object_or_404(Project, pk=self.kwargs['project_id']) diff --git a/app/server/webpack.config.js b/app/server/webpack.config.js index 7477d93a..76d8bb79 100644 --- a/app/server/webpack.config.js +++ b/app/server/webpack.config.js @@ -16,6 +16,7 @@ module.exports = { 'stats': './static/js/stats.js', 'label': './static/js/label.js', 'guideline': './static/js/guideline.js', + 'dataset': './static/js/dataset.js', 'demo_text_classification': './static/js/demo/demo_text_classification.js', 'demo_named_entity': './static/js/demo/demo_named_entity.js', 'demo_translation': './static/js/demo/demo_translation.js',