PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.22
ووسلام – همگام سازی ووکامرس و باسلام v1.10.22
1.10.22 1.10.21 1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 All 55 releases
← All changes | assets/js/admin.js +64 -7 1.10.15 → 1.10.22 View file →
@@ -22,9 +22,62 @@
22 22 action: "connect_products_with_basalam",
23 23 },
24 24 ];
25 25
26 + const updateModal = document.getElementById("BasalamUpdateProductsModal");
27 + let updateStatusPoller = null;
28 + let updateStatusInFlight = false;
29 +
30 + const showUpdatePanel = (panelId) => {
31 + ["update-status-loading", "update-status-error", "update-type-selection", "quick-update-in-progress", "active-jobs-info"].forEach((id) => {
32 + const panel = document.getElementById(id);
33 + if (panel) panel.hidden = id !== panelId;
34 + });
35 + };
36 +
37 + const refreshUpdateStatus = () => {
38 + if (!updateModal || !document.getElementById("update-type-selection") || updateStatusInFlight) return;
39 +
40 + updateStatusInFlight = true;
41 + const formData = new FormData();
42 + formData.append("action", "get_update_queue_status");
43 + formData.append("_wpnonce", updateModal.dataset.statusNonce || "");
44 +
45 + return fetch(ajaxurl, { method: "POST", body: formData, cache: "no-store" })
46 + .then((response) => response.json())
47 + .then((response) => {
48 + if (!response.success || !response.data) throw new Error("Update status unavailable");
49 +
50 + const status = response.data;
51 + if (!status.active) {
52 + showUpdatePanel("update-type-selection");
53 + } else if (status.type === "quick") {
54 + const badge = document.getElementById("quick-update-status");
55 + if (badge) badge.textContent = status.status === "processing" ? "در حال پردازش" : "در انتظار";
56 + showUpdatePanel("quick-update-in-progress");
57 + } else {
58 + const count = Number(status.count) || 0;
59 + const countRow = document.getElementById("update-queue-count-row");
60 + const countBadge = document.getElementById("update-queue-count");
61 + if (countRow) countRow.hidden = count === 0;
62 + if (countBadge) countBadge.textContent = `${count} محصول`;
63 + showUpdatePanel("active-jobs-info");
64 + }
65 + })
66 + .catch((error) => {
67 + console.error("Error fetching product update status:", error);
68 + showUpdatePanel("update-status-error");
69 + })
70 + .finally(() => {
71 + updateStatusInFlight = false;
72 + });
73 + };
74 +
26 75 const closeModal = () => {
76 + if (updateStatusPoller) {
77 + clearInterval(updateStatusPoller);
78 + updateStatusPoller = null;
79 + }
27 80 document.querySelectorAll(".basalam-modal").forEach((modal) => {
28 81 modal.style.display = "none";
29 82 });
30 83 document.body.style.overflow = "auto";
@@ -40,15 +93,14 @@
40 93 modal.style.display = "block";
41 94 document.body.style.overflow = "hidden";
42 95
43 96 if (modalId === "BasalamUpdateProductsModal") {
44 - const selectionDiv = document.getElementById("update-type-selection");
45 - const quickConfirm = document.getElementById("quick-update-confirm");
46 - const fullConfirm = document.getElementById("full-update-confirm");
47 -
48 - if (selectionDiv) selectionDiv.style.display = "block";
49 - if (quickConfirm) quickConfirm.style.display = "none";
50 - if (fullConfirm) fullConfirm.style.display = "none";
97 + if (document.getElementById("update-type-selection")) {
98 + showUpdatePanel("update-status-loading");
99 + refreshUpdateStatus();
100 + if (updateStatusPoller) clearInterval(updateStatusPoller);
101 + updateStatusPoller = setInterval(refreshUpdateStatus, 5000);
102 + }
51 103 }
52 104 });
53 105 }
54 106
@@ -75,8 +127,13 @@
75 127 submitToServer(form, action);
76 128 }
77 129 });
78 130 }
131 + });
132 +
133 + document.getElementById("update-status-retry")?.addEventListener("click", () => {
134 + showUpdatePanel("update-status-loading");
135 + refreshUpdateStatus();
79 136 });
80 137
81 138 setTimeout(() => {
82 139 const quickUpdateBtn = document.getElementById("quick-update-btn");