56 lines
2.0 KiB
Plaintext
56 lines
2.0 KiB
Plaintext
@namespace Oqtane.Themes.Controls
|
|
@inherits ThemeControlBase
|
|
@inject ISettingService SettingService
|
|
@inject ICookieConsentService CookieConsentService
|
|
@inject IJSRuntime JSRuntime
|
|
@inject IStringLocalizer<CookieConsent> Localizer
|
|
|
|
@if (_enabled && !Hidden && showBanner)
|
|
{
|
|
<form method="post" @formname="CookieConsentForm" @onsubmit="async () => await AcceptPolicy()" data-enhance>
|
|
<input type="hidden" name="@Constants.RequestVerificationToken" value="@SiteState.AntiForgeryToken" />
|
|
<div class="gdpr-consent-bar bg-light text-dark p-3 fixed-bottom">
|
|
<div class="container-fluid d-flex justify-content-between align-items-center">
|
|
<div>
|
|
@((MarkupString)Convert.ToString(Localizer["ConsentDescription"]))
|
|
</div>
|
|
<div>
|
|
<button class="btn btn-primary" type="submit">@((MarkupString)Convert.ToString(Localizer["Apply"]))</button>
|
|
@if (ShowPrivacyLink)
|
|
{
|
|
<a class="btn btn-secondary ms-2" href="/privacy" target="_blank">@((MarkupString)Convert.ToString(Localizer["Privacy"]))</a>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</form>
|
|
}
|
|
@code {
|
|
private bool showBanner;
|
|
private bool _enabled;
|
|
|
|
[Parameter]
|
|
public bool Hidden { get; set; }
|
|
|
|
[Parameter]
|
|
public bool ShowPrivacyLink { get; set; } = true;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
showBanner = !(await CookieConsentService.CanTrackAsync());
|
|
_enabled = bool.Parse(SettingService.GetSetting(PageState.Site.Settings, "CookieConsent", "False"));
|
|
}
|
|
|
|
private async Task AcceptPolicy()
|
|
{
|
|
var cookieString = await CookieConsentService.CreateConsentCookieAsync();
|
|
if (!string.IsNullOrEmpty(cookieString))
|
|
{
|
|
var interop = new Interop(JSRuntime);
|
|
await interop.SetCookieString(cookieString);
|
|
|
|
showBanner = false;
|
|
}
|
|
}
|
|
} |