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