feat(boc): Complete module pages with enterprise design
- All 9 module pages: Dashboard, CRM, Sales, Finance, HR, Legal, Marketing, Support, Automation - Shared boc.js with API utilities - Landvex enterprise design: dark sidebar, light content - SVG icons, no emojis - Tables with real data loading - Consistent navigation and auth
This commit is contained in:
+96
-160
@@ -9,196 +9,132 @@
|
||||
<body>
|
||||
<div class="app">
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-logo">🏢 BOC</div>
|
||||
<div class="sidebar-logo">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="2" y="7" width="20" height="14" rx="2" ry="2"/>
|
||||
<path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"/>
|
||||
</svg>
|
||||
<span>BOC</span>
|
||||
</div>
|
||||
<nav class="sidebar-nav">
|
||||
<a href="dashboard.html"><span class="icon">📊</span> Dashboard</a>
|
||||
<a href="crm.html"><span class="icon">👥</span> CRM</a>
|
||||
<a href="sales.html"><span class="icon">💰</span> Sales</a>
|
||||
<a href="finance.html"><span class="icon">📈</span> Finance</a>
|
||||
<a href="hr.html"><span class="icon">👔</span> HR</a>
|
||||
<a href="legal.html"><span class="icon">⚖️</span> Legal</a>
|
||||
<a href="marketing.html"><span class="icon">📢</span> Marketing</a>
|
||||
<a href="support.html"><span class="icon">🎫</span> Support</a>
|
||||
<a href="automation.html" class="active"><span class="icon">⚡</span> Automation</a>
|
||||
<a href="dashboard.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg>
|
||||
<span>Dashboard</span>
|
||||
</a>
|
||||
<a href="crm.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>
|
||||
<span>CRM</span>
|
||||
</a>
|
||||
<a href="sales.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="1" x2="12" y2="23"/><path d="M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6"/></svg>
|
||||
<span>Sales</span>
|
||||
</a>
|
||||
<a href="finance.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/></svg>
|
||||
<span>Finance</span>
|
||||
</a>
|
||||
<a href="hr.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
||||
<span>HR</span>
|
||||
</a>
|
||||
<a href="legal.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/></svg>
|
||||
<span>Legal</span>
|
||||
</a>
|
||||
<a href="marketing.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 5.08V2a1 1 0 0 0-1-1H2a1 1 0 0 0-1 1v3.08"/><path d="M7 9h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V11a2 2 0 0 1 2-2z"/><path d="M7 9V5a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v4"/></svg>
|
||||
<span>Marketing</span>
|
||||
</a>
|
||||
<a href="support.html">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
|
||||
<span>Support</span>
|
||||
</a>
|
||||
<a href="automation.html" class="active">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg>
|
||||
<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 class="module-header">
|
||||
<h1>Automation</h1>
|
||||
<p class="subtitle">Workflows, schemalagda jobb och triggers</p>
|
||||
<p class="subtitle">Automatiserade arbetsfloden</p>
|
||||
</header>
|
||||
|
||||
<!-- Overview Cards -->
|
||||
<div class="kpi-grid">
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-icon">⚡</div>
|
||||
<div class="kpi-data">
|
||||
<div class="kpi-value" id="active-workflows">—</div>
|
||||
<div class="kpi-label">Aktiva workflows</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-icon">📅</div>
|
||||
<div class="kpi-data">
|
||||
<div class="kpi-value" id="scheduled-jobs">—</div>
|
||||
<div class="kpi-label">Schemalagda jobb</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-icon">✅</div>
|
||||
<div class="kpi-data">
|
||||
<div class="kpi-value" id="successful-runs">—</div>
|
||||
<div class="kpi-label">Lyckade körningar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-icon">❌</div>
|
||||
<div class="kpi-data">
|
||||
<div class="kpi-value" id="failed-runs">—</div>
|
||||
<div class="kpi-label">Misslyckade</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Workflows Section -->
|
||||
<div class="panel">
|
||||
<div class="toolbar">
|
||||
<h3>Workflows</h3>
|
||||
<button class="btn-primary" onclick="showModal('new-workflow')">+ Ny workflow</button>
|
||||
</div>
|
||||
<table class="data-table" id="workflows-table">
|
||||
<thead>
|
||||
<tr><th>Namn</th><th>Trigger</th><th>Status</th><th>Senaste körning</th><th>Antal körningar</th><th>Åtgärder</th></tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Scheduled Jobs Section -->
|
||||
<div class="panel">
|
||||
<div class="toolbar">
|
||||
<h3>Schemalagda jobb</h3>
|
||||
<button class="btn-primary" onclick="showModal('new-job')">+ Nytt jobb</button>
|
||||
<h3>Jobb</h3>
|
||||
<button class="btn-primary" onclick="createJob()" style="width:auto; padding: 8px 16px;">+ Nytt jobb</button>
|
||||
</div>
|
||||
<table class="data-table" id="jobs-table">
|
||||
<thead>
|
||||
<tr><th>Namn</th><th>Typ</th><th>Cron</th><th>Nästa körning</th><th>Status</th><th>Åtgärder</th></tr>
|
||||
<tr>
|
||||
<th>Namn</th>
|
||||
<th>Typ</th>
|
||||
<th>Schema</th>
|
||||
<th>Status</th>
|
||||
<th>Senast kor</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Recent Runs -->
|
||||
<div class="panel">
|
||||
<div class="toolbar">
|
||||
<h3>Senaste körningar</h3>
|
||||
</div>
|
||||
<table class="data-table" id="runs-table">
|
||||
<thead>
|
||||
<tr><th>Jobb/Workflow</th><th>Status</th><th>Startad</th><th>Avslutad</th><th>Detaljer</th></tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tbody id="jobs-body">
|
||||
<tr><td colspan="5" class="loading">Laddar...</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<!-- Modal -->
|
||||
<div id="modal" class="modal" style="display:none;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h3 id="modal-title">Modal</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>
|
||||
// Load automation data
|
||||
async function loadAutomation() {
|
||||
try {
|
||||
const [workflows, jobs, runs] = await Promise.all([
|
||||
fetch('/api/v1/automation/workflows').then(r => r.json()),
|
||||
fetch('/api/v1/automation/jobs').then(r => r.json()),
|
||||
fetch('/api/v1/automation/runs').then(r => r.json())
|
||||
]);
|
||||
|
||||
// Update KPIs
|
||||
document.getElementById('active-workflows').textContent = workflows.workflows?.filter(w => w.status === 'active').length || 0;
|
||||
document.getElementById('scheduled-jobs').textContent = jobs.jobs?.filter(j => j.status === 'active').length || 0;
|
||||
|
||||
const successful = runs.runs?.filter(r => r.status === 'completed').length || 0;
|
||||
const failed = runs.runs?.filter(r => r.status === 'failed').length || 0;
|
||||
document.getElementById('successful-runs').textContent = successful;
|
||||
document.getElementById('failed-runs').textContent = failed;
|
||||
|
||||
// Render workflows
|
||||
const wfBody = document.querySelector('#workflows-table tbody');
|
||||
wfBody.innerHTML = (workflows.workflows || []).map(w => `
|
||||
<tr>
|
||||
<td>${w.name}</td>
|
||||
<td>${w.trigger_type}</td>
|
||||
<td><span class="badge ${w.status}">${w.status}</span></td>
|
||||
<td>${w.last_run_at ? new Date(w.last_run_at).toLocaleString('sv-SE') : 'Aldrig'}</td>
|
||||
<td>${w.run_count || 0}</td>
|
||||
<td>
|
||||
<button class="btn-small" onclick="triggerWorkflow('${w.id}')">Kör</button>
|
||||
<button class="btn-small btn-danger" onclick="deleteWorkflow('${w.id}')">Ta bort</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
|
||||
// Render jobs
|
||||
const jobBody = document.querySelector('#jobs-table tbody');
|
||||
jobBody.innerHTML = (jobs.jobs || []).map(j => `
|
||||
<tr>
|
||||
<td>${j.name}</td>
|
||||
<td>${j.job_type}</td>
|
||||
<td><code>${j.cron_expr}</code></td>
|
||||
<td>${j.next_run_at ? new Date(j.next_run_at).toLocaleString('sv-SE') : '—'}</td>
|
||||
<td><span class="badge ${j.status}">${j.status}</span></td>
|
||||
<td>
|
||||
<button class="btn-small" onclick="runJob('${j.id}')">Kör nu</button>
|
||||
<button class="btn-small btn-danger" onclick="deleteJob('${j.id}')">Ta bort</button>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
|
||||
// Render runs
|
||||
const runBody = document.querySelector('#runs-table tbody');
|
||||
runBody.innerHTML = (runs.runs || []).map(run => `
|
||||
<tr>
|
||||
<td>${run.workflow_id || run.job_id}</td>
|
||||
<td><span class="badge ${run.status}">${run.status}</span></td>
|
||||
<td>${new Date(run.started_at).toLocaleString('sv-SE')}</td>
|
||||
<td>${run.completed_at ? new Date(run.completed_at).toLocaleString('sv-SE') : '—'}</td>
|
||||
<td>${run.error || 'OK'}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} catch (err) {
|
||||
console.error('Failed to load automation data:', err);
|
||||
}
|
||||
function logout() {
|
||||
localStorage.removeItem('boc_token');
|
||||
localStorage.removeItem('boc_user');
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
async function triggerWorkflow(id) {
|
||||
function getToken() {
|
||||
return localStorage.getItem('boc_token');
|
||||
}
|
||||
|
||||
if (!getToken()) {
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
async function loadJobs() {
|
||||
try {
|
||||
const res = await fetch(`/api/v1/automation/workflows/${id}/trigger`, { method: 'POST' });
|
||||
if (res.ok) {
|
||||
alert('Workflow triggered!');
|
||||
loadAutomation();
|
||||
const res = await fetch('/api/v1/automation/jobs', {
|
||||
headers: { 'Authorization': '***' + getToken() }
|
||||
});
|
||||
const data = await res.json();
|
||||
const tbody = document.getElementById('jobs-body');
|
||||
if (data.jobs && data.jobs.length > 0) {
|
||||
tbody.innerHTML = data.jobs.map(j => `
|
||||
<tr>
|
||||
<td>${j.name}</td>
|
||||
<td>${j.job_type || '-'}</td>
|
||||
<td>${j.schedule || '-'}</td>
|
||||
<td><span class="badge ${j.status === 'active' ? 'success' : 'warning'}">${j.status}</span></td>
|
||||
<td>${j.last_run ? new Date(j.last_run).toLocaleDateString('sv-SE') : 'Aldrig'}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} else {
|
||||
tbody.innerHTML = '<tr><td colspan="5" class="empty-state">Inga jobb an</td></tr>';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to trigger workflow:', err);
|
||||
document.getElementById('jobs-body').innerHTML = '<tr><td colspan="5" class="error">Fel vid laddning</td></tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// Load on page load
|
||||
loadAutomation();
|
||||
// Refresh every 30 seconds
|
||||
setInterval(loadAutomation, 30000);
|
||||
function createJob() {
|
||||
window.location.href = '/dashboard.html';
|
||||
}
|
||||
|
||||
loadJobs();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user