1
1
@attribute [Route($"{ Constants .Routes .FairPlayTubeRoutes .CreatorRoutes .MyVideoViewers } /{{ VideoId }} ")]
2
- @implements IDisposable
2
+ @implements IAsyncDisposable
3
3
4
4
@attribute [Authorize(Roles = FairPlayCombined.Common.Constants.RoleName.BasicPlanUser)]
5
5
9
9
@using FairPlayCombined .Models .FairPlayTube .VideoInfo
10
10
@using FairPlayCombined .Models .FairPlayTube .VideoViewer
11
11
@using FairPlayCombined .Models .Pagination
12
+ @using FairPlayTube .SharedUI .Components .Paginators
12
13
@using FairPlayTube .SharedUI .Components .Spinners
13
14
14
- @inject IVideoViewerService videoViewerService
15
- @inject IUserProviderService userProviderService
16
- <PageTitle >My Video Viewers</PageTitle >
15
+
16
+ <PageTitle >@Localizer ![MyVideoViewersTextKey]</PageTitle >
17
17
18
18
<LoadingIndicator ShowSpinners =" this.IsBusy" ></LoadingIndicator >
19
19
20
20
<div class =" @ThemeConfiguration.Grids.GridContainerCss" >
21
21
<FluentDataGrid ItemsProvider =" ItemsProvider" Pagination =" this.paginationState" >
22
- <TemplateColumn Class =" multiline-text" >
22
+ <TemplateColumn Class =" multiline-text" Title = " @Localizer![UserTextKey] " >
23
23
@if (String .IsNullOrWhiteSpace (context .Username ))
24
24
{
25
- <FluentLabel >Anonymous </FluentLabel >
25
+ <FluentLabel >@Localizer ! [ AnonymousTextKey ] </FluentLabel >
26
26
}
27
27
else
28
28
{
29
29
<FluentLabel >@context.Username </FluentLabel >
30
30
}
31
31
</TemplateColumn >
32
- <TemplateColumn Title =" @nameof(VideoViewerModel.TotalTimeWatched) " >
32
+ <TemplateColumn Title =" @Localizer![TotalTimeWatchedTextKey] " >
33
33
@TimeSpan.FromSeconds(context.TotalTimeWatched)
34
34
</TemplateColumn >
35
- <PropertyColumn Property =" @( p=> p.TotalSessions)" ></PropertyColumn >
35
+ <PropertyColumn Property =" @( p=> p.TotalSessions)" Title = " @Localizer![TotalSessionsTextKey] " ></PropertyColumn >
36
36
</FluentDataGrid >
37
37
</div >
38
- <FluentPaginator State =" this.paginationState" ></FluentPaginator >
39
-
40
- @code
41
- {
42
- [Parameter ]
43
- public string ? VideoId { get ; set ; }
44
- private bool IsBusy { get ; set ; }
45
- private GridItemsProvider <VideoViewerModel >? ItemsProvider ;
46
- private readonly PaginationState paginationState = new ()
47
- {
48
- ItemsPerPage = Constants .Pagination .PageSize
49
- };
50
- private readonly CancellationTokenSource cancellationTokenSource = new ();
51
-
52
- protected override void OnInitialized ()
53
- {
54
- this .IsBusy = true ;
55
- ItemsProvider = async req =>
56
- {
57
- StateHasChanged ();
58
- PaginationRequest paginationRequest = new ()
59
- {
60
- PageSize = paginationState .ItemsPerPage ,
61
- StartIndex = req .StartIndex
62
- };
63
- var items = await videoViewerService
64
- .GetPaginatedVideoViewerInfoForUserIdAsync (paginationRequest ,
65
- videoId : this .VideoId ! ,
66
- userId : this .userProviderService ! .GetCurrentUserId ()! ,
67
- this .cancellationTokenSource .Token );
68
- StateHasChanged ();
69
- var result = GridItemsProviderResult .From <VideoViewerModel >(items ! .Items ! , items .TotalItems );
70
- return result ;
71
- };
72
- this .IsBusy = false ;
73
- }
74
-
75
- void IDisposable .Dispose ()
76
- {
77
- this .cancellationTokenSource .Dispose ();
78
- }
79
- }
38
+ <CustomFluentPaginator State =" @this.paginationState" ></CustomFluentPaginator >
0 commit comments