201 lines
8.1 KiB
JavaScript
201 lines
8.1 KiB
JavaScript
// ajax error
|
|
function ajax_error(response, code) {
|
|
let errors = [];
|
|
errors = response?.errors;
|
|
const array_errors = [];
|
|
switch (code) {
|
|
case 400:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
html: `
|
|
<ul class="list-group">
|
|
${response.message}
|
|
</ul>`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
case 401:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
text: `دسترسی شما منقضی شده است`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "ورود مجدد",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
window.location.reload()
|
|
}
|
|
})
|
|
break;
|
|
case 403:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
text: `شما دسترسی لازم برای انجام این عملیات را ندارید`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
case 404:
|
|
Swal.fire({
|
|
icon: "warning",
|
|
heightAuto: false,
|
|
title: `خطا :${code}`,
|
|
text: `نتیجه ای یافت نشد !`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
// case 419:
|
|
// showLogin();
|
|
// break;
|
|
case 422:
|
|
$.each(errors, function (key, value) {
|
|
for (let i = 0; i < value.length; i++) {
|
|
array_errors.push(
|
|
`<li class="list-group-item list-errors-font">${value[i]}</li>`
|
|
);
|
|
}
|
|
});
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
html: `
|
|
<ul class="list-group">
|
|
${array_errors.join("")}
|
|
</ul>`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
case 500:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
text: `خطا ارتباط با سرور (لطفا با پشتیبانی تماس بگیرید)`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
case 503:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
text: `خطا ارتباط با سرور (لطفا با پشتیبانی تماس بگیرید)`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
case 504:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: ` خطا :${code}`,
|
|
text: `خطا ارتباط با سرور (لطفا با پشتیبانی تماس بگیرید)`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
break;
|
|
default:
|
|
Swal.fire({
|
|
icon: "error",
|
|
heightAuto: false,
|
|
title: `خطا :${code}`,
|
|
text: `عملیات با خطا مواجه شد !`,
|
|
showConfirmButton: true,
|
|
confirmButtonText: "متوجه شدم",
|
|
customClass: {
|
|
confirmButton: 'swal2-confirm-button-color',
|
|
},
|
|
});
|
|
}
|
|
}
|
|
// end ajax error
|
|
|
|
// loader
|
|
function showLoaderScreen() {
|
|
$(".divloader").css("display", "flex").hide().fadeIn();
|
|
}
|
|
|
|
function hideLoaderScreen() {
|
|
$(".divloader").fadeOut();
|
|
}
|
|
// end loader
|
|
|
|
function getSideBarActivity() {
|
|
|
|
$.ajax({
|
|
url: "/v2/activity_statistics",
|
|
type: "GET",
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false,
|
|
success: function (result) {
|
|
result.road_items.total != 0 && result.road_items.total !== undefined ? $("#road_items_total").text(Number(result.road_items.total).toLocaleString('en')) && $("#road_items_total").removeClass("d-none") : $("#road_items_total").addClass("d-none")
|
|
|
|
result.road_items.supervise_cnt != 0 && result.road_items.supervise_cnt !== undefined ? $("#road_items_supervise_cnt").text(Number(result.road_items.supervise_cnt).toLocaleString('en')) && $("#road_items_supervise_cnt").removeClass("d-none") : $("#road_items_supervise_cnt").addClass("d-none")
|
|
|
|
result.road_items.operation_cnt != 0 && result.road_items.operation_cnt !== undefined ? $(".road_items_operation_cnt").text(Number(result.road_items.operation_cnt).toLocaleString('en')) && $(".road_items_operation_cnt").removeClass("d-none") : $(".road_items_operation_cnt").addClass("d-none")
|
|
|
|
result.road_patrols.total != 0 && result.road_patrols.total !== undefined ? $("#road_patrols_total").text(Number(result.road_patrols.total).toLocaleString('en')) && $("#road_patrols_total").removeClass("d-none") : $("#road_patrols_total").addClass("d-none")
|
|
|
|
result.road_patrols.operation_cnt != 0 && result.road_patrols.operation_cnt !== undefined ? $(".road_patrols_operation_cnt").text(Number(result.road_patrols.operation_cnt).toLocaleString('en')) && $(".road_patrols_operation_cnt").removeClass("d-none") : $(".road_patrols_operation_cnt").addClass("d-none")
|
|
|
|
result.road_patrols.supervise_cnt != 0 && result.road_patrols.supervise_cnt !== undefined && result.road_patrols.supervise_cnt !== undefined ? $("#road_patrols_supervise_cnt").text(Number(result.road_patrols.supervise_cnt).toLocaleString('en')) && $("#road_patrols_supervise_cnt").removeClass("d-none") : $("#road_patrols_supervise_cnt").addClass("d-none")
|
|
|
|
result.road_observations.total != 0 && result.road_observations.total !== undefined ? $("#road_observations_total").text(Number(result.road_observations.total).toLocaleString('en')) && $("#road_observations_total").removeClass("d-none") : $("#road_observations_total").addClass("d-none")
|
|
|
|
result.road_observations.operation_cnt != 0 && result.road_observations.operation_cnt !== undefined ? $(".road_observations_operation_cnt").text(Number(result.road_observations.operation_cnt).toLocaleString('en')) && $(".road_observations_operation_cnt").removeClass("d-none") : $(".road_observations_operation_cnt").addClass("d-none")
|
|
|
|
result.road_observations.supervise_cnt != 0 && result.road_observations.supervise_cnt !== undefined ? $("#road_observations_supervise_cnt").text(Number(result.road_observations.supervise_cnt).toLocaleString('en')) && $("#road_observations_supervise_cnt").removeClass("d-none") : $("#road_observations_supervise_cnt").addClass("d-none")
|
|
|
|
result.safety_and_privacy.step_one != 0 && result.safety_and_privacy.step_one !== undefined ? $("#safety_and_privacy_step_one").text(Number(result.safety_and_privacy.step_one).toLocaleString('en')) && $("#safety_and_privacy_step_one").removeClass("d-none") : $("#safety_and_privacy_step_one").addClass("d-none")
|
|
|
|
result.safety_and_privacy.step_two != 0 && result.safety_and_privacy.step_two !== undefined ? $("#safety_and_privacy_step_two").text(Number(result.safety_and_privacy.step_two).toLocaleString('en')) && $("#safety_and_privacy_step_two").removeClass("d-none") : $("#safety_and_privacy_step_two").addClass("d-none")
|
|
|
|
},
|
|
error: function (error) {
|
|
|
|
Swal.fire({
|
|
icon: "error",
|
|
title: "خطا",
|
|
text: "دسترسی های شما به درستی تنظیم نشده است. لطفا با پشتیبانی یا مدیر سامانه تماس حاصل فرمایید.",
|
|
confirmButtonText: "بستن",
|
|
});
|
|
|
|
},
|
|
});
|
|
|
|
} |