15-12-2022 ~ 2

This commit is contained in:
Jonathan Jenne
2022-12-15 15:59:38 +01:00
parent e4c5658c13
commit 63edd9e542
30 changed files with 331 additions and 214 deletions

View File

@@ -0,0 +1,11 @@
<a class="btn btn-primary" href="@linkUrl">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" />
</svg> New
</a>
@code {
[Parameter]
public string? linkUrl { get; set; }
}

View File

@@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="12.0.0" />
<PackageReference Include="NLog" Version="5.1.0" />
<PackageReference Include="Quartz" Version="3.5.0" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.10.*" />

View File

@@ -71,7 +71,7 @@ else
</div>
<div class="btn-group mt-3" role="group" aria-label="Basic example">
<a class="btn btn-primary" href="profiles/import/new">
<a class="btn btn-primary" href="/profiles/import/new">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" />

View File

@@ -72,10 +72,6 @@ else
</li>
</ul>
<h3>Profilschritte</h3>
<ECM.JobRunner.Web.Pages.ImportStep.ListSteps Profile="profile" />
<div class="btn-toolbar mt-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group me-2" role="group" aria-label="First group">
<a class="btn btn-secondary" href="profiles/import">
@@ -97,7 +93,7 @@ else
</div>
<div class="flex-column flex-fill"></div>
<div class="btn-group" role="group">
<a class="btn btn-secondary" href="profiles/import/@profile.Id/steps">Profilschritte bearbeiten</a>
<a class="btn btn-secondary" href="profiles/import/@profile.Id/steps">Profilschritte bearbeiten (@profile.Steps.Length)</a>
</div>
</div>
}
@@ -127,10 +123,10 @@ else
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
if (confirmed)
{
//if (await Jobs.DeleteJob(profile) == true)
//{
// Navigation.NavigateTo($"/jobs");
//};
if (await Import.DeleteProfile(profile) == true)
{
Navigation.NavigateTo($"/jobs");
};
}
}
}

View File

@@ -32,7 +32,7 @@
if (result == true)
{
Navigation.NavigateTo($"/profiles/import/{profile.Id}");
Navigation.NavigateTo($"/profiles/import/{profile.Id}/steps");
}
}
}

View File

@@ -1,7 +1,5 @@
@using ECM.JobRunner.Common.JobRunnerReference;
@using ECM.JobRunner.Web.Data;
@inject JobService Jobs
@inject ImportService Import;
@if (Profile == null)
{
@@ -45,7 +43,7 @@ else
</span>
<span>@step.IndexName</span>
</div>
@step.Method
Process @step.Scope with Method @step.Method
</div>
</a>
}

View File

@@ -0,0 +1,40 @@
@page "/profiles/import/{profileId:int}/steps/new"
@using ECM.JobRunner.Common.JobRunnerReference;
@using ECM.JobRunner.Web.Data;
@inject NavigationManager Navigation;
@inject ImportService Profile;
<PageTitle>Schritt bearbeiten</PageTitle>
<h3>Schritt bearbeiten</h3>
<StepForm ProfileId="ProfileId" StepId="-1" OnValidSubmit="OnFormSubmit" />
@code {
[Parameter]
public int ProfileId { get; set; }
[Parameter]
public int StepId { get; set; }
public ImportProfile? profile;
private async void OnFormSubmit(EditContext ctx)
{
ImportProfile profile = await Profile.GetProfile(ProfileId);
ImportProfileStep step = (ImportProfileStep)ctx.Model;
// TODO: This is ugly and manual and needs to be abstracted.
var steps = profile.Steps.ToList();
steps.Add(step);
profile.Steps = steps.ToArray();
bool result = await Profile.UpdateProfile(profile);
if (result == true)
{
Navigation.NavigateTo($"/profiles/import/{profile.Id}");
}
}
}

View File

@@ -114,7 +114,7 @@ else
</ul>
<div class="btn-group mt-3" role="group" aria-label="Basic example">
<a class="btn btn-secondary" href="profiles/import/@profile.Id">
<a class="btn btn-secondary" href="profiles/import/@profile.Id/steps">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z" />
</svg> Back
@@ -125,7 +125,7 @@ else
<path fill-rule="evenodd" d="M1 13.5A1.5 1.5 0 0 0 2.5 15h11a1.5 1.5 0 0 0 1.5-1.5v-6a.5.5 0 0 0-1 0v6a.5.5 0 0 1-.5.5h-11a.5.5 0 0 1-.5-.5v-11a.5.5 0 0 1 .5-.5H9a.5.5 0 0 0 0-1H2.5A1.5 1.5 0 0 0 1 2.5v11z" />
</svg> Edit
</a>
<a class="btn btn-danger" @onclick="DeleteJob">
<a class="btn btn-danger" @onclick="DeleteStep">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash3" viewBox="0 0 16 16">
<path d="M6.5 1h3a.5.5 0 0 1 .5.5v1H6v-1a.5.5 0 0 1 .5-.5ZM11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3A1.5 1.5 0 0 0 5 1.5v1H2.506a.58.58 0 0 0-.01 0H1.5a.5.5 0 0 0 0 1h.538l.853 10.66A2 2 0 0 0 4.885 16h6.23a2 2 0 0 0 1.994-1.84l.853-10.66h.538a.5.5 0 0 0 0-1h-.995a.59.59 0 0 0-.01 0H11Zm1.958 1-.846 10.58a1 1 0 0 1-.997.92h-6.23a1 1 0 0 1-.997-.92L3.042 3.5h9.916Zm-7.487 1a.5.5 0 0 1 .528.47l.5 8.5a.5.5 0 0 1-.998.06L5 5.03a.5.5 0 0 1 .47-.53Zm5.058 0a.5.5 0 0 1 .47.53l-.5 8.5a.5.5 0 1 1-.998-.06l.5-8.5a.5.5 0 0 1 .528-.47ZM8 4.5a.5.5 0 0 1 .5.5v8.5a.5.5 0 0 1-1 0V5a.5.5 0 0 1 .5-.5Z" />
</svg> Delete
@@ -156,19 +156,22 @@ else
}
}
protected async void DeleteJob()
protected async void DeleteStep()
{
if (profile != null)
{
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?");
if (confirmed)
{
var steps = profile.Steps.Where(s => s.Id != StepId).ToArray();
var steps = profile.Steps.
ToList().
Where<ImportProfileStep>(s => s.Id != StepId).
ToArray();
profile.Steps = steps;
if (await Import.UpdateProfile(profile) == true)
{
Navigation.NavigateTo($"/profiles/import/{ProfileId}");
Navigation.NavigateTo($"/profiles/import/{ProfileId}/steps");
};
}
}

View File

@@ -161,7 +161,7 @@ else
if (StepId == Constants.ENTITY_ID_NEW)
{
step = new ImportProfileStep() { Id = Constants.ENTITY_ID_NEW };
step = new ImportProfileStep() { Id = Constants.ENTITY_ID_NEW, ProfileId = ProfileId };
}
else
{

View File

@@ -0,0 +1,51 @@
@page "/profiles/import/{profileId:int}/steps"
@using ECM.JobRunner.Common.JobRunnerReference
@using ECM.JobRunner.Web.Data
@using ECM.JobRunner.Web.Pages.ImportStep
@inject ImportService Import
<h3>Profilschritte</h3>
@if (profile == null)
{
<ul class="list-group">
<li class="list-group-item">Loading Steps..</li>
</ul>
}
else
{
<ListSteps Profile="profile" />
<div class="btn-toolbar mt-3" role="toolbar" aria-label="Toolbar with button groups">
<div class="btn-group me-2" role="group" aria-label="First group">
<a class="btn btn-secondary" href="profiles/import/@profile.Id">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-left" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M15 8a.5.5 0 0 0-.5-.5H2.707l3.147-3.146a.5.5 0 1 0-.708-.708l-4 4a.5.5 0 0 0 0 .708l4 4a.5.5 0 0 0 .708-.708L2.707 8.5H14.5A.5.5 0 0 0 15 8z" />
</svg> Back
</a>
<a class="btn btn-primary" href="/profiles/import/@profile.Id/steps/new">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z" />
<path d="M8 4a.5.5 0 0 1 .5.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3A.5.5 0 0 1 8 4z" />
</svg> New
</a>
</div>
</div>
}
@code {
[Parameter]
public int ProfileId { get; set; }
private ImportProfile? profile;
protected async override void OnInitialized()
{
profile = await Import.GetProfile(ProfileId);
StateHasChanged();
}
}