created generic confirmation dialog control and implemented in File Management module
This commit is contained in:
parent
414935dc58
commit
b3e010d5e2
|
@ -9,18 +9,16 @@
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<ActionLink Action="Add" Text="Add Files" Style="float: right; margin: 10px;" />
|
<ActionLink Action="Add" Text="Add Files" />
|
||||||
|
|
||||||
<Pager Items="@Files">
|
<Pager Items="@Files">
|
||||||
<Header>
|
<Header>
|
||||||
<th>Name</th>
|
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
<th>Name</th>
|
||||||
</Header>
|
</Header>
|
||||||
<Row>
|
<Row>
|
||||||
|
<td><ConfirmationDialog Header="Delete File" Message="@("Are You Sure You Wish To Delete " + context + "?")" Action="Delete" Class="btn btn-danger" OnClick="@(async () => await DeleteFile(context))" /></td>
|
||||||
<td><a href="@(uri.Scheme + "://" + uri.Authority + "/" + PageState.Site.SiteRootPath + context)" target="_new">@context</a></td>
|
<td><a href="@(uri.Scheme + "://" + uri.Authority + "/" + PageState.Site.SiteRootPath + context)" target="_new">@context</a></td>
|
||||||
<td>
|
|
||||||
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteFile(context))>Delete</button>
|
|
||||||
</td>
|
|
||||||
</Row>
|
</Row>
|
||||||
</Pager>
|
</Pager>
|
||||||
}
|
}
|
||||||
|
@ -40,7 +38,7 @@ else
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError("Error Loading Files {Error}", ex.Message);
|
await logger.LogError(ex, "Error Loading Files {Error}", ex.Message);
|
||||||
AddModuleMessage("Error Loading Files", MessageType.Error);
|
AddModuleMessage("Error Loading Files", MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,13 +49,13 @@ else
|
||||||
{
|
{
|
||||||
await FileService.DeleteFileAsync(PageState.Site.SiteRootPath, filename);
|
await FileService.DeleteFileAsync(PageState.Site.SiteRootPath, filename);
|
||||||
Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath);
|
Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath);
|
||||||
await logger.LogInformation("File Deleted");
|
await logger.LogInformation("File Deleted {File}", filename);
|
||||||
AddModuleMessage("File Deleted", MessageType.Success);
|
AddModuleMessage("File " + filename + " Deleted", MessageType.Success);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
await logger.LogError("Error Deleting File {Error}", ex.Message);
|
await logger.LogError(ex, "Error Deleting File {File} {Error}", filename, ex.Message);
|
||||||
AddModuleMessage("Error Deleting File", MessageType.Error);
|
AddModuleMessage("Error Deleting File " + filename, MessageType.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
69
Oqtane.Client/Modules/Controls/ConfirmationDialog.razor
Normal file
69
Oqtane.Client/Modules/Controls/ConfirmationDialog.razor
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
@namespace Oqtane.Modules.Controls
|
||||||
|
@inherits ModuleBase
|
||||||
|
|
||||||
|
@if (visible)
|
||||||
|
{
|
||||||
|
<div class="app-admin-modal">
|
||||||
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">@Header</h5>
|
||||||
|
<button type="button" class="close" @onclick="DisplayModal" aria-label="Close">×</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<p>@Message</p>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="@Class" @onclick="Confirm">@Action</button>
|
||||||
|
<button type="button" class="btn btn-secondary" @onclick="DisplayModal">Cancel</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
<button class="@Class" @onclick="DisplayModal">@Action</button>
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter]
|
||||||
|
public string Header { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Action { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Class { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public Action OnClick { get; set; }
|
||||||
|
|
||||||
|
bool visible = false;
|
||||||
|
|
||||||
|
protected override void OnParametersSet()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(Action))
|
||||||
|
{
|
||||||
|
Action = "Ok";
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(Class))
|
||||||
|
{
|
||||||
|
Class = "btn btn-success";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DisplayModal()
|
||||||
|
{
|
||||||
|
visible = !visible;
|
||||||
|
StateHasChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Confirm()
|
||||||
|
{
|
||||||
|
DisplayModal();
|
||||||
|
OnClick();
|
||||||
|
}
|
||||||
|
}
|
|
@ -128,14 +128,14 @@
|
||||||
private string HostEmail = "";
|
private string HostEmail = "";
|
||||||
private string Message = "";
|
private string Message = "";
|
||||||
|
|
||||||
private string IntegratedSecurityDisplay = "display:none;";
|
private string IntegratedSecurityDisplay = "display: none;";
|
||||||
private string LoadingDisplay = "display:none;";
|
private string LoadingDisplay = "display: none;";
|
||||||
|
|
||||||
private void SetIntegratedSecurity(ChangeEventArgs e)
|
private void SetIntegratedSecurity(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
if (Convert.ToBoolean(e.Value))
|
if (Convert.ToBoolean(e.Value))
|
||||||
{
|
{
|
||||||
IntegratedSecurityDisplay = "display:none;";
|
IntegratedSecurityDisplay = "display: none;";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -158,7 +158,7 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
connectionstring = "Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";";
|
connectionstring = "Data Source=" + ServerName + ";Initial Catalog=" + DatabaseName + ";";
|
||||||
if (IntegratedSecurityDisplay == "display:none;")
|
if (IntegratedSecurityDisplay == "display: none;")
|
||||||
{
|
{
|
||||||
connectionstring += "Integrated Security=SSPI;";
|
connectionstring += "Integrated Security=SSPI;";
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
|
Message = "<div class=\"alert alert-danger\" role=\"alert\">" + response.Message + "</div>";
|
||||||
LoadingDisplay = "display:none;";
|
LoadingDisplay = "display: none;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -3,14 +3,12 @@
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
<div class="app-admin-modal">
|
<div class="app-admin-modal">
|
||||||
<div class="modal" style="display: block">
|
<div class="modal" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title"><ModuleTitle /></h5>
|
<h5 class="modal-title"><ModuleTitle /></h5>
|
||||||
<button type="button" class="close" @onclick="CloseModal" data-dismiss="modal" aria-label="Close">
|
<button type="button" class="close" @onclick="CloseModal" aria-label="Close">×</button>
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<ModuleInstance />
|
<ModuleInstance />
|
||||||
|
|
|
@ -44,6 +44,7 @@ app {
|
||||||
z-index: 9999; /* Sit on top */
|
z-index: 9999; /* Sit on top */
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
display: block;
|
||||||
width: 100%; /* Full width */
|
width: 100%; /* Full width */
|
||||||
height: 100%; /* Full height */
|
height: 100%; /* Full height */
|
||||||
overflow: auto; /* Enable scroll if needed */
|
overflow: auto; /* Enable scroll if needed */
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.5 MiB |
|
@ -44,6 +44,7 @@ app {
|
||||||
z-index: 9999; /* Sit on top */
|
z-index: 9999; /* Sit on top */
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
display: block;
|
||||||
width: 100%; /* Full width */
|
width: 100%; /* Full width */
|
||||||
height: 100%; /* Full height */
|
height: 100%; /* Full height */
|
||||||
overflow: auto; /* Enable scroll if needed */
|
overflow: auto; /* Enable scroll if needed */
|
||||||
|
@ -90,4 +91,4 @@ app {
|
||||||
color: gray;
|
color: gray;
|
||||||
height: 1px;
|
height: 1px;
|
||||||
background-color: gray;
|
background-color: gray;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user