Skip to content

Commit 6b7800b

Browse files
Add agenda assistant (#69)
1 parent 1ec86ec commit 6b7800b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1862
-571
lines changed

app/MindWork AI Studio/Chat/ContentText.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ await Task.Run(async () =>
7070
// Notify the UI that the content has changed,
7171
// depending on the energy saving mode:
7272
var now = DateTimeOffset.Now;
73-
switch (settings.ConfigurationData.IsSavingEnergy)
73+
switch (settings.ConfigurationData.App.IsSavingEnergy)
7474
{
7575
// Energy saving mode is off. We notify the UI
7676
// as fast as possible -- no matter the odds:

app/MindWork AI Studio/Components/Blocks/Changelog.Logs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public readonly record struct Log(int Build, string Display, string Filename)
1313

1414
public static readonly Log[] LOGS =
1515
[
16+
new (169, "v0.8.7, build 169 (2024-08-01 19:08 UTC)", "v0.8.7.md"),
1617
new (168, "v0.8.6, build 168 (2024-08-01 19:50 UTC)", "v0.8.6.md"),
1718
new (167, "v0.8.5, build 167 (2024-07-28 16:44 UTC)", "v0.8.5.md"),
1819
new (166, "v0.8.4, build 166 (2024-07-26 06:53 UTC)", "v0.8.4.md"),

app/MindWork AI Studio/Components/Blocks/ConfigurationSlider.razor.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,35 @@ public partial class ConfigurationSlider<T> : ConfigurationBase where T : struct
4242
[Parameter]
4343
public Action<T> ValueUpdate { get; set; } = _ => { };
4444

45+
#region Overrides of ComponentBase
46+
47+
protected override async Task OnInitializedAsync()
48+
{
49+
await this.EnsureMinMax();
50+
await base.OnInitializedAsync();
51+
}
52+
53+
protected override async Task OnParametersSetAsync()
54+
{
55+
await this.EnsureMinMax();
56+
await base.OnParametersSetAsync();
57+
}
58+
59+
#endregion
60+
4561
private async Task OptionChanged(T updatedValue)
4662
{
4763
this.ValueUpdate(updatedValue);
4864
await this.SettingsManager.StoreSettings();
4965
await this.InformAboutChange();
5066
}
67+
68+
private async Task EnsureMinMax()
69+
{
70+
if (this.Value() < this.Min)
71+
await this.OptionChanged(this.Min);
72+
73+
else if(this.Value() > this.Max)
74+
await this.OptionChanged(this.Max);
75+
}
5176
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@typeparam T
2+
@inherits EnumSelectionBase
3+
4+
<MudStack Row="@true" AlignItems="AlignItems.Center" Class="mb-3">
5+
<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">
6+
@foreach (var value in Enum.GetValues<T>())
7+
{
8+
<MudSelectItem Value="@value">
9+
@this.NameFunc(value)
10+
</MudSelectItem>
11+
}
12+
</MudSelect>
13+
@if (this.AllowOther && this.Value.Equals(this.OtherValue))
14+
{
15+
<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"/>
16+
}
17+
</MudStack>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using AIStudio.Settings;
2+
3+
using Microsoft.AspNetCore.Components;
4+
5+
namespace AIStudio.Components.Blocks;
6+
7+
public partial class EnumSelection<T> : EnumSelectionBase where T : struct, Enum
8+
{
9+
[Parameter]
10+
public T Value { get; set; }
11+
12+
[Parameter]
13+
public EventCallback<T> ValueChanged { get; set; }
14+
15+
[Parameter]
16+
public bool AllowOther { get; set; }
17+
18+
[Parameter]
19+
public T OtherValue { get; set; }
20+
21+
[Parameter]
22+
public string OtherInput { get; set; } = string.Empty;
23+
24+
[Parameter]
25+
public EventCallback<string> OtherInputChanged { get; set; }
26+
27+
[Parameter]
28+
public string Label { get; set; } = string.Empty;
29+
30+
[Parameter]
31+
public string LabelOther { get; set; } = "Other";
32+
33+
[Parameter]
34+
public Func<T, string?> ValidateSelection { get; set; } = _ => null;
35+
36+
[Parameter]
37+
public Func<string, string?> ValidateOther { get; set; } = _ => null;
38+
39+
[Parameter]
40+
public string Icon { get; set; } = Icons.Material.Filled.ArrowDropDown;
41+
42+
/// <summary>
43+
/// Gets or sets the custom name function for selecting the display name of an enum value.
44+
/// </summary>
45+
/// <typeparam name="T">The enum type.</typeparam>
46+
/// <param name="value">The enum value.</param>
47+
/// <returns>The display name of the enum value.</returns>
48+
[Parameter]
49+
public Func<T, string> NameFunc { get; set; } = value => value.ToString();
50+
51+
[Parameter]
52+
public Func<T, Task> SelectionUpdated { get; set; } = _ => Task.CompletedTask;
53+
54+
[Inject]
55+
private SettingsManager SettingsManager { get; set; } = null!;
56+
57+
#region Overrides of ComponentBase
58+
59+
protected override async Task OnInitializedAsync()
60+
{
61+
// Configure the spellchecking for the user input:
62+
this.SettingsManager.InjectSpellchecking(USER_INPUT_ATTRIBUTES);
63+
await base.OnInitializedAsync();
64+
}
65+
66+
#endregion
67+
68+
private async Task SelectionChanged(T value)
69+
{
70+
await this.ValueChanged.InvokeAsync(value);
71+
await this.SelectionUpdated(value);
72+
}
73+
74+
private async Task OtherValueChanged(string value)
75+
{
76+
await this.OtherInputChanged.InvokeAsync(value);
77+
await this.SelectionUpdated(this.Value);
78+
}
79+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace AIStudio.Components.Blocks;
4+
5+
public abstract class EnumSelectionBase : ComponentBase
6+
{
7+
protected static readonly Dictionary<string, object?> USER_INPUT_ATTRIBUTES = new();
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@typeparam T
2+
3+
<MudField Label="@this.Label" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.Disabled()">
4+
<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()">
5+
@this.Value @this.Unit
6+
</MudSlider>
7+
</MudField>
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using System.Numerics;
2+
3+
using Microsoft.AspNetCore.Components;
4+
5+
namespace AIStudio.Components.Blocks;
6+
7+
public partial class MudTextSlider<T> : ComponentBase where T : struct, INumber<T>
8+
{
9+
/// <summary>
10+
/// The minimum value for the slider.
11+
/// </summary>
12+
[Parameter]
13+
public T Min { get; set; } = T.Zero;
14+
15+
/// <summary>
16+
/// The maximum value for the slider.
17+
/// </summary>
18+
[Parameter]
19+
public T Max { get; set; } = T.One;
20+
21+
/// <summary>
22+
/// The step size for the slider.
23+
/// </summary>
24+
[Parameter]
25+
public T Step { get; set; } = T.One;
26+
27+
/// <summary>
28+
/// The unit to display next to the slider's value.
29+
/// </summary>
30+
[Parameter]
31+
public string Unit { get; set; } = string.Empty;
32+
33+
[Parameter]
34+
public T Value { get; set; }
35+
36+
[Parameter]
37+
public EventCallback<T> ValueChanged { get; set; }
38+
39+
/// <summary>
40+
/// The label to display above the slider.
41+
/// </summary>
42+
[Parameter]
43+
public string Label { get; set; } = string.Empty;
44+
45+
[Parameter]
46+
public Func<bool> Disabled { get; set; } = () => false;
47+
48+
#region Overrides of ComponentBase
49+
50+
protected override async Task OnInitializedAsync()
51+
{
52+
await this.EnsureMinMax();
53+
await base.OnInitializedAsync();
54+
}
55+
56+
protected override async Task OnParametersSetAsync()
57+
{
58+
await this.EnsureMinMax();
59+
await base.OnParametersSetAsync();
60+
}
61+
62+
#endregion
63+
64+
private async Task EnsureMinMax()
65+
{
66+
if (this.Value < this.Min)
67+
await this.ValueUpdated(this.Min);
68+
69+
else if(this.Value > this.Max)
70+
await this.ValueUpdated(this.Max);
71+
}
72+
73+
private async Task ValueUpdated(T value)
74+
{
75+
this.Value = value;
76+
await this.ValueChanged.InvokeAsync(this.Value);
77+
}
78+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<MudField Label="@this.Label" Variant="Variant.Outlined" Class="mb-3" Disabled="@this.Disabled">
2+
<MudSwitch T="bool" Value="@this.Value" ValueChanged="@this.ValueChanged" Color="@this.Color" Validation="@this.Validation" Disabled="@this.Disabled">
3+
@(this.Value ? this.LabelOn : this.LabelOff)
4+
</MudSwitch>
5+
</MudField>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using Microsoft.AspNetCore.Components;
2+
3+
namespace AIStudio.Components.Blocks;
4+
5+
public partial class MudTextSwitch : ComponentBase
6+
{
7+
[Parameter]
8+
public string Label { get; set; } = string.Empty;
9+
10+
[Parameter]
11+
public bool Disabled { get; set; }
12+
13+
[Parameter]
14+
public bool Value { get; set; }
15+
16+
[Parameter]
17+
public EventCallback<bool> ValueChanged { get; set; }
18+
19+
[Parameter]
20+
public Color Color { get; set; } = Color.Primary;
21+
22+
[Parameter]
23+
public Func<bool, string?> Validation { get; set; } = _ => null;
24+
25+
[Parameter]
26+
public string LabelOn { get; set; } = string.Empty;
27+
28+
[Parameter]
29+
public string LabelOff { get; set; } = string.Empty;
30+
}

0 commit comments

Comments
 (0)