mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 18:07:21 +00:00
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
97 lines
4.9 KiB
Plaintext
97 lines
4.9 KiB
Plaintext
@inherits MSGComponentBase
|
|
|
|
<MudDialog ContentClass="dialog-content-fit">
|
|
<TitleContent>
|
|
@* Named after the document once there is one, and after what the caller opened us for until then.
|
|
A file which is no longer at its place is told about below, together with what is shown instead: *@
|
|
<FileDialogTitle Title="@(this.document?.FileName ?? this.MudDialog.Title ?? string.Empty)" Path="@(this.document?.FilePath ?? string.Empty)" WarnIfMissing="@false"/>
|
|
</TitleContent>
|
|
<DialogContent>
|
|
@* A drop anywhere in this dialog belongs to the dialog, not to the page behind it: *@
|
|
<PathDropZone IsArea="@true"
|
|
IdPrefix="document-check"
|
|
OnPathsDropped="@this.DropCallback"
|
|
Disabled="@this.IsZoneDisabled"
|
|
Class="dialog-fit"
|
|
Context="isDropTarget">
|
|
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
|
@T("See how we load your file. Review the content before we process it further.")
|
|
</MudJustifiedText>
|
|
|
|
@if (this.CanAttach)
|
|
{
|
|
<MudJustifiedText Typo="Typo.body1" Class="mb-3">
|
|
@T("You can drag another file into this window. We attach it right away and show it here.")
|
|
</MudJustifiedText>
|
|
}
|
|
|
|
@if (this.document is null)
|
|
{
|
|
<ReadFileContent Text="@T("Load file")" @bind-FileContent="@this.fileContent" EnableDragDrop="true" CatchAllDocuments="true"/>
|
|
}
|
|
|
|
@* The frame shows where a dropped file would land. It is drawn only while this dialog can
|
|
take one, and keeps its width in both states so that nothing jumps during a drag: *@
|
|
<div class="dialog-fit @this.PreviewAreaClass(isDropTarget)">
|
|
@if (this.isLoadingContent)
|
|
{
|
|
<MudJustifiedText Typo="Typo.body1" Class="my-3">
|
|
@T("Please wait while we load the content of your file. Depending on the file type and size, this may take a moment.")
|
|
</MudJustifiedText>
|
|
<MudSkeleton Width="30%" Height="42px"/>
|
|
<MudSkeleton Width="80%"/>
|
|
<MudSkeleton Width="100%"/>
|
|
<MudSkeleton Width="90%"/>
|
|
}
|
|
else if (this.IsFileMissing && !this.showsStoredText)
|
|
{
|
|
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Class="my-2">
|
|
@T("The file could not be found. It may have been moved, renamed, or deleted, or it is otherwise inaccessible.")
|
|
</MudAlert>
|
|
}
|
|
else if (this.loadFailureMessage is not null)
|
|
{
|
|
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Class="my-2">
|
|
@this.loadFailureMessage
|
|
</MudAlert>
|
|
}
|
|
else
|
|
{
|
|
@if (this.IsFileMissing)
|
|
{
|
|
@* The text the AI received outlives the file, so the file being gone is worth a note, not an error: *@
|
|
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Dense="@true" Class="my-2">
|
|
@T("The file is no longer in its original location. Below is the text the AI received from it when you sent it.")
|
|
</MudAlert>
|
|
}
|
|
|
|
@* Keyed by the document: every document starts on the first panel of its own. *@
|
|
<ContentViewer
|
|
@key="@($"preview-tabs-{this.document?.FilePath}")"
|
|
Kind="@this.ViewerKind"
|
|
Text="@this.fileContent"
|
|
MediaUrl="@(this.document?.FilePathAsUrl ?? string.Empty)"
|
|
HelperText="@(this.showsStoredText ? T("This is the text the AI received from your file when you first sent it. Later changes to the file do not reach the AI in this chat.") : T("This is the content we loaded from your file — including headings, lists, and formatting. Use this to verify your file loads as expected."))"
|
|
CharacterLimit="@PREVIEW_CHARACTER_LIMIT"
|
|
CutOffNotice="@this.CutOffNotice"
|
|
MaxHeight="@ContentViewer.NO_HEIGHT_LIMIT">
|
|
<Toolbar>
|
|
@* The label takes the free width, so the button stands right, next to the views. *@
|
|
<MudText Typo="Typo.subtitle2" Class="flex-grow-1">
|
|
@(this.showsStoredText ? T("Text the AI received") : T("Loaded Content"))
|
|
</MudText>
|
|
|
|
@* At its beginning: the preview shows how we read the file, not a place in it. *@
|
|
<FileActions Path="@(this.document?.FilePath ?? string.Empty)" ShowCopy="@false" ShowFileManager="@false" WarnIfMissing="@false"/>
|
|
</Toolbar>
|
|
</ContentViewer>
|
|
}
|
|
</div>
|
|
</PathDropZone>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<MudButton OnClick="@this.Close" Variant="Variant.Filled" Color="Color.Primary">
|
|
@T("Close")
|
|
</MudButton>
|
|
</DialogActions>
|
|
</MudDialog> |