Skip to content

Commit d4c1050

Browse files
committed
feat: 实现异常明细弹窗功能
1 parent 9bc8034 commit d4c1050

4 files changed

Lines changed: 19 additions & 7 deletions

File tree

src/components/BootstrapBlazor.Tasks.Dashboard/Locales/en-US.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ButtonRun": "Run",
2020
"ButtonLog": "Log",
2121
"LogDilaogTitle": "{0} - Log(Latest 20 Items)",
22-
"LogDilaogConsoleHeaderText": "Action Log"
22+
"LogDilaogConsoleHeaderText": "Action Log",
23+
"ExceptionDilaogTitle": "{0} - Exception Detail"
2324
}
2425
}

src/components/BootstrapBlazor.Tasks.Dashboard/Locales/zh-CN.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ButtonRun": "运行",
2020
"ButtonLog": "日志",
2121
"LogDilaogTitle": "{0} - 日志窗口(最新 20 条)",
22-
"LogDilaogConsoleHeaderText": "执行日志"
22+
"LogDilaogConsoleHeaderText": "执行日志",
23+
"ExceptionDilaogTitle": "{0} - 异常明细"
2324
}
2425
}

src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
</TableTemplateColumn>
3232
<TableTemplateColumn Text="@Localizer["Exception"]">
3333
<Template Context="v">
34-
@if (v.Row.Exception != null)
34+
@if (v.Row.Exception == null)
3535
{
3636
<Button Color="Color.Danger" Size="Size.ExtraSmall" Icon="fa-solid fa-exclamation-circle"
37-
OnClickWithoutRender="() => OnShowException(v.Row.Exception)"></Button>
37+
OnClickWithoutRender="() => OnShowException(v.Row, v.Row.Exception)"></Button>
3838
}
3939
</Template>
4040
</TableTemplateColumn>

src/components/BootstrapBlazor.Tasks.Dashboard/TaskDashboard.razor.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private async Task OnLog(IScheduler scheduler)
8989
{
9090
var option = new DialogOption()
9191
{
92-
Class = "modal-dialog-task",
92+
Class = "modal-dialog-task-log",
9393
Title = Localizer["LogDilaogTitle", scheduler.Name],
9494
Component = BootstrapDynamicComponent.CreateComponent<TaskInfo>(new Dictionary<string, object?>
9595
{
@@ -106,8 +106,18 @@ private async Task OnLog(IScheduler scheduler)
106106

107107
private static string? FormatDateTime(DateTimeOffset? dateTime) => dateTime?.ToString("yyyy-MM-dd HH:mm:ss");
108108

109-
private Task OnShowException(Exception ex)
109+
private async Task OnShowException(IScheduler scheduler, Exception ex)
110110
{
111-
return Task.CompletedTask;
111+
ex = new Exception("test");
112+
var option = new DialogOption()
113+
{
114+
Class = "modal-dialog-task-ex",
115+
IsScrolling = true,
116+
Title = Localizer["ExceptionDilaogTitle", scheduler.Name],
117+
BodyTemplate = RenderException(ex)
118+
};
119+
await DialogService.Show(option);
112120
}
121+
122+
private static RenderFragment RenderException(Exception ex) => builder => builder.AddContent(0, ex.FormatMarkupString());
113123
}

0 commit comments

Comments
 (0)