Added an auto-save option

This commit is contained in:
Thorsten Sommer 2024-12-19 11:51:38 +01:00
parent bbc906f4ca
commit 720c530e28
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
3 changed files with 54 additions and 3 deletions

View File

@ -20,7 +20,19 @@
<PreviewPrototype/> <PreviewPrototype/>
<div class="mb-6"></div> <div class="mb-6"></div>
<MudText Typo="Typo.h4" Class="mb-1"> <MudText Typo="Typo.h4" Class="mb-3">
Auto Save
</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
The ERI specification will change over time. You probably want to keep your ERI server up to date. This means you might want to
regenerate the code for your ERI server. To avoid having to make all inputs each time, all your inputs and decisions can be
automatically saved. Would you like this?
</MudText>
<MudTextSwitch Label="Should we automatically save any input made?" @bind-Value="@this.autoSave" LabelOn="Yes, please save my inputs" LabelOff="No, I will enter everything again or configure it manually in the settings" />
<MudText Typo="Typo.h4" Class="mt-6 mb-1">
Common ERI server settings Common ERI server settings
</MudText> </MudText>
<MudTextField T="string" @bind-Text="@this.serverName" Validation="@this.ValidateServerName" Immediate="@true" Label="ERI server name" HelperText="Please give your ERI server a name that provides information about the data source and/or its intended purpose. The name will be displayed to users in AI Studio." Counter="60" MaxLength="60" Variant="Variant.Outlined" Margin="Margin.Normal" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/> <MudTextField T="string" @bind-Text="@this.serverName" Validation="@this.ValidateServerName" Immediate="@true" Label="ERI server name" HelperText="Please give your ERI server a name that provides information about the data source and/or its intended purpose. The name will be displayed to users in AI Studio." Counter="60" MaxLength="60" Variant="Variant.Outlined" Margin="Margin.Normal" UserAttributes="@USER_INPUT_ATTRIBUTES" Class="mb-3"/>

View File

@ -63,6 +63,7 @@ public partial class AssistantERI : AssistantBaseCore
protected override bool MightPreselectValues() protected override bool MightPreselectValues()
{ {
this.autoSave = this.SettingsManager.ConfigurationData.ERI.AutoSaveChanges;
if (this.SettingsManager.ConfigurationData.ERI.PreselectOptions) if (this.SettingsManager.ConfigurationData.ERI.PreselectOptions)
{ {
this.serverName = this.SettingsManager.ConfigurationData.ERI.PreselectedServerName; this.serverName = this.SettingsManager.ConfigurationData.ERI.PreselectedServerName;
@ -90,6 +91,36 @@ public partial class AssistantERI : AssistantBaseCore
return false; return false;
} }
protected override async Task OnFormChange()
{
await this.AutoSave();
}
private async Task AutoSave()
{
if(!this.autoSave)
return;
this.SettingsManager.ConfigurationData.ERI.PreselectedServerName = this.serverName;
this.SettingsManager.ConfigurationData.ERI.PreselectedServerDescription = this.serverDescription;
this.SettingsManager.ConfigurationData.ERI.PreselectedERIVersion = this.selectedERIVersion;
this.SettingsManager.ConfigurationData.ERI.PreselectedProgrammingLanguage = this.selectedProgrammingLanguage;
this.SettingsManager.ConfigurationData.ERI.PreselectedOtherProgrammingLanguage = this.otherProgrammingLanguage;
this.SettingsManager.ConfigurationData.ERI.PreselectedDataSource = this.selectedDataSource;
this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourceProductName = this.dataSourceProductName;
this.SettingsManager.ConfigurationData.ERI.PreselectedOtherDataSource = this.otherDataSource;
this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourceHostname = this.dataSourceHostname;
this.SettingsManager.ConfigurationData.ERI.PreselectedDataSourcePort = this.dataSourcePort;
this.SettingsManager.ConfigurationData.ERI.PreselectedAuthMethods = [..this.selectedAuthenticationMethods];
this.SettingsManager.ConfigurationData.ERI.PreselectedAuthDescription = this.authDescription;
this.SettingsManager.ConfigurationData.ERI.PreselectedOperatingSystem = this.selectedOperatingSystem;
this.SettingsManager.ConfigurationData.ERI.PreselectedAllowedLLMProviders = this.allowedLLMProviders;
this.SettingsManager.ConfigurationData.ERI.PreselectedRetrievalDescription = this.retrievalDescription;
this.SettingsManager.ConfigurationData.ERI.PreselectedAdditionalLibraries = this.additionalLibraries;
await this.SettingsManager.StoreSettings();
}
private bool autoSave;
private string serverName = string.Empty; private string serverName = string.Empty;
private string serverDescription = string.Empty; private string serverDescription = string.Empty;
private ERIVersion selectedERIVersion = ERIVersion.V1; private ERIVersion selectedERIVersion = ERIVersion.V1;
@ -303,7 +334,9 @@ public partial class AssistantERI : AssistantBaseCore
private bool IsAuthDescriptionOptional() private bool IsAuthDescriptionOptional()
{ {
var authenticationMethods = (this.selectedAuthenticationMethods as HashSet<Auth>)!; if (this.selectedAuthenticationMethods is not HashSet<Auth> authenticationMethods)
return true;
if(authenticationMethods.Count > 1) if(authenticationMethods.Count > 1)
return false; return false;
@ -359,6 +392,7 @@ public partial class AssistantERI : AssistantBaseCore
private async Task GenerateServer() private async Task GenerateServer()
{ {
await this.AutoSave();
await this.form!.Validate(); await this.form!.Validate();
if (!this.inputIsValid) if (!this.inputIsValid)
return; return;

View File

@ -7,10 +7,15 @@ namespace AIStudio.Settings.DataModel;
public sealed class DataERI public sealed class DataERI
{ {
/// <summary>
/// Should we automatically save any input made in the ERI assistant?
/// </summary>
public bool AutoSaveChanges { get; set; } = true;
/// <summary> /// <summary>
/// Preselect any ERI options? /// Preselect any ERI options?
/// </summary> /// </summary>
public bool PreselectOptions { get; set; } public bool PreselectOptions { get; set; } = true;
/// <summary> /// <summary>
/// Preselect the server name? /// Preselect the server name?