File
Implements
Metadata
selector |
[cookies-banner] |
styleUrls |
./cookies-banner.component.scss |
templateUrl |
./cookies-banner.component.html |
Methods
Public
fetchCookiesBanner
|
fetchCookiesBanner()
|
|
|
cookieInformationLabel
|
Type : string
|
|
cookiesBannerUrl
|
Type : string
|
|
import { Component, OnInit, Input } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { UtilService } from 'src/app/core/services/util-service/util.service';
import { AppConfig } from 'src/app/app.config';
import { DataResolverService } from 'src/app/core/services/data-resolver/data-resolver.service';
import { PublicationService } from 'src/app/core/services/publication-service/publication.service';
@Component({
selector: '[cookies-banner]',
templateUrl: './cookies-banner.component.html',
styleUrls: ['./cookies-banner.component.scss'],
})
export class CookiesBannerComponent implements OnInit {
cookiesContent;
hasAcceptedCookies: boolean;
titleLabel: string;
buttonLabel: string;
cookieInformationLabel: string;
cookiesBannerUrl: string;
constructor(private cookieService: CookieService, private util: UtilService,
private dataService: DataResolverService, private publicationService: PublicationService)
{
this.cookiesBannerUrl = `${this.publicationService.getPublicationPath()}/system-pages/cookiesbanner.html`;
}
ngOnInit() {
this.hasAcceptedCookies = this.cookieService.get(AppConfig.settings.cookiesConfig.acceptCookie) === 'yes';
if(!this.hasAcceptedCookies) {
this.fetchCookiesBanner();
}
}
public accept() {
this.cookieService.set(AppConfig.settings.cookiesConfig.acceptCookie, 'yes', 365,
AppConfig.settings.cookiesConfig.path, AppConfig.settings.cookiesConfig.domain);
this.hasAcceptedCookies = true;
}
public fetchCookiesBanner(): void {
this.dataService.getPageData(this.cookiesBannerUrl).then(page => {
this.cookiesContent = page;
const entity = this.util.extract(this.cookiesContent, 'Regions', region => region.Name === 'main', 'Entities', '0');
this.titleLabel = entity.Title;
this.cookieInformationLabel = entity.Text.BodyText;
this.buttonLabel = entity.ButtonText;
});
}
}
<div class="cookies-banner" *ngIf="!hasAcceptedCookies && cookiesContent" [ngClass]="{'container': isDesktop, 'container-fluid': !isDesktop}">
<h3 class="text-white cookies-title">{{titleLabel}}</h3>
<div [innerHtml]="cookieInformationLabel" id="cookies-info"></div>
<button class="btn btn-green mr-1 mb-1" (click)="accept()">{{ buttonLabel }}</button>
</div>
@import "src/app/styles/helpers";
.cookies-banner {
padding: calc-rem(30);
background-color: $dark-slate;
text-align: center;
}
.cookies-title {
margin: calc-rem(10);
margin-bottom: calc-rem(20);
}
#cookies-info {
color: $white;
margin-bottom: calc-rem(20);
padding-left: calc-rem(35);
padding-right: calc-rem(35);
}
#cookies-info {
::ng-deep {
p {
margin: calc-rem(5);
}
}
}
#cookies-info {
::ng-deep {
p > a {
color: $light-blue;
}
}
}
Legend
Html element with directive