mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-04-28 15:39:46 +00:00
Fixed navbar & provide additional configuration options
This commit is contained in:
parent
9d28d8379e
commit
7ec4f9adcf
@ -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 180 days", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_180_DAYS);
|
||||||
yield return new("Delete temporary chats older than 1 year", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_365_DAYS);
|
yield return new("Delete temporary chats older than 1 year", WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_365_DAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<ConfigurationSelectData<NavBehavior>> 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);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,36 +1,32 @@
|
|||||||
@inherits LayoutComponentBase
|
@using AIStudio.Settings
|
||||||
|
@inherits LayoutComponentBase
|
||||||
|
|
||||||
<MudPaper Height="calc(100vh);" Elevation="0">
|
<MudPaper Height="calc(100vh);" Elevation="0">
|
||||||
<MudLayout>
|
<MudLayout>
|
||||||
@if (!this.performingUpdate)
|
@if (!this.performingUpdate)
|
||||||
{
|
{
|
||||||
<MudDrawerContainer Class="mud-height-full absolute">
|
<MudDrawerContainer Class="mud-height-full absolute">
|
||||||
<MudDrawer Elevation="0" Variant="@DrawerVariant.Mini" OpenMiniOnHover="@true" Color="Color.Default">
|
<MudDrawer @bind-Open="@this.navBarOpen" MiniWidth="@NAVBAR_COLLAPSED_WIDTH" Width="@NAVBAR_EXPANDED_WIDTH" Elevation="1" Fixed="@true" Variant="@DrawerVariant.Mini" OpenMiniOnHover="@(this.SettingsManager.ConfigurationData.NavigationBehavior is NavBehavior.EXPAND_ON_HOVER)" Color="Color.Default">
|
||||||
<MudNavMenu>
|
<MudNavMenu>
|
||||||
<MudTooltip Text="Home" Placement="Placement.Right">
|
@foreach (var navBarItem in NAV_ITEMS)
|
||||||
<MudNavLink Href="/" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
|
{
|
||||||
</MudTooltip>
|
if (this.SettingsManager.ConfigurationData.NavigationBehavior is NavBehavior.NEVER_EXPAND_USE_TOOLTIPS)
|
||||||
<MudTooltip Text="Chat" Placement="Placement.Right">
|
{
|
||||||
<MudNavLink Href="/chat" Icon="@Icons.Material.Filled.Chat">Chat</MudNavLink>
|
<MudTooltip Text="@navBarItem.Name" Placement="Placement.Right">
|
||||||
</MudTooltip>
|
<MudNavLink Href="@navBarItem.Path" Match="@(navBarItem.MatchAll ? NavLinkMatch.All : NavLinkMatch.Prefix)" Icon="@navBarItem.Icon" IconColor="@navBarItem.IconColor">@navBarItem.Name</MudNavLink>
|
||||||
<MudTooltip Text="Assistants" Placement="Placement.Right">
|
</MudTooltip>
|
||||||
<MudNavLink Href="/assistants" Icon="@Icons.Material.Filled.Apps">Assistants</MudNavLink>
|
}
|
||||||
</MudTooltip>
|
else
|
||||||
<MudTooltip Text="Supporters" Placement="Placement.Right">
|
{
|
||||||
<MudNavLink Href="/supporters" Icon="@Icons.Material.Filled.Favorite" IconColor="Color.Error">Supporters</MudNavLink>
|
<MudNavLink Href="@navBarItem.Path" Match="@(navBarItem.MatchAll ? NavLinkMatch.All : NavLinkMatch.Prefix)" Icon="@navBarItem.Icon" IconColor="@navBarItem.IconColor">@navBarItem.Name</MudNavLink>
|
||||||
</MudTooltip>
|
}
|
||||||
<MudTooltip Text="About" Placement="Placement.Right">
|
}
|
||||||
<MudNavLink Href="/about" Icon="@Icons.Material.Filled.Info">About</MudNavLink>
|
|
||||||
</MudTooltip>
|
|
||||||
<MudTooltip Text="Settings" Placement="Placement.Right">
|
|
||||||
<MudNavLink Href="/settings" Icon="@Icons.Material.Filled.Settings">Settings</MudNavLink>
|
|
||||||
</MudTooltip>
|
|
||||||
</MudNavMenu>
|
</MudNavMenu>
|
||||||
</MudDrawer>
|
</MudDrawer>
|
||||||
</MudDrawerContainer>
|
</MudDrawerContainer>
|
||||||
}
|
}
|
||||||
|
|
||||||
<MudMainContent Class="mud-height-full pt-1">
|
<MudMainContent Class="mud-height-full pt-1" Style="@this.PaddingLeft">
|
||||||
<MudContainer Fixed="@true" Class="mud-height-full" Style="margin-left: 5em; width: calc(100% - 5em);">
|
<MudContainer Fixed="@true" Class="mud-height-full" Style="margin-left: 5em; width: calc(100% - 5em);">
|
||||||
@if (!this.performingUpdate && this.IsUpdateAlertVisible)
|
@if (!this.performingUpdate && this.IsUpdateAlertVisible)
|
||||||
{
|
{
|
||||||
|
@ -34,12 +34,30 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver
|
|||||||
|
|
||||||
public string AdditionalHeight { get; private set; } = "0em";
|
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 isUpdateAvailable;
|
||||||
private bool performingUpdate;
|
private bool performingUpdate;
|
||||||
private bool userDismissedUpdate;
|
private bool userDismissedUpdate;
|
||||||
private string updateToVersion = string.Empty;
|
private string updateToVersion = string.Empty;
|
||||||
private UpdateResponse? currentUpdateResponse;
|
private UpdateResponse? currentUpdateResponse;
|
||||||
|
|
||||||
|
private static readonly IReadOnlyCollection<NavBarItem> NAV_ITEMS = new List<NavBarItem>
|
||||||
|
{
|
||||||
|
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
|
#region Overrides of ComponentBase
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
@ -63,12 +81,16 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver
|
|||||||
|
|
||||||
// Register this component with the message bus:
|
// Register this component with the message bus:
|
||||||
this.MessageBus.RegisterComponent(this);
|
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:
|
// Set the js runtime for the update service:
|
||||||
UpdateService.SetBlazorDependencies(this.JsRuntime, this.Snackbar);
|
UpdateService.SetBlazorDependencies(this.JsRuntime, this.Snackbar);
|
||||||
TemporaryChatService.Initialize();
|
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();
|
await base.OnInitializedAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,6 +118,15 @@ public partial class MainLayout : LayoutComponentBase, IMessageBusReceiver
|
|||||||
}
|
}
|
||||||
|
|
||||||
break;
|
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
|
#endregion
|
||||||
|
|
||||||
private async Task DismissUpdate()
|
private async Task DismissUpdate()
|
||||||
{
|
{
|
||||||
this.userDismissedUpdate = true;
|
this.userDismissedUpdate = true;
|
||||||
|
3
app/MindWork AI Studio/Components/Layout/NavBarItem.cs
Normal file
3
app/MindWork AI Studio/Components/Layout/NavBarItem.cs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
namespace AIStudio.Components.Layout;
|
||||||
|
|
||||||
|
public record NavBarItem(string Name, string Icon, Color IconColor, string Path, bool MatchAll);
|
@ -73,5 +73,6 @@
|
|||||||
<ConfigurationSelect OptionDescription="Check for updates" SelectedValue="@(() => this.SettingsManager.ConfigurationData.UpdateBehavior)" Data="@ConfigurationSelectDataFactory.GetUpdateBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.UpdateBehavior = selectedValue)" OptionHelp="How often should we check for app updates?"/>
|
<ConfigurationSelect OptionDescription="Check for updates" SelectedValue="@(() => this.SettingsManager.ConfigurationData.UpdateBehavior)" Data="@ConfigurationSelectDataFactory.GetUpdateBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.UpdateBehavior = selectedValue)" OptionHelp="How often should we check for app updates?"/>
|
||||||
<ConfigurationSelect OptionDescription="Workspace behavior" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior = selectedValue)" OptionHelp="Should we store your chats?"/>
|
<ConfigurationSelect OptionDescription="Workspace behavior" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageBehavior = selectedValue)" OptionHelp="Should we store your chats?"/>
|
||||||
<ConfigurationSelect OptionDescription="Workspace maintenance" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageTemporaryMaintenancePolicyData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy = selectedValue)" OptionHelp="If and when should we delete your temporary chats?"/>
|
<ConfigurationSelect OptionDescription="Workspace maintenance" SelectedValue="@(() => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy)" Data="@ConfigurationSelectDataFactory.GetWorkspaceStorageTemporaryMaintenancePolicyData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.WorkspaceStorageTemporaryMaintenancePolicy = selectedValue)" OptionHelp="If and when should we delete your temporary chats?"/>
|
||||||
|
<ConfigurationSelect OptionDescription="Navigation bar behavior" SelectedValue="@(() => this.SettingsManager.ConfigurationData.NavigationBehavior)" Data="@ConfigurationSelectDataFactory.GetNavBehaviorData()" SelectionUpdate="@(selectedValue => this.SettingsManager.ConfigurationData.NavigationBehavior = selectedValue)" OptionHelp="Select the desired behavior for the navigation bar."/>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</InnerScrolling>
|
</InnerScrolling>
|
@ -1,6 +1,8 @@
|
|||||||
using AIStudio.Components.CommonDialogs;
|
using AIStudio.Components.CommonDialogs;
|
||||||
using AIStudio.Provider;
|
using AIStudio.Provider;
|
||||||
using AIStudio.Settings;
|
using AIStudio.Settings;
|
||||||
|
using AIStudio.Tools;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Components;
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
using DialogOptions = AIStudio.Components.CommonDialogs.DialogOptions;
|
using DialogOptions = AIStudio.Components.CommonDialogs.DialogOptions;
|
||||||
@ -19,6 +21,9 @@ public partial class Settings : ComponentBase
|
|||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
public IJSRuntime JsRuntime { get; init; } = null!;
|
public IJSRuntime JsRuntime { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
protected MessageBus MessageBus { get; init; } = null!;
|
||||||
|
|
||||||
#region Provider related
|
#region Provider related
|
||||||
|
|
||||||
@ -39,6 +44,7 @@ public partial class Settings : ComponentBase
|
|||||||
|
|
||||||
this.SettingsManager.ConfigurationData.Providers.Add(addedProvider);
|
this.SettingsManager.ConfigurationData.Providers.Add(addedProvider);
|
||||||
await this.SettingsManager.StoreSettings();
|
await this.SettingsManager.StoreSettings();
|
||||||
|
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task EditProvider(AIStudio.Settings.Provider provider)
|
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;
|
this.SettingsManager.ConfigurationData.Providers[this.SettingsManager.ConfigurationData.Providers.IndexOf(provider)] = editedProvider;
|
||||||
await this.SettingsManager.StoreSettings();
|
await this.SettingsManager.StoreSettings();
|
||||||
|
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DeleteProvider(AIStudio.Settings.Provider provider)
|
private async Task DeleteProvider(AIStudio.Settings.Provider provider)
|
||||||
@ -91,6 +98,8 @@ public partial class Settings : ComponentBase
|
|||||||
this.SettingsManager.ConfigurationData.Providers.Remove(provider);
|
this.SettingsManager.ConfigurationData.Providers.Remove(provider);
|
||||||
await this.SettingsManager.StoreSettings();
|
await this.SettingsManager.StoreSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.MessageBus.SendMessage<bool>(this, Event.CONFIGURATION_CHANGED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetProviderDashboardURL(Providers provider) => provider switch
|
private string GetProviderDashboardURL(Providers provider) => provider switch
|
||||||
|
@ -51,4 +51,9 @@ public sealed class Data
|
|||||||
/// The chat storage maintenance behavior.
|
/// The chat storage maintenance behavior.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public WorkspaceStorageTemporaryMaintenancePolicy WorkspaceStorageTemporaryMaintenancePolicy { get; set; } = WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_90_DAYS;
|
public WorkspaceStorageTemporaryMaintenancePolicy WorkspaceStorageTemporaryMaintenancePolicy { get; set; } = WorkspaceStorageTemporaryMaintenancePolicy.DELETE_OLDER_THAN_90_DAYS;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The navigation behavior.
|
||||||
|
/// </summary>
|
||||||
|
public NavBehavior NavigationBehavior { get; set; } = NavBehavior.EXPAND_ON_HOVER;
|
||||||
}
|
}
|
9
app/MindWork AI Studio/Settings/NavBehavior.cs
Normal file
9
app/MindWork AI Studio/Settings/NavBehavior.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace AIStudio.Settings;
|
||||||
|
|
||||||
|
public enum NavBehavior
|
||||||
|
{
|
||||||
|
EXPAND_ON_HOVER,
|
||||||
|
NEVER_EXPAND_USE_TOOLTIPS,
|
||||||
|
NEVER_EXPAND_NO_TOOLTIPS,
|
||||||
|
ALWAYS_EXPAND,
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user