From 8d18d42b3220bb89fbe550f0ba3e3d72e2554d0a Mon Sep 17 00:00:00 2001 From: Gr1ll Date: Tue, 13 Aug 2024 04:44:55 +0530 Subject: [PATCH 1/3] feat: add cookie disclaimer --- apps/frontend/src/app/app.component.html | 1 + apps/frontend/src/app/app.component.ts | 3 +- apps/frontend/src/app/app.routes.ts | 5 ++ .../disclaimer/disclaimer.component.css | 0 .../disclaimer/disclaimer.component.html | 25 ++++++++ .../disclaimer/disclaimer.component.spec.ts | 22 +++++++ .../cookie/disclaimer/disclaimer.component.ts | 21 +++++++ .../shared/cookie/policy/policy.component.css | 0 .../cookie/policy/policy.component.html | 60 +++++++++++++++++++ .../cookie/policy/policy.component.spec.ts | 22 +++++++ .../shared/cookie/policy/policy.component.ts | 10 ++++ 11 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.css create mode 100644 apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html create mode 100644 apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.spec.ts create mode 100644 apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.ts create mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.css create mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.html create mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts create mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.ts diff --git a/apps/frontend/src/app/app.component.html b/apps/frontend/src/app/app.component.html index 40c1f0a..f4e3756 100644 --- a/apps/frontend/src/app/app.component.html +++ b/apps/frontend/src/app/app.component.html @@ -1,3 +1,4 @@
+ diff --git a/apps/frontend/src/app/app.component.ts b/apps/frontend/src/app/app.component.ts index 286cc41..b5cc696 100644 --- a/apps/frontend/src/app/app.component.ts +++ b/apps/frontend/src/app/app.component.ts @@ -1,10 +1,11 @@ import { Component } from '@angular/core' import { RouterModule } from '@angular/router' import { NavbarComponent } from './shared/navigation/navbar/navbar.component' +import { DisclaimerComponent } from './shared/cookie/disclaimer/disclaimer.component' @Component({ standalone: true, - imports: [RouterModule, NavbarComponent], + imports: [RouterModule, NavbarComponent, DisclaimerComponent], selector: 'app-root', templateUrl: './app.component.html', styleUrl: './app.component.scss', diff --git a/apps/frontend/src/app/app.routes.ts b/apps/frontend/src/app/app.routes.ts index 9923396..099b860 100644 --- a/apps/frontend/src/app/app.routes.ts +++ b/apps/frontend/src/app/app.routes.ts @@ -9,6 +9,7 @@ import { AuthGuard } from './guards/auth.guard' import { NotAuthGuard } from './guards/not-auth.guard' import { UnsavedChangesGuard } from './guards/unsaved-changes.guard' import { ResultsComponent } from './features/voting/results/results.component' +import { PolicyComponent } from './shared/cookie/policy/policy.component' export const appRoutes: Route[] = [ { @@ -53,6 +54,10 @@ export const appRoutes: Route[] = [ }, ], }, + { + path: 'cookie-policy', + component: PolicyComponent, + }, { path: '**', redirectTo: '/', diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.css b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.css new file mode 100644 index 0000000..e69de29 diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html new file mode 100644 index 0000000..a9a4678 --- /dev/null +++ b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html @@ -0,0 +1,25 @@ +@if (!hasAcceptedCookies()){ +
+
+

+ This website uses cookies to make sure you can stay logged in and dont + have to re-enter your login credentials every time you open the website. + See our + cookie policy. +

+
+ +
+
+
+} diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.spec.ts b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.spec.ts new file mode 100644 index 0000000..a21a51e --- /dev/null +++ b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing' + +import { DisclaimerComponent } from './disclaimer.component' + +describe('DisclaimerComponent', () => { + let component: DisclaimerComponent + let fixture: ComponentFixture + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [DisclaimerComponent], + }).compileComponents() + + fixture = TestBed.createComponent(DisclaimerComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.ts b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.ts new file mode 100644 index 0000000..c156f00 --- /dev/null +++ b/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.ts @@ -0,0 +1,21 @@ +import { Component } from '@angular/core' +import { CookieService } from 'ngx-cookie-service' +import { RouterLink } from '@angular/router' + +@Component({ + selector: 'app-disclaimer', + standalone: true, + imports: [RouterLink], + templateUrl: './disclaimer.component.html', + styleUrl: './disclaimer.component.css', +}) +export class DisclaimerComponent { + constructor(private cookieService: CookieService) {} + acceptCookies() { + this.cookieService.set('disclaimer', 'accepted', 365) + } + + hasAcceptedCookies() { + return this.cookieService.check('disclaimer') + } +} diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.css b/apps/frontend/src/app/shared/cookie/policy/policy.component.css new file mode 100644 index 0000000..e69de29 diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.html b/apps/frontend/src/app/shared/cookie/policy/policy.component.html new file mode 100644 index 0000000..75da028 --- /dev/null +++ b/apps/frontend/src/app/shared/cookie/policy/policy.component.html @@ -0,0 +1,60 @@ +
+

Cookie Policy

+ +

+ This Cookie Policy explains how we use cookies and similar technologies to + recognize you when you visit our website. It explains what these + technologies are and why we use them, as well as your rights to control our + use of them. +

+ +

What Are Cookies?

+

+ Cookies are small data files that are placed on your computer or mobile + device when you visit a website. Cookies are widely used by website owners + to make their websites work, or to work more efficiently, as well as to + provide reporting information. +

+ +

How We Use Cookies

+

We use cookies for the following purposes:

+
    +
  • + Session Cookies: We use session cookies to store a + private and public key that allows us to maintain your session while you + navigate our website. These cookies are essential for the website to + function properly and are automatically deleted when you close your + browser. +
  • +
  • + Cookie Consent: We use a cookie to remember whether you + have accepted our use of cookies. This ensures that we do not show you the + cookie consent banner repeatedly once you have made your choice. +
  • +
+ +

Managing Cookies

+

+ By using our website, you must accept the use of cookies. If you do not + accept cookies, you will not be able to use our website, as they are + essential for the website's functionality. +

+ +

+ Changes to This Cookie Policy +

+

+ We may update this Cookie Policy from time to time in order to reflect + changes to the cookies we use or for other operational, legal, or regulatory + reasons. Please revisit this Cookie Policy regularly to stay informed about + our use of cookies and related technologies. +

+ +

Contact Us

+

+ If you have any questions or concerns about our use of cookies or other + technologies, please feel free to reach out to us via our github repository. +

+
diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts b/apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts new file mode 100644 index 0000000..893dce0 --- /dev/null +++ b/apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts @@ -0,0 +1,22 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing' + +import { PolicyComponent } from './policy.component' + +describe('PolicyComponent', () => { + let component: PolicyComponent + let fixture: ComponentFixture + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [PolicyComponent], + }).compileComponents() + + fixture = TestBed.createComponent(PolicyComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) + + it('should create', () => { + expect(component).toBeTruthy() + }) +}) diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.ts b/apps/frontend/src/app/shared/cookie/policy/policy.component.ts new file mode 100644 index 0000000..4d17e16 --- /dev/null +++ b/apps/frontend/src/app/shared/cookie/policy/policy.component.ts @@ -0,0 +1,10 @@ +import { Component } from '@angular/core' + +@Component({ + selector: 'app-policy', + standalone: true, + imports: [], + templateUrl: './policy.component.html', + styleUrl: './policy.component.css', +}) +export class PolicyComponent {} From 56f5a6fe886c432c42b8bef07216d44404cba9a3 Mon Sep 17 00:00:00 2001 From: Gr1ll Date: Tue, 13 Aug 2024 14:25:10 +0530 Subject: [PATCH 2/3] fix: fix mistakes in cookie disclaimer. --- .../src/app/features/home/home.component.spec.ts | 11 ++++++++++- .../app/shared/cookie/policy/policy.component.html | 12 ++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/apps/frontend/src/app/features/home/home.component.spec.ts b/apps/frontend/src/app/features/home/home.component.spec.ts index 32eefa3..db8b64c 100644 --- a/apps/frontend/src/app/features/home/home.component.spec.ts +++ b/apps/frontend/src/app/features/home/home.component.spec.ts @@ -1,5 +1,6 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' +import { ComponentFixture, inject, TestBed } from '@angular/core/testing' import { HomeComponent } from './home.component' +import { Router } from '@angular/router' describe('HomeComponent', () => { let component: HomeComponent @@ -18,4 +19,12 @@ describe('HomeComponent', () => { it('should create', () => { expect(component).toBeTruthy() }) + + test('should search vote', inject([Router], (mockRouter: Router) => { + const spyRouter = spyOn(mockRouter, 'navigate').and.stub() + + component.voteId.setValue('123') + component.searchVote() + expect(spyRouter.calls.first().args[0]).toContain('voting' && '123') + })) }) diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.html b/apps/frontend/src/app/shared/cookie/policy/policy.component.html index 75da028..fff32e7 100644 --- a/apps/frontend/src/app/shared/cookie/policy/policy.component.html +++ b/apps/frontend/src/app/shared/cookie/policy/policy.component.html @@ -25,13 +25,14 @@

How We Use Cookies

Session Cookies: We use session cookies to store a private and public key that allows us to maintain your session while you navigate our website. These cookies are essential for the website to - function properly and are automatically deleted when you close your - browser. + function properly.
  • Cookie Consent: We use a cookie to remember whether you have accepted our use of cookies. This ensures that we do not show you the - cookie consent banner repeatedly once you have made your choice. + cookie consent banner repeatedly once you have made your choice. We do NOT + share the cookies with 3th party websites. All cookies are only saved and + processed on your device!
  • @@ -55,6 +56,9 @@

    Contact Us

    If you have any questions or concerns about our use of cookies or other - technologies, please feel free to reach out to us via our github repository. + technologies, please feel free to reach out to us via our + github repository

    From 679616ad91dc5848859ce0db76b8bf3ac6987a9a Mon Sep 17 00:00:00 2001 From: Daniel Jancar Date: Tue, 13 Aug 2024 19:18:50 +0200 Subject: [PATCH 3/3] fix: improve cookie banner grammar --- apps/frontend/src/app/app.component.ts | 2 +- apps/frontend/src/app/app.routes.ts | 5 -- .../shared/cookie/policy/policy.component.css | 0 .../cookie/policy/policy.component.html | 64 ------------------- .../cookie/policy/policy.component.spec.ts | 22 ------- .../shared/cookie/policy/policy.component.ts | 10 --- .../disclaimer/disclaimer.component.css | 0 .../disclaimer/disclaimer.component.html | 13 ++-- .../disclaimer/disclaimer.component.spec.ts | 0 .../disclaimer/disclaimer.component.ts | 0 package-lock.json | 10 +-- 11 files changed, 11 insertions(+), 115 deletions(-) delete mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.css delete mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.html delete mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts delete mode 100644 apps/frontend/src/app/shared/cookie/policy/policy.component.ts rename apps/frontend/src/app/shared/{cookie => navigation}/disclaimer/disclaimer.component.css (100%) rename apps/frontend/src/app/shared/{cookie => navigation}/disclaimer/disclaimer.component.html (65%) rename apps/frontend/src/app/shared/{cookie => navigation}/disclaimer/disclaimer.component.spec.ts (100%) rename apps/frontend/src/app/shared/{cookie => navigation}/disclaimer/disclaimer.component.ts (100%) diff --git a/apps/frontend/src/app/app.component.ts b/apps/frontend/src/app/app.component.ts index b5cc696..2b657ba 100644 --- a/apps/frontend/src/app/app.component.ts +++ b/apps/frontend/src/app/app.component.ts @@ -1,7 +1,7 @@ import { Component } from '@angular/core' import { RouterModule } from '@angular/router' import { NavbarComponent } from './shared/navigation/navbar/navbar.component' -import { DisclaimerComponent } from './shared/cookie/disclaimer/disclaimer.component' +import { DisclaimerComponent } from './shared/navigation/disclaimer/disclaimer.component' @Component({ standalone: true, diff --git a/apps/frontend/src/app/app.routes.ts b/apps/frontend/src/app/app.routes.ts index 099b860..9923396 100644 --- a/apps/frontend/src/app/app.routes.ts +++ b/apps/frontend/src/app/app.routes.ts @@ -9,7 +9,6 @@ import { AuthGuard } from './guards/auth.guard' import { NotAuthGuard } from './guards/not-auth.guard' import { UnsavedChangesGuard } from './guards/unsaved-changes.guard' import { ResultsComponent } from './features/voting/results/results.component' -import { PolicyComponent } from './shared/cookie/policy/policy.component' export const appRoutes: Route[] = [ { @@ -54,10 +53,6 @@ export const appRoutes: Route[] = [ }, ], }, - { - path: 'cookie-policy', - component: PolicyComponent, - }, { path: '**', redirectTo: '/', diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.css b/apps/frontend/src/app/shared/cookie/policy/policy.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.html b/apps/frontend/src/app/shared/cookie/policy/policy.component.html deleted file mode 100644 index fff32e7..0000000 --- a/apps/frontend/src/app/shared/cookie/policy/policy.component.html +++ /dev/null @@ -1,64 +0,0 @@ -
    -

    Cookie Policy

    - -

    - This Cookie Policy explains how we use cookies and similar technologies to - recognize you when you visit our website. It explains what these - technologies are and why we use them, as well as your rights to control our - use of them. -

    - -

    What Are Cookies?

    -

    - Cookies are small data files that are placed on your computer or mobile - device when you visit a website. Cookies are widely used by website owners - to make their websites work, or to work more efficiently, as well as to - provide reporting information. -

    - -

    How We Use Cookies

    -

    We use cookies for the following purposes:

    -
      -
    • - Session Cookies: We use session cookies to store a - private and public key that allows us to maintain your session while you - navigate our website. These cookies are essential for the website to - function properly. -
    • -
    • - Cookie Consent: We use a cookie to remember whether you - have accepted our use of cookies. This ensures that we do not show you the - cookie consent banner repeatedly once you have made your choice. We do NOT - share the cookies with 3th party websites. All cookies are only saved and - processed on your device! -
    • -
    - -

    Managing Cookies

    -

    - By using our website, you must accept the use of cookies. If you do not - accept cookies, you will not be able to use our website, as they are - essential for the website's functionality. -

    - -

    - Changes to This Cookie Policy -

    -

    - We may update this Cookie Policy from time to time in order to reflect - changes to the cookies we use or for other operational, legal, or regulatory - reasons. Please revisit this Cookie Policy regularly to stay informed about - our use of cookies and related technologies. -

    - -

    Contact Us

    -

    - If you have any questions or concerns about our use of cookies or other - technologies, please feel free to reach out to us via our - github repository -

    -
    diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts b/apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts deleted file mode 100644 index 893dce0..0000000 --- a/apps/frontend/src/app/shared/cookie/policy/policy.component.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' - -import { PolicyComponent } from './policy.component' - -describe('PolicyComponent', () => { - let component: PolicyComponent - let fixture: ComponentFixture - - beforeEach(async () => { - await TestBed.configureTestingModule({ - imports: [PolicyComponent], - }).compileComponents() - - fixture = TestBed.createComponent(PolicyComponent) - component = fixture.componentInstance - fixture.detectChanges() - }) - - it('should create', () => { - expect(component).toBeTruthy() - }) -}) diff --git a/apps/frontend/src/app/shared/cookie/policy/policy.component.ts b/apps/frontend/src/app/shared/cookie/policy/policy.component.ts deleted file mode 100644 index 4d17e16..0000000 --- a/apps/frontend/src/app/shared/cookie/policy/policy.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core' - -@Component({ - selector: 'app-policy', - standalone: true, - imports: [], - templateUrl: './policy.component.html', - styleUrl: './policy.component.css', -}) -export class PolicyComponent {} diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.css b/apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.css similarity index 100% rename from apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.css rename to apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.css diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html b/apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.html similarity index 65% rename from apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html rename to apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.html index a9a4678..86c105c 100644 --- a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.html +++ b/apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.html @@ -1,15 +1,12 @@ -@if (!hasAcceptedCookies()){ +@if (!hasAcceptedCookies()) {

    - This website uses cookies to make sure you can stay logged in and dont - have to re-enter your login credentials every time you open the website. - See our - cookie policy. + We use cookies to enhance your experience. Any data, such as your wallet + address, is only shared between you and the Stellar Network. By using our + site, you consent to this.

    diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.spec.ts b/apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.spec.ts similarity index 100% rename from apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.spec.ts rename to apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.spec.ts diff --git a/apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.ts b/apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.ts similarity index 100% rename from apps/frontend/src/app/shared/cookie/disclaimer/disclaimer.component.ts rename to apps/frontend/src/app/shared/navigation/disclaimer/disclaimer.component.ts diff --git a/package-lock.json b/package-lock.json index b91e462..374b0a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@votevault/source", - "version": "0.0.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@votevault/source", - "version": "0.0.0", + "version": "1.0.0", "license": "MIT", "dependencies": { "@angular/animations": "~18.1.0", @@ -13585,9 +13585,9 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", - "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz", + "integrity": "sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw==", "license": "MIT", "dependencies": { "follow-redirects": "^1.15.6",