From 8eba80f7d4b85bf11e641f84311811baec880680 Mon Sep 17 00:00:00 2001 From: Jegor Date: Wed, 16 Jun 2021 09:59:25 +0200 Subject: [PATCH 01/13] WIP: proile component created. --- .../components/profile/profile.component.css | 0 .../components/profile/profile.component.html | 15 +++++++++++ .../profile/profile.component.spec.ts | 25 +++++++++++++++++++ .../components/profile/profile.component.ts | 25 +++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 Frontend/src/app/components/profile/profile.component.css create mode 100644 Frontend/src/app/components/profile/profile.component.html create mode 100644 Frontend/src/app/components/profile/profile.component.spec.ts create mode 100644 Frontend/src/app/components/profile/profile.component.ts diff --git a/Frontend/src/app/components/profile/profile.component.css b/Frontend/src/app/components/profile/profile.component.css new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html new file mode 100644 index 0000000..d44b8bf --- /dev/null +++ b/Frontend/src/app/components/profile/profile.component.html @@ -0,0 +1,15 @@ +
+

+ e-mail + {{ currentUser.email}} +

+

+ username: + {{ currentUser.username}} +

+
+ + + Please login. + + diff --git a/Frontend/src/app/components/profile/profile.component.spec.ts b/Frontend/src/app/components/profile/profile.component.spec.ts new file mode 100644 index 0000000..e88012e --- /dev/null +++ b/Frontend/src/app/components/profile/profile.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfileComponent } from './profile.component'; + +describe('ProfileComponent', () => { + let component: ProfileComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ProfileComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ProfileComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/src/app/components/profile/profile.component.ts b/Frontend/src/app/components/profile/profile.component.ts new file mode 100644 index 0000000..dc8fe69 --- /dev/null +++ b/Frontend/src/app/components/profile/profile.component.ts @@ -0,0 +1,25 @@ +import { Component, OnInit } from '@angular/core'; +import {ApiService} from "../../services/api.service"; + +@Component({ + selector: 'app-profile', + templateUrl: './profile.component.html', + styleUrls: ['./profile.component.css'] +}) +export class ProfileComponent implements OnInit { + + currentUser: any; + obj:any + + constructor(private api: ApiService ) { } + + ngOnInit(): void { + + this.api.getUserInfo().subscribe( + user=> { + this.currentUser = user + console.log(this.currentUser); + }, + ); + } +} From c88efc548404c8ca4a53720a9aed3ea71f6a9217 Mon Sep 17 00:00:00 2001 From: Jegor Date: Wed, 16 Jun 2021 09:59:57 +0200 Subject: [PATCH 02/13] WIP: problems with best deals. --- Frontend/src/app/app.module.ts | 2 ++ Frontend/src/app/app.routing.ts | 2 ++ .../auth/signin/signin.component.ts | 4 +--- .../hot-deals-widget.component.ts | 24 +++++++++++++++---- .../landingpage/landingpage.component.ts | 7 ++++-- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Frontend/src/app/app.module.ts b/Frontend/src/app/app.module.ts index 5635d5f..5da2756 100644 --- a/Frontend/src/app/app.module.ts +++ b/Frontend/src/app/app.module.ts @@ -38,6 +38,7 @@ import { CopyrightComponent } from './components/copyright/copyright.component'; import { GreetingInfoSliderComponent } from './components/greeting-info-slider/greeting-info-slider.component'; import { KundenComponent } from './components/kunden/kunden.component'; import { AboutUsComponent } from './components/about-us/about-us.component'; +import { ProfileComponent } from './components/profile/profile.component'; // For cookie popup const cookieConfig: NgcCookieConsentConfig = { @@ -102,6 +103,7 @@ const cookieConfig: NgcCookieConsentConfig = { GreetingInfoSliderComponent, KundenComponent, AboutUsComponent, + ProfileComponent, ], imports: [ BrowserModule, diff --git a/Frontend/src/app/app.routing.ts b/Frontend/src/app/app.routing.ts index 8008c5b..58ddb59 100644 --- a/Frontend/src/app/app.routing.ts +++ b/Frontend/src/app/app.routing.ts @@ -11,6 +11,7 @@ import {ImprintComponent} from './pages/imprint/imprint.component'; import {PrivacyComponent} from './pages/privacy/privacy.component'; import {SigninComponent} from "./components/auth/signin/signin.component"; import {RegistrationComponent} from "./components/auth/registration/registration.component"; +import {ProfileComponent} from "./components/profile/profile.component"; const routes: Routes = [ {path: '', component: LandingpageComponent, pathMatch: 'full'}, @@ -21,6 +22,7 @@ const routes: Routes = [ {path: 'signin', component: SigninComponent}, {path: 'registration', component: RegistrationComponent}, {path: "product-detail", component: ProductDetailPageComponent}, + {path: "profile", component: ProfileComponent}, {path: '**', component: PageNotFoundPageComponent} ]; diff --git a/Frontend/src/app/components/auth/signin/signin.component.ts b/Frontend/src/app/components/auth/signin/signin.component.ts index e39ac56..dee46ed 100644 --- a/Frontend/src/app/components/auth/signin/signin.component.ts +++ b/Frontend/src/app/components/auth/signin/signin.component.ts @@ -18,7 +18,6 @@ export class SigninComponent implements OnInit { private isSignUpFailed: boolean; private errorMessage: ''; - constructor( private formBuilder: FormBuilder, private api: ApiService, @@ -43,10 +42,9 @@ export class SigninComponent implements OnInit { this.api.loginUser(this.loginForm.value.username, this.loginForm.value.password) .subscribe( data => { - this.router.navigate(['']); this.isSuccessful = true; this.isSignUpFailed = false; - this.api.saveSessionInfoToLocalStorage(data); + this.router.navigate(['']); }, err => { this.errorMessage = err.error.message; diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts index 031dc53..3f5d6d4 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts @@ -11,6 +11,7 @@ import {ActivatedRoute, Router} from '@angular/router'; export class HotDealsWidgetComponent implements OnInit { products: Product[] = []; + bestDealsProductIds = []; @Input() numberOfProducts: number; @Input() showProductPicture: boolean; @Input() searchQuery: string; @@ -24,12 +25,14 @@ export class HotDealsWidgetComponent implements OnInit { } ngOnInit(): void { + this.loadParams(); + this.getBestDeals(); } loadParams(): void { if (!this.numberOfProducts) { - this.numberOfProducts = 10; + this.numberOfProducts = 9; } if (!this.showProductPicture) { this.showProductPicture = false; @@ -47,14 +50,27 @@ export class HotDealsWidgetComponent implements OnInit { break; } default: { - this.getProducts(); + this.getProductsByIds(); break; } } } - getProducts(): void { - this.apiService.getProducts().subscribe(products => this.products = products); + getProductsByIds(): void { + this.apiService.getProductsByIds(this.bestDealsProductIds).subscribe( + products => this.products = products + ); + } + + + getBestDeals(): void { + this.apiService.getBestDeals(9).subscribe( + deals => { + deals.forEach(deal => { + this.bestDealsProductIds.push(deal.product_id); + }); + } + ); } getSearchedProducts(): void { diff --git a/Frontend/src/app/pages/landingpage/landingpage.component.ts b/Frontend/src/app/pages/landingpage/landingpage.component.ts index d62ca82..cf3deac 100644 --- a/Frontend/src/app/pages/landingpage/landingpage.component.ts +++ b/Frontend/src/app/pages/landingpage/landingpage.component.ts @@ -1,5 +1,6 @@ import {Component, OnInit} from '@angular/core'; import {Router} from '@angular/router'; +import {ApiService} from "../../services/api.service"; @Component({ selector: 'app-landingpage', @@ -8,13 +9,16 @@ import {Router} from '@angular/router'; }) export class LandingpageComponent implements OnInit { searchInput: string; + isLoggedIn = false; constructor( - private router: Router + private router: Router, + private api: ApiService ) { } ngOnInit(): void { + } startedSearch(): void { @@ -25,5 +29,4 @@ export class LandingpageComponent implements OnInit { this.router.navigateByUrl('/', {skipLocationChange: true}).then(() => this.router.navigate([uri], queryParams)); } - } From be534551bab4dafffc70ccfcfa0c79273dddf999 Mon Sep 17 00:00:00 2001 From: Jegor Date: Wed, 16 Jun 2021 15:25:12 +0200 Subject: [PATCH 03/13] wip: hot deals widget loadig data --- .../hot-deals-widget.component.html | 10 +++--- .../hot-deals-widget.component.ts | 33 +++++++++++++++---- .../components/top-bar/top-bar.component.html | 1 + 3 files changed, 33 insertions(+), 11 deletions(-) diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html index a77fc6f..7def010 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html @@ -9,18 +9,18 @@
-
+
-
+
-
{{product.name}}
+
{{productsPricesMap[productId]?.product.name}}
-
Amazon: {{product.price}}$
+
Amazon: {{productsPricesMap[productId]?.amazonPrice.price_in_cents}}$
-
Plantshub: 599,00$
+
Plantshub: {{productsPricesMap[productId]?.lowestPrice.price_in_cents}}
diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts index 3f5d6d4..688a951 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts @@ -12,6 +12,8 @@ export class HotDealsWidgetComponent implements OnInit { products: Product[] = []; bestDealsProductIds = []; + amazonPrices = []; + productsPricesMap: any = {}; @Input() numberOfProducts: number; @Input() showProductPicture: boolean; @Input() searchQuery: string; @@ -26,7 +28,6 @@ export class HotDealsWidgetComponent implements OnInit { ngOnInit(): void { - this.loadParams(); this.getBestDeals(); } @@ -46,11 +47,11 @@ export class HotDealsWidgetComponent implements OnInit { switch (this.type) { case 'search': { - this.getSearchedProducts(); break; } default: { this.getProductsByIds(); + this.getAmazonPricesForBestDeals(); break; } } @@ -58,27 +59,47 @@ export class HotDealsWidgetComponent implements OnInit { getProductsByIds(): void { this.apiService.getProductsByIds(this.bestDealsProductIds).subscribe( - products => this.products = products + products => { + products.forEach(product => { + this.productsPricesMap [product.product_id].product = product; + }); + } ); } - getBestDeals(): void { this.apiService.getBestDeals(9).subscribe( deals => { deals.forEach(deal => { this.bestDealsProductIds.push(deal.product_id); + this.productsPricesMap [deal.product_id] = {lowestPrice: deal} }); + this.loadParams(); } ); } + + + getAmazonPricesForBestDeals(): void{ + this.bestDealsProductIds.forEach(id => { + this.apiService.getAmazonPrice(id).subscribe( + price => { + this.amazonPrices.push(price); + this.productsPricesMap[price.product_id].amazonPrice = price; + } + ); + } + ); + console.log(this.amazonPrices); + } + getSearchedProducts(): void { this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products); } - clickedProduct(product: Product): void { - this.router.navigate([('/product/' + product.product_id)]); + clickedProduct(productId: string): void { + this.router.navigate([('/product/' + productId)]); } diff --git a/Frontend/src/app/components/top-bar/top-bar.component.html b/Frontend/src/app/components/top-bar/top-bar.component.html index b8b6697..6a41f7d 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.html +++ b/Frontend/src/app/components/top-bar/top-bar.component.html @@ -15,6 +15,7 @@ +
From 969ac6feafe9a2325a0aefb5b65da2b10e661d0c Mon Sep 17 00:00:00 2001 From: Jegor Date: Thu, 17 Jun 2021 09:55:40 +0200 Subject: [PATCH 04/13] wip: profile component --- Frontend/src/app/app.component.ts | 10 ++++++- Frontend/src/app/app.module.ts | 2 ++ Frontend/src/app/app.routing.ts | 3 +- .../registration/registration.component.ts | 11 +++++-- .../auth/signin/signin.component.ts | 2 +- .../hot-deals-widget.component.html | 8 ++--- .../hot-deals-widget.component.ts | 3 +- .../product-details.component.html | 2 +- .../product-details.component.ts | 6 ++++ .../components/profile/profile.component.html | 21 ++++++++++++++ .../components/profile/profile.component.ts | 29 ++++++++++++++++++- .../components/top-bar/top-bar.component.html | 9 +++--- .../components/top-bar/top-bar.component.ts | 26 +++++++++++++++-- 13 files changed, 113 insertions(+), 19 deletions(-) diff --git a/Frontend/src/app/app.component.ts b/Frontend/src/app/app.component.ts index d45de93..f65d28c 100644 --- a/Frontend/src/app/app.component.ts +++ b/Frontend/src/app/app.component.ts @@ -1,6 +1,8 @@ import {Component, OnDestroy, OnInit} from '@angular/core'; import {NgcCookieConsentService, NgcInitializeEvent, NgcNoCookieLawEvent, NgcStatusChangeEvent} from 'ngx-cookieconsent'; import {Subscription} from 'rxjs'; +import {ApiService} from "./services/api.service"; + @Component({ selector: 'app-root', @@ -19,12 +21,18 @@ export class AppComponent implements OnInit, OnDestroy { private revokeChoiceSubscription: Subscription; private noCookieLawSubscription: Subscription; + isLoggedIn = false; + showUserBoard = false; + username?: string; + constructor( - private ccService: NgcCookieConsentService + private ccService: NgcCookieConsentService, + private api: ApiService ) { } ngOnInit(): void { + // subscribe to cookieconsent observables to react to main events this.popupOpenSubscription = this.ccService.popupOpen$.subscribe( () => { diff --git a/Frontend/src/app/app.module.ts b/Frontend/src/app/app.module.ts index 5da2756..153ae2c 100644 --- a/Frontend/src/app/app.module.ts +++ b/Frontend/src/app/app.module.ts @@ -39,6 +39,7 @@ import { GreetingInfoSliderComponent } from './components/greeting-info-slider/g import { KundenComponent } from './components/kunden/kunden.component'; import { AboutUsComponent } from './components/about-us/about-us.component'; import { ProfileComponent } from './components/profile/profile.component'; +import { ProfilePageComponent } from './pages/profile-page/profile-page.component'; // For cookie popup const cookieConfig: NgcCookieConsentConfig = { @@ -104,6 +105,7 @@ const cookieConfig: NgcCookieConsentConfig = { KundenComponent, AboutUsComponent, ProfileComponent, + ProfilePageComponent, ], imports: [ BrowserModule, diff --git a/Frontend/src/app/app.routing.ts b/Frontend/src/app/app.routing.ts index 58ddb59..2e13ded 100644 --- a/Frontend/src/app/app.routing.ts +++ b/Frontend/src/app/app.routing.ts @@ -12,6 +12,7 @@ import {PrivacyComponent} from './pages/privacy/privacy.component'; import {SigninComponent} from "./components/auth/signin/signin.component"; import {RegistrationComponent} from "./components/auth/registration/registration.component"; import {ProfileComponent} from "./components/profile/profile.component"; +import {ProfilePageComponent} from "./pages/profile-page/profile-page.component"; const routes: Routes = [ {path: '', component: LandingpageComponent, pathMatch: 'full'}, @@ -22,7 +23,7 @@ const routes: Routes = [ {path: 'signin', component: SigninComponent}, {path: 'registration', component: RegistrationComponent}, {path: "product-detail", component: ProductDetailPageComponent}, - {path: "profile", component: ProfileComponent}, + {path: "profile", component: ProfilePageComponent}, {path: '**', component: PageNotFoundPageComponent} ]; diff --git a/Frontend/src/app/components/auth/registration/registration.component.ts b/Frontend/src/app/components/auth/registration/registration.component.ts index ff8c904..a624666 100644 --- a/Frontend/src/app/components/auth/registration/registration.component.ts +++ b/Frontend/src/app/components/auth/registration/registration.component.ts @@ -1,6 +1,7 @@ import { Component, OnInit } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import {ApiService} from "../../../services/api.service"; +import {Router} from "@angular/router"; @Component({ @@ -15,7 +16,8 @@ export class RegistrationComponent implements OnInit { constructor( private formBuilder: FormBuilder, - private api : ApiService + private api : ApiService, + private router: Router ) { } ngOnInit(): void { @@ -32,6 +34,11 @@ export class RegistrationComponent implements OnInit { get me() { return this.form.controls; } onSubmit() { - this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe(res=>console.log(res)); + this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe( + res=> { + this.router.navigate(['']); + this.api.saveSessionInfoToLocalStorage(res); + } + ); } } diff --git a/Frontend/src/app/components/auth/signin/signin.component.ts b/Frontend/src/app/components/auth/signin/signin.component.ts index dee46ed..8ca6646 100644 --- a/Frontend/src/app/components/auth/signin/signin.component.ts +++ b/Frontend/src/app/components/auth/signin/signin.component.ts @@ -43,8 +43,8 @@ export class SigninComponent implements OnInit { .subscribe( data => { this.isSuccessful = true; - this.isSignUpFailed = false; this.router.navigate(['']); + this.api.saveSessionInfoToLocalStorage(data); }, err => { this.errorMessage = err.error.message; diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html index 7def010..947b3f9 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html @@ -11,16 +11,16 @@
-
+
-
{{productsPricesMap[productId]?.product.name}}
+
{{productsPricesMap[productId]?.product?.name}}
-
Amazon: {{productsPricesMap[productId]?.amazonPrice.price_in_cents}}$
+
Amazon: {{productsPricesMap[productId]?.amazonPrice?.price_in_cents/100}}$
-
Plantshub: {{productsPricesMap[productId]?.lowestPrice.price_in_cents}}
+
Plantshub: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}
diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts index 688a951..0fe7af1 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts @@ -86,12 +86,11 @@ export class HotDealsWidgetComponent implements OnInit { this.apiService.getAmazonPrice(id).subscribe( price => { this.amazonPrices.push(price); - this.productsPricesMap[price.product_id].amazonPrice = price; + this.productsPricesMap[price[0].product_id].amazonPrice = price[0]; } ); } ); - console.log(this.amazonPrices); } getSearchedProducts(): void { diff --git a/Frontend/src/app/components/product-details/product-details.component.html b/Frontend/src/app/components/product-details/product-details.component.html index f392f00..cdccfb3 100644 --- a/Frontend/src/app/components/product-details/product-details.component.html +++ b/Frontend/src/app/components/product-details/product-details.component.html @@ -20,7 +20,7 @@ {{product?.short_description}}
-
+
Set Price Alarm
diff --git a/Frontend/src/app/components/product-details/product-details.component.ts b/Frontend/src/app/components/product-details/product-details.component.ts index 54b9c00..1ccae5a 100644 --- a/Frontend/src/app/components/product-details/product-details.component.ts +++ b/Frontend/src/app/components/product-details/product-details.component.ts @@ -117,4 +117,10 @@ export class ProductDetailsComponent implements OnInit { return Math.round(percentage); } + + setPriceAlarm() { + this.apiService.createPriceAlarms(this.productId, 9).subscribe( + alarms => console.log(alarms) + ) + } } diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html index d44b8bf..4bfa28e 100644 --- a/Frontend/src/app/components/profile/profile.component.html +++ b/Frontend/src/app/components/profile/profile.component.html @@ -7,6 +7,27 @@ username: {{ currentUser.username}}

+

+ alarms + {{alarms}} +

+ + + + + + + + + +
ProduktPreis
+ {{productsMap[alarm.product_id]?.name}} + + {{alarm.defined_price/100}} +
+

+ zurück +

diff --git a/Frontend/src/app/components/profile/profile.component.ts b/Frontend/src/app/components/profile/profile.component.ts index dc8fe69..611e06a 100644 --- a/Frontend/src/app/components/profile/profile.component.ts +++ b/Frontend/src/app/components/profile/profile.component.ts @@ -9,7 +9,9 @@ import {ApiService} from "../../services/api.service"; export class ProfileComponent implements OnInit { currentUser: any; - obj:any + obj:any; + alarms: any []; + productsMap: any; constructor(private api: ApiService ) { } @@ -21,5 +23,30 @@ export class ProfileComponent implements OnInit { console.log(this.currentUser); }, ); + + this.getPriceAlarms(); + } + + getPriceAlarms(): void { + this.api.getPriceAlarms().subscribe( + alarms => { + this.alarms = alarms + this.getProductsByIds() + } + ) + } + + getProductsByIds(): void { + let productIds: number []; + this.alarms.forEach( + alarm => {productIds.push(alarm.product_id)} + ); + this.api.getProductsByIds(productIds).subscribe( + products => { + products.forEach( + product => {this.productsMap[product.product_id] = product} + ) + } + ) } } diff --git a/Frontend/src/app/components/top-bar/top-bar.component.html b/Frontend/src/app/components/top-bar/top-bar.component.html index 6a41f7d..944d654 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.html +++ b/Frontend/src/app/components/top-bar/top-bar.component.html @@ -2,7 +2,7 @@
diff --git a/Frontend/src/app/components/top-bar/top-bar.component.ts b/Frontend/src/app/components/top-bar/top-bar.component.ts index f2e667b..89f5cd0 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.ts +++ b/Frontend/src/app/components/top-bar/top-bar.component.ts @@ -1,5 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import {Component, Input, OnInit} from '@angular/core'; import {ApiService} from "../../services/api.service"; +import {Router} from "@angular/router"; @Component({ @@ -10,13 +11,34 @@ import {ApiService} from "../../services/api.service"; export class TopBarComponent implements OnInit { sidenav: any; + isLoggedIn: boolean; + @Input() searchQuery: string; constructor( - private api: ApiService + private api: ApiService, + private router: Router ) { } ngOnInit() { this.api.getUserInfo().subscribe(data=>{console.log(data)}); + + if ( this.api.getSessionInfoFromLocalStorage().session_id != "") { + this.isLoggedIn = true; + } + } + + logout(): void { + localStorage.setItem('session_id', ''); + localStorage.setItem('session_key', ''); + window.location.reload() + } + + getSearchedProducts(): void { + this.api.getProductsByQuery(this.searchQuery).subscribe( + data => { + this.router.navigate([('/registration')]); + } + ); } } From b748b9492a958745d76fcad1756e2dfda44a8d30 Mon Sep 17 00:00:00 2001 From: Jegor Date: Thu, 17 Jun 2021 09:58:49 +0200 Subject: [PATCH 05/13] wip: profile component --- .../profile-page/profile-page.component.css | 0 .../profile-page/profile-page.component.html | 3 +++ .../profile-page.component.spec.ts | 25 +++++++++++++++++++ .../profile-page/profile-page.component.ts | 15 +++++++++++ 4 files changed, 43 insertions(+) create mode 100644 Frontend/src/app/pages/profile-page/profile-page.component.css create mode 100644 Frontend/src/app/pages/profile-page/profile-page.component.html create mode 100644 Frontend/src/app/pages/profile-page/profile-page.component.spec.ts create mode 100644 Frontend/src/app/pages/profile-page/profile-page.component.ts diff --git a/Frontend/src/app/pages/profile-page/profile-page.component.css b/Frontend/src/app/pages/profile-page/profile-page.component.css new file mode 100644 index 0000000..e69de29 diff --git a/Frontend/src/app/pages/profile-page/profile-page.component.html b/Frontend/src/app/pages/profile-page/profile-page.component.html new file mode 100644 index 0000000..efb0505 --- /dev/null +++ b/Frontend/src/app/pages/profile-page/profile-page.component.html @@ -0,0 +1,3 @@ + + + diff --git a/Frontend/src/app/pages/profile-page/profile-page.component.spec.ts b/Frontend/src/app/pages/profile-page/profile-page.component.spec.ts new file mode 100644 index 0000000..9101f43 --- /dev/null +++ b/Frontend/src/app/pages/profile-page/profile-page.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { ProfilePageComponent } from './profile-page.component'; + +describe('ProfilePageComponent', () => { + let component: ProfilePageComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ ProfilePageComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(ProfilePageComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/Frontend/src/app/pages/profile-page/profile-page.component.ts b/Frontend/src/app/pages/profile-page/profile-page.component.ts new file mode 100644 index 0000000..c0d41b6 --- /dev/null +++ b/Frontend/src/app/pages/profile-page/profile-page.component.ts @@ -0,0 +1,15 @@ +import { Component, OnInit } from '@angular/core'; + +@Component({ + selector: 'app-profile-page', + templateUrl: './profile-page.component.html', + styleUrls: ['./profile-page.component.css'] +}) +export class ProfilePageComponent implements OnInit { + + constructor() { } + + ngOnInit(): void { + } + +} From 9821c004ecdaebe326118935f3531ed1f3217a0a Mon Sep 17 00:00:00 2001 From: Jegor Date: Thu, 17 Jun 2021 10:30:40 +0200 Subject: [PATCH 06/13] wip: profile component --- .../registration/registration.component.ts | 2 +- .../components/profile/profile.component.ts | 4 +-- .../components/top-bar/top-bar.component.html | 2 +- .../components/top-bar/top-bar.component.ts | 33 +++++++++++-------- .../product-search-page.component.html | 3 +- 5 files changed, 25 insertions(+), 19 deletions(-) diff --git a/Frontend/src/app/components/auth/registration/registration.component.ts b/Frontend/src/app/components/auth/registration/registration.component.ts index a624666..5324f72 100644 --- a/Frontend/src/app/components/auth/registration/registration.component.ts +++ b/Frontend/src/app/components/auth/registration/registration.component.ts @@ -36,8 +36,8 @@ export class RegistrationComponent implements OnInit { onSubmit() { this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe( res=> { - this.router.navigate(['']); this.api.saveSessionInfoToLocalStorage(res); + this.router.navigate(['/']); } ); } diff --git a/Frontend/src/app/components/profile/profile.component.ts b/Frontend/src/app/components/profile/profile.component.ts index 611e06a..5620827 100644 --- a/Frontend/src/app/components/profile/profile.component.ts +++ b/Frontend/src/app/components/profile/profile.component.ts @@ -11,7 +11,7 @@ export class ProfileComponent implements OnInit { currentUser: any; obj:any; alarms: any []; - productsMap: any; + productsMap: any = {}; constructor(private api: ApiService ) { } @@ -37,7 +37,7 @@ export class ProfileComponent implements OnInit { } getProductsByIds(): void { - let productIds: number []; + let productIds: number [] = []; this.alarms.forEach( alarm => {productIds.push(alarm.product_id)} ); diff --git a/Frontend/src/app/components/top-bar/top-bar.component.html b/Frontend/src/app/components/top-bar/top-bar.component.html index 944d654..2e3ebd8 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.html +++ b/Frontend/src/app/components/top-bar/top-bar.component.html @@ -2,7 +2,7 @@
Betterzon
- +
-
Plantshub: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}
+
{{productsPricesMap[productId]?.vendor?.name}}: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}
diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts index 0fe7af1..95635d7 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.ts @@ -13,7 +13,7 @@ export class HotDealsWidgetComponent implements OnInit { products: Product[] = []; bestDealsProductIds = []; amazonPrices = []; - productsPricesMap: any = {}; + productsPricesMap = new Map(); @Input() numberOfProducts: number; @Input() showProductPicture: boolean; @Input() searchQuery: string; @@ -52,6 +52,7 @@ export class HotDealsWidgetComponent implements OnInit { default: { this.getProductsByIds(); this.getAmazonPricesForBestDeals(); + this.getVendors() break; } } @@ -79,6 +80,16 @@ export class HotDealsWidgetComponent implements OnInit { ); } + getVendors(): void { + this.productsPricesMap.keys().forEach( + key => { + const currentDeal = this.productsPricesMap[key].lowestPrice; + this.apiService.getVendorById(currentDeal.vendor_id).subscribe( + vendor => { + this.productsPricesMap[key].vendor = vendor + }) + }) + } getAmazonPricesForBestDeals(): void{ diff --git a/Frontend/src/app/components/top-bar/top-bar.component.html b/Frontend/src/app/components/top-bar/top-bar.component.html index 2e3ebd8..651adb2 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.html +++ b/Frontend/src/app/components/top-bar/top-bar.component.html @@ -1,9 +1,9 @@
+
+
+
+ diff --git a/Frontend/src/app/components/profile/profile.component.css b/Frontend/src/app/components/profile/profile.component.css index e69de29..42605dc 100644 --- a/Frontend/src/app/components/profile/profile.component.css +++ b/Frontend/src/app/components/profile/profile.component.css @@ -0,0 +1,21 @@ +.inf-content{ + border:1px solid #DDDDDD; + -webkit-border-radius:10px; + -moz-border-radius:10px; + border-radius:10px; + box-shadow: 7px 7px 7px rgba(0, 0, 0, 0.3); +} + +.header-in-page { + padding-top: calc(1rem + 20px); + padding-bottom: 1rem; +} + +table, th, td { + border: 1px solid black; +} + +.delete:hover { + cursor: pointer; + color: #0d5a4b; +} diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html index 4bfa28e..9c9f0a6 100644 --- a/Frontend/src/app/components/profile/profile.component.html +++ b/Frontend/src/app/components/profile/profile.component.html @@ -1,3 +1,100 @@ +
+
+
+
+ +
    +
  • +
  • +
  • +
  • +
  • +
+
+
+ Information
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + Username + + + bootnipets +
+ + + Role + + + User +
+ + + Email + + + noreply@email.com +
+ + + created + + + 20 jul 20014 +
+
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + +
ProduktPreisLöschen
+ {{productsMap[alarm.product_id]?.name}} + + {{alarm.defined_price/100}} + + +
+
+
+ diff --git a/Frontend/src/app/components/profile/profile.component.ts b/Frontend/src/app/components/profile/profile.component.ts index 5620827..02eb9af 100644 --- a/Frontend/src/app/components/profile/profile.component.ts +++ b/Frontend/src/app/components/profile/profile.component.ts @@ -49,4 +49,8 @@ export class ProfileComponent implements OnInit { } ) } + + delete() { + + } } diff --git a/Frontend/src/app/components/top-bar/top-bar.component.ts b/Frontend/src/app/components/top-bar/top-bar.component.ts index aa639fb..bbf5226 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.ts +++ b/Frontend/src/app/components/top-bar/top-bar.component.ts @@ -4,9 +4,9 @@ import {Router} from "@angular/router"; @Component({ - selector: 'app-top-bar', - templateUrl: './top-bar.component.html', - styleUrls: ['./top-bar.component.css'] + selector: 'app-top-bar', + templateUrl: './top-bar.component.html', + styleUrls: ['./top-bar.component.css'] }) export class TopBarComponent implements OnInit { diff --git a/Frontend/src/app/pages/landingpage/landingpage.component.css b/Frontend/src/app/pages/landingpage/landingpage.component.css index cac058e..e69de29 100644 --- a/Frontend/src/app/pages/landingpage/landingpage.component.css +++ b/Frontend/src/app/pages/landingpage/landingpage.component.css @@ -1,50 +0,0 @@ -#mainComponents { - margin: 5em; - margin-top: .5em; - margin-bottom: .5em; -} - -#productListsContainer { - display: grid; - grid-template-areas: - 'search search' - 'popularSearches bestDeals'; - grid-template-columns: 50% 50%; -} - -#searchContainer { - position: relative; - grid-area: search; - height: 10em; -} - -#searchContainer input { - position: relative; - font-size: 1.5em; - padding: .25em; - display: block; - border: 1px solid #ccc; - border-radius: 4px; - box-sizing: border-box; - margin: auto; - -ms-transform: translateY(50%); - transform: translateY(2.5em); -} - -#popularSearchesList { - grid-area: popularSearches; - padding: .5em; -} - -#popularSearchesList h2 { - text-align: center; -} - -#bestDealsList { - grid-area: bestDeals; - padding: .5em; -} - -#bestDealsList h2 { - text-align: center; -} diff --git a/Frontend/src/app/pages/product-search-page/product-search-page.component.css b/Frontend/src/app/pages/product-search-page/product-search-page.component.css index 653b875..6b48f27 100644 --- a/Frontend/src/app/pages/product-search-page/product-search-page.component.css +++ b/Frontend/src/app/pages/product-search-page/product-search-page.component.css @@ -1,5 +1,43 @@ -#mainComponents { - margin: 5em; - margin-top: .5em; - margin-bottom: .5em; +body { + background: #eee } + +.ratings i { + font-size: 16px; + color: red +} + +.strike-text { + color: red; + text-decoration: line-through +} + +.product-image { + width: 20%; + height: 20%; +} + +.dot { + height: 7px; + width: 7px; + margin-left: 6px; + margin-right: 6px; + margin-top: 3px; + background-color: blue; + border-radius: 50%; + display: inline-block +} + +.spec-1 { + color: #938787; + font-size: 15px +} + +h5 { + font-weight: 400 +} + +.para { + font-size: 16px +} + diff --git a/Frontend/src/app/pages/product-search-page/product-search-page.component.html b/Frontend/src/app/pages/product-search-page/product-search-page.component.html index cedafa9..03d93fe 100644 --- a/Frontend/src/app/pages/product-search-page/product-search-page.component.html +++ b/Frontend/src/app/pages/product-search-page/product-search-page.component.html @@ -1,7 +1,14 @@ + +
+ +
+
+ +
diff --git a/Frontend/src/app/pages/profile-page/profile-page.component.css b/Frontend/src/app/pages/profile-page/profile-page.component.css index e69de29..593c8e9 100644 --- a/Frontend/src/app/pages/profile-page/profile-page.component.css +++ b/Frontend/src/app/pages/profile-page/profile-page.component.css @@ -0,0 +1,4 @@ +.header-in-page { + padding-top: calc(2rem + 20px); + padding-bottom: 6rem; +} diff --git a/Frontend/src/app/pages/profile-page/profile-page.component.html b/Frontend/src/app/pages/profile-page/profile-page.component.html index efb0505..592be07 100644 --- a/Frontend/src/app/pages/profile-page/profile-page.component.html +++ b/Frontend/src/app/pages/profile-page/profile-page.component.html @@ -1,3 +1,10 @@ + +
+
+
+
+ + diff --git a/Frontend/src/assets/images/Delete_icon-icons.com_55931.png b/Frontend/src/assets/images/Delete_icon-icons.com_55931.png new file mode 100644 index 0000000000000000000000000000000000000000..f1e94608a640e6aa8369435d38cc67debe580984 GIT binary patch literal 239 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdzmSQK*5Dp-y;YjHK@;M7UB8wRq z_>O=u<5X=vX`tXlPZ!6Kh}O5$9Jv}41YGwE&RghrNq6tuxWjn~vp2Rj8ZAydVlzQx z_WR^J92#8nc^lX#bUn=MZ(aFDwNv){8dnK1hBqQv8FDR=p+(j4tEZPGNN61p)p);U ztDK&JjA#I(Xh7pjChgDvKLuWlGM{;`@jSQ7FS({SF~wY2`7-m?$G Date: Thu, 17 Jun 2021 17:52:27 +0200 Subject: [PATCH 09/13] wip: profile --- .../product-details.component.html | 8 +++++-- .../product-details.component.ts | 9 +++++++- .../product-list/product-list.component.html | 2 +- .../product-list/product-list.component.ts | 22 ++++++++++++++++++- .../components/profile/profile.component.html | 6 ++++- .../components/profile/profile.component.ts | 6 +++-- 6 files changed, 45 insertions(+), 8 deletions(-) diff --git a/Frontend/src/app/components/product-details/product-details.component.html b/Frontend/src/app/components/product-details/product-details.component.html index a40e238..4e91ab0 100644 --- a/Frontend/src/app/components/product-details/product-details.component.html +++ b/Frontend/src/app/components/product-details/product-details.component.html @@ -23,8 +23,12 @@ {{product?.short_description}}
-
- Set Price Alarm +
+ Login to set a price alarm +
+
+ +
Set Price Alarm
diff --git a/Frontend/src/app/components/product-details/product-details.component.ts b/Frontend/src/app/components/product-details/product-details.component.ts index 1ccae5a..e7588c2 100644 --- a/Frontend/src/app/components/product-details/product-details.component.ts +++ b/Frontend/src/app/components/product-details/product-details.component.ts @@ -34,6 +34,8 @@ export class ProductDetailsComponent implements OnInit { vendorMap = {}; @ViewChild('chart') chart: ChartComponent; public chartOptions: ChartOptions; + isLoggedIn: boolean; + price: any; constructor( private apiService: ApiService @@ -44,6 +46,9 @@ export class ProductDetailsComponent implements OnInit { this.getProduct(); this.getVendors(); this.getPrices(); + if (this.apiService.getSessionInfoFromLocalStorage().session_id != "") { + this.isLoggedIn = true; + } } getProduct(): void { @@ -119,8 +124,10 @@ export class ProductDetailsComponent implements OnInit { } setPriceAlarm() { - this.apiService.createPriceAlarms(this.productId, 9).subscribe( + this.apiService.createPriceAlarms(this.productId, this.price*100).subscribe( alarms => console.log(alarms) ) } + + } diff --git a/Frontend/src/app/components/product-list/product-list.component.html b/Frontend/src/app/components/product-list/product-list.component.html index f5186c8..5c26ab9 100644 --- a/Frontend/src/app/components/product-list/product-list.component.html +++ b/Frontend/src/app/components/product-list/product-list.component.html @@ -16,7 +16,7 @@
-

${{product.price}}

+

${{pricesMap[product.product_id]?.price_in_cents/100}}

diff --git a/Frontend/src/app/components/product-list/product-list.component.ts b/Frontend/src/app/components/product-list/product-list.component.ts index 94bab8a..5fe6432 100644 --- a/Frontend/src/app/components/product-list/product-list.component.ts +++ b/Frontend/src/app/components/product-list/product-list.component.ts @@ -10,6 +10,7 @@ import {ActivatedRoute, Router} from '@angular/router'; }) export class ProductListComponent implements OnInit { products: Product[] = []; + pricesMap: any = {}; @Input() numberOfProducts: number; @Input() showProductPicture: boolean; @Input() searchQuery: string; @@ -53,9 +54,27 @@ export class ProductListComponent implements OnInit { } getProducts(): void { - this.apiService.getProducts().subscribe(products => this.products = products); + this.apiService.getProducts().subscribe(products => { + this.products = products; + this.getPrices(); + }); } + getPrices(): void { + const productIds: number[] = []; + this.products.forEach( + product => productIds.push(product.product_id) + ) + this.apiService.getProductsByIds(productIds).subscribe( + prices => { + prices.forEach(price => { + this.pricesMap[price.product_id] = price; + }) + } + ) + } + + getSearchedProducts(): void { this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products); } @@ -64,4 +83,5 @@ export class ProductListComponent implements OnInit { this.router.navigate([('/product/' + product.product_id)]); } + } diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html index 9c9f0a6..4d94c9f 100644 --- a/Frontend/src/app/components/profile/profile.component.html +++ b/Frontend/src/app/components/profile/profile.component.html @@ -78,6 +78,7 @@ Produkt Preis + Ändern Löschen @@ -88,7 +89,10 @@ {{alarm.defined_price/100}} - + + + + diff --git a/Frontend/src/app/components/profile/profile.component.ts b/Frontend/src/app/components/profile/profile.component.ts index 02eb9af..4e9402a 100644 --- a/Frontend/src/app/components/profile/profile.component.ts +++ b/Frontend/src/app/components/profile/profile.component.ts @@ -50,7 +50,9 @@ export class ProfileComponent implements OnInit { ) } - delete() { - + delete(id:number): void { + this.api.deletePriceAlarm(id).subscribe( + res => window.location.reload() + ) } } From 78e2de65457005bc4765cfaee8102985899be90f Mon Sep 17 00:00:00 2001 From: Patrick <50352812+Mueller-Patrick@users.noreply.github.com> Date: Thu, 17 Jun 2021 19:06:18 +0200 Subject: [PATCH 10/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d32e79..45fab35 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Wiki: https://github.com/Mueller-Patrick/Betterzon/wiki # Code Quality [![Codacy Badge](https://app.codacy.com/project/badge/Grade/88e47ebf837b43af9d12147c22f77f7f)](https://www.codacy.com/gh/Mueller-Patrick/Betterzon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Mueller-Patrick/Betterzon&utm_campaign=Badge_Grade) -[![Code Coverage](https://img.shields.io/badge/coverage-82%25-green)](https://ci.betterzon.xyz) +[![Code Coverage](https://img.shields.io/badge/coverage-71%25-green)](https://ci.betterzon.xyz) # Project Status [![Website Status](https://img.shields.io/website?label=www.betterzon.xyz&style=for-the-badge&url=https%3A%2F%2Fwww.betterzon.xyz)](https://www.betterzon.xyz) From a792c43e24742ce012dc5d7b1cc54e835f815a25 Mon Sep 17 00:00:00 2001 From: Jegor Date: Thu, 17 Jun 2021 22:52:09 +0200 Subject: [PATCH 11/13] wip: german -> english --- .../about-us/about-us.component.html | 4 ++-- .../registration/registration.component.html | 8 +++---- .../auth/signin/signin.component.html | 6 ++--- .../bottom-bar/bottom-bar.component.html | 14 +++++------ .../hot-deals-widget.component.html | 2 +- .../components/kunden/kunden.component.html | 2 +- .../product-list/product-list.component.ts | 23 ++++++++++--------- .../components/profile/profile.component.html | 14 +++++------ .../components/top-bar/top-bar.component.html | 14 +++++------ Frontend/src/styles.css | 4 ++-- 10 files changed, 45 insertions(+), 46 deletions(-) diff --git a/Frontend/src/app/components/about-us/about-us.component.html b/Frontend/src/app/components/about-us/about-us.component.html index 6fa5b2e..02cbb14 100644 --- a/Frontend/src/app/components/about-us/about-us.component.html +++ b/Frontend/src/app/components/about-us/about-us.component.html @@ -10,8 +10,8 @@
-

text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries

-

text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries

+

You follow the same passion as we do and you want to find alternatives to the de-facto monopolist Amazon?

+

In this case, welcome aboard! We’re happy that you share our passion and hope that we can help you achieving this goal with the website

diff --git a/Frontend/src/app/components/auth/registration/registration.component.html b/Frontend/src/app/components/auth/registration/registration.component.html index c18e6e0..e203b31 100644 --- a/Frontend/src/app/components/auth/registration/registration.component.html +++ b/Frontend/src/app/components/auth/registration/registration.component.html @@ -6,7 +6,7 @@ diff --git a/Frontend/src/app/components/bottom-bar/bottom-bar.component.html b/Frontend/src/app/components/bottom-bar/bottom-bar.component.html index 039881b..9059db7 100644 --- a/Frontend/src/app/components/bottom-bar/bottom-bar.component.html +++ b/Frontend/src/app/components/bottom-bar/bottom-bar.component.html @@ -5,24 +5,22 @@

Location

- 70376 Stuttgart + 76133 Karlsruhe

-

FOLGE UNS

- - - - +

FOLLOW UNS

+ +
-

SOME INFO

+

CONTACT US

- text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries + betterzon-contact@mueller-patrick.tech

diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html index 7a43211..37474da 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html @@ -1,7 +1,7 @@
-

TOP-ANGEBOTE

+

TOP-SEARCHES

diff --git a/Frontend/src/app/components/kunden/kunden.component.html b/Frontend/src/app/components/kunden/kunden.component.html index 0012423..0fde734 100644 --- a/Frontend/src/app/components/kunden/kunden.component.html +++ b/Frontend/src/app/components/kunden/kunden.component.html @@ -1,7 +1,7 @@
-

SIE VERTRAUEN UNS

+

THEY TRUST US

diff --git a/Frontend/src/app/components/product-list/product-list.component.ts b/Frontend/src/app/components/product-list/product-list.component.ts index 5fe6432..1f1bdd3 100644 --- a/Frontend/src/app/components/product-list/product-list.component.ts +++ b/Frontend/src/app/components/product-list/product-list.component.ts @@ -61,24 +61,25 @@ export class ProductListComponent implements OnInit { } getPrices(): void { - const productIds: number[] = []; this.products.forEach( - product => productIds.push(product.product_id) - ) - this.apiService.getProductsByIds(productIds).subscribe( - prices => { - prices.forEach(price => { - this.pricesMap[price.product_id] = price; - }) + product => { + this.apiService.getLowestPrices(product.product_id).subscribe( + prices => { + this.pricesMap[product.product_id] = prices[prices.length - 1]; + } + ); } - ) + ); } getSearchedProducts(): void { - this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products); + this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => { + this.products = products; + this.getPrices(); + }); } - + clickedProduct(product: Product): void { this.router.navigate([('/product/' + product.product_id)]); } diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html index 4d94c9f..c08a7d9 100644 --- a/Frontend/src/app/components/profile/profile.component.html +++ b/Frontend/src/app/components/profile/profile.component.html @@ -24,7 +24,7 @@ - bootnipets + {{currentUser.username}} @@ -48,7 +48,7 @@ - noreply@email.com + {{currentUser.email}} @@ -59,7 +59,7 @@ - 20 jul 20014 + {{currentUser.registration_date}} @@ -76,10 +76,10 @@
- - - - + + + +
ProduktPreisÄndernLöschenProductPriceChangeDelete
diff --git a/Frontend/src/app/components/top-bar/top-bar.component.html b/Frontend/src/app/components/top-bar/top-bar.component.html index 651adb2..7cfece9 100644 --- a/Frontend/src/app/components/top-bar/top-bar.component.html +++ b/Frontend/src/app/components/top-bar/top-bar.component.html @@ -10,13 +10,13 @@ diff --git a/Frontend/src/styles.css b/Frontend/src/styles.css index ce64db2..29431c5 100644 --- a/Frontend/src/styles.css +++ b/Frontend/src/styles.css @@ -447,8 +447,8 @@ progress { } .lead { - font-size: 1.25rem; - font-weight: 300; + font-size: 1.30rem; + font-weight: 400; } .display-1 { From 7ac73204dfbdc28a7605c1b251c0421bd189b138 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Thu, 17 Jun 2021 23:04:47 +0200 Subject: [PATCH 12/13] Fixing typo --- .../src/app/components/bottom-bar/bottom-bar.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Frontend/src/app/components/bottom-bar/bottom-bar.component.html b/Frontend/src/app/components/bottom-bar/bottom-bar.component.html index 9059db7..2b4fc09 100644 --- a/Frontend/src/app/components/bottom-bar/bottom-bar.component.html +++ b/Frontend/src/app/components/bottom-bar/bottom-bar.component.html @@ -12,7 +12,7 @@
-

FOLLOW UNS

+

FOLLOW US

From 0bc02ee9ea1a40fef8fa3cba08da38eecf7e2963 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Thu, 17 Jun 2021 23:33:53 +0200 Subject: [PATCH 13/13] Fixing currency sign --- .../hot-deals-widget/hot-deals-widget.component.html | 4 ++-- Frontend/src/app/components/profile/profile.component.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html index 37474da..7b08b63 100644 --- a/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html +++ b/Frontend/src/app/components/hot-deals-widget/hot-deals-widget.component.html @@ -17,10 +17,10 @@
{{productsPricesMap[productId]?.product?.name}}
-
Amazon: {{productsPricesMap[productId]?.amazonPrice?.price_in_cents/100}}$
+
Amazon: {{productsPricesMap[productId]?.amazonPrice?.price_in_cents/100}}€
-
{{productsPricesMap[productId]?.vendor?.name}}: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}
+
{{productsPricesMap[productId]?.vendor?.name}}: {{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}€
diff --git a/Frontend/src/app/components/profile/profile.component.html b/Frontend/src/app/components/profile/profile.component.html index c08a7d9..669e11f 100644 --- a/Frontend/src/app/components/profile/profile.component.html +++ b/Frontend/src/app/components/profile/profile.component.html @@ -86,7 +86,7 @@ {{productsMap[alarm.product_id]?.name}}
- {{alarm.defined_price/100}} + {{alarm.defined_price/100}}€