Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
<router-outlet></router-outlet>
</main>
<app-chatbot-widget class="relative"></app-chatbot-widget>
@if(!cookiesAllowed){
<cookie-card class="relative"></cookie-card>
}
<bae-footer class="hidden md:block"></bae-footer>
13 changes: 12 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Component, OnInit} from '@angular/core';
import { initFlowbite } from 'flowbite';
import { TranslateService } from '@ngx-translate/core';
import {LocalStorageService} from "./services/local-storage.service";
import {Category} from "./models/interfaces";
import {Category, CookieInfo} from "./models/interfaces";
import {EventMessageService} from "./services/event-message.service";
import { ActivatedRoute } from '@angular/router';
import { Router } from '@angular/router';
Expand All @@ -20,6 +20,7 @@ import * as moment from 'moment';
export class AppComponent implements OnInit {
title = 'YUMKET deployed by the DOME Project';
showPanel = false;
cookiesAllowed:boolean=false;

constructor(private translate: TranslateService,
private localStorage: LocalStorageService,
Expand Down Expand Up @@ -64,6 +65,12 @@ export class AppComponent implements OnInit {

//this.refreshApi.startInterval(3000, ev.value);
}
if(ev.type=='CookiesAllowed'){
this.cookiesAllowed=true;
}
if(ev.type=='CookiesDisabled'){
this.cookiesAllowed=false;
}
})
let aux =this.localStorage.getObject('login_items') as LoginInfo;
if(JSON.stringify(aux) === '{}'){
Expand All @@ -77,6 +84,10 @@ export class AppComponent implements OnInit {
console.log('token')
console.log(aux.token)
}
let cookieInfo = this.localStorage.getObject('cookie_info') as CookieInfo;
if(cookieInfo.allowed==true){
this.cookiesAllowed=true;
}
}

checkPanel() {
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import { CategoriesComponent } from './pages/admin/categories/categories.compone
import { CreateCategoryComponent } from './pages/admin/categories/create-category/create-category.component';
import { UpdateCategoryComponent } from './pages/admin/categories/update-category/update-category.component';
import { CategoriesRecursionListComponent } from './shared/categories-recursion-list/categories-recursion-list.component';
import { CookieCardComponent } from './shared/cookie-card/cookie-card.component';
import { ContactUsComponent } from './offerings/contact-us/contact-us.component';
import { provideMatomo } from 'ngx-matomo-client';
import { withRouter } from 'ngx-matomo-client'
Expand Down Expand Up @@ -128,7 +129,8 @@ import { appConfigFactory } from './app-config-factory';
CreateCategoryComponent,
UpdateCategoryComponent,
CategoriesRecursionListComponent,
ContactUsComponent
ContactUsComponent,
CookieCardComponent
],
imports: [
BrowserModule,
Expand Down
5 changes: 5 additions & 0 deletions src/app/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ export interface LoginInfo {
logged_as: string
}

export interface CookieInfo {
allowed: boolean,
expire: number
}

export interface productSpecCharacteristicValueCart {
characteristic: ProductSpecificationCharacteristic,
value?: CharacteristicValueSpecification
Expand Down
16 changes: 16 additions & 0 deletions src/app/services/cookie-renewal.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';

import { CookieRenewalService } from './cookie-renewal.service';

describe('CookieRenewalService', () => {
let service: CookieRenewalService;

beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(CookieRenewalService);
});

it('should be created', () => {
expect(service).toBeTruthy();
});
});
50 changes: 50 additions & 0 deletions src/app/services/cookie-renewal.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Injectable } from '@angular/core';
import { Observable, Subscription, interval } from 'rxjs';
import * as moment from 'moment';
import {LocalStorageService} from "./local-storage.service";
import { CookieInfo } from '../models/interfaces';
import { environment } from "src/environments/environment";
import { Router } from '@angular/router';
import {EventMessageService} from "./event-message.service";

@Injectable({
providedIn: 'root'
})
export class CookieRenewalService {

private intervalObservable: Observable<number>;
private intervalSubscription: Subscription | undefined;

constructor(
private localStorage: LocalStorageService,
private eventMessage: EventMessageService
) {
}

startCookieInterval(intervalDuration: number): void {
this.intervalObservable = interval(intervalDuration);
console.log('start interval')
console.log(intervalDuration)

this.intervalSubscription = this.intervalObservable.subscribe(() => {
console.log('cookie subscription')

//let aux = this.localStorage.getObject('cookie_info') as CookieInfo;
this.stopCookieInterval();
this.localStorage.setObject('cookie_info',{
"allowed": false,
"expire": environment.COOKIE_INTERVAL
});
//this.startCookieInterval(moment().unix());
this.eventMessage.emitCookiesDisabled();

});
}

stopCookieInterval(): void {
if (this.intervalSubscription) {
console.log('stop cookie interval')
this.intervalSubscription.unsubscribe();
}
}
}
10 changes: 9 additions & 1 deletion src/app/services/event-message.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface EventMessage {
'SellerProductSpec' | 'SellerCreateProductSpec' | 'SellerServiceSpec' | 'SellerCreateServiceSpec' | 'SellerResourceSpec' | 'SellerCreateResourceSpec' |
'SellerOffer' | 'SellerCreateOffer' | 'SellerUpdateProductSpec' | 'SellerUpdateServiceSpec' | 'SellerUpdateResourceSpec' | 'SellerUpdateOffer' |
'SellerCatalog' | 'SellerCatalogCreate' | 'SellerCatalogUpdate' | 'CategoryAdded' | 'CategoryRemoved' | 'ChangedSession' | 'CloseCartCard'|
'AdminCategories' | 'CreateCategory' | 'UpdateCategory' | 'ShowCartToast' | 'HideCartToast' | 'CloseContact';
'AdminCategories' | 'CreateCategory' | 'UpdateCategory' | 'ShowCartToast' | 'HideCartToast' | 'CloseContact' | 'CookiesAllowed' | 'CookiesDisabled';
text?: string,
value?: object | boolean
}
Expand Down Expand Up @@ -157,4 +157,12 @@ export class EventMessageService {
emitCloseContact(close:boolean){
this.eventMessageSubject.next({type: 'CloseContact', value: close})
}

emitCookiesAllowed(){
this.eventMessageSubject.next({type: 'CookiesAllowed', value: true})
}

emitCookiesDisabled(){
this.eventMessageSubject.next({type: 'CookiesDisabled', value: true})
}
}
Empty file.
23 changes: 23 additions & 0 deletions src/app/shared/cookie-card/cookie-card.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div class="fixed bottom-14 md:bottom-28 right-0 mb-4 mr-4 w-64 z-10">
<div class="bg-white dark:bg-secondary-100 border border-primary-100 dark:border-primary-50 rounded-lg shadow-lg p-4">
<div class="flex items-center justify-between mb-2">
<div class="flex items-center">
<img src="https://www.svgrepo.com/show/401340/cookie.svg" alt="Cookie" class="h-6 w-6 mr-2">
<span class="text-gray-700 dark:text-white font-bold text-sm">Cookie Policy</span>
</div>
</div>
<p class="text-gray-600 dark:text-gray-200 text-sm">
We use cookies to enhance your experience. By continuing to visit this site, you agree to our use of
cookies.
</p>
<div class="flex justify-between">
<button (click)="allowCookies()" class="flex mt-4 bg-primary-100 dark:bg-primary-50 hover:bg-primary-50 dark:hover:bg-primary-100 text-white font-bold py-2 px-4 rounded">
Accept
</button>
<!--<button class="flex mt-4 bg-gray-200 hover:bg-gray-300 text-gray-700 font-bold py-2 px-4 rounded">
Decline
</button>-->
</div>

</div>
</div>
23 changes: 23 additions & 0 deletions src/app/shared/cookie-card/cookie-card.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { CookieCardComponent } from './cookie-card.component';

describe('CookieCardComponent', () => {
let component: CookieCardComponent;
let fixture: ComponentFixture<CookieCardComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [CookieCardComponent]
})
.compileComponents();

fixture = TestBed.createComponent(CookieCardComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
29 changes: 29 additions & 0 deletions src/app/shared/cookie-card/cookie-card.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Component, OnInit } from '@angular/core';
import { CookieRenewalService } from "src/app/services/cookie-renewal.service";
import {LocalStorageService} from "../../services/local-storage.service";
import {EventMessageService} from "../../services/event-message.service";
import { CookieInfo } from 'src/app/models/interfaces';
import { environment } from 'src/environments/environment';
import * as moment from 'moment';

@Component({
selector: 'cookie-card',
templateUrl: './cookie-card.component.html',
styleUrl: './cookie-card.component.css'
})
export class CookieCardComponent {
constructor(
private localStorage: LocalStorageService,
private eventMessage: EventMessageService,
private cookieService: CookieRenewalService
) { }

allowCookies(){
this.localStorage.setObject('cookie_info',{
"allowed": true,
"expire": environment.COOKIE_INTERVAL
});
this.cookieService.startCookieInterval(environment.COOKIE_INTERVAL);
this.eventMessage.emitCookiesAllowed();
}
}
4 changes: 3 additions & 1 deletion src/environments/environment.development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ export const environment = {
TICKETING_SYSTEM_URL: "",
KNOWLEDGE_BASE_URL: "",
SEARCH_ENABLED: true,
PURCHASE_ENABLED: false
PURCHASE_ENABLED: false,
//Cookie lasting time in milis - set to 15 days
COOKIE_INTERVAL: 1296000000
};
4 changes: 3 additions & 1 deletion src/environments/environment.production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ export const environment = {
TICKETING_SYSTEM_URL: "",
KNOWLEDGE_BASE_URL: "",
SEARCH_ENABLED: true,
PURCHASE_ENABLED: false
PURCHASE_ENABLED: false,
//Cookie lasting time in milis - set to 15 days
COOKIE_INTERVAL: 1296000000
};
4 changes: 3 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,7 @@ export const environment = {
TICKETING_SYSTEM_URL: "",
KNOWLEDGE_BASE_URL: "",
SEARCH_ENABLED: true,
PURCHASE_ENABLED: false
PURCHASE_ENABLED: false,
//Cookie lasting time in milis - set to 15 days
COOKIE_INTERVAL: 1296000000
};