feat: Aggiunto sistema completo di gestione profili per Data Coupler
- Creata nuova libreria Components con componenti Blazor riutilizzabili * ProfileSelector: dropdown per selezione profili salvati * ProfileSaver: componente per salvare configurazioni correnti come profili * ProfileManagement: modale per gestione profili salvati * ProfileQuickActions: bottoni azioni rapide per operazioni sui profili - Esteso CredentialManager con entità e servizi per DataCouplerProfile * Aggiunto modello DataCouplerProfile con configurazioni mapping e metadati * Implementata migrazione Entity Framework per memorizzazione profili * Creato DataCouplerProfileService per operazioni CRUD * Aggiunto CredentialDbContextFactory per operazioni database design-time - Migliorato componente principale DataCoupler con integrazione profili * Integrata funzionalità caricamento/salvataggio profili * Aggiunto selettore profili nella parte superiore dell'interfaccia * Mantenuta retrocompatibilità con funzionalità esistenti * Migliorata esperienza utente con gestione configurazioni salvate - Aggiornata struttura progetto e dipendenze * Aggiunto progetto Components alla soluzione * Aggiornati riferimenti progetti e import * Rimosso progetto obsoleto TestDatabaseFix Questo aggiornamento migliora significativamente il flusso di lavoro permettendo agli utenti di salvare, caricare e gestire configurazioni complete di accoppiamento dati come
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using CredentialManager.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Components;
|
||||
|
||||
public partial class ProfileSaver
|
||||
{
|
||||
[Parameter] public bool CanSave { get; set; }
|
||||
[Parameter] public string SourceType { get; set; } = "";
|
||||
[Parameter] public int? SourceCredentialId { get; set; }
|
||||
[Parameter] public string? SourceSchema { get; set; }
|
||||
[Parameter] public string? SourceTable { get; set; }
|
||||
[Parameter] public string? SourceFilePath { get; set; }
|
||||
[Parameter] public string DestinationType { get; set; } = "";
|
||||
[Parameter] public int? DestinationCredentialId { get; set; }
|
||||
[Parameter] public string? DestinationSchema { get; set; }
|
||||
[Parameter] public string? DestinationTable { get; set; }
|
||||
[Parameter] public string? DestinationEndpoint { get; set; }
|
||||
[Parameter] public List<FieldMappingDto>? FieldMappings { get; set; }
|
||||
[Parameter] public EventCallback<DataCouplerProfileDto> OnProfileSaved { get; set; }
|
||||
|
||||
private bool ShowSaveForm { get; set; } = false;
|
||||
private bool IsSaving { get; set; } = false;
|
||||
private string SaveMessage { get; set; } = "";
|
||||
private string SaveMessageType { get; set; } = "info";
|
||||
private ProfileFormModel ProfileData { get; set; } = new();
|
||||
|
||||
private void ShowSaveDialog()
|
||||
{
|
||||
ProfileData = new ProfileFormModel();
|
||||
ShowSaveForm = true;
|
||||
SaveMessage = "";
|
||||
}
|
||||
|
||||
private void CancelSave()
|
||||
{
|
||||
ShowSaveForm = false;
|
||||
SaveMessage = "";
|
||||
ProfileData = new();
|
||||
}
|
||||
|
||||
private async Task SaveProfile()
|
||||
{
|
||||
IsSaving = true;
|
||||
SaveMessage = "";
|
||||
|
||||
try
|
||||
{
|
||||
var profileDto = new DataCouplerProfileDto
|
||||
{
|
||||
Name = ProfileData.Name,
|
||||
Description = ProfileData.Description,
|
||||
SourceType = SourceType,
|
||||
SourceCredentialId = SourceCredentialId,
|
||||
SourceSchema = SourceSchema,
|
||||
SourceTable = SourceTable,
|
||||
SourceFilePath = SourceFilePath,
|
||||
DestinationType = DestinationType,
|
||||
DestinationCredentialId = DestinationCredentialId,
|
||||
DestinationSchema = DestinationSchema,
|
||||
DestinationTable = DestinationTable,
|
||||
DestinationEndpoint = DestinationEndpoint,
|
||||
FieldMappings = FieldMappings
|
||||
};
|
||||
|
||||
await OnProfileSaved.InvokeAsync(profileDto);
|
||||
|
||||
SaveMessage = $"Profilo '{ProfileData.Name}' salvato con successo!";
|
||||
SaveMessageType = "success";
|
||||
|
||||
// Reset form after successful save
|
||||
await Task.Delay(1500); // Show success message briefly
|
||||
ShowSaveForm = false;
|
||||
ProfileData = new();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SaveMessage = $"Errore nel salvataggio: {ex.Message}";
|
||||
SaveMessageType = "danger";
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsSaving = false;
|
||||
}
|
||||
}
|
||||
|
||||
private string GetSourceSummary()
|
||||
{
|
||||
return SourceType switch
|
||||
{
|
||||
"database" => "Database",
|
||||
"file" => "File Excel/CSV",
|
||||
_ => "Non configurato"
|
||||
};
|
||||
}
|
||||
|
||||
private string GetDestinationSummary()
|
||||
{
|
||||
return DestinationType switch
|
||||
{
|
||||
"database" => "Database",
|
||||
"rest" => "REST API",
|
||||
_ => "Non configurato"
|
||||
};
|
||||
}
|
||||
|
||||
public void SetMessage(string message, string type = "info")
|
||||
{
|
||||
SaveMessage = message;
|
||||
SaveMessageType = type;
|
||||
}
|
||||
|
||||
public class ProfileFormModel
|
||||
{
|
||||
[Required(ErrorMessage = "Il nome del profilo è obbligatorio")]
|
||||
[StringLength(100, ErrorMessage = "Il nome non può superare i 100 caratteri")]
|
||||
public string Name { get; set; } = "";
|
||||
|
||||
[StringLength(500, ErrorMessage = "La descrizione non può superare i 500 caratteri")]
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user