From eedc0d1ccdf7d862f250f92a1c63a394297f0ef8 Mon Sep 17 00:00:00 2001 From: Watiah11 Date: Tue, 7 May 2024 15:27:37 +0700 Subject: [PATCH 1/2] fix: update end point image --- edit-mode/function/ganttConfig.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/edit-mode/function/ganttConfig.js b/edit-mode/function/ganttConfig.js index 9654313..3cf1ef7 100644 --- a/edit-mode/function/ganttConfig.js +++ b/edit-mode/function/ganttConfig.js @@ -5,7 +5,9 @@ const timestamp = getUrlParameter("timestamp"); let base_url = getUrlParameter("base_url"); const role_name = getUrlParameter("role_name"); const company_id = getUrlParameter("company_id"); -const base_url_image = "https://project-api.ospro.id/assets/image/"; +const company_name = getUrlParameter("company_name"); +const base_url_image = `https://project-api.ospro.id/assets/${company_name}/`; +// const base_url_image = `http://localhost:8444/generic-ospro-backend/assets/${company_name}/`; const adwIntegrationUrl = "https://adw-api.ospro.id/api"; let userToVersionGanttId = 0 From 70660b0b5a0d9224402fec07a7a13b5d149f129d Mon Sep 17 00:00:00 2001 From: Watiah11 Date: Tue, 7 May 2024 15:28:26 +0700 Subject: [PATCH 2/2] fix(image): fixed image upload, view, delete on image --- edit-mode/function/humanResource.js | 1 + edit-mode/function/reportActivity.js | 32 +++++++--------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/edit-mode/function/humanResource.js b/edit-mode/function/humanResource.js index bf1837c..fb1042a 100644 --- a/edit-mode/function/humanResource.js +++ b/edit-mode/function/humanResource.js @@ -225,6 +225,7 @@ $(document).ready(function () { gantt.alert("Human Resource Assign Success!"); }, error: function (data) { + $('#btn-assign-hr').html('Assign'); resetFormAssign(); gantt.alert("Human Resource Assign Failed, try again later!"); } diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js index e9a837e..e7f2fda 100644 --- a/edit-mode/function/reportActivity.js +++ b/edit-mode/function/reportActivity.js @@ -56,7 +56,6 @@ $(document).ready(function () { }); $("#ra_select_status").on("change", function () { let val = $(this).val() - console.log(val) if (val == 'done') { $('#ra_date_end_activity').prop('disabled', false); } else { @@ -178,7 +177,6 @@ $(document).ready(function () { d.type = 'actual'; }, "error": function (xhr, error, code) { - console.log(xhr, error, code); } }, "columns": [ @@ -397,8 +395,6 @@ $(document).ready(function () { .then(res => res) .catch((error) => error.response); - // console.log("cek result", result); - if (result && result.data.code == 200) { gantt.alert("Update Status report activity Success!"); resetFormAddRa(); @@ -417,8 +413,6 @@ $(document).ready(function () { .then(res => res) .catch((error) => error.response); - // console.log("cek result", result); - if (result && result.status == 200) { gantt.alert("Add report activity Success!"); resetFormAddRa(); @@ -435,8 +429,6 @@ $(document).ready(function () { .then(res => res) .catch((error) => error.response); - // console.log("cek result", result); - if (result && result.status == 200) { gantt.alert("Edit report activity Success!"); resetFormAddRa(); @@ -464,9 +456,10 @@ $(document).ready(function () { imageFormData.append("ref_id", reportId); imageFormData.append("category", "report_activity"); imageFormData.append("files", image, image.name); + imageFormData.append("company_name",company_name); if (image.name && image.size) { - const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData); + await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData); } if (result.status === 200) { @@ -474,9 +467,11 @@ $(document).ready(function () { resetFormAddRaMaterial(); tableRaMaterialActual.draw(); } else { + $('#btn_add_ra_material').html('Add'); throw new Error("Add report activity material failed."); } } catch (error) { + $('#btn_add_ra_material').html('Add'); throw new Error("Image upload failed."); } } catch (error) { @@ -505,14 +500,13 @@ $(document).ready(function () { .then(res => res) .catch((error) => error.response); - // console.log("cek result", result); - if (result && result.status == 200) { gantt.alert("Edit report activity Success!"); resetFormAddRaMaterial(); tableRaMaterialActual.draw(); } else { resetFormAddRaMaterial(); + $('#btn_add_ra_material').html('Add'); gantt.alert("Edit report activity failed, try again later!"); } } @@ -533,7 +527,7 @@ $(document).ready(function () { $("#table_activity_material_actual").on("click", ".btn-ram-delete", function () { let id = $(this).data('id'); - var box = gantt.confirm({ + gantt.confirm({ text: "Report activity material will be deleted from activity material, continue?", ok: "Delete", cancel: "Cancel", @@ -556,9 +550,8 @@ $(document).ready(function () { gantt.alert({ type: "error", text: "Failed to get report image" }); return false; } - if (data && data.image) { - $("#report-image").html(``); + $("#report-image").html(``); $('#modal-report-image').modal('show'); } // kalo gambarnya banyak belum di handle... @@ -596,7 +589,6 @@ $(document).ready(function () { if (attributeString.includes('"=""')) { materialName = materialName + '"'; } - // console.log(" okeee ",{ assignMaterialId, activityId, materialName }); $("#report_activity_material_title").html(`Report Activity Actual ${materialName}`) $("#modal_report_activity").hide(); @@ -632,7 +624,6 @@ $(document).ready(function () { if (attributeString.includes('"=""')) { materialName = materialName + '"'; } - // console.log(" okeee ",{ assignMaterialId, activityId, materialName }); $("#report_activity_material_title").html(`Report Activity Plan ${materialName}`) $("#modal_report_activity").hide(); // $("#show_form_ra_material").hide(); @@ -669,7 +660,7 @@ $(document).ready(function () { function deleteRaMaterial(id) { searchReport(assignMaterialId, false); $.ajax({ - url: `${base_url}report-activity-material/delete/${id}`, + url: `${base_url}report-activity-material/delete/${id}/${company_id}`, type: "DELETE", success: function (data) { actionHappen = true; @@ -685,20 +676,16 @@ $(document).ready(function () { $("#table_report").on("click", ".btn_report_edit", function () { let id = $(this).data('id'); $("#id_ra").val(id); - // console.log("cek edit id", id); $.ajax({ url: `${base_url}report-activity/edit/${id}`, type: "get", success: function (data) { - // console.log("data report-activity edit", data); if (data && data.code == 200) { let dataRes = data.data - // console.log("dataRes", dataRes); $('#btn_add_ra').html('Edit'); var newOption = new Option(dataRes.user_name, dataRes.user_id, true, true); $('#select_ra_hr').append(newOption).trigger('change'); let reportDate = moment(dataRes.report_date).format("YYYY-MM-DD"); - // console.log("reportDate", reportDate); $("#ra_date").val(reportDate); $("#volume_pekerjaan").val(dataRes.job_count_report); $("#ra_description").val(dataRes.description); @@ -709,9 +696,6 @@ $(document).ready(function () { resetFormAddRa(); gantt.alert("Edit Report Activity Failed, try again later!"); } - // actionHappen = true; - // gantt.alert("Delete Report Activity Success!"); - // tableRa.draw(); }, error: function (data) { resetFormAddRa();