mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-22 14:23:57 +00:00
BETTERZON-37: Adding cookie notice popup (#23)
This commit is contained in:
parent
1b1cdb59f6
commit
4d4a391f38
|
@ -1,124 +1,131 @@
|
||||||
{
|
{
|
||||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"newProjectRoot": "projects",
|
"newProjectRoot": "projects",
|
||||||
"projects": {
|
"projects": {
|
||||||
"Betterzon": {
|
"Betterzon": {
|
||||||
"projectType": "application",
|
"projectType": "application",
|
||||||
"schematics": {},
|
"schematics": {},
|
||||||
"root": "",
|
"root": "",
|
||||||
"sourceRoot": "src",
|
"sourceRoot": "src",
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"architect": {
|
"architect": {
|
||||||
"build": {
|
"build": {
|
||||||
"builder": "@angular-devkit/build-angular:browser",
|
"builder": "@angular-devkit/build-angular:browser",
|
||||||
"options": {
|
"options": {
|
||||||
"outputPath": "dist/Betterzon",
|
"outputPath": "dist/Betterzon",
|
||||||
"index": "src/index.html",
|
"index": "src/index.html",
|
||||||
"main": "src/main.ts",
|
"main": "src/main.ts",
|
||||||
"polyfills": "src/polyfills.ts",
|
"polyfills": "src/polyfills.ts",
|
||||||
"tsConfig": "tsconfig.app.json",
|
"tsConfig": "tsconfig.app.json",
|
||||||
"aot": true,
|
"aot": true,
|
||||||
"assets": [
|
"assets": [
|
||||||
"src/favicon.ico",
|
"src/favicon.ico",
|
||||||
"src/assets"
|
"src/assets"
|
||||||
],
|
],
|
||||||
"styles": [
|
"styles": [
|
||||||
"src/styles.css"
|
"src/styles.css",
|
||||||
],
|
"./node_modules/cookieconsent/build/cookieconsent.min.css"
|
||||||
"scripts": []
|
],
|
||||||
},
|
"scripts": [
|
||||||
"configurations": {
|
"./node_modules/cookieconsent/build/cookieconsent.min.js"
|
||||||
"production": {
|
]
|
||||||
"fileReplacements": [
|
},
|
||||||
{
|
"configurations": {
|
||||||
"replace": "src/environments/environment.ts",
|
"production": {
|
||||||
"with": "src/environments/environment.prod.ts"
|
"fileReplacements": [
|
||||||
}
|
{
|
||||||
],
|
"replace": "src/environments/environment.ts",
|
||||||
"optimization": true,
|
"with": "src/environments/environment.prod.ts"
|
||||||
"outputHashing": "all",
|
}
|
||||||
"sourceMap": false,
|
],
|
||||||
"extractCss": true,
|
"optimization": true,
|
||||||
"namedChunks": false,
|
"outputHashing": "all",
|
||||||
"extractLicenses": true,
|
"sourceMap": false,
|
||||||
"vendorChunk": false,
|
"extractCss": true,
|
||||||
"buildOptimizer": true,
|
"namedChunks": false,
|
||||||
"budgets": [
|
"extractLicenses": true,
|
||||||
{
|
"vendorChunk": false,
|
||||||
"type": "initial",
|
"buildOptimizer": true,
|
||||||
"maximumWarning": "2mb",
|
"budgets": [
|
||||||
"maximumError": "5mb"
|
{
|
||||||
|
"type": "initial",
|
||||||
|
"maximumWarning": "2mb",
|
||||||
|
"maximumError": "5mb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "anyComponentStyle",
|
||||||
|
"maximumWarning": "6kb",
|
||||||
|
"maximumError": "10kb"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
"serve": {
|
||||||
"type": "anyComponentStyle",
|
"builder": "@angular-devkit/build-angular:dev-server",
|
||||||
"maximumWarning": "6kb",
|
"options": {
|
||||||
"maximumError": "10kb"
|
"browserTarget": "Betterzon:build"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"browserTarget": "Betterzon:build:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extract-i18n": {
|
||||||
|
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||||
|
"options": {
|
||||||
|
"browserTarget": "Betterzon:build"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test": {
|
||||||
|
"builder": "@angular-devkit/build-angular:karma",
|
||||||
|
"options": {
|
||||||
|
"main": "src/test.ts",
|
||||||
|
"polyfills": "src/polyfills.ts",
|
||||||
|
"tsConfig": "tsconfig.spec.json",
|
||||||
|
"karmaConfig": "karma.conf.js",
|
||||||
|
"assets": [
|
||||||
|
"src/favicon.ico",
|
||||||
|
"src/assets"
|
||||||
|
],
|
||||||
|
"styles": [
|
||||||
|
"src/styles.css",
|
||||||
|
"./node_modules/cookieconsent/build/cookieconsent.min.css"
|
||||||
|
],
|
||||||
|
"scripts": [
|
||||||
|
"./node_modules/cookieconsent/build/cookieconsent.min.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lint": {
|
||||||
|
"builder": "@angular-devkit/build-angular:tslint",
|
||||||
|
"options": {
|
||||||
|
"tsConfig": [
|
||||||
|
"tsconfig.app.json",
|
||||||
|
"tsconfig.spec.json",
|
||||||
|
"e2e/tsconfig.json"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"e2e": {
|
||||||
|
"builder": "@angular-devkit/build-angular:protractor",
|
||||||
|
"options": {
|
||||||
|
"protractorConfig": "e2e/protractor.conf.js",
|
||||||
|
"devServerTarget": "Betterzon:serve"
|
||||||
|
},
|
||||||
|
"configurations": {
|
||||||
|
"production": {
|
||||||
|
"devServerTarget": "Betterzon:serve:production"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
"serve": {
|
|
||||||
"builder": "@angular-devkit/build-angular:dev-server",
|
|
||||||
"options": {
|
|
||||||
"browserTarget": "Betterzon:build"
|
|
||||||
},
|
|
||||||
"configurations": {
|
|
||||||
"production": {
|
|
||||||
"browserTarget": "Betterzon:build:production"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"extract-i18n": {
|
|
||||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
|
||||||
"options": {
|
|
||||||
"browserTarget": "Betterzon:build"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test": {
|
|
||||||
"builder": "@angular-devkit/build-angular:karma",
|
|
||||||
"options": {
|
|
||||||
"main": "src/test.ts",
|
|
||||||
"polyfills": "src/polyfills.ts",
|
|
||||||
"tsConfig": "tsconfig.spec.json",
|
|
||||||
"karmaConfig": "karma.conf.js",
|
|
||||||
"assets": [
|
|
||||||
"src/favicon.ico",
|
|
||||||
"src/assets"
|
|
||||||
],
|
|
||||||
"styles": [
|
|
||||||
"src/styles.css"
|
|
||||||
],
|
|
||||||
"scripts": []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint": {
|
|
||||||
"builder": "@angular-devkit/build-angular:tslint",
|
|
||||||
"options": {
|
|
||||||
"tsConfig": [
|
|
||||||
"tsconfig.app.json",
|
|
||||||
"tsconfig.spec.json",
|
|
||||||
"e2e/tsconfig.json"
|
|
||||||
],
|
|
||||||
"exclude": [
|
|
||||||
"**/node_modules/**"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"e2e": {
|
|
||||||
"builder": "@angular-devkit/build-angular:protractor",
|
|
||||||
"options": {
|
|
||||||
"protractorConfig": "e2e/protractor.conf.js",
|
|
||||||
"devServerTarget": "Betterzon:serve"
|
|
||||||
},
|
|
||||||
"configurations": {
|
|
||||||
"production": {
|
|
||||||
"devServerTarget": "Betterzon:serve:production"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}},
|
"defaultProject": "Betterzon"
|
||||||
"defaultProject": "Betterzon"
|
|
||||||
}
|
}
|
||||||
|
|
43794
Frontend/package-lock.json
generated
43794
Frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -21,8 +21,10 @@
|
||||||
"@angular/platform-browser-dynamic": "^10.2.3",
|
"@angular/platform-browser-dynamic": "^10.2.3",
|
||||||
"@angular/router": "^10.2.3",
|
"@angular/router": "^10.2.3",
|
||||||
"apexcharts": "^3.22.3",
|
"apexcharts": "^3.22.3",
|
||||||
|
"cookieconsent": "^3.1.1",
|
||||||
"ng": "0.0.0",
|
"ng": "0.0.0",
|
||||||
"ng-apexcharts": "^1.5.6",
|
"ng-apexcharts": "^1.5.6",
|
||||||
|
"ngx-cookieconsent": "^2.2.3",
|
||||||
"rxjs": "~6.6.0",
|
"rxjs": "~6.6.0",
|
||||||
"tslib": "^2.0.3",
|
"tslib": "^2.0.3",
|
||||||
"zone.js": "~0.10.2"
|
"zone.js": "~0.10.2"
|
||||||
|
|
|
@ -1,10 +1,69 @@
|
||||||
import { Component } from '@angular/core';
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||||
|
import {NgcCookieConsentService, NgcInitializeEvent, NgcNoCookieLawEvent, NgcStatusChangeEvent} from 'ngx-cookieconsent';
|
||||||
|
import {Subscription} from 'rxjs';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
styleUrls: ['./app.component.css']
|
styleUrls: ['./app.component.css']
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent implements OnInit, OnDestroy {
|
||||||
title = 'Betterzon';
|
title = 'Betterzon';
|
||||||
|
|
||||||
|
// Cookie popup stuff
|
||||||
|
// Docs on https://www.npmjs.com/package/ngx-cookieconsent
|
||||||
|
private popupOpenSubscription: Subscription;
|
||||||
|
private popupCloseSubscription: Subscription;
|
||||||
|
private initializeSubscription: Subscription;
|
||||||
|
private statusChangeSubscription: Subscription;
|
||||||
|
private revokeChoiceSubscription: Subscription;
|
||||||
|
private noCookieLawSubscription: Subscription;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private ccService: NgcCookieConsentService
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
// subscribe to cookieconsent observables to react to main events
|
||||||
|
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(
|
||||||
|
() => {
|
||||||
|
// you can use this.ccService.getConfig() to do stuff...
|
||||||
|
});
|
||||||
|
|
||||||
|
this.popupCloseSubscription = this.ccService.popupClose$.subscribe(
|
||||||
|
() => {
|
||||||
|
// you can use this.ccService.getConfig() to do stuff...
|
||||||
|
});
|
||||||
|
|
||||||
|
this.initializeSubscription = this.ccService.initialize$.subscribe(
|
||||||
|
(event: NgcInitializeEvent) => {
|
||||||
|
// you can use this.ccService.getConfig() to do stuff...
|
||||||
|
});
|
||||||
|
|
||||||
|
this.statusChangeSubscription = this.ccService.statusChange$.subscribe(
|
||||||
|
(event: NgcStatusChangeEvent) => {
|
||||||
|
// you can use this.ccService.getConfig() to do stuff...
|
||||||
|
});
|
||||||
|
|
||||||
|
this.revokeChoiceSubscription = this.ccService.revokeChoice$.subscribe(
|
||||||
|
() => {
|
||||||
|
// you can use this.ccService.getConfig() to do stuff...
|
||||||
|
});
|
||||||
|
|
||||||
|
this.noCookieLawSubscription = this.ccService.noCookieLaw$.subscribe(
|
||||||
|
(event: NgcNoCookieLawEvent) => {
|
||||||
|
// you can use this.ccService.getConfig() to do stuff...
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
// unsubscribe to cookieconsent observables to prevent memory leaks
|
||||||
|
this.popupOpenSubscription.unsubscribe();
|
||||||
|
this.popupCloseSubscription.unsubscribe();
|
||||||
|
this.initializeSubscription.unsubscribe();
|
||||||
|
this.statusChangeSubscription.unsubscribe();
|
||||||
|
this.revokeChoiceSubscription.unsubscribe();
|
||||||
|
this.noCookieLawSubscription.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,48 @@ import {HeaderComponent} from './components/header/header.component';
|
||||||
import {NewestPricesListComponent} from './components/newest-prices-list/newest-prices-list.component';
|
import {NewestPricesListComponent} from './components/newest-prices-list/newest-prices-list.component';
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {PageNotFoundPageComponent} from './pages/page-not-found-page/page-not-found-page.component';
|
import {PageNotFoundPageComponent} from './pages/page-not-found-page/page-not-found-page.component';
|
||||||
import { ImprintComponent } from './pages/imprint/imprint.component';
|
import {ImprintComponent} from './pages/imprint/imprint.component';
|
||||||
import { PrivacyComponent } from './pages/privacy/privacy.component';
|
import {PrivacyComponent} from './pages/privacy/privacy.component';
|
||||||
|
import {NgcCookieConsentModule, NgcCookieConsentConfig} from 'ngx-cookieconsent';
|
||||||
|
|
||||||
|
// For cookie popup
|
||||||
|
const cookieConfig: NgcCookieConsentConfig = {
|
||||||
|
cookie: {
|
||||||
|
domain: 'betterzon.xyz'
|
||||||
|
},
|
||||||
|
palette: {
|
||||||
|
popup: {
|
||||||
|
background: '#000'
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
background: '#f1d600'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
theme: 'edgeless',
|
||||||
|
type: 'opt-out',
|
||||||
|
layout: 'my-custom-layout',
|
||||||
|
layouts: {
|
||||||
|
'my-custom-layout': '{{messagelink}}{{compliance}}'
|
||||||
|
},
|
||||||
|
elements: {
|
||||||
|
messagelink: `
|
||||||
|
<span id="cookieconsent:desc" class="cc-message">{{message}}
|
||||||
|
<a aria-label="learn more about cookies" tabindex="0" class="cc-link" href="{{whatAreCookiesHref}}" target="_blank">{{whatAreCookiesLink}}</a>
|
||||||
|
<a aria-label="learn more about our privacy policy" tabindex="1" class="cc-link" href="{{privacyPolicyHref}}" target="_blank">{{privacyPolicyLink}}</a>
|
||||||
|
</span>
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
content: {
|
||||||
|
// Custom message
|
||||||
|
//message: 'By using our site, you acknowledge that you have read and understand our ',
|
||||||
|
|
||||||
|
whatAreCookiesLink: 'Learn more',
|
||||||
|
whatAreCookiesHref: 'https://www.cookiesandyou.com/',
|
||||||
|
|
||||||
|
privacyPolicyLink: 'Privacy Policy',
|
||||||
|
privacyPolicyHref: '/datenschutz',
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
@ -38,7 +78,8 @@ import { PrivacyComponent } from './pages/privacy/privacy.component';
|
||||||
AppRouting,
|
AppRouting,
|
||||||
HttpClientModule,
|
HttpClientModule,
|
||||||
NgApexchartsModule,
|
NgApexchartsModule,
|
||||||
FormsModule
|
FormsModule,
|
||||||
|
NgcCookieConsentModule.forRoot(cookieConfig)
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Betterzon</title>
|
<title>Betterzon</title>
|
||||||
<base href="/">
|
<base href="/">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||||
</head>
|
<link rel="stylesheet" type="text/css" href="node_modules/cookieconsent/build/cookieconsent.min.css"/>
|
||||||
<body>
|
<script src="node_modules/cookieconsent/build/cookieconsent.min.js"></script>
|
||||||
<app-root></app-root>
|
</head>
|
||||||
</body>
|
<body>
|
||||||
|
<app-root></app-root>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user