This commit is contained in:
Đăng Nguyễn
2025-11-04 10:57:41 +07:00
parent 70e27da4a2
commit 73038de662
12 changed files with 226 additions and 84 deletions

View File

@@ -306,7 +306,7 @@ public partial class RobotConfigManager
}
}
private async Task<bool> SaveCertificates(Guid id)
private async Task<bool> SaveCertificates()
{
using var content = new MultipartFormDataContent();
@@ -325,12 +325,16 @@ public partial class RobotConfigManager
var fileContent = new StreamContent(RobotVDA5050ConfigRef.KeyFile.OpenReadStream(maxAllowedSize: RobotVDA5050ConfigRef.MaxFileSize));
content.Add(fileContent, "KeyFile", RobotVDA5050ConfigRef.KeyFile.Name);
}
var response = await (await Http.PostAsync($"api/File/certificates/{id}", content)).Content.ReadFromJsonAsync<MessageResult>();
if (response is null) Snackbar.Add("Failed to update certificates", Severity.Warning);
else if (!response.IsSuccess) Snackbar.Add(response.Message ?? "Failed to update certificates config", Severity.Warning);
else return true;
return false;
if (content.Any())
{
var response = await (await Http.PostAsync($"api/File/certificates", content)).Content.ReadFromJsonAsync<MessageResult>();
if (response is null) Snackbar.Add("Failed to update certificates", Severity.Warning);
else if (!response.IsSuccess) Snackbar.Add(response.Message ?? "Failed to update certificates", Severity.Warning);
else return true;
StateHasChanged();
return false;
}
return true;
}
private async Task SaveConfig()
@@ -377,7 +381,7 @@ public partial class RobotConfigManager
SelectedVda.VDA5050Key,
SelectedVda.Description
};
var saveCer = await SaveCertificates(SelectedVda.Id);
var saveCer = await SaveCertificates();
if (saveCer) result = await (await Http.PutAsJsonAsync($"api/RobotConfigs/vda5050/{id}", updateDto)).Content.ReadFromJsonAsync<MessageResult>();
else return;
break;
@@ -551,4 +555,13 @@ public partial class RobotConfigManager
StateHasChanged();
}
}
private async Task LoadConfig()
{
var response = await (await Http.PostAsync($"api/RobotConfigs/load", null)).Content.ReadFromJsonAsync<MessageResult>();
if (response is null) Snackbar.Add("Failed to load config", Severity.Warning);
else if (!response.IsSuccess) Snackbar.Add(response.Message ?? "Failed to load config", Severity.Warning);
else Snackbar.Add("Config loaded", Severity.Success);
StateHasChanged();
}
}