From d19a51f0dd15d2275549debe1a3c9601745e7a92 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Wed, 18 Sep 2019 13:25:41 +0900 Subject: [PATCH] Implement upload feature roughly --- frontend/api/routes/docs.js | 12 +++++++++ .../containers/DocumentUploadButton.vue | 7 ++--- .../organisms/DocumentUploadForm.vue | 26 +------------------ frontend/services/document.service.js | 4 +++ frontend/store/documents.js | 2 +- 5 files changed, 20 insertions(+), 31 deletions(-) diff --git a/frontend/api/routes/docs.js b/frontend/api/routes/docs.js index 58bc5458..025d847b 100644 --- a/frontend/api/routes/docs.js +++ b/frontend/api/routes/docs.js @@ -22,6 +22,18 @@ router.post('/', (req, res) => { res.json(doc) }) +// Upload a file. +router.post('/upload', (req, res) => { + const doc = { + id: db.reduce((x, y) => { return x.id > y.id ? x : y }).id + 1, + text: 'Uploaded Document', + meta: JSON.stringify({}), + annotations: [] + } + db.push(doc) + res.json(doc) +}) + // Update a document partially. router.patch('/:docId', (req, res) => { const docIndex = db.findIndex(item => item.id === parseInt(req.params.docId)) diff --git a/frontend/components/containers/DocumentUploadButton.vue b/frontend/components/containers/DocumentUploadButton.vue index bccfc54b..6ce15a20 100644 --- a/frontend/components/containers/DocumentUploadButton.vue +++ b/frontend/components/containers/DocumentUploadButton.vue @@ -7,9 +7,6 @@ @@ -28,11 +25,11 @@ export default { }, computed: { - ...mapGetters('documents', ['formatList', 'parsedDoc', 'headers']) + ...mapGetters('documents', ['formatList']) }, methods: { - ...mapActions('documents', ['uploadDocument', 'parseFile']) + ...mapActions('documents', ['uploadDocument']) } } diff --git a/frontend/components/organisms/DocumentUploadForm.vue b/frontend/components/organisms/DocumentUploadForm.vue index 548b6a59..62362a0a 100644 --- a/frontend/components/organisms/DocumentUploadForm.vue +++ b/frontend/components/organisms/DocumentUploadForm.vue @@ -28,28 +28,19 @@ :accept="acceptType" :rules="uploadFileRules" label="File input" - @change="parseFile" /> -