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.
This commit is contained in:
Juergen Kunz
2025-06-08 12:03:17 +00:00
parent 5faca8c1b6
commit f1fb4c8495
13 changed files with 2064 additions and 47 deletions

View File

@ -164,13 +164,13 @@ export class StatsHandler {
}
```
### Phase 3: Frontend State Management
### Phase 3: Frontend State Management
#### 3.1 Set up Smartstate (`ts_web/appstate.ts`)
#### 3.1 Set up Smartstate (`ts_web/appstate.ts`)
- [ ] Initialize Smartstate instance
- [ ] Create state parts with appropriate persistence
- [ ] Define initial state structures
- [x] Initialize Smartstate instance
- [x] Create state parts with appropriate persistence
- [x] Define initial state structures
```typescript
// State structure example
@ -184,48 +184,53 @@ interface IStatsState {
}
```
#### 3.2 State Parts to Create
#### 3.2 State Parts to Create
- [ ] `statsState` - Runtime statistics (soft persistence)
- [ ] `configState` - Configuration data (soft persistence)
- [ ] `uiState` - UI preferences (persistent)
- [ ] `loginState` - Authentication state (persistent) *if needed*
- [x] `statsState` - Runtime statistics (soft persistence)
- [x] `configState` - Configuration data (soft persistence)
- [x] `uiState` - UI preferences (persistent)
- [x] `loginState` - Authentication state (persistent)
### Phase 4: Frontend Integration
### Phase 4: Frontend Integration
#### 4.1 API Client Setup (`ts_web/api/clients.ts`)
#### 4.1 API Client Setup
- [ ] Create TypedRequest instances for each endpoint
- [ ] Configure base URL handling
- [ ] Add error interceptors
- [ ] Implement retry logic
- [x] TypedRequest instances created inline within actions
- [x] Base URL handled through relative paths
- [x] Error handling integrated in actions
- [x] Following cloudly pattern of creating requests within actions
#### 4.2 Create Actions (`ts_web/state/actions.ts`)
#### 4.2 Create Actions (`ts_web/appstate.ts`)
- [ ] `fetchAllStatsAction` - Batch fetch all statistics
- [ ] `refreshServerStatsAction` - Update server stats only
- [ ] `refreshEmailStatsAction` - Update email stats only
- [ ] `setAutoRefreshAction` - Toggle auto-refresh
- [ ] Error handling actions
- [x] `loginAction` - Authentication with JWT
- [x] `logoutAction` - Clear authentication state
- [x] `fetchAllStatsAction` - Batch fetch all statistics
- [x] `fetchConfigurationAction` - Get configuration
- [x] `updateConfigurationAction` - Update configuration
- [x] `fetchRecentLogsAction` - Get recent logs
- [x] `toggleAutoRefreshAction` - Toggle auto-refresh
- [x] `setActiveViewAction` - Change active view
- [x] Error handling in all actions
#### 4.3 Update Dashboard Component (`ts_web/elements/ops-dashboard.ts`)
#### 4.3 Update Dashboard Component (`ts_web/elements/ops-dashboard.ts`)
- [ ] Subscribe to state changes
- [ ] Implement reactive UI updates
- [ ] Add refresh controls
- [ ] Create sub-components for different stat types
- [ ] Implement auto-refresh timer
- [x] Subscribe to state changes (login and UI state)
- [x] Implement reactive UI updates
- [x] Use dees-simple-login and dees-simple-appdash components
- [x] Create view components for different sections
- [x] Implement auto-refresh timer functionality
### Phase 5: Component Structure
### Phase 5: Component Structure
Create modular components in `ts_web/elements/components/`:
Created modular view components in `ts_web/elements/`:
- [ ] `server-stats.ts` - Server statistics display
- [ ] `email-stats.ts` - Email metrics visualization
- [ ] `dns-stats.ts` - DNS statistics
- [ ] `rate-limit-display.ts` - Rate limiting status
- [ ] `security-metrics.ts` - Security dashboard
- [ ] `log-viewer.ts` - Real-time log display
- [x] `ops-view-overview.ts` - Overview with server, email, and DNS statistics
- [x] `ops-view-stats.ts` - Detailed statistics with tables and metrics
- [x] `ops-view-logs.ts` - Log viewer with filtering and search
- [x] `ops-view-config.ts` - Configuration editor with JSON editing
- [x] `ops-view-security.ts` - Security metrics and threat monitoring
- [x] `shared/ops-sectionheading.ts` - Reusable section heading component
- [x] `shared/css.ts` - Shared CSS styles
### Phase 6: Optional Enhancements
@ -314,10 +319,32 @@ Create modular components in `ts_web/elements/components/`:
- Added guard helpers for protecting endpoints
- Full test coverage for JWT authentication flows
- **Phase 3: Frontend State Management** - Smartstate implementation
- Initialized Smartstate with proper state parts
- Created state interfaces for all data types
- Implemented persistent vs soft state persistence
- Set up reactive subscriptions
- **Phase 4: Frontend Integration** - Complete dashboard implementation
- Created all state management actions with TypedRequest
- Implemented JWT authentication flow in frontend
- Built reactive dashboard with dees-simple-login and dees-simple-appdash
- Added auto-refresh functionality
- Fixed all interface import issues (using dist_ts_interfaces)
- **Phase 5: Component Structure** - View components
- Created all view components following cloudly patterns
- Implemented reactive data binding with state subscriptions
- Added interactive features (filtering, editing, refresh controls)
- Used @design.estate/dees-catalog components throughout
- Created shared components and styles
### Next Steps
- Phase 3: Frontend State Management - Set up Smartstate
- Phase 4: Frontend Integration - Create API clients and update dashboard
- Phase 5: Create modular UI components
- Write comprehensive tests for handlers and frontend components
- Implement real data sources (replace mock data)
- Add WebSocket support for real-time updates
- Enhance error handling and user feedback
- Add more detailed charts and visualizations
---