Upload via GUI (74 Dateien)

This commit is contained in:
2026-11-05 21:22:50 +00:00
parent c0b4092498
commit dee5c631b9
10 changed files with 299 additions and 282 deletions
@@ -5,7 +5,7 @@
}, },
"projects": { "projects": {
"C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj": { "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj": {
"version": "2.12.2", "version": "0.0.0",
"restore": { "restore": {
"projectUniqueName": "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj", "projectUniqueName": "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj",
"projectName": "DeskHub-Setup", "projectName": "DeskHub-Setup",
+1 -1
View File
@@ -418,7 +418,7 @@
"C:\\Users\\Viper\\.nuget\\packages\\": {} "C:\\Users\\Viper\\.nuget\\packages\\": {}
}, },
"project": { "project": {
"version": "2.12.2", "version": "0.0.0",
"restore": { "restore": {
"projectUniqueName": "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj", "projectUniqueName": "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj",
"projectName": "DeskHub-Setup", "projectName": "DeskHub-Setup",
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "Xvw5MCNB0oU=", "dgSpecHash": "+dcsa7CcM5g=",
"success": true, "success": true,
"projectFilePath": "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj", "projectFilePath": "C:\\Users\\Viper\\Desktop\\deskhub\\desktop\\installer\\DeskHubSetup.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "deskhub", "name": "deskhub",
"productName": "DeskHub", "productName": "DeskHub",
"version": "2.12.2", "version": "2.12.3",
"description": "DeskHub Desktop-Client für Mitarbeiter", "description": "DeskHub Desktop-Client für Mitarbeiter",
"main": "src/main.js", "main": "src/main.js",
"author": "M_Viper", "author": "M_Viper",
+270 -268
View File
@@ -1,268 +1,270 @@
'use strict'; 'use strict';
// Zusätzliche Verwaltungsbereiche (wie in der Android-App): Teams, Rollen, Eskalationen, // Zusätzliche Verwaltungsbereiche (wie in der Android-App): Teams, Rollen, Eskalationen,
// Geschäftszeiten, E-Mail-Vorlagen und Ticket-Regeln. Jeder Bereich rendert sich selbst in `body`. // Geschäftszeiten, E-Mail-Vorlagen und Ticket-Regeln. Jeder Bereich rendert sich selbst in `body`.
const PERM_LABELS = { const PERM_LABELS = {
reply_ticket: 'Tickets beantworten', close_ticket: 'Tickets lösen/schließen', delete_ticket: 'Tickets löschen', transfer_ticket: 'Tickets verschieben', reply_ticket: 'Tickets beantworten', close_ticket: 'Tickets lösen/schließen', delete_ticket: 'Tickets löschen', transfer_ticket: 'Tickets verschieben',
post_note: 'Interne Notizen', assign_ticket: 'Tickets zuweisen', manage_canned: 'Textbausteine verwalten', view_reports: 'Berichte ansehen', post_note: 'Interne Notizen', assign_ticket: 'Tickets zuweisen', manage_canned: 'Textbausteine verwalten', view_reports: 'Berichte ansehen',
create_ticket: 'Tickets erstellen', manage_kb: 'Wissensdatenbank', manage_departments: 'Abteilungen', manage_priorities: 'Prioritäten / SLA', create_ticket: 'Tickets erstellen', manage_kb: 'Wissensdatenbank', manage_departments: 'Abteilungen', manage_priorities: 'Prioritäten / SLA',
manage_help_topics: 'Hilfe-Themen', manage_email_addresses: 'E-Mail-Adressen', manage_email_templates: 'E-Mail-Vorlagen', manage_organizations: 'Organisationen', manage_help_topics: 'Hilfe-Themen', manage_email_addresses: 'E-Mail-Adressen', manage_email_templates: 'E-Mail-Vorlagen', manage_organizations: 'Organisationen',
manage_teams: 'Teams', manage_roles: 'Rollen', manage_staff: 'Mitarbeiter', view_audit_log: 'Admin-Protokoll', manage_escalations: 'Eskalationsregeln', manage_teams: 'Teams', manage_roles: 'Rollen', manage_staff: 'Mitarbeiter', view_audit_log: 'Admin-Protokoll', manage_escalations: 'Eskalationsregeln',
view_time_entries: 'Zeiterfassung', manage_business_hours: 'Geschäftszeiten', view_time_entries: 'Zeiterfassung', manage_business_hours: 'Geschäftszeiten',
}; };
const WEEKDAYS = { 1: 'Montag', 2: 'Dienstag', 3: 'Mittwoch', 4: 'Donnerstag', 5: 'Freitag', 6: 'Samstag', 0: 'Sonntag' }; const WEEKDAYS = { 1: 'Montag', 2: 'Dienstag', 3: 'Mittwoch', 4: 'Donnerstag', 5: 'Freitag', 6: 'Samstag', 0: 'Sonntag' };
const opt = (arr, val, empty) => [empty ? h('option', { value: '' }, empty) : null, ...arr.map(([v, l]) => h('option', { value: v, selected: String(v) === String(val ?? '') }, l))]; const opt = (arr, val, empty) => [empty ? h('option', { value: '' }, empty) : null, ...arr.map(([v, l]) => h('option', { value: v, selected: String(v) === String(val ?? '') }, l))];
const named = (list) => list.map((x) => [x.id, x.name]); const named = (list) => list.map((x) => [x.id, x.name]);
const numOrNull = (v) => (v === '' || v == null ? null : Number(v)); const numOrNull = (v) => (v === '' || v == null ? null : Number(v));
const row = (...kids) => h('div', { class: 'row' }, ...kids); const row = (...kids) => h('div', { class: 'row' }, ...kids);
const delBtn = (fn) => h('button', { class: 'btn danger sm', onclick: (e) => { e.stopPropagation(); if (confirm('Wirklich löschen?')) fn(); } }, '✕'); const delBtn = (fn) => h('button', { class: 'btn danger sm', onclick: (e) => { e.stopPropagation(); if (confirm('Wirklich löschen?')) fn(); } }, '✕');
const table = (heads, rows) => h('div', { class: 'panel' }, rows.length ? h('table', {}, h('tr', {}, ...heads.map((t) => h('th', {}, t))), ...rows) : h('div', { class: 'muted' }, 'Keine Einträge.')); const table = (heads, rows) => h('div', { class: 'panel' }, rows.length ? h('table', {}, h('tr', {}, ...heads.map((t) => h('th', {}, t))), ...rows) : h('div', { class: 'muted' }, 'Keine Einträge.'));
// ─── Teams ─────────────────────────────────────────────────────────────────── // ─── Teams ───────────────────────────────────────────────────────────────────
async function adminTeams(body, addBtn) { async function adminTeams(body, addBtn) {
const load = async () => { const load = async () => {
const r = await run(() => api('teams.php')); if (!r) return; const r = await run(() => api('teams.php')); if (!r) return;
clear(body).append(table(['Name', 'Leitung', 'Mitglieder', 'Aktiv', 'Aktualisiert', ''], r.items.map((t) => h('tr', { class: 'click', onclick: () => edit(t, r) }, clear(body).append(table(['Name', 'Leitung', 'Mitglieder', 'Aktiv', 'Aktualisiert', ''], r.items.map((t) => h('tr', { class: 'click', onclick: () => edit(t, r) },
h('td', {}, t.name), h('td', {}, t.leadName || '—'), h('td', {}, t.memberCount), h('td', {}, t.name), h('td', {}, t.leadName || '—'), h('td', {}, t.memberCount),
h('td', {}, h('input', { type: 'checkbox', checked: t.isActive, onclick: (e) => e.stopPropagation(), onchange: () => run(async () => { await post('teams.php', { action: 'toggle', id: t.id }); load(); }) })), h('td', {}, h('input', { type: 'checkbox', checked: t.isActive, onclick: (e) => e.stopPropagation(), onchange: () => run(async () => { await post('teams.php', { action: 'toggle', id: t.id }); load(); }) })),
h('td', { class: 'muted' }, t.updatedAt ? new Date(t.updatedAt.replace(' ', 'T')).toLocaleString(window.I18N?.locale || 'de-DE', { dateStyle: 'short', timeStyle: 'short' }) : ''), h('td', { class: 'muted' }, t.updatedAt ? new Date(t.updatedAt.replace(' ', 'T')).toLocaleString(window.I18N?.locale || 'de-DE', { dateStyle: 'short', timeStyle: 'short' }) : ''),
h('td', {}, delBtn(() => run(async () => { await post('teams.php', { action: 'delete', id: t.id }); load(); }, 'Gelöscht'))))))); h('td', {}, delBtn(() => run(async () => { await post('teams.php', { action: 'delete', id: t.id }); load(); }, 'Gelöscht')))))));
addBtn.onclick = () => edit(null, r); addBtn.onclick = () => edit(null, r);
}; };
function edit(t, r) { function edit(t, r) {
const name = h('input', { value: t?.name || '' }), notes = h('textarea', { value: t?.notes || '' }); const name = h('input', { value: t?.name || '' }), notes = h('textarea', { value: t?.notes || '' });
const lead = h('select', {}, ...opt(named(r.staffOptions), t?.leadId, '— keine —')); const lead = h('select', {}, ...opt(named(r.staffOptions), t?.leadId, '— keine —'));
const active = h('input', { type: 'checkbox', checked: t ? t.isActive : true }), noAlerts = h('input', { type: 'checkbox', checked: !!t?.noAlerts }); const active = h('input', { type: 'checkbox', checked: t ? t.isActive : true }), noAlerts = h('input', { type: 'checkbox', checked: !!t?.noAlerts });
const members = r.staffOptions.map((s) => ({ s, cb: h('input', { type: 'checkbox', checked: t?.memberIds?.includes(s.id) }) })); const members = r.staffOptions.map((s) => ({ s, cb: h('input', { type: 'checkbox', checked: t?.memberIds?.includes(s.id) }) }));
modal(t ? 'Team bearbeiten' : 'Neues Team', h('div', {}, h('label', {}, 'Name'), name, h('label', {}, 'Leitung'), lead, h('label', { class: 'check' }, active, 'Aktiv'), modal(t ? 'Team bearbeiten' : 'Neues Team', h('div', {}, h('label', {}, 'Name'), name, h('label', {}, 'Leitung'), lead, h('label', { class: 'check' }, active, 'Aktiv'),
h('label', { class: 'check' }, noAlerts, 'Benachrichtigung bei Ticketzuweisung deaktivieren'), h('label', {}, 'Administratornotizen (intern)'), notes, h('label', { class: 'check' }, noAlerts, 'Benachrichtigung bei Ticketzuweisung deaktivieren'), h('label', {}, 'Administratornotizen (intern)'), notes,
h('label', {}, 'Mitglieder'), h('div', { class: 'checks' }, ...members.map(({ s, cb }) => h('label', { class: 'check' }, cb, s.name)))), h('label', {}, 'Mitglieder'), h('div', { class: 'checks' }, ...members.map(({ s, cb }) => h('label', { class: 'check' }, cb, s.name)))),
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post('teams.php', { action: 'save', id: t?.id ?? null, name: name.value, leadId: numOrNull(lead.value), isActive: active.checked, noAlerts: noAlerts.checked, notes: notes.value || null, memberIds: members.filter((m) => m.cb.checked).map((m) => m.s.id) }), 'Gespeichert')) { close(); load(); } } }]); [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('teams.php', { action: 'save', id: t?.id ?? null, name: name.value, leadId: numOrNull(lead.value), isActive: active.checked, noAlerts: noAlerts.checked, notes: notes.value || null, memberIds: members.filter((m) => m.cb.checked).map((m) => m.s.id) }), 'Gespeichert')) { close(); load(); } } }]);
} }
load(); load();
} }
// ─── Rollen ────────────────────────────────────────────────────────────────── // ─── Rollen ──────────────────────────────────────────────────────────────────
async function adminRoles(body, addBtn) { async function adminRoles(body, addBtn) {
const load = async () => { const load = async () => {
const r = await run(() => api('roles.php')); if (!r) return; const r = await run(() => api('roles.php')); if (!r) return;
clear(body).append(table(['Rolle', 'Status', 'Zugewiesen', 'Rechte', ''], r.items.map((x) => h('tr', { class: 'click', onclick: () => edit(x, r) }, clear(body).append(table(['Rolle', 'Status', 'Zugewiesen', 'Rechte', ''], r.items.map((x) => h('tr', { class: 'click', onclick: () => edit(x, r) },
h('td', {}, x.name), h('td', {}, x.isActive ? 'Aktiv' : 'Deaktiviert'), h('td', {}, x.staffCount), h('td', { class: 'muted' }, Object.values(x.permissions).filter(Boolean).length + ' von ' + r.permissionKeys.length), h('td', {}, x.name), h('td', {}, x.isActive ? 'Aktiv' : 'Deaktiviert'), h('td', {}, x.staffCount), h('td', { class: 'muted' }, Object.values(x.permissions).filter(Boolean).length + ' von ' + r.permissionKeys.length),
h('td', {}, delBtn(() => run(async () => { await post('roles.php', { action: 'delete', id: x.id }); load(); }, 'Gelöscht'))))))); h('td', {}, delBtn(() => run(async () => { await post('roles.php', { action: 'delete', id: x.id }); load(); }, 'Gelöscht')))))));
addBtn.onclick = () => edit(null, r); addBtn.onclick = () => edit(null, r);
}; };
function edit(x, r) { function edit(x, r) {
const name = h('input', { value: x?.name || '' }), notes = h('textarea', { value: x?.notes || '' }); const name = h('input', { value: x?.name || '' }), notes = h('textarea', { value: x?.notes || '' });
const active = h('input', { type: 'checkbox', checked: x ? x.isActive : true }); const active = h('input', { type: 'checkbox', checked: x ? x.isActive : true });
const perms = (x?.permissions) || r.defaultAgentPermissions || {}; const perms = (x?.effectivePermissions) || (x?.permissions) || r.defaultAgentPermissions || {};
const boxes = r.permissionKeys.map((k) => ({ k, cb: h('input', { type: 'checkbox', checked: !!perms[k] }) })); const boxes = r.permissionKeys.map((k) => ({ k, cb: h('input', { type: 'checkbox', checked: !!perms[k] }) }));
modal(x ? 'Rolle bearbeiten' : 'Neue Rolle', h('div', {}, h('label', {}, 'Name'), name, h('label', { class: 'check' }, active, 'Aktiv (deaktivierte Rolle wird ignoriert)'), h('label', {}, 'Administratornotizen (intern)'), notes, h('label', {}, 'Rechte'), const byKey = Object.fromEntries(boxes.map((b) => [b.k, b]));
h('div', { class: 'checks' }, ...boxes.map(({ k, cb }) => h('label', { class: 'check' }, cb, PERM_LABELS[k] || k)))), const groups = (r.permissionGroups && r.permissionGroups.length ? r.permissionGroups : [{ title: 'Rechte', keys: r.permissionKeys }]);
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post('roles.php', { action: 'save', id: x?.id ?? null, name: name.value, isActive: active.checked, notes: notes.value || null, permissions: Object.fromEntries(boxes.map(({ k, cb }) => [k, cb.checked])) }), 'Gespeichert')) { close(); load(); } } }]); modal(x ? 'Rolle bearbeiten' : 'Neue Rolle', h('div', {}, h('label', {}, 'Name'), name, h('label', { class: 'check' }, active, 'Aktiv (deaktivierte Rolle wird ignoriert)'), h('label', {}, 'Administratornotizen (intern)'), notes, h('label', {}, 'Rechte'),
} ...groups.map((g) => h('div', {}, h('h4', {}, g.title), h('div', { class: 'checks' }, ...g.keys.filter((k) => byKey[k]).map((k) => h('label', { class: 'check' }, byKey[k].cb, r.permissionLabels?.[k] || PERM_LABELS[k] || k)))))),
load(); [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('roles.php', { action: 'save', id: x?.id ?? null, name: name.value, isActive: active.checked, notes: notes.value || null, permissions: Object.fromEntries(boxes.map(({ k, cb }) => [k, cb.checked])) }), 'Gespeichert')) { close(); load(); } } }]);
} }
load();
// ─── Eskalationsregeln ─────────────────────────────────────────────────────── }
const TRIGGERS = [['no_reply', 'Keine Antwort seit …'], ['no_update', 'Keine Aktualisierung seit …'], ['overdue', 'Überfällig seit …'], ['open_too_long', 'Zu lange offen seit …']];
async function adminEscalations(body, addBtn) { // ─── Eskalationsregeln ───────────────────────────────────────────────────────
const load = async () => { const TRIGGERS = [['no_reply', 'Keine Antwort seit …'], ['no_update', 'Keine Aktualisierung seit …'], ['overdue', 'Überfällig seit …'], ['open_too_long', 'Zu lange offen seit …']];
const r = await run(() => api('escalation_rules.php')); if (!r) return; async function adminEscalations(body, addBtn) {
clear(body).append(table(['Regel', 'Auslöser', 'Angewendet', 'Aktiv', ''], r.rules.map((x) => h('tr', { class: 'click', onclick: () => edit(x, r) }, const load = async () => {
h('td', {}, x.name), h('td', {}, `${(TRIGGERS.find((t) => t[0] === x.triggerType) || [, x.triggerType])[1].replace('…', x.triggerHours + ' Std.')}`), h('td', {}, x.appliedCount), const r = await run(() => api('escalation_rules.php')); if (!r) return;
h('td', {}, h('input', { type: 'checkbox', checked: x.isActive, onclick: (e) => e.stopPropagation(), onchange: () => run(async () => { await post('escalation_rules.php', { action: 'toggle', id: x.id }); load(); }) })), clear(body).append(table(['Regel', 'Auslöser', 'Angewendet', 'Aktiv', ''], r.rules.map((x) => h('tr', { class: 'click', onclick: () => edit(x, r) },
h('td', {}, delBtn(() => run(async () => { await post('escalation_rules.php', { action: 'delete', id: x.id }); load(); }, 'Gelöscht'))))))); h('td', {}, x.name), h('td', {}, `${(TRIGGERS.find((t) => t[0] === x.triggerType) || [, x.triggerType])[1].replace('…', x.triggerHours + ' Std.')}`), h('td', {}, x.appliedCount),
addBtn.onclick = () => edit(null, r); h('td', {}, h('input', { type: 'checkbox', checked: x.isActive, onclick: (e) => e.stopPropagation(), onchange: () => run(async () => { await post('escalation_rules.php', { action: 'toggle', id: x.id }); load(); }) })),
}; h('td', {}, delBtn(() => run(async () => { await post('escalation_rules.php', { action: 'delete', id: x.id }); load(); }, 'Gelöscht')))))));
function edit(x, r) { addBtn.onclick = () => edit(null, r);
const f = { };
name: h('input', { value: x?.name || '' }), active: h('input', { type: 'checkbox', checked: x?.isActive ?? true }), function edit(x, r) {
trig: h('select', {}, ...opt(TRIGGERS, x?.triggerType || 'no_reply')), hours: h('input', { type: 'number', min: 1, value: x?.triggerHours ?? 24 }), const f = {
cStatus: h('select', {}, ...opt(state.meta.statuses.map((s) => [s.value, s.label]), x?.conditionStatus, 'Beliebig')), name: h('input', { value: x?.name || '' }), active: h('input', { type: 'checkbox', checked: x?.isActive ?? true }),
cPrio: h('select', {}, ...opt(named(r.priorities), x?.conditionPriorityId, 'Beliebig')), cDept: h('select', {}, ...opt(named(r.departments), x?.conditionDeptId, 'Beliebig')), trig: h('select', {}, ...opt(TRIGGERS, x?.triggerType || 'no_reply')), hours: h('input', { type: 'number', min: 1, value: x?.triggerHours ?? 24 }),
aPrio: h('select', {}, ...opt(named(r.priorities), x?.actionSetPriorityId, '— nicht ändern —')), aStaff: h('select', {}, ...opt(named(r.staffOptions), x?.actionAssignStaffId, '— nicht ändern —')), cStatus: h('select', {}, ...opt(state.meta.statuses.map((s) => [s.value, s.label]), x?.conditionStatus, 'Beliebig')),
aStatus: h('select', {}, ...opt([['open', 'Offen'], ['pending', 'Wartend'], ['on_hold', 'Zurückgestellt']], x?.actionSetStatus, '— nicht ändern —')), cPrio: h('select', {}, ...opt(named(r.priorities), x?.conditionPriorityId, 'Beliebig')), cDept: h('select', {}, ...opt(named(r.departments), x?.conditionDeptId, 'Beliebig')),
nAdmin: h('input', { type: 'checkbox', checked: x?.actionNotifyAdmin ?? true }), nStaff: h('input', { type: 'checkbox', checked: !!x?.actionNotifyStaff }), aPrio: h('select', {}, ...opt(named(r.priorities), x?.actionSetPriorityId, '— nicht ändern —')), aStaff: h('select', {}, ...opt(named(r.staffOptions), x?.actionAssignStaffId, '— nicht ändern —')),
}; aStatus: h('select', {}, ...opt([['open', 'Offen'], ['pending', 'Wartend'], ['on_hold', 'Zurückgestellt']], x?.actionSetStatus, '— nicht ändern —')),
modal(x ? 'Regel bearbeiten' : 'Neue Eskalationsregel', h('div', {}, h('label', {}, 'Name'), f.name, h('label', { class: 'check' }, f.active, 'Aktiv'), nAdmin: h('input', { type: 'checkbox', checked: x?.actionNotifyAdmin ?? true }), nStaff: h('input', { type: 'checkbox', checked: !!x?.actionNotifyStaff }),
h('label', {}, 'Auslöser'), f.trig, h('label', {}, 'Nach Stunden'), f.hours, };
h('h3', {}, 'Bedingungen'), h('label', {}, 'Status'), f.cStatus, h('label', {}, 'Priorität'), f.cPrio, h('label', {}, 'Abteilung'), f.cDept, modal(x ? 'Regel bearbeiten' : 'Neue Eskalationsregel', h('div', {}, h('label', {}, 'Name'), f.name, h('label', { class: 'check' }, f.active, 'Aktiv'),
h('h3', {}, 'Aktionen'), h('label', {}, 'Priorität setzen'), f.aPrio, h('label', {}, 'Zuweisen an'), f.aStaff, h('label', {}, 'Status setzen'), f.aStatus, h('label', {}, 'Auslöser'), f.trig, h('label', {}, 'Nach Stunden'), f.hours,
h('label', { class: 'check' }, f.nAdmin, 'Admins benachrichtigen'), h('label', { class: 'check' }, f.nStaff, 'Zuständigen benachrichtigen')), h('h3', {}, 'Bedingungen'), h('label', {}, 'Status'), f.cStatus, h('label', {}, 'Priorität'), f.cPrio, h('label', {}, 'Abteilung'), f.cDept,
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post('escalation_rules.php', { action: 'save', id: x?.id ?? null, name: f.name.value, isActive: f.active.checked, triggerType: f.trig.value, triggerHours: +f.hours.value || 24, h('h3', {}, 'Aktionen'), h('label', {}, 'Priorität setzen'), f.aPrio, h('label', {}, 'Zuweisen an'), f.aStaff, h('label', {}, 'Status setzen'), f.aStatus,
conditionStatus: f.cStatus.value || null, conditionPriorityId: numOrNull(f.cPrio.value), conditionDeptId: numOrNull(f.cDept.value), actionSetPriorityId: numOrNull(f.aPrio.value), h('label', { class: 'check' }, f.nAdmin, 'Admins benachrichtigen'), h('label', { class: 'check' }, f.nStaff, 'Zuständigen benachrichtigen')),
actionAssignStaffId: numOrNull(f.aStaff.value), actionSetStatus: f.aStatus.value || null, actionNotifyAdmin: f.nAdmin.checked, actionNotifyStaff: f.nStaff.checked, sortOrder: x?.sortOrder ?? 0 }), 'Gespeichert')) { close(); load(); } } }]); [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('escalation_rules.php', { action: 'save', id: x?.id ?? null, name: f.name.value, isActive: f.active.checked, triggerType: f.trig.value, triggerHours: +f.hours.value || 24,
} conditionStatus: f.cStatus.value || null, conditionPriorityId: numOrNull(f.cPrio.value), conditionDeptId: numOrNull(f.cDept.value), actionSetPriorityId: numOrNull(f.aPrio.value),
load(); actionAssignStaffId: numOrNull(f.aStaff.value), actionSetStatus: f.aStatus.value || null, actionNotifyAdmin: f.nAdmin.checked, actionNotifyStaff: f.nStaff.checked, sortOrder: x?.sortOrder ?? 0 }), 'Gespeichert')) { close(); load(); } } }]);
} }
load();
// ─── Geschäftszeiten ───────────────────────────────────────────────────────── }
async function adminBusinessHours(body, addBtn) {
addBtn.classList.add('hidden'); // ─── Geschäftszeiten ─────────────────────────────────────────────────────────
const load = async () => { async function adminBusinessHours(body, addBtn) {
const r = await run(() => api('business_hours.php')); if (!r) return; addBtn.classList.add('hidden');
const enabled = h('input', { type: 'checkbox', checked: r.enabled }); const load = async () => {
const rows = r.hours.map((x) => ({ x, open: h('input', { type: 'checkbox', checked: x.isOpen }), from: h('input', { type: 'time', value: x.openTime }), to: h('input', { type: 'time', value: x.closeTime }) })); const r = await run(() => api('business_hours.php')); if (!r) return;
const hDate = h('input', { type: 'date' }), hName = h('input', { placeholder: 'Bezeichnung (z. B. Neujahr)' }); const enabled = h('input', { type: 'checkbox', checked: r.enabled });
clear(body).append(h('div', { class: 'panel' }, h('label', { class: 'check' }, enabled, 'SLA-Uhr nur innerhalb der Geschäftszeiten laufen lassen'), const rows = r.hours.map((x) => ({ x, open: h('input', { type: 'checkbox', checked: x.isOpen }), from: h('input', { type: 'time', value: x.openTime }), to: h('input', { type: 'time', value: x.closeTime }) }));
h('table', {}, ...rows.map(({ x, open, from, to }) => h('tr', {}, h('td', {}, WEEKDAYS[x.weekday]), h('td', {}, open), h('td', {}, from), h('td', {}, to)))), const hDate = h('input', { type: 'date' }), hName = h('input', { placeholder: 'Bezeichnung (z. B. Neujahr)' });
row(h('button', { class: 'btn', onclick: () => run(() => post('business_hours.php', { action: 'save_hours', enabled: enabled.checked, clear(body).append(h('div', { class: 'panel' }, h('label', { class: 'check' }, enabled, 'SLA-Uhr nur innerhalb der Geschäftszeiten laufen lassen'),
hours: rows.map(({ x, open, from, to }) => ({ weekday: x.weekday, isOpen: open.checked, openTime: from.value || '09:00', closeTime: to.value || '17:00' })) }), 'Gespeichert') }, 'Speichern'))), h('table', {}, ...rows.map(({ x, open, from, to }) => h('tr', {}, h('td', {}, WEEKDAYS[x.weekday]), h('td', {}, open), h('td', {}, from), h('td', {}, to)))),
h('h3', {}, 'Feiertage / Schließtage'), row(h('button', { class: 'btn', onclick: () => run(() => post('business_hours.php', { action: 'save_hours', enabled: enabled.checked,
h('div', { class: 'panel' }, row(hDate, hName, h('button', { class: 'btn', onclick: () => hDate.value && hName.value && run(async () => { await post('business_hours.php', { action: 'add_holiday', date: hDate.value, name: hName.value }); load(); }) }, 'Hinzufügen')), hours: rows.map(({ x, open, from, to }) => ({ weekday: x.weekday, isOpen: open.checked, openTime: from.value || '09:00', closeTime: to.value || '17:00' })) }), 'Gespeichert') }, 'Speichern'))),
...r.holidays.map((hd) => row(h('span', { class: 'grow' }, `${hd.date} – ${hd.name}`), delBtn(() => run(async () => { await post('business_hours.php', { action: 'delete_holiday', id: hd.id }); load(); })))))); h('h3', {}, 'Feiertage / Schließtage'),
}; h('div', { class: 'panel' }, row(hDate, hName, h('button', { class: 'btn', onclick: () => hDate.value && hName.value && run(async () => { await post('business_hours.php', { action: 'add_holiday', date: hDate.value, name: hName.value }); load(); }) }, 'Hinzufügen')),
load(); ...r.holidays.map((hd) => row(h('span', { class: 'grow' }, `${hd.date} – ${hd.name}`), delBtn(() => run(async () => { await post('business_hours.php', { action: 'delete_holiday', id: hd.id }); load(); }))))));
} };
load();
// ─── E-Mail-Vorlagen ───────────────────────────────────────────────────────── }
async function adminEmailTemplates(body, addBtn) {
addBtn.classList.add('hidden'); // ─── E-Mail-Vorlagen ─────────────────────────────────────────────────────────
const load = async () => { async function adminEmailTemplates(body, addBtn) {
const r = await run(() => api('email_templates.php')); if (!r) return; addBtn.classList.add('hidden');
clear(body).append(table(['Vorlage', 'Angepasst'], r.items.map((t) => h('tr', { class: 'click', onclick: () => edit(t) }, h('td', {}, t.label), h('td', {}, t.isCustomized ? '✓' : ''))))); const load = async () => {
}; const r = await run(() => api('email_templates.php')); if (!r) return;
function edit(t) { clear(body).append(table(['Vorlage', 'Angepasst'], r.items.map((t) => h('tr', { class: 'click', onclick: () => edit(t) }, h('td', {}, t.label), h('td', {}, t.isCustomized ? '✓' : '')))));
const subject = h('input', { value: t.subject }), text = h('textarea', { value: t.body, class: 'tall' }); };
modal(t.label, h('div', {}, h('label', {}, 'Betreff'), subject, h('label', {}, 'Text'), text, function edit(t) {
h('div', { class: 'muted' }, 'Platzhalter: ' + t.placeholders.join(' '))), const subject = h('input', { value: t.subject }), text = h('textarea', { value: t.body, class: 'tall' });
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post('email_templates.php', { action: 'save', key: t.key, subject: subject.value, body: text.value }), 'Gespeichert')) { close(); load(); } } }, modal(t.label, h('div', {}, h('label', {}, 'Betreff'), subject, h('label', {}, 'Text'), text,
...(t.isCustomized ? [{ label: 'Zurücksetzen', cls: 'ghost', fn: async (close) => { if (confirm('Auf Standard zurücksetzen?') && await run(() => post('email_templates.php', { action: 'reset', key: t.key }), 'Zurückgesetzt')) { close(); load(); } } }] : [])]); h('div', { class: 'muted' }, 'Platzhalter: ' + t.placeholders.join(' '))),
} [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('email_templates.php', { action: 'save', key: t.key, subject: subject.value, body: text.value }), 'Gespeichert')) { close(); load(); } } },
load(); ...(t.isCustomized ? [{ label: 'Zurücksetzen', cls: 'ghost', fn: async (close) => { if (confirm('Auf Standard zurücksetzen?') && await run(() => post('email_templates.php', { action: 'reset', key: t.key }), 'Zurückgesetzt')) { close(); load(); } } }] : [])]);
} }
load();
// ─── Ticket-Regeln ─────────────────────────────────────────────────────────── }
async function adminTicketRules(body, addBtn) {
const load = async () => { // ─── Ticket-Regeln ───────────────────────────────────────────────────────────
const r = await run(() => api('ticket_rules.php')); if (!r) return; async function adminTicketRules(body, addBtn) {
const label = (list, v) => (list.find((o) => o.value === v) || { label: v }).label; const load = async () => {
const acEnabled = h('input', { type: 'checkbox', checked: r.autoCloseEnabled }), acDays = h('input', { type: 'number', min: 1, value: r.autoCloseDays, class: 'narrow' }); const r = await run(() => api('ticket_rules.php')); if (!r) return;
clear(body).append( const label = (list, v) => (list.find((o) => o.value === v) || { label: v }).label;
h('div', { class: 'panel' }, h('b', {}, 'Automatisch schließen'), row(h('label', { class: 'check' }, acEnabled, 'Beantwortete Tickets nach'), acDays, h('span', {}, 'Tagen schließen'), const acEnabled = h('input', { type: 'checkbox', checked: r.autoCloseEnabled }), acDays = h('input', { type: 'number', min: 1, value: r.autoCloseDays, class: 'narrow' });
h('button', { class: 'btn sm', onclick: () => run(() => post('ticket_rules.php', { action: 'save_auto_close', enabled: acEnabled.checked, days: +acDays.value || 7 }), 'Gespeichert') }, 'Speichern'))), clear(body).append(
table(['Regel', 'Bedingungen', 'Aktionen', 'Aktiv', ''], r.rules.map((x) => h('tr', { class: 'click', onclick: () => edit(x, r) }, h('div', { class: 'panel' }, h('b', {}, 'Automatisch schließen'), row(h('label', { class: 'check' }, acEnabled, 'Beantwortete Tickets nach'), acDays, h('span', {}, 'Tagen schließen'),
h('td', {}, x.name), h('td', { class: 'muted' }, x.conditions.map((c) => `${label(r.fieldOptions, c.field)} ${label(r.operatorOptions, c.operator)} „${c.value}“`).join(x.matchType === 'any' ? ' ODER ' : ' UND ')), h('button', { class: 'btn sm', onclick: () => run(() => post('ticket_rules.php', { action: 'save_auto_close', enabled: acEnabled.checked, days: +acDays.value || 7 }), 'Gespeichert') }, 'Speichern'))),
h('td', { class: 'muted' }, x.actions.map((a) => label(r.actionOptions, a.type) + (a.valueLabel ? `: ${a.valueLabel}` : '')).join(', ')), table(['Regel', 'Bedingungen', 'Aktionen', 'Aktiv', ''], r.rules.map((x) => h('tr', { class: 'click', onclick: () => edit(x, r) },
h('td', {}, h('input', { type: 'checkbox', checked: x.isActive, onclick: (e) => e.stopPropagation(), onchange: () => run(async () => { await post('ticket_rules.php', { action: 'toggle', id: x.id }); load(); }) })), h('td', {}, x.name), h('td', { class: 'muted' }, x.conditions.map((c) => `${label(r.fieldOptions, c.field)} ${label(r.operatorOptions, c.operator)} „${c.value}“`).join(x.matchType === 'any' ? ' ODER ' : ' UND ')),
h('td', {}, delBtn(() => run(async () => { await post('ticket_rules.php', { action: 'delete', id: x.id }); load(); }, 'Gelöscht'))))))); h('td', { class: 'muted' }, x.actions.map((a) => label(r.actionOptions, a.type) + (a.valueLabel ? `: ${a.valueLabel}` : '')).join(', ')),
addBtn.onclick = () => edit(null, r); h('td', {}, h('input', { type: 'checkbox', checked: x.isActive, onclick: (e) => e.stopPropagation(), onchange: () => run(async () => { await post('ticket_rules.php', { action: 'toggle', id: x.id }); load(); }) })),
}; h('td', {}, delBtn(() => run(async () => { await post('ticket_rules.php', { action: 'delete', id: x.id }); load(); }, 'Gelöscht')))))));
function edit(x, r) { addBtn.onclick = () => edit(null, r);
const name = h('input', { value: x?.name || '' }), match = h('select', {}, ...opt([['all', 'Alle Bedingungen müssen zutreffen'], ['any', 'Mindestens eine Bedingung']], x?.matchType || 'all')); };
const active = h('input', { type: 'checkbox', checked: x?.isActive ?? true }), sort = h('input', { type: 'number', value: x?.sortOrder ?? 0 }); function edit(x, r) {
const conds = h('div'), acts = h('div'); const name = h('input', { value: x?.name || '' }), match = h('select', {}, ...opt([['all', 'Alle Bedingungen müssen zutreffen'], ['any', 'Mindestens eine Bedingung']], x?.matchType || 'all'));
const valueSource = { set_department: r.departments, set_priority: r.priorities, set_help_topic: r.helpTopics, assign_staff: r.staffOptions, auto_reply: r.cannedResponses }; const active = h('input', { type: 'checkbox', checked: x?.isActive ?? true }), sort = h('input', { type: 'number', value: x?.sortOrder ?? 0 });
const addCond = (c) => { const rowEl = h('div', { class: 'row rule' }, h('select', { 'data-f': 'field' }, ...opt(r.fieldOptions.map((o) => [o.value, o.label]), c?.field)), const conds = h('div'), acts = h('div');
h('select', { 'data-f': 'operator' }, ...opt(r.operatorOptions.map((o) => [o.value, o.label]), c?.operator)), h('input', { 'data-f': 'value', value: c?.value || '', placeholder: 'Wert' }), const valueSource = { set_department: r.departments, set_priority: r.priorities, set_help_topic: r.helpTopics, assign_staff: r.staffOptions, auto_reply: r.cannedResponses };
h('button', { class: 'btn ghost sm', onclick: () => rowEl.remove() }, '✕')); conds.append(rowEl); }; const addCond = (c) => { const rowEl = h('div', { class: 'row rule' }, h('select', { 'data-f': 'field' }, ...opt(r.fieldOptions.map((o) => [o.value, o.label]), c?.field)),
const addAct = (a) => { h('select', { 'data-f': 'operator' }, ...opt(r.operatorOptions.map((o) => [o.value, o.label]), c?.operator)), h('input', { 'data-f': 'value', value: c?.value || '', placeholder: 'Wert' }),
const rowEl = h('div', { class: 'row rule' }), valHolder = h('span', { class: 'grow' }); h('button', { class: 'btn ghost sm', onclick: () => rowEl.remove() }, '✕')); conds.append(rowEl); };
const type = h('select', { 'data-f': 'type', onchange: () => paint(type.value, '') }, ...opt(r.actionOptions.map((o) => [o.value, o.label]), a?.type)); const addAct = (a) => {
const paint = (t, v) => { clear(valHolder); if (t === 'reject') return; const src = valueSource[t]; const rowEl = h('div', { class: 'row rule' }), valHolder = h('span', { class: 'grow' });
valHolder.append(src ? h('select', { 'data-f': 'value' }, ...opt(named(src), v)) : h('input', { 'data-f': 'value', value: v || '', placeholder: 'Wert' })); }; const type = h('select', { 'data-f': 'type', onchange: () => paint(type.value, '') }, ...opt(r.actionOptions.map((o) => [o.value, o.label]), a?.type));
rowEl.append(type, valHolder, h('button', { class: 'btn ghost sm', onclick: () => rowEl.remove() }, '✕')); acts.append(rowEl); paint(type.value, a?.value); const paint = (t, v) => { clear(valHolder); if (t === 'reject') return; const src = valueSource[t];
}; valHolder.append(src ? h('select', { 'data-f': 'value' }, ...opt(named(src), v)) : h('input', { 'data-f': 'value', value: v || '', placeholder: 'Wert' })); };
(x?.conditions?.length ? x.conditions : [null]).forEach(addCond); (x?.actions?.length ? x.actions : [null]).forEach(addAct); rowEl.append(type, valHolder, h('button', { class: 'btn ghost sm', onclick: () => rowEl.remove() }, '✕')); acts.append(rowEl); paint(type.value, a?.value);
const collect = (box) => [...box.children].map((el) => Object.fromEntries([...el.querySelectorAll('[data-f]')].map((i) => [i.dataset.f, i.value]))); };
modal(x ? 'Regel bearbeiten' : 'Neue Ticket-Regel', h('div', {}, h('label', {}, 'Name'), name, h('label', {}, 'Verknüpfung'), match, h('label', { class: 'check' }, active, 'Aktiv'), h('label', {}, 'Reihenfolge'), sort, (x?.conditions?.length ? x.conditions : [null]).forEach(addCond); (x?.actions?.length ? x.actions : [null]).forEach(addAct);
h('h3', {}, 'Wenn …'), conds, h('button', { class: 'btn ghost sm', onclick: () => addCond(null) }, '+ Bedingung'), h('h3', {}, 'Dann …'), acts, h('button', { class: 'btn ghost sm', onclick: () => addAct(null) }, '+ Aktion')), const collect = (box) => [...box.children].map((el) => Object.fromEntries([...el.querySelectorAll('[data-f]')].map((i) => [i.dataset.f, i.value])));
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post('ticket_rules.php', { action: 'save', id: x?.id ?? null, name: name.value, matchType: match.value, isActive: active.checked, sortOrder: +sort.value || 0, modal(x ? 'Regel bearbeiten' : 'Neue Ticket-Regel', h('div', {}, h('label', {}, 'Name'), name, h('label', {}, 'Verknüpfung'), match, h('label', { class: 'check' }, active, 'Aktiv'), h('label', {}, 'Reihenfolge'), sort,
conditions: collect(conds).map((c) => ({ field: c.field, operator: c.operator, value: c.value || '' })), actions: collect(acts).map((a) => ({ type: a.type, value: a.value || '' })) }), 'Gespeichert')) { close(); load(); } } }]); h('h3', {}, 'Wenn …'), conds, h('button', { class: 'btn ghost sm', onclick: () => addCond(null) }, '+ Bedingung'), h('h3', {}, 'Dann …'), acts, h('button', { class: 'btn ghost sm', onclick: () => addAct(null) }, '+ Aktion')),
} [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('ticket_rules.php', { action: 'save', id: x?.id ?? null, name: name.value, matchType: match.value, isActive: active.checked, sortOrder: +sort.value || 0,
load(); conditions: collect(conds).map((c) => ({ field: c.field, operator: c.operator, value: c.value || '' })), actions: collect(acts).map((a) => ({ type: a.type, value: a.value || '' })) }), 'Gespeichert')) { close(); load(); } } }]);
} }
load();
// ─── Digitaler Assistent (Einstellungen, zusätzliche Antworten, Fragen-Log, Gleichbedeutende Wörter, Ausprobieren) ─── }
async function adminAssistant(body) {
const A = 'assistant.php'; // ─── Digitaler Assistent (Einstellungen, zusätzliche Antworten, Fragen-Log, Gleichbedeutende Wörter, Ausprobieren) ───
const tabs = [['settings', 'Einstellungen'], ['answers', 'Zusätzliche Antworten'], ['log', 'Fragen-Log'], ['synonyms', 'Gleichbedeutende Wörter'], ['test', 'Frage ausprobieren']]; async function adminAssistant(body) {
let tab = 'settings'; const A = 'assistant.php';
const logF = { result: '', period: '30', q: '', page: 1 }; const tabs = [['settings', 'Einstellungen'], ['answers', 'Zusätzliche Antworten'], ['log', 'Fragen-Log'], ['synonyms', 'Gleichbedeutende Wörter'], ['test', 'Frage ausprobieren']];
const bar = h('div', { class: 'tabs wrap' }), view = h('div'); let tab = 'settings';
body.append(bar, view); const logF = { result: '', period: '30', q: '', page: 1 };
const paintBar = () => clear(bar).append(...tabs.map(([k, l]) => h('button', { class: 'tab' + (tab === k ? ' active' : ''), onclick: () => { tab = k; paintBar(); paint(); } }, l))); const bar = h('div', { class: 'tabs wrap' }), view = h('div');
const paint = () => ({ settings: pSettings, answers: pAnswers, log: pLog, synonyms: pSynonyms, test: pTest })[tab](); body.append(bar, view);
const paintBar = () => clear(bar).append(...tabs.map(([k, l]) => h('button', { class: 'tab' + (tab === k ? ' active' : ''), onclick: () => { tab = k; paintBar(); paint(); } }, l)));
async function pSettings() { const paint = () => ({ settings: pSettings, answers: pAnswers, log: pLog, synonyms: pSynonyms, test: pTest })[tab]();
const o = await run(() => api(A, { query: { section: 'overview' } })); if (!o) return;
const s = o.settings, d = o.defaults; async function pSettings() {
const en = h('input', { type: 'checkbox', checked: s.enabled }), mode = h('select', {}, ...opt([['offline_only', 'Nur wenn der Live-Chat ausgeschaltet oder niemand erreichbar ist (Standard)'], ['always', 'Immer (zum Testen)']], s.mode)); const o = await run(() => api(A, { query: { section: 'overview' } })); if (!o) return;
const name = h('input', { value: s.name, maxlength: 60, placeholder: d.name }), greet = h('textarea', { rows: 3, maxlength: 500, placeholder: d.greeting }, s.greeting), none = h('textarea', { rows: 2, maxlength: 500, placeholder: d.noAnswer }, s.noAnswer); const s = o.settings, d = o.defaults;
const dept = h('select', {}, ...opt(named(o.departments), s.departmentId || '', '— Standardabteilung (bzw. Abteilung des gewählten Themas) —')); const en = h('input', { type: 'checkbox', checked: s.enabled }), mode = h('select', {}, ...opt([['offline_only', 'Nur wenn der Live-Chat ausgeschaltet oder niemand erreichbar ist (Standard)'], ['always', 'Immer (zum Testen)']], s.mode));
const prio = h('select', {}, ...opt(named(o.priorities), s.priorityId || '', '— Standard —')); const name = h('input', { value: s.name, maxlength: 60, placeholder: d.name }), greet = h('textarea', { rows: 3, maxlength: 500, placeholder: d.greeting }, s.greeting), none = h('textarea', { rows: 2, maxlength: 500, placeholder: d.noAnswer }, s.noAnswer);
const days = h('input', { type: 'number', min: 0, max: 3650, value: s.logDays, style: 'max-width:140px' }); const dept = h('select', {}, ...opt(named(o.departments), s.departmentId || '', '— Standardabteilung (bzw. Abteilung des gewählten Themas) —'));
const st = o.state; const prio = h('select', {}, ...opt(named(o.priorities), s.priorityId || '', '— Standard —'));
clear(view).append(h('div', { class: 'panel' }, const days = h('input', { type: 'number', min: 0, max: 3650, value: s.logDays, style: 'max-width:140px' });
!o.dbReady ? h('div', { class: 'warnbox' }, 'Die Datenbank ist noch nicht aktuell. Bitte im Adminportal unter System-Update „Datenbank aktualisieren“ klicken.') : null, const st = o.state;
h('p', { class: 'muted' }, 'Der Assistent beantwortet Fragen von Kunden aus der Wissensdatenbank und aus den zusätzlichen Antworten. Findet er nichts, bietet er ein Ticket an. Es wird kein externer KI-Dienst verwendet.'), clear(view).append(h('div', { class: 'panel' },
h('p', {}, 'Zustand jetzt: ', h('b', {}, !s.enabled ? 'ausgeschaltet' : st.activeNow ? 'aktiv (Kunden sehen den Assistenten)' : 'bereit, aber gerade nicht sichtbar'), !o.dbReady ? h('div', { class: 'warnbox' }, 'Die Datenbank ist noch nicht aktuell. Bitte im Adminportal unter System-Update „Datenbank aktualisieren“ klicken.') : null,
h('span', { class: 'muted' }, ` · Live-Chat ${st.liveChatEnabled ? 'an' : 'aus'} · Wissensdatenbank im Portal ${st.kbEnabled ? 'an' : 'aus'}`)), h('p', { class: 'muted' }, 'Der Assistent beantwortet Fragen von Kunden aus der Wissensdatenbank und aus den zusätzlichen Antworten. Findet er nichts, bietet er ein Ticket an. Es wird kein externer KI-Dienst verwendet.'),
h('label', { class: 'check' }, en, 'Digitalen Assistenten einschalten'), h('p', {}, 'Zustand jetzt: ', h('b', {}, !s.enabled ? 'ausgeschaltet' : st.activeNow ? 'aktiv (Kunden sehen den Assistenten)' : 'bereit, aber gerade nicht sichtbar'),
h('label', {}, 'Wann ist er aktiv?'), mode, h('label', {}, 'Name des Assistenten'), name, h('label', {}, 'Begrüßung'), greet, h('label', {}, 'Text, wenn er keine Antwort findet'), none, h('span', { class: 'muted' }, ` · Live-Chat ${st.liveChatEnabled ? 'an' : 'aus'} · Wissensdatenbank im Portal ${st.kbEnabled ? 'an' : 'aus'}`)),
h('label', {}, 'Abteilung für Tickets des Assistenten'), dept, h('label', {}, 'Priorität für Tickets des Assistenten'), prio, h('label', { class: 'check' }, en, 'Digitalen Assistenten einschalten'),
h('label', {}, 'Fragen-Log: Aufbewahrung in Tagen (0 = nichts speichern)'), days, h('label', {}, 'Wann ist er aktiv?'), mode, h('label', {}, 'Name des Assistenten'), name, h('label', {}, 'Begrüßung'), greet, h('label', {}, 'Text, wenn er keine Antwort findet'), none,
h('div', { class: 'row top' }, h('button', { class: 'btn', onclick: () => run(() => post(A, { action: 'save_settings', enabled: en.checked, mode: mode.value, name: name.value, greeting: greet.value, noAnswer: none.value, departmentId: numOrNull(dept.value) || 0, priorityId: numOrNull(prio.value) || 0, logDays: +days.value || 0 }), 'Gespeichert').then(pSettings) }, 'Speichern')))); h('label', {}, 'Abteilung für Tickets des Assistenten'), dept, h('label', {}, 'Priorität für Tickets des Assistenten'), prio,
} h('label', {}, 'Fragen-Log: Aufbewahrung in Tagen (0 = nichts speichern)'), days,
h('div', { class: 'row top' }, h('button', { class: 'btn', onclick: () => run(() => post(A, { action: 'save_settings', enabled: en.checked, mode: mode.value, name: name.value, greeting: greet.value, noAnswer: none.value, departmentId: numOrNull(dept.value) || 0, priorityId: numOrNull(prio.value) || 0, logDays: +days.value || 0 }), 'Gespeichert').then(pSettings) }, 'Speichern'))));
async function pAnswers() { }
const r = await run(() => api(A, { query: { section: 'answers' } })); if (!r) return;
const add = h('button', { class: 'btn', onclick: () => edit(null) }, '+ Antwort hinzufügen'); async function pAnswers() {
clear(view).append(h('div', { class: 'row' }, h('span', { class: 'grow muted' }, 'Diese Antworten haben Vorrang vor der Wissensdatenbank. Der Assistent findet sie über die Wörter in der Frage und in den Stichwörtern.'), add), const r = await run(() => api(A, { query: { section: 'answers' } })); if (!r) return;
table(['Frage / Thema', 'Stichwörter', 'Genutzt', 'Status', ''], r.items.map((a) => h('tr', { class: 'click', onclick: () => edit(a) }, h('td', {}, a.title, h('div', { class: 'muted' }, a.answer.slice(0, 90))), h('td', { class: 'muted' }, a.keywords), h('td', {}, a.hits + '×'), h('td', {}, a.isActive ? 'Aktiv' : 'Aus'), const add = h('button', { class: 'btn', onclick: () => edit(null) }, '+ Antwort hinzufügen');
h('td', {}, delBtn(() => run(async () => { await post(A, { action: 'delete_answer', id: a.id }); pAnswers(); }, 'Gelöscht'))))))); clear(view).append(h('div', { class: 'row' }, h('span', { class: 'grow muted' }, 'Diese Antworten haben Vorrang vor der Wissensdatenbank. Der Assistent findet sie über die Wörter in der Frage und in den Stichwörtern.'), add),
} table(['Frage / Thema', 'Stichwörter', 'Genutzt', 'Status', ''], r.items.map((a) => h('tr', { class: 'click', onclick: () => edit(a) }, h('td', {}, a.title, h('div', { class: 'muted' }, a.answer.slice(0, 90))), h('td', { class: 'muted' }, a.keywords), h('td', {}, a.hits + '×'), h('td', {}, a.isActive ? 'Aktiv' : 'Aus'),
function edit(a, prefill) { h('td', {}, delBtn(() => run(async () => { await post(A, { action: 'delete_answer', id: a.id }); pAnswers(); }, 'Gelöscht')))))));
const title = h('input', { value: a?.title ?? prefill ?? '', maxlength: 255, placeholder: 'z. B. Wie lange dauert der Versand?' }), kw = h('input', { value: a?.keywords ?? '', maxlength: 1000, placeholder: 'z. B. Lieferzeit, Paket, Lieferung' }); }
const ans = h('textarea', { rows: 6, maxlength: 4000, placeholder: 'Reiner Text. Adressen mit https:// werden anklickbar.' }, a?.answer ?? ''), act = h('input', { type: 'checkbox', checked: a ? a.isActive : true }); function edit(a, prefill) {
modal(a ? 'Antwort bearbeiten' : 'Neue Antwort', h('div', {}, h('label', {}, 'Frage / Thema *'), title, h('label', {}, 'Stichwörter (optional, durch Komma getrennt)'), kw, h('label', {}, 'Antwort *'), ans, h('label', { class: 'check' }, act, 'Aktiv')), const title = h('input', { value: a?.title ?? prefill ?? '', maxlength: 255, placeholder: 'z. B. Wie lange dauert der Versand?' }), kw = h('input', { value: a?.keywords ?? '', maxlength: 1000, placeholder: 'z. B. Lieferzeit, Paket, Lieferung' });
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post(A, { action: 'save_answer', id: a?.id ?? 0, title: title.value, keywords: kw.value, answer: ans.value, isActive: act.checked }), 'Gespeichert')) { close(); tab = 'answers'; paintBar(); pAnswers(); } } }]); const ans = h('textarea', { rows: 6, maxlength: 4000, placeholder: 'Reiner Text. Adressen mit https:// werden anklickbar.' }, a?.answer ?? ''), act = h('input', { type: 'checkbox', checked: a ? a.isActive : true });
} modal(a ? 'Antwort bearbeiten' : 'Neue Antwort', h('div', {}, h('label', {}, 'Frage / Thema *'), title, h('label', {}, 'Stichwörter (optional, durch Komma getrennt)'), kw, h('label', {}, 'Antwort *'), ans, h('label', { class: 'check' }, act, 'Aktiv')),
[{ label: 'Speichern', fn: async (close) => { if (await run(() => post(A, { action: 'save_answer', id: a?.id ?? 0, title: title.value, keywords: kw.value, answer: ans.value, isActive: act.checked }), 'Gespeichert')) { close(); tab = 'answers'; paintBar(); pAnswers(); } } }]);
async function pLog() { }
const r = await run(() => api(A, { query: { section: 'log', result: logF.result, period: logF.period, q: logF.q, page: logF.page } })); if (!r) return;
const reset = () => { logF.page = 1; pLog(); }; async function pLog() {
const tiles = h('div', { class: 'cards' }, ...Object.entries(r.filters).map(([k, label]) => h('div', { class: 'stat link' + (logF.result === k ? ' active' : ''), onclick: () => { logF.result = logF.result === k ? '' : k; reset(); } }, h('div', { class: 'n' }, r.stats[k] ?? 0), h('div', { class: 'muted' }, label)))); const r = await run(() => api(A, { query: { section: 'log', result: logF.result, period: logF.period, q: logF.q, page: logF.page } })); if (!r) return;
const sel = h('select', { onchange: (e) => { logF.result = e.target.value; reset(); } }, ...opt(Object.entries(r.filters), logF.result, 'Alle Ergebnisse')); const reset = () => { logF.page = 1; pLog(); };
const per = h('select', { onchange: (e) => { logF.period = e.target.value; reset(); } }, ...opt([['today', 'Heute'], ['7', 'Letzte 7 Tage'], ['30', 'Letzte 30 Tage'], ['all', 'Gesamter Zeitraum']], logF.period)); const tiles = h('div', { class: 'cards' }, ...Object.entries(r.filters).map(([k, label]) => h('div', { class: 'stat link' + (logF.result === k ? ' active' : ''), onclick: () => { logF.result = logF.result === k ? '' : k; reset(); } }, h('div', { class: 'n' }, r.stats[k] ?? 0), h('div', { class: 'muted' }, label))));
const q = h('input', { value: logF.q, placeholder: 'Suchen…', onkeydown: (e) => { if (e.key === 'Enter') { logF.q = e.target.value; reset(); } } }); const sel = h('select', { onchange: (e) => { logF.result = e.target.value; reset(); } }, ...opt(Object.entries(r.filters), logF.result, 'Alle Ergebnisse'));
const clearBtn = h('button', { class: 'btn ghost sm', onclick: () => confirm('Das gesamte Fragen-Log löschen?') && run(async () => { await post(A, { action: 'clear_log' }); reset(); }, 'Log geleert') }, 'Log leeren'); const per = h('select', { onchange: (e) => { logF.period = e.target.value; reset(); } }, ...opt([['today', 'Heute'], ['7', 'Letzte 7 Tage'], ['30', 'Letzte 30 Tage'], ['all', 'Gesamter Zeitraum']], logF.period));
clear(view).append(h('p', { class: 'muted' }, 'Zeigt, was Kunden den Assistenten gefragt haben und ob er eine Antwort fand. Gespeichert werden nur Frage und Ergebnis (kein Name, keine E-Mail-Adresse).'), tiles, const q = h('input', { value: logF.q, placeholder: 'Suchen…', onkeydown: (e) => { if (e.key === 'Enter') { logF.q = e.target.value; reset(); } } });
h('div', { class: 'row' }, sel, per, q, h('button', { class: 'btn secondary', onclick: () => { logF.q = q.value; reset(); } }, 'Filtern'), h('span', { class: 'grow' }), clearBtn), const clearBtn = h('button', { class: 'btn ghost sm', onclick: () => confirm('Das gesamte Fragen-Log löschen?') && run(async () => { await post(A, { action: 'clear_log' }); reset(); }, 'Log geleert') }, 'Log leeren');
r.top.length ? h('div', { class: 'panel' }, h('b', {}, 'Häufige Fragen ohne Antwort'), ...r.top.map((t) => h('div', { class: 'row' }, h('span', { class: 'grow' }, `${t.question} (${t.n}×)`), h('button', { class: 'btn ghost sm', onclick: () => { tab = 'answers'; paintBar(); edit(null, t.question); } }, 'Antwort dazu anlegen')))) : null, clear(view).append(h('p', { class: 'muted' }, 'Zeigt, was Kunden den Assistenten gefragt haben und ob er eine Antwort fand. Gespeichert werden nur Frage und Ergebnis (kein Name, keine E-Mail-Adresse).'), tiles,
table(['Zeit', 'Frage', 'Ergebnis', 'Antwort / Ticket', ''], r.items.map((x) => h('tr', {}, h('td', { class: 'muted' }, fmtDate(x.createdAt)), h('td', {}, x.question), h('td', {}, (r.filters[x.result] || x.result) + (x.helpful === null ? '' : x.helpful ? ' 👍' : ' 👎')), h('td', { class: 'muted' }, x.ticketNumber ? '#' + x.ticketNumber : (x.matchedTitle || '')), h('div', { class: 'row' }, sel, per, q, h('button', { class: 'btn secondary', onclick: () => { logF.q = q.value; reset(); } }, 'Filtern'), h('span', { class: 'grow' }), clearBtn),
h('td', {}, x.result === 'none' ? h('button', { class: 'btn ghost sm', onclick: () => { tab = 'answers'; paintBar(); edit(null, x.question); } }, 'Antwort anlegen') : null)))), r.top.length ? h('div', { class: 'panel' }, h('b', {}, 'Häufige Fragen ohne Antwort'), ...r.top.map((t) => h('div', { class: 'row' }, h('span', { class: 'grow' }, `${t.question} (${t.n}×)`), h('button', { class: 'btn ghost sm', onclick: () => { tab = 'answers'; paintBar(); edit(null, t.question); } }, 'Antwort dazu anlegen')))) : null,
h('div', { class: 'row pager' }, h('button', { class: 'btn ghost sm', disabled: r.page <= 1, onclick: () => { logF.page--; pLog(); } }, '‹'), h('span', { class: 'muted' }, `${r.total} Einträge · Seite ${r.page} von ${r.pages}`), h('button', { class: 'btn ghost sm', disabled: r.page >= r.pages, onclick: () => { logF.page++; pLog(); } }, '›'))); table(['Zeit', 'Frage', 'Ergebnis', 'Antwort / Ticket', ''], r.items.map((x) => h('tr', {}, h('td', { class: 'muted' }, fmtDate(x.createdAt)), h('td', {}, x.question), h('td', {}, (r.filters[x.result] || x.result) + (x.helpful === null ? '' : x.helpful ? ' 👍' : ' 👎')), h('td', { class: 'muted' }, x.ticketNumber ? '#' + x.ticketNumber : (x.matchedTitle || '')),
} h('td', {}, x.result === 'none' ? h('button', { class: 'btn ghost sm', onclick: () => { tab = 'answers'; paintBar(); edit(null, x.question); } }, 'Antwort anlegen') : null)))),
h('div', { class: 'row pager' }, h('button', { class: 'btn ghost sm', disabled: r.page <= 1, onclick: () => { logF.page--; pLog(); } }, '‹'), h('span', { class: 'muted' }, `${r.total} Einträge · Seite ${r.page} von ${r.pages}`), h('button', { class: 'btn ghost sm', disabled: r.page >= r.pages, onclick: () => { logF.page++; pLog(); } }, '›')));
async function pSynonyms() { }
const o = await run(() => api(A, { query: { section: 'overview' } })); if (!o) return;
const t = h('textarea', { rows: 8, maxlength: 5000, placeholder: 'Zugang, Einladung, beitreten\nGeld zurück, Erstattung, Rückzahlung' }, o.settings.synonyms); async function pSynonyms() {
clear(view).append(h('div', { class: 'panel' }, h('p', { class: 'muted' }, 'Wörter, die Kunden und Artikel unterschiedlich nennen, aber dasselbe meinen. Eine Gruppe je Zeile, durch Komma getrennt, zum Beispiel „Zugang, Einladung, beitreten“. Einige Gruppen sind eingebaut, deine ergänzen oder überschreiben sie.'), t, const o = await run(() => api(A, { query: { section: 'overview' } })); if (!o) return;
h('div', { class: 'row top' }, h('button', { class: 'btn', onclick: () => run(async () => { const r = await post(A, { action: 'save_synonyms', text: t.value }); toast(`Gespeichert (${r.groups} Gruppen)`); }) }, 'Speichern')))); const t = h('textarea', { rows: 8, maxlength: 5000, placeholder: 'Zugang, Einladung, beitreten\nGeld zurück, Erstattung, Rückzahlung' }, o.settings.synonyms);
} clear(view).append(h('div', { class: 'panel' }, h('p', { class: 'muted' }, 'Wörter, die Kunden und Artikel unterschiedlich nennen, aber dasselbe meinen. Eine Gruppe je Zeile, durch Komma getrennt, zum Beispiel „Zugang, Einladung, beitreten“. Einige Gruppen sind eingebaut, deine ergänzen oder überschreiben sie.'), t,
h('div', { class: 'row top' }, h('button', { class: 'btn', onclick: () => run(async () => { const r = await post(A, { action: 'save_synonyms', text: t.value }); toast(`Gespeichert (${r.groups} Gruppen)`); }) }, 'Speichern'))));
function pTest() { }
const q = h('input', { placeholder: 'z. B. Wie setze ich mein Passwort zurück?', maxlength: 300 }), out = h('div');
const go = () => run(async () => { function pTest() {
const r = await post(A, { action: 'test', question: q.value }); const q = h('input', { placeholder: 'z. B. Wie setze ich mein Passwort zurück?', maxlength: 300 }), out = h('div');
clear(out).append(r.found ? h('div', { class: 'panel' }, h('div', { class: 'muted' }, (r.result.source === 'custom' ? 'Zusätzliche Antwort' : 'Wissensdatenbank') + ': ' + r.result.title), h('p', { style: 'white-space:pre-wrap' }, r.result.text), ...r.result.others.map((x) => h('div', { class: 'muted' }, 'Weiterer Treffer: ' + x))) const go = () => run(async () => {
: h('div', { class: 'muted' }, 'Keine passende Antwort: Der Assistent würde anbieten, ein Ticket zu erstellen. Lege dafür eine zusätzliche Antwort an oder ergänze die Wissensdatenbank.')); const r = await post(A, { action: 'test', question: q.value });
}); clear(out).append(r.found ? h('div', { class: 'panel' }, h('div', { class: 'muted' }, (r.result.source === 'custom' ? 'Zusätzliche Antwort' : 'Wissensdatenbank') + ': ' + r.result.title), h('p', { style: 'white-space:pre-wrap' }, r.result.text), ...r.result.others.map((x) => h('div', { class: 'muted' }, 'Weiterer Treffer: ' + x)))
q.addEventListener('keydown', (e) => { if (e.key === 'Enter') go(); }); : h('div', { class: 'muted' }, 'Keine passende Antwort: Der Assistent würde anbieten, ein Ticket zu erstellen. Lege dafür eine zusätzliche Antwort an oder ergänze die Wissensdatenbank.'));
clear(view).append(h('div', { class: 'panel' }, h('p', { class: 'muted' }, 'Zeigt, was der Assistent auf eine Kundenfrage antworten würde (ohne Zähler und ohne Ticket).'), h('div', { class: 'row' }, q, h('button', { class: 'btn', onclick: go }, 'Testen')), out)); });
} q.addEventListener('keydown', (e) => { if (e.key === 'Enter') go(); });
clear(view).append(h('div', { class: 'panel' }, h('p', { class: 'muted' }, 'Zeigt, was der Assistent auf eine Kundenfrage antworten würde (ohne Zähler und ohne Ticket).'), h('div', { class: 'row' }, q, h('button', { class: 'btn', onclick: go }, 'Testen')), out));
paintBar(); paint(); }
}
paintBar(); paint();
ADMIN.push( }
{ key: 'assistant', label: 'Digitaler Assistent', perm: 'manage_assistant', custom: adminAssistant },
{ key: 'teams', label: 'Teams', perm: 'manage_teams', custom: adminTeams, add: true }, ADMIN.push(
{ key: 'roles', label: 'Rollen', perm: 'manage_roles', custom: adminRoles, add: true }, { key: 'assistant', label: 'Digitaler Assistent', perm: 'manage_assistant', custom: adminAssistant },
{ key: 'escalations', label: 'Eskalationsregeln', perm: 'manage_escalations', custom: adminEscalations, add: true }, { key: 'teams', label: 'Teams', perm: 'manage_teams', custom: adminTeams, add: true },
{ key: 'business_hours', label: 'Geschäftszeiten', perm: 'manage_business_hours', custom: adminBusinessHours }, { key: 'roles', label: 'Rollen', perm: 'manage_roles', custom: adminRoles, add: true },
{ key: 'email_templates', label: 'E-Mail-Vorlagen', perm: 'manage_email_templates', custom: adminEmailTemplates }, { key: 'escalations', label: 'Eskalationsregeln', perm: 'manage_escalations', custom: adminEscalations, add: true },
{ key: 'ticket_rules', label: 'Ticket-Regeln', admin: true, custom: adminTicketRules, add: true }, { key: 'business_hours', label: 'Geschäftszeiten', perm: 'manage_business_hours', custom: adminBusinessHours },
); { key: 'email_templates', label: 'E-Mail-Vorlagen', perm: 'manage_email_templates', custom: adminEmailTemplates },
{ key: 'ticket_rules', label: 'Ticket-Regeln', admin: true, custom: adminTicketRules, add: true },
);
+7 -7
View File
@@ -224,7 +224,7 @@ function renderShell() {
const top = h('header', { class: 'topbar' }, const top = h('header', { class: 'topbar' },
h('div', { class: 'brand' }, h('span', { class: 'logo' }, 'D'), 'DeskHub'), h('div', { class: 'brand' }, h('span', { class: 'logo' }, 'D'), 'DeskHub'),
can('create_ticket') ? h('button', { class: 'btn ok', onclick: () => go('newticket') }, 'Neues Ticket') : null, can('create_ticket') ? h('button', { class: 'btn ok', onclick: () => go('newticket') }, 'Neues Ticket') : null,
h('button', { class: 'btn ghost sm', title: tr('Ruft neue E-Mails aus den Postfächern ab'), onclick: (e) => fetchMailNow(e.currentTarget) }, tr('📥 E-Mails abrufen')), can('fetch_mail') ? h('button', { class: 'btn ghost sm', title: tr('Ruft neue E-Mails aus den Postfächern ab'), onclick: (e) => fetchMailNow(e.currentTarget) }, tr('📥 E-Mails abrufen')) : null,
h('button', { class: 'searchbtn', onclick: openPalette }, h('span', { class: 'nl' }, icon('search'), 'Ticket, Kunde oder Bereich suchen…'), h('kbd', {}, 'Strg K')), h('button', { class: 'searchbtn', onclick: openPalette }, h('span', { class: 'nl' }, icon('search'), 'Ticket, Kunde oder Bereich suchen…'), h('kbd', {}, 'Strg K')),
h('div', { class: 'spacer' }), h('div', { class: 'spacer' }),
window.I18N.switcher(), window.I18N.switcher(),
@@ -409,7 +409,7 @@ async function vTickets(main, preset) {
}; };
const saveView = () => { const saveView = () => {
const name = h('input', { placeholder: 'z. B. Meine überfälligen' }), shared = h('input', { type: 'checkbox' }); const name = h('input', { placeholder: 'z. B. Meine überfälligen' }), shared = h('input', { type: 'checkbox' });
modal('Ansicht speichern', h('div', {}, h('p', { class: 'muted' }, 'Speichert die aktuellen Filter (Reiter, Suche, Abteilung, Priorität).'), h('label', {}, 'Name'), name, h('label', { class: 'check' }, shared, 'Für alle Mitarbeiter sichtbar')), modal('Ansicht speichern', h('div', {}, h('p', { class: 'muted' }, 'Speichert die aktuellen Filter (Reiter, Suche, Abteilung, Priorität).'), h('label', {}, 'Name'), name, can('share_views') ? h('label', { class: 'check' }, shared, 'Für alle Mitarbeiter sichtbar') : null),
[{ label: 'Speichern', fn: async (close) => { [{ label: 'Speichern', fn: async (close) => {
const { page, ...filters } = filt(); const { page, ...filters } = filt();
if (await run(() => post('queues.php', { action: 'save', name: name.value, isShared: shared.checked, filters }), 'Ansicht gespeichert')) { close(); paintViews(); } if (await run(() => post('queues.php', { action: 'save', name: name.value, isShared: shared.checked, filters }), 'Ansicht gespeichert')) { close(); paintViews(); }
@@ -843,7 +843,7 @@ async function vReports(main) {
h('div', { class: 'checks wide' }, ...metrics), h('div', { class: 'checks wide' }, ...metrics),
h('div', { class: 'row top' }, h('button', { class: 'btn', onclick: () => run_() }, 'Bericht erstellen'), h('div', { class: 'row top' }, h('button', { class: 'btn', onclick: () => run_() }, 'Bericht erstellen'),
h('button', { class: 'btn ghost', onclick: () => { const name = h('input', { placeholder: 'z. B. Monatsbericht Support' }), shared = h('input', { type: 'checkbox' }); h('button', { class: 'btn ghost', onclick: () => { const name = h('input', { placeholder: 'z. B. Monatsbericht Support' }), shared = h('input', { type: 'checkbox' });
modal('Bericht speichern', h('div', {}, h('label', {}, 'Name'), name, h('label', { class: 'check' }, shared, 'Für alle Mitarbeiter sichtbar')), [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('report_builder.php', { action: 'save', name: name.value, isShared: shared.checked, config: { ...cfg } }), 'Bericht gespeichert')) { close(); run_(); } } }]); } }, 'Bericht speichern'))); modal('Bericht speichern', h('div', {}, h('label', {}, 'Name'), name, can('share_views') ? h('label', { class: 'check' }, shared, 'Für alle Mitarbeiter sichtbar') : null), [{ label: 'Speichern', fn: async (close) => { if (await run(() => post('report_builder.php', { action: 'save', name: name.value, isShared: shared.checked, config: { ...cfg } }), 'Bericht gespeichert')) { close(); run_(); } } }]); } }, 'Bericht speichern')));
}; };
// Kundenzufriedenheit (Bewertungen der letzten 30 Tage), nur wenn die Abfrage eingeschaltet ist oder es schon Antworten gibt // Kundenzufriedenheit (Bewertungen der letzten 30 Tage), nur wenn die Abfrage eingeschaltet ist oder es schon Antworten gibt
const csatBox = h('div'); const csatBox = h('div');
@@ -871,10 +871,10 @@ async function vAvailability(main) {
const note = h('input', { value: r.myNote, placeholder: 'Notiz (optional)' }); const note = h('input', { value: r.myNote, placeholder: 'Notiz (optional)' });
main.append(h('h2', {}, 'Verfügbarkeit'), h('div', { class: 'panel' }, h('label', {}, 'Mein Status'), sel, h('label', {}, 'Notiz'), note, main.append(h('h2', {}, 'Verfügbarkeit'), h('div', { class: 'panel' }, h('label', {}, 'Mein Status'), sel, h('label', {}, 'Notiz'), note,
h('div', { class: 'row' }, h('button', { class: 'btn', onclick: () => run(() => post('availability.php', { status: sel.value, note: note.value }), 'Gespeichert') }, 'Speichern'))), h('div', { class: 'row' }, h('button', { class: 'btn', onclick: () => run(() => post('availability.php', { status: sel.value, note: note.value }), 'Gespeichert') }, 'Speichern'))),
h('h3', {}, isAdmin() ? 'Team (als Administrator kannst du den Status ändern)' : 'Team'), h('h3', {}, can('manage_availability') ? 'Team (du kannst den Status ändern)' : 'Team'),
h('div', { class: 'panel' }, h('table', {}, ...r.team.map((m) => { h('div', { class: 'panel' }, h('table', {}, ...r.team.map((m) => {
const cells = [h('td', {}, m.name), h('td', {}, m.isOnVacation ? '🏖 Urlaub' : (labels[m.status] || m.status) + (m.autoOffline ? ' (automatisch, inaktiv)' : '')), h('td', { class: 'muted' }, m.note)]; const cells = [h('td', {}, m.name), h('td', {}, m.isOnVacation ? '🏖 Urlaub' : (labels[m.status] || m.status) + (m.autoOffline ? ' (automatisch, inaktiv)' : '')), h('td', { class: 'muted' }, m.note)];
if (isAdmin()) { if (can('manage_availability')) {
const ms = h('select', {}, ...Object.entries(labels).map(([v, l]) => h('option', { value: v, selected: v === m.status }, l))); const ms = h('select', {}, ...Object.entries(labels).map(([v, l]) => h('option', { value: v, selected: v === m.status }, l)));
const mn = h('input', { value: m.note || '', placeholder: 'Notiz', maxlength: '120' }); const mn = h('input', { value: m.note || '', placeholder: 'Notiz', maxlength: '120' });
cells.push(h('td', {}, ms), h('td', {}, mn), h('td', {}, h('button', { class: 'btn sm', onclick: async () => { const ok = await run(() => post('availability.php', { status: ms.value, note: mn.value, staffId: m.id }), 'Status von ' + m.name + ' geändert'); if (ok) go('availability'); } }, 'Setzen'))); cells.push(h('td', {}, ms), h('td', {}, mn), h('td', {}, h('button', { class: 'btn sm', onclick: async () => { const ok = await run(() => post('availability.php', { status: ms.value, note: mn.value, staffId: m.id }), 'Status von ' + m.name + ' geändert'); if (ok) go('availability'); } }, 'Setzen')));
@@ -913,7 +913,7 @@ const ADMIN = [
['_h2', 'Zugang', H], ['departmentId', 'Hauptabteilung', 'departments?'], ['extraDepartments', 'Erweiterter Zugriff', XD], ['_h2', 'Zugang', H], ['departmentId', 'Hauptabteilung', 'departments?'], ['extraDepartments', 'Erweiterter Zugriff', XD],
['_h3', 'Berechtigungen', H], ['role', 'Kontotyp', [['agent', 'Mitarbeiter'], ['admin', 'Administrator (alle Rechte)']]], ['roleId', 'Rolle (für Mitarbeiter)', 'roles?'], ['_h3', 'Berechtigungen', H], ['role', 'Kontotyp', [['agent', 'Mitarbeiter'], ['admin', 'Administrator (alle Rechte)']]], ['roleId', 'Rolle (für Mitarbeiter)', 'roles?'],
['_h4', 'Teams', H], ['teamIds', 'Mitglied in Teams', 'multi:teams']] }, ['_h4', 'Teams', H], ['teamIds', 'Mitglied in Teams', 'multi:teams']] },
{ key: 'banlist', label: 'Sperrliste', admin: true, file: 'banlist.php', cols: [['Typ', 'matchType'], ['Wert', 'value'], ['Grund', 'reason'], ['Von', 'addedByName']], saveAction: 'create', noEdit: true, { key: 'banlist', label: 'Sperrliste', perm: 'manage_banlist', file: 'banlist.php', cols: [['Typ', 'matchType'], ['Wert', 'value'], ['Grund', 'reason'], ['Von', 'addedByName']], saveAction: 'create', noEdit: true,
fields: [['matchType', 'Typ', [['email', 'E-Mail-Adresse'], ['domain', 'Domain']]], ['value', 'Wert', T], ['reason', 'Grund', T]] }, fields: [['matchType', 'Typ', [['email', 'E-Mail-Adresse'], ['domain', 'Domain']]], ['value', 'Wert', T], ['reason', 'Grund', T]] },
{ key: 'audit', label: 'Admin-Protokoll', perm: 'view_audit_log', file: 'audit_log.php', readonly: true, paged: true, cols: [['Zeit', (x) => fmtDate(x.createdAt)], ['Mitarbeiter', 'staffName'], ['Aktion', 'action']] }, { key: 'audit', label: 'Admin-Protokoll', perm: 'view_audit_log', file: 'audit_log.php', readonly: true, paged: true, cols: [['Zeit', (x) => fmtDate(x.createdAt)], ['Mitarbeiter', 'staffName'], ['Aktion', 'action']] },
{ key: 'time', label: 'Zeiterfassung', perm: 'view_time_entries', file: 'time_entries.php', readonly: true, list: 'entries', cols: [['Datum', (x) => fmtDate(x.loggedAt)], ['Mitarbeiter', 'staffName'], ['Ticket', 'ticketNumber'], ['Minuten', 'minutes'], ['Notiz', 'note']] }, { key: 'time', label: 'Zeiterfassung', perm: 'view_time_entries', file: 'time_entries.php', readonly: true, list: 'entries', cols: [['Datum', (x) => fmtDate(x.loggedAt)], ['Mitarbeiter', 'staffName'], ['Ticket', 'ticketNumber'], ['Minuten', 'minutes'], ['Notiz', 'note']] },
@@ -937,7 +937,7 @@ async function vAdmin(main, sectionKey) {
if (!sectionKey) { if (!sectionKey) {
// Bereiche zu Gruppen ordnen (gleiche Gruppen wie im Adminportal und in der Android-App) // Bereiche zu Gruppen ordnen (gleiche Gruppen wie im Adminportal und in der Android-App)
const entries = new Map(sections.map((s) => [s.key, { label: s.label, open: () => go('admin', s.key) }])); const entries = new Map(sections.map((s) => [s.key, { label: s.label, open: () => go('admin', s.key) }]));
if (isAdmin()) entries.set('status', { label: 'Status der Mitarbeiter', open: () => go('availability') }); if (can('manage_availability')) entries.set('status', { label: 'Status der Mitarbeiter', open: () => go('availability') });
const used = new Set(); const used = new Set();
const groupsView = ADMIN_GROUPS.map(([title, keys]) => { const groupsView = ADMIN_GROUPS.map(([title, keys]) => {
const tiles = keys.filter((k) => entries.has(k)).map((k) => { used.add(k); const e = entries.get(k); const tiles = keys.filter((k) => entries.has(k)).map((k) => { used.add(k); const e = entries.get(k);
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -4,7 +4,7 @@
<body><div id="app"></div><div id="toast" class="toast hidden"></div> <body><div id="app"></div><div id="toast" class="toast hidden"></div>
<script> <script>
// Test-Attrappe für die Electron-Brücke (window.deskhub) – nur für lokale UI-Tests ohne Server // Test-Attrappe für die Electron-Brücke (window.deskhub) – nur für lokale UI-Tests ohne Server
const staff = { id: 1, name: 'Max Muster', email: 'max@example.de', role: 'agent', permissions: { view_reports: true, reply_ticket: true, close_ticket: true, post_note: true, assign_ticket: true, create_ticket: true, manage_teams: true, manage_roles: true, manage_business_hours: true } }; const staff = { id: 1, name: 'Max Muster', email: 'max@example.de', role: 'agent', permissions: { view_reports: true, reply_ticket: true, close_ticket: true, post_note: true, assign_ticket: true, create_ticket: true, manage_teams: true, manage_roles: true, manage_business_hours: true, fetch_mail: true, share_views: true, manage_banlist: true } };
const prio = [{ id: 1, name: 'Hoch', color: '#ef4444' }, { id: 2, name: 'Normal', color: '#3b82f6' }]; const prio = [{ id: 1, name: 'Hoch', color: '#ef4444' }, { id: 2, name: 'Normal', color: '#3b82f6' }];
const statuses = [{ value: 'open', label: 'Offen', color: '#3b82f6' }, { value: 'answered', label: 'Beantwortet', color: '#22c55e' }, { value: 'closed', label: 'Geschlossen', color: '#64748b' }, { value: 'resolved', label: 'Gelöst', color: '#16a34a' }]; const statuses = [{ value: 'open', label: 'Offen', color: '#3b82f6' }, { value: 'answered', label: 'Beantwortet', color: '#22c55e' }, { value: 'closed', label: 'Geschlossen', color: '#64748b' }, { value: 'resolved', label: 'Gelöst', color: '#16a34a' }];
const tk = (n, s, st, over) => ({ id: n, number: 'T-' + (1000 + n), subject: s, requesterName: 'Kunde ' + n, requesterEmail: `k${n}@mail.de`, status: st, priority: prio[n % 2], department: { id: 1, name: 'Technik' }, assignedStaff: n % 3 ? { id: 1, name: 'Max Muster' } : null, isOverdue: !!over, dueLabel: over ? 'vor 2 Std (überfällig)' : 'in 5 Std', isSpam: false, createdAt: '2026-10-12 08:00:00', updatedAt: '2026-10-12 09:1' + n + ':00' }); const tk = (n, s, st, over) => ({ id: n, number: 'T-' + (1000 + n), subject: s, requesterName: 'Kunde ' + n, requesterEmail: `k${n}@mail.de`, status: st, priority: prio[n % 2], department: { id: 1, name: 'Technik' }, assignedStaff: n % 3 ? { id: 1, name: 'Max Muster' } : null, isOverdue: !!over, dueLabel: over ? 'vor 2 Std (überfällig)' : 'in 5 Std', isSpam: false, createdAt: '2026-10-12 08:00:00', updatedAt: '2026-10-12 09:1' + n + ':00' });
@@ -57,7 +57,7 @@ const routes = {
'canned_responses.php': () => ({ items: [{ id: 1, title: 'Gruß', body: 'Hallo,<br>danke für Ihre Nachricht.', departmentId: null }, { id: 2, title: 'Nur Technik', body: 'Technik-Text', departmentId: 1 }, { id: 3, title: 'Nur Vertrieb', body: 'Vertrieb-Text', departmentId: 2 }] }), 'canned_responses.php': () => ({ items: [{ id: 1, title: 'Gruß', body: 'Hallo,<br>danke für Ihre Nachricht.', departmentId: null }, { id: 2, title: 'Nur Technik', body: 'Technik-Text', departmentId: 1 }, { id: 3, title: 'Nur Vertrieb', body: 'Vertrieb-Text', departmentId: 2 }] }),
'customer.php': () => ({ customer: { name: 'Kunde 1', email: 'k1@mail.de' }, tickets }), 'customer.php': () => ({ customer: { name: 'Kunde 1', email: 'k1@mail.de' }, tickets }),
'teams.php': () => ({ staffOptions: [{ id: 1, name: 'Max Muster' }, { id: 2, name: 'Eva Beispiel' }], items: [{ id: 1, name: 'Support', leadId: 1, leadName: 'Max Muster', notes: '', isActive: true, memberCount: 2, memberIds: [1, 2] }] }), 'teams.php': () => ({ staffOptions: [{ id: 1, name: 'Max Muster' }, { id: 2, name: 'Eva Beispiel' }], items: [{ id: 1, name: 'Support', leadId: 1, leadName: 'Max Muster', notes: '', isActive: true, memberCount: 2, memberIds: [1, 2] }] }),
'roles.php': () => ({ permissionKeys: ['reply_ticket', 'close_ticket', 'manage_teams'], defaultAgentPermissions: { reply_ticket: true }, items: [{ id: 1, name: 'Teamleitung', permissions: { reply_ticket: true }, staffCount: 2 }] }), 'roles.php': () => ({ permissionKeys: ['reply_ticket', 'close_ticket', 'manage_teams', 'merge_split_ticket'], permissionLabels: { reply_ticket: 'Tickets beantworten', close_ticket: 'Tickets schließen/lösen', manage_teams: 'Teams verwalten', merge_split_ticket: 'Tickets zusammenführen und teilen' }, permissionGroups: [{ title: 'Tickets bearbeiten', keys: ['reply_ticket', 'close_ticket', 'merge_split_ticket'] }, { title: 'Team und Sicherheit', keys: ['manage_teams'] }], defaultAgentPermissions: { reply_ticket: true, merge_split_ticket: true }, items: [{ id: 1, name: 'Teamleitung', permissions: { reply_ticket: true }, effectivePermissions: { reply_ticket: true, close_ticket: false, manage_teams: false, merge_split_ticket: true }, staffCount: 2 }] }),
'business_hours.php': () => ({ enabled: true, hours: [1, 2, 3, 4, 5, 6, 0].map((w) => ({ weekday: w, isOpen: w > 0 && w < 6, openTime: '09:00', closeTime: '17:00' })), holidays: [{ id: 1, date: '2026-12-25', name: 'Weihnachten' }] }), 'business_hours.php': () => ({ enabled: true, hours: [1, 2, 3, 4, 5, 6, 0].map((w) => ({ weekday: w, isOpen: w > 0 && w < 6, openTime: '09:00', closeTime: '17:00' })), holidays: [{ id: 1, date: '2026-12-25', name: 'Weihnachten' }] }),
}; };
window.__calls = []; window.__calls = [];
+15
View File
@@ -55,6 +55,21 @@ app.whenReady().then(async () => {
await run(`[...document.querySelectorAll('.topbar button')].find(b => b.textContent.includes('E-Mails abrufen')).click()`); await run(`[...document.querySelectorAll('.topbar button')].find(b => b.textContent.includes('E-Mails abrufen')).click()`);
check('Abruf von Hand sendet die Anfrage und zeigt das Ergebnis', await waitFor(`(window.__mailFetchPosts || []).length === 1 && document.body.innerText.includes('Abruf fertig: 2 E-Mail(s) verarbeitet.')`)); check('Abruf von Hand sendet die Anfrage und zeigt das Ergebnis', await waitFor(`(window.__mailFetchPosts || []).length === 1 && document.body.innerText.includes('Abruf fertig: 2 E-Mail(s) verarbeitet.')`));
check('Knopf ist nach dem Abruf wieder bedienbar', await waitFor(`(() => { const b = [...document.querySelectorAll('.topbar button')].find(b => b.textContent.includes('E-Mails abrufen')); return !!b && !b.disabled; })()`)); check('Knopf ist nach dem Abruf wieder bedienbar', await waitFor(`(() => { const b = [...document.querySelectorAll('.topbar button')].find(b => b.textContent.includes('E-Mails abrufen')); return !!b && !b.disabled; })()`));
// Neue Rechte (Server 1.0.85): Knöpfe und Bereiche erscheinen nur mit dem Recht
const withPerm = async (perm, on, fn) => { await run(`state.staff.permissions['${perm}'] = ${on}; renderShell(); go('tickets')`); await wait(400); return fn(); };
check('Ohne das Recht „E-Mails jetzt abrufen“ fehlt der Knopf', await withPerm('fetch_mail', false, () => run(`![...document.querySelectorAll('.topbar button')].find(b => b.textContent.includes('E-Mails abrufen'))`)));
check('Mit dem Recht ist der Knopf wieder da', await withPerm('fetch_mail', true, () => run(`!![...document.querySelectorAll('.topbar button')].find(b => b.textContent.includes('E-Mails abrufen'))`)));
await run(`state.staff.permissions.manage_banlist = false; state.staff.permissions.manage_teams = true; go('admin')`);
check('Sperrliste ist ohne Recht nicht in der Verwaltung', await waitFor(`document.getElementById('main').innerText.includes('Teams') && !document.getElementById('main').innerText.includes('Sperrliste')`));
await run(`state.staff.permissions.manage_banlist = true; go('admin')`);
check('Sperrliste erscheint mit dem Recht „Sperrliste“ (ohne Administrator zu sein)', await waitFor(`document.getElementById('main').innerText.includes('Sperrliste')`));
// Rollen-Editor: Gruppen und Beschriftungen vom Server, wirksame Rechte (Standardwerte) angekreuzt
await run(`go('admin', 'roles')`);
check('Rollen: Tabelle zeigt die Rolle', await waitFor(`document.getElementById('main').innerText.includes('Teamleitung')`));
await run(`[...document.querySelectorAll('#main tr.click')][0].click()`);
check('Rollen-Editor zeigt Gruppen und neue Rechte mit Beschriftung vom Server', await waitFor(`(() => { const t = document.body.innerText.toLowerCase(); return t.includes('tickets bearbeiten') && t.includes('team und sicherheit') && t.includes('tickets zusammenführen und teilen'); })()`));
check('Rechte, die für die Rolle als Standard gelten, sind angekreuzt (nicht „aus“)', await run(`(() => { const l = [...document.querySelectorAll('.modal label.check, .modal-box label.check, label.check')].find(x => x.textContent.includes('zusammenführen und teilen')); return !!l && l.querySelector('input').checked; })()`));
await run(`document.querySelector('.modal button.ghost, .modal .btn.ghost, .modal-box .btn.ghost')?.click()`);
await run(`window.__source = 'email'; go('ticket', 1)`); await run(`window.__source = 'email'; go('ticket', 1)`);
check('E-Mail-Ticket: Knopf „Anhänge laden“ ist da', await waitFor(`!![...document.querySelectorAll('#main button')].find(b => b.textContent.includes('Anhänge laden'))`)); check('E-Mail-Ticket: Knopf „Anhänge laden“ ist da', await waitFor(`!![...document.querySelectorAll('#main button')].find(b => b.textContent.includes('Anhänge laden'))`));
await run(`[...document.querySelectorAll('#main button')].find(b => b.textContent.includes('Anhänge laden')).click()`); await run(`[...document.querySelectorAll('#main button')].find(b => b.textContent.includes('Anhänge laden')).click()`);