refactor(helpdesk): redesign team dashboard with section widgets and ticket tables
Replace custom card layout with the existing debitor dashboard pattern: each agent is a section with helpdesk-support-section-title (avatar initials + name + count badge + line) and a ticket table underneath (Ticket No, Customer, Description, Age). Critical rows highlighted. Queue section uses same pattern without avatar. Performance tab uses compact rows with avatar + name + resolved badge. No custom card or pill styles — consistent with existing dashboard widgets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Team workload dashboard — visual workload map with avatar cards.
|
||||
* Current tab: queue section + agent cards with ticket pills.
|
||||
* Performance tab: compact agent cards with resolved counts.
|
||||
* Team workload dashboard.
|
||||
* Current tab: per-agent widget with section title + ticket table.
|
||||
* Performance tab: compact agent rows with resolved counts.
|
||||
*/
|
||||
|
||||
const container = document.querySelector('.app-details-container[data-team-workload-url]');
|
||||
@@ -36,9 +36,6 @@ if (container) {
|
||||
return e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate two-letter initials from a display name.
|
||||
*/
|
||||
function initials(name) {
|
||||
const parts = name.trim().split(/\s+/);
|
||||
if (parts.length >= 2) return (parts[0][0] + parts[parts.length - 1][0]).toUpperCase();
|
||||
@@ -50,97 +47,87 @@ if (container) {
|
||||
return Math.floor(hours / 24) + 'd';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a ticket pill: "T-1234 · K-10610 · 12h"
|
||||
*/
|
||||
function buildTicketPill(t) {
|
||||
const pill = h('span', 'helpdesk-team-pill');
|
||||
if (t.critical) pill.classList.add('helpdesk-team-pill-critical');
|
||||
|
||||
pill.appendChild(h('span', 'helpdesk-team-pill-no', t.no));
|
||||
if (t.customer) {
|
||||
pill.appendChild(h('span', 'helpdesk-team-pill-sep', '·'));
|
||||
pill.appendChild(h('span', 'helpdesk-team-pill-customer', t.customer));
|
||||
}
|
||||
pill.appendChild(h('span', 'helpdesk-team-pill-sep', '·'));
|
||||
pill.appendChild(h('span', 'helpdesk-team-pill-age', formatAge(t.age_hours)));
|
||||
|
||||
if (t.description) pill.title = t.description;
|
||||
return pill;
|
||||
function formatDate(isoString) {
|
||||
if (!isoString) return '—';
|
||||
const d = new Date(isoString);
|
||||
if (isNaN(d.getTime())) return '—';
|
||||
return d.toLocaleDateString(undefined, { day: '2-digit', month: '2-digit', year: 'numeric' });
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the queue section (unassigned tickets).
|
||||
* Build a ticket table row: No | Customer | Last activity | Age
|
||||
*/
|
||||
function buildQueueSection(member) {
|
||||
const section = h('div', 'helpdesk-team-queue');
|
||||
function buildTicketRow(t) {
|
||||
const tr = h('tr', t.critical ? 'helpdesk-team-ticket-critical' : '');
|
||||
|
||||
const header = h('div', 'helpdesk-team-queue-header');
|
||||
header.appendChild(h('span', 'helpdesk-team-queue-title', labelQueue));
|
||||
header.appendChild(h('span', 'helpdesk-team-queue-count', String(member.open_tickets) + ' ' + labelTickets));
|
||||
section.appendChild(header);
|
||||
const noCell = h('td', 'helpdesk-team-ticket-no', t.no);
|
||||
tr.appendChild(noCell);
|
||||
tr.appendChild(h('td', '', t.customer || '—'));
|
||||
tr.appendChild(h('td', '', t.description || '—'));
|
||||
const ageCell = h('td', '', formatAge(t.age_hours));
|
||||
tr.appendChild(ageCell);
|
||||
|
||||
const pills = h('div', 'helpdesk-team-pills');
|
||||
for (const t of member.open_ticket_details || []) {
|
||||
pills.appendChild(buildTicketPill(t));
|
||||
return tr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a section widget for one agent — mirrors debitor dashboard section pattern.
|
||||
*/
|
||||
function buildAgentWidget(m, isQueue) {
|
||||
const section = h('section');
|
||||
|
||||
// Section title: "MM Name (count)" with line — same as helpdesk-support-section-title
|
||||
const title = h('h3', 'helpdesk-support-section-title');
|
||||
const name = isQueue ? labelQueue : m.display_name;
|
||||
const count = String(m.open_tickets);
|
||||
|
||||
if (!isQueue) {
|
||||
const avatar = h('span', 'helpdesk-team-avatar-inline', initials(m.display_name));
|
||||
title.appendChild(avatar);
|
||||
}
|
||||
title.appendChild(document.createTextNode(name));
|
||||
|
||||
const badge = h('span', 'helpdesk-team-title-count', count);
|
||||
if (m.critical_tickets > 0) badge.classList.add('helpdesk-team-title-count-warning');
|
||||
title.appendChild(badge);
|
||||
section.appendChild(title);
|
||||
|
||||
// Ticket table
|
||||
const tickets = m.open_ticket_details || [];
|
||||
if (tickets.length > 0) {
|
||||
const table = h('table', 'helpdesk-team-ticket-table');
|
||||
const thead = h('thead');
|
||||
const headRow = h('tr');
|
||||
headRow.appendChild(h('th', '', 'Ticket'));
|
||||
headRow.appendChild(h('th', '', 'Kunde'));
|
||||
headRow.appendChild(h('th', '', 'Beschreibung'));
|
||||
headRow.appendChild(h('th', '', 'Alter'));
|
||||
thead.appendChild(headRow);
|
||||
table.appendChild(thead);
|
||||
|
||||
const tbody = h('tbody');
|
||||
for (const t of tickets) tbody.appendChild(buildTicketRow(t));
|
||||
table.appendChild(tbody);
|
||||
section.appendChild(table);
|
||||
}
|
||||
section.appendChild(pills);
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an agent card with avatar and ticket pills.
|
||||
* Build a compact row for the performance tab.
|
||||
*/
|
||||
function buildAgentCard(m) {
|
||||
const card = h('article', 'helpdesk-team-agent');
|
||||
|
||||
// Avatar
|
||||
card.appendChild(h('div', 'helpdesk-team-avatar', initials(m.display_name)));
|
||||
|
||||
// Content area
|
||||
const content = h('div', 'helpdesk-team-agent-content');
|
||||
|
||||
// Name row
|
||||
const nameRow = h('div', 'helpdesk-team-agent-header');
|
||||
nameRow.appendChild(h('span', 'helpdesk-team-agent-name', m.display_name));
|
||||
const countBadge = h('span', 'helpdesk-team-agent-count', String(m.open_tickets));
|
||||
if (m.critical_tickets > 0) countBadge.classList.add('helpdesk-team-agent-count-warning');
|
||||
nameRow.appendChild(countBadge);
|
||||
content.appendChild(nameRow);
|
||||
|
||||
// Ticket pills
|
||||
const tickets = m.open_ticket_details || [];
|
||||
if (tickets.length > 0) {
|
||||
const pills = h('div', 'helpdesk-team-pills');
|
||||
for (const t of tickets) pills.appendChild(buildTicketPill(t));
|
||||
content.appendChild(pills);
|
||||
}
|
||||
|
||||
card.appendChild(content);
|
||||
return card;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a compact performance card with avatar and resolved count.
|
||||
*/
|
||||
function buildPerformanceCard(m) {
|
||||
function buildPerformanceRow(m) {
|
||||
const isQueue = m.support_user === '';
|
||||
const section = h('div', 'helpdesk-team-perf-row');
|
||||
|
||||
const card = h('article', 'helpdesk-team-agent helpdesk-team-agent-compact');
|
||||
if (!isQueue) {
|
||||
section.appendChild(h('span', 'helpdesk-team-avatar-inline', initials(m.display_name)));
|
||||
}
|
||||
section.appendChild(h('span', 'helpdesk-team-perf-name', isQueue ? labelQueue : m.display_name));
|
||||
section.appendChild(h('span', 'helpdesk-team-perf-count', String(m.resolved_in_period)));
|
||||
|
||||
const avatar = h('div', 'helpdesk-team-avatar helpdesk-team-avatar-sm', isQueue ? '?' : initials(m.display_name));
|
||||
if (isQueue) avatar.classList.add('helpdesk-team-avatar-muted');
|
||||
card.appendChild(avatar);
|
||||
|
||||
const content = h('div', 'helpdesk-team-agent-content');
|
||||
const nameRow = h('div', 'helpdesk-team-agent-header');
|
||||
nameRow.appendChild(h('span', 'helpdesk-team-agent-name', isQueue ? labelQueue : m.display_name));
|
||||
nameRow.appendChild(h('span', 'helpdesk-team-agent-count helpdesk-team-agent-count-success', String(m.resolved_in_period)));
|
||||
content.appendChild(nameRow);
|
||||
|
||||
card.appendChild(content);
|
||||
return card;
|
||||
return section;
|
||||
}
|
||||
|
||||
function renderCurrentTab(members) {
|
||||
@@ -150,11 +137,8 @@ if (container) {
|
||||
const queue = members.find(m => m.support_user === '' && m.open_tickets > 0);
|
||||
const agents = members.filter(m => m.support_user !== '' && (m.open_tickets > 0 || m.critical_tickets > 0));
|
||||
|
||||
if (queue) elCurrentCards.appendChild(buildQueueSection(queue));
|
||||
|
||||
const grid = h('div', 'helpdesk-team-agents');
|
||||
for (const m of agents) grid.appendChild(buildAgentCard(m));
|
||||
elCurrentCards.appendChild(grid);
|
||||
if (queue) elCurrentCards.appendChild(buildAgentWidget(queue, true));
|
||||
for (const m of agents) elCurrentCards.appendChild(buildAgentWidget(m, false));
|
||||
}
|
||||
|
||||
function renderPerformanceTab(members) {
|
||||
@@ -169,9 +153,7 @@ if (container) {
|
||||
return b.resolved_in_period - a.resolved_in_period;
|
||||
});
|
||||
|
||||
const grid = h('div', 'helpdesk-team-agents');
|
||||
for (const m of sorted) grid.appendChild(buildPerformanceCard(m));
|
||||
elPerformanceCards.appendChild(grid);
|
||||
for (const m of sorted) elPerformanceCards.appendChild(buildPerformanceRow(m));
|
||||
}
|
||||
|
||||
async function fetchData(refresh = false) {
|
||||
|
||||
Reference in New Issue
Block a user