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">
|
<RadzenAlert Visible="@hasError" AlertStyle="AlertStyle.Danger" Variant="Variant.Flat" Shade="Shade.Lighter" AllowClose="false">
|
||||||
@errorMessage
|
@errorMessage
|
||||||
</RadzenAlert>
|
</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">
|
<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="Отмена" />
|
<RadzenButton Click="@Close" Visible="@(state == UploadState.Idle)" ButtonStyle="ButtonStyle.Light" Text="Отмена" />
|
||||||
</RadzenStack>
|
</RadzenStack>
|
||||||
<RadzenProgressBar Value="@progress" Visible="@(state != UploadState.Idle)" />
|
<RadzenProgressBar Value="@progress" Visible="@(state != UploadState.Idle)" />
|
||||||
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
RadzenUpload upload;
|
RadzenUpload upload;
|
||||||
UploadState state;
|
UploadState state;
|
||||||
|
bool fileNotSelected = true;
|
||||||
int progress;
|
int progress;
|
||||||
bool hasError;
|
bool hasError;
|
||||||
string errorMessage;
|
string errorMessage;
|
||||||
@ -83,8 +84,25 @@
|
|||||||
{
|
{
|
||||||
hasError = true;
|
hasError = true;
|
||||||
errorMessage = e.Message;
|
errorMessage = e.Message;
|
||||||
|
|
||||||
|
upload.ClearFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
state = hasError ? UploadState.Idle : UploadState.Completed;
|
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;
|
var fileToParseId = -1;
|
||||||
if (dialogResult != null && int.TryParse(dialogResult, out fileToParseId))
|
if (dialogResult != null && int.TryParse(dialogResult, out fileToParseId))
|
||||||
{
|
{
|
||||||
|
ChangeState(SyncedPageState.SyncWaiting);
|
||||||
|
|
||||||
// TODO: Use user id
|
// TODO: Use user id
|
||||||
var campaign = await HeadquartersService.InitiateCampaignAsync(CampaignType, "", new CampaignParseArgs()
|
var campaign = await HeadquartersService.InitiateCampaignAsync(CampaignType, "", new CampaignParseArgs()
|
||||||
{
|
{
|
||||||
FileToParseId = fileToParseId
|
FileToParseId = fileToParseId
|
||||||
});
|
});
|
||||||
CampaignManagementState.EnqueueCampaign(campaign);
|
CampaignManagementState.EnqueueCampaign(campaign);
|
||||||
|
|
||||||
ChangeState(SyncedPageState.SyncWaiting);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user