Skip to content

Commit db36112

Browse files
authored
Merge pull request #220 from pticostaricags/development
Adding video authorization view to allow access to only the videos owner
2 parents 6875f04 + d825204 commit db36112

8 files changed

+345
-247
lines changed

src/FairPlayCombinedSln/FairPlayTube.SharedUI/Components/Pages/Creator/VideoChapters.razor

+21-13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
@using FairPlayCombined.Models.FairPlayTube.VideoInfo
1111
@using FairPlayCombined.Models.Pagination
1212
@using FairPlayTube.SharedUI.Components.Spinners
13+
@using FairPlayTube.SharedUI.Components.Video
1314

1415
<PageTitle>
1516
@Localizer![VideoChaptersTextKey] @(VideoInfoModel != null ? $"- {VideoInfoModel.Name}" : String.Empty)
@@ -21,16 +22,23 @@
2122

2223
<LoadingIndicator ShowSpinners="this.IsBusy"></LoadingIndicator>
2324

24-
<div>
25-
<FluentButton Type="ButtonType.Button" OnClick="OnRecreatePlanButtonclickedAsync">
26-
@Localizer![ReCreateChaptersTextKey]
27-
</FluentButton>
28-
</div>
29-
<div>
30-
@if (!String.IsNullOrWhiteSpace(this.YouTubeChapters))
31-
{
32-
<p>
33-
@((MarkupString)this.YouTubeChapters)
34-
</p>
35-
}
36-
</div>
25+
@if (this.VideoInfoModel != null)
26+
{
27+
<VideoAuthorizeView VideoInfoModel="@this.VideoInfoModel" CancellationTokenSource="@this.cancellationTokenSource">
28+
<AuthorizedContent>
29+
<div>
30+
<FluentButton Type="ButtonType.Button" OnClick="OnRecreatePlanButtonclickedAsync">
31+
@Localizer![ReCreateChaptersTextKey]
32+
</FluentButton>
33+
</div>
34+
<div>
35+
@if (!String.IsNullOrWhiteSpace(this.YouTubeChapters))
36+
{
37+
<p>
38+
@((MarkupString)this.YouTubeChapters)
39+
</p>
40+
}
41+
</div>
42+
</AuthorizedContent>
43+
</VideoAuthorizeView>
44+
}

src/FairPlayCombinedSln/FairPlayTube.SharedUI/Components/Pages/Creator/VideoDailyPosts.razor

+51-44
Original file line numberDiff line numberDiff line change
@@ -28,51 +28,58 @@
2828

2929
<LoadingIndicator ShowSpinners="this.IsBusy"></LoadingIndicator>
3030

31-
@if (this.VideoInfoId.HasValue)
31+
@if (this.VideoInfoModel != null)
3232
{
33-
<FluentAccordion>
34-
<FluentAccordionItem Expanded="true">
35-
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
36-
</FluentAccordionItem>
37-
</FluentAccordion>
38-
}
33+
<VideoAuthorizeView VideoInfoModel="@this.VideoInfoModel" CancellationTokenSource="@this.cancellationTokenSource">
34+
<AuthorizedContent>
35+
@if (this.VideoInfoId.HasValue)
36+
{
37+
<FluentAccordion>
38+
<FluentAccordionItem Expanded="true">
39+
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
40+
</FluentAccordionItem>
41+
</FluentAccordion>
42+
}
3943

40-
<div>
41-
<FluentSelect @bind-SelectedOption="@this.SelectedCulture" Items="@SupportedCultures"
42-
Embedded="true">
43-
<OptionTemplate>@context!.DisplayName</OptionTemplate>
44-
</FluentSelect>
45-
</div>
46-
<div>
47-
<FluentRadioGroup DisplayName="Social Network" @bind-Value="@this.SelectedSocialNetwork">
48-
<FluentRadio Value="@("LinkedIn")">LinkedIn</FluentRadio>
49-
<FluentRadio Value="@("X")">Twitter/X</FluentRadio>
50-
</FluentRadioGroup>
51-
</div>
52-
<div>
53-
<FluentButton Appearance="Appearance.Accent" Type="ButtonType.Button"
54-
OnClick="OnCreateVideoDailyPostAsync">@Localizer![CreateVideoDailyPostsTextKey]</FluentButton>
55-
</div>
44+
<div>
45+
<FluentSelect @bind-SelectedOption="@this.SelectedCulture" Items="@SupportedCultures"
46+
Embedded="true">
47+
<OptionTemplate>@context!.DisplayName</OptionTemplate>
48+
</FluentSelect>
49+
</div>
50+
<div>
51+
<FluentRadioGroup DisplayName="Social Network" @bind-Value="@this.SelectedSocialNetwork">
52+
<FluentRadio Value="@("LinkedIn")">LinkedIn</FluentRadio>
53+
<FluentRadio Value="@("X")">Twitter/X</FluentRadio>
54+
</FluentRadioGroup>
55+
</div>
56+
<div>
57+
<FluentButton Appearance="Appearance.Accent" Type="ButtonType.Button"
58+
OnClick="OnCreateVideoDailyPostAsync">@Localizer![CreateVideoDailyPostsTextKey]</FluentButton>
59+
</div>
5660

57-
@if (this.ItemsProvider != null)
58-
{
59-
<FluentDataGrid ItemsProvider="@this.ItemsProvider" Pagination="@this.paginationState">
60-
<TemplateColumn Class="multiline-text" Title="Posts">
61-
<FluentAccordion>
62-
<FluentAccordionItem Expanded="false" Heading="@($"({context.SocialNetworkName} - Expand to see the content)")">
63-
@((MarkupString)context.HtmlVideoDigitalMarketingDailyPostsIdeas!)
64-
</FluentAccordionItem>
65-
</FluentAccordion>
66-
</TemplateColumn>
67-
</FluentDataGrid>
68-
<CustomFluentPaginator State="@this.paginationState"></CustomFluentPaginator>
69-
}
61+
@if (this.ItemsProvider != null)
62+
{
63+
<FluentDataGrid ItemsProvider="@this.ItemsProvider" Pagination="@this.paginationState">
64+
<TemplateColumn Class="multiline-text" Title="Posts">
65+
<FluentAccordion>
66+
<FluentAccordionItem Expanded="false" Heading="@($"({context.SocialNetworkName} - Expand to see the content)")">
67+
@((MarkupString)context.HtmlVideoDigitalMarketingDailyPostsIdeas!)
68+
</FluentAccordionItem>
69+
</FluentAccordion>
70+
</TemplateColumn>
71+
</FluentDataGrid>
72+
<CustomFluentPaginator State="@this.paginationState"></CustomFluentPaginator>
73+
}
7074

71-
<div>
72-
@if (!String.IsNullOrWhiteSpace(this.DigitalMarketingDailyPostsIdeas))
73-
{
74-
<p>
75-
@((MarkupString)this.DigitalMarketingDailyPostsIdeas)
76-
</p>
77-
}
78-
</div>
75+
<div>
76+
@if (!String.IsNullOrWhiteSpace(this.DigitalMarketingDailyPostsIdeas))
77+
{
78+
<p>
79+
@((MarkupString)this.DigitalMarketingDailyPostsIdeas)
80+
</p>
81+
}
82+
</div>
83+
</AuthorizedContent>
84+
</VideoAuthorizeView>
85+
}

src/FairPlayCombinedSln/FairPlayTube.SharedUI/Components/Pages/Creator/VideoDigitalMarketing.razor

+36-29
Original file line numberDiff line numberDiff line change
@@ -23,36 +23,43 @@
2323

2424
<LoadingIndicator ShowSpinners="this.IsBusy"></LoadingIndicator>
2525

26-
@if (this.VideoInfoId.HasValue)
26+
@if (this.VideoInfoModel != null)
2727
{
28-
<FluentAccordion>
29-
<FluentAccordionItem Expanded="true">
30-
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
31-
</FluentAccordionItem>
32-
</FluentAccordion>
33-
}
28+
<VideoAuthorizeView VideoInfoModel="@this.VideoInfoModel" CancellationTokenSource="@this.cancellationTokenSource">
29+
<AuthorizedContent>
30+
@if (this.VideoInfoId.HasValue)
31+
{
32+
<FluentAccordion>
33+
<FluentAccordionItem Expanded="true">
34+
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
35+
</FluentAccordionItem>
36+
</FluentAccordion>
37+
}
3438

35-
<div>
36-
<FluentSelect @bind-SelectedOption="@this.SelectedCulture" Items="@SupportedCultures"
37-
Embedded="true">
38-
<OptionTemplate>@context!.DisplayName</OptionTemplate>
39-
</FluentSelect>
40-
</div>
41-
<div>
42-
<FluentButton Type="ButtonType.Button" OnClick="OnRecreatePlanButtonclickedAsync">
43-
@Localizer![CreateNewPlanTextKey]
44-
</FluentButton>
45-
</div>
46-
<div>
47-
@if (this.DigitalMarketingIdeas?.Count > 0)
48-
{
49-
foreach (var singleDigitalMarketingIdea in this.DigitalMarketingIdeas)
50-
{
5139
<div>
52-
<p>
53-
@((MarkupString)singleDigitalMarketingIdea)
54-
</p>
40+
<FluentSelect @bind-SelectedOption="@this.SelectedCulture" Items="@SupportedCultures"
41+
Embedded="true">
42+
<OptionTemplate>@context!.DisplayName</OptionTemplate>
43+
</FluentSelect>
5544
</div>
56-
}
57-
}
58-
</div>
45+
<div>
46+
<FluentButton Type="ButtonType.Button" OnClick="OnRecreatePlanButtonclickedAsync">
47+
@Localizer![CreateNewPlanTextKey]
48+
</FluentButton>
49+
</div>
50+
<div>
51+
@if (this.DigitalMarketingIdeas?.Count > 0)
52+
{
53+
foreach (var singleDigitalMarketingIdea in this.DigitalMarketingIdeas)
54+
{
55+
<div>
56+
<p>
57+
@((MarkupString)singleDigitalMarketingIdea)
58+
</p>
59+
</div>
60+
}
61+
}
62+
</div>
63+
</AuthorizedContent>
64+
</VideoAuthorizeView>
65+
}

src/FairPlayCombinedSln/FairPlayTube.SharedUI/Components/Pages/Creator/VideoInfographic.razor

+57-48
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,63 @@
2626
</FluentLabel>
2727

2828
<LoadingIndicator ShowSpinners="this.IsBusy"></LoadingIndicator>
29-
@if (this.VideoInfoId.HasValue)
30-
{
31-
<FluentAccordion>
32-
<FluentAccordionItem Expanded="true">
33-
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
34-
</FluentAccordionItem>
35-
</FluentAccordion>
36-
}
3729

38-
<div>
39-
<FluentButton Appearance="Appearance.Accent" Type="ButtonType.Button"
40-
OnClick="OnCreateNewInfographicClickedAsync">@Localizer![CreateNewInfographicTextKey]</FluentButton>
41-
</div>
42-
<div>
43-
@if (this.Items?.Items?.Length > 0)
44-
{
45-
<FluentStack Orientation="Orientation.Horizontal" Wrap="true">
46-
@foreach (var singlePhotoId in this.Items.Items.Select(p=>p.PhotoId))
30+
@if (this.VideoInfoModel != null)
31+
{
32+
<VideoAuthorizeView VideoInfoModel="@this.VideoInfoModel" CancellationTokenSource="@this.cancellationTokenSource">
33+
<AuthorizedContent>
34+
@if (this.VideoInfoId.HasValue)
4735
{
48-
<div style="width:400px;">
49-
@if (!this.PagePhotos.ContainsKey(singlePhotoId))
50-
{
51-
<FluentCard class="card-padding" Width="400">
52-
<FluentSkeleton Shape="SkeletonShape.Circle"></FluentSkeleton>
53-
<FluentProgressRing></FluentProgressRing>
54-
</FluentCard>
55-
}
56-
else
57-
{
58-
<img @key="@singlePhotoId" loading="lazy" src="@(this.PagePhotos[singlePhotoId])" width="400" />
59-
}
60-
</div>
36+
<FluentAccordion>
37+
<FluentAccordionItem Expanded="true">
38+
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
39+
</FluentAccordionItem>
40+
</FluentAccordion>
6141
}
62-
</FluentStack>
63-
}
64-
<CustomFluentPaginator State="@this.paginationState" CurrentPageIndexChanged="OnCurrentPageIndexChangedAsync"></CustomFluentPaginator>
65-
</div>
66-
<FluentDivider Role="DividerRole.Separator"></FluentDivider>
67-
<div>
68-
@if (!String.IsNullOrWhiteSpace(this.GeneratedInfographicUri))
69-
{
70-
<a data-enhance-nav="false" href="@this.GeneratedInfographicUri" target="_blank">
71-
<img width="400" class="@ThemeConfiguration.Images.ThumbnailDefaultCss" src="@this.GeneratedInfographicUri" />
72-
</a>
73-
<p>
74-
<FluentLabel Typo="Typography.Body">
75-
@this.RevisedPrompt
76-
</FluentLabel>
77-
</p>
78-
}
79-
</div>
42+
43+
<div>
44+
<FluentButton Appearance="Appearance.Accent" Type="ButtonType.Button"
45+
OnClick="OnCreateNewInfographicClickedAsync">@Localizer![CreateNewInfographicTextKey]</FluentButton>
46+
</div>
47+
<div>
48+
@if (this.Items?.Items?.Length > 0)
49+
{
50+
<FluentStack Orientation="Orientation.Horizontal" Wrap="true">
51+
@foreach (var singlePhotoId in this.Items.Items.Select(p => p.PhotoId))
52+
{
53+
<div style="width:400px;">
54+
@if (!this.PagePhotos.ContainsKey(singlePhotoId))
55+
{
56+
<FluentCard class="card-padding" Width="400">
57+
<FluentSkeleton Shape="SkeletonShape.Circle"></FluentSkeleton>
58+
<FluentProgressRing></FluentProgressRing>
59+
</FluentCard>
60+
}
61+
else
62+
{
63+
<img @key="@singlePhotoId" loading="lazy" src="@(this.PagePhotos[singlePhotoId])" width="400" />
64+
}
65+
</div>
66+
}
67+
</FluentStack>
68+
}
69+
<CustomFluentPaginator State="@this.paginationState" CurrentPageIndexChanged="OnCurrentPageIndexChangedAsync"></CustomFluentPaginator>
70+
</div>
71+
<FluentDivider Role="DividerRole.Separator"></FluentDivider>
72+
<div>
73+
@if (!String.IsNullOrWhiteSpace(this.GeneratedInfographicUri))
74+
{
75+
<a data-enhance-nav="false" href="@this.GeneratedInfographicUri" target="_blank">
76+
<img width="400" class="@ThemeConfiguration.Images.ThumbnailDefaultCss" src="@this.GeneratedInfographicUri" />
77+
</a>
78+
<p>
79+
<FluentLabel Typo="Typography.Body">
80+
@this.RevisedPrompt
81+
</FluentLabel>
82+
</p>
83+
}
84+
</div>
85+
86+
</AuthorizedContent>
87+
</VideoAuthorizeView>
88+
}

src/FairPlayCombinedSln/FairPlayTube.SharedUI/Components/Pages/Creator/VideoLinkedInArticle.razor

+27-20
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,31 @@
2222

2323
<LoadingIndicator ShowSpinners="this.IsBusy"></LoadingIndicator>
2424

25-
@if (this.VideoInfoId.HasValue)
25+
@if (this.VideoInfoModel != null)
2626
{
27-
<FluentAccordion>
28-
<FluentAccordionItem Expanded="true">
29-
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
30-
</FluentAccordionItem>
31-
</FluentAccordion>
32-
}
33-
34-
<FluentButton Type="ButtonType.Button" OnClick="CreateLinkedInArticleAsync">
35-
@Localizer![ReCreateArticleTextKey]
36-
</FluentButton>
37-
38-
<div>
39-
@if (!String.IsNullOrWhiteSpace(this.LinkedInArticleDraftText))
40-
{
41-
<p>
42-
@((MarkupString)this.LinkedInArticleDraftText)
43-
</p>
44-
}
45-
</div>
27+
<VideoAuthorizeView VideoInfoModel="@this.VideoInfoModel" CancellationTokenSource="@this.cancellationTokenSource">
28+
<AuthorizedContent>
29+
@if (this.VideoInfoId.HasValue)
30+
{
31+
<FluentAccordion>
32+
<FluentAccordionItem Expanded="true">
33+
<VideoActions context="this.VideoInfoModel" OnVideoDeleted="LoadDataAsync"></VideoActions>
34+
</FluentAccordionItem>
35+
</FluentAccordion>
36+
}
37+
38+
<FluentButton Type="ButtonType.Button" OnClick="CreateLinkedInArticleAsync">
39+
@Localizer![ReCreateArticleTextKey]
40+
</FluentButton>
41+
42+
<div>
43+
@if (!String.IsNullOrWhiteSpace(this.LinkedInArticleDraftText))
44+
{
45+
<p>
46+
@((MarkupString)this.LinkedInArticleDraftText)
47+
</p>
48+
}
49+
</div>
50+
</AuthorizedContent>
51+
</VideoAuthorizeView>
52+
}

0 commit comments

Comments
 (0)