-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ec86ec
commit 6b7800b
Showing
60 changed files
with
1,862 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
app/MindWork AI Studio/Components/Blocks/EnumSelection.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@typeparam T | ||
@inherits EnumSelectionBase | ||
|
||
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3"> | ||
<MudSelect T="@T" Value="@this.Value" ValueChanged="@this.SelectionChanged" AdornmentIcon="@this.Icon" Adornment="Adornment.Start" Label="@this.Label" Variant="Variant.Outlined" Margin="Margin.Dense" Validation="@this.ValidateSelection"> | ||
@foreach (var value in Enum.GetValues<T>()) | ||
{ | ||
<MudSelectItem Value="@value"> | ||
@this.NameFunc(value) | ||
</MudSelectItem> | ||
} | ||
</MudSelect> | ||
@if (this.AllowOther && this.Value.Equals(this.OtherValue)) | ||
{ | ||
<MudTextField T="string" Text="@this.OtherInput" TextChanged="this.OtherInputChanged" Validation="@this.ValidateOther" Label="@this.LabelOther" Variant="Variant.Outlined" Margin="Margin.Dense" UserAttributes="@USER_INPUT_ATTRIBUTES" Immediate="@true"/> | ||
} | ||
</MudStack> |
79 changes: 79 additions & 0 deletions
79
app/MindWork AI Studio/Components/Blocks/EnumSelection.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using AIStudio.Settings; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace AIStudio.Components.Blocks; | ||
|
||
public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum | ||
{ | ||
[Parameter] | ||
public T Value { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<T> ValueChanged { get; set; } | ||
|
||
[Parameter] | ||
public bool AllowOther { get; set; } | ||
|
||
[Parameter] | ||
public T OtherValue { get; set; } | ||
|
||
[Parameter] | ||
public string OtherInput { get; set; } = string.Empty; | ||
|
||
[Parameter] | ||
public EventCallback<string> OtherInputChanged { get; set; } | ||
|
||
[Parameter] | ||
public string Label { get; set; } = string.Empty; | ||
|
||
[Parameter] | ||
public string LabelOther { get; set; } = "Other"; | ||
|
||
[Parameter] | ||
public Func<T, string?> ValidateSelection { get; set; } = _ => null; | ||
|
||
[Parameter] | ||
public Func<string, string?> ValidateOther { get; set; } = _ => null; | ||
|
||
[Parameter] | ||
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown; | ||
|
||
/// <summary> | ||
/// Gets or sets the custom name function for selecting the display name of an enum value. | ||
/// </summary> | ||
/// <typeparam name="T">The enum type.</typeparam> | ||
/// <param name="value">The enum value.</param> | ||
/// <returns>The display name of the enum value.</returns> | ||
[Parameter] | ||
public Func<T, string> NameFunc { get; set; } = value => value.ToString(); | ||
|
||
[Parameter] | ||
public Func<T, Task> SelectionUpdated { get; set; } = _ => Task.CompletedTask; | ||
|
||
[Inject] | ||
private SettingsManager SettingsManager { get; set; } = null!; | ||
|
||
#region Overrides of ComponentBase | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
// Configure the spellchecking for the user input: | ||
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES); | ||
await base.OnInitializedAsync(); | ||
} | ||
|
||
#endregion | ||
|
||
private async Task SelectionChanged(T value) | ||
{ | ||
await this.ValueChanged.InvokeAsync(value); | ||
await this.SelectionUpdated(value); | ||
} | ||
|
||
private async Task OtherValueChanged(string value) | ||
{ | ||
await this.OtherInputChanged.InvokeAsync(value); | ||
await this.SelectionUpdated(this.Value); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/MindWork AI Studio/Components/Blocks/EnumSelectionBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace AIStudio.Components.Blocks; | ||
|
||
public abstract class EnumSelectionBase : ComponentBase | ||
{ | ||
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@typeparam T | ||
|
||
<MudField Label="@this.Label" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.Disabled()"> | ||
<MudSlider T="@T" Size="Size.Medium" Value="@this.Value" ValueChanged="@this.ValueUpdated" Min="@this.Min" Max="@this.Max" Step="@this.Step" Immediate="@true" Disabled="@this.Disabled()"> | ||
@this.Value @this.Unit | ||
</MudSlider> | ||
</MudField> |
78 changes: 78 additions & 0 deletions
78
app/MindWork AI Studio/Components/Blocks/MudTextSlider.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Numerics; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace AIStudio.Components.Blocks; | ||
|
||
public partial class MudTextSlider<T> : ComponentBase where T : struct, INumber<T> | ||
{ | ||
/// <summary> | ||
/// The minimum value for the slider. | ||
/// </summary> | ||
[Parameter] | ||
public T Min { get; set; } = T.Zero; | ||
|
||
/// <summary> | ||
/// The maximum value for the slider. | ||
/// </summary> | ||
[Parameter] | ||
public T Max { get; set; } = T.One; | ||
|
||
/// <summary> | ||
/// The step size for the slider. | ||
/// </summary> | ||
[Parameter] | ||
public T Step { get; set; } = T.One; | ||
|
||
/// <summary> | ||
/// The unit to display next to the slider's value. | ||
/// </summary> | ||
[Parameter] | ||
public string Unit { get; set; } = string.Empty; | ||
|
||
[Parameter] | ||
public T Value { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<T> ValueChanged { get; set; } | ||
|
||
/// <summary> | ||
/// The label to display above the slider. | ||
/// </summary> | ||
[Parameter] | ||
public string Label { get; set; } = string.Empty; | ||
|
||
[Parameter] | ||
public Func<bool> Disabled { get; set; } = () => false; | ||
|
||
#region Overrides of ComponentBase | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
await this.EnsureMinMax(); | ||
await base.OnInitializedAsync(); | ||
} | ||
|
||
protected override async Task OnParametersSetAsync() | ||
{ | ||
await this.EnsureMinMax(); | ||
await base.OnParametersSetAsync(); | ||
} | ||
|
||
#endregion | ||
|
||
private async Task EnsureMinMax() | ||
{ | ||
if (this.Value < this.Min) | ||
await this.ValueUpdated(this.Min); | ||
|
||
else if(this.Value > this.Max) | ||
await this.ValueUpdated(this.Max); | ||
} | ||
|
||
private async Task ValueUpdated(T value) | ||
{ | ||
this.Value = value; | ||
await this.ValueChanged.InvokeAsync(this.Value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<MudField Label="@this.Label" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.Disabled"> | ||
<MudSwitch T="bool" Value="@this.Value" ValueChanged="@this.ValueChanged" Color="@this.Color" Validation="@this.Validation" Disabled="@this.Disabled"> | ||
@(this.Value ? this.LabelOn : this.LabelOff) | ||
</MudSwitch> | ||
</MudField> |
30 changes: 30 additions & 0 deletions
30
app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace AIStudio.Components.Blocks; | ||
|
||
public partial class MudTextSwitch : ComponentBase | ||
{ | ||
[Parameter] | ||
public string Label { get; set; } = string.Empty; | ||
|
||
[Parameter] | ||
public bool Disabled { get; set; } | ||
|
||
[Parameter] | ||
public bool Value { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<bool> ValueChanged { get; set; } | ||
|
||
[Parameter] | ||
public Color Color { get; set; } = Color.Primary; | ||
|
||
[Parameter] | ||
public Func<bool, string?> Validation { get; set; } = _ => null; | ||
|
||
[Parameter] | ||
public string LabelOn { get; set; } = string.Empty; | ||
|
||
[Parameter] | ||
public string LabelOff { get; set; } = string.Empty; | ||
} |
11 changes: 11 additions & 0 deletions
11
app/MindWork AI Studio/Components/Blocks/ProcessComponent.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@typeparam T | ||
|
||
@if (this.ShowProgressAnimation) | ||
{ | ||
<div class="pa-1"> | ||
<MudProgressLinear Color="Color.Primary" Indeterminate="true"/> | ||
</div> | ||
} | ||
<div class="pa-6"> | ||
<MudSlider T="int" Disabled="@true" Value="@this.StepValue" Min="@this.process.Min" Max="@this.process.Max" TickMarks="@true" Size="Size.Large" Variant="Variant.Filled" TickMarkLabels="@this.process.Labels" Class="mb-12"/> | ||
</div> |
16 changes: 16 additions & 0 deletions
16
app/MindWork AI Studio/Components/Blocks/ProcessComponent.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using AIStudio.Tools; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace AIStudio.Components.Blocks; | ||
|
||
public partial class ProcessComponent<T> : ComponentBase where T : struct, Enum | ||
{ | ||
[Parameter] | ||
public bool ShowProgressAnimation { get; set; } | ||
|
||
[Parameter] | ||
public ProcessStepValue StepValue { get; set; } | ||
|
||
private readonly Process<T> process = Process<T>.INSTANCE; | ||
} |
8 changes: 8 additions & 0 deletions
8
app/MindWork AI Studio/Components/Blocks/ProviderSelection.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@using AIStudio.Settings | ||
|
||
<MudSelect T="Provider" Value="@this.ProviderSettings" ValueChanged="@this.SelectionChanged" Validation="@this.ValidateProvider" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Apps" Margin="Margin.Dense" Label="Provider" Class="mb-3 rounded-lg" Variant="Variant.Outlined"> | ||
@foreach (var provider in this.SettingsManager.ConfigurationData.Providers) | ||
{ | ||
<MudSelectItem Value="@provider"/> | ||
} | ||
</MudSelect> |
26 changes: 26 additions & 0 deletions
26
app/MindWork AI Studio/Components/Blocks/ProviderSelection.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using AIStudio.Settings; | ||
|
||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace AIStudio.Components.Blocks; | ||
|
||
public partial class ProviderSelection : ComponentBase | ||
{ | ||
[Parameter] | ||
public Settings.Provider ProviderSettings { get; set; } | ||
|
||
[Parameter] | ||
public EventCallback<Settings.Provider> ProviderSettingsChanged { get; set; } | ||
|
||
[Parameter] | ||
public Func<Settings.Provider, string?> ValidateProvider { get; set; } = _ => null; | ||
|
||
[Inject] | ||
protected SettingsManager SettingsManager { get; set; } = null!; | ||
|
||
private async Task SelectionChanged(Settings.Provider provider) | ||
{ | ||
this.ProviderSettings = provider; | ||
await this.ProviderSettingsChanged.InvokeAsync(provider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.