mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2025-02-11 15:29:06 +00:00
Refactored & added the text info line component
This commit is contained in:
parent
d56690b721
commit
90683a5b4d
18
app/MindWork AI Studio/Components/TextInfoLine.razor
Normal file
18
app/MindWork AI Studio/Components/TextInfoLine.razor
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<MudStack Row="@true" AlignItems="AlignItems.Center">
|
||||||
|
<MudTextField
|
||||||
|
T="string"
|
||||||
|
ReadOnly="@true"
|
||||||
|
Label="@this.Label"
|
||||||
|
Text="@this.Value"
|
||||||
|
Variant="Variant.Outlined"
|
||||||
|
Margin="Margin.Dense"
|
||||||
|
Adornment="Adornment.Start"
|
||||||
|
AdornmentIcon="@this.Icon"/>
|
||||||
|
|
||||||
|
@if (this.ShowingCopyButton)
|
||||||
|
{
|
||||||
|
<MudTooltip Text="@this.ClipboardTooltip">
|
||||||
|
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" Size="Size.Medium" OnClick="@(() => this.CopyToClipboard(this.Value))"/>
|
||||||
|
</MudTooltip>
|
||||||
|
}
|
||||||
|
</MudStack>
|
31
app/MindWork AI Studio/Components/TextInfoLine.razor.cs
Normal file
31
app/MindWork AI Studio/Components/TextInfoLine.razor.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
|
|
||||||
|
namespace AIStudio.Components;
|
||||||
|
|
||||||
|
public partial class TextInfoLine : ComponentBase
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public string Label { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Icon { get; set; } = Icons.Material.Filled.Info;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string Value { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public string ClipboardTooltipSubject { get; set; } = "the text";
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public bool ShowingCopyButton { get; set; } = true;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private RustService RustService { get; init; } = null!;
|
||||||
|
|
||||||
|
[Inject]
|
||||||
|
private ISnackbar Snackbar { get; init; } = null!;
|
||||||
|
|
||||||
|
private string ClipboardTooltip => $"Copy {this.ClipboardTooltipSubject} to the clipboard";
|
||||||
|
|
||||||
|
private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content);
|
||||||
|
}
|
@ -1,37 +1,8 @@
|
|||||||
<MudDialog>
|
<MudDialog>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<MudStack Row="@true">
|
<TextInfoLine Icon="@Icons.Material.Filled.Tag" Label="Data source name" Value="@this.DataSource.Name" ClipboardTooltipSubject="the data source name"/>
|
||||||
<MudTextField
|
|
||||||
T="string"
|
|
||||||
ReadOnly="@true"
|
|
||||||
Label="Data source name"
|
|
||||||
Text="@this.DataSource.Name"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
Margin="Margin.Dense"
|
|
||||||
Adornment="Adornment.Start"
|
|
||||||
AdornmentIcon="@Icons.Material.Filled.Tag"/>
|
|
||||||
|
|
||||||
<MudTooltip Text="Copy the data source name to the clipboard">
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" OnClick="@(() => this.CopyToClipboard(this.DataSource.Name))"/>
|
|
||||||
</MudTooltip>
|
|
||||||
</MudStack>
|
|
||||||
|
|
||||||
<MudStack Row="@true">
|
|
||||||
<MudTextField
|
|
||||||
T="string"
|
|
||||||
ReadOnly="@true"
|
|
||||||
Label="File path"
|
|
||||||
Text="@this.DataSource.FilePath"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
Margin="Margin.Dense"
|
|
||||||
Adornment="Adornment.Start"
|
|
||||||
AdornmentIcon="@Icons.Material.Filled.FolderOpen"/>
|
|
||||||
|
|
||||||
<MudTooltip Text="Copy this path to the clipboard">
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" OnClick="@(() => this.CopyToClipboard(this.DataSource.FilePath))"/>
|
|
||||||
</MudTooltip>
|
|
||||||
</MudStack>
|
|
||||||
|
|
||||||
|
<TextInfoLine Icon="@Icons.Material.Filled.FolderOpen" Label="File path" Value="@this.DataSource.FilePath" ClipboardTooltipSubject="this path"/>
|
||||||
@if (!this.IsFileAvailable)
|
@if (!this.IsFileAvailable)
|
||||||
{
|
{
|
||||||
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
|
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
|
||||||
@ -45,22 +16,7 @@
|
|||||||
</MudJustifiedText>
|
</MudJustifiedText>
|
||||||
}
|
}
|
||||||
|
|
||||||
<MudStack Row="@true">
|
<TextInfoLine Icon="@Icons.Material.Filled.Layers" Label="Embedding name" Value="@this.embeddingProvider.Name" ClipboardTooltipSubject="the embedding name"/>
|
||||||
<MudTextField
|
|
||||||
T="string"
|
|
||||||
ReadOnly="@true"
|
|
||||||
Label="Embedding name"
|
|
||||||
Text="@this.embeddingProvider.Name"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
Margin="Margin.Dense"
|
|
||||||
Adornment="Adornment.Start"
|
|
||||||
AdornmentIcon="@Icons.Material.Filled.Layers"/>
|
|
||||||
|
|
||||||
<MudTooltip Text="Copy the embedding name to the clipboard">
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" OnClick="@(() => this.CopyToClipboard(this.embeddingProvider.Name))"/>
|
|
||||||
</MudTooltip>
|
|
||||||
</MudStack>
|
|
||||||
|
|
||||||
@if (this.IsCloudEmbedding)
|
@if (this.IsCloudEmbedding)
|
||||||
{
|
{
|
||||||
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
|
<MudJustifiedText Typo="Typo.body1" Color="Color.Error" Class="mb-3">
|
||||||
@ -75,21 +31,7 @@
|
|||||||
</MudJustifiedText>
|
</MudJustifiedText>
|
||||||
}
|
}
|
||||||
|
|
||||||
<MudStack Row="@true">
|
<TextInfoLine Icon="@Icons.Material.Filled.SquareFoot" Label="File size" Value="@this.FileSize" ClipboardTooltipSubject="the file size"/>
|
||||||
<MudTextField
|
|
||||||
T="string"
|
|
||||||
ReadOnly="@true"
|
|
||||||
Label="File size"
|
|
||||||
Text="@this.FileSize"
|
|
||||||
Variant="Variant.Outlined"
|
|
||||||
Margin="Margin.Dense"
|
|
||||||
Adornment="Adornment.Start"
|
|
||||||
AdornmentIcon="@Icons.Material.Filled.SquareFoot"/>
|
|
||||||
|
|
||||||
<MudTooltip Text="Copy the file size to the clipboard">
|
|
||||||
<MudIconButton Icon="@Icons.Material.Filled.ContentCopy" OnClick="@(() => this.CopyToClipboard(this.FileSize))"/>
|
|
||||||
</MudTooltip>
|
|
||||||
</MudStack>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<MudButton OnClick="@this.Close" Variant="Variant.Filled">Close</MudButton>
|
<MudButton OnClick="@this.Close" Variant="Variant.Filled">Close</MudButton>
|
||||||
|
@ -13,12 +13,6 @@ public partial class DataSourceLocalFileInfoDialog : ComponentBase
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public DataSourceLocalFile DataSource { get; set; }
|
public DataSourceLocalFile DataSource { get; set; }
|
||||||
|
|
||||||
[Inject]
|
|
||||||
private RustService RustService { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
|
||||||
private ISnackbar Snackbar { get; init; } = null!;
|
|
||||||
|
|
||||||
[Inject]
|
[Inject]
|
||||||
private SettingsManager SettingsManager { get; init; } = null!;
|
private SettingsManager SettingsManager { get; init; } = null!;
|
||||||
|
|
||||||
@ -42,7 +36,5 @@ public partial class DataSourceLocalFileInfoDialog : ComponentBase
|
|||||||
|
|
||||||
private string FileSize => this.fileInfo.FileSize();
|
private string FileSize => this.fileInfo.FileSize();
|
||||||
|
|
||||||
private async Task CopyToClipboard(string content) => await this.RustService.CopyText2Clipboard(this.Snackbar, content);
|
|
||||||
|
|
||||||
private void Close() => this.MudDialog.Close();
|
private void Close() => this.MudDialog.Close();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user