diff --git a/app/MindWork AI Studio/Components/ConfigurationSelectData.cs b/app/MindWork AI Studio/Components/ConfigurationSelectData.cs index 6ed436ed..cdb9cf4d 100644 --- a/app/MindWork AI Studio/Components/ConfigurationSelectData.cs +++ b/app/MindWork AI Studio/Components/ConfigurationSelectData.cs @@ -47,4 +47,12 @@ public static class ConfigurationSelectDataFactory yield return new("Delete temporary chats older than 180 days", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_180_DAYS); yield return new("Delete temporary chats older than 1 year", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_365_DAYS); } + + public static IEnumerable> GetNavBehaviorData() + { + yield return new("Navigation expands on mouse hover", NavBehavior.EXPAND_ON_HOVER); + yield return new("Navigation never expands, but there are tooltips", NavBehavior.NEVER_EXPAND_USE_TOOLTIPS); + yield return new("Navigation never expands, no tooltips", NavBehavior.NEVER_EXPAND_NO_TOOLTIPS); + yield return new("Always expand navigation", NavBehavior.ALWAYS_EXPAND); + } } \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Layout/MainLayout.razor b/app/MindWork AI Studio/Components/Layout/MainLayout.razor index 052ec944..1e6eb6ac 100644 --- a/app/MindWork AI Studio/Components/Layout/MainLayout.razor +++ b/app/MindWork AI Studio/Components/Layout/MainLayout.razor @@ -1,36 +1,32 @@ -@inherits LayoutComponentBase +@using AIStudio.Settings +@inherits LayoutComponentBase @if (!this.performingUpdate) { - + - - Home - - - Chat - - - Assistants - - - Supporters - - - About - - - Settings - + @foreach (var navBarItem in NAV_ITEMS) + { + if (this.SettingsManager.ConfigurationData.NavigationBehavior is NavBehavior.NEVER_EXPAND_USE_TOOLTIPS) + { + + @navBarItem.Name + + } + else + { + @navBarItem.Name + } + } } - + @if (!this.performingUpdate && this.IsUpdateAlertVisible) { diff --git a/app/MindWork AI Studio/Components/Layout/MainLayout.razor.cs b/app/MindWork AI Studio/Components/Layout/MainLayout.razor.cs index 040591a8..6223b33e 100644 --- a/app/MindWork AI Studio/Components/Layout/MainLayout.razor.cs +++ b/app/MindWork AI Studio/Components/Layout/MainLayout.razor.cs @@ -34,12 +34,30 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver public string AdditionalHeight { get; private set; } = "0em"; + private string PaddingLeft => this.navBarOpen ? $"padding-left: {NAVBAR_EXPANDED_WIDTH_INT - NAVBAR_COLLAPSED_WIDTH_INT}em;" : "padding-left: 0em;"; + + private const int NAVBAR_COLLAPSED_WIDTH_INT = 4; + private const int NAVBAR_EXPANDED_WIDTH_INT = 10; + private static readonly string NAVBAR_COLLAPSED_WIDTH = $"{NAVBAR_COLLAPSED_WIDTH_INT}em"; + private static readonly string NAVBAR_EXPANDED_WIDTH = $"{NAVBAR_EXPANDED_WIDTH_INT}em"; + + private bool navBarOpen; private bool isUpdateAvailable; private bool performingUpdate; private bool userDismissedUpdate; private string updateToVersion = string.Empty; private UpdateResponse? currentUpdateResponse; + private static readonly IReadOnlyCollection NAV_ITEMS = new List + { + new("Home", Icons.Material.Filled.Home, Color.Default, "/", true), + new("Chat", Icons.Material.Filled.Chat, Color.Default, "/chat", false), + new("Assistants", Icons.Material.Filled.Apps, Color.Default ,"/assistants", false), + new("Supporters", Icons.Material.Filled.Favorite, Color.Error ,"/supporters", false), + new("About", Icons.Material.Filled.Info, Color.Default ,"/about", false), + new("Settings", Icons.Material.Filled.Settings, Color.Default ,"/settings", false), + }; + #region Overrides of ComponentBase protected override async Task OnInitializedAsync() @@ -63,12 +81,16 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver // Register this component with the message bus: this.MessageBus.RegisterComponent(this); - this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.USER_SEARCH_FOR_UPDATE ]); + this.MessageBus.ApplyFilters(this, [], [ Event.UPDATE_AVAILABLE, Event.USER_SEARCH_FOR_UPDATE, Event.CONFIGURATION_CHANGED ]); // Set the js runtime for the update service: UpdateService.SetBlazorDependencies(this.JsRuntime, this.Snackbar); TemporaryChatService.Initialize(); + // Should the navigation bar be open by default? + if(this.SettingsManager.ConfigurationData.NavigationBehavior is NavBehavior.ALWAYS_EXPAND) + this.navBarOpen = true; + await base.OnInitializedAsync(); } @@ -96,6 +118,15 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver } break; + + case Event.CONFIGURATION_CHANGED: + if(this.SettingsManager.ConfigurationData.NavigationBehavior is NavBehavior.ALWAYS_EXPAND) + this.navBarOpen = true; + else + this.navBarOpen = false; + + this.StateHasChanged(); + break; } } @@ -105,7 +136,7 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver } #endregion - + private async Task DismissUpdate() { this.userDismissedUpdate = true; diff --git a/app/MindWork AI Studio/Components/Layout/NavBarItem.cs b/app/MindWork AI Studio/Components/Layout/NavBarItem.cs new file mode 100644 index 00000000..668634cb --- /dev/null +++ b/app/MindWork AI Studio/Components/Layout/NavBarItem.cs @@ -0,0 +1,3 @@ +namespace AIStudio.Components.Layout; + +public record NavBarItem(string Name, string Icon, Color IconColor, string Path, bool MatchAll); \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Pages/Settings.razor b/app/MindWork AI Studio/Components/Pages/Settings.razor index 2becc03b..9a11b045 100644 --- a/app/MindWork AI Studio/Components/Pages/Settings.razor +++ b/app/MindWork AI Studio/Components/Pages/Settings.razor @@ -73,5 +73,6 @@ + \ 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 d2ce4b12..868289fa 100644 --- a/app/MindWork AI Studio/Components/Pages/Settings.razor.cs +++ b/app/MindWork AI Studio/Components/Pages/Settings.razor.cs @@ -1,6 +1,8 @@ using AIStudio.Components.CommonDialogs; using AIStudio.Provider; using AIStudio.Settings; +using AIStudio.Tools; + using Microsoft.AspNetCore.Components; using DialogOptions = AIStudio.Components.CommonDialogs.DialogOptions; @@ -19,6 +21,9 @@ public partial class Settings : ComponentBase [Inject] public IJSRuntime JsRuntime { get; init; } = null!; + + [Inject] + protected MessageBus MessageBus { get; init; } = null!; #region Provider related @@ -39,6 +44,7 @@ public partial class Settings : ComponentBase this.SettingsManager.ConfigurationData.Providers.Add(addedProvider); await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); } private async Task EditProvider(AIStudio.Settings.Provider provider) @@ -70,6 +76,7 @@ public partial class Settings : ComponentBase this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider; await this.SettingsManager.StoreSettings(); + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); } private async Task DeleteProvider(AIStudio.Settings.Provider provider) @@ -91,6 +98,8 @@ public partial class Settings : ComponentBase this.SettingsManager.ConfigurationData.Providers.Remove(provider); await this.SettingsManager.StoreSettings(); } + + await this.MessageBus.SendMessage(this, Event.CONFIGURATION_CHANGED); } private string GetProviderDashboardURL(Providers provider) => provider switch diff --git a/app/MindWork AI Studio/Settings/Data.cs b/app/MindWork AI Studio/Settings/Data.cs index ea774876..f18fd854 100644 --- a/app/MindWork AI Studio/Settings/Data.cs +++ b/app/MindWork AI Studio/Settings/Data.cs @@ -51,4 +51,9 @@ public sealed class Data /// The chat storage maintenance behavior. /// public WorkspaceStorageTemporaryMaintenancePolicy WorkspaceStorageTemporaryMaintenancePolicy { get; set; } = WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_90_DAYS; + + /// + /// The navigation behavior. + /// + public NavBehavior NavigationBehavior { get; set; } = NavBehavior.EXPAND_ON_HOVER; } \ No newline at end of file diff --git a/app/MindWork AI Studio/Settings/NavBehavior.cs b/app/MindWork AI Studio/Settings/NavBehavior.cs new file mode 100644 index 00000000..70170a1d --- /dev/null +++ b/app/MindWork AI Studio/Settings/NavBehavior.cs @@ -0,0 +1,9 @@ +namespace AIStudio.Settings; + +public enum NavBehavior +{ + EXPAND_ON_HOVER, + NEVER_EXPAND_USE_TOOLTIPS, + NEVER_EXPAND_NO_TOOLTIPS, + ALWAYS_EXPAND, +} \ No newline at end of file