unused files removed

This commit is contained in:
2024-09-22 23:12:27 +02:00
Unverified
parent de0eac4a0c
commit e38d954f16
4 changed files with 0 additions and 227 deletions

View File

@@ -1,96 +0,0 @@
<div class="row">
<div class="col-auto rounded-3 panel panel-regular m-1 p-3">
<img class="rounded-2 shadow mb-1" src="@(_posterBase64 is not null ? $"data:{_posterMediaType};base64,{_posterBase64}" : "assets/poster.png")" alt="poster" width="300" height="500"/>
<br/>
<InputFile id="posterInput" class="form-control my-1" OnChange="LoadPoster" disabled=@(!Id.HasValue) autocomplete="off"/>
@if (_posterChanged || !string.IsNullOrWhiteSpace(_actualPosterBase64))
{
<div id="posterButtons" class="container-fluid mt-2 p-0">
<div class="row gx-1">
@if (_posterChanged)
{
<div class="col">
<button type="button" class="btn btn-secondary btn-block btn-stretch-x" @onclick="SavePoster" disabled=@(!Id.HasValue || _posterLoading) autocomplete="off">Save poster</button>
</div>
<div class="col">
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="CancelPoster" disabled=@(!Id.HasValue || _posterLoading) autocomplete="off">Drop changes</button>
</div>
}
else if (!string.IsNullOrWhiteSpace(_actualPosterBase64))
{
<div class="col">
<button type="button" class="btn btn-danger btn-block btn-stretch-x" @onclick="DeletePoster" disabled=@(!Id.HasValue || _posterLoading) autocomplete="off">Delete poster</button>
</div>
}
@if (_posterLoading)
{
<div class="col-auto">
<div class="d-flex align-items-center justify-content-center">
<div class="spinner-border" role="status"></div>
</div>
</div>
}
</div>
</div>
}
</div>
<div class="col rounded-3 panel panel-regular m-1 p-3">
<EditForm Model="Data" FormName="MediaInfo">
<AntiforgeryToken/>
<div class="form-group row my-1">
<label for="title" class="col-2 col-form-label">Title*</label>
<div class="col-10">
<InputText id="title" class="form-control" @bind-Value="Data!.Title"/>
</div>
</div>
<div class="form-group row my-1">
<label for="originalTitle" class="col-2 col-form-label">Original title</label>
<div class="col-10">
<InputText id="originalTitle" class="form-control" @bind-Value="Data!.OriginalTitle"/>
</div>
</div>
<div class="form-group row my-1">
<label for="description" class="col-2 col-form-label">Description</label>
<div class="col-10">
<InputTextArea id="description" class="form-control" rows="14" @bind-Value="Data!.Description"/>
</div>
</div>
<div class="form-group row my-1">
<label for="releaseDate" class="col-2 col-form-label">Release date</label>
<div class="col-10">
<InputDate TValue="DateOnly?" id="releaseDate" class="form-control" @bind-Value="Data!.ReleaseDate"/>
</div>
</div>
<div class="form-group row my-1">
<label for="length" class="col-2 col-form-label">Length</label>
<div class="col-10">
<InputNumber TValue="short?" id="length" class="form-control" @bind-Value="Data!.Length"/>
</div>
</div>
<div class="row my-1 mt-3">
<div class="col d-flex align-items-center">
@if (SaveDataErrors is not null && SaveDataErrors.Any())
{
<p class="text-danger m-0">@(SaveDataErrors.ElementAt(0))</p>
}
else if (!string.IsNullOrWhiteSpace(SaveDataInfo))
{
<p class="text-success m-0">@(SaveDataInfo)</p>
}
</div>
<div class="col-auto">
<button type="button" class="btn btn-secondary" @onclick="SaveDataAction">Save data</button>
</div>
</div>
</EditForm>
</div>
</div>
<style>
#posterInput, #posterButtons {
width: 300px;
}
</style>

View File

@@ -1,125 +0,0 @@
using System.Diagnostics;
using System.Text;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using WatchIt.Common.Model.Media;
using WatchIt.Website.Services.WebAPI.Media;
namespace WatchIt.Website.Components;
public partial class MediaFormComponent : ComponentBase
{
#region SERVICES
[Inject] public NavigationManager NavigationManager { get; set; } = default!;
[Inject] public IMediaWebAPIService MediaWebAPIService { get; set; } = default!;
#endregion
#region PROPERTIES
[Parameter] public Media Data { get; set; }
[Parameter] public long? Id { get; set; }
[Parameter] public Func<Task> SaveDataAction { get; set; }
[Parameter] public IEnumerable<string>? SaveDataErrors { get; set; }
[Parameter] public string? SaveDataInfo { get; set; }
#endregion
#region FIELDS
private string? _actualPosterBase64 = null;
private string? _actualPosterMediaType = null;
private bool _posterChanged = false;
private string? _posterBase64 = null;
private string? _posterMediaType = null;
private bool _posterLoading = false;
#endregion
#region PRIVATE METHODS
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
await MediaWebAPIService.GetPoster(Id.Value, (data) =>
{
_actualPosterBase64 = Encoding.UTF8.GetString(data.Image);
_actualPosterMediaType = data.MimeType;
_posterBase64 = _actualPosterBase64;
_posterMediaType = _actualPosterMediaType;
});
StateHasChanged();
}
}
private async Task LoadPoster(InputFileChangeEventArgs args)
{
if (args.File.ContentType.StartsWith("image"))
{
Stream stream = args.File.OpenReadStream(5242880);
byte[] array;
using (MemoryStream ms = new MemoryStream())
{
await stream.CopyToAsync(ms);
array = ms.ToArray();
}
_posterMediaType = args.File.ContentType;
_posterBase64 = Convert.ToBase64String(array);
_posterChanged = true;
}
}
private async Task SavePoster()
{
void SuccessAction(MediaPosterResponse data)
{
_actualPosterBase64 = _posterBase64;
_actualPosterMediaType = _posterMediaType;
_posterChanged = false;
_posterLoading = false;
}
MediaPosterRequest data = new MediaPosterRequest
{
Image = Encoding.UTF8.GetBytes(_posterBase64),
MimeType = _posterMediaType
};
_posterLoading = true;
await MediaWebAPIService.PutPoster(Id.Value, data, SuccessAction);
}
private async Task DeletePoster()
{
void SuccessAction()
{
_actualPosterBase64 = null;
_actualPosterMediaType = null;
_posterChanged = false;
_posterBase64 = null;
_posterMediaType = null;
_posterLoading = false;
}
_posterLoading = true;
await MediaWebAPIService.DeletePoster(Id.Value, SuccessAction);
}
private void CancelPoster()
{
_posterBase64 = _actualPosterBase64;
_posterMediaType = _actualPosterMediaType;
_posterChanged = false;
}
#endregion
}

View File

@@ -1,5 +0,0 @@
/* IDS */
#posterInput, #posterButtons {
width: 300px;
}