BOC v1.0: RS256 auth, Ledger integration, Prometheus metrics, CI/CD, backup
This commit is contained in:
@@ -0,0 +1,141 @@
|
||||
// BOC — Business Operations Center
|
||||
// Single-page app shell. One sidebar, dynamic modules.
|
||||
// Linus principle: write it once, route everything through it.
|
||||
|
||||
const API_BASE = '/api/v1';
|
||||
|
||||
// Module registry — add new modules here
|
||||
const modules = {
|
||||
'/': () => import('./modules/dashboard.js'),
|
||||
'/crm': () => import('./modules/crm.js'),
|
||||
'/sales': () => import('./modules/sales.js'),
|
||||
'/finance': () => import('./modules/finance.js'),
|
||||
'/hr': () => import('./modules/hr.js'),
|
||||
'/legal': () => import('./modules/legal.js'),
|
||||
'/marketing': () => import('./modules/marketing.js'),
|
||||
'/support': () => import('./modules/support.js'),
|
||||
'/automation': () => import('./modules/automation.js'),
|
||||
};
|
||||
|
||||
// Sidebar configuration — one source of truth
|
||||
const sidebarItems = [
|
||||
{ path: '/', label: 'Dashboard', icon: 'grid' },
|
||||
{ path: '/crm', label: 'CRM', icon: 'users' },
|
||||
{ path: '/sales', label: 'Sales', icon: 'dollar' },
|
||||
{ path: '/finance', label: 'Finance', icon: 'bar-chart' },
|
||||
{ path: '/hr', label: 'HR', icon: 'user' },
|
||||
{ path: '/legal', label: 'Legal', icon: 'file-text' },
|
||||
{ path: '/marketing', label: 'Marketing', icon: 'megaphone' },
|
||||
{ path: '/support', label: 'Support', icon: 'help-circle' },
|
||||
{ path: '/automation', label: 'Automation', icon: 'zap' },
|
||||
];
|
||||
|
||||
// Auth utilities
|
||||
function getToken() { return localStorage.getItem('boc_token'); }
|
||||
function getUser() {
|
||||
const u = localStorage.getItem('boc_user');
|
||||
return u ? JSON.parse(u) : null;
|
||||
}
|
||||
|
||||
function apiRequest(endpoint, options = {}) {
|
||||
const token = getToken();
|
||||
const url = endpoint.startsWith('http') ? endpoint : `${API_BASE}${endpoint}`;
|
||||
return fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
...options.headers
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Router
|
||||
async function navigate(path) {
|
||||
const app = document.getElementById('app');
|
||||
const loader = modules[path] || modules['/'];
|
||||
|
||||
try {
|
||||
const mod = await loader();
|
||||
app.innerHTML = '';
|
||||
await mod.render(app);
|
||||
updateActiveNav(path);
|
||||
} catch (err) {
|
||||
app.innerHTML = `<div class="alert alert-error">Failed to load module: ${err.message}</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
function updateActiveNav(path) {
|
||||
document.querySelectorAll('.sidebar-nav a').forEach(a => {
|
||||
a.classList.toggle('active', a.getAttribute('href') === '#' + path);
|
||||
});
|
||||
}
|
||||
|
||||
// Sidebar renderer
|
||||
function renderSidebar() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const user = getUser();
|
||||
|
||||
sidebar.innerHTML = `
|
||||
<div class="sidebar-logo">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="2" y="7" width="20" height="14" rx="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">
|
||||
${sidebarItems.map(item => `
|
||||
<a href="#${item.path}" data-path="${item.path}">
|
||||
<span>${item.label}</span>
|
||||
</a>
|
||||
`).join('')}
|
||||
</nav>
|
||||
<div class="sidebar-footer">
|
||||
<span>${user?.email || 'guest'}</span>
|
||||
<button onclick="logout()">Logga ut</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
sidebar.querySelectorAll('a').forEach(a => {
|
||||
a.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const path = a.getAttribute('data-path');
|
||||
location.hash = path;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem('boc_token');
|
||||
localStorage.removeItem('boc_user');
|
||||
location.href = '/login.html';
|
||||
}
|
||||
|
||||
// Auth check
|
||||
function requireAuth() {
|
||||
if (!getToken()) {
|
||||
location.href = '/login.html';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Init
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
if (!requireAuth()) return;
|
||||
renderSidebar();
|
||||
|
||||
const path = location.hash.slice(1) || '/';
|
||||
navigate(path);
|
||||
});
|
||||
|
||||
window.addEventListener('hashchange', () => {
|
||||
const path = location.hash.slice(1) || '/';
|
||||
navigate(path);
|
||||
});
|
||||
|
||||
// Export for modules
|
||||
window.apiRequest = apiRequest;
|
||||
window.getToken = getToken;
|
||||
window.getUser = getUser;
|
||||
@@ -0,0 +1,867 @@
|
||||
/* ============================================
|
||||
BOC — Business Operations Center
|
||||
Enterprise Design System
|
||||
============================================ */
|
||||
|
||||
:root {
|
||||
/* Brand — Landvex Blue */
|
||||
--brand: #0066FF;
|
||||
--brand-dark: #0052CC;
|
||||
--brand-light: #4D94FF;
|
||||
--brand-glow: rgba(0, 102, 255, 0.15);
|
||||
|
||||
/* Neutral Scale */
|
||||
--neutral-0: #ffffff;
|
||||
--neutral-50: #f8f9fa;
|
||||
--neutral-100: #f1f3f5;
|
||||
--neutral-200: #e9ecef;
|
||||
--neutral-300: #dee2e6;
|
||||
--neutral-400: #ced4da;
|
||||
--neutral-500: #adb5bd;
|
||||
--neutral-600: #868e96;
|
||||
--neutral-700: #495057;
|
||||
--neutral-800: #343a40;
|
||||
--neutral-900: #212529;
|
||||
--neutral-1000: #0f172a;
|
||||
|
||||
/* Semantic */
|
||||
--success: #40c057;
|
||||
--warning: #fcc419;
|
||||
--danger: #fa5252;
|
||||
--info: #339af0;
|
||||
|
||||
/* Surfaces */
|
||||
--bg: #f5f5f7;
|
||||
--surface: #ffffff;
|
||||
--surface-hover: #f8f9fa;
|
||||
--sidebar-bg: #0f172a;
|
||||
|
||||
/* Text */
|
||||
--text: #1d1d1f;
|
||||
--text-secondary: #6B6B6B;
|
||||
--text-muted: #868e96;
|
||||
--text-inverse: #ffffff;
|
||||
|
||||
/* Borders */
|
||||
--border: rgba(0,0,0,0.08);
|
||||
--border-strong: #e9ecef;
|
||||
|
||||
/* Spacing */
|
||||
--space-xs: 4px;
|
||||
--space-sm: 8px;
|
||||
--space-md: 16px;
|
||||
--space-lg: 24px;
|
||||
--space-xl: 32px;
|
||||
--space-2xl: 48px;
|
||||
|
||||
/* Radius */
|
||||
--radius-sm: 8px;
|
||||
--radius-md: 14px;
|
||||
--radius-lg: 24px;
|
||||
|
||||
/* Shadows */
|
||||
--shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
|
||||
--shadow-md: 0 2px 8px rgba(0,0,0,0.06);
|
||||
--shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
|
||||
|
||||
/* Typography */
|
||||
--font-sans: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', sans-serif;
|
||||
--font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;
|
||||
}
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: var(--font-sans);
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
LOGIN PAGE
|
||||
============================================ */
|
||||
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.login-box {
|
||||
background: var(--surface);
|
||||
padding: 48px;
|
||||
border-radius: var(--radius-lg);
|
||||
box-shadow: var(--shadow-lg);
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
|
||||
.login-logo {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background: var(--brand);
|
||||
border-radius: var(--radius-md);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.login-logo svg {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.login-box h1 {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
margin-bottom: 8px;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.login-box .subtitle {
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group select,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 15px;
|
||||
font-family: var(--font-sans);
|
||||
color: var(--text);
|
||||
background: var(--surface);
|
||||
transition: border-color 0.15s, box-shadow 0.15s;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group select:focus,
|
||||
.form-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--brand);
|
||||
box-shadow: 0 0 0 3px var(--brand-glow);
|
||||
}
|
||||
|
||||
.form-group input::placeholder,
|
||||
.form-group textarea::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: var(--brand);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
font-family: var(--font-sans);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s, transform 0.1s;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--brand-dark);
|
||||
}
|
||||
|
||||
.btn-primary:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
.btn-primary:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.login-footer {
|
||||
margin-top: 32px;
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--border);
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.login-footer a {
|
||||
color: var(--brand);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.error-msg {
|
||||
background: #fff5f5;
|
||||
color: var(--danger);
|
||||
padding: 12px 16px;
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: 20px;
|
||||
font-size: 14px;
|
||||
border: 1px solid rgba(250, 82, 82, 0.2);
|
||||
display: none;
|
||||
}
|
||||
|
||||
.error-msg.show {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
APP LAYOUT
|
||||
============================================ */
|
||||
|
||||
.app {
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
.sidebar {
|
||||
width: 240px;
|
||||
background: var(--sidebar-bg);
|
||||
color: var(--text-inverse);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: fixed;
|
||||
height: 100vh;
|
||||
left: 0;
|
||||
top: 0;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.sidebar-logo {
|
||||
padding: 24px;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.08);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.sidebar-logo svg {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
color: var(--brand);
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
flex: 1;
|
||||
padding: 16px 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.sidebar-nav a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 16px;
|
||||
border-radius: var(--radius-sm);
|
||||
color: rgba(255,255,255,0.6);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.sidebar-nav a:hover {
|
||||
background: rgba(255,255,255,0.06);
|
||||
color: rgba(255,255,255,0.9);
|
||||
}
|
||||
|
||||
.sidebar-nav a.active {
|
||||
background: var(--brand);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.sidebar-nav svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.sidebar-nav a.active svg {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: 16px;
|
||||
border-top: 1px solid rgba(255,255,255,0.08);
|
||||
font-size: 13px;
|
||||
color: rgba(255,255,255,0.4);
|
||||
}
|
||||
|
||||
.sidebar-footer button {
|
||||
width: 100%;
|
||||
margin-top: 12px;
|
||||
padding: 8px;
|
||||
background: rgba(255,255,255,0.06);
|
||||
border: 1px solid rgba(255,255,255,0.1);
|
||||
border-radius: var(--radius-sm);
|
||||
color: rgba(255,255,255,0.6);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.sidebar-footer button:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
/* Main Content */
|
||||
.main {
|
||||
flex: 1;
|
||||
margin-left: 240px;
|
||||
padding: 32px;
|
||||
max-width: 1400px;
|
||||
}
|
||||
|
||||
.module-header {
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.module-header h1 {
|
||||
font-size: 30px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--text);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.module-header .subtitle {
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
KPI CARDS
|
||||
============================================ */
|
||||
|
||||
.kpi-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(6, 1fr);
|
||||
gap: 16px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.kpi-card {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 20px;
|
||||
border: 1px solid var(--border);
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.15s, transform 0.1s;
|
||||
}
|
||||
|
||||
.kpi-card:hover {
|
||||
box-shadow: var(--shadow-md);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.kpi-icon {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--brand-glow);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.kpi-icon svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
color: var(--brand);
|
||||
}
|
||||
|
||||
.kpi-value {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
letter-spacing: -0.02em;
|
||||
color: var(--text);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.kpi-label {
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.kpi-trend {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.kpi-trend.up {
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.kpi-trend.down {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
PANELS
|
||||
============================================ */
|
||||
|
||||
.panel {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius-md);
|
||||
padding: 24px;
|
||||
border: 1px solid var(--border);
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.panel h3 {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
margin-bottom: 16px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.toolbar h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
DASHBOARD GRID
|
||||
============================================ */
|
||||
|
||||
.dashboard-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 2fr 1fr;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
QUICK ACTIONS
|
||||
============================================ */
|
||||
|
||||
.quick-actions {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
padding: 12px;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
cursor: pointer;
|
||||
transition: all 0.15s;
|
||||
font-family: var(--font-sans);
|
||||
}
|
||||
|
||||
.btn-action:hover {
|
||||
background: var(--surface-hover);
|
||||
border-color: var(--brand);
|
||||
color: var(--brand);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
ACTIVITY FEED
|
||||
============================================ */
|
||||
|
||||
.list-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.list-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.list-item-main {
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.list-item-meta {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.badge {
|
||||
padding: 4px 10px;
|
||||
border-radius: 9999px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
}
|
||||
|
||||
.badge.success {
|
||||
background: rgba(64, 192, 87, 0.1);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
.badge.warning {
|
||||
background: rgba(252, 196, 25, 0.1);
|
||||
color: #d4a017;
|
||||
}
|
||||
|
||||
.badge.danger {
|
||||
background: rgba(250, 82, 82, 0.1);
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.badge.info {
|
||||
background: rgba(51, 154, 240, 0.1);
|
||||
color: var(--info);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
AUTOMATION STATUS
|
||||
============================================ */
|
||||
|
||||
.automation-grid {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.automation-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.automation-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.automation-indicator {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.automation-indicator.active {
|
||||
background: var(--success);
|
||||
}
|
||||
|
||||
.automation-indicator.warning {
|
||||
background: var(--warning);
|
||||
}
|
||||
|
||||
.automation-indicator.danger {
|
||||
background: var(--danger);
|
||||
}
|
||||
|
||||
.automation-name {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: var(--text);
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.automation-schedule {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
ALERTS
|
||||
============================================ */
|
||||
|
||||
.alert {
|
||||
padding: 16px 20px;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.alert-critical {
|
||||
background: rgba(250, 82, 82, 0.06);
|
||||
border: 1px solid rgba(250, 82, 82, 0.15);
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.alert-warning {
|
||||
background: rgba(252, 196, 25, 0.06);
|
||||
border: 1px solid rgba(252, 196, 25, 0.15);
|
||||
color: #d4a017;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
LIVE INDICATOR
|
||||
============================================ */
|
||||
|
||||
#live-indicator {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
#live-indicator::before {
|
||||
content: '';
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
background: var(--success);
|
||||
animation: pulse 2s infinite;
|
||||
}
|
||||
|
||||
@keyframes pulse {
|
||||
0%, 100% { opacity: 1; }
|
||||
50% { opacity: 0.4; }
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
MODAL
|
||||
============================================ */
|
||||
|
||||
.modal {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
background: rgba(15, 23, 42, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 300;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius-lg);
|
||||
width: 100%;
|
||||
max-width: 480px;
|
||||
max-height: 90vh;
|
||||
overflow: auto;
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 24px 24px 0;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 24px;
|
||||
color: var(--text-muted);
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
EMPTY STATE
|
||||
============================================ */
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 48px 24px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.empty-state-icon {
|
||||
font-size: 32px;
|
||||
margin-bottom: 12px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
LOADING
|
||||
============================================ */
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 24px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.spinner {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border: 2px solid var(--border-strong);
|
||||
border-top-color: var(--brand);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
margin: 0 auto 12px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
RESPONSIVE
|
||||
============================================ */
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.kpi-grid {
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
}
|
||||
.dashboard-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 100%;
|
||||
transform: translateX(-100%);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
.sidebar.open {
|
||||
transform: translateX(0);
|
||||
}
|
||||
.main {
|
||||
margin-left: 0;
|
||||
padding: 16px;
|
||||
}
|
||||
.kpi-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
.quick-actions {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
TABLES
|
||||
============================================ */
|
||||
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 12px 16px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: var(--text-muted);
|
||||
border-bottom: 1px solid var(--border);
|
||||
background: var(--neutral-50);
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.data-table tr:hover td {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
BUTTONS
|
||||
============================================ */
|
||||
|
||||
.btn-link {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: var(--brand);
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.btn-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* ============================================
|
||||
SCROLLBAR
|
||||
============================================ */
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--neutral-300);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--neutral-400);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// BOC — Business Operations Center
|
||||
// Shared JavaScript utilities
|
||||
|
||||
const API_BASE = '/api/v1';
|
||||
|
||||
function getToken() {
|
||||
return localStorage.getItem('boc_token');
|
||||
}
|
||||
|
||||
function getUser() {
|
||||
const user = localStorage.getItem('boc_user');
|
||||
return user ? JSON.parse(user) : null;
|
||||
}
|
||||
|
||||
function apiRequest(endpoint, options = {}) {
|
||||
const token = getToken();
|
||||
const url = endpoint.startsWith('http') ? endpoint : `${API_BASE}${endpoint}`;
|
||||
|
||||
return fetch(url, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
...options.headers
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function formatCurrency(value, currency = 'USD') {
|
||||
if (value === null || value === undefined) return '—';
|
||||
return new Intl.NumberFormat('sv-SE', {
|
||||
style: 'currency',
|
||||
currency,
|
||||
maximumFractionDigits: 0
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
function formatDate(date) {
|
||||
if (!date) return '-';
|
||||
return new Date(date).toLocaleDateString('sv-SE');
|
||||
}
|
||||
|
||||
function formatDateTime(date) {
|
||||
if (!date) return '-';
|
||||
return new Date(date).toLocaleString('sv-SE');
|
||||
}
|
||||
|
||||
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`;
|
||||
const days = Math.floor(hours / 24);
|
||||
if (days < 30) return `${days}d sedan`;
|
||||
return formatDate(timestamp);
|
||||
}
|
||||
|
||||
function showToast(message, type = 'info') {
|
||||
const toast = document.createElement('div');
|
||||
toast.className = `alert alert-${type}`;
|
||||
toast.style.cssText = 'position:fixed;top:24px;right:24px;z-index:1000;max-width:400px;animation:slideIn 0.3s ease;';
|
||||
toast.textContent = message;
|
||||
document.body.appendChild(toast);
|
||||
setTimeout(() => toast.remove(), 5000);
|
||||
}
|
||||
|
||||
function confirmDelete(message) {
|
||||
return confirm(message || 'Ar du saker pa att du vill ta bort detta?');
|
||||
}
|
||||
|
||||
// Check authentication on page load
|
||||
function requireAuth() {
|
||||
if (!getToken()) {
|
||||
window.location.href = '/';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Update user email in sidebar
|
||||
function updateUserInfo() {
|
||||
const user = getUser();
|
||||
const el = document.getElementById('user-email');
|
||||
if (el && user) {
|
||||
el.textContent = user.email || 'erik@landvex.com';
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
updateUserInfo();
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
// Automation module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Automation</h1>
|
||||
<p class="subtitle">Workflows och schemalagda jobb</p>
|
||||
</header>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// CRM module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>CRM</h1>
|
||||
<p class="subtitle">Kunder och leads</p>
|
||||
</header>
|
||||
<div class="toolbar">
|
||||
<button class="btn-primary" id="btn-new-customer">+ Ny kund</button>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<table class="data-table" id="customers-table">
|
||||
<thead>
|
||||
<tr><th>Namn</th><th>Företag</th><th>Status</th><th>Email</th></tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
`;
|
||||
|
||||
try {
|
||||
const res = await apiRequest('/crm/customers');
|
||||
const data = await res.json();
|
||||
const tbody = container.querySelector('#customers-table tbody');
|
||||
|
||||
if (data.customers?.length) {
|
||||
tbody.innerHTML = data.customers.map(c => `
|
||||
<tr>
|
||||
<td>${c.name}</td>
|
||||
<td>${c.company || '-'}</td>
|
||||
<td><span class="badge badge-${c.status}">${c.status}</span></td>
|
||||
<td>${c.email || '-'}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} else {
|
||||
tbody.innerHTML = '<tr><td colspan="4">Inga kunder hittades</td></tr>';
|
||||
}
|
||||
} catch (err) {
|
||||
container.innerHTML += `<div class="alert alert-error">Kunde inte ladda kunder: ${err.message}</div>`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// Dashboard module — rendered dynamically into #app
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Dashboard</h1>
|
||||
<p class="subtitle">Överblick över hela verksamheten</p>
|
||||
</header>
|
||||
<div class="kpi-grid">
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-value" id="kpi-revenue">—</div>
|
||||
<div class="kpi-label">Månadsintäkt</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-value" id="kpi-deals">—</div>
|
||||
<div class="kpi-label">Aktiva deals</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-value" id="kpi-customers">—</div>
|
||||
<div class="kpi-label">Kunder</div>
|
||||
</div>
|
||||
<div class="kpi-card">
|
||||
<div class="kpi-value" id="kpi-tickets">—</div>
|
||||
<div class="kpi-label">Öppna ärenden</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section">
|
||||
<h2>Snabbåtgärder</h2>
|
||||
<div class="quick-actions">
|
||||
<button onclick="location.hash='/crm'">+ Ny kund</button>
|
||||
<button onclick="location.hash='/sales'">+ Ny offert</button>
|
||||
<button onclick="location.hash='/finance'">+ Ny faktura</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Load real data
|
||||
try {
|
||||
const [deals, customers, tickets] = await Promise.all([
|
||||
apiRequest('/sales/deals').then(r => r.ok ? r.json() : {deals: []}),
|
||||
apiRequest('/crm/customers').then(r => r.ok ? r.json() : {customers: []}),
|
||||
apiRequest('/support/tickets').then(r => r.ok ? r.json() : {tickets: []}),
|
||||
]);
|
||||
|
||||
document.getElementById('kpi-deals').textContent = deals.deals?.length || 0;
|
||||
document.getElementById('kpi-customers').textContent = customers.customers?.length || 0;
|
||||
document.getElementById('kpi-tickets').textContent = tickets.tickets?.length || 0;
|
||||
} catch (err) {
|
||||
console.error('Dashboard load error:', err);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Finance module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Finance</h1>
|
||||
<p class="subtitle">Fakturor och ekonomi</p>
|
||||
</header>
|
||||
<div class="toolbar">
|
||||
<button class="btn-primary">+ Ny faktura</button>
|
||||
</div>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// HR module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>HR</h1>
|
||||
<p class="subtitle">Anställda och tidrapporter</p>
|
||||
</header>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Legal module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Legal</h1>
|
||||
<p class="subtitle">Kontrakt och påminnelser</p>
|
||||
</header>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Marketing module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Marketing</h1>
|
||||
<p class="subtitle">Kampanjer och innehåll</p>
|
||||
</header>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Sales module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Sales</h1>
|
||||
<p class="subtitle">Deals och offert</p>
|
||||
</header>
|
||||
<div class="toolbar">
|
||||
<button class="btn-primary">+ Ny deal</button>
|
||||
<button class="btn-secondary">+ Ny offert</button>
|
||||
</div>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// Support module
|
||||
export async function render(container) {
|
||||
container.innerHTML = `
|
||||
<header class="module-header">
|
||||
<h1>Support</h1>
|
||||
<p class="subtitle">Ärenden och kundtjänst</p>
|
||||
</header>
|
||||
<p>Modulen laddas...</p>
|
||||
`;
|
||||
}
|
||||
Reference in New Issue
Block a user