Add file upload popup dialog
This commit is contained in:
@ -46,8 +46,8 @@
|
||||
</Helper>
|
||||
</RadzenFormField>
|
||||
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem">
|
||||
<RadzenButton ButtonType="ButtonType.Submit" Disabled="@inProgress" Text="Создать"></RadzenButton>
|
||||
<RadzenButton Click="@DoClose" ButtonStyle="ButtonStyle.Light" Disabled="@inProgress" Text="Отмена"></RadzenButton>
|
||||
<RadzenButton ButtonType="ButtonType.Submit" Disabled="@inProgress" Text="Создать" />
|
||||
<RadzenButton Click="@DoClose" ButtonStyle="ButtonStyle.Light" Disabled="@inProgress" Text="Отмена" />
|
||||
</RadzenStack>
|
||||
</RadzenStack>
|
||||
</RadzenTemplateForm>
|
||||
|
||||
80
Hcs.WebApp/Components/Dialogs/StartParsing.razor
Normal file
80
Hcs.WebApp/Components/Dialogs/StartParsing.razor
Normal file
@ -0,0 +1,80 @@
|
||||
@using Hcs.WebApp.Services
|
||||
|
||||
@inject DialogService DialogService
|
||||
@inject FileToParseService FileToParseService
|
||||
|
||||
<style>
|
||||
#uploadWithDragAndDrop {
|
||||
left: 0;
|
||||
--rz-upload-button-bar-background-color: transparent;
|
||||
--rz-upload-button-bar-padding: 0;
|
||||
}
|
||||
|
||||
#uploadWithDragAndDrop .rz-fileupload-buttonbar .rz-fileupload-choose {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 16px;
|
||||
padding: 75px 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<RadzenStack JustifyContent="JustifyContent.Center" Style="height: 100%;">
|
||||
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
|
||||
@errorMessage
|
||||
</RadzenAlert>
|
||||
<RadzenUpload id="uploadWithDragAndDrop" @ref="upload" Url="upload-to-parse" Progress="@OnProgress" Complete="@OnCompleteAsync" ChooseText="Перетащите сюда или нажмите, чтобы выбрать файл" Auto="false" Multiple="false" Style="width: 100%;" />
|
||||
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Center" JustifyContent="JustifyContent.End" Gap="0.5rem">
|
||||
<RadzenButton Click="@Upload" Visible="@(state == UploadState.Idle)" Text="Отправить" />
|
||||
<RadzenButton Click="@Close" Visible="@(state == UploadState.Idle)" ButtonStyle="ButtonStyle.Light" Text="Отмена" />
|
||||
</RadzenStack>
|
||||
<RadzenProgressBar Value="@progress" Visible="@(state != UploadState.Idle)" />
|
||||
<RadzenButton Click="@Close" Visible="@(state == UploadState.Completed)" Text="Закрыть" />
|
||||
</RadzenStack>
|
||||
|
||||
@code {
|
||||
enum UploadState
|
||||
{
|
||||
Idle,
|
||||
InProgress,
|
||||
Completed
|
||||
}
|
||||
|
||||
RadzenUpload upload;
|
||||
UploadState state;
|
||||
int progress;
|
||||
bool hasError;
|
||||
string errorMessage;
|
||||
|
||||
void Upload()
|
||||
{
|
||||
state = UploadState.InProgress;
|
||||
hasError = false;
|
||||
|
||||
upload.Upload();
|
||||
}
|
||||
|
||||
void Close()
|
||||
{
|
||||
DialogService.Close(true);
|
||||
}
|
||||
|
||||
void OnProgress(UploadProgressArgs args)
|
||||
{
|
||||
progress = args.Progress;
|
||||
}
|
||||
|
||||
async Task OnCompleteAsync(UploadCompleteEventArgs args)
|
||||
{
|
||||
try
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
hasError = true;
|
||||
errorMessage = e.Message;
|
||||
}
|
||||
|
||||
state = hasError ? UploadState.Idle : UploadState.Completed;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user