mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-15 07:18:58 -04:00
removing logs
This commit is contained in:
@@ -6,35 +6,32 @@ function debounce(func, wait) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener('DOMContentLoaded', function () {
|
||||||
const isJobPage = window.location.pathname.includes("/jobs/");
|
const isJobPage = window.location.pathname.includes('/jobs/');
|
||||||
if (!isJobPage) return;
|
if (!isJobPage) return;
|
||||||
|
|
||||||
const jobEl = document.querySelector("[data-job-id]");
|
const jobEl = document.querySelector('[data-job-id]');
|
||||||
const jobId = jobEl?.dataset?.jobId;
|
const jobId = jobEl?.dataset?.jobId;
|
||||||
const featureEnabled = jobEl?.dataset?.feature === "true";
|
const featureEnabled = jobEl?.dataset?.feature === 'true';
|
||||||
|
|
||||||
if (!jobId) return;
|
if (!jobId) return;
|
||||||
|
|
||||||
|
|
||||||
if (featureEnabled) {
|
if (featureEnabled) {
|
||||||
const socket = io("http://localhost:6011");
|
const socket = io('http://localhost:6011');
|
||||||
|
|
||||||
socket.on("connect", () => {
|
socket.on('connect', () => {
|
||||||
console.log("Connected to Socket.IO server");
|
socket.emit('join', { room: `job-${jobId}` });
|
||||||
socket.emit("join", { room: `job-${jobId}` });
|
|
||||||
console.log("join", { room: `job-${jobId}` });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener("beforeunload", () => {
|
window.addEventListener('beforeunload', () => {
|
||||||
socket.emit("leave", { room: `job-${jobId}` });
|
socket.emit('leave', { room: `job-${jobId}` });
|
||||||
});
|
});
|
||||||
|
|
||||||
const debouncedUpdate = debounce((data) => {
|
const debouncedUpdate = debounce((data) => {
|
||||||
updateAllJobSections();
|
updateAllJobSections();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
socket.on("job_updated", (data) => {
|
socket.on('job_updated', (data) => {
|
||||||
if (data.job_id !== jobId) return;
|
if (data.job_id !== jobId) return;
|
||||||
debouncedUpdate(data);
|
debouncedUpdate(data);
|
||||||
});
|
});
|
||||||
@@ -45,7 +42,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
const url = resourceEl?.dataset?.resource;
|
const url = resourceEl?.dataset?.resource;
|
||||||
|
|
||||||
if (!url) {
|
if (!url) {
|
||||||
console.warn("No resource URL found for job updates");
|
console.warn('No resource URL found for job updates');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,26 +52,23 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
const sections = {
|
const sections = {
|
||||||
status: document.querySelector('[data-socket-update="status"]'),
|
status: document.querySelector('[data-socket-update="status"]'),
|
||||||
counts: document.querySelector('[data-socket-update="counts"]'),
|
counts: document.querySelector('[data-socket-update="counts"]'),
|
||||||
notifications: document.querySelector('[data-socket-update="notifications"]'),
|
notifications: document.querySelector(
|
||||||
|
'[data-socket-update="notifications"]'
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (status && sections.status) {
|
if (status && sections.status) {
|
||||||
sections.status.innerHTML = status;
|
sections.status.innerHTML = status;
|
||||||
console.log("status partial updated");
|
|
||||||
}
|
}
|
||||||
if (counts && sections.counts) {
|
if (counts && sections.counts) {
|
||||||
sections.counts.innerHTML = counts;
|
sections.counts.innerHTML = counts;
|
||||||
console.log("counts partial updated");
|
|
||||||
}
|
}
|
||||||
if (notifications && sections.notifications) {
|
if (notifications && sections.notifications) {
|
||||||
sections.notifications.innerHTML = notifications;
|
sections.notifications.innerHTML = notifications;
|
||||||
console.log("notifications partial updated");
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Error fetching job update partials:", err);
|
console.error('Error fetching job update partials:', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user