Fix upload error handling
This commit is contained in:
@ -22,9 +22,9 @@
|
||||
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
|
||||
@errorMessage
|
||||
</RadzenAlert>
|
||||
<RadzenUpload id="uploadWithDragAndDrop" @ref="upload" Url="upload/parsing" Progress="@OnProgress" Complete="@OnCompleteAsync" ChooseText="Перетащите сюда или нажмите, чтобы выбрать файл" Accept=".xlsx" Auto="false" Multiple="false" Style="width: 100%;" />
|
||||
<RadzenUpload id="uploadWithDragAndDrop" @ref="upload" Url="upload/parsing" Progress="@OnProgress" Complete="@OnCompleteAsync" Error="@OnError" Change="@OnChange" ChooseText="Перетащите сюда или нажмите, чтобы выбрать файл" Accept=".xlsx" 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="@Upload" Visible="@(state == UploadState.Idle)" Disabled="@fileNotSelected" Text="Отправить" />
|
||||
<RadzenButton Click="@Close" Visible="@(state == UploadState.Idle)" ButtonStyle="ButtonStyle.Light" Text="Отмена" />
|
||||
</RadzenStack>
|
||||
<RadzenProgressBar Value="@progress" Visible="@(state != UploadState.Idle)" />
|
||||
@ -41,6 +41,7 @@
|
||||
|
||||
RadzenUpload upload;
|
||||
UploadState state;
|
||||
bool fileNotSelected = true;
|
||||
int progress;
|
||||
bool hasError;
|
||||
string errorMessage;
|
||||
@ -83,8 +84,25 @@
|
||||
{
|
||||
hasError = true;
|
||||
errorMessage = e.Message;
|
||||
|
||||
upload.ClearFiles();
|
||||
}
|
||||
|
||||
state = hasError ? UploadState.Idle : UploadState.Completed;
|
||||
}
|
||||
|
||||
void OnError(UploadErrorEventArgs args)
|
||||
{
|
||||
hasError = true;
|
||||
errorMessage = args.Message;
|
||||
|
||||
upload.ClearFiles();
|
||||
|
||||
state = UploadState.Idle;
|
||||
}
|
||||
|
||||
void OnChange(UploadChangeEventArgs args)
|
||||
{
|
||||
fileNotSelected = args.Files.Count() <= 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,14 +113,14 @@ namespace Hcs.WebApp.Components.Shared
|
||||
var fileToParseId = -1;
|
||||
if (dialogResult != null && int.TryParse(dialogResult, out fileToParseId))
|
||||
{
|
||||
ChangeState(SyncedPageState.SyncWaiting);
|
||||
|
||||
// TODO: Use user id
|
||||
var campaign = await HeadquartersService.InitiateCampaignAsync(CampaignType, "", new CampaignParseArgs()
|
||||
{
|
||||
FileToParseId = fileToParseId
|
||||
});
|
||||
CampaignManagementState.EnqueueCampaign(campaign);
|
||||
|
||||
ChangeState(SyncedPageState.SyncWaiting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user