Ticket time tracking

Bugfix for ticket time tracking as this was broken since the open ticket timer was removed
This commit is contained in:
Marcus Hill
2024-05-26 17:05:42 +01:00
parent f1037975a7
commit 059a5516fc
3 changed files with 7 additions and 169 deletions

View File

@@ -8,8 +8,6 @@
var ticketID = getCurrentTicketID();
var elapsedSecs = getElapsedSeconds();
updateRunningTicketsCount();
function getCurrentTicketID() {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get('ticket_id');
@@ -55,7 +53,6 @@
timerInterval = setInterval(countTime, 1000);
isPaused = false;
document.getElementById("startStopTimer").innerText = "Pause";
updateRunningTicketsCount();
localStorage.setItem("ticket-timer-running-" + ticketID, "true");
}
@@ -70,7 +67,6 @@
localStorage.removeItem(getLocalStorageKey("startTime"));
isPaused = true;
document.getElementById("startStopTimer").innerText = "Start";
updateRunningTicketsCount();
localStorage.setItem("ticket-timer-running-" + ticketID, "false");
}
@@ -91,7 +87,6 @@
document.getElementById("startStopTimer").innerText = "Start";
}
localStorage.setItem("ticket-timer-running-" + ticketID, "false");
updateRunningTicketsCount();
}
function forceResetTimer() {
@@ -102,7 +97,7 @@
displayTime();
document.getElementById("startStopTimer").innerText = "Start";
}
function handleInputFocus() {
if (!isPaused) {
pauseTimer();
@@ -114,7 +109,7 @@
const minutes = parseInt(document.getElementById("minutes").value, 10) || 0;
const seconds = parseInt(document.getElementById("seconds").value, 10) || 0;
elapsedSecs = (hours * 3600) + (minutes * 60) + seconds;
// Update local storage so the manually entered time is retained even if the page is reloaded.
if (!timerInterval) {
localStorage.setItem(getLocalStorageKey("pausedTime"), elapsedSecs.toString());
@@ -125,18 +120,6 @@
}
}
function updateRunningTicketsCount() {
let runningTickets = parseInt(document.getElementById('runningTicketsCount').innerText, 10);
if (!isPaused && timerInterval) {
runningTickets += 1;
} else {
runningTickets = Math.max(0, runningTickets - 1);
}
document.getElementById('runningTicketsCount').innerText = runningTickets.toString();
}
// Function to check status and pause timer
function checkStatusAndPauseTimer() {
var status = document.querySelector('select[name="status"]').value;
@@ -148,7 +131,7 @@
document.getElementById("hours").addEventListener('change', updateTimeFromInput);
document.getElementById("minutes").addEventListener('change', updateTimeFromInput);
document.getElementById("seconds").addEventListener('change', updateTimeFromInput);
document.getElementById("hours").addEventListener('focus', handleInputFocus);
document.getElementById("minutes").addEventListener('focus', handleInputFocus);
document.getElementById("seconds").addEventListener('focus', handleInputFocus);
@@ -184,11 +167,11 @@
} else if (localStorage.getItem(getLocalStorageKey("startTime"))) {
startTimer();
}
// Check and pause timer if status is pending
checkStatusAndPauseTimer();
} catch (error) {
console.error("There was an issue initializing the timer:", error);
}
});
})();
})();