Overview
The Dashboard module serves as the main landing page for authenticated users, displaying Power BI reports embedded directly in the application. It handles authentication tokens, report filtering, and provides a tabbed interface for multiple reports. Controller:DashboardController (app/Http/Controllers/DashboardController.php:11)Vue Component:
resources/js/Pages/Dashboard.vueTrait:
PowerBITrait (app/Traits/PowerBITrait.php)
Key Features
Embedded Power BI
Seamlessly embed Power BI reports with automatic token management
User-Specific Reports
Display only reports assigned to the authenticated user
Auto Token Refresh
Automatically refresh expired Power BI access tokens
Tabbed Interface
Organize multiple reports in an intuitive tabbed layout
Dashboard Interface
The dashboard provides a clean, organized view of all assigned Power BI reports:Tabbed Navigation
- Each report appears as a separate tab
- Active tab displays the embedded report
- Tab titles show report names
- First report is selected by default
Empty State
If no reports are assigned, displays a welcome component instead of tabs. Vue Implementation: Dashboard.vue:12-16API Endpoint
View Dashboard
auth:sanctum middleware)Email Verification Required: Yes (
verified middleware)
Implementation: DashboardController.php:20-41
Report Loading Process
Refresh Tokens
If token is expired, request new embed token from Power BI API using
getReportAccessToken().Build Embed URL
Construct Power BI embed URL:
https://app.powerbi.com/reportEmbed?reportId={reportId}&groupId={groupId}Report Data Structure
Each report object passed to the frontend includes:Token Management
The dashboard implements automatic token refresh to ensure uninterrupted report access:Token Validation
- Check if report has no token OR token is expired
- Request new embed token from Power BI API
- Update report record with new token and expiration
- Continue rendering
Power BI Trait Methods
ThePowerBITrait provides reusable methods for Power BI integration:
getUserAccessToken(): Authenticate with Power BI service and get user-level tokengetReportAccessToken($userToken, $report): Generate embed token for specific report- Token caching and refresh logic
Report Assignment
Reports are assigned to users through theuser_reports pivot table:
Pivot Table Columns
user_id: Foreign key to users tablereport_id: Foreign key to reports tableshow: Boolean flag controlling dashboard visibility
show = true.
Report Viewer Component
The dashboard uses aReportViewer component to render embedded Power BI reports:
- Embeds Power BI JavaScript SDK
- Handles report initialization
- Manages report interactions
- Applies user-specific filters
User-Specific Filtering
Reports can have user-specific filters applied through theReport model’s filter_array attribute:
Route Configuration
Dashboard route in routes/web.php:41-42:auth:sanctum, auth_session, verified
Error Handling
The dashboard gracefully handles common scenarios:No Reports Assigned
Displays welcome component instead of empty tab bar.Token Refresh Failure
If Power BI API fails to generate embed token:- Error is caught in
getReportAccessToken()method - Report may fail to load
- User should contact administrator
Expired User Token
If user access token expires:getUserAccessToken()automatically requests new token- Process is transparent to user
Performance Considerations
Token Caching: Embed tokens are cached in the database (
reports.token) to minimize API calls to Power BI. Tokens are only refreshed when expired.Lazy Loading: Reports are loaded on-demand when tabs are clicked, reducing initial page load time for users with many reports.
Related Modules
Reports
Manage Power BI report configurations and assignments
Users
Assign reports to users and control dashboard visibility
Report Filters
Configure user-specific report filters
Customization
The dashboard interface can be customized:Tab Variant
Current implementation usesvariant="underline" for tabs. Can be changed to:
pillsdefaultfull-width