feat(Tasks): add Bootstrap.Tasks.Dashboard project#530
Conversation
Reviewer's GuideThis 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 componentsclassDiagram
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
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| private string FormatResult(TriggerResult result) => result switch | ||
| { | ||
| TriggerResult.Running => Localizer["TriggerResult.Running"], | ||
| TriggerResult.Success => Localizer["TriggerResult.Success"], | ||
| TriggerResult.Cancelled => Localizer["TriggerResult.Timeout"], |
There was a problem hiding this comment.
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.
| .my-component { | ||
| border: 2px dashed red; | ||
| padding: 1em; | ||
| margin: 1em 0; | ||
| background-image: url('background.png'); |
There was a problem hiding this comment.
nitpick: CSS class .my-component is defined but not used.
If the class is not needed, please remove it to keep the stylesheet clean.
| var scheduler = TaskServicesManager.Get(Scheduler.Name); | ||
| if (scheduler != null) | ||
| { | ||
| scheduler.Triggers.First().PulseCallback += DispatchMessageCallback; |
There was a problem hiding this comment.
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.
Link issues
fixes #529
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
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: