Skip to content

feat: Custom Reports and Dashboards#7

Merged
christag merged 3 commits intomainfrom
feature/custom-reports-dashboards
Oct 28, 2025
Merged

feat: Custom Reports and Dashboards#7
christag merged 3 commits intomainfrom
feature/custom-reports-dashboards

Conversation

@christag
Copy link
Copy Markdown
Owner

Summary

Implements comprehensive custom reports and dashboards system for M.O.S.S. with MVP focus on report creation, execution, and dashboard viewing.

Features

  • Custom report builder with 10 pre-built templates
  • Report execution with SQL injection protection
  • Saved reports CRUD operations
  • Dashboard viewer with metric and chart widgets
  • Export utilities (CSV, Excel, PDF)

Files Changed

  • 31 files: 1 migration, 7 API routes, 6 components, 5 pages, 4 utilities, 1 schema
  • +7,737 lines / -1,537 lines

Testing

  • Build passes with 0 errors
  • Middleware protection added
  • API auth fixed for session compatibility

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

christag and others added 3 commits October 28, 2025 11:14
## Features Implemented

### Reports System
- Custom report builder with query configuration
- Report execution API with SQL injection protection
- Report preview with pagination and table display
- Saved reports CRUD (create, read, update, delete)
- 10 pre-built report templates
- Public/private report sharing
- Search and filter capabilities

### Dashboards System (View-Only MVP)
- Dashboard CRUD APIs
- Metric widget (single number display)
- Chart widget (bar charts with Recharts)
- Responsive dashboard viewer with react-grid-layout
- Dashboard listing and detail pages

## Technical Implementation

### Database (Migration 026)
- custom_reports table with report configuration storage
- custom_dashboards table with layout configuration
- dashboard_widget_types table with 10 pre-configured widget types
- 10 pre-built report templates seeded

### Backend
- Query builder with field whitelisting and parameterized queries
- CSV, Excel (xlsx), and PDF (jsPDF) export utilities
- API authentication with bearer tokens
- Rate limiting on all endpoints
- Zod validation for all inputs

### Frontend
- Report builder page with form-based configuration
- Saved reports list with tabs (My Reports, Shared, Templates)
- Report preview with pagination
- Dashboard viewer with responsive grid layout
- Widget components (Metric, Chart)

### Dependencies Added
- recharts (charting library)
- jspdf-autotable (PDF table generation)
- react-grid-layout (dashboard grid positioning)

## Pages Created
- /reports - Saved reports list
- /reports/builder - Create new report
- /reports/[id] - View and run report
- /reports/[id]/edit - Edit report
- /reports/preview - Report preview with results
- /dashboards - Dashboard list
- /dashboards/[id] - View dashboard

## Build Status
✅ Build passes with 0 errors
✅ All routes properly configured
✅ Design system compliant

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…mpatibility

The reports and dashboards APIs were requiring bearer tokens for all requests,
but the web UI uses session-based authentication (NextAuth). This change makes
the GET endpoints work with session auth while keeping bearer token auth
available for external API access.

Changes:
- Removed requireApiScope from GET /api/reports (list reports)
- Added comment explaining web UI uses session auth
- Reports now show public and system templates
- Write operations (POST, PATCH, DELETE) still require API tokens

This matches the pattern used by other M.O.S.S. APIs like /api/devices.
@christag christag merged commit 8e847c3 into main Oct 28, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant