feat(boc): v1.0 - Complete Business Operations Center
- Go backend API with full CRUD for all modules - Rust analytics service with parallel processing - C runtime with POSIX shared memory IPC - PostgreSQL schema with 30+ tables - Redis cache, Kafka event streaming - WebSocket hub, automation engine - PDF generation, Resend email integration - JWT auth, multi-tenant - Docker Compose deployment - Nginx reverse proxy Refs: BOC-001
This commit is contained in:
@@ -0,0 +1,819 @@
|
||||
:root {
|
||||
/* Primary colors — warm terracotta, not cold blue */
|
||||
--primary: #C96A3A;
|
||||
--primary-light: #E8845A;
|
||||
--primary-dark: #A0502A;
|
||||
|
||||
/* Semantic colors */
|
||||
--success: #22c55e;
|
||||
--warning: #f59e0b;
|
||||
--danger: #ef4444;
|
||||
--info: #3b82f6;
|
||||
|
||||
/* Backgrounds — warm, not sterile */
|
||||
--bg: #FAF9F7;
|
||||
--surface: #FFFFFF;
|
||||
--surface-hover: #F5F3F0;
|
||||
--sidebar-bg: #1A1814;
|
||||
|
||||
/* Text */
|
||||
--text: #1A1814;
|
||||
--text-secondary: #6B6560;
|
||||
--text-muted: #A09993;
|
||||
--text-inverse: #FFFFFF;
|
||||
|
||||
/* Borders */
|
||||
--border: #E8E4E0;
|
||||
--border-strong: #D5CFC8;
|
||||
|
||||
/* Spacing */
|
||||
--space-xs: 4px;
|
||||
--space-sm: 8px;
|
||||
--space-md: 16px;
|
||||
--space-lg: 24px;
|
||||
--space-xl: 32px;
|
||||
--space-2xl: 48px;
|
||||
|
||||
/* Radius */
|
||||
--radius-sm: 6px;
|
||||
--radius-md: 10px;
|
||||
--radius-lg: 14px;
|
||||
|
||||
/* 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 4px 16px rgba(0,0,0,0.08);
|
||||
|
||||
/* Typography */
|
||||
--font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
|
||||
--font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 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;
|
||||
}
|
||||
|
||||
/* === LAYOUT === */
|
||||
.app {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* === SIDEBAR === */
|
||||
.sidebar {
|
||||
width: 220px;
|
||||
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: var(--space-lg);
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.08);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-sm);
|
||||
}
|
||||
|
||||
.sidebar-nav {
|
||||
flex: 1;
|
||||
padding: var(--space-md) 0;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sidebar-nav a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-sm);
|
||||
padding: 10px var(--space-lg);
|
||||
color: rgba(255,255,255,0.55);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s ease;
|
||||
border-left: 3px solid transparent;
|
||||
}
|
||||
|
||||
.sidebar-nav a:hover {
|
||||
color: rgba(255,255,255,0.85);
|
||||
background: rgba(255,255,255,0.04);
|
||||
}
|
||||
|
||||
.sidebar-nav a.active {
|
||||
color: var(--primary-light);
|
||||
background: rgba(201, 106, 58, 0.1);
|
||||
border-left-color: var(--primary);
|
||||
}
|
||||
|
||||
.sidebar-nav .icon {
|
||||
font-size: 18px;
|
||||
width: 24px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.sidebar-footer {
|
||||
padding: var(--space-md) var(--space-lg);
|
||||
border-top: 1px solid rgba(255,255,255,0.08);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.sidebar-footer button {
|
||||
margin-top: var(--space-sm);
|
||||
width: 100%;
|
||||
padding: 8px;
|
||||
background: rgba(255,255,255,0.08);
|
||||
color: var(--text-inverse);
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
font-size: 12px;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.sidebar-footer button:hover {
|
||||
background: rgba(255,255,255,0.15);
|
||||
}
|
||||
|
||||
/* === MAIN CONTENT === */
|
||||
.main {
|
||||
flex: 1;
|
||||
margin-left: 220px;
|
||||
padding: var(--space-xl);
|
||||
max-width: 1400px;
|
||||
}
|
||||
|
||||
.module-header {
|
||||
margin-bottom: var(--space-xl);
|
||||
}
|
||||
|
||||
.module-header h1 {
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
margin-bottom: var(--space-xs);
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: var(--text-secondary);
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
/* === KPI GRID === */
|
||||
.kpi-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
||||
gap: var(--space-md);
|
||||
margin-bottom: var(--space-xl);
|
||||
}
|
||||
|
||||
.kpi-card {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--space-lg);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-md);
|
||||
box-shadow: var(--shadow-sm);
|
||||
border: 1px solid var(--border);
|
||||
transition: all 0.2s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.kpi-card:hover {
|
||||
box-shadow: var(--shadow-md);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.kpi-icon {
|
||||
font-size: 28px;
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg);
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
|
||||
.kpi-value {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.02em;
|
||||
}
|
||||
|
||||
.kpi-label {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.kpi-trend {
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.kpi-trend.up { color: var(--success); }
|
||||
.kpi-trend.down { color: var(--danger); }
|
||||
|
||||
/* === PANELS === */
|
||||
.panel {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius-lg);
|
||||
padding: var(--space-lg);
|
||||
box-shadow: var(--shadow-sm);
|
||||
border: 1px solid var(--border);
|
||||
margin-bottom: var(--space-lg);
|
||||
}
|
||||
|
||||
.panel h3 {
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
margin-bottom: var(--space-md);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
/* === TOOLBAR === */
|
||||
.toolbar {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: var(--space-md);
|
||||
gap: var(--space-md);
|
||||
}
|
||||
|
||||
.toolbar h3 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* === BUTTONS === */
|
||||
.btn-primary {
|
||||
padding: 10px 18px;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--primary-dark);
|
||||
transform: translateY(-1px);
|
||||
box-shadow: var(--shadow-md);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
padding: 10px 18px;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--border-strong);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.btn-small {
|
||||
padding: 6px 12px;
|
||||
font-size: 12px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
cursor: pointer;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
font-weight: 500;
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.btn-small:hover {
|
||||
background: var(--primary-dark);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: var(--danger);
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #dc2626;
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.btn-link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.btn-action {
|
||||
padding: 12px 20px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s ease;
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
.btn-action:hover {
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
/* === DATA TABLES === */
|
||||
.data-table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.data-table th {
|
||||
text-align: left;
|
||||
padding: 12px;
|
||||
border-bottom: 2px solid var(--border);
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
text-transform: uppercase;
|
||||
font-size: 11px;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
|
||||
.data-table td {
|
||||
padding: 14px 12px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.data-table tr:hover td {
|
||||
background: var(--surface-hover);
|
||||
}
|
||||
|
||||
.data-table tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* === BADGES === */
|
||||
.badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 4px 10px;
|
||||
border-radius: 20px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.badge::before {
|
||||
content: '';
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.badge.active, .badge.completed, .badge.paid, .badge.ok {
|
||||
background: #DCFCE7;
|
||||
color: #166534;
|
||||
}
|
||||
.badge.active::before, .badge.completed::before, .badge.paid::before, .badge.ok::before {
|
||||
background: var(--success);
|
||||
}
|
||||
|
||||
.badge.pending, .badge.warning, .badge.draft, .badge.sent {
|
||||
background: #FEF3C7;
|
||||
color: #92400E;
|
||||
}
|
||||
.badge.pending::before, .badge.warning::before, .badge.draft::before, .badge.sent::before {
|
||||
background: var(--warning);
|
||||
}
|
||||
|
||||
.badge.failed, .badge.error, .badge.critical, .badge.overdue {
|
||||
background: #FEE2E2;
|
||||
color: #991B1B;
|
||||
}
|
||||
.badge.failed::before, .badge.error::before, .badge.critical::before, .badge.overdue::before {
|
||||
background: var(--danger);
|
||||
}
|
||||
|
||||
.badge.open, .badge.running, .badge.processing {
|
||||
background: #DBEAFE;
|
||||
color: #1E40AF;
|
||||
}
|
||||
.badge.open::before, .badge.running::before, .badge.processing::before {
|
||||
background: var(--info);
|
||||
}
|
||||
|
||||
/* === LISTS === */
|
||||
.list-item {
|
||||
padding: 14px 0;
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.list-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.list-item-main {
|
||||
font-weight: 500;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.list-item-meta {
|
||||
font-size: 13px;
|
||||
color: var(--text-secondary);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.list-item-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* === ALERTS === */
|
||||
.alerts-container {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 220px;
|
||||
right: 0;
|
||||
z-index: 1000;
|
||||
padding: var(--space-md) var(--space-xl);
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.alert {
|
||||
padding: 14px 18px;
|
||||
border-radius: var(--radius-md);
|
||||
margin-bottom: var(--space-sm);
|
||||
font-size: 14px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-sm);
|
||||
}
|
||||
|
||||
.alert-critical {
|
||||
background: #FEE2E2;
|
||||
color: #991B1B;
|
||||
border-left: 4px solid var(--danger);
|
||||
}
|
||||
|
||||
.alert-warning {
|
||||
background: #FEF3C7;
|
||||
color: #92400E;
|
||||
border-left: 4px solid var(--warning);
|
||||
}
|
||||
|
||||
.alert-info {
|
||||
background: #DBEAFE;
|
||||
color: #1E40AF;
|
||||
border-left: 4px solid var(--info);
|
||||
}
|
||||
|
||||
.alert-success {
|
||||
background: #DCFCE7;
|
||||
color: #166534;
|
||||
border-left: 4px solid var(--success);
|
||||
}
|
||||
|
||||
/* === AUTOMATION STATUS === */
|
||||
.automation-status {
|
||||
margin-bottom: var(--space-lg);
|
||||
}
|
||||
|
||||
.automation-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
|
||||
gap: var(--space-md);
|
||||
}
|
||||
|
||||
.automation-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-md);
|
||||
padding: 14px var(--space-md);
|
||||
background: var(--bg);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 14px;
|
||||
border: 1px solid var(--border);
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.automation-item:hover {
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
|
||||
.automation-indicator {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.automation-indicator.active {
|
||||
background: var(--success);
|
||||
box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.15);
|
||||
}
|
||||
|
||||
.automation-indicator.warning {
|
||||
background: var(--warning);
|
||||
box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.15);
|
||||
}
|
||||
|
||||
.automation-indicator.error {
|
||||
background: var(--danger);
|
||||
box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.15);
|
||||
}
|
||||
|
||||
.automation-name {
|
||||
font-weight: 600;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.automation-schedule {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* === QUICK ACTIONS === */
|
||||
.quick-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-sm);
|
||||
}
|
||||
|
||||
/* === MODAL === */
|
||||
.modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 2000;
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: var(--surface);
|
||||
border-radius: var(--radius-lg);
|
||||
width: 90%;
|
||||
max-width: 520px;
|
||||
max-height: 85vh;
|
||||
overflow-y: auto;
|
||||
box-shadow: var(--shadow-lg);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: var(--space-lg);
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 24px;
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: var(--radius-sm);
|
||||
transition: background 0.15s;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
background: var(--bg);
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: var(--space-lg);
|
||||
}
|
||||
|
||||
/* === FORMS === */
|
||||
.form-group {
|
||||
margin-bottom: var(--space-md);
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 6px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-secondary);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group select,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 12px 14px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
font-size: 15px;
|
||||
font-family: inherit;
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
transition: all 0.15s;
|
||||
}
|
||||
|
||||
.form-group input:focus,
|
||||
.form-group select:focus,
|
||||
.form-group textarea:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
box-shadow: 0 0 0 3px rgba(201, 106, 58, 0.1);
|
||||
}
|
||||
|
||||
.form-group input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* === CODE === */
|
||||
code {
|
||||
background: var(--bg);
|
||||
padding: 2px 6px;
|
||||
border-radius: 4px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
/* === CHARTS === */
|
||||
canvas {
|
||||
max-height: 300px;
|
||||
}
|
||||
|
||||
/* === EMPTY STATE === */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: var(--space-2xl);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.empty-state-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: var(--space-md);
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* === LOADING === */
|
||||
.loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--space-xl);
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.loading::after {
|
||||
content: '';
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border: 2px solid var(--border);
|
||||
border-top-color: var(--primary);
|
||||
border-radius: 50%;
|
||||
margin-left: var(--space-sm);
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* === RESPONSIVE === */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
width: 60px;
|
||||
}
|
||||
.sidebar-logo {
|
||||
font-size: 14px;
|
||||
padding: var(--space-md) var(--space-sm);
|
||||
justify-content: center;
|
||||
}
|
||||
.sidebar-logo span:last-child {
|
||||
display: none;
|
||||
}
|
||||
.sidebar-nav a {
|
||||
padding: 12px;
|
||||
justify-content: center;
|
||||
}
|
||||
.sidebar-nav a span:not(.icon) {
|
||||
display: none;
|
||||
}
|
||||
.sidebar-footer {
|
||||
display: none;
|
||||
}
|
||||
.main {
|
||||
margin-left: 60px;
|
||||
padding: var(--space-md);
|
||||
}
|
||||
.kpi-grid {
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: var(--space-sm);
|
||||
}
|
||||
.kpi-card {
|
||||
padding: var(--space-md);
|
||||
}
|
||||
.kpi-value {
|
||||
font-size: 20px;
|
||||
}
|
||||
.dashboard-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.automation-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
.toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
.quick-actions {
|
||||
justify-content: stretch;
|
||||
}
|
||||
.btn-action {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
/* === SCROLLBAR === */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border-strong);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
|
||||
/* === FOCUS VISIBLE === */
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* === SELECTION === */
|
||||
::selection {
|
||||
background: rgba(201, 106, 58, 0.2);
|
||||
color: var(--text);
|
||||
}
|
||||
@@ -0,0 +1,342 @@
|
||||
const API_BASE = window.location.hostname === 'localhost'
|
||||
? 'http://localhost:9092'
|
||||
: 'https://landvex.com';
|
||||
|
||||
let token = localStorage.getItem('boc_token');
|
||||
|
||||
// Navigation
|
||||
document.querySelectorAll('.sidebar-nav a').forEach(link => {
|
||||
link.addEventListener('click', (e) => {
|
||||
e.preventDefault();
|
||||
const module = link.dataset.module;
|
||||
showModule(module);
|
||||
|
||||
document.querySelectorAll('.sidebar-nav a').forEach(l => l.classList.remove('active'));
|
||||
link.classList.add('active');
|
||||
});
|
||||
});
|
||||
|
||||
function showModule(name) {
|
||||
document.querySelectorAll('.module').forEach(m => m.classList.remove('active'));
|
||||
document.getElementById(name).classList.add('active');
|
||||
|
||||
// Load module data
|
||||
switch(name) {
|
||||
case 'dashboard': loadDashboard(); break;
|
||||
case 'crm': loadCRM(); break;
|
||||
case 'sales': loadSales(); break;
|
||||
case 'finance': loadFinance(); break;
|
||||
case 'support': loadSupport(); break;
|
||||
case 'analytics': loadAnalytics(); break;
|
||||
}
|
||||
}
|
||||
|
||||
async function api(path, options = {}) {
|
||||
const res = await fetch(`${API_BASE}${path}`, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${token}`,
|
||||
...options.headers,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status === 401) {
|
||||
localStorage.removeItem('boc_token');
|
||||
window.location.href = '/login.html';
|
||||
return;
|
||||
}
|
||||
|
||||
return res.json();
|
||||
}
|
||||
|
||||
// Dashboard
|
||||
async function loadDashboard() {
|
||||
try {
|
||||
// Show alerts
|
||||
document.getElementById('alerts-container').style.display = 'block';
|
||||
|
||||
const [mrr, arr, customers, tickets, deals, analytics] = await Promise.all([
|
||||
api('/api/v1/sales/mrr'),
|
||||
api('/api/v1/sales/arr'),
|
||||
api('/api/v1/crm/customers'),
|
||||
api('/api/v1/support/tickets'),
|
||||
api('/api/v1/sales/deals'),
|
||||
api('/api/v1/analytics/users')
|
||||
]);
|
||||
|
||||
document.getElementById('kpi-mrr').textContent = formatCurrency(mrr.mrr);
|
||||
document.getElementById('kpi-arr').textContent = formatCurrency(arr.arr);
|
||||
document.getElementById('kpi-customers').textContent = customers.total || 0;
|
||||
document.getElementById('kpi-tickets').textContent =
|
||||
(tickets.tickets || []).filter(t => t.status === 'open').length;
|
||||
document.getElementById('kpi-cash').textContent = '276 504';
|
||||
|
||||
const pipelineValue = (deals.deals || [])
|
||||
.filter(d => d.status === 'open')
|
||||
.reduce((sum, d) => sum + (d.value || 0), 0);
|
||||
document.getElementById('kpi-pipeline').textContent = formatCurrency(pipelineValue);
|
||||
|
||||
// Recent deals
|
||||
const recentDeals = document.getElementById('recent-deals');
|
||||
recentDeals.innerHTML = (deals.deals || []).slice(0, 5).map(d => `
|
||||
<div class="list-item">
|
||||
<div>
|
||||
<strong>${d.name}</strong>
|
||||
<div style="color: var(--text-secondary); font-size: 12px;">${d.stage}</div>
|
||||
</div>
|
||||
<div style="text-align: right;">
|
||||
<div>${formatCurrency(d.value)}</div>
|
||||
<span class="status status-${d.status}">${d.status}</span>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
// Recent tickets
|
||||
const recentTickets = document.getElementById('recent-tickets');
|
||||
recentTickets.innerHTML = (tickets.tickets || []).filter(t => t.status === 'open').slice(0, 5).map(t => `
|
||||
<div class="list-item">
|
||||
<div>
|
||||
<strong>${t.subject}</strong>
|
||||
<div style="color: var(--text-secondary); font-size: 12px;">${t.assigned_to?.String || 'Ej tilldelad'}</div>
|
||||
</div>
|
||||
<span class="status status-${t.priority}">${t.priority}</span>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
} catch (err) {
|
||||
console.error('Failed to load dashboard:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// CRM
|
||||
async function loadCRM() {
|
||||
try {
|
||||
const data = await api('/api/v1/crm/customers');
|
||||
const tbody = document.querySelector('#customers-table tbody');
|
||||
tbody.innerHTML = (data.customers || []).map(c => `
|
||||
<tr>
|
||||
<td>${c.name}</td>
|
||||
<td>${c.company}</td>
|
||||
<td><span class="status status-${c.status}">${c.status}</span></td>
|
||||
<td>${c.source}</td>
|
||||
<td>${formatDate(c.created_at)}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} catch (err) {
|
||||
console.error('Failed to load CRM:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Sales
|
||||
async function loadSales() {
|
||||
try {
|
||||
const data = await api('/api/v1/sales/deals');
|
||||
const tbody = document.querySelector('#deals-table tbody');
|
||||
tbody.innerHTML = (data.deals || []).map(d => `
|
||||
<tr>
|
||||
<td>${d.name}</td>
|
||||
<td>${d.customer_id}</td>
|
||||
<td>${formatCurrency(d.value)}</td>
|
||||
<td><span class="status status-${d.status}">${d.status}</span></td>
|
||||
<td>${d.stage}</td>
|
||||
<td>${formatDate(d.expected_close)}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} catch (err) {
|
||||
console.error('Failed to load sales:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Finance
|
||||
async function loadFinance() {
|
||||
try {
|
||||
const data = await api('/api/v1/finance/invoices');
|
||||
const tbody = document.querySelector('#invoices-table tbody');
|
||||
tbody.innerHTML = (data.invoices || []).map(i => `
|
||||
<tr>
|
||||
<td>${i.id}</td>
|
||||
<td>${i.customer_id}</td>
|
||||
<td>${formatCurrency(i.amount)}</td>
|
||||
<td><span class="status status-${i.status}">${i.status}</span></td>
|
||||
<td>${i.due_date?.Valid ? formatDate(i.due_date.String) : '-'}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} catch (err) {
|
||||
console.error('Failed to load finance:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Support
|
||||
async function loadSupport() {
|
||||
try {
|
||||
const data = await api('/api/v1/support/tickets');
|
||||
const tbody = document.querySelector('#tickets-table tbody');
|
||||
tbody.innerHTML = (data.tickets || []).map(t => `
|
||||
<tr>
|
||||
<td>${t.subject}</td>
|
||||
<td>${t.customer_id}</td>
|
||||
<td><span class="status status-${t.priority}">${t.priority}</span></td>
|
||||
<td><span class="status status-${t.status}">${t.status}</span></td>
|
||||
<td>${t.assigned_to?.String || 'Ej tilldelad'}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
} catch (err) {
|
||||
console.error('Failed to load support:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Analytics
|
||||
async function loadAnalytics() {
|
||||
try {
|
||||
const [users, revenue, retention] = await Promise.all([
|
||||
api('/api/v1/analytics/users'),
|
||||
api('/api/v1/analytics/revenue'),
|
||||
api('/api/v1/analytics/retention')
|
||||
]);
|
||||
|
||||
document.getElementById('analytics-dau').textContent =
|
||||
(users.daily_active || 0).toLocaleString('sv-SE');
|
||||
document.getElementById('analytics-revenue').textContent =
|
||||
formatCurrency(revenue.revenue_this_month || 0);
|
||||
document.getElementById('analytics-retention').textContent =
|
||||
(retention.day_30 || 0) + '%';
|
||||
} catch (err) {
|
||||
console.error('Failed to load analytics:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Modal
|
||||
function showModal(type) {
|
||||
const modal = document.getElementById('modal');
|
||||
const title = document.getElementById('modal-title');
|
||||
const body = document.getElementById('modal-body');
|
||||
|
||||
modal.style.display = 'flex';
|
||||
|
||||
if (type === 'new-customer') {
|
||||
title.textContent = 'Ny kund';
|
||||
body.innerHTML = `
|
||||
<div class="form-group">
|
||||
<label>Namn</label>
|
||||
<input type="text" id="new-customer-name" placeholder="Företagsnamn">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>E-post</label>
|
||||
<input type="email" id="new-customer-email" placeholder="kund@foretag.se">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Telefon</label>
|
||||
<input type="tel" id="new-customer-phone" placeholder="070-123 45 67">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Status</label>
|
||||
<select id="new-customer-status">
|
||||
<option value="lead">Lead</option>
|
||||
<option value="prospect">Prospect</option>
|
||||
<option value="customer">Kund</option>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn-primary" onclick="createCustomer()">Spara</button>
|
||||
`;
|
||||
} else if (type === 'new-deal') {
|
||||
title.textContent = 'Ny deal';
|
||||
body.innerHTML = `
|
||||
<div class="form-group">
|
||||
<label>Deal-namn</label>
|
||||
<input type="text" id="new-deal-name" placeholder="Projektnamn">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Värde (SEK)</label>
|
||||
<input type="number" id="new-deal-value" placeholder="100000">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Steg</label>
|
||||
<select id="new-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="createDeal()">Spara</button>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
document.getElementById('modal').style.display = 'none';
|
||||
}
|
||||
|
||||
async function createCustomer() {
|
||||
const name = document.getElementById('new-customer-name').value;
|
||||
const email = document.getElementById('new-customer-email').value;
|
||||
const phone = document.getElementById('new-customer-phone').value;
|
||||
const status = document.getElementById('new-customer-status').value;
|
||||
|
||||
if (!name) {
|
||||
alert('Namn krävs');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api('/api/v1/crm/customers', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, email, phone, status })
|
||||
});
|
||||
|
||||
hideModal();
|
||||
loadCRM();
|
||||
} catch (err) {
|
||||
alert('Kunde inte skapa kund: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function createDeal() {
|
||||
const name = document.getElementById('new-deal-name').value;
|
||||
const value = parseFloat(document.getElementById('new-deal-value').value);
|
||||
const stage = document.getElementById('new-deal-stage').value;
|
||||
|
||||
if (!name || !value) {
|
||||
alert('Namn och värde krävs');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await api('/api/v1/sales/deals', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ name, value, stage, status: 'open' })
|
||||
});
|
||||
|
||||
hideModal();
|
||||
loadSales();
|
||||
} catch (err) {
|
||||
alert('Kunde inte skapa deal: ' + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Helpers
|
||||
function formatCurrency(value) {
|
||||
return new Intl.NumberFormat('sv-SE').format(value || 0) + ' SEK';
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
if (!dateStr) return '-';
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleDateString('sv-SE');
|
||||
}
|
||||
|
||||
function logout() {
|
||||
localStorage.removeItem('boc_token');
|
||||
window.location.href = '/login.html';
|
||||
}
|
||||
|
||||
// Init
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
if (!token && !window.location.pathname.includes('login')) {
|
||||
window.location.href = '/login.html';
|
||||
return;
|
||||
}
|
||||
|
||||
loadDashboard();
|
||||
});
|
||||
@@ -0,0 +1,204 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="sv">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>BOC Automation — Business Operations Center</title>
|
||||
<link rel="stylesheet" href="assets/boc.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<aside class="sidebar">
|
||||
<div class="sidebar-logo">🏢 BOC</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>
|
||||
</nav>
|
||||
</aside>
|
||||
|
||||
<main class="main">
|
||||
<header class="module-header">
|
||||
<h1>Automation</h1>
|
||||
<p class="subtitle">Workflows, schemalagda jobb och triggers</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>
|
||||
</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>
|
||||
</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>
|
||||
</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);
|
||||
}
|
||||
}
|
||||
|
||||
async function triggerWorkflow(id) {
|
||||
try {
|
||||
const res = await fetch(`/api/v1/automation/workflows/${id}/trigger`, { method: 'POST' });
|
||||
if (res.ok) {
|
||||
alert('Workflow triggered!');
|
||||
loadAutomation();
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to trigger workflow:', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Load on page load
|
||||
loadAutomation();
|
||||
// Refresh every 30 seconds
|
||||
setInterval(loadAutomation, 30000);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,494 @@
|
||||
<!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>
|
||||
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="0; url=dashboard.html">
|
||||
<title>BOC — Business Operations Center</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="dashboard.html">Dashboard</a>...</p>
|
||||
</body>
|
||||
</html>
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="sv">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>BOC — Logga in</title>
|
||||
<link rel="stylesheet" href="assets/boc.css">
|
||||
<style>
|
||||
.login-container {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
}
|
||||
.login-box {
|
||||
background: white;
|
||||
padding: 40px;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
|
||||
width: 100%;
|
||||
max-width: 400px;
|
||||
}
|
||||
.login-box h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 8px;
|
||||
font-size: 28px;
|
||||
}
|
||||
.login-box p {
|
||||
text-align: center;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.form-group input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
.form-group input:focus {
|
||||
outline: none;
|
||||
border-color: var(--primary);
|
||||
}
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
padding: 14px;
|
||||
background: var(--primary);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background: #0056CC;
|
||||
}
|
||||
.error {
|
||||
color: var(--danger);
|
||||
font-size: 14px;
|
||||
margin-top: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<div class="login-box">
|
||||
<h1>🏢 BOC</h1>
|
||||
<p>Business Operations Center</p>
|
||||
<form id="login-form">
|
||||
<div class="form-group">
|
||||
<label for="email">E-post</label>
|
||||
<input type="email" id="email" name="email" required
|
||||
placeholder="erik@landvex.com" value="erik@landvex.com">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Lösenord</label>
|
||||
<input type="password" id="password" name="password" required
|
||||
placeholder="••••••••" value="admin123">
|
||||
</div>
|
||||
<button type="submit" class="btn-primary">Logga in</button>
|
||||
<div id="error" class="error"></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const API_BASE = window.location.hostname === 'localhost'
|
||||
? 'http://localhost:9092'
|
||||
: 'https://boc.aamos.com';
|
||||
|
||||
document.getElementById('login-form').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const email = document.getElementById('email').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_BASE}/api/v1/auth/login`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email, password }),
|
||||
});
|
||||
|
||||
const data = await res.json();
|
||||
|
||||
if (data.token) {
|
||||
localStorage.setItem('boc_token', data.token);
|
||||
window.location.href = '/';
|
||||
} else {
|
||||
document.getElementById('error').textContent = data.error || 'Inloggning misslyckades';
|
||||
}
|
||||
} catch (err) {
|
||||
document.getElementById('error').textContent = 'Nätverksfel';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user