3.2 KiB
3.2 KiB
Site Dashboard
Purpose
Provide a per-site overview showing basic site info, stats (pages/content/integrations/deployments), and quick actions for navigation. Serves as the landing view for a specific site id.
Code Locations (exact paths)
- Page:
frontend/src/pages/Sites/Dashboard.tsx - API:
frontend/src/services/api(fetchAPIfor/v1/auth/sites/{id}/;fetchSiteStatsplaceholder) - UI:
frontend/src/components/common/{PageMeta,PageHeader,ComponentCard},frontend/src/components/dashboard/EnhancedMetricCard,frontend/src/components/sites/SiteProgressWidget,frontend/src/components/ui/{card,button}
High-Level Responsibilities
- Load a single site’s record (name/slug/type/hosting/domain/status) and display a card-based dashboard.
- Show metric cards for pages, integrations, deployments, and content counts (placeholder stats until backend endpoint exists).
- Provide quick actions to manage pages, sync, publish, or open settings.
Detailed Behavior
- Routing: expects
:idparam; usesuseParamsandfetchAPI(/v1/auth/sites/{id}/)to load site. - Stats:
fetchSiteStatscurrently returns placeholder structure (zeros); TODO noted to back with a real endpoint. - If site not found: shows “Site not found” with Back to Sites button.
- Metric cards (EnhancedMetricCard) link to pages list, published filter, draft filter, integrations tab, deployments preview, and content list.
- Quick actions: buttons for Manage Pages, View Integrations, View Content, Deployments (navigations).
- Header shows site name, slug, type, hosting, optional domain, and Settings button linking to
/sites/{id}/settings. - Loading state: spinner until data fetch completes.
Data Structures / Models Involved (no code)
- Site DTO:
id,name,slug,site_type,hosting_type,status,is_active,domain. - Stats DTO (placeholder): counts for pages/content/integrations/deployments/views/visitors.
Execution Flow
useEffectonsiteId→loadSiteData(Promise.all for site + stats) → setsite+stats.- Renders cards and actions with derived links.
Cross-Module Interactions
- Integrations quick action routes to Site Settings integrations tab.
- Content and pages links route to module pages that rely on planner/writer data scoped by site.
State Transitions
loadinggates initial fetch; absent site shows fallback card.
Error Handling
- Errors during fetch show toast (
Failed to load site data) and stop loading spinner.
Tenancy Rules
- Site fetch is account-scoped server-side; client only supplies the site id from the router.
Billing Rules (if applicable)
- None on this page.
Background Tasks / Schedulers (if applicable)
- None; no polling.
Key Design Considerations
- Uses placeholder stats until backend supplies real site analytics; structure prepared for drop-in replacement.
- Quick navigation shortcuts reduce hops for site-level operations.
How Developers Should Work With This Module
- Replace
fetchSiteStatswith a real endpoint and map returned fields intostatCards. - Add new quick actions by extending the ComponentCard grid with navigation handlers.
- Keep links consistent with router paths in
App.tsxto avoid broken navigation.