mirror of
https://github.com/coollabsio/coolify.git
synced 2026-06-14 03:19:51 +00:00
53f24df0a0
Add a visible countdown in the terminal UI and terminate realtime PTY sessions after the fixed maximum lifetime.
23 lines
763 B
JavaScript
23 lines
763 B
JavaScript
export const MAX_TERMINAL_SESSION_SECONDS = 8 * 60 * 60;
|
|
export const TERMINAL_SESSION_WARNING_SECONDS = 30 * 60;
|
|
export const TERMINAL_SESSION_DANGER_SECONDS = 5 * 60;
|
|
|
|
export function formatTerminalSessionRemainingTime(seconds) {
|
|
const remainingSeconds = Math.max(0, Math.ceil(seconds));
|
|
|
|
if (remainingSeconds === 0) {
|
|
return 'expired';
|
|
}
|
|
|
|
const totalMinutes = Math.floor(remainingSeconds / 60);
|
|
const hours = Math.floor(totalMinutes / 60);
|
|
const minutes = totalMinutes % 60;
|
|
const secondsPart = remainingSeconds % 60;
|
|
|
|
if (hours === 0) {
|
|
return `${minutes}m ${String(secondsPart).padStart(2, '0')}s`;
|
|
}
|
|
|
|
return `${hours}h ${String(minutes).padStart(2, '0')}m ${String(secondsPart).padStart(2, '0')}s`;
|
|
}
|