diff --git a/app/MindWork AI Studio/Components/Pages/IconFinder/AssistantIconFinder.razor.cs b/app/MindWork AI Studio/Components/Pages/IconFinder/AssistantIconFinder.razor.cs index a04398b7..a2cf3671 100644 --- a/app/MindWork AI Studio/Components/Pages/IconFinder/AssistantIconFinder.razor.cs +++ b/app/MindWork AI Studio/Components/Pages/IconFinder/AssistantIconFinder.razor.cs @@ -5,6 +5,21 @@ public partial class AssistantIconFinder : AssistantBaseCore private string inputContext = string.Empty; private IconSources selectedIconSource; + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + if (this.SettingsManager.ConfigurationData.PreselectIconOptions) + { + this.selectedIconSource = this.SettingsManager.ConfigurationData.PreselectedIconSource; + this.providerSettings = this.SettingsManager.ConfigurationData.Providers.FirstOrDefault(x => x.Id == this.SettingsManager.ConfigurationData.PreselectedIconProvider); + } + + await base.OnInitializedAsync(); + } + + #endregion + protected override string Title => "Icon Finder"; protected override string Description => diff --git a/app/MindWork AI Studio/Components/Pages/Settings.razor b/app/MindWork AI Studio/Components/Pages/Settings.razor index a616915c..e63918ea 100644 --- a/app/MindWork AI Studio/Components/Pages/Settings.razor +++ b/app/MindWork AI Studio/Components/Pages/Settings.razor @@ -60,10 +60,7 @@ No providers configured yet. } - + Add Provider @@ -79,5 +76,11 @@ Workspace Options + + Assistants Options + Icon Finder Options + + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Pages/Settings.razor.cs b/app/MindWork AI Studio/Components/Pages/Settings.razor.cs index 2bf6f5f0..650e40d7 100644 --- a/app/MindWork AI Studio/Components/Pages/Settings.razor.cs +++ b/app/MindWork AI Studio/Components/Pages/Settings.razor.cs @@ -24,6 +24,18 @@ public partial class Settings : ComponentBase [Inject] protected MessageBus MessageBus { get; init; } = null!; + + private readonly List> availableProviders = new(); + + #region Overrides of ComponentBase + + protected override async Task OnInitializedAsync() + { + this.UpdateProviders(); + await base.OnInitializedAsync(); + } + + #endregion #region Provider related @@ -43,6 +55,8 @@ public partial class Settings : ComponentBase addedProvider = addedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ }; this.SettingsManager.ConfigurationData.Providers.Add(addedProvider); + this.UpdateProviders(); + await this.SettingsManager.StoreSettings(); await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); } @@ -75,6 +89,8 @@ public partial class Settings : ComponentBase editedProvider = editedProvider with { Num = this.SettingsManager.ConfigurationData.NextProviderNum++ }; this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider; + this.UpdateProviders(); + await this.SettingsManager.StoreSettings(); await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); } @@ -99,6 +115,7 @@ public partial class Settings : ComponentBase await this.SettingsManager.StoreSettings(); } + this.UpdateProviders(); await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); } @@ -128,6 +145,13 @@ public partial class Settings : ComponentBase var modelName = provider.Model.ToString(); return modelName.Length > MAX_LENGTH ? "[...] " + modelName[^Math.Min(MAX_LENGTH, modelName.Length)..] : modelName; } + + private void UpdateProviders() + { + this.availableProviders.Clear(); + foreach (var provider in this.SettingsManager.ConfigurationData.Providers) + this.availableProviders.Add(new (provider.InstanceName, provider.Id)); + } #endregion } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs index 74207eec..82e01531 100644 --- a/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs +++ b/app/MindWork AI Studio/Settings/ConfigurationSelectData.cs @@ -1,3 +1,4 @@ +using AIStudio.Components.Pages.IconFinder; using AIStudio.Settings.DataModel; namespace AIStudio.Settings; @@ -55,4 +56,10 @@ public static class ConfigurationSelectDataFactory yield return new("Navigation never expands, no tooltips", NavBehavior.NEVER_EXPAND_NO_TOOLTIPS); yield return new("Always expand navigation", NavBehavior.ALWAYS_EXPAND); } + + public static IEnumerable> GetIconSourcesData() + { + foreach (var source in Enum.GetValues()) + yield return new(source.ToString(), source); + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/DataModel/Data.cs b/app/MindWork AI Studio/Settings/DataModel/Data.cs index 7304d882..6a1711e9 100644 --- a/app/MindWork AI Studio/Settings/DataModel/Data.cs +++ b/app/MindWork AI Studio/Settings/DataModel/Data.cs @@ -1,3 +1,5 @@ +using AIStudio.Components.Pages.IconFinder; + namespace AIStudio.Settings.DataModel; /// @@ -56,4 +58,19 @@ public sealed class Data /// The navigation behavior. /// public NavBehavior NavigationBehavior { get; set; } = NavBehavior.EXPAND_ON_HOVER; + + /// + /// Do we want to preselect an icon source? + /// + public bool PreselectIconOptions { get; set; } + + /// + /// The preselected icon source. + /// + public IconSources PreselectedIconSource { get; set; } + + /// + /// The preselected icon provider. + /// + public string PreselectedIconProvider { get; set; } = string.Empty; } \ No newline at end of file