495 lines
18 KiB
HTML
495 lines
18 KiB
HTML
|
|
<!DOCTYPE html>
|
||
|
|
<html lang="sv">
|
||
|
|
<head>
|
||
|
|
<meta charset="UTF-8">
|
||
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
|
<title>BOC Dashboard — Business Operations Center</title>
|
||
|
|
<link rel="stylesheet" href="assets/boc.css">
|
||
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.1/dist/chart.umd.min.js"></script>
|
||
|
|
</head>
|
||
|
|
<body>
|
||
|
|
<div class="app">
|
||
|
|
<!-- Sidebar -->
|
||
|
|
<aside class="sidebar">
|
||
|
|
<div class="sidebar-logo">🏢 <span>BOC</span></div>
|
||
|
|
<nav class="sidebar-nav">
|
||
|
|
<a href="dashboard.html" class="active"><span class="icon">📊</span> <span>Dashboard</span></a>
|
||
|
|
<a href="crm.html"><span class="icon">👥</span> <span>CRM</span></a>
|
||
|
|
<a href="sales.html"><span class="icon">💰</span> <span>Sales</span></a>
|
||
|
|
<a href="finance.html"><span class="icon">📈</span> <span>Finance</span></a>
|
||
|
|
<a href="hr.html"><span class="icon">👔</span> <span>HR</span></a>
|
||
|
|
<a href="legal.html"><span class="icon">⚖️</span> <span>Legal</span></a>
|
||
|
|
<a href="marketing.html"><span class="icon">📢</span> <span>Marketing</span></a>
|
||
|
|
<a href="support.html"><span class="icon">🎫</span> <span>Support</span></a>
|
||
|
|
<a href="automation.html"><span class="icon">⚡</span> <span>Automation</span></a>
|
||
|
|
</nav>
|
||
|
|
<div class="sidebar-footer">
|
||
|
|
<span id="user-email">erik@landvex.com</span>
|
||
|
|
<button onclick="logout()">Logga ut</button>
|
||
|
|
</div>
|
||
|
|
</aside>
|
||
|
|
|
||
|
|
<main class="main">
|
||
|
|
<!-- Header -->
|
||
|
|
<header class="module-header">
|
||
|
|
<h1>Dashboard</h1>
|
||
|
|
<p class="subtitle">Överblick över hela verksamheten · <span id="last-updated">Uppdateras live</span></p>
|
||
|
|
</header>
|
||
|
|
|
||
|
|
<!-- Critical Alerts -->
|
||
|
|
<div id="alerts-container" style="display:none; margin-bottom: var(--space-lg);">
|
||
|
|
<div class="alert alert-critical">
|
||
|
|
<strong>⚠️ Kritisk:</strong> Momsdeklaration 442,000 kr — deadline 2026-07-26 (14 dagar kvar)
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- KPI Grid — 6 key metrics, one row -->
|
||
|
|
<div class="kpi-grid">
|
||
|
|
<div class="kpi-card" onclick="navigateTo('sales')">
|
||
|
|
<div class="kpi-icon">💰</div>
|
||
|
|
<div>
|
||
|
|
<div class="kpi-value" id="kpi-mrr">—</div>
|
||
|
|
<div class="kpi-label">MRR</div>
|
||
|
|
<div class="kpi-trend up" id="kpi-mrr-trend">+5%</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="kpi-card" onclick="navigateTo('sales')">
|
||
|
|
<div class="kpi-icon">📈</div>
|
||
|
|
<div>
|
||
|
|
<div class="kpi-value" id="kpi-arr">—</div>
|
||
|
|
<div class="kpi-label">ARR</div>
|
||
|
|
<div class="kpi-trend up" id="kpi-arr-trend">+12%</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="kpi-card" onclick="navigateTo('crm')">
|
||
|
|
<div class="kpi-icon">👥</div>
|
||
|
|
<div>
|
||
|
|
<div class="kpi-value" id="kpi-customers">—</div>
|
||
|
|
<div class="kpi-label">Kunder</div>
|
||
|
|
<div class="kpi-trend up" id="kpi-customers-trend">+3 nya</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="kpi-card" onclick="navigateTo('support')">
|
||
|
|
<div class="kpi-icon">🎫</div>
|
||
|
|
<div>
|
||
|
|
<div class="kpi-value" id="kpi-tickets">—</div>
|
||
|
|
<div class="kpi-label">Öppna ärenden</div>
|
||
|
|
<div class="kpi-trend down" id="kpi-tickets-trend">-2 idag</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="kpi-card" onclick="navigateTo('finance')">
|
||
|
|
<div class="kpi-icon">💵</div>
|
||
|
|
<div>
|
||
|
|
<div class="kpi-value" id="kpi-cash">—</div>
|
||
|
|
<div class="kpi-label">Kassa</div>
|
||
|
|
<div class="kpi-trend" id="kpi-cash-trend">4 månader runway</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
<div class="kpi-card" onclick="navigateTo('sales')">
|
||
|
|
<div class="kpi-icon">📊</div>
|
||
|
|
<div>
|
||
|
|
<div class="kpi-value" id="kpi-pipeline">—</div>
|
||
|
|
<div class="kpi-label">Pipeline</div>
|
||
|
|
<div class="kpi-trend up" id="kpi-pipeline-trend">+15%</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Two Column Layout -->
|
||
|
|
<div class="dashboard-grid">
|
||
|
|
<!-- Left: Charts -->
|
||
|
|
<div>
|
||
|
|
<div class="panel">
|
||
|
|
<div class="toolbar">
|
||
|
|
<h3>📈 Intäktstrend</h3>
|
||
|
|
<select id="revenue-period" onchange="updateRevenueChart()">
|
||
|
|
<option value="6m">6 månader</option>
|
||
|
|
<option value="1y">1 år</option>
|
||
|
|
<option value="ytd">År till datum</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<canvas id="revenue-chart" height="200"></canvas>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div class="panel">
|
||
|
|
<div class="toolbar">
|
||
|
|
<h3>🎯 Pipeline</h3>
|
||
|
|
<a href="sales.html" class="btn-link">Se alla deals →</a>
|
||
|
|
</div>
|
||
|
|
<canvas id="pipeline-chart" height="200"></canvas>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Right: Activity & Quick Actions -->
|
||
|
|
<div>
|
||
|
|
<!-- Quick Actions — one click, no dropdowns -->
|
||
|
|
<div class="panel">
|
||
|
|
<h3>⚡ Snabbåtgärder</h3>
|
||
|
|
<div class="quick-actions">
|
||
|
|
<button class="btn-action" onclick="createCustomer()">+ Kund</button>
|
||
|
|
<button class="btn-action" onclick="createDeal()">+ Deal</button>
|
||
|
|
<button class="btn-action" onclick="createInvoice()">+ Faktura</button>
|
||
|
|
<button class="btn-action" onclick="createTicket()">+ Ärende</button>
|
||
|
|
<button class="btn-action" onclick="createExpense()">+ Utgift</button>
|
||
|
|
<button class="btn-action" onclick="createContract()">+ Kontrakt</button>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Recent Activity -->
|
||
|
|
<div class="panel">
|
||
|
|
<div class="toolbar">
|
||
|
|
<h3>🔔 Senaste aktivitet</h3>
|
||
|
|
<span class="badge active" id="live-indicator">● Live</span>
|
||
|
|
</div>
|
||
|
|
<div id="activity-feed">
|
||
|
|
<div class="loading">Laddar aktivitet...</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Automation Status -->
|
||
|
|
<div class="panel">
|
||
|
|
<div class="toolbar">
|
||
|
|
<h3>🤖 Automation</h3>
|
||
|
|
<a href="automation.html" class="btn-link">Hantera →</a>
|
||
|
|
</div>
|
||
|
|
<div class="automation-grid" id="automation-status">
|
||
|
|
<div class="automation-item">
|
||
|
|
<span class="automation-indicator active"></span>
|
||
|
|
<span class="automation-name">Kontraktsförnyelser</span>
|
||
|
|
<span class="automation-schedule">Dagligen 09:00</span>
|
||
|
|
</div>
|
||
|
|
<div class="automation-item">
|
||
|
|
<span class="automation-indicator active"></span>
|
||
|
|
<span class="automation-name">Fakturapåminnelser</span>
|
||
|
|
<span class="automation-schedule">Måndagar</span>
|
||
|
|
</div>
|
||
|
|
<div class="automation-item">
|
||
|
|
<span class="automation-indicator warning"></span>
|
||
|
|
<span class="automation-name">Momsrapport</span>
|
||
|
|
<span class="automation-schedule">Manuell — deadline 2026-07-26</span>
|
||
|
|
</div>
|
||
|
|
<div class="automation-item">
|
||
|
|
<span class="automation-indicator active"></span>
|
||
|
|
<span class="automation-name">Backup</span>
|
||
|
|
<span class="automation-schedule">Dagligen 02:00</span>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
</main>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<!-- Modal for quick create -->
|
||
|
|
<div id="modal" class="modal" style="display:none;" onclick="if(event.target===this)hideModal()">
|
||
|
|
<div class="modal-content">
|
||
|
|
<div class="modal-header">
|
||
|
|
<h3 id="modal-title">Skapa</h3>
|
||
|
|
<button class="modal-close" onclick="hideModal()">×</button>
|
||
|
|
</div>
|
||
|
|
<div id="modal-body" class="modal-body"></div>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<script src="assets/boc.js"></script>
|
||
|
|
<script>
|
||
|
|
// Navigation
|
||
|
|
function navigateTo(module) {
|
||
|
|
window.location.href = module + '.html';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Quick create functions
|
||
|
|
function createCustomer() {
|
||
|
|
showModal('new-customer', `
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Företag / Namn</label>
|
||
|
|
<input type="text" id="cust-name" placeholder="Acme AB" autofocus>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>E-post</label>
|
||
|
|
<input type="email" id="cust-email" placeholder="kontakt@acme.se">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Telefon</label>
|
||
|
|
<input type="tel" id="cust-phone" placeholder="+46 70 123 45 67">
|
||
|
|
</div>
|
||
|
|
<button class="btn-primary" onclick="submitCustomer()" style="width:100%">Skapa kund</button>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
function createDeal() {
|
||
|
|
showModal('new-deal', `
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Deal-namn</label>
|
||
|
|
<input type="text" id="deal-name" placeholder="Q3 Enterprise" autofocus>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Värde (USD)</label>
|
||
|
|
<input type="number" id="deal-value" placeholder="50000">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Steg</label>
|
||
|
|
<select id="deal-stage">
|
||
|
|
<option value="prospect">Prospect</option>
|
||
|
|
<option value="qualified">Qualified</option>
|
||
|
|
<option value="proposal">Proposal</option>
|
||
|
|
<option value="negotiation">Negotiation</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<button class="btn-primary" onclick="submitDeal()" style="width:100%">Skapa deal</button>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
function createInvoice() {
|
||
|
|
showModal('new-invoice', `
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Kund</label>
|
||
|
|
<select id="inv-customer"><option>Laddar...</option></select>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Belopp (USD)</label>
|
||
|
|
<input type="number" id="inv-amount" placeholder="10000">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Förfallodatum</label>
|
||
|
|
<input type="date" id="inv-due">
|
||
|
|
</div>
|
||
|
|
<button class="btn-primary" onclick="submitInvoice()" style="width:100%">Skapa faktura</button>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
function createTicket() {
|
||
|
|
showModal('new-ticket', `
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Ämne</label>
|
||
|
|
<input type="text" id="ticket-subject" placeholder="Problem med inloggning" autofocus>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Beskrivning</label>
|
||
|
|
<textarea id="ticket-desc" rows="3" placeholder="Beskriv problemet..."></textarea>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Prioritet</label>
|
||
|
|
<select id="ticket-priority">
|
||
|
|
<option value="low">Låg</option>
|
||
|
|
<option value="medium" selected>Medium</option>
|
||
|
|
<option value="high">Hög</option>
|
||
|
|
<option value="critical">Kritisk</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<button class="btn-primary" onclick="submitTicket()" style="width:100%">Skapa ärende</button>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
function createExpense() {
|
||
|
|
showModal('new-expense', `
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Kategori</label>
|
||
|
|
<select id="exp-cat">
|
||
|
|
<option>Boende</option>
|
||
|
|
<option>Mat</option>
|
||
|
|
<option>Resa</option>
|
||
|
|
<option>Transport</option>
|
||
|
|
<option>Tech</option>
|
||
|
|
<option>Juridik</option>
|
||
|
|
<option>Kommunikation</option>
|
||
|
|
<option>Övrigt</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Belopp</label>
|
||
|
|
<input type="number" id="exp-amount" placeholder="0">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Beskrivning</label>
|
||
|
|
<input type="text" id="exp-desc" placeholder="Vad gäller utgiften?">
|
||
|
|
</div>
|
||
|
|
<button class="btn-primary" onclick="submitExpense()" style="width:100%">Registrera utgift</button>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
function createContract() {
|
||
|
|
showModal('new-contract', `
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Titel</label>
|
||
|
|
<input type="text" id="contract-title" placeholder="Tjänsteavtal 2026" autofocus>
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Motpart</label>
|
||
|
|
<input type="text" id="contract-party" placeholder="Företagsnamn">
|
||
|
|
</div>
|
||
|
|
<div class="form-group">
|
||
|
|
<label>Typ</label>
|
||
|
|
<select id="contract-type">
|
||
|
|
<option value="service">Tjänsteavtal</option>
|
||
|
|
<option value="employment">Anställning</option>
|
||
|
|
<option value="nda">NDA</option>
|
||
|
|
<option value="partnership">Partnerskap</option>
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<button class="btn-primary" onclick="submitContract()" style="width:100%">Skapa kontrakt</button>
|
||
|
|
`);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Modal helpers
|
||
|
|
function showModal(title, html) {
|
||
|
|
document.getElementById('modal-title').textContent = title;
|
||
|
|
document.getElementById('modal-body').innerHTML = html;
|
||
|
|
document.getElementById('modal').style.display = 'flex';
|
||
|
|
}
|
||
|
|
|
||
|
|
function hideModal() {
|
||
|
|
document.getElementById('modal').style.display = 'none';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Submit functions (placeholder)
|
||
|
|
async function submitCustomer() { /* TODO */ hideModal(); }
|
||
|
|
async function submitDeal() { /* TODO */ hideModal(); }
|
||
|
|
async function submitInvoice() { /* TODO */ hideModal(); }
|
||
|
|
async function submitTicket() { /* TODO */ hideModal(); }
|
||
|
|
async function submitExpense() { /* TODO */ hideModal(); }
|
||
|
|
async function submitContract() { /* TODO */ hideModal(); }
|
||
|
|
|
||
|
|
// Load dashboard data
|
||
|
|
async function loadDashboard() {
|
||
|
|
try {
|
||
|
|
const res = await fetch('/api/v1/analytics/dashboard');
|
||
|
|
const data = await res.json();
|
||
|
|
|
||
|
|
if (data.kpis) {
|
||
|
|
document.getElementById('kpi-mrr').textContent = formatCurrency(data.kpis.mrr?.value);
|
||
|
|
document.getElementById('kpi-arr').textContent = formatCurrency(data.kpis.arr?.value);
|
||
|
|
document.getElementById('kpi-customers').textContent = data.kpis.customers?.active || 0;
|
||
|
|
document.getElementById('kpi-tickets').textContent = data.kpis.tickets?.open || 0;
|
||
|
|
document.getElementById('kpi-cash').textContent = formatCurrency(data.kpis.cash?.on_hand);
|
||
|
|
document.getElementById('kpi-pipeline').textContent = formatCurrency(data.kpis.pipeline?.total_value);
|
||
|
|
}
|
||
|
|
|
||
|
|
renderCharts(data.charts);
|
||
|
|
renderActivity(data.activity || []);
|
||
|
|
} catch (err) {
|
||
|
|
console.error('Failed to load dashboard:', err);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function formatCurrency(value) {
|
||
|
|
if (!value) return '—';
|
||
|
|
return new Intl.NumberFormat('sv-SE', { style: 'currency', currency: 'USD', maximumFractionDigits: 0 }).format(value);
|
||
|
|
}
|
||
|
|
|
||
|
|
function renderCharts(charts) {
|
||
|
|
if (!charts) return;
|
||
|
|
|
||
|
|
// Revenue chart
|
||
|
|
const revCtx = document.getElementById('revenue-chart');
|
||
|
|
if (revCtx && charts.revenue_trend) {
|
||
|
|
new Chart(revCtx, {
|
||
|
|
type: 'line',
|
||
|
|
data: {
|
||
|
|
labels: charts.revenue_trend.map(d => d.month),
|
||
|
|
datasets: [{
|
||
|
|
label: 'Intäkt',
|
||
|
|
data: charts.revenue_trend.map(d => d.revenue),
|
||
|
|
borderColor: '#C96A3A',
|
||
|
|
backgroundColor: 'rgba(201, 106, 58, 0.08)',
|
||
|
|
fill: true,
|
||
|
|
tension: 0.4,
|
||
|
|
pointRadius: 4,
|
||
|
|
pointHoverRadius: 6
|
||
|
|
}]
|
||
|
|
},
|
||
|
|
options: {
|
||
|
|
responsive: true,
|
||
|
|
maintainAspectRatio: false,
|
||
|
|
plugins: { legend: { display: false } },
|
||
|
|
scales: {
|
||
|
|
y: { beginAtZero: true, grid: { color: '#E8E4E0' }, ticks: { callback: v => '$' + (v/1000) + 'k' } },
|
||
|
|
x: { grid: { display: false } }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
// Pipeline chart
|
||
|
|
const pipeCtx = document.getElementById('pipeline-chart');
|
||
|
|
if (pipeCtx && charts.pipeline_by_stage) {
|
||
|
|
new Chart(pipeCtx, {
|
||
|
|
type: 'doughnut',
|
||
|
|
data: {
|
||
|
|
labels: charts.pipeline_by_stage.map(d => d.stage),
|
||
|
|
datasets: [{
|
||
|
|
data: charts.pipeline_by_stage.map(d => d.value),
|
||
|
|
backgroundColor: ['#C96A3A', '#E8845A', '#F0A070', '#F5C4A0'],
|
||
|
|
borderWidth: 0
|
||
|
|
}]
|
||
|
|
},
|
||
|
|
options: {
|
||
|
|
responsive: true,
|
||
|
|
maintainAspectRatio: false,
|
||
|
|
cutout: '65%',
|
||
|
|
plugins: {
|
||
|
|
legend: { position: 'right', labels: { usePointStyle: true, padding: 16 } }
|
||
|
|
}
|
||
|
|
}
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
function renderActivity(activities) {
|
||
|
|
const feed = document.getElementById('activity-feed');
|
||
|
|
if (activities.length === 0) {
|
||
|
|
feed.innerHTML = '<div class="empty-state"><div class="empty-state-icon">📭</div><p>Ingen aktivitet än</p></div>';
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
feed.innerHTML = activities.slice(0, 8).map(a => `
|
||
|
|
<div class="list-item">
|
||
|
|
<div>
|
||
|
|
<div class="list-item-main">${a.description}</div>
|
||
|
|
<div class="list-item-meta">${a.user} · ${timeAgo(a.timestamp)}</div>
|
||
|
|
</div>
|
||
|
|
<span class="badge ${a.status}">${a.type}</span>
|
||
|
|
</div>
|
||
|
|
`).join('');
|
||
|
|
}
|
||
|
|
|
||
|
|
function timeAgo(timestamp) {
|
||
|
|
const diff = Date.now() - new Date(timestamp).getTime();
|
||
|
|
const mins = Math.floor(diff / 60000);
|
||
|
|
if (mins < 1) return 'nyss';
|
||
|
|
if (mins < 60) return `${mins}m sedan`;
|
||
|
|
const hours = Math.floor(mins / 60);
|
||
|
|
if (hours < 24) return `${hours}h sedan`;
|
||
|
|
return `${Math.floor(hours / 24)}d sedan`;
|
||
|
|
}
|
||
|
|
|
||
|
|
// WebSocket for real-time updates
|
||
|
|
let ws;
|
||
|
|
function connectWebSocket() {
|
||
|
|
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||
|
|
ws = new WebSocket(`${protocol}//${window.location.host}/ws?tenant_id=default`);
|
||
|
|
|
||
|
|
ws.onopen = () => {
|
||
|
|
document.getElementById('live-indicator').style.display = 'inline-flex';
|
||
|
|
};
|
||
|
|
|
||
|
|
ws.onmessage = (event) => {
|
||
|
|
const data = JSON.parse(event.data);
|
||
|
|
if (data.type === 'deal_updated' || data.type === 'ticket_updated') {
|
||
|
|
loadDashboard(); // Refresh on relevant events
|
||
|
|
}
|
||
|
|
};
|
||
|
|
|
||
|
|
ws.onclose = () => {
|
||
|
|
document.getElementById('live-indicator').style.display = 'none';
|
||
|
|
setTimeout(connectWebSocket, 5000); // Reconnect
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
// Init
|
||
|
|
loadDashboard();
|
||
|
|
connectWebSocket();
|
||
|
|
setInterval(loadDashboard, 60000);
|
||
|
|
</script>
|
||
|
|
</body>
|
||
|
|
</html>
|