mirror of https://github.com/abpframework/abp.git
8 changed files with 264 additions and 44 deletions
@ -0,0 +1,19 @@ |
|||
namespace Volo.Abp.AspNetCore.Components.WebAssembly |
|||
{ |
|||
public class UiMessageOptions |
|||
{ |
|||
public bool ShowMessageIcon { get; set; } = true; |
|||
|
|||
public string OkButtonText { get; set; } |
|||
|
|||
public object OkButtonIcon { get; set; } |
|||
|
|||
public string ConfirmButtonText { get; set; } |
|||
|
|||
public object ConfirmButtonIcon { get; set; } |
|||
|
|||
public string CancelButtonText { get; set; } |
|||
|
|||
public object CancelButtonIcon { get; set; } |
|||
} |
|||
} |
|||
@ -1,17 +1,48 @@ |
|||
<Modal @ref="@ModalRef"> |
|||
<ModalBackdrop /> |
|||
<ModalContent> |
|||
<ModalContent Centered="true"> |
|||
<ModalHeader> |
|||
<ModalTitle> |
|||
@Title |
|||
</ModalTitle> |
|||
</ModalHeader> |
|||
<ModalBody> |
|||
@if ( ShowMessageIcon ) |
|||
{ |
|||
<DisplayHeading Size="DisplayHeadingSize.Is2"> |
|||
<Icon Name="@MessageIcon" Style="@MessageIconStyle" /> |
|||
</DisplayHeading> |
|||
} |
|||
@Message |
|||
</ModalBody> |
|||
<ModalFooter> |
|||
<Button Color="Color.Secondary" Clicked="@OnCancelClicked">Cancel</Button> |
|||
<Button Color="Color.Primary" Clicked="@OnOKClicked">OK</Button> |
|||
@if ( IsConfirmation ) |
|||
{ |
|||
<Button Color="Color.Danger" Padding="Padding.Is2.OnX" Margin="Margin.IsAuto.FromRight" Clicked="@OnCancelClicked"> |
|||
@if ( Options?.CancelButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.CancelButtonIcon" Margin="Margin.Is2.FromRight" /> |
|||
} |
|||
@CancelButtonText |
|||
</Button> |
|||
<Button Color="Color.Primary" Padding="Padding.Is2.OnX" Clicked="@OnConfirmClicked"> |
|||
@if ( Options?.ConfirmButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.ConfirmButtonIcon" Margin="Margin.Is2.FromRight" /> |
|||
} |
|||
@ConfirmButtonText |
|||
</Button> |
|||
} |
|||
else |
|||
{ |
|||
<Button Color="Color.Primary" Padding="Padding.Is2.OnX" Clicked="@OnOkClicked"> |
|||
@if ( Options?.OkButtonIcon != null ) |
|||
{ |
|||
<Icon Name="@Options.OkButtonIcon" Margin="Margin.Is2.FromRight" /> |
|||
} |
|||
@OkButtonText |
|||
</Button> |
|||
} |
|||
</ModalFooter> |
|||
</ModalContent> |
|||
</Modal> |
|||
@ -0,0 +1,62 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Security.Claims; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Components; |
|||
using Volo.Abp.AspNetCore.Components.WebAssembly; |
|||
|
|||
namespace MyCompanyName.MyProjectName.Blazor.Pages |
|||
{ |
|||
public partial class Index |
|||
{ |
|||
private IEnumerable<Claim> _claims; |
|||
|
|||
protected override async Task OnInitializedAsync() |
|||
{ |
|||
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync(); |
|||
if ( authState.User.Identity.IsAuthenticated ) |
|||
{ |
|||
_claims = authState.User.Claims; |
|||
} |
|||
} |
|||
|
|||
Task OnInfoTestClicked() |
|||
{ |
|||
return UiMessageService.InfoAsync( "This is the Info message", "Info" ); |
|||
} |
|||
|
|||
Task OnSuccessTestClicked() |
|||
{ |
|||
return UiMessageService.SuccessAsync( "This is the Success message", "Success" ); |
|||
} |
|||
|
|||
Task OnWarningTestClicked() |
|||
{ |
|||
return UiMessageService.WarnAsync( "This is the Warning message", "Warning" ); |
|||
} |
|||
|
|||
Task OnErrorTestClicked() |
|||
{ |
|||
return UiMessageService.ErrorAsync( "This is the Error message", "Error" ); |
|||
} |
|||
|
|||
Task OnConfirmTestClicked() |
|||
{ |
|||
return UiMessageService.ConfirmAsync( "This is the Confirm message", "Confirm" ) |
|||
.ContinueWith( result => |
|||
{ |
|||
if ( result.Result ) |
|||
{ |
|||
Console.WriteLine( "Confirmed" ); |
|||
} |
|||
else |
|||
{ |
|||
Console.WriteLine( "Cancelled" ); |
|||
} |
|||
} ); |
|||
} |
|||
|
|||
[Inject] IUiMessageService UiMessageService { get; set; } |
|||
} |
|||
} |
|||
Loading…
Reference in new issue