Implemented template crud, db entities, import/export, ptero and pelican import
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
@using Moonlight.Frontend.Helpers
|
||||
@using MoonlightServers.Shared
|
||||
@using MoonlightServers.Shared.Admin.Templates
|
||||
@using ShadcnBlazor.Dialogs
|
||||
@using ShadcnBlazor.Buttons
|
||||
@using ShadcnBlazor.Extras.Forms
|
||||
@using ShadcnBlazor.Extras.Toasts
|
||||
@using ShadcnBlazor.Fields
|
||||
@using ShadcnBlazor.Inputs
|
||||
@using ShadcnBlazor.Switches
|
||||
|
||||
@inherits ShadcnBlazor.Extras.Dialogs.DialogBase
|
||||
|
||||
@inject HttpClient HttpClient
|
||||
@inject ToastService ToastService
|
||||
|
||||
<DialogHeader>
|
||||
<DialogTitle>Create Docker Image</DialogTitle>
|
||||
<DialogDescription>
|
||||
Create a new docker image
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
<EnhancedEditForm @ref="Form" Model="Model" OnValidSubmit="OnValidSubmitAsync">
|
||||
<FieldGroup>
|
||||
<DataAnnotationsValidator/>
|
||||
<FormValidationSummary/>
|
||||
|
||||
<FieldSet>
|
||||
<Field>
|
||||
<FieldLabel for="dockerImageDisplayName">Display Name</FieldLabel>
|
||||
<TextInputField
|
||||
@bind-Value="Model.DisplayName"
|
||||
id="dockerImageDisplayName"/>
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<FieldLabel for="dockerImageIdentifier">Image Name</FieldLabel>
|
||||
<TextInputField
|
||||
@bind-Value="Model.ImageName"
|
||||
id="dockerImageIdentifier"/>
|
||||
</Field>
|
||||
|
||||
<Field>
|
||||
<FieldLabel for="dockerImageSkipPulling">Skip Pulling</FieldLabel>
|
||||
<Switch id="dockerImageSkipPulling" @bind-Value="Model.SkipPulling" />
|
||||
</Field>
|
||||
</FieldSet>
|
||||
</FieldGroup>
|
||||
</EnhancedEditForm>
|
||||
<DialogFooter>
|
||||
<DialogClose>
|
||||
<Slot>
|
||||
<Button Type="button" Variant="ButtonVariant.Outline" @attributes="context">
|
||||
Cancel
|
||||
</Button>
|
||||
</Slot>
|
||||
</DialogClose>
|
||||
<Button @onclick="() => Form.SubmitAsync()" Type="button">
|
||||
Save
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
|
||||
@code
|
||||
{
|
||||
[Parameter] public DetailedTemplateDto Template { get; set; }
|
||||
[Parameter] public Func<Task> OnSubmit { get; set; }
|
||||
|
||||
private CreateDockerImageDto Model = new();
|
||||
private EnhancedEditForm Form;
|
||||
|
||||
private async Task<bool> OnValidSubmitAsync(EditContext editContext, ValidationMessageStore validationMessageStore)
|
||||
{
|
||||
var response = await HttpClient.PostAsJsonAsync(
|
||||
$"api/admin/servers/templates/{Template.Id}/dockerImages",
|
||||
Model,
|
||||
SerializationContext.Default.Options
|
||||
);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
await ProblemDetailsHelper.HandleProblemDetailsAsync(response, Model, validationMessageStore);
|
||||
return false;
|
||||
}
|
||||
|
||||
await OnSubmit.Invoke();
|
||||
|
||||
await ToastService.SuccessAsync(
|
||||
"Docker Image Creation",
|
||||
$"Successfully created variable {Model.DisplayName}"
|
||||
);
|
||||
|
||||
await CloseAsync();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user