From 7688d963f45f584e922efb6d7b7d078c7227fe16 Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 10:15:26 +0200 Subject: [PATCH 01/22] feat: CookieComponent --- package-lock.json | 13 +++++++++++ package.json | 1 + src/app/cookie/cookie.component.html | 6 +++++ src/app/cookie/cookie.component.scss | 4 ++++ src/app/cookie/cookie.component.spec.ts | 23 ++++++++++++++++++ src/app/cookie/cookie.component.ts | 31 +++++++++++++++++++++++++ 6 files changed, 78 insertions(+) create mode 100644 src/app/cookie/cookie.component.html create mode 100644 src/app/cookie/cookie.component.scss create mode 100644 src/app/cookie/cookie.component.spec.ts create mode 100644 src/app/cookie/cookie.component.ts diff --git a/package-lock.json b/package-lock.json index 7294e41..009191b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@angular/platform-browser": "^17.3.0", "@angular/platform-browser-dynamic": "^17.3.0", "@angular/router": "^17.3.0", + "ngx-cookie-service": "^17.1.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.14.3" @@ -8564,6 +8565,18 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, + "node_modules/ngx-cookie-service": { + "version": "17.1.0", + "resolved": "https://registry.npmjs.org/ngx-cookie-service/-/ngx-cookie-service-17.1.0.tgz", + "integrity": "sha512-m4YI9IEgTaEBDMCz7oeVsO6UX14EmCzg29cTL6yxW8f7oye9wv56egi+3C4wAVSRPkI+cWlqnIOr+XyHwYQYmg==", + "dependencies": { + "tslib": "^2.6.2" + }, + "peerDependencies": { + "@angular/common": "^17.0.0", + "@angular/core": "^17.0.0" + } + }, "node_modules/nice-napi": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/nice-napi/-/nice-napi-1.0.2.tgz", diff --git a/package.json b/package.json index c4f7e1e..6b57e3c 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@angular/platform-browser": "^17.3.0", "@angular/platform-browser-dynamic": "^17.3.0", "@angular/router": "^17.3.0", + "ngx-cookie-service": "^17.1.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.14.3" diff --git a/src/app/cookie/cookie.component.html b/src/app/cookie/cookie.component.html new file mode 100644 index 0000000..039d5a2 --- /dev/null +++ b/src/app/cookie/cookie.component.html @@ -0,0 +1,6 @@ +

Do you Consent to Cookies, well, doesn't matter, it saves nothing yet

+
+ Here are your Cookies: +
{{getCookies()}}
+ +
diff --git a/src/app/cookie/cookie.component.scss b/src/app/cookie/cookie.component.scss new file mode 100644 index 0000000..b0de7fb --- /dev/null +++ b/src/app/cookie/cookie.component.scss @@ -0,0 +1,4 @@ +.text-wrapper{ + font-family: Bahnschrift, sans-serif; + margin: 10px; +} diff --git a/src/app/cookie/cookie.component.spec.ts b/src/app/cookie/cookie.component.spec.ts new file mode 100644 index 0000000..09c8594 --- /dev/null +++ b/src/app/cookie/cookie.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { CookieComponent } from './cookie.component'; + +describe('CookieComponent', () => { + let component: CookieComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + imports: [CookieComponent] + }) + .compileComponents(); + + fixture = TestBed.createComponent(CookieComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/cookie/cookie.component.ts b/src/app/cookie/cookie.component.ts new file mode 100644 index 0000000..8787c63 --- /dev/null +++ b/src/app/cookie/cookie.component.ts @@ -0,0 +1,31 @@ +import {Component} from '@angular/core'; +import {CookieService} from "ngx-cookie-service"; +import {NgForOf} from "@angular/common"; + +@Component({ + selector: 'app-cookie', + standalone: true, + imports: [ + NgForOf + ], + templateUrl: './cookie.component.html', + styleUrl: './cookie.component.scss' +}) +export class CookieComponent { + private isConsented: boolean = false; + + // TODO: Do I need a Dependency for CookieService? Uhhhh + constructor(private cookieService: CookieService) { + this.cookieService.set('MainCookie', 'This is your Cookie, no one else!') + this.cookieService.set('SecondCookie', "Well, this is your second Chocolate Cookie") + } + + setCookie(name: string) { + this.cookieService.set('MainCookie', 'This is your Cookie, no one else!') + } + + getCookies() { + const allCookies = this.cookieService.getAll() + return JSON.stringify(allCookies) + } +} From 8e790f3cca3ca8eb17f23e7abcc0474c1e33001d Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 10:15:39 +0200 Subject: [PATCH 02/22] ci: Here are your cookies --- src/app/app.component.html | 1 + src/app/app.routes.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/app/app.component.html b/src/app/app.component.html index 82e9690..63b6701 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -8,5 +8,6 @@

+ diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 23c4e78..5755f85 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -2,6 +2,7 @@ import { Routes } from '@angular/router'; import {MainPortalComponent} from "./main-portal/main-portal.component"; import {LogInPageComponent} from "./log-in-page/log-in-page.component"; import {AuthGuard} from "./app.guard"; +import {CookieComponent} from "./cookie/cookie.component"; export const routes: Routes = [ { @@ -12,5 +13,9 @@ export const routes: Routes = [ { path: "LogIn", component: LogInPageComponent + }, + { + path: "Cookies", + component: CookieComponent } ]; From b4e2a698177f99a8fd8dd7bba056ecc278197293 Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 10:18:53 +0200 Subject: [PATCH 03/22] ci: unused cookieMethod --- src/app/cookie/cookie.component.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/app/cookie/cookie.component.ts b/src/app/cookie/cookie.component.ts index 8787c63..995192b 100644 --- a/src/app/cookie/cookie.component.ts +++ b/src/app/cookie/cookie.component.ts @@ -12,7 +12,6 @@ import {NgForOf} from "@angular/common"; styleUrl: './cookie.component.scss' }) export class CookieComponent { - private isConsented: boolean = false; // TODO: Do I need a Dependency for CookieService? Uhhhh constructor(private cookieService: CookieService) { @@ -20,10 +19,6 @@ export class CookieComponent { this.cookieService.set('SecondCookie', "Well, this is your second Chocolate Cookie") } - setCookie(name: string) { - this.cookieService.set('MainCookie', 'This is your Cookie, no one else!') - } - getCookies() { const allCookies = this.cookieService.getAll() return JSON.stringify(allCookies) From 8bb54190b4f3b69dd791148e21423262ceeb86cd Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 10:37:50 +0200 Subject: [PATCH 04/22] ci: implement redundant login --- src/app/shared/config.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/shared/config.service.ts b/src/app/shared/config.service.ts index 1b2614d..86fdb97 100644 --- a/src/app/shared/config.service.ts +++ b/src/app/shared/config.service.ts @@ -1,13 +1,16 @@ import {Injectable} from '@angular/core'; import {Router} from "@angular/router"; +import {CookieService} from "ngx-cookie-service"; @Injectable({ providedIn: 'root' }) export class ConfigService { - constructor(private router: Router) { + constructor(private router: Router, + private cookieService: CookieService) { } // TODO: Own Service for localStorage + // TODO: Please dont save Account in localStorage AND Cookies, wat de hell login(username: string, password: string){ const userData = { username: username, @@ -15,6 +18,7 @@ export class ConfigService { }; this.storeUserData(userData) this.router.navigate(['/MainPortal']) + this.cookieService.set('YourAccountCookie', JSON.stringify(this.getStoredUserData())) return Promise.resolve(true); } @@ -33,6 +37,7 @@ export class ConfigService { logout() { localStorage.removeItem('user'); + this.cookieService.delete("YourAccountCookie") } isLoggedIn(): boolean { From d4d7219e0f4352e3884cedfcb8b7fa87400ab211 Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 11:04:02 +0200 Subject: [PATCH 05/22] style: ugly buttons --- src/styles.scss | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/styles.scss b/src/styles.scss index bdd6337..54a8979 100644 --- a/src/styles.scss +++ b/src/styles.scss @@ -4,3 +4,27 @@ --text-100: #2A3132; --backround-100: #763626; } + +.button { + font-family: Bahnschrift, serif; + display: inline-block; + padding: 15px 25px; + margin: 20px; + cursor: pointer; + text-align: center; + text-decoration: none; + outline: none; + color: #fff; + background-color: #04AA6D; + border: none; + border-radius: 15px; + box-shadow: 0 9px #999; +} + +.button:hover {background-color: #3e8e41} + +.button:active { + background-color: #3e8e41; + box-shadow: 0 5px #666; + transform: translateY(4px); +} From dc4fd8ef5b1ac8fbca6aa56d55e7c5a70565b41a Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 11:04:12 +0200 Subject: [PATCH 06/22] ci: localStorage Service --- src/app/shared/local-storage.service.spec.ts | 16 ++++++++++++ src/app/shared/local-storage.service.ts | 26 ++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/app/shared/local-storage.service.spec.ts create mode 100644 src/app/shared/local-storage.service.ts diff --git a/src/app/shared/local-storage.service.spec.ts b/src/app/shared/local-storage.service.spec.ts new file mode 100644 index 0000000..ba1dbd4 --- /dev/null +++ b/src/app/shared/local-storage.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { LocalStorageService } from './local-storage.service'; + +describe('LocalStorageService', () => { + let service: LocalStorageService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(LocalStorageService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/shared/local-storage.service.ts b/src/app/shared/local-storage.service.ts new file mode 100644 index 0000000..39d5305 --- /dev/null +++ b/src/app/shared/local-storage.service.ts @@ -0,0 +1,26 @@ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class LocalStorageService { + + constructor() { } + + public setItem(key: string, data: any): void { + localStorage.setItem(key, JSON.stringify(data)); + } + + public getItem(key: string): any { + const item = localStorage.getItem(key); + return item ? JSON.parse(item) : null; + } + + public removeItem(key: string): void { + localStorage.removeItem(key); + } + + public clear(): void { + localStorage.clear(); + } +} From e857e7ea993ebb3b237f87735bb73e09a47f8aa4 Mon Sep 17 00:00:00 2001 From: flockean Date: Wed, 22 May 2024 11:04:33 +0200 Subject: [PATCH 07/22] ci: optimization new service --- src/app/app.component.html | 2 +- src/app/cookie/cookie.component.html | 5 +++++ src/app/cookie/cookie.component.scss | 1 + src/app/cookie/cookie.component.ts | 6 +++++- src/app/shared/config.service.ts | 21 +++++++-------------- 5 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index 63b6701..fb05946 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -5,7 +5,7 @@