Skip to content

Commit 04fa373

Browse files
committed
Alert manager refactoring/improvements
1 parent 701840a commit 04fa373

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@using Abp.Web.Mvc.Alerts
2+
3+
@inject IAlertManager AlertManager
4+
5+
<div class="container-fluid">
6+
@if (AlertManager.Alerts.Any())
7+
{
8+
@foreach (var alertMessage in AlertManager.Alerts)
9+
{
10+
<div class="alert [email protected]().ToLowerInvariant() @(alertMessage.Dismissible ? "alert-dismisable" : "") mt-3 mr-1 ml-1">
11+
@if (alertMessage.Dismissible)
12+
{
13+
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
14+
}
15+
<h5>
16+
@{
17+
var iconClass = "info";
18+
switch (alertMessage.Type)
19+
{
20+
case AlertType.Success:
21+
iconClass = "check";
22+
break;
23+
case AlertType.Danger:
24+
iconClass = "ban";
25+
break;
26+
case AlertType.Warning:
27+
iconClass = "exclamation-triangle";
28+
break;
29+
case AlertType.Info:
30+
iconClass = "info";
31+
break;
32+
}
33+
}
34+
<i class="icon fas fa-@iconClass"></i>
35+
@alertMessage.Title
36+
</h5>
37+
@alertMessage.Text
38+
</div>
39+
}
40+
}
41+
</div>

aspnet-core/src/AbpCompanyName.AbpProjectName.Web.Mvc/Views/Shared/Layout/_Layout.cshtml

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,8 @@
5353
<div class="wrapper">
5454
@await Html.PartialAsync("_Header.cshtml")
5555
@await Html.PartialAsync("_SideBar.cshtml")
56-
<div>
57-
@if (AlertManager.Alerts.Any())
58-
{
59-
<div id="AbpPageAlerts">
60-
@foreach (var alertMessage in AlertManager.Alerts)
61-
{
62-
<div class="alert [email protected]().ToLower() @(alertMessage.Dismissible ? "alert-dismisable" : "")" role="alert">
63-
<h4 class="alert-heading">
64-
@alertMessage.Title
65-
@if (alertMessage.Dismissible)
66-
{
67-
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
68-
}
69-
</h4>
70-
<p>@alertMessage.Text</p>
71-
</div>
72-
}
73-
</div>
74-
}
75-
</div>
7656
<div class="content-wrapper">
57+
@await Html.PartialAsync("_Layout.Alerts.cshtml")
7758
@RenderBody()
7859
</div>
7960
@await Component.InvokeAsync(typeof(ControlSidebarViewComponent))

0 commit comments

Comments
 (0)