Browse Source

Added placeholder hook for calling API for deleting documents

pull/170/head
Michael Olund 5 years ago
parent
commit
2f81c509c2
3 changed files with 23 additions and 7 deletions
  1. +9
    -2
      vue/package-lock.json
  2. +1
    -0
      vue/package.json
  3. +13
    -5
      vue/src/components/Uploader/Uploader.vue

+ 9
- 2
vue/package-lock.json View File

@ -2441,6 +2441,14 @@
"integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==",
"dev": true
},
"axios": {
"version": "0.20.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.20.0.tgz",
"integrity": "sha512-ANA4rr2BDcmmAQLOKft2fufrtuvlqR+cXNNinUmvfeSNCOF98PZL+7M/v1zIdGo7OLjEA9J2gXJL+j4zGsl0bA==",
"requires": {
"follow-redirects": "^1.10.0"
}
},
"babel-loader": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.1.0.tgz",
@ -5175,8 +5183,7 @@
"follow-redirects": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.0.tgz",
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA==",
"dev": true
"integrity": "sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA=="
},
"for-in": {
"version": "1.0.2",


+ 1
- 0
vue/package.json View File

@ -7,6 +7,7 @@
"build": "vue-cli-service build"
},
"dependencies": {
"axios": "^0.20.0",
"core-js": "^3.6.5",
"uiv": "^0.36.1",
"vue": "^2.6.11",


+ 13
- 5
vue/src/components/Uploader/Uploader.vue View File

@ -89,6 +89,7 @@ import { Tooltip, Modal } from 'uiv';
import ItemTile from './ItemTile'
import FormDefinitions from "../../utils/forms";
import rotateFix from '../../utils/rotation';
import axios from 'axios';
export default {
props: {
@ -165,15 +166,16 @@ export default {
if (newFile.xhr) {
// Error Handling
if (newFile.xhr.status === 400) {
const statusCode = newFile.xhr.status;
if (statusCode === 400) {
// 400 validation error: show the message returned by the server
const message = JSON.parse(newFile.xhr.responseText)[0];
this.showError(message);
this.$refs.upload.remove(newFile);
} else if (newFile.xhr.status !== 200) {
} else if (statusCode !== 200 && statusCode !== 201 ) {
// 500 server error: show the status text and a generic message
this.showError('Error: ' + newFile.xhr.statusText + '. Please try the upload again. If this doesn\'t work, try again later.');
console.log('status', newFile.xhr.status)
console.log('status', statusCode)
}
}
}
@ -253,8 +255,14 @@ export default {
}
},
remove(file) {
// todo: call the API to remove the file
this.$refs.upload.remove(file)
var url = this.$parent.proxyRootPath + "api/delete-document/";
axios.delete(url, {doc_type: this.docType, party_code: this.party, filename: file.name, size: file.size})
.then(response => {
this.$refs.upload.remove(file)
})
.catch(error => {
this.showError('Error deleting document from the server: ' + file.name);
});
},
moveUp(old_index) {
if (old_index >= 1 && this.files.length > 1) {


Loading…
Cancel
Save