IndexerStatusLabel.razor 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. @using WarcViewerBlazorWinForm.Backend.Warc
  2. @using WarcViewerBlazorWinForm.Library.EventBus
  3. @implements IDisposable
  4. @inject IEventBus EventBus
  5. <BootstrapInputGroup>
  6. <Tag>Indexer</Tag>
  7. @if (_event?.IsRunning != true)
  8. {
  9. <Tag><Light Color="Color.Dark" class="mt-2"></Light></Tag>
  10. <Tag>Idle</Tag>
  11. }
  12. else
  13. {
  14. <Tag><Light Color="Color.Success" class="mt-2"></Light></Tag>
  15. <Tag>Running</Tag>
  16. }
  17. @if (_event?.FileDescriptor != null)
  18. {
  19. if (_event.FileDescriptor.IsReadDirectly)
  20. {
  21. <Tag>@_event.FileDescriptor.FilePath</Tag>
  22. }
  23. else
  24. {
  25. <Tag>
  26. <div>@_event.FileDescriptor.FilePath</div>
  27. <div>@_event.FileDescriptor.ArchiveEntryKey</div>
  28. </Tag>
  29. }
  30. }
  31. @if (_event?.Position.HasValue == true)
  32. {
  33. <Tag><Progress IsAnimated Value="_event.Position.Value*100" Round="2" IsStriped IsShowValue Height="20"></Progress></Tag>
  34. }
  35. else if (_event?.IsRunning == true)
  36. {
  37. <Tag>Waiting...</Tag>
  38. }
  39. </BootstrapInputGroup>
  40. @code {
  41. private WarcIndexerStatusEvent? _event;
  42. protected override void OnInitialized()
  43. {
  44. EventBus.Subscript<WarcIndexerStatusEvent>(UpdateLabel);
  45. }
  46. public void Dispose()
  47. {
  48. EventBus.UnSubscript<WarcIndexerStatusEvent>(UpdateLabel);
  49. }
  50. private void UpdateLabel(WarcIndexerStatusEvent obj)
  51. {
  52. _event = obj;
  53. InvokeAsync(StateHasChanged);
  54. }
  55. }