@page "/profiles/import/{profileId:int}"
@using ECM.JobRunner.Common.JobRunnerReference;
@using ECM.JobRunner.Web.Data;
@inject NavigationManager Navigation;
@inject IJSRuntime JsRuntime;
@inject HelperService Helper;
@inject ImportProfileService Import;
Profile
@if (profile == null)
{
Job
}
else
{
}
@code {
[Parameter]
public int ProfileId { get; set; }
private ImportProfile? profile;
private DateTime nextExecution;
protected async override void OnInitialized()
{
profile = await Import.GetProfile(ProfileId);
if (profile != null)
{
Helper.SetPageTitle(profile.Job.Name);
nextExecution = Helper.GetNextExecutionTime(profile.Job.CronSchedule);
StateHasChanged();
}
}
protected async void RunProfile()
{
if (profile != null)
{
bool confirmed = await JsRuntime.InvokeAsync("confirm", "Are you sure?");
if (confirmed)
{
await Import.RunProfile(profile);
}
}
}
protected async void DeleteJob()
{
if (profile != null)
{
bool confirmed = await JsRuntime.InvokeAsync("confirm", "Are you sure?");
if (confirmed)
{
if (await Import.DeleteProfile(profile) == true)
{
Navigation.NavigateTo($"/jobs");
};
}
}
}
}