feat(client): migrate PartOperationFilterPanel to API clients
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
@* Part operation/MIS filter panel with upload/download/clear functionality *@
|
||||
@inject IFileService FileService
|
||||
@using JdeScoping.Core.ApiContracts
|
||||
@inject IFileApiClient FileApi
|
||||
@inject DialogService DialogService
|
||||
@inject NotificationService NotificationService
|
||||
|
||||
@@ -49,7 +50,15 @@
|
||||
|
||||
private async Task DownloadTemplateAsync()
|
||||
{
|
||||
await FileService.DownloadTemplateAsync("partoperations", PartOperations);
|
||||
var result = await FileApi.DownloadPartOperationsTemplateAsync(PartOperations.AsReadOnly());
|
||||
result.Switch(
|
||||
bytes => { _ = JSRuntime.InvokeVoidAsync("downloadFile", "partoperations_template.xlsx", bytes); },
|
||||
_ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Template not found."); },
|
||||
validation => { NotificationService.Notify(NotificationSeverity.Error, "Error", string.Join("; ", validation.FieldErrors.SelectMany(e => e.Value))); },
|
||||
_ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Session expired."); },
|
||||
_ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Access denied."); },
|
||||
error => { NotificationService.Notify(NotificationSeverity.Error, "Error", error.Message); }
|
||||
);
|
||||
}
|
||||
|
||||
private async Task TriggerFileInput()
|
||||
@@ -65,19 +74,22 @@
|
||||
try
|
||||
{
|
||||
using var stream = e.File.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024); // 10MB max
|
||||
var result = await FileService.UploadAsync<PartOperationViewModel>("partoperations", stream, e.File.Name);
|
||||
var result = await FileApi.UploadPartOperationsAsync(stream, e.File.Name);
|
||||
|
||||
if (result.WasSuccessful)
|
||||
{
|
||||
PartOperations.Clear();
|
||||
PartOperations.AddRange(result.Data);
|
||||
await PartOperationsChanged.InvokeAsync(PartOperations);
|
||||
NotificationService.Notify(NotificationSeverity.Success, "Upload Complete", $"Loaded {result.Data.Count} part operations.");
|
||||
}
|
||||
else
|
||||
{
|
||||
NotificationService.Notify(NotificationSeverity.Error, "Upload Failed", result.ErrorMessage);
|
||||
}
|
||||
result.Switch(
|
||||
partOperations =>
|
||||
{
|
||||
PartOperations.Clear();
|
||||
PartOperations.AddRange(partOperations);
|
||||
_ = PartOperationsChanged.InvokeAsync(PartOperations);
|
||||
NotificationService.Notify(NotificationSeverity.Success, "Upload Complete", $"Loaded {partOperations.Count} part operations.");
|
||||
},
|
||||
_ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Upload endpoint not found."); },
|
||||
validation => { NotificationService.Notify(NotificationSeverity.Error, "Upload Failed", string.Join("; ", validation.FieldErrors.SelectMany(e => e.Value))); },
|
||||
_ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Session expired."); },
|
||||
_ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Access denied."); },
|
||||
error => { NotificationService.Notify(NotificationSeverity.Error, "Upload Failed", error.Message); }
|
||||
);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user