* Changed views to have them in the same layout
* Added Authorization
This commit is contained in:
@@ -1,30 +1,77 @@
|
||||
@page "/Admin/Scheduler"
|
||||
|
||||
@attribute [Authorize]
|
||||
|
||||
@using System.Security.Claims
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@using OrdersManagementDataModel.Dtos
|
||||
@using Syncfusion.Blazor.Grids
|
||||
@using Action = Syncfusion.Blazor.Grids.Action
|
||||
@inject HangfireService HangfireService
|
||||
@using Syncfusion.Blazor.Cards
|
||||
|
||||
<h3>Zarządzanie Zadaniami</h3>
|
||||
<br />
|
||||
<SfGrid DataSource="@Tasks" AllowPaging="true" ShowColumnMenu="true" Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Cancel", "Update" })">
|
||||
<GridColumns>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.RowPointer.ToString) IsPrimaryKey="true" HeaderText="Id"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.Name) HeaderText="Nazwa"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.Path) HeaderText="Ścieżka"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.CronOptions) HeaderText="CRON"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.LastExecution) HeaderText="Ostatnie Uruchomienie"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.NextExecution) HeaderText="Następne Uruchomienie"></GridColumn>
|
||||
</GridColumns>
|
||||
<GridEditSettings AllowDeleting="true" ShowDeleteConfirmDialog="true" AllowAdding="true" NewRowPosition="NewRowPosition.Bottom" AllowEditing="true"></GridEditSettings>
|
||||
<GridEvents OnActionBegin="OnActionBegin" TValue="TaskSchedulerDto" OnActionComplete="OnActionComplete"></GridEvents>
|
||||
</SfGrid>
|
||||
@inject HangfireService HangfireService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject CustomAuthenticationStateProvider CustomAuthenticationStateProvider
|
||||
|
||||
<div class="h-100 d-flex justify-content-center align-items-start">
|
||||
<SfCard CssClass="shadow" style="width: 100%; max-width: 1200px;">
|
||||
<CardHeader>
|
||||
<h3 class="text-primary">Zarządzanie Zadaniami</h3>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<SfGrid DataSource="@Tasks"
|
||||
AllowPaging="true"
|
||||
ShowColumnMenu="true"
|
||||
Toolbar="@(new List<string> { "Add", "Edit", "Delete", "Cancel", "Update" })">
|
||||
<GridColumns>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.RowPointer) AllowEditing="false" IsPrimaryKey="true" HeaderText="Id"
|
||||
Width="100"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.Name) HeaderText="Nazwa" Width="150"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.Path) HeaderText="Ścieżka" Width="200"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.CronOptions) HeaderText="CRON" Width="120"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.LastExecution) AllowEditing="false" HeaderText="Ostatnie Uruchomienie"
|
||||
Width="150"></GridColumn>
|
||||
<GridColumn Field=@nameof(TaskSchedulerDto.NextExecution) AllowEditing="false" HeaderText="Następne Uruchomienie"
|
||||
Width="150"></GridColumn>
|
||||
</GridColumns>
|
||||
<GridEditSettings AllowDeleting="true"
|
||||
ShowDeleteConfirmDialog="true"
|
||||
AllowAdding="true"
|
||||
NewRowPosition="NewRowPosition.Bottom"
|
||||
AllowEditing="true">
|
||||
</GridEditSettings>
|
||||
<GridEvents OnActionBegin="OnActionBegin"
|
||||
OnActionComplete="OnActionComplete"
|
||||
TValue="TaskSchedulerDto">
|
||||
</GridEvents>
|
||||
<GridPageSettings PageSize="10"></GridPageSettings>
|
||||
</SfGrid>
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<small class="text-muted">FA Krosno Manager © @(DateTime.Now.Year)</small>
|
||||
</CardFooter>
|
||||
</SfCard>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private List<TaskSchedulerDto> Tasks { get; set; } = new();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
await LoadTasks();
|
||||
if (firstRender)
|
||||
{
|
||||
ClaimsPrincipal currentUser = CustomAuthenticationStateProvider.GetCurrentUser();
|
||||
|
||||
if (currentUser.Identity?.IsAuthenticated == false || currentUser.Identity?.Name != "pkus")
|
||||
{
|
||||
NavigationManager.NavigateTo("/Unauthorized");
|
||||
}
|
||||
else
|
||||
{
|
||||
await LoadTasks();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task OnActionBegin(ActionEventArgs<TaskSchedulerDto> args)
|
||||
@@ -65,4 +112,5 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user