-
Notifications
You must be signed in to change notification settings - Fork 0
Feature dashboard #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…board feature. It sets up HtDataClient and HtDataRepository for the DashboardSummary model, providing both in-memory (for demo mode) and API-based (for development/production) implementations. The new HtDataRepository<DashboardSummary> is now provided to the application's widget tree via RepositoryProvider, making it accessible for the upcoming DashboardBloc.
…d feature. It includes: - DashboardState: Defines the possible states for the dashboard UI (initial, loading, success, failure) and holds the - DashboardSummary data. - DashboardEvent: Defines the events that can be dispatched to the BLoC, starting with DashboardSummaryLoaded. - DashboardBloc: Manages the dashboard's state by fetching summary data from the HtDataRepository<DashboardSummary> and emitting the appropriate states. dashboard.dart: A barrel file for easy importing of BLoC components. The new DashboardBloc has also been registered in app.dart using BlocProvider, making it available throughout the widget tree for the upcoming UI implementation.
… the dashboard. It includes: - Localization: New strings for dashboard-specific labels, loading states, and error messages have been added to the .arb files and localization classes. - UI Implementation: The DashboardPage is now a stateful widget that fetches data on initialization. It uses a BlocBuilder to react to the DashboardState. - State Handling: The UI correctly displays a LoadingStateWidget while fetching data and a FailureStateWidget if an error occurs, with a functional retry button. - Summary Cards: On success, the page displays a row of three _SummaryCard widgets, presenting the total counts for headlines, categories, and sources. This card is a private, reusable component designed for clarity and consistency, adhering to the project's theme and spacing constants. This completes the foundational UI for the dashboard.
…for a richer user experience. - The DashboardState now includes a recentHeadlines property to store a list of the latest headlines. - The DashboardBloc has been updated to inject the HtDataRepository<Headline>. - The data loading logic now fetches both the DashboardSummary and the 5 most recent headlines concurrently using Future.wait for improved performance. - The DashboardBloc provider in app.dart has been updated to supply the newly required headlinesRepository. This prepares the business logic layer to provide all necessary data for the enhanced dashboard UI.
…ost recently created headlines. - Localization: Added new strings for the "Recent Headlines" section title, a "View All" button, and a message for when no headlines are available. - UI Update: The DashboardPage now includes a new _RecentHeadlinesCard widget. - Recent Headlines Card: This card displays a title, a "View All" button that navigates to the content management page, and a list of recent headlines. Each headline in the list shows its title and relative creation time (e.g., "5m ago") and is tappable, navigating the user directly to that headline's edit page.
…s configuration data. - The DashboardState now includes an appConfig property to hold the fetched configuration. - The DashboardBloc has been updated to inject the HtDataRepository<AppConfig>. - The data loading logic now fetches the AppConfig concurrently with the summary and recent headlines, improving efficiency. - The DashboardBloc provider in app.dart has been updated to supply the newly required appConfigRepository. This change prepares the dashboard to display system status information in the UI.
…nts: - Localization: New strings have been added for the "System Status" and "Quick Actions" cards, including labels for different app statuses and action buttons. - System Status Card: A new _SystemStatusCard widget displays the application's current operational status (Active, Maintenance, Disabled), fetched from the AppConfig. It uses distinct icons and colors for immediate visual feedback. - Quick Actions Card: A new _QuickActionsCard provides direct navigation to key administrative areas: "Create Headline," "Manage Content," and "App Configuration," improving workflow efficiency. - Layout Update: The DashboardPage layout has been updated to a two-column format to accommodate the new cards alongside the "Recent Headlines" list. This concludes all planned phases for the dashboard feature. The dashboard now serves as a comprehensive and functional hub for administrators.
…on to improve responsiveness.
Moves the `sortBy` and `sortOrder` parameters from the `query` map to the dedicated named arguments in the `readAllBy` method call within the `DashboardBloc`. This aligns the call with the repository's API contract and resolves the `BadRequestException` thrown by the `HtDataInMemory` client, which was incorrectly receiving sorting parameters as filter keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request introduces a new, dedicated dashboard feature to the application, serving as a central administrative hub. It provides a quick overview of critical application metrics, displays recent content activity, shows the system's operational status, and offers convenient shortcuts to common management tasks. The implementation leverages the BLoC pattern for robust state management and integrates new data repositories to efficiently fetch and present the required information.
Highlights
- New Dashboard Feature: I've implemented a comprehensive dashboard page (
lib/dashboard/view/dashboard_page.dart
) to provide an overview of key application statistics (headlines, categories, sources), recent activities, system status, and quick administrative actions. - Dashboard BLoC Integration: A new
DashboardBloc
(lib/dashboard/bloc/dashboard_bloc.dart
,dashboard_event.dart
,dashboard_state.dart
) has been introduced to manage the state and data fetching for the dashboard, including concurrent loading of summary data, app configuration, and recent headlines. - Data Repository Setup: I've configured and integrated a new
HtDataRepository<DashboardSummary>
across the application (lib/app/view/app.dart
,lib/bootstrap.dart
) to handle dashboard-specific data, ensuring proper data flow and management. - Internationalization Support: Extensive localization keys have been added (
lib/l10n/app_localizations.dart
,app_localizations_ar.dart
,app_localizations_en.dart
,arb/app_ar.arb
,arb/app_en.arb
) to support all new dashboard UI elements and messages in multiple languages.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new dashboard feature. I've identified areas for improvement regarding code duplication in the bootstrap process and enhancing robustness and security in the BLoC's error handling logic. Addressing these points will improve the long-term maintainability and reliability of the new feature.
} catch (e) { | ||
emit( | ||
state.copyWith( | ||
status: DashboardStatus.failure, | ||
errorMessage: 'An unknown error occurred: $e', | ||
), | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The generic catch (e)
block catches all throwables and exposes the error details ($e
) directly into the state's errorMessage
. It's better to catch specific Exception
types, log the full error for debugging, and provide a generic, user-friendly error message in the state to avoid potential security issues and improve user experience.
} on HtHttpException catch (e) {
emit(
state.copyWith(
status: DashboardStatus.failure,
errorMessage: e.message,
),
);
} catch (e) {
// Log the full error `e` for debugging purposes.
emit(
state.copyWith(
status: DashboardStatus.failure,
errorMessage: 'An unknown error occurred.',
),
);
}
fromJson: AppConfig.fromJson, | ||
toJson: (config) => config.toJson(), | ||
); | ||
dashboardSummaryClient = HtDataApi<DashboardSummary>( | ||
httpClient: httpClient, | ||
modelName: 'dashboard_summary', | ||
fromJson: DashboardSummary.fromJson, | ||
toJson: (summary) => summary.toJson(), | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status
READY
Description
Feature dashboard
Type of Change