From 3aeba836ffeb2ae29cf92c5643a84319cb44358a Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sat, 3 Aug 2024 22:09:38 +0200 Subject: [PATCH] Refactored switch component --- .../Components/Blocks/MudTextSwitch.razor | 5 ++++ .../Components/Blocks/MudTextSwitch.razor.cs | 30 +++++++++++++++++++ .../Components/Blocks/ReadWebContent.razor | 13 ++------ .../Pages/Coding/AssistantCoding.razor | 4 +-- .../Translation/AssistantTranslation.razor | 7 +---- 5 files changed, 39 insertions(+), 20 deletions(-) create mode 100644 app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor create mode 100644 app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor.cs diff --git a/app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor b/app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor new file mode 100644 index 00000000..353ac8b8 --- /dev/null +++ b/app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor @@ -0,0 +1,5 @@ + + + @(this.Value ? this.LabelOn : this.LabelOff) + + \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor.cs b/app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor.cs new file mode 100644 index 00000000..30492d37 --- /dev/null +++ b/app/MindWork AI Studio/Components/Blocks/MudTextSwitch.razor.cs @@ -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 ValueChanged { get; set; } + + [Parameter] + public Color Color { get; set; } = Color.Primary; + + [Parameter] + public Func Validation { get; set; } = _ => null; + + [Parameter] + public string LabelOn { get; set; } = string.Empty; + + [Parameter] + public string LabelOff { get; set; } = string.Empty; +} \ No newline at end of file diff --git a/app/MindWork AI Studio/Components/Blocks/ReadWebContent.razor b/app/MindWork AI Studio/Components/Blocks/ReadWebContent.razor index 8b33a12e..fc716034 100644 --- a/app/MindWork AI Studio/Components/Blocks/ReadWebContent.razor +++ b/app/MindWork AI Studio/Components/Blocks/ReadWebContent.razor @@ -1,17 +1,8 @@ - - - @(this.showWebContentReader ? "Show web content options" : "Hide web content options") - - - + @if (this.showWebContentReader) { - - - @(this.useContentCleanerAgent ? "The content is cleaned using an LLM agent: the main content is extracted, advertisements and other irrelevant things are attempted to be removed; relative links are attempted to be converted into absolute links so that they can be used." : "No content cleaning") - - + diff --git a/app/MindWork AI Studio/Components/Pages/Coding/AssistantCoding.razor b/app/MindWork AI Studio/Components/Pages/Coding/AssistantCoding.razor index 2f9af4b0..9353d315 100644 --- a/app/MindWork AI Studio/Components/Pages/Coding/AssistantCoding.razor +++ b/app/MindWork AI Studio/Components/Pages/Coding/AssistantCoding.razor @@ -16,9 +16,7 @@ - - @(this.provideCompilerMessages ? "Provide compiler messages" : "Provide no compiler messages") - + @if (this.provideCompilerMessages) { diff --git a/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor b/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor index 2b03eca6..9fa4139b 100644 --- a/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor +++ b/app/MindWork AI Studio/Components/Pages/Translation/AssistantTranslation.razor @@ -8,12 +8,7 @@ } - - - @(this.liveTranslation ? "Live translation" : "No live translation") - - - + @if (this.liveTranslation) {