Skip to content

feat(Tasks): add Bootstrap.Tasks.Dashboard project#530

Merged
ArgoZhang merged 12 commits intomasterfrom
feat-task-dash
Aug 16, 2025
Merged

feat(Tasks): add Bootstrap.Tasks.Dashboard project#530
ArgoZhang merged 12 commits intomasterfrom
feat-task-dash

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Aug 16, 2025

Link issues

fixes #529

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add a new BootstrapBlazor.Tasks.Dashboard project containing TaskDashboard and TaskInfo components to manage, monitor, and log scheduled tasks within the BootstrapBlazor framework.

New Features:

  • Add TaskDashboard component to display and control schedulers in a table with status, runtimes, results, exceptions, and operations
  • Add TaskInfo component to show detailed logs and real-time console output for a selected scheduler
  • Include localization support for dashboard UI texts via en-US and zh-CN JSON resource files
  • Provide CSS styling and component imports for the new dashboard

@bb-auto bb-auto Bot added the enhancement New feature or request label Aug 16, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Aug 16, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Aug 16, 2025

Reviewer's Guide

This pull request introduces a new Bootstrap.Tasks.Dashboard project, adding TaskDashboard and TaskInfo components with full scheduler management UI, integrating with TaskServicesManager, localization resources, and styling.

Class diagram for new TaskDashboard and TaskInfo components

classDiagram
    class TaskDashboard {
        - IStringLocalizer<TaskDashboard> Localizer
        - DialogService DialogService
        - IEnumerable<IScheduler> _schedulers
        + OnParametersSet()
        + GetStatusColor(status)
        + FormatStatus(status)
        + GetStatusIcon(status)
        + GetResultColor(result)
        + FormatResult(result)
        + OnPause(scheduler)
        + OnRun(scheduler)
        + OnLog(scheduler)
        + OnCheckPauseTaskStatus(model)
        + OnCheckRunTaskStatus(model)
        + FormatDateTime(dateTime)
        + OnShowException(scheduler, ex)
        + RenderException(ex)
    }
    class TaskInfo {
        + IScheduler Scheduler
        + string HeaderText
        - List<ConsoleMessageItem> Messages
        + OnAfterRenderAsync(firstRender)
        - DispatchMessageCallback(trigger)
        - DispatchMessage(trigger)
        - Dispose(disposing)
        + Dispose()
    }
    TaskDashboard --> TaskInfo : uses (via DialogService)
    TaskInfo --> IScheduler : parameter
    TaskDashboard --> IScheduler : manages
    TaskDashboard --> DialogService : injects
    TaskDashboard --> IStringLocalizer : injects
Loading

File-Level Changes

Change Details Files
Added new Tasks.Dashboard project to solution
  • Included project in main solution file
  • Created project file with necessary dependencies and settings
BootstrapBlazor.Extensions.sln
src/components/BootstrapBlazor.Tasks.Dashboard/BootstrapBlazor.Tasks.Dashboard.csproj
Implemented TaskDashboard component UI and logic
  • Defined table layout with scheduler attributes and operation buttons in Razor
  • Injected localization and dialog services
  • Added methods for status/result formatting and pause/run/log/exception handlers
src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor
src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor.cs
src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor.css
Created TaskInfo component for live log display
  • Rendered Console component for displaying trigger messages
  • Subscribed to trigger callbacks and updated message list on events
  • Managed disposal of event handlers to prevent leaks
src/components/BootstrapBlazor.Tasks.Dashboard/TaskInfo.razor
src/components/BootstrapBlazor.Tasks.Dashboard/TaskInfo.razor.cs
Added localization and shared imports
  • Provided en-US and zh-CN resource files for component texts
  • Defined common usings in _Imports.razor for the dashboard project
src/components/BootstrapBlazor.Tasks.Dashboard/Locales/en-US.json
src/components/BootstrapBlazor.Tasks.Dashboard/Locales/zh-CN.json
src/components/BootstrapBlazor.Tasks.Dashboard/_Imports.razor

Assessment against linked issues

Issue Objective Addressed Explanation
#529 Add a new project named Bootstrap.Tasks.Dashboard to the codebase.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@ArgoZhang ArgoZhang merged commit 789b58d into master Aug 16, 2025
1 check passed
@ArgoZhang ArgoZhang deleted the feat-task-dash branch August 16, 2025 08:10
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • The TaskDashboard.razor.css file contains a placeholder ".my-component" class that isn’t referenced anywhere—either remove it or replace it with actual dashboard styles.
  • In FormatResult the TriggerResult.Cancelled case uses the Timeout localization key—swap it to a dedicated Cancelled key so the UI text matches the real state.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The TaskDashboard.razor.css file contains a placeholder ".my-component" class that isn’t referenced anywhere—either remove it or replace it with actual dashboard styles.
- In FormatResult the TriggerResult.Cancelled case uses the Timeout localization key—swap it to a dedicated Cancelled key so the UI text matches the real state.

## Individual Comments

### Comment 1
<location> `src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor.cs:67` </location>
<code_context>
+        _ => Color.Danger,
+    };
+
+    private string FormatResult(TriggerResult result) => result switch
+    {
+        TriggerResult.Running => Localizer["TriggerResult.Running"],
+        TriggerResult.Success => Localizer["TriggerResult.Success"],
+        TriggerResult.Cancelled => Localizer["TriggerResult.Timeout"],
+        TriggerResult.Timeout => Localizer["TriggerResult.Timeout"],
+        _ => Localizer["TriggerResult.Error"],
</code_context>

<issue_to_address>
Cancelled result is mapped to Timeout localization key.

Using the Timeout key for Cancelled may mislead users. Please add a separate localization key for Cancelled.

Suggested implementation:

```csharp
        TriggerResult.Cancelled => Localizer["TriggerResult.Cancelled"],

```

You must also add the "TriggerResult.Cancelled" key to your localization resource files (e.g., .resx or JSON files) with the appropriate value for each supported language.
</issue_to_address>

### Comment 2
<location> `src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor.css:1` </location>
<code_context>
+.my-component {
+    border: 2px dashed red;
+    padding: 1em;
+    margin: 1em 0;
+    background-image: url('background.png');
+}
</code_context>

<issue_to_address>
CSS class .my-component is defined but not used.

If the class is not needed, please remove it to keep the stylesheet clean.
</issue_to_address>

### Comment 3
<location> `src/components/BootstrapBlazor.Tasks.Dashboard/TaskInfo.razor.cs:41` </location>
<code_context>
+
+        if (firstRender)
+        {
+            var scheduler = TaskServicesManager.Get(Scheduler.Name);
+            if (scheduler != null)
+            {
+                scheduler.Triggers.First().PulseCallback += DispatchMessageCallback;
+                await DispatchMessage(scheduler.Triggers.First());
+            }
</code_context>

<issue_to_address>
Assumes at least one trigger exists for scheduler.

Add a check to ensure scheduler.Triggers is not empty before accessing First(), to prevent possible exceptions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +67 to +71
private string FormatResult(TriggerResult result) => result switch
{
TriggerResult.Running => Localizer["TriggerResult.Running"],
TriggerResult.Success => Localizer["TriggerResult.Success"],
TriggerResult.Cancelled => Localizer["TriggerResult.Timeout"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Cancelled result is mapped to Timeout localization key.

Using the Timeout key for Cancelled may mislead users. Please add a separate localization key for Cancelled.

Suggested implementation:

        TriggerResult.Cancelled => Localizer["TriggerResult.Cancelled"],

You must also add the "TriggerResult.Cancelled" key to your localization resource files (e.g., .resx or JSON files) with the appropriate value for each supported language.

Comment on lines +1 to +5
.my-component {
border: 2px dashed red;
padding: 1em;
margin: 1em 0;
background-image: url('background.png');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: CSS class .my-component is defined but not used.

If the class is not needed, please remove it to keep the stylesheet clean.

Comment on lines +41 to +44
var scheduler = TaskServicesManager.Get(Scheduler.Name);
if (scheduler != null)
{
scheduler.Triggers.First().PulseCallback += DispatchMessageCallback;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Assumes at least one trigger exists for scheduler.

Add a check to ensure scheduler.Triggers is not empty before accessing First(), to prevent possible exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Tasks): add Bootstrap.Tasks.Dashboard project

1 participant