Compare commits

..

No commits in common. "fe2c064e3003fbdf79c6dc1cdf02dae0c02353c2" and "be534551bab4dafffc70ccfcfa0c79273dddf999" have entirely different histories.

18 changed files with 27 additions and 181 deletions

View File

@ -1,8 +1,6 @@
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',
@ -21,18 +19,12 @@ export class AppComponent implements OnInit, OnDestroy {
private revokeChoiceSubscription: Subscription;
private noCookieLawSubscription: Subscription;
isLoggedIn = false;
showUserBoard = false;
username?: string;
constructor(
private ccService: NgcCookieConsentService,
private api: ApiService
private ccService: NgcCookieConsentService
) {
}
ngOnInit(): void {
// subscribe to cookieconsent observables to react to main events
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(
() => {

View File

@ -39,7 +39,6 @@ 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 = {
@ -105,7 +104,6 @@ const cookieConfig: NgcCookieConsentConfig = {
KundenComponent,
AboutUsComponent,
ProfileComponent,
ProfilePageComponent,
],
imports: [
BrowserModule,

View File

@ -12,7 +12,6 @@ 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'},
@ -23,7 +22,7 @@ const routes: Routes = [
{path: 'signin', component: SigninComponent},
{path: 'registration', component: RegistrationComponent},
{path: "product-detail", component: ProductDetailPageComponent},
{path: "profile", component: ProfilePageComponent},
{path: "profile", component: ProfileComponent},
{path: '**', component: PageNotFoundPageComponent}
];

View File

@ -1,7 +1,6 @@
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({
@ -16,8 +15,7 @@ export class RegistrationComponent implements OnInit {
constructor(
private formBuilder: FormBuilder,
private api : ApiService,
private router: Router
private api : ApiService
) { }
ngOnInit(): void {
@ -34,11 +32,6 @@ 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=> {
this.api.saveSessionInfoToLocalStorage(res);
this.router.navigate(['/']);
}
);
this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe(res=>console.log(res));
}
}

View File

@ -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;

View File

@ -11,16 +11,16 @@
<!-- Portfolio Item 1-->
<div class="col-md-4 mx-auto my-5" *ngFor="let productId of bestDealsProductIds" (click)="clickedProduct(productId)">
<div class="bbb_deals_wrapper">
<div class="bbb_deals_image"><img src="https://www.mueller-patrick.tech/betterzon/images/{{productsPricesMap[productId]?.product?.image_guid}}.jpg" alt=""></div>
<div class="bbb_deals_image"><img src="https://www.mueller-patrick.tech/betterzon/images/{{productsPricesMap[productId]?.product.image_guid}}.jpg" alt=""></div>
<div class="bbb_deals_content">
<div class="bbb_deals_info_line d-flex flex-row justify-content-start">
<div class="bbb_deals_item_name">{{productsPricesMap[productId]?.product?.name}}</div>
<div class="bbb_deals_item_name">{{productsPricesMap[productId]?.product.name}}</div>
</div>
<div class="bbb_deals_info_line d-flex flex-row justify-content-start">
<div class="bbb_deals_item_category">Amazon: <span id="bbb_deals_item_price_a"><strike>{{productsPricesMap[productId]?.amazonPrice?.price_in_cents/100}}$</strike></span></div>
<div class="bbb_deals_item_category">Amazon: <span id="bbb_deals_item_price_a"><strike>{{productsPricesMap[productId]?.amazonPrice.price_in_cents}}$</strike></span></div>
</div>
<div class="bbb_deals_info_line d-flex flex-row justify-content-start">
<div class="bbb_deals_item_category">{{productsPricesMap[productId]?.vendor?.name}}: <span id="bbb_deals_item_price_b">{{productsPricesMap[productId]?.lowestPrice?.price_in_cents/100}}</span></div>
<div class="bbb_deals_item_category">Plantshub: <span id="bbb_deals_item_price_b">{{productsPricesMap[productId]?.lowestPrice.price_in_cents}}</span></div>
</div>
<div class="available_bar">
<span style="width:17%"></span>

View File

@ -13,7 +13,7 @@ export class HotDealsWidgetComponent implements OnInit {
products: Product[] = [];
bestDealsProductIds = [];
amazonPrices = [];
productsPricesMap = new Map();
productsPricesMap: any = {};
@Input() numberOfProducts: number;
@Input() showProductPicture: boolean;
@Input() searchQuery: string;
@ -52,7 +52,6 @@ export class HotDealsWidgetComponent implements OnInit {
default: {
this.getProductsByIds();
this.getAmazonPricesForBestDeals();
this.getVendors()
break;
}
}
@ -80,16 +79,6 @@ 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{
@ -97,11 +86,12 @@ export class HotDealsWidgetComponent implements OnInit {
this.apiService.getAmazonPrice(id).subscribe(
price => {
this.amazonPrices.push(price);
this.productsPricesMap[price[0].product_id].amazonPrice = price[0];
this.productsPricesMap[price.product_id].amazonPrice = price;
}
);
}
);
console.log(this.amazonPrices);
}
getSearchedProducts(): void {

View File

@ -20,7 +20,7 @@
{{product?.short_description}}
</div>
</div>
<div class="priceAlarm" (click)="setPriceAlarm()">
<div class="priceAlarm">
Set Price Alarm
</div>
<div class="bestPriceContainer">

View File

@ -117,10 +117,4 @@ export class ProductDetailsComponent implements OnInit {
return Math.round(percentage);
}
setPriceAlarm() {
this.apiService.createPriceAlarms(this.productId, 9).subscribe(
alarms => console.log(alarms)
)
}
}

View File

@ -7,27 +7,6 @@
<strong>username:</strong>
{{ currentUser.username}}
</p>
<p>
<strong>alarms</strong>
{{alarms}}
</p>
<table>
<tr>
<th>Produkt</th>
<th>Preis</th>
</tr>
<tr *ngFor="let alarm of alarms">
<td>
{{productsMap[alarm.product_id]?.name}}
</td>
<td>
{{alarm.defined_price/100}}
</td>
</tr>
</table>
<p>
<strong><a routerLink="/">zurück</a></strong>
</p>
</div>
<ng-template #loggedOut>

View File

@ -9,9 +9,7 @@ import {ApiService} from "../../services/api.service";
export class ProfileComponent implements OnInit {
currentUser: any;
obj:any;
alarms: any [];
productsMap: any = {};
obj:any
constructor(private api: ApiService ) { }
@ -23,30 +21,5 @@ 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}
)
}
)
}
}

View File

@ -1,9 +1,9 @@
<nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
<div class="container">
<a class="navbar-brand" routerLink=""> Betterzon</a>
<div class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" (keyup.enter)="getSearchedProducts()" [(ngModel)]="searchQuery">
</div>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
</form>
<button class="navbar-toggler text-uppercase font-weight-bold bg-primary text-white rounded" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
Menu
<i class="fas fa-bars"></i>
@ -13,10 +13,9 @@
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#top-gesuchte">Top-Gesuchte</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#about">über uns</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" href="#unsere-kunden">Unsere Kunden</a></li>
<li class="nav-item mx-0 mx-lg-1" *ngIf="!isLoggedIn"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/signin">Anmelden</a></li>
<li class="nav-item mx-0 mx-lg-1" *ngIf="!isLoggedIn"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/registration">Konto Erstellen</a></li>
<li class="nav-item mx-0 mx-lg-1" *ngIf="isLoggedIn"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="" (click)="logout()">Log Out</a></li>
<li class="nav-item mx-0 mx-lg-1" *ngIf="isLoggedIn"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/profile">Profile</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/signin">Anmelden</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/registration">Konto Erstellen</a></li>
<li class="nav-item mx-0 mx-lg-1"><a class="nav-link py-3 px-0 px-lg-3 rounded" routerLink="/registration">Log Out</a></li>
</ul>
</div>
</div>

View File

@ -1,6 +1,5 @@
import {Component, Input, OnInit} from '@angular/core';
import { Component, OnInit } from '@angular/core';
import {ApiService} from "../../services/api.service";
import {Router} from "@angular/router";
@Component({
@ -10,40 +9,14 @@ import {Router} from "@angular/router";
})
export class TopBarComponent implements OnInit {
sidenav: any;
isLoggedIn: boolean;
searchQuery: string;
sidenav: any;
constructor(
private api: ApiService,
private router: Router
) {
}
constructor(
private api: ApiService
) { }
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 {
console.log(this.searchQuery);
this.redirectTo('/search', {queryParams: {q: this.searchQuery}});
}
redirectTo(uri: string, queryParams: object): void {
this.router.navigateByUrl('/', {skipLocationChange: true}).then(() =>
this.router.navigate([uri], queryParams));
this.api.getUserInfo().subscribe(data=>{console.log(data)});
}
}

View File

@ -1,7 +1,6 @@
<div id="mainComponents">
<app-product-list numberOfProducts="20" [showProductPicture]="true" searchQuery="{{searchTerm}}"
type="search"></app-product-list>
</div>
<app-bottom-bar></app-bottom-bar>
<app-footer></app-footer>

View File

@ -1,3 +0,0 @@
<app-profile></app-profile>

View File

@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ProfilePageComponent } from './profile-page.component';
describe('ProfilePageComponent', () => {
let component: ProfilePageComponent;
let fixture: ComponentFixture<ProfilePageComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProfilePageComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(ProfilePageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@ -1,15 +0,0 @@
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 {
}
}