Admin Dashboard
Relevant source files
The following files were used as context for generating this wiki page:- README.md
- packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts
- packages/admin-web-angular/src/app/pages/+dashboard/dashboard.stories.ts
- packages/admin-web-angular/angular.json
- packages/admin-web-angular/package.json
- packages/admin-web-angular/src/app/app.module.ts
- packages/admin-web-angular/CREDITS.md
The Admin Dashboard is the central administrative interface for the Ever Demand platform. It provides a high-level, real-time overview of business operations, focusing on data visualization for orders and profits. Built with Angular and based on the ngx-admin template, it serves as the primary tool for managers to monitor and control platform activities. The dashboard is designed to be reactive, allowing for dynamic filtering of data, such as viewing metrics for a specific store.
The Admin Website is one of the key headless implementations of the platform, providing a web-based interface to manage all platform features and settings.
Sources: README.md, packages/admin-web-angular/CREDITS.md
Architecture and Core Components
The Admin Dashboard is encapsulated within the DashboardModule, an Angular feature module. This module lazy-loads its own components, services, and dependencies, ensuring the main application bundle remains lean. It heavily relies on the Nebular ThemeModule for UI components and ngx-echarts for data visualization.
Sources: packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts
Module Structure
The DashboardModule orchestrates the various parts of the dashboard, including chart components, data services, and UI elements.
The following diagram illustrates the key components and services defined within the DashboardModule.
Component Hierarchy
The dashboard is composed of several nested components, creating a structured and maintainable user interface. The DashboardComponent acts as the main container.
This diagram shows the hierarchical relationship between the dashboard components.
Key Components and Services
The module declares several components and provides services to manage the dashboard's state and data.
| Type | Name | Description |
|---|---|---|
| Component | DashboardComponent | The main container for the dashboard page. |
| Component | ChartsPanelComponent | A panel that holds all the chart-related components. |
| Component | ChartPanelHeaderComponent | Header for the charts panel, includes period selection (e.g., Week, Month). |
| Component | ChartPanelSummaryComponent | Displays summary data, likely as stat cards. |
| Component | OrdersChartComponent | A chart component for visualizing order data. |
| Component | ProfitChartComponent | A chart component for visualizing profit data. |
| Component | DashboardSelectStoreComponent | A dropdown to filter dashboard data by a specific store. |
| Service | LayoutService | Manages dashboard layout, possibly for responsive design. |
| Service | OrdersProfitChartService | Service to fetch and process data for both orders and profit charts. |
| Service | OrdersChartService | Service dedicated to fetching data for the orders chart. |
| Service | ProfitChartService | Service dedicated to fetching data for the profit chart. |
| Service | PeriodsService | Manages the available time periods for filtering chart data. |
Sources: packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts:55-71
Data Visualization and Charting
Data visualization is a core feature of the Admin Dashboard, primarily achieved using the ngx-echarts library, which is a wrapper for Apache ECharts. The project configuration also includes chart.js, indicating potential use of multiple charting libraries across the application.
Sources: packages/admin-web-angular/angular.json:58-60, packages/admin-web-angular/package.json:115, packages/admin-web-angular/src/app/app.module.ts:71-77
The DashboardModule specifically imports and configures NgxEchartsModule for its charting needs.
// packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts:44-48
@NgModule({
imports: [
// ...
NgxEchartsModule.forRoot({
echarts: () => import('echarts')
}),
// ...
],
//...
Sources: packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts:44-48
The primary chart components are:
OrdersChartComponent: Renders a chart displaying order volumes over a selected period.ProfitChartComponent: Renders a chart displaying profit margins over a selected period.
These components receive their data from dedicated services (OrdersChartService, ProfitChartService) which handle the logic for fetching and preparing data for visualization.
Services and Data Flow
The dashboard's functionality is driven by a set of injectable services that manage state, data fetching, and business logic. The data flow is typically initiated by user interaction, such as selecting a store or changing the time period.
The following sequence diagram illustrates a typical data flow when a user interacts with the dashboard.
This data flow is inferred from the service and component names in dashboard.module.ts and dashboard.stories.ts.
Sources: packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts:68-71, packages/admin-web-angular/src/app/pages/+dashboard/dashboard.stories.ts:133-137
Dependencies and Configuration
The DashboardModule relies on several other Angular modules and third-party libraries to function.
Module Imports
| Module | Purpose |
|---|---|
CommonModule | Provides common Angular directives like ngIf and ngFor. |
ThemeModule | Provides Nebular UI components and theming for a consistent look. |
NgxEchartsModule | Integrates the ECharts library for data visualization. |
ToasterModule | Used for displaying toast notifications. |
TranslateModule | Handles internationalization (i18n) for text content. |
RouterModule | Defines the route for the DashboardComponent. |
NbSpinnerModule | Displays a loading spinner, likely used while charts are loading. |
PipesModule | Contains custom pipes for data formatting (e.g., currency, dates). |
NgSelectModule | Provides the rich select dropdown for the store filter. |
FormsModule | Provides template-driven forms support, used by ng-select. |
Sources: packages/admin-web-angular/src/app/pages/+dashboard/dashboard.module.ts:43-54
Build Configuration
The main angular.json file for the admin application defines global scripts and styles that are essential for the dashboard. This includes the core charting libraries and UI frameworks.
- Styles:
bootstrap.css,pace-theme-flash.tmpl.css,styles.scss(theme styles). - Scripts:
pace.min.js(for page load indicators),echarts.min.js,chart.min.js.