Added the cookie consent banner
This commit is contained in:
@@ -116,6 +116,7 @@ public class CoreConfiguration
|
|||||||
public FileManagerData FileManager { get; set; } = new();
|
public FileManagerData FileManager { get; set; } = new();
|
||||||
|
|
||||||
[JsonProperty("Footer")] public FooterData Footer { get; set; } = new();
|
[JsonProperty("Footer")] public FooterData Footer { get; set; } = new();
|
||||||
|
[JsonProperty("CookieConsentBanner")] public CookieData CookieConsentBanner{ get; set; } = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FooterData
|
public class FooterData
|
||||||
@@ -147,4 +148,27 @@ public class CoreConfiguration
|
|||||||
[Description("This specifies the general timeout for file manager operations. This can but has not to be used by file accesses")]
|
[Description("This specifies the general timeout for file manager operations. This can but has not to be used by file accesses")]
|
||||||
public int OperationTimeout { get; set; } = 5;
|
public int OperationTimeout { get; set; } = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class CookieData
|
||||||
|
{
|
||||||
|
[JsonProperty("ShowCookieConsentBanner")]
|
||||||
|
[Description("This specifies if the cookie consent banner is shown to users.")]
|
||||||
|
public bool ShowBanner { get; set; } = true;
|
||||||
|
|
||||||
|
[JsonProperty("BannerTitle")]
|
||||||
|
[Description("The title for the cookie consent banner.")]
|
||||||
|
public string BannerTitle = "\ud83c\udf6a Cookies";
|
||||||
|
|
||||||
|
[JsonProperty("BannerText")]
|
||||||
|
[Description("The description for the cookie consent banner.")]
|
||||||
|
public string BannerText = "Moonlight is using cookies \ud83c\udf6a, to personalize your experience.";
|
||||||
|
|
||||||
|
[JsonProperty("ConsentText")]
|
||||||
|
[Description("The text for the consent option.")]
|
||||||
|
public string ConsentText = "Consent";
|
||||||
|
|
||||||
|
[JsonProperty("DeclineText")]
|
||||||
|
[Description("The text for the decline option.")]
|
||||||
|
public string DeclineText = "Decline";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
@using ApexCharts
|
||||||
|
@using MoonCore.Services
|
||||||
|
@using Moonlight.Core.Configuration
|
||||||
|
@using Moonlight.Core.Services
|
||||||
|
|
||||||
|
@inject ConfigService<CoreConfiguration> ConfigService
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
|
||||||
|
@ChildContent
|
||||||
|
|
||||||
|
@if (ConfigService.Get().Customisation.CookieConsentBanner.ShowBanner && !IdentityService.HasFlag("CookieAsked").Result)
|
||||||
|
{
|
||||||
|
<div class="mb-12 mx-8 d-flex justify-content-end fixed-bottom no-pointer-events" style="pointer-events: none;">
|
||||||
|
<div style="pointer-events: all; max-width: var(--bs-breakpoint-sm)" class="w-100">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3 class="mb-4">@ConfigService.Get().Customisation.CookieConsentBanner.BannerTitle</h3>
|
||||||
|
<p class="text-muted fs-6">
|
||||||
|
@ConfigService.Get().Customisation.CookieConsentBanner.BannerText
|
||||||
|
</p>
|
||||||
|
<span class="d-flex gap-5">
|
||||||
|
<a @onclick:preventDefault @onclick="Consent" class="cursor-pointer text-primary">
|
||||||
|
<i class="bx bx-check"></i> @ConfigService.Get().Customisation.CookieConsentBanner.ConsentText
|
||||||
|
</a>
|
||||||
|
<a @onclick:preventDefault @onclick="Decline" class="cursor-pointer text-primary">
|
||||||
|
<i class="bx bx-x"></i> @ConfigService.Get().Customisation.CookieConsentBanner.DeclineText
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
@code {
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
|
private async Task Consent()
|
||||||
|
{
|
||||||
|
if (!IdentityService.IsLoggedIn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await IdentityService.SetFlag("CookieAsked", true);
|
||||||
|
await IdentityService.SetFlag("CookieConsent", true);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Decline()
|
||||||
|
{
|
||||||
|
if (!IdentityService.IsLoggedIn)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await IdentityService.SetFlag("CookieAsked", true);
|
||||||
|
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -55,7 +55,9 @@
|
|||||||
if (IdentityService.IsLoggedIn)
|
if (IdentityService.IsLoggedIn)
|
||||||
{
|
{
|
||||||
<PermissionChecker>
|
<PermissionChecker>
|
||||||
|
<CookieConsentBanner>
|
||||||
@Body
|
@Body
|
||||||
|
</CookieConsentBanner>
|
||||||
</PermissionChecker>
|
</PermissionChecker>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user