feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
import * as plugins from '../plugins.js';
|
|
|
|
|
import * as shared from './shared/index.js';
|
|
|
|
|
import * as appstate from '../appstate.js';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
customElement,
|
|
|
|
|
html,
|
|
|
|
|
state,
|
|
|
|
|
css,
|
|
|
|
|
cssManager,
|
2025-06-12 08:04:30 +00:00
|
|
|
type TemplateResult,
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
} from '@design.estate/dees-element';
|
2025-06-12 08:04:30 +00:00
|
|
|
import { type IStatsTile } from '@design.estate/dees-catalog';
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
|
|
|
|
|
@customElement('ops-view-overview')
|
|
|
|
|
export class OpsViewOverview extends DeesElement {
|
|
|
|
|
@state()
|
2026-02-01 19:21:37 +00:00
|
|
|
accessor statsState: appstate.IStatsState = {
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
serverStats: null,
|
|
|
|
|
emailStats: null,
|
|
|
|
|
dnsStats: null,
|
|
|
|
|
securityMetrics: null,
|
|
|
|
|
lastUpdated: 0,
|
|
|
|
|
isLoading: false,
|
|
|
|
|
error: null,
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-19 17:23:43 +00:00
|
|
|
@state()
|
|
|
|
|
accessor logState: appstate.ILogState = {
|
|
|
|
|
recentLogs: [],
|
|
|
|
|
isStreaming: false,
|
|
|
|
|
filters: {},
|
|
|
|
|
};
|
|
|
|
|
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
constructor() {
|
|
|
|
|
super();
|
2026-02-19 17:23:43 +00:00
|
|
|
const statsSub = appstate.statsStatePart
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
.select((stateArg) => stateArg)
|
|
|
|
|
.subscribe((statsState) => {
|
|
|
|
|
this.statsState = statsState;
|
|
|
|
|
});
|
2026-02-19 17:23:43 +00:00
|
|
|
this.rxSubscriptions.push(statsSub);
|
|
|
|
|
|
|
|
|
|
const logSub = appstate.logStatePart
|
|
|
|
|
.select((stateArg) => stateArg)
|
|
|
|
|
.subscribe((logState) => {
|
|
|
|
|
this.logState = logState;
|
|
|
|
|
});
|
|
|
|
|
this.rxSubscriptions.push(logSub);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async connectedCallback() {
|
|
|
|
|
super.connectedCallback();
|
|
|
|
|
// Ensure logs are fetched for the overview charts
|
|
|
|
|
if (this.logState.recentLogs.length === 0) {
|
|
|
|
|
appstate.logStatePart.dispatchAction(appstate.fetchRecentLogsAction, { limit: 100 });
|
|
|
|
|
}
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
|
shared.viewHostCss,
|
|
|
|
|
css`
|
2025-06-12 08:04:30 +00:00
|
|
|
h2 {
|
|
|
|
|
margin: 32px 0 16px 0;
|
|
|
|
|
font-size: 24px;
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
font-weight: 600;
|
2025-06-19 12:14:52 +00:00
|
|
|
color: ${cssManager.bdTheme('#333', '#ccc')};
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.chartGrid {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(2, 1fr);
|
|
|
|
|
grid-gap: 16px;
|
|
|
|
|
margin-top: 32px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.loadingMessage {
|
|
|
|
|
text-align: center;
|
|
|
|
|
padding: 40px;
|
2025-06-19 12:14:52 +00:00
|
|
|
color: ${cssManager.bdTheme('#666', '#999')};
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.errorMessage {
|
2025-06-19 12:14:52 +00:00
|
|
|
background-color: ${cssManager.bdTheme('#fee', '#4a1f1f')};
|
|
|
|
|
border: 1px solid ${cssManager.bdTheme('#fcc', '#6a2f2f')};
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
border-radius: 4px;
|
|
|
|
|
padding: 16px;
|
2025-06-19 12:14:52 +00:00
|
|
|
color: ${cssManager.bdTheme('#c00', '#ff6666')};
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
margin: 16px 0;
|
|
|
|
|
}
|
2025-06-12 08:04:30 +00:00
|
|
|
|
|
|
|
|
dees-statsgrid {
|
|
|
|
|
margin-bottom: 32px;
|
|
|
|
|
}
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
|
return html`
|
|
|
|
|
<ops-sectionheading>Overview</ops-sectionheading>
|
|
|
|
|
|
|
|
|
|
${this.statsState.isLoading ? html`
|
|
|
|
|
<div class="loadingMessage">
|
|
|
|
|
<dees-spinner></dees-spinner>
|
|
|
|
|
<p>Loading statistics...</p>
|
|
|
|
|
</div>
|
|
|
|
|
` : this.statsState.error ? html`
|
|
|
|
|
<div class="errorMessage">
|
|
|
|
|
Error loading statistics: ${this.statsState.error}
|
|
|
|
|
</div>
|
|
|
|
|
` : html`
|
2025-06-12 08:04:30 +00:00
|
|
|
${this.renderServerStats()}
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
|
2025-06-12 08:04:30 +00:00
|
|
|
${this.renderEmailStats()}
|
|
|
|
|
|
|
|
|
|
${this.renderDnsStats()}
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
|
|
|
|
|
<div class="chartGrid">
|
2026-02-19 17:23:43 +00:00
|
|
|
<dees-chart-area
|
|
|
|
|
.label=${'Email Traffic (24h)'}
|
|
|
|
|
.series=${this.getEmailTrafficSeries()}
|
|
|
|
|
.yAxisFormatter=${(val: number) => `${val}`}
|
|
|
|
|
></dees-chart-area>
|
|
|
|
|
<dees-chart-area
|
|
|
|
|
.label=${'DNS Queries (24h)'}
|
|
|
|
|
.series=${this.getDnsQuerySeries()}
|
|
|
|
|
.yAxisFormatter=${(val: number) => `${val}`}
|
|
|
|
|
></dees-chart-area>
|
|
|
|
|
<dees-chart-log
|
|
|
|
|
.label=${'Recent Events'}
|
|
|
|
|
.logEntries=${this.getRecentEventEntries()}
|
|
|
|
|
></dees-chart-log>
|
|
|
|
|
<dees-chart-log
|
|
|
|
|
.label=${'Security Alerts'}
|
|
|
|
|
.logEntries=${this.getSecurityAlertEntries()}
|
|
|
|
|
></dees-chart-log>
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
</div>
|
|
|
|
|
`}
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private formatUptime(seconds: number): string {
|
|
|
|
|
const days = Math.floor(seconds / 86400);
|
|
|
|
|
const hours = Math.floor((seconds % 86400) / 3600);
|
|
|
|
|
const minutes = Math.floor((seconds % 3600) / 60);
|
2025-06-10 16:09:41 +00:00
|
|
|
const secs = Math.floor(seconds % 60);
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
|
|
|
|
|
if (days > 0) {
|
2025-06-10 16:09:41 +00:00
|
|
|
return `${days}d ${hours}h ${minutes}m ${secs}s`;
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
} else if (hours > 0) {
|
2025-06-10 16:09:41 +00:00
|
|
|
return `${hours}h ${minutes}m ${secs}s`;
|
|
|
|
|
} else if (minutes > 0) {
|
|
|
|
|
return `${minutes}m ${secs}s`;
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
} else {
|
2025-06-10 16:09:41 +00:00
|
|
|
return `${secs}s`;
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private formatBytes(bytes: number): string {
|
|
|
|
|
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
|
|
|
let size = bytes;
|
|
|
|
|
let unitIndex = 0;
|
2026-02-13 14:19:19 +00:00
|
|
|
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
while (size >= 1024 && unitIndex < units.length - 1) {
|
|
|
|
|
size /= 1024;
|
|
|
|
|
unitIndex++;
|
|
|
|
|
}
|
2026-02-13 14:19:19 +00:00
|
|
|
|
|
|
|
|
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private formatBitsPerSecond(bytesPerSecond: number): string {
|
|
|
|
|
const bitsPerSecond = bytesPerSecond * 8;
|
|
|
|
|
const units = ['bit/s', 'kbit/s', 'Mbit/s', 'Gbit/s'];
|
|
|
|
|
let size = bitsPerSecond;
|
|
|
|
|
let unitIndex = 0;
|
|
|
|
|
|
|
|
|
|
while (size >= 1000 && unitIndex < units.length - 1) {
|
|
|
|
|
size /= 1000;
|
|
|
|
|
unitIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
|
|
|
|
}
|
2025-06-12 08:04:30 +00:00
|
|
|
|
|
|
|
|
private renderServerStats(): TemplateResult {
|
|
|
|
|
if (!this.statsState.serverStats) return html``;
|
|
|
|
|
|
2025-06-12 11:22:18 +00:00
|
|
|
const cpuUsage = Math.round(this.statsState.serverStats.cpuUsage.user);
|
|
|
|
|
const memoryUsage = this.statsState.serverStats.memoryUsage.actualUsagePercentage !== undefined
|
|
|
|
|
? Math.round(this.statsState.serverStats.memoryUsage.actualUsagePercentage)
|
|
|
|
|
: Math.round((this.statsState.serverStats.memoryUsage.heapUsed / this.statsState.serverStats.memoryUsage.heapTotal) * 100);
|
2025-06-12 08:04:30 +00:00
|
|
|
|
|
|
|
|
const tiles: IStatsTile[] = [
|
|
|
|
|
{
|
|
|
|
|
id: 'status',
|
|
|
|
|
title: 'Server Status',
|
|
|
|
|
value: this.statsState.serverStats.uptime ? 'Online' : 'Offline',
|
|
|
|
|
type: 'text',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Server',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: this.statsState.serverStats.uptime ? '#22c55e' : '#ef4444',
|
|
|
|
|
description: `Uptime: ${this.formatUptime(this.statsState.serverStats.uptime)}`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'connections',
|
|
|
|
|
title: 'Active Connections',
|
|
|
|
|
value: this.statsState.serverStats.activeConnections,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Network',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#3b82f6',
|
|
|
|
|
description: `Total: ${this.statsState.serverStats.totalConnections}`,
|
|
|
|
|
},
|
2026-02-13 14:19:19 +00:00
|
|
|
{
|
|
|
|
|
id: 'throughputIn',
|
|
|
|
|
title: 'Throughput In',
|
|
|
|
|
value: this.formatBitsPerSecond(this.statsState.serverStats.throughput?.bytesInPerSecond || 0),
|
|
|
|
|
type: 'text',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Download',
|
2026-02-13 14:19:19 +00:00
|
|
|
color: '#22c55e',
|
|
|
|
|
description: `Total: ${this.formatBytes(this.statsState.serverStats.throughput?.bytesIn || 0)}`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'throughputOut',
|
|
|
|
|
title: 'Throughput Out',
|
|
|
|
|
value: this.formatBitsPerSecond(this.statsState.serverStats.throughput?.bytesOutPerSecond || 0),
|
|
|
|
|
type: 'text',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Upload',
|
2026-02-13 14:19:19 +00:00
|
|
|
color: '#8b5cf6',
|
|
|
|
|
description: `Total: ${this.formatBytes(this.statsState.serverStats.throughput?.bytesOut || 0)}`,
|
|
|
|
|
},
|
2025-06-12 08:04:30 +00:00
|
|
|
{
|
|
|
|
|
id: 'cpu',
|
|
|
|
|
title: 'CPU Usage',
|
|
|
|
|
value: cpuUsage,
|
|
|
|
|
type: 'gauge',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Cpu',
|
2025-06-12 08:04:30 +00:00
|
|
|
gaugeOptions: {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 100,
|
|
|
|
|
thresholds: [
|
|
|
|
|
{ value: 0, color: '#22c55e' },
|
|
|
|
|
{ value: 60, color: '#f59e0b' },
|
|
|
|
|
{ value: 80, color: '#ef4444' },
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'memory',
|
|
|
|
|
title: 'Memory Usage',
|
|
|
|
|
value: memoryUsage,
|
|
|
|
|
type: 'percentage',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:MemoryStick',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: memoryUsage > 80 ? '#ef4444' : memoryUsage > 60 ? '#f59e0b' : '#22c55e',
|
2025-06-12 11:22:18 +00:00
|
|
|
description: this.statsState.serverStats.memoryUsage.actualUsageBytes !== undefined && this.statsState.serverStats.memoryUsage.maxMemoryMB !== undefined
|
|
|
|
|
? `${this.formatBytes(this.statsState.serverStats.memoryUsage.actualUsageBytes)} / ${this.formatBytes(this.statsState.serverStats.memoryUsage.maxMemoryMB * 1024 * 1024)}`
|
|
|
|
|
: `${this.formatBytes(this.statsState.serverStats.memoryUsage.rss)} / ${this.formatBytes(this.statsState.serverStats.memoryUsage.heapTotal)}`,
|
2025-06-12 08:04:30 +00:00
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<dees-statsgrid
|
|
|
|
|
.tiles=${tiles}
|
|
|
|
|
.gridActions=${[
|
|
|
|
|
{
|
|
|
|
|
name: 'Refresh',
|
2026-02-17 10:57:27 +00:00
|
|
|
iconName: 'lucide:RefreshCw',
|
2025-06-12 08:04:30 +00:00
|
|
|
action: async () => {
|
|
|
|
|
await appstate.statsStatePart.dispatchAction(appstate.fetchAllStatsAction, null);
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
></dees-statsgrid>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderEmailStats(): TemplateResult {
|
|
|
|
|
if (!this.statsState.emailStats) return html``;
|
|
|
|
|
|
|
|
|
|
const deliveryRate = this.statsState.emailStats.deliveryRate || 0;
|
|
|
|
|
const bounceRate = this.statsState.emailStats.bounceRate || 0;
|
|
|
|
|
|
|
|
|
|
const tiles: IStatsTile[] = [
|
|
|
|
|
{
|
|
|
|
|
id: 'sent',
|
|
|
|
|
title: 'Emails Sent',
|
|
|
|
|
value: this.statsState.emailStats.sent,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Send',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#22c55e',
|
|
|
|
|
description: `Delivery rate: ${(deliveryRate * 100).toFixed(1)}%`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'received',
|
|
|
|
|
title: 'Emails Received',
|
|
|
|
|
value: this.statsState.emailStats.received,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Mail',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#3b82f6',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'queued',
|
|
|
|
|
title: 'Queued',
|
|
|
|
|
value: this.statsState.emailStats.queued,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Clock',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#f59e0b',
|
|
|
|
|
description: 'Pending delivery',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'failed',
|
|
|
|
|
title: 'Failed',
|
|
|
|
|
value: this.statsState.emailStats.failed,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:TriangleAlert',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#ef4444',
|
|
|
|
|
description: `Bounce rate: ${(bounceRate * 100).toFixed(1)}%`,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<h2>Email Statistics</h2>
|
|
|
|
|
<dees-statsgrid .tiles=${tiles}></dees-statsgrid>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private renderDnsStats(): TemplateResult {
|
|
|
|
|
if (!this.statsState.dnsStats) return html``;
|
|
|
|
|
|
|
|
|
|
const cacheHitRate = Math.round(this.statsState.dnsStats.cacheHitRate * 100);
|
|
|
|
|
|
|
|
|
|
const tiles: IStatsTile[] = [
|
|
|
|
|
{
|
|
|
|
|
id: 'queries',
|
|
|
|
|
title: 'DNS Queries',
|
|
|
|
|
value: this.statsState.dnsStats.totalQueries,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Globe',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#3b82f6',
|
|
|
|
|
description: 'Total queries handled',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'cacheRate',
|
|
|
|
|
title: 'Cache Hit Rate',
|
|
|
|
|
value: cacheHitRate,
|
|
|
|
|
type: 'percentage',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Database',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: cacheHitRate > 80 ? '#22c55e' : cacheHitRate > 60 ? '#f59e0b' : '#ef4444',
|
|
|
|
|
description: `${this.statsState.dnsStats.cacheHits} hits / ${this.statsState.dnsStats.cacheMisses} misses`,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'domains',
|
|
|
|
|
title: 'Active Domains',
|
|
|
|
|
value: this.statsState.dnsStats.activeDomains,
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:Network',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: '#8b5cf6',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'responseTime',
|
|
|
|
|
title: 'Avg Response Time',
|
|
|
|
|
value: this.statsState.dnsStats.averageResponseTime.toFixed(1),
|
|
|
|
|
unit: 'ms',
|
|
|
|
|
type: 'number',
|
2026-02-17 10:57:27 +00:00
|
|
|
icon: 'lucide:History',
|
2025-06-12 08:04:30 +00:00
|
|
|
color: this.statsState.dnsStats.averageResponseTime < 50 ? '#22c55e' : '#f59e0b',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<h2>DNS Statistics</h2>
|
|
|
|
|
<dees-statsgrid .tiles=${tiles}></dees-statsgrid>
|
|
|
|
|
`;
|
|
|
|
|
}
|
2026-02-19 17:23:43 +00:00
|
|
|
|
|
|
|
|
// --- Chart data helpers ---
|
|
|
|
|
|
|
|
|
|
private getRecentEventEntries(): Array<{ timestamp: string; level: 'debug' | 'info' | 'warn' | 'error' | 'success'; message: string; source?: string }> {
|
|
|
|
|
return this.logState.recentLogs.map((log) => ({
|
|
|
|
|
timestamp: new Date(log.timestamp).toISOString(),
|
|
|
|
|
level: log.level as 'debug' | 'info' | 'warn' | 'error',
|
|
|
|
|
message: log.message,
|
|
|
|
|
source: log.category,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private getSecurityAlertEntries(): Array<{ timestamp: string; level: 'debug' | 'info' | 'warn' | 'error' | 'success'; message: string; source?: string }> {
|
|
|
|
|
const events: any[] = this.statsState.securityMetrics?.recentEvents || [];
|
|
|
|
|
return events.map((evt: any) => ({
|
|
|
|
|
timestamp: new Date(evt.timestamp).toISOString(),
|
|
|
|
|
level: evt.level === 'critical' || evt.level === 'error' ? 'error' as const : evt.level === 'warn' ? 'warn' as const : 'info' as const,
|
|
|
|
|
message: evt.message,
|
|
|
|
|
source: evt.type,
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private getEmailTrafficSeries(): Array<{ name: string; color: string; data: Array<{ x: number; y: number }> }> {
|
|
|
|
|
const ts = this.statsState.emailStats?.timeSeries;
|
|
|
|
|
if (!ts) return [];
|
|
|
|
|
return [
|
|
|
|
|
{ name: 'Sent', color: '#22c55e', data: (ts.sent || []).map((p: any) => ({ x: p.timestamp, y: p.value })) },
|
|
|
|
|
{ name: 'Received', color: '#3b82f6', data: (ts.received || []).map((p: any) => ({ x: p.timestamp, y: p.value })) },
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private getDnsQuerySeries(): Array<{ name: string; color: string; data: Array<{ x: number; y: number }> }> {
|
|
|
|
|
const ts = this.statsState.dnsStats?.timeSeries;
|
|
|
|
|
if (!ts) return [];
|
|
|
|
|
return [
|
|
|
|
|
{ name: 'Queries', color: '#8b5cf6', data: (ts.queries || []).map((p: any) => ({ x: p.timestamp, y: p.value })) },
|
|
|
|
|
];
|
|
|
|
|
}
|
feat: Add operations view components for logs, overview, security, and stats
- Implemented `ops-view-logs` for displaying and filtering logs with streaming capabilities.
- Created `ops-view-overview` to show server, email, DNS statistics, and charts.
- Developed `ops-view-security` for monitoring security metrics, blocked IPs, and authentication attempts.
- Added `ops-view-stats` to present comprehensive statistics on server, email, DNS, and security metrics.
- Introduced shared styles and components including `ops-sectionheading` for consistent UI.
2025-06-08 12:03:17 +00:00
|
|
|
}
|