- Implemented subscription creation, updating, and rendering in script_9.js. - Added functions for handling subscription line items, product selection, and total calculations. - Integrated AnyDesk API for session management in test_anydesk.py. - Created REST client test requests for API endpoints in api.http. - Developed a script to check ESET machine status and save details in tmp_check_eset_machine.py.
54 lines
2.9 KiB
Plaintext
54 lines
2.9 KiB
Plaintext
function renderTimeV1Timeline(entries) {
|
|
const timeline = document.getElementById('timeTimelineColumns');
|
|
const unplaced = document.getElementById('timeUnplacedEntries');
|
|
const activeBanner = document.getElementById('timeActiveBanner');
|
|
const activeBannerText = document.getElementById('timeActiveBannerText');
|
|
if (!timeline || !unplaced) return;
|
|
|
|
const active = (entries || []).find((entry) => entry.aktiv_timer && !entry.slut_tid);
|
|
if (active) {
|
|
activeBanner.classList.remove('d-none');
|
|
activeBannerText.textContent = `Aktiv på ${active.user_name || 'ukendt bruger'}: ${active.description || 'uden beskrivelse'}`;
|
|
} else {
|
|
activeBanner.classList.add('d-none');
|
|
}
|
|
|
|
const unplacedEntries = (entries || []).filter((entry) => entry.ikke_placeret || (!entry.start_tid && !entry.slut_tid));
|
|
if (!unplacedEntries.length) {
|
|
unplaced.innerHTML = '<div class="text-muted small">Ingen entries uden tidspunkter.</div>';
|
|
} else {
|
|
unplaced.innerHTML = unplacedEntries.map((entry) => {
|
|
return `
|
|
<div class="border rounded p-2 mb-2">
|
|
<div class="small fw-semibold">${entry.description || 'Uden beskrivelse'}</div>
|
|
<div class="small text-muted">${minutesToLabel(entry.faktisk_tid_min || Math.round((entry.original_hours || 0) * 60))}</div>
|
|
<div class="mt-1">${timeStatusBadge(entry.entry_status || 'afventer')}</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
if (!entries || !entries.length) {
|
|
timeline.innerHTML = '<div class="text-muted text-center py-3">Ingen tidsregistreringer endnu.</div>';
|
|
return;
|
|
}
|
|
|
|
const grouped = {};
|
|
(entries || []).forEach((entry) => {
|
|
const key = `${entry.medarbejder_id || 0}:${entry.user_name || 'Ukendt bruger'}`;
|
|
if (!grouped[key]) grouped[key] = [];
|
|
grouped[key].push(entry);
|
|
});
|
|
|
|
if (!entries || !entries.length) {
|
|
timeline.innerHTML = '<div class="text-muted text-center py-3">Ingen tidsregistreringer endnu.</div>';
|
|
return;
|
|
}
|
|
|
|
timeline.innerHTML = Object.entries(grouped).map(([key, rows]) => {
|
|
const userName = key.split(':')[1] || 'Ukendt bruger';
|
|
const sortedRows = [...rows].sort((a, b) => {
|
|
const aDate = new Date(a.start_tid || a.slut_tid || a.worked_date || a.created_at || 0).getTime();
|
|
const bDate = new Date(b.start_tid || b.slut_tid || b.worked_date || b.created_at || 0).getTime();
|
|
return bDate - aDate;
|
|
} |