|
|
|
@ -1,8 +1,8 @@
|
|
|
|
|
// Upload Document Activity
|
|
|
|
|
const DOCUMENT_UPLOAD_URL = `${base_url}document-activity/upload`; |
|
|
|
|
const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}`; |
|
|
|
|
const DOCUMENT_DOWNLOAD_URL = (id) => `${base_url}document-activity/download/${id}/${company_id}`; |
|
|
|
|
const DOCUMENT_SEARCH_URL = `${base_url}document-activity/search`; |
|
|
|
|
const DOCUMENT_DELETE_URL = (id) => `${base_url}document-activity/delete/${id}`; |
|
|
|
|
const DOCUMENT_DELETE_URL = (id, company_id) => `${base_url}document-activity/delete/${id}/${company_id}`; |
|
|
|
|
|
|
|
|
|
var fileToUpload = null; |
|
|
|
|
|
|
|
|
@ -100,35 +100,27 @@ async function submitDocuments() {
|
|
|
|
|
var formData = new FormData; |
|
|
|
|
formData.append('activity_id', activity_id); |
|
|
|
|
formData.append('dokumen', files); |
|
|
|
|
|
|
|
|
|
formData.append('company_id',company_id); |
|
|
|
|
if (activity_id !== '' && dokumen !== '') { |
|
|
|
|
const result = await axiosInstance |
|
|
|
|
.post(DOCUMENT_UPLOAD_URL, formData) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|
console.log("result", result) |
|
|
|
|
|
|
|
|
|
if(result && result.status==200){ |
|
|
|
|
console.log('done upload doc', result) |
|
|
|
|
// gantt.message("Upload success");
|
|
|
|
|
gantt.alert("Upload Success"); |
|
|
|
|
$("#add_doc_form").trigger("reset"); |
|
|
|
|
$('#btn_doc_submit').html('Upload'); |
|
|
|
|
$('#btn_doc_submit').prop("disabled",false); |
|
|
|
|
searchDocuments(activity_id); // reload the contents
|
|
|
|
|
}else{ |
|
|
|
|
// closeDialog('failed upload')
|
|
|
|
|
console.log('failed upload'); |
|
|
|
|
// alert('Upload failed');
|
|
|
|
|
// gantt.message({type:"error", text:"Upload Failed"});
|
|
|
|
|
gantt.alert({type: "error", text: "Upload Failed"}); |
|
|
|
|
$('#btn_doc_submit').html('Upload'); |
|
|
|
|
$('#btn_doc_submit').prop("disabled",false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
// alert('Please input the comment');
|
|
|
|
|
gantt.alert("Please insert the document file"); |
|
|
|
|
$('#btn_doc_submit').html('Upload'); |
|
|
|
|
$('#btn_doc_submit').prop("disabled",false); |
|
|
|
@ -209,7 +201,7 @@ function searchDocuments(activity_id) {
|
|
|
|
|
|
|
|
|
|
async function downloadDocument(id, name) { |
|
|
|
|
let result; |
|
|
|
|
await fetch(DOCUMENT_DOWNLOAD_URL(id), { |
|
|
|
|
await fetch(DOCUMENT_DOWNLOAD_URL(id, company_id), { |
|
|
|
|
headers: new Headers({ |
|
|
|
|
'Content-Type': 'application/json', |
|
|
|
|
'Authorization': `Bearer ${token}` |
|
|
|
@ -253,7 +245,7 @@ async function deleteDocument(id, activity_id) {
|
|
|
|
|
if (result) { |
|
|
|
|
console.log('download document', id); |
|
|
|
|
const result = await axiosInstance |
|
|
|
|
.delete(DOCUMENT_DELETE_URL(id)) |
|
|
|
|
.delete(DOCUMENT_DELETE_URL(id, company_id)) |
|
|
|
|
.then(res => res) |
|
|
|
|
.catch((error) => error.response); |
|
|
|
|
|
|
|
|
|