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