2025-05-18 21:31:15 +02:00
|
|
|
using AIStudio.Components;
|
2025-02-09 12:36:37 +01:00
|
|
|
using AIStudio.Settings;
|
|
|
|
|
using AIStudio.Settings.DataModel;
|
|
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
|
|
|
|
|
|
namespace AIStudio.Dialogs;
|
|
|
|
|
|
2025-05-18 21:31:15 +02:00
|
|
|
public partial class DataSourceLocalFileInfoDialog : MSGComponentBase
|
2025-02-09 12:36:37 +01:00
|
|
|
{
|
|
|
|
|
[CascadingParameter]
|
2025-03-12 19:12:56 +01:00
|
|
|
private IMudDialogInstance MudDialog { get; set; } = null!;
|
2025-02-09 12:36:37 +01:00
|
|
|
|
|
|
|
|
[Parameter]
|
|
|
|
|
public DataSourceLocalFile DataSource { get; set; }
|
|
|
|
|
|
|
|
|
|
#region Overrides of ComponentBase
|
|
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
2026-01-09 15:41:54 +01:00
|
|
|
this.embeddingProvider = this.SettingsManager.ConfigurationData.EmbeddingProviders.FirstOrDefault(x => x.Id == this.DataSource.EmbeddingId) ?? EmbeddingProvider.NONE;
|
2025-02-09 12:36:37 +01:00
|
|
|
this.fileInfo = new FileInfo(this.DataSource.FilePath);
|
|
|
|
|
await base.OnInitializedAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
2026-01-09 15:41:54 +01:00
|
|
|
private EmbeddingProvider embeddingProvider = EmbeddingProvider.NONE;
|
2025-02-09 12:36:37 +01:00
|
|
|
private FileInfo fileInfo = null!;
|
|
|
|
|
|
2026-06-21 15:16:37 +02:00
|
|
|
private bool IsCloudEmbedding => !this.embeddingProvider.IsTrustedForDataSourceSecurityChecks(this.SettingsManager);
|
2025-02-09 12:36:37 +01:00
|
|
|
|
|
|
|
|
private bool IsFileAvailable => this.fileInfo.Exists;
|
|
|
|
|
|
|
|
|
|
private string FileSize => this.fileInfo.FileSize();
|
2026-10-23 09:27:22 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The level which applies, including what the organization demands.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private string OutboundDataRestrictionName => this.DataSource.GetEffectiveOutboundDataRestriction(this.SettingsManager.ConfigurationData.DataSourceSecurity.MinimumOutboundDataRestriction).GetName();
|
2025-02-09 12:36:37 +01:00
|
|
|
|
|
|
|
|
private void Close() => this.MudDialog.Close();
|
|
|
|
|
}
|