Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Added cookie consent #316

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@
"src/styles/base.scss",
"./node_modules/froala-editor/css/froala_editor.pkgd.min.css",
"./node_modules/froala-editor/css/froala_style.min.css",
"./node_modules/ng-pick-datetime/assets/style/picker.min.css"
"./node_modules/ng-pick-datetime/assets/style/picker.min.css",
"./node_modules/cookieconsent/build/cookieconsent.min.css"
],
"scripts": [
"./node_modules/froala-editor/js/froala_editor.pkgd.min.js"
"./node_modules/froala-editor/js/froala_editor.pkgd.min.js",
"./node_modules/cookieconsent/build/cookieconsent.min.js"
]
},
"configurations": {
Expand Down
6 changes: 5 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ module.exports = function (config) {
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
files: [
'./node_modules/cookieconsent/build/cookieconsent.min.js', // loading cookie service
'./node_modules/cookieconsent/build/cookieconsent.min.css' // cookie styles
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},

reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
"@angular/router": "^7.2.15",
"@types/moment-timezone": "^0.5.12",
"angular-froala-wysiwyg": "^3.0.0-rc.2-1",
"cookieconsent": "^3.1.1",
"core-js": "^2.4.1",
"materialize-css": "^0.97.8",
"hammerjs": "^2.0.8",
"materialize-css": "^0.97.8",
"moment": "^2.24.0",
"ng-pick-datetime": "^7.0.0",
"ngx-cookieconsent": "^2.2.3",
"ngx-textarea-autosize": "^2.0.3",
"ngx-twitter-timeline": "^0.1.5",
"normalize.css": "^8.0.0",
Expand Down
10 changes: 9 additions & 1 deletion src/app/app.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import { LoadingComponent } from './components/utility/loading/loading.component
import { ConfirmComponent } from './components/utility/confirm/confirm.component';
import { ModalComponent } from './components/utility/modal/modal.component';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { NgcCookieConsentConfig, NgcCookieConsentModule } from 'ngx-cookieconsent';

const cookieConfig: NgcCookieConsentConfig = {
cookie: {
domain: 'localhost' // or 'your.domain.com'
}
};

describe('AppComponent', () => {

Expand All @@ -38,7 +45,8 @@ describe('AppComponent', () => {
],
imports: [
RouterTestingModule,
HttpClientModule
HttpClientModule,
NgcCookieConsentModule.forRoot(cookieConfig)
],
providers: [
GlobalService,
Expand Down
6 changes: 4 additions & 2 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { DOCUMENT } from '@angular/common';
import { Title } from '@angular/platform-browser';


// service for initializing cookie
import { NgcCookieConsentService } from 'ngx-cookieconsent';


@Component({
Expand Down Expand Up @@ -46,7 +47,8 @@ export class AppComponent implements OnInit, OnDestroy {
public activatedRoute: ActivatedRoute,
public titleService: Title,
private globalService: GlobalService,
private authService: AuthService
private authService: AuthService,
private ccService: NgcCookieConsentService
) {
}

Expand Down
19 changes: 19 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { FroalaEditorModule, FroalaViewModule } from 'angular-froala-wysiwyg';
import { NgcCookieConsentModule, NgcCookieConsentConfig } from 'ngx-cookieconsent';

// Import services
import { WindowService } from './services/window.service';
Expand All @@ -24,6 +25,23 @@ import { TermsAndConditionsModalComponent } from './components/challenge/challen
// import module
import { SharedModule } from './shared/shared.module';

// configuration of cookie consent
const cookieConfig: NgcCookieConsentConfig = {
cookie: {
domain: 'localhost' // or 'your.domain.com' // it is mandatory to set a domain, for cookies to work properly (see https://goo.gl/S2Hy2A)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will be the domain when it is in production or staging environment? At that time how will we configure it? Can it pick the domain without setting it - can you explore about it ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shekharrajak we just need to change the domain in here for the production mode and in it's doc, i couldn't find any feature of automatic domain detection.So will have to change it manually at the time of production.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to make it environment variable then.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for suggestion @Shekharrajak . I have made the suggested changes. Can you please now check if this looks good to you?

},
palette: {
popup: {
background: '#000'
},
button: {
background: '#f1d600'
}
},
theme: 'edgeless',
type: 'opt-out'
};

@NgModule({
declarations: [
AppComponent,
Expand All @@ -40,6 +58,7 @@ import { SharedModule } from './shared/shared.module';
HttpClientModule,
FroalaEditorModule.forRoot(),
FroalaViewModule.forRoot(),
NgcCookieConsentModule.forRoot(cookieConfig)
],
providers: [
WindowService,
Expand Down