mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2026-05-26 12:38:03 +00:00
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6c5031c007 | |||
| e8bb639ebd | |||
| ceef01899d | |||
| 464414cbe2 | |||
| 0f19bd77cd | |||
| a3d9b826f0 | |||
| 536acc06ee | |||
| ac237a6ba1 | |||
| 058230e9a9 | |||
| f71f53c869 | |||
| 6982a139af | |||
| b0158198d4 | |||
| 7e5ef71924 | |||
| b17b92fcc3 | |||
| 0c50162fdf | |||
| 825f744af9 | |||
| e0f1724d95 | |||
| 93b17bc65f | |||
| 64074b48e8 | |||
| ee50296dc9 | |||
| 57c3f521d1 |
@@ -16,8 +16,6 @@ import {notFoundHandler} from './middleware/notFound.middleware';
|
|||||||
import {usersRouter} from './models/users/users.router';
|
import {usersRouter} from './models/users/users.router';
|
||||||
import {pricealarmsRouter} from './models/pricealarms/pricealarms.router';
|
import {pricealarmsRouter} from './models/pricealarms/pricealarms.router';
|
||||||
import {contactpersonsRouter} from './models/contact_persons/contact_persons.router';
|
import {contactpersonsRouter} from './models/contact_persons/contact_persons.router';
|
||||||
import {favoriteshopsRouter} from './models/favorite_shops/favoriteshops.router';
|
|
||||||
import {crawlingstatusRouter} from './models/crawling_status/crawling_status.router';
|
|
||||||
|
|
||||||
const cookieParser = require('cookie-parser');
|
const cookieParser = require('cookie-parser');
|
||||||
|
|
||||||
@@ -53,8 +51,6 @@ app.use('/users', usersRouter);
|
|||||||
app.use('/vendors', vendorsRouter);
|
app.use('/vendors', vendorsRouter);
|
||||||
app.use('/pricealarms', pricealarmsRouter);
|
app.use('/pricealarms', pricealarmsRouter);
|
||||||
app.use('/contactpersons', contactpersonsRouter);
|
app.use('/contactpersons', contactpersonsRouter);
|
||||||
app.use('/favoriteshops', favoriteshopsRouter);
|
|
||||||
app.use('/crawlingstatus', crawlingstatusRouter);
|
|
||||||
|
|
||||||
app.use(errorHandler);
|
app.use(errorHandler);
|
||||||
app.use(notFoundHandler);
|
app.use(notFoundHandler);
|
||||||
|
|||||||
@@ -76,9 +76,7 @@ contactpersonsRouter.post('/', async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
// Get required parameters
|
||||||
const vendor_id = req.body.vendor_id;
|
const vendor_id = req.body.vendor_id;
|
||||||
@@ -91,9 +89,9 @@ contactpersonsRouter.post('/', async (req: Request, res: Response) => {
|
|||||||
const success = await ContactPersonService.createContactEntry(user.user_id, vendor_id, first_name, last_name, gender, email, phone);
|
const success = await ContactPersonService.createContactEntry(user.user_id, vendor_id, first_name, last_name, gender, email, phone);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(201).send({});
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({});
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
@@ -106,9 +104,7 @@ contactpersonsRouter.put('/:id', async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
// Get required parameters
|
||||||
const contact_person_id = parseInt(req.params.id, 10);
|
const contact_person_id = parseInt(req.params.id, 10);
|
||||||
@@ -122,9 +118,9 @@ contactpersonsRouter.put('/:id', async (req: Request, res: Response) => {
|
|||||||
const success = await ContactPersonService.updateContactEntry(user.user_id, contact_person_id, vendor_id, first_name, last_name, gender, email, phone);
|
const success = await ContactPersonService.updateContactEntry(user.user_id, contact_person_id, vendor_id, first_name, last_name, gender, email, phone);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send({});
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({});
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
export interface Crawling_Status {
|
|
||||||
process_id: number;
|
|
||||||
started_timestamp: Date;
|
|
||||||
combinations_to_crawl: number;
|
|
||||||
successful_crawls: number;
|
|
||||||
failed_crawls: number;
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/**
|
|
||||||
* Required External Modules and Interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
import express, {Request, Response} from 'express';
|
|
||||||
import * as CrawlingStatusService from './crawling_status.service';
|
|
||||||
import {Crawling_Status} from './crawling_status.interface';
|
|
||||||
import {Crawling_Statuses} from './crawling_statuses.interface';
|
|
||||||
import * as UserService from '../users/users.service';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Router Definition
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const crawlingstatusRouter = express.Router();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller Definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
// GET crawlingstatus/
|
|
||||||
crawlingstatusRouter.get('/', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const session_id = (req.query.session_id ?? '').toString();
|
|
||||||
const session_key = (req.query.session_key ?? '').toString();
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
if (!user.is_admin) {
|
|
||||||
res.status(403).send({});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const status: Crawling_Status = await CrawlingStatusService.getCurrent();
|
|
||||||
|
|
||||||
res.status(200).send(status);
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
import * as dotenv from 'dotenv';
|
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const mariadb = require('mariadb');
|
|
||||||
const pool = mariadb.createPool({
|
|
||||||
host: process.env.DB_HOST,
|
|
||||||
user: process.env.DB_USER,
|
|
||||||
password: process.env.DB_PASSWORD,
|
|
||||||
database: process.env.DB_DATABASE,
|
|
||||||
connectionLimit: 5
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data Model Interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {Crawling_Status} from './crawling_status.interface';
|
|
||||||
import {Crawling_Statuses} from './crawling_statuses.interface';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service Methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns the current crawling status if the issuing user is an admin
|
|
||||||
*/
|
|
||||||
export const getCurrent = async (): Promise<Crawling_Status> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
|
|
||||||
// Get the current crawling process
|
|
||||||
let process_info = {
|
|
||||||
process_id: -1,
|
|
||||||
started_timestamp: new Date(),
|
|
||||||
combinations_to_crawl: -1
|
|
||||||
};
|
|
||||||
const process = await conn.query('SELECT process_id, started_timestamp, combinations_to_crawl FROM crawling_processes ORDER BY started_timestamp DESC LIMIT 1');
|
|
||||||
for (let row in process) {
|
|
||||||
if (row !== 'meta') {
|
|
||||||
process_info = process[row];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the current status
|
|
||||||
let total_crawls = 0;
|
|
||||||
let successful_crawls = 0;
|
|
||||||
const rows = await conn.query('SELECT COUNT(status_id) as total, SUM(success) as successful FROM crawling_status WHERE process_id = ?', process_info.process_id);
|
|
||||||
for (let row in rows) {
|
|
||||||
if (row !== 'meta') {
|
|
||||||
total_crawls = rows[row].total;
|
|
||||||
successful_crawls = rows[row].successful;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const failed_crawls = total_crawls - successful_crawls;
|
|
||||||
|
|
||||||
return {
|
|
||||||
process_id: process_info.process_id,
|
|
||||||
started_timestamp: process_info.started_timestamp,
|
|
||||||
combinations_to_crawl: process_info.combinations_to_crawl,
|
|
||||||
successful_crawls: successful_crawls,
|
|
||||||
failed_crawls: failed_crawls,
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import {Crawling_Status} from './crawling_status.interface';
|
|
||||||
|
|
||||||
export interface Crawling_Statuses {
|
|
||||||
[key: number]: Crawling_Status;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export interface FavoriteShop {
|
|
||||||
favorite_id: number;
|
|
||||||
vendor_id: number;
|
|
||||||
user_id: number;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import {FavoriteShop} from './favoriteshop.interface';
|
|
||||||
|
|
||||||
export interface FavoriteShops {
|
|
||||||
[key: number]: FavoriteShop;
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
/**
|
|
||||||
* Required External Modules and Interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
import express, {Request, Response} from 'express';
|
|
||||||
import * as FavoriteShopsService from './favoriteshops.service';
|
|
||||||
import {FavoriteShop} from './favoriteshop.interface';
|
|
||||||
import {FavoriteShops} from './favoriteshops.interface';
|
|
||||||
import * as UserService from '../users/users.service';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Router Definition
|
|
||||||
*/
|
|
||||||
export const favoriteshopsRouter = express.Router();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Controller Definitions
|
|
||||||
*/
|
|
||||||
|
|
||||||
//GET favoriteshops/
|
|
||||||
favoriteshopsRouter.get('/', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const session_id = (req.query.session_id ?? '').toString();
|
|
||||||
const session_key = (req.query.session_key ?? '').toString();
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
const priceAlarms = await FavoriteShopsService.getFavoriteShops(user.user_id);
|
|
||||||
|
|
||||||
res.status(200).send(priceAlarms);
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// POST favoriteshops/
|
|
||||||
favoriteshopsRouter.post('/', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const session_id = req.body.session_id;
|
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get info for price alarm creation
|
|
||||||
const vendor_id = req.body.vendor_id;
|
|
||||||
|
|
||||||
if (!vendor_id) {
|
|
||||||
// Missing
|
|
||||||
res.status(400).send(JSON.stringify({message: 'Missing parameters'}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create price alarm
|
|
||||||
const success = await FavoriteShopsService.createFavoriteShop(user.user_id, vendor_id);
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
res.status(201).send(JSON.stringify({success: true}));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DELETE favoriteshops/
|
|
||||||
favoriteshopsRouter.delete('/:id', async (req: Request, res: Response) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const session_id = (req.query.session_id ?? '').toString();
|
|
||||||
const session_key = (req.query.session_key ?? '').toString();
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get info for price alarm creation
|
|
||||||
const favorite_id = parseInt(req.params.id, 10);
|
|
||||||
|
|
||||||
if (!favorite_id) {
|
|
||||||
// Missing
|
|
||||||
res.status(400).send(JSON.stringify({message: 'Missing parameters'}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create price alarm
|
|
||||||
const success = await FavoriteShopsService.deleteFavoriteShop(user.user_id, favorite_id);
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
res.status(201).send(JSON.stringify({success: true}));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
import * as dotenv from 'dotenv';
|
|
||||||
|
|
||||||
dotenv.config();
|
|
||||||
|
|
||||||
const mariadb = require('mariadb');
|
|
||||||
const pool = mariadb.createPool({
|
|
||||||
host: process.env.DB_HOST,
|
|
||||||
user: process.env.DB_USER,
|
|
||||||
password: process.env.DB_PASSWORD,
|
|
||||||
database: process.env.DB_DATABASE,
|
|
||||||
connectionLimit: 5
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Data Model Interfaces
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {FavoriteShop} from './favoriteshop.interface';
|
|
||||||
import {FavoriteShops} from './favoriteshops.interface';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service Methods
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a favorite shop entry for the given user for the given shop
|
|
||||||
* @param user_id The id of the user to create the favorite shop entry for
|
|
||||||
* @param vendor_id The id of the vendor to set as favorite
|
|
||||||
*/
|
|
||||||
export const createFavoriteShop = async (user_id: number, vendor_id: number): Promise<boolean> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const res = await conn.query('INSERT INTO favorite_shops (vendor_id, user_id) VALUES (?, ?)', [vendor_id, user_id]);
|
|
||||||
|
|
||||||
return res.affectedRows === 1;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetches and returns all favorite shops for the given user
|
|
||||||
* @param user_id
|
|
||||||
*/
|
|
||||||
export const getFavoriteShops = async (user_id: number): Promise<FavoriteShops> => {
|
|
||||||
let conn;
|
|
||||||
let shops = [];
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const rows = await conn.query('SELECT favorite_id, vendor_id, user_id FROM favorite_shops WHERE user_id = ?', user_id);
|
|
||||||
for (let row in rows) {
|
|
||||||
if (row !== 'meta') {
|
|
||||||
shops.push(rows[row]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return shops;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the given favorite shop entry
|
|
||||||
* @param user_id The id of the user that wants to delete the favorite shop entry
|
|
||||||
* @param favorite_id The favorite shop to delete
|
|
||||||
*/
|
|
||||||
export const deleteFavoriteShop = async (user_id: number, favorite_id: number): Promise<boolean> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const res = await conn.query('DELETE FROM favorite_shops WHERE favorite_id = ? AND user_id = ?', [favorite_id, user_id]);
|
|
||||||
|
|
||||||
return res.affectedRows === 1;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -24,9 +24,7 @@ pricealarmsRouter.get('/', async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = (req.query.session_id ?? '').toString();
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = (req.query.session_key ?? '').toString();
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
const priceAlarms = await PriceAlarmsService.getPriceAlarms(user.user_id);
|
const priceAlarms = await PriceAlarmsService.getPriceAlarms(user.user_id);
|
||||||
|
|
||||||
@@ -37,14 +35,12 @@ pricealarmsRouter.get('/', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST pricealarms/
|
// POST pricealarms/create
|
||||||
pricealarmsRouter.post('/', async (req: Request, res: Response) => {
|
pricealarmsRouter.post('/', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get info for price alarm creation
|
// Get info for price alarm creation
|
||||||
const product_id = req.body.product_id;
|
const product_id = req.body.product_id;
|
||||||
@@ -72,14 +68,12 @@ pricealarmsRouter.post('/', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// PUT pricealarms/
|
// PUT pricealarms/update
|
||||||
pricealarmsRouter.put('/', async (req: Request, res: Response) => {
|
pricealarmsRouter.put('/', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get info for price alarm creation
|
// Get info for price alarm creation
|
||||||
const alarm_id = req.body.alarm_id;
|
const alarm_id = req.body.alarm_id;
|
||||||
@@ -91,37 +85,11 @@ pricealarmsRouter.put('/', async (req: Request, res: Response) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update price alarm
|
// Create price alarm
|
||||||
const success = await PriceAlarmsService.updatePriceAlarm(alarm_id, user.user_id, defined_price);
|
const success = await PriceAlarmsService.updatePriceAlarm(alarm_id, user.user_id, defined_price);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send(JSON.stringify({success: true}));
|
res.status(201).send(JSON.stringify({success: true}));
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// DELETE pricealarms/:id
|
|
||||||
pricealarmsRouter.delete('/:id', async (req, res) => {
|
|
||||||
try {
|
|
||||||
// Authenticate user
|
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
|
||||||
const session_id = (req.query.session_id ?? '').toString();
|
|
||||||
const session_key = (req.query.session_key ?? '').toString();
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
const id: number = parseInt(req.params.id, 10);
|
|
||||||
|
|
||||||
const success = await PriceAlarmsService.deletePriceAlarm(id, user.user_id);
|
|
||||||
|
|
||||||
if (success) {
|
|
||||||
res.status(200).send(JSON.stringify({success: true}));
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send(JSON.stringify({success: false}));
|
res.status(500).send(JSON.stringify({success: false}));
|
||||||
|
|||||||
@@ -29,13 +29,17 @@ import {PriceAlarms} from './pricealarms.interface';
|
|||||||
* @param product_id The id of the product to create the price alarm for
|
* @param product_id The id of the product to create the price alarm for
|
||||||
* @param defined_price The defined price for the price alarm
|
* @param defined_price The defined price for the price alarm
|
||||||
*/
|
*/
|
||||||
export const createPriceAlarm = async (user_id: number, product_id: number, defined_price: number): Promise<boolean> => {
|
export const createPriceAlarm = async (user_id: number, product_id: number, defined_price: number): Promise<Boolean> => {
|
||||||
let conn;
|
let conn;
|
||||||
try {
|
try {
|
||||||
conn = await pool.getConnection();
|
conn = await pool.getConnection();
|
||||||
const res = await conn.query('INSERT INTO price_alarms (user_id, product_id, defined_price) VALUES (?, ?, ?)', [user_id, product_id, defined_price]);
|
const res = await conn.query('INSERT INTO price_alarms (user_id, product_id, defined_price) VALUES (?, ?, ?)', [user_id, product_id, defined_price]);
|
||||||
|
|
||||||
return res.affectedRows === 1;
|
if (res.affectedRows === 1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -43,6 +47,8 @@ export const createPriceAlarm = async (user_id: number, product_id: number, defi
|
|||||||
conn.end();
|
conn.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -77,13 +83,17 @@ export const getPriceAlarms = async (user_id: number): Promise<PriceAlarms> => {
|
|||||||
* @param user_id The id of the user that wants to update the price alarm
|
* @param user_id The id of the user that wants to update the price alarm
|
||||||
* @param defined_price The defined price for the price alarm
|
* @param defined_price The defined price for the price alarm
|
||||||
*/
|
*/
|
||||||
export const updatePriceAlarm = async (alarm_id: number, user_id: number, defined_price: number): Promise<boolean> => {
|
export const updatePriceAlarm = async (alarm_id: number, user_id: number, defined_price: number): Promise<Boolean> => {
|
||||||
let conn;
|
let conn;
|
||||||
try {
|
try {
|
||||||
conn = await pool.getConnection();
|
conn = await pool.getConnection();
|
||||||
const res = await conn.query('UPDATE price_alarms SET defined_price = ? WHERE alarm_id = ? AND user_id = ?', [defined_price, alarm_id, user_id]);
|
const res = await conn.query('UPDATE price_alarms SET defined_price = ? WHERE alarm_id = ? AND user_id = ?', [defined_price, alarm_id, user_id]);
|
||||||
|
|
||||||
return res.affectedRows === 1;
|
if (res.affectedRows === 1) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throw err;
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -91,25 +101,6 @@ export const updatePriceAlarm = async (alarm_id: number, user_id: number, define
|
|||||||
conn.end();
|
conn.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
return false;
|
||||||
* Deletes the given price alarm
|
|
||||||
* @param alarm_id The id of the price alarm to update
|
|
||||||
* @param user_id The id of the user that wants to update the price alarm
|
|
||||||
*/
|
|
||||||
export const deletePriceAlarm = async (alarm_id: number, user_id: number): Promise<boolean> => {
|
|
||||||
let conn;
|
|
||||||
try {
|
|
||||||
conn = await pool.getConnection();
|
|
||||||
const res = await conn.query('DELETE FROM price_alarms WHERE alarm_id = ? AND user_id = ?', [alarm_id, user_id]);
|
|
||||||
|
|
||||||
return res.affectedRows === 1;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
} finally {
|
|
||||||
if (conn) {
|
|
||||||
conn.end();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -107,9 +107,7 @@ pricesRouter.post('/', async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
// Get required parameters
|
||||||
const vendor_id = req.body.vendor_id;
|
const vendor_id = req.body.vendor_id;
|
||||||
@@ -119,9 +117,9 @@ pricesRouter.post('/', async (req: Request, res: Response) => {
|
|||||||
const success = await PriceService.createPriceEntry(user.user_id, vendor_id, product_id, price_in_cents);
|
const success = await PriceService.createPriceEntry(user.user_id, vendor_id, product_id, price_in_cents);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(201).send({});
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({});
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
|
|||||||
@@ -282,11 +282,11 @@ export const getBestDeals = async (amount: number): Promise<Prices> => {
|
|||||||
'price_in_cents': lowestPrice.price_in_cents,
|
'price_in_cents': lowestPrice.price_in_cents,
|
||||||
'timestamp': lowestPrice.timestamp,
|
'timestamp': lowestPrice.timestamp,
|
||||||
'amazonDifference': (amazonPrice.price_in_cents - lowestPrice.price_in_cents),
|
'amazonDifference': (amazonPrice.price_in_cents - lowestPrice.price_in_cents),
|
||||||
'amazonDifferencePercent': ((amazonPrice.price_in_cents / lowestPrice.price_in_cents) * 100),
|
'amazonDifferencePercent': ((1 - (lowestPrice.price_in_cents / amazonPrice.price_in_cents)) * 100),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Push only deals were the amazon price is actually higher
|
// Push only deals were the amazon price is actually higher
|
||||||
if (deal.amazonDifferencePercent > 0 && deal.amazonDifference > 0) {
|
if (deal.amazonDifferencePercent > 0) {
|
||||||
deals.push(deal as Deal);
|
deals.push(deal as Deal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,26 +106,3 @@ productsRouter.get('/vendor/:id', async (req: Request, res: Response) => {
|
|||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// POST products/
|
|
||||||
productsRouter.post('/', async (req: Request, res: Response) => {
|
|
||||||
const asin: string = req.body.asin;
|
|
||||||
|
|
||||||
if (!asin) {
|
|
||||||
res.status(400).send('Missing parameters.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const result: boolean = await ProductService.addNewProduct(asin);
|
|
||||||
|
|
||||||
if (result) {
|
|
||||||
res.status(201).send({});
|
|
||||||
} else {
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log('Error handling a request: ' + e.message);
|
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ const pool = mariadb.createPool({
|
|||||||
|
|
||||||
import {Product} from './product.interface';
|
import {Product} from './product.interface';
|
||||||
import {Products} from './products.interface';
|
import {Products} from './products.interface';
|
||||||
import * as http from 'http';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -198,32 +197,3 @@ export const findByVendor = async (id: number): Promise<Products> => {
|
|||||||
|
|
||||||
return prodRows;
|
return prodRows;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Makes a callout to a crawler instance to search for the requested product
|
|
||||||
* @param asin The amazon asin of the product to look for
|
|
||||||
*/
|
|
||||||
export const addNewProduct = async (asin: string): Promise<boolean> => {
|
|
||||||
try {
|
|
||||||
let options = {
|
|
||||||
host: 'crawl.p4ddy.com',
|
|
||||||
path: '/searchNew',
|
|
||||||
port: '443',
|
|
||||||
method: 'POST'
|
|
||||||
};
|
|
||||||
|
|
||||||
let req = http.request(options, res => {
|
|
||||||
return res.statusCode === 202;
|
|
||||||
});
|
|
||||||
req.write(JSON.stringify({
|
|
||||||
asin: asin,
|
|
||||||
key: process.env.CRAWLER_ACCESS_KEY
|
|
||||||
}));
|
|
||||||
req.end();
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
throw(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -5,5 +5,4 @@ export interface User {
|
|||||||
password_hash: string;
|
password_hash: string;
|
||||||
registration_date: Date;
|
registration_date: Date;
|
||||||
last_login_date: Date;
|
last_login_date: Date;
|
||||||
is_admin: boolean;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ usersRouter.post('/register', async (req: Request, res: Response) => {
|
|||||||
const session: Session = await UserService.createUser(username, password, email, ip);
|
const session: Session = await UserService.createUser(username, password, email, ip);
|
||||||
|
|
||||||
// Send the session details back to the user
|
// Send the session details back to the user
|
||||||
res.status(201).send({
|
res.cookie('betterauth', JSON.stringify({
|
||||||
session_id: session.session_id,
|
id: session.session_id,
|
||||||
session_key: session.session_key
|
key: session.session_key
|
||||||
});
|
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).sendStatus(201);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||||
@@ -80,10 +80,10 @@ usersRouter.post('/login', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the session details back to the user
|
// Send the session details back to the user
|
||||||
res.status(200).send({
|
res.cookie('betterauth', JSON.stringify({
|
||||||
session_id: session.session_id,
|
id: session.session_id,
|
||||||
session_key: session.session_key
|
key: session.session_key
|
||||||
});
|
}), {expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30)}).sendStatus(200);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||||
@@ -94,17 +94,9 @@ usersRouter.post('/login', async (req: Request, res: Response) => {
|
|||||||
usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
const ip: string = req.connection.remoteAddress ?? '';
|
const ip: string = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
|
||||||
const session_key = req.body.session_key;
|
|
||||||
|
|
||||||
if(!session_id || !session_key) {
|
|
||||||
// Error logging in, probably wrong username / password
|
|
||||||
res.status(401).send(JSON.stringify({messages: ['No session detected'], codes: [5]}));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the user entry and create a session
|
// Update the user entry and create a session
|
||||||
const user: User = await UserService.checkSession(session_id, session_key, ip);
|
const user: User = await UserService.checkSessionWithCookie(req.cookies.betterauth, ip);
|
||||||
|
|
||||||
if (!user.user_id) {
|
if (!user.user_id) {
|
||||||
// Error logging in, probably wrong username / password
|
// Error logging in, probably wrong username / password
|
||||||
@@ -113,7 +105,7 @@ usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the session details back to the user
|
// Send the session details back to the user
|
||||||
res.status(200).send(user);
|
res.status(201).send(user);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
res.status(500).send(JSON.stringify({'message': 'Internal Server Error. Try again later.'}));
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ export const login = async (username: string, password: string, ip: string): Pro
|
|||||||
const sessionKeyHash = bcrypt.hashSync(sessionKey, 10);
|
const sessionKeyHash = bcrypt.hashSync(sessionKey, 10);
|
||||||
|
|
||||||
// Update user entry in SQL
|
// Update user entry in SQL
|
||||||
const userQuery = 'UPDATE users SET last_login_date = NOW() WHERE user_id = ?';
|
const userQuery = 'UPDATE users SET last_login_date = NOW()';
|
||||||
const userIdRes = await conn.query(userQuery, userId);
|
const userIdRes = await conn.query(userQuery);
|
||||||
await conn.commit();
|
await conn.commit();
|
||||||
|
|
||||||
// Create session
|
// Create session
|
||||||
@@ -193,20 +193,18 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
|||||||
await conn.commit();
|
await conn.commit();
|
||||||
|
|
||||||
// Get the other required user information and update the user
|
// Get the other required user information and update the user
|
||||||
const userQuery = 'SELECT user_id, username, email, registration_date, last_login_date, is_admin FROM users WHERE user_id = ?';
|
const userQuery = 'SELECT user_id, username, email, registration_date, last_login_date FROM users WHERE user_id = ?';
|
||||||
const userRows = await conn.query(userQuery, userId);
|
const userRows = await conn.query(userQuery, userId);
|
||||||
let username = '';
|
let username = '';
|
||||||
let email = '';
|
let email = '';
|
||||||
let registrationDate = new Date();
|
let registrationDate = new Date();
|
||||||
let lastLoginDate = new Date();
|
let lastLoginDate = new Date();
|
||||||
let is_admin = false;
|
|
||||||
for (const row in userRows) {
|
for (const row in userRows) {
|
||||||
if (row !== 'meta' && userRows[row].user_id != null) {
|
if (row !== 'meta' && userRows[row].user_id != null) {
|
||||||
username = userRows[row].username;
|
username = userRows[row].username;
|
||||||
email = userRows[row].email;
|
email = userRows[row].email;
|
||||||
registrationDate = userRows[row].registration_date;
|
registrationDate = userRows[row].registration_date;
|
||||||
lastLoginDate = userRows[row].last_login_date;
|
lastLoginDate = userRows[row].last_login_date;
|
||||||
is_admin = userRows[row].is_admin;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +215,7 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
|||||||
email: email,
|
email: email,
|
||||||
password_hash: 'HIDDEN',
|
password_hash: 'HIDDEN',
|
||||||
registration_date: registrationDate,
|
registration_date: registrationDate,
|
||||||
last_login_date: lastLoginDate,
|
last_login_date: lastLoginDate
|
||||||
is_admin: is_admin
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -228,6 +225,8 @@ export const checkSession = async (sessionId: string, sessionKey: string, ip: st
|
|||||||
conn.end();
|
conn.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {} as User;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -313,4 +312,6 @@ export const checkUsernameAndEmail = async (username: string, email: string): Pr
|
|||||||
conn.end();
|
conn.end();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {hasProblems: true, messages: ['Internal server error'], codes: [3]};
|
||||||
};
|
};
|
||||||
|
|||||||
+13
-21
@@ -37,9 +37,7 @@ vendorsRouter.get('/managed', async (req: Request, res: Response) => {
|
|||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = (req.query.session_id ?? '').toString();
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = (req.query.session_key ?? '').toString();
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
const vendors = await VendorService.getManagedShops(user.user_id);
|
const vendors = await VendorService.getManagedShops(user.user_id);
|
||||||
|
|
||||||
@@ -88,14 +86,12 @@ vendorsRouter.get('/search/:term', async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// PUT vendors/manage/deactivatelisting
|
// PUT /manage/deactivatelisting
|
||||||
vendorsRouter.put('/manage/deactivatelisting', async (req: Request, res: Response) => {
|
vendorsRouter.put('/manage/deactivatelisting', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
// Get required parameters
|
||||||
const vendor_id = req.body.vendor_id;
|
const vendor_id = req.body.vendor_id;
|
||||||
@@ -104,9 +100,9 @@ vendorsRouter.put('/manage/deactivatelisting', async (req: Request, res: Respons
|
|||||||
const success = await VendorService.deactivateListing(user.user_id, vendor_id, product_id);
|
const success = await VendorService.deactivateListing(user.user_id, vendor_id, product_id);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send({});
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({});
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
@@ -114,14 +110,12 @@ vendorsRouter.put('/manage/deactivatelisting', async (req: Request, res: Respons
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// PUT vendors/manage/shop/deactivate/:id
|
// PUT /manage/shop/deactivate/:id
|
||||||
vendorsRouter.put('/manage/shop/deactivate/:id', async (req: Request, res: Response) => {
|
vendorsRouter.put('/manage/shop/deactivate/:id', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
// Get required parameters
|
||||||
const vendor_id = parseInt(req.params.id, 10);
|
const vendor_id = parseInt(req.params.id, 10);
|
||||||
@@ -129,9 +123,9 @@ vendorsRouter.put('/manage/shop/deactivate/:id', async (req: Request, res: Respo
|
|||||||
const success = await VendorService.setShopStatus(user.user_id, vendor_id, false);
|
const success = await VendorService.setShopStatus(user.user_id, vendor_id, false);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send({});
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({});
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
@@ -139,14 +133,12 @@ vendorsRouter.put('/manage/shop/deactivate/:id', async (req: Request, res: Respo
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// PUT vendors/manage/shop/activate/:id
|
// PUT /manage/shop/activate/:id
|
||||||
vendorsRouter.put('/manage/shop/activate/:id', async (req: Request, res: Response) => {
|
vendorsRouter.put('/manage/shop/activate/:id', async (req: Request, res: Response) => {
|
||||||
try {
|
try {
|
||||||
// Authenticate user
|
// Authenticate user
|
||||||
const user_ip = req.connection.remoteAddress ?? '';
|
const user_ip = req.connection.remoteAddress ?? '';
|
||||||
const session_id = req.body.session_id;
|
const user = await UserService.checkSessionWithCookie(req.cookies.betterauth, user_ip);
|
||||||
const session_key = req.body.session_key;
|
|
||||||
const user = await UserService.checkSession(session_id, session_key, user_ip);
|
|
||||||
|
|
||||||
// Get required parameters
|
// Get required parameters
|
||||||
const vendor_id = parseInt(req.params.id, 10);
|
const vendor_id = parseInt(req.params.id, 10);
|
||||||
@@ -154,9 +146,9 @@ vendorsRouter.put('/manage/shop/activate/:id', async (req: Request, res: Respons
|
|||||||
const success = await VendorService.setShopStatus(user.user_id, vendor_id, true);
|
const success = await VendorService.setShopStatus(user.user_id, vendor_id, true);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
res.status(200).send({});
|
res.sendStatus(200);
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send({});
|
res.sendStatus(500);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('Error handling a request: ' + e.message);
|
console.log('Error handling a request: ' + e.message);
|
||||||
|
|||||||
+2
-2
@@ -1,10 +1,10 @@
|
|||||||
# Base image
|
# Base image
|
||||||
FROM python:3.9.5-buster
|
FROM python
|
||||||
|
|
||||||
# Create directories and copy files
|
# Create directories and copy files
|
||||||
RUN echo 'Creating directory and copying files'
|
RUN echo 'Creating directory and copying files'
|
||||||
RUN mkdir /crawler
|
RUN mkdir /crawler
|
||||||
COPY . /crawler
|
ADD . /crawler
|
||||||
WORKDIR /crawler
|
WORKDIR /crawler
|
||||||
|
|
||||||
# Install dependencies
|
# Install dependencies
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ import stepdefs.Preconditions;
|
|||||||
@RunWith(Cucumber.class)
|
@RunWith(Cucumber.class)
|
||||||
@CucumberOptions(
|
@CucumberOptions(
|
||||||
features = {"src/test/resource/searchProduct.feature",
|
features = {"src/test/resource/searchProduct.feature",
|
||||||
"src/test/resource/priceAlarms.feature",
|
"src/test/resource/priceAlarms.feature"}
|
||||||
"src/test/resource/favoriteShopList.feature",
|
|
||||||
"src/test/resource/manageVendor.feature"}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
public class RunTest {
|
public class RunTest {
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package stepdefs;
|
|
||||||
|
|
||||||
import io.cucumber.java.en.Given;
|
|
||||||
import io.cucumber.java.en.Then;
|
|
||||||
import io.cucumber.java.en.When;
|
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebElement;
|
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
|
|
||||||
public class FavoriteShopList {
|
|
||||||
@Given("^the user has at least (\\d+) favorite shop$")
|
|
||||||
public void the_user_has_at_least_favorite_shop(int arg1) throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Then("^the profile page should open$")
|
|
||||||
public void the_profile_page_should_open() throws Exception {
|
|
||||||
WebElement profile_info_text = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("table.table.table-hover")));
|
|
||||||
assert(profile_info_text.isDisplayed());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Then("^he should see his favorite shops list$")
|
|
||||||
public void he_should_see_his_favorite_shops_list() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@When("^he clicks on delete a favorite shop entry$")
|
|
||||||
public void he_clicks_on_delete_a_favorite_shop_entry() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Then("^the favorite shop entry should be deleted$")
|
|
||||||
public void the_favorite_shop_entry_should_be_deleted() throws Exception {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
package stepdefs;
|
|
||||||
|
|
||||||
import io.cucumber.java.en.Given;
|
|
||||||
import io.cucumber.java.en.Then;
|
|
||||||
import io.cucumber.java.en.When;
|
|
||||||
|
|
||||||
public class ManageVendor {
|
|
||||||
@Given("^the user is logged in as vendor manager$")
|
|
||||||
public void the_user_is_logged_in_as_vendor_manager() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@When("^the user opens the shop managing page$")
|
|
||||||
public void the_user_opens_the_shop_managing_page() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@When("^the user clicks on deactivate a listing$")
|
|
||||||
public void the_user_clicks_on_deactivate_a_listing() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Then("^the listing should be deactivated$")
|
|
||||||
public void the_listing_should_be_deactivated() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@When("^the user clicks on deactivate the shop$")
|
|
||||||
public void the_user_clicks_on_deactivate_the_shop() throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Then("^the shop and all related listings should be deactivated$")
|
|
||||||
public void the_shop_and_all_related_listings_should_be_deactivated() throws Exception {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,5 +4,4 @@ import org.openqa.selenium.WebDriver;
|
|||||||
|
|
||||||
public class Preconditions {
|
public class Preconditions {
|
||||||
public static WebDriver driver;
|
public static WebDriver driver;
|
||||||
public static final int delaySeconds = 7;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,12 +4,6 @@ import io.cucumber.java.PendingException;
|
|||||||
import io.cucumber.java.en.Given;
|
import io.cucumber.java.en.Given;
|
||||||
import io.cucumber.java.en.Then;
|
import io.cucumber.java.en.Then;
|
||||||
import io.cucumber.java.en.When;
|
import io.cucumber.java.en.When;
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.openqa.selenium.WebElement;
|
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PriceAlarm {
|
public class PriceAlarm {
|
||||||
@Given("^the user has at least (\\d+) price alarm set$")
|
@Given("^the user has at least (\\d+) price alarm set$")
|
||||||
@@ -18,43 +12,42 @@ public class PriceAlarm {
|
|||||||
|
|
||||||
@When("^the user clicks on the profile icon$")
|
@When("^the user clicks on the profile icon$")
|
||||||
public void the_user_clicks_on_the_profile_icon() throws Exception {
|
public void the_user_clicks_on_the_profile_icon() throws Exception {
|
||||||
WebElement profileButton = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
}
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(text(),'profile')]")));
|
|
||||||
profileButton.click();
|
@Then("^the profile details popup should open$")
|
||||||
|
public void the_profile_details_popup_should_open() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@When("^the user clicks on price alarms$")
|
||||||
|
public void the_user_clicks_on_price_alarms() throws Exception {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Then("^the price alarm list should open$")
|
||||||
|
public void the_price_alarm_list_should_open() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm list should contain at least (\\d+) entry$")
|
@Then("^the price alarm list should contain at least (\\d+) entry$")
|
||||||
public void the_price_alarm_list_should_contain_at_least_entry(int arg1) throws Exception {
|
public void the_price_alarm_list_should_contain_at_least_entry(int arg1) throws Exception {
|
||||||
WebElement alarmEntry = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("table.table.table-hover tr:nth-child(2)")));
|
|
||||||
|
|
||||||
assert (alarmEntry != null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Given("^the user is on the profile page$")
|
@Then("^the price alarm list should contain a maximum of (\\d+) entries per page$")
|
||||||
public void the_user_is_on_the_profile_page() throws Exception {
|
public void the_price_alarm_list_should_contain_a_maximum_of_entries_per_page(int arg1) throws Exception {
|
||||||
Preconditions.driver.get("https://www.betterzon.xyz/profile");
|
}
|
||||||
|
|
||||||
WebElement profile_info_text = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
@Given("^the user is on the price alarm list page$")
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("table.table.table-user-information")));
|
public void the_user_is_on_the_price_alarm_list_page() throws Exception {
|
||||||
assert (profile_info_text.isDisplayed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user clicks on the \"([^\"]*)\" button next to a price alarm$")
|
@When("^the user clicks on the \"([^\"]*)\" button next to a price alarm$")
|
||||||
public void the_user_clicks_on_the_button_next_to_a_price_alarm(String arg1) throws Exception {
|
public void the_user_clicks_on_the_button_next_to_a_price_alarm(String arg1) throws Exception {
|
||||||
if (arg1.equals("remove")) {
|
|
||||||
WebElement entry = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("table.table.table-hover tr:nth-child(2)")));
|
|
||||||
|
|
||||||
if (entry == null) {
|
|
||||||
throw new Exception("Too few price alarm entries found!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WebElement btn = entry.findElement(By.cssSelector("img.delete[src='../assets/images/Delete_icon-icons.com_55931.png']"));
|
@Then("^a popup should open asking the user to confirm the removal$")
|
||||||
|
public void a_popup_should_open_asking_the_user_to_confirm_the_removal() throws Exception {
|
||||||
btn.click();
|
|
||||||
} else if (arg1.equals("edit")) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@When("^the user confirms the removal of the price alarm$")
|
||||||
|
public void the_user_confirms_the_removal_of_the_price_alarm() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the price alarm should be removed from the database$")
|
@Then("^the price alarm should be removed from the database$")
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import io.cucumber.java.PendingException;
|
|||||||
import io.cucumber.java.en.Given;
|
import io.cucumber.java.en.Given;
|
||||||
import io.cucumber.java.en.Then;
|
import io.cucumber.java.en.Then;
|
||||||
import io.cucumber.java.en.When;
|
import io.cucumber.java.en.When;
|
||||||
import org.openqa.selenium.*;
|
import org.openqa.selenium.By;
|
||||||
|
import org.openqa.selenium.Keys;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.ui.ExpectedConditions;
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
import org.openqa.selenium.support.ui.WebDriverWait;
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
@@ -13,8 +15,8 @@ public class SearchProduct {
|
|||||||
public void the_user_is_on_the_landing_page() throws Exception {
|
public void the_user_is_on_the_landing_page() throws Exception {
|
||||||
//throw new PendingException();
|
//throw new PendingException();
|
||||||
Preconditions.driver.get("https://betterzon.xyz");
|
Preconditions.driver.get("https://betterzon.xyz");
|
||||||
WebElement logo = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
WebElement logo = (new WebDriverWait(Preconditions.driver, 10))
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("a.navbar-brand")));
|
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".logo")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user enters the search term \"([^\"]*)\" and clicks search$")
|
@When("^the user enters the search term \"([^\"]*)\" and clicks search$")
|
||||||
@@ -22,99 +24,49 @@ public class SearchProduct {
|
|||||||
WebElement searchField = Preconditions.driver.findElement(By.cssSelector(".ng-untouched.ng-pristine.ng-valid"));
|
WebElement searchField = Preconditions.driver.findElement(By.cssSelector(".ng-untouched.ng-pristine.ng-valid"));
|
||||||
searchField.sendKeys(searchTerm);
|
searchField.sendKeys(searchTerm);
|
||||||
searchField.sendKeys(Keys.ENTER);
|
searchField.sendKeys(Keys.ENTER);
|
||||||
WebElement logo = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
WebElement logo = (new WebDriverWait(Preconditions.driver, 10))
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".navbar-brand")));
|
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".logo")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should see the error page \"([^\"]*)\"$")
|
@Then("^the user should see the error page \"([^\"]*)\"$")
|
||||||
public void the_user_should_see_the_error_page(String arg0) throws Exception {
|
public void the_user_should_see_the_error_page(String arg0) throws Exception {
|
||||||
WebElement noProdsFoundMsg = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
WebElement noProdsFoundMsg = (new WebDriverWait(Preconditions.driver, 10))
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(text(),'No Products found!')]")));
|
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".ng-star-inserted")));
|
||||||
assert (noProdsFoundMsg.isDisplayed());
|
assert(noProdsFoundMsg.getText().contains("No Products found!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Given("^the user is not logged in$")
|
@Given("^the user is not logged in$")
|
||||||
public void the_user_is_not_logged_in() throws Exception {
|
public void the_user_is_not_logged_in() throws Exception {
|
||||||
try {
|
|
||||||
WebElement logoutButton = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(text(),'log out')]")));
|
|
||||||
|
|
||||||
logoutButton.click();
|
|
||||||
} catch (TimeoutException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Given("^the user is logged in$")
|
@Given("^the user is logged in$")
|
||||||
public void the_user_is_logged_in() throws Exception {
|
public void the_user_is_logged_in() throws Exception {
|
||||||
try {
|
|
||||||
WebElement loginButton = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[contains(text(),'sign in')]")));
|
|
||||||
loginButton.click();
|
|
||||||
|
|
||||||
WebElement usernameField = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.id("username")));
|
|
||||||
usernameField.sendKeys("Selenium");
|
|
||||||
|
|
||||||
WebElement passwordField = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.id("password")));
|
|
||||||
passwordField.sendKeys("Selenium");
|
|
||||||
|
|
||||||
WebElement loginBtn = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.className("btn_signin")));
|
|
||||||
loginBtn.click();
|
|
||||||
|
|
||||||
} catch (TimeoutException e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should see a list of products$")
|
@Then("^the user should see a list of products$")
|
||||||
public void the_user_should_see_a_list_of_products() throws Exception {
|
public void the_user_should_see_a_list_of_products() throws Exception {
|
||||||
WebElement product = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
WebElement product = (new WebDriverWait(Preconditions.driver, 10))
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".row.p-2.bg-white.border.rounded")));
|
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".productItem.ng-star-inserted")));
|
||||||
assert(product.isDisplayed());
|
assert(product.isDisplayed());
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user clicks on the first product$")
|
@When("^the user clicks on the first product$")
|
||||||
public void the_user_clicks_on_the_first_product() throws Exception {
|
public void the_user_clicks_on_the_first_product() throws Exception {
|
||||||
WebElement productDetailsBtn = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".row.p-2.bg-white.border.rounded button.btn.btn-primary.btn-sm")));
|
|
||||||
productDetailsBtn.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should see the product detail page$")
|
@Then("^the user should see the product detail page$")
|
||||||
public void the_user_should_see_the_product_detail_page() throws Exception {
|
public void the_user_should_see_the_product_detail_page() throws Exception {
|
||||||
WebElement productTitle = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.productTitle")));
|
|
||||||
assert (productTitle.isDisplayed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the set price alarm box should show \"([^\"]*)\"$")
|
@Then("^the set price alarm box should show \"([^\"]*)\"$")
|
||||||
public void the_set_price_alarm_box_should_show(String arg0) throws Exception {
|
public void the_set_price_alarm_box_should_show(String arg0) throws Exception {
|
||||||
WebElement alarmBox = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.priceAlarm")));
|
|
||||||
if (arg0.equals("Login to set a price alarm")) {
|
|
||||||
assert (alarmBox.getText().equals("Login to set a price alarm"));
|
|
||||||
} else {
|
|
||||||
assert (alarmBox.isDisplayed());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@When("^the user sets a price alarm$")
|
@When("^the user sets a price alarm$")
|
||||||
public void the_user_sets_a_price_alarm() throws Exception {
|
public void the_user_sets_a_price_alarm() throws Exception {
|
||||||
WebElement alarmBoxField = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.priceAlarm input")));
|
|
||||||
alarmBoxField.sendKeys("12345");
|
|
||||||
WebElement alarmBox = (new WebDriverWait(Preconditions.driver, Preconditions.delaySeconds))
|
|
||||||
.until(ExpectedConditions.elementToBeClickable(By.cssSelector("div.priceAlarm")));
|
|
||||||
alarmBox.click();
|
|
||||||
|
|
||||||
assert (alarmBox.isDisplayed() && alarmBoxField.isDisplayed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Then("^the user should receive an email confirming the price alarm$")
|
@Then("^the user should receive an email confirming the price alarm$")
|
||||||
public void the_user_should_receive_an_email_confirming_the_price_alarm() throws Exception {
|
public void the_user_should_receive_an_email_confirming_the_price_alarm() throws Exception {
|
||||||
assert (true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
Feature: Favorite Shop List
|
|
||||||
|
|
||||||
Scenario: Access Favorite Shop List
|
|
||||||
Given the user is on the landing page
|
|
||||||
And the user is logged in
|
|
||||||
And the user has at least 1 favorite shop
|
|
||||||
When the user clicks on the profile icon
|
|
||||||
Then the profile page should open
|
|
||||||
Then he should see his favorite shops list
|
|
||||||
|
|
||||||
Scenario: Remove Favorite Shop Entry
|
|
||||||
Given the user is on the landing page
|
|
||||||
And the user is logged in
|
|
||||||
And the user has at least 1 favorite shop
|
|
||||||
When the user clicks on the profile icon
|
|
||||||
Then the profile page should open
|
|
||||||
When he clicks on delete a favorite shop entry
|
|
||||||
Then the favorite shop entry should be deleted
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
Feature: Manage Vendor Shop
|
|
||||||
|
|
||||||
Scenario: Deactivate Product Listing
|
|
||||||
Given the user is on the landing page
|
|
||||||
And the user is logged in as vendor manager
|
|
||||||
When the user opens the shop managing page
|
|
||||||
And the user clicks on deactivate a listing
|
|
||||||
Then the listing should be deactivated
|
|
||||||
|
|
||||||
Scenario: Deactivate Shop Completely
|
|
||||||
Given the user is on the landing page
|
|
||||||
And the user is logged in as vendor manager
|
|
||||||
When the user opens the shop managing page
|
|
||||||
And the user clicks on deactivate the shop
|
|
||||||
Then the shop and all related listings should be deactivated
|
|
||||||
@@ -5,22 +5,23 @@ Feature: Price Alarms
|
|||||||
And the user is logged in
|
And the user is logged in
|
||||||
And the user has at least 1 price alarm set
|
And the user has at least 1 price alarm set
|
||||||
When the user clicks on the profile icon
|
When the user clicks on the profile icon
|
||||||
Then the profile page should open
|
Then the profile details popup should open
|
||||||
|
When the user clicks on price alarms
|
||||||
|
Then the price alarm list should open
|
||||||
And the price alarm list should contain at least 1 entry
|
And the price alarm list should contain at least 1 entry
|
||||||
|
And the price alarm list should contain a maximum of 20 entries per page
|
||||||
|
|
||||||
Scenario: Remove a price alarm
|
Scenario: Remove a price alarm
|
||||||
Given the user is on the landing page
|
Given the user is on the price alarm list page
|
||||||
And the user is logged in
|
And the user is logged in
|
||||||
When the user clicks on the profile icon
|
|
||||||
Then the profile page should open
|
|
||||||
When the user clicks on the "remove" button next to a price alarm
|
When the user clicks on the "remove" button next to a price alarm
|
||||||
|
Then a popup should open asking the user to confirm the removal
|
||||||
|
When the user confirms the removal of the price alarm
|
||||||
Then the price alarm should be removed from the database
|
Then the price alarm should be removed from the database
|
||||||
|
|
||||||
Scenario: Edit a price alarm
|
Scenario: Edit a price alarm
|
||||||
Given the user is on the landing page
|
Given the user is on the price alarm list page
|
||||||
And the user is logged in
|
And the user is logged in
|
||||||
When the user clicks on the profile icon
|
|
||||||
Then the profile page should open
|
|
||||||
When the user clicks on the "edit" button next to a price alarm
|
When the user clicks on the "edit" button next to a price alarm
|
||||||
Then a popup should open where the user can edit the alarm
|
Then a popup should open where the user can edit the alarm
|
||||||
When the user clicks on the "save changes" button
|
When the user clicks on the "save changes" button
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ Feature: Search a Product
|
|||||||
Then the user should see a list of products
|
Then the user should see a list of products
|
||||||
When the user clicks on the first product
|
When the user clicks on the first product
|
||||||
Then the user should see the product detail page
|
Then the user should see the product detail page
|
||||||
And the set price alarm box should show "Login to set a price alarm"
|
And the set price alarm box should show "Log in to continue"
|
||||||
|
|
||||||
Scenario: User is logged in, searches for known product
|
Scenario: User is logged in, searches for known product
|
||||||
Given the user is on the landing page
|
Given the user is on the landing page
|
||||||
|
|||||||
@@ -92,8 +92,7 @@
|
|||||||
"karmaConfig": "karma.conf.js",
|
"karmaConfig": "karma.conf.js",
|
||||||
"codeCoverage": true,
|
"codeCoverage": true,
|
||||||
"codeCoverageExclude": [
|
"codeCoverageExclude": [
|
||||||
"src/app/mocks/mock.service.ts",
|
"src/app/mocks/mock.service.ts"
|
||||||
"src/app/services/api.service.ts"
|
|
||||||
],
|
],
|
||||||
"assets": [
|
"assets": [
|
||||||
"src/favicon.ico",
|
"src/favicon.ico",
|
||||||
|
|||||||
@@ -14,10 +14,7 @@ module.exports = function (config) {
|
|||||||
require('@angular-devkit/build-angular/plugins/karma')
|
require('@angular-devkit/build-angular/plugins/karma')
|
||||||
],
|
],
|
||||||
client: {
|
client: {
|
||||||
clearContext: false, // leave Jasmine Spec Runner output visible in browser
|
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
||||||
jasmine: {
|
|
||||||
random: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
coverageIstanbulReporter: {
|
coverageIstanbulReporter: {
|
||||||
dir: require('path').join(__dirname, './coverage/Betterzon'),
|
dir: require('path').join(__dirname, './coverage/Betterzon'),
|
||||||
|
|||||||
Generated
+5241
-6517
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,7 @@
|
|||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"test": "ng test",
|
"test": "ng test",
|
||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"e2e": "ng e2e",
|
"e2e": "ng e2e"
|
||||||
"postinstall": "ngcc"
|
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,10 +1 @@
|
|||||||
.wrapper_app {
|
|
||||||
padding-bottom: 2.5rem; /* Footer height */
|
|
||||||
}
|
|
||||||
|
|
||||||
.footer_app {
|
|
||||||
position: relative;
|
|
||||||
bottom: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 2.5rem; /* Footer height */
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<app-top-bar></app-top-bar>
|
||||||
|
</div>
|
||||||
|
<div class="page-content">
|
||||||
<router-outlet></router-outlet>
|
<router-outlet></router-outlet>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<app-bottom-bar></app-bottom-bar>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
import {AppComponent} from './app.component';
|
import {AppComponent} from './app.component';
|
||||||
import {RouterTestingModule} from '@angular/router/testing';
|
import {RouterTestingModule} from "@angular/router/testing";
|
||||||
import {NgcCookieConsentConfig, NgcCookieConsentModule} from 'ngx-cookieconsent';
|
import {NgcCookieConsentConfig, NgcCookieConsentModule} from "ngx-cookieconsent";
|
||||||
import {FormsModule} from '@angular/forms';
|
import {FormsModule} from "@angular/forms";
|
||||||
|
|
||||||
// For cookie consent module testing
|
// For cookie consent module testing
|
||||||
const cookieConfig: NgcCookieConsentConfig = {
|
const cookieConfig: NgcCookieConsentConfig = {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import {Component, OnDestroy, OnInit} from '@angular/core';
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
||||||
import {NgcCookieConsentService, NgcInitializeEvent, NgcNoCookieLawEvent, NgcStatusChangeEvent} from 'ngx-cookieconsent';
|
import {NgcCookieConsentService, NgcInitializeEvent, NgcNoCookieLawEvent, NgcStatusChangeEvent} from 'ngx-cookieconsent';
|
||||||
import {Subscription} from 'rxjs';
|
import {Subscription} from 'rxjs';
|
||||||
import {ApiService} from './services/api.service';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
@@ -21,17 +19,12 @@ export class AppComponent implements OnInit, OnDestroy {
|
|||||||
private revokeChoiceSubscription: Subscription;
|
private revokeChoiceSubscription: Subscription;
|
||||||
private noCookieLawSubscription: Subscription;
|
private noCookieLawSubscription: Subscription;
|
||||||
|
|
||||||
isLoggedIn = false;
|
|
||||||
showUserBoard = false;
|
|
||||||
username?: string;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private ccService: NgcCookieConsentService
|
private ccService: NgcCookieConsentService
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
// subscribe to cookieconsent observables to react to main events
|
// subscribe to cookieconsent observables to react to main events
|
||||||
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(
|
this.popupOpenSubscription = this.ccService.popupOpen$.subscribe(
|
||||||
() => {
|
() => {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import {NgApexchartsModule} from 'ng-apexcharts';
|
|||||||
import {ProductSearchPageComponent} from './pages/product-search-page/product-search-page.component';
|
import {ProductSearchPageComponent} from './pages/product-search-page/product-search-page.component';
|
||||||
import {HeaderComponent} from './components/header/header.component';
|
import {HeaderComponent} from './components/header/header.component';
|
||||||
import {NewestPricesListComponent} from './components/newest-prices-list/newest-prices-list.component';
|
import {NewestPricesListComponent} from './components/newest-prices-list/newest-prices-list.component';
|
||||||
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
|
import {FormsModule} from '@angular/forms';
|
||||||
import {PageNotFoundPageComponent} from './pages/page-not-found-page/page-not-found-page.component';
|
import {PageNotFoundPageComponent} from './pages/page-not-found-page/page-not-found-page.component';
|
||||||
import {MatMenuModule} from '@angular/material/menu';
|
import {MatMenuModule} from '@angular/material/menu';
|
||||||
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
|
||||||
@@ -23,23 +23,15 @@ import {NgcCookieConsentModule, NgcCookieConsentConfig} from 'ngx-cookieconsent'
|
|||||||
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
import {MatSlideToggleModule} from '@angular/material/slide-toggle';
|
||||||
import {TopBarComponent} from './components/top-bar/top-bar.component';
|
import {TopBarComponent} from './components/top-bar/top-bar.component';
|
||||||
import {RouterModule} from '@angular/router';
|
import {RouterModule} from '@angular/router';
|
||||||
import {MatButtonModule} from '@angular/material/button';
|
import {MatButtonModule} from "@angular/material/button";
|
||||||
import {MatToolbarModule} from '@angular/material/toolbar';
|
import {MatToolbarModule} from '@angular/material/toolbar';
|
||||||
import {MatIconModule} from '@angular/material/icon';
|
import {MatIconModule} from '@angular/material/icon';
|
||||||
import {MatSidenavModule} from '@angular/material/sidenav';
|
import {MatSidenavModule} from '@angular/material/sidenav';
|
||||||
import {MatListModule} from '@angular/material/list';
|
import {MatListModule} from "@angular/material/list";
|
||||||
import {BottomBarComponent} from './components/bottom-bar/bottom-bar.component';
|
import {BottomBarComponent} from './components/bottom-bar/bottom-bar.component';
|
||||||
import { HotDealsWidgetComponent } from './components/hot-deals-widget/hot-deals-widget.component';
|
import { HotDealsWidgetComponent } from './components/hot-deals-widget/hot-deals-widget.component';
|
||||||
import { SliderForProductsComponent } from './components/slider-for-products/slider-for-products.component';
|
import { SliderForProductsComponent } from './components/slider-for-products/slider-for-products.component';
|
||||||
import {RegistrationComponent} from './components/auth/registration/registration.component';
|
|
||||||
import {MatCardModule} from '@angular/material/card';
|
|
||||||
import {SigninComponent} from './components/auth/signin/signin.component';
|
|
||||||
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 './pages/profile/profile.component';
|
|
||||||
import {ProfilePageComponent} from './pages/profile-page/profile-page.component';
|
|
||||||
|
|
||||||
// For cookie popup
|
// For cookie popup
|
||||||
const cookieConfig: NgcCookieConsentConfig = {
|
const cookieConfig: NgcCookieConsentConfig = {
|
||||||
@@ -97,15 +89,7 @@ const cookieConfig: NgcCookieConsentConfig = {
|
|||||||
TopBarComponent,
|
TopBarComponent,
|
||||||
BottomBarComponent,
|
BottomBarComponent,
|
||||||
HotDealsWidgetComponent,
|
HotDealsWidgetComponent,
|
||||||
SliderForProductsComponent,
|
SliderForProductsComponent
|
||||||
RegistrationComponent,
|
|
||||||
SigninComponent,
|
|
||||||
CopyrightComponent,
|
|
||||||
GreetingInfoSliderComponent,
|
|
||||||
KundenComponent,
|
|
||||||
AboutUsComponent,
|
|
||||||
ProfileComponent,
|
|
||||||
ProfilePageComponent,
|
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
@@ -126,8 +110,6 @@ const cookieConfig: NgcCookieConsentConfig = {
|
|||||||
RouterModule.forRoot([
|
RouterModule.forRoot([
|
||||||
{path: '', component: LandingpageComponent},
|
{path: '', component: LandingpageComponent},
|
||||||
]),
|
]),
|
||||||
MatCardModule,
|
|
||||||
ReactiveFormsModule,
|
|
||||||
],
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
|
|||||||
@@ -9,10 +9,6 @@ import {ProductSearchPageComponent} from './pages/product-search-page/product-se
|
|||||||
import {PageNotFoundPageComponent} from './pages/page-not-found-page/page-not-found-page.component';
|
import {PageNotFoundPageComponent} from './pages/page-not-found-page/page-not-found-page.component';
|
||||||
import {ImprintComponent} from './pages/imprint/imprint.component';
|
import {ImprintComponent} from './pages/imprint/imprint.component';
|
||||||
import {PrivacyComponent} from './pages/privacy/privacy.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 './pages/profile/profile.component';
|
|
||||||
import {ProfilePageComponent} from './pages/profile-page/profile-page.component';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{path: '', component: LandingpageComponent, pathMatch: 'full'},
|
{path: '', component: LandingpageComponent, pathMatch: 'full'},
|
||||||
@@ -20,10 +16,6 @@ const routes: Routes = [
|
|||||||
{path: 'product/:id', component: ProductDetailPageComponent},
|
{path: 'product/:id', component: ProductDetailPageComponent},
|
||||||
{path: 'impressum', component: ImprintComponent},
|
{path: 'impressum', component: ImprintComponent},
|
||||||
{path: 'datenschutz', component: PrivacyComponent},
|
{path: 'datenschutz', component: PrivacyComponent},
|
||||||
{path: 'signin', component: SigninComponent},
|
|
||||||
{path: 'registration', component: RegistrationComponent},
|
|
||||||
{path: 'product-detail', component: ProductDetailPageComponent},
|
|
||||||
{path: 'profile', component: ProfilePageComponent},
|
|
||||||
{path: '**', component: PageNotFoundPageComponent}
|
{path: '**', component: PageNotFoundPageComponent}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
<section class="page-section bg-primary text-white mb-0" id="about">
|
|
||||||
<div class="container">
|
|
||||||
<!-- About Section Heading-->
|
|
||||||
<h2 class="page-section-heading text-center text-uppercase text-white">About</h2>
|
|
||||||
<!-- Icon Divider-->
|
|
||||||
<div class="divider-custom divider-light">
|
|
||||||
<div class="divider-custom-line"></div>
|
|
||||||
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
|
|
||||||
<div class="divider-custom-line"></div>
|
|
||||||
</div>
|
|
||||||
<!-- About Section Content-->
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-lg-4 ms-auto"><p class="lead">You follow the same passion as we do and you want to find
|
|
||||||
alternatives to the de-facto monopolist Amazon?</p></div>
|
|
||||||
<div class="col-lg-4 me-auto"><p class="lead">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.</p></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {AboutUsComponent} from './about-us.component';
|
|
||||||
|
|
||||||
describe('AboutUsComponent', () => {
|
|
||||||
let component: AboutUsComponent;
|
|
||||||
let fixture: ComponentFixture<AboutUsComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [AboutUsComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AboutUsComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-about-us',
|
|
||||||
templateUrl: './about-us.component.html',
|
|
||||||
styleUrls: ['./about-us.component.css']
|
|
||||||
})
|
|
||||||
export class AboutUsComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import {NgModule} from '@angular/core';
|
|
||||||
import {Routes, RouterModule} from '@angular/router';
|
|
||||||
import {RegistrationComponent} from './registration/registration.component';
|
|
||||||
import {SigninComponent} from './signin/signin.component';
|
|
||||||
import {ResetpasswortComponent} from './resetpasswort/resetpasswort.component';
|
|
||||||
|
|
||||||
const routes: Routes = [
|
|
||||||
{
|
|
||||||
path: 'registration',
|
|
||||||
component: RegistrationComponent
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'signin',
|
|
||||||
component: SigninComponent
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'resetpasswort',
|
|
||||||
component: ResetpasswortComponent
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [RouterModule.forChild(routes)],
|
|
||||||
exports: [RouterModule]
|
|
||||||
})
|
|
||||||
export class AuthRoutingModule {
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import {NgModule} from '@angular/core';
|
|
||||||
import {CommonModule} from '@angular/common';
|
|
||||||
|
|
||||||
import {AuthRoutingModule} from './auth-routing.module';
|
|
||||||
import {SigninComponent} from './signin/signin.component';
|
|
||||||
import {RegistrationComponent} from './registration/registration.component';
|
|
||||||
import {ResetpasswortComponent} from './resetpasswort/resetpasswort.component';
|
|
||||||
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
declarations: [SigninComponent, RegistrationComponent, ResetpasswortComponent],
|
|
||||||
imports: [
|
|
||||||
CommonModule,
|
|
||||||
AuthRoutingModule,
|
|
||||||
],
|
|
||||||
exports: [
|
|
||||||
SigninComponent,
|
|
||||||
RegistrationComponent,
|
|
||||||
ResetpasswortComponent,
|
|
||||||
],
|
|
||||||
})
|
|
||||||
export class AuthModule {
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
.main-content {
|
|
||||||
width: 50%;
|
|
||||||
border-radius: 20px;
|
|
||||||
box-shadow: 0 5px 5px rgba(0, 0, 0, .4);
|
|
||||||
margin: 5em auto;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.company__info {
|
|
||||||
background-color: #008080;
|
|
||||||
border-top-left-radius: 20px;
|
|
||||||
border-bottom-left-radius: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fa-android {
|
|
||||||
font-size: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 640px) {
|
|
||||||
.main-content {
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.company__info {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login_form {
|
|
||||||
border-top-left-radius: 20px;
|
|
||||||
border-bottom-left-radius: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (min-width: 642px) and (max-width: 800px) {
|
|
||||||
.main-content {
|
|
||||||
width: 70%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.row > h2 {
|
|
||||||
color: #008080;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login_form {
|
|
||||||
background-color: #fff;
|
|
||||||
border-top-right-radius: 20px;
|
|
||||||
border-bottom-right-radius: 20px;
|
|
||||||
border-top: 1px solid #ccc;
|
|
||||||
border-right: 1px solid #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
padding: 0 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form__input {
|
|
||||||
width: 100%;
|
|
||||||
border: 0px solid transparent;
|
|
||||||
border-radius: 0;
|
|
||||||
border-bottom: 1px solid #aaa;
|
|
||||||
padding: 1em .5em .5em;
|
|
||||||
padding-left: 2em;
|
|
||||||
outline: none;
|
|
||||||
margin: 1.5em auto;
|
|
||||||
transition: all .5s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form__input:focus {
|
|
||||||
border-bottom-color: #008080;
|
|
||||||
box-shadow: 0 0 5px rgba(0, 80, 80, .4);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn_signin {
|
|
||||||
transition: all .5s ease;
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 30px;
|
|
||||||
color: #008080;
|
|
||||||
font-weight: 600;
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid #008080;
|
|
||||||
margin-top: 1.5em;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn_signin:hover, .btn:focus {
|
|
||||||
background-color: #008080;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<div class="row main-content bg-success text-center">
|
|
||||||
<div class="col-md-4 text-center company__info">
|
|
||||||
<span class="company__logo" routerLink=""><h2><img src="assets/images/Betterzon.svg"></h2></span>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-8 col-xs-12 col-sm-12 login_form ">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<h2>Registration</h2>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<form [formGroup]="form" class="form-group" (ngSubmit)="onSubmit()">
|
|
||||||
<div class="row">
|
|
||||||
<input type="text" formControlName="username" id="username" name="username"
|
|
||||||
class="form__input" placeholder="Username">
|
|
||||||
<div *ngIf="submitted && me.username.errors" class="invalid-feedback">
|
|
||||||
<div *ngIf="me.username.errors.required">Username is required</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<!-- <span class="fa fa-lock"></span> -->
|
|
||||||
<input type="email" formControlName="email" name="email" id="email" class="form__input"
|
|
||||||
placeholder="E-Mail">
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<!-- <span class="fa fa-lock"></span> -->
|
|
||||||
<input type="password" formControlName="password" name="password" id="password"
|
|
||||||
class="form__input" placeholder="Password">
|
|
||||||
</div>
|
|
||||||
<!--
|
|
||||||
<div class="row">
|
|
||||||
<input type="password" name="password" id="password_repeated" class="form__input" placeholder="Kennwort bestätigen">
|
|
||||||
</div> -->
|
|
||||||
<div class="row">
|
|
||||||
<input type="submit" value="Sign up" class="btn_signin">
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<p>Have an account?<a href="/signin">Log In</a></p>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {RegistrationComponent} from './registration.component';
|
|
||||||
import {AbstractMockObservableService} from '../../../mocks/mock.service';
|
|
||||||
import {ApiService} from '../../../services/api.service';
|
|
||||||
import {FormBuilder, FormControl, Validators} from '@angular/forms';
|
|
||||||
import {Router} from '@angular/router';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
|
||||||
registerUser(username: string, password: string, email: string): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('RegistrationComponent', () => {
|
|
||||||
let component: RegistrationComponent;
|
|
||||||
let fixture: ComponentFixture<RegistrationComponent>;
|
|
||||||
let mockService;
|
|
||||||
let formBuilder: FormBuilder;
|
|
||||||
const router = {
|
|
||||||
navigate: jasmine.createSpy('navigate'),
|
|
||||||
routerState: jasmine.createSpy('routerState')
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
mockService = new MockApiService();
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [RegistrationComponent],
|
|
||||||
providers: [{provide: ApiService, useValue: mockService}, {provide: Router, useValue: router}, FormBuilder]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(RegistrationComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
formBuilder = TestBed.get(FormBuilder);
|
|
||||||
component.form = formBuilder.group({
|
|
||||||
recipientTypes: new FormControl(
|
|
||||||
{
|
|
||||||
value: ['mock'],
|
|
||||||
disabled: true
|
|
||||||
},
|
|
||||||
Validators.required
|
|
||||||
)
|
|
||||||
});
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
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({
|
|
||||||
selector: 'app-registration',
|
|
||||||
templateUrl: './registration.component.html',
|
|
||||||
styleUrls: ['./registration.component.css']
|
|
||||||
})
|
|
||||||
export class RegistrationComponent implements OnInit {
|
|
||||||
form: any;
|
|
||||||
loading = false;
|
|
||||||
submitted = false;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private formBuilder: FormBuilder,
|
|
||||||
private api: ApiService,
|
|
||||||
private router: Router
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.form = this.formBuilder.group({
|
|
||||||
username: ['', Validators.required],
|
|
||||||
email: ['', Validators.required],
|
|
||||||
password: ['', [
|
|
||||||
Validators.required,
|
|
||||||
Validators.minLength(8)]
|
|
||||||
],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
get me() {
|
|
||||||
return this.form.controls;
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit(): void {
|
|
||||||
this.api.registerUser(this.form.value.username, this.form.value.password, this.form.value.email).subscribe(
|
|
||||||
res => {
|
|
||||||
this.api.saveSessionInfoToLocalStorage(res);
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
<p>resetpasswort works!</p>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {ResetpasswortComponent} from './resetpasswort.component';
|
|
||||||
|
|
||||||
describe('ResetpasswortComponent', () => {
|
|
||||||
let component: ResetpasswortComponent;
|
|
||||||
let fixture: ComponentFixture<ResetpasswortComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [ResetpasswortComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(ResetpasswortComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-resetpasswort',
|
|
||||||
templateUrl: './resetpasswort.component.html',
|
|
||||||
styleUrls: ['./resetpasswort.component.css']
|
|
||||||
})
|
|
||||||
export class ResetpasswortComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
.main-content {
|
|
||||||
width: 50%;
|
|
||||||
border-radius: 20px;
|
|
||||||
box-shadow: 0 5px 5px rgba(0, 0, 0, .4);
|
|
||||||
margin: 5em auto;
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
|
|
||||||
.company__info {
|
|
||||||
background-color: #008080;
|
|
||||||
border-top-left-radius: 20px;
|
|
||||||
border-bottom-left-radius: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fa-android {
|
|
||||||
font-size: 3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 640px) {
|
|
||||||
.main-content {
|
|
||||||
width: 90%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.company__info {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login_form {
|
|
||||||
border-top-left-radius: 20px;
|
|
||||||
border-bottom-left-radius: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (min-width: 642px) and (max-width: 800px) {
|
|
||||||
.main-content {
|
|
||||||
width: 70%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.row > h2 {
|
|
||||||
color: #008080;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login_form {
|
|
||||||
background-color: #fff;
|
|
||||||
border-top-right-radius: 20px;
|
|
||||||
border-bottom-right-radius: 20px;
|
|
||||||
border-top: 1px solid #ccc;
|
|
||||||
border-right: 1px solid #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
form {
|
|
||||||
padding: 0 2em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form__input {
|
|
||||||
width: 100%;
|
|
||||||
border: 0px solid transparent;
|
|
||||||
border-radius: 0;
|
|
||||||
border-bottom: 1px solid #aaa;
|
|
||||||
padding: 1em .5em .5em;
|
|
||||||
padding-left: 2em;
|
|
||||||
outline: none;
|
|
||||||
margin: 1.5em auto;
|
|
||||||
transition: all .5s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form__input:focus {
|
|
||||||
border-bottom-color: #008080;
|
|
||||||
box-shadow: 0 0 5px rgba(0, 80, 80, .4);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn_signin {
|
|
||||||
transition: all .5s ease;
|
|
||||||
width: 100%;
|
|
||||||
border-radius: 30px;
|
|
||||||
color: #008080;
|
|
||||||
font-weight: 600;
|
|
||||||
background-color: #fff;
|
|
||||||
border: 1px solid #008080;
|
|
||||||
margin-top: 1.5em;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn_signin:hover, .btn:focus {
|
|
||||||
background-color: #008080;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<div class="container">
|
|
||||||
<div class="row main-content bg-success text-center">
|
|
||||||
<div class="col-md-4 text-center company__info">
|
|
||||||
<span class="company__logo" routerLink=""><h2><img src="assets/images/Betterzon.svg"></h2></span>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-8 col-xs-12 col-sm-12 login_form ">
|
|
||||||
<div class="container-fluid">
|
|
||||||
<div class="row">
|
|
||||||
<h2>Sign In</h2>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<form [formGroup]="loginForm" class="form-group" (ngSubmit)="onSubmit()">
|
|
||||||
<div class="row">
|
|
||||||
<input type="text" formControlName="username" name="username" id="username"
|
|
||||||
class="form__input" placeholder="Username">
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<!-- <span class="fa fa-lock"></span> -->
|
|
||||||
<input type="password" formControlName="password" name="password" id="password"
|
|
||||||
class="form__input" placeholder="Password">
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<input type="submit" value="Log in" class="btn_signin">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<p>No account yet?<a href="/registration">sign up</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {SigninComponent} from './signin.component';
|
|
||||||
import {AbstractMockObservableService} from '../../../mocks/mock.service';
|
|
||||||
import {ApiService} from '../../../services/api.service';
|
|
||||||
import {FormBuilder, FormControl, Validators} from '@angular/forms';
|
|
||||||
import {Router} from '@angular/router';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
|
||||||
loginUser(username: string, password: string): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('SigninComponent', () => {
|
|
||||||
let component: SigninComponent;
|
|
||||||
let fixture: ComponentFixture<SigninComponent>;
|
|
||||||
let mockService;
|
|
||||||
let formBuilder: FormBuilder;
|
|
||||||
const router = {
|
|
||||||
navigate: jasmine.createSpy('navigate'),
|
|
||||||
routerState: jasmine.createSpy('routerState')
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
mockService = new MockApiService();
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [SigninComponent],
|
|
||||||
providers: [{provide: ApiService, useValue: mockService}, {provide: Router, useValue: router}, FormBuilder]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(SigninComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
formBuilder = TestBed.get(FormBuilder);
|
|
||||||
component.loginForm = formBuilder.group({
|
|
||||||
recipientTypes: new FormControl(
|
|
||||||
{
|
|
||||||
value: ['mock'],
|
|
||||||
disabled: true
|
|
||||||
},
|
|
||||||
Validators.required
|
|
||||||
)
|
|
||||||
});
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
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({
|
|
||||||
selector: 'app-signin',
|
|
||||||
templateUrl: './signin.component.html',
|
|
||||||
styleUrls: ['./signin.component.css']
|
|
||||||
})
|
|
||||||
|
|
||||||
export class SigninComponent implements OnInit {
|
|
||||||
|
|
||||||
loginForm: FormGroup;
|
|
||||||
loading = false;
|
|
||||||
submitted = false;
|
|
||||||
private isSuccessful: boolean;
|
|
||||||
private isSignUpFailed: boolean;
|
|
||||||
private errorMessage: '';
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private formBuilder: FormBuilder,
|
|
||||||
private api: ApiService,
|
|
||||||
private router: Router
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.loginForm = this.formBuilder.group({
|
|
||||||
username: ['', Validators.required],
|
|
||||||
password: ['', [Validators.required, Validators.minLength(8)]]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onSubmit(): void {
|
|
||||||
this.submitted = true;
|
|
||||||
|
|
||||||
if (this.loginForm.invalid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.api.loginUser(this.loginForm.value.username, this.loginForm.value.password)
|
|
||||||
.subscribe(
|
|
||||||
data => {
|
|
||||||
this.isSuccessful = true;
|
|
||||||
this.router.navigate(['']);
|
|
||||||
this.api.saveSessionInfoToLocalStorage(data);
|
|
||||||
},
|
|
||||||
err => {
|
|
||||||
this.errorMessage = err.error.message;
|
|
||||||
this.isSignUpFailed = true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,14 +7,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.folge-uns-item {
|
.folge-uns-item {
|
||||||
grid-column: 2;
|
grid-column: 2; grid-row: 1;
|
||||||
grid-row: 1;
|
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.link-items {
|
.link-items {
|
||||||
grid-column: 2;
|
grid-column: 2; grid-row: 2;
|
||||||
grid-row: 2;
|
|
||||||
justify-self: center;
|
justify-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,13 +29,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.bottom-logo {
|
.bottom-logo {
|
||||||
grid-column: 1;
|
grid-column: 1; grid-row: 3;
|
||||||
grid-row: 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom-info {
|
.bottom-info {
|
||||||
grid-column: 3;
|
grid-column: 3; grid-row: 3;
|
||||||
grid-row: 3;
|
|
||||||
justify-self: right;
|
justify-self: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,26 @@
|
|||||||
<footer class="footer text-center">
|
<div class="bottom-bar-wrapper">
|
||||||
<div class="container">
|
<div class="folge-uns-item">
|
||||||
<div class="row">
|
<p><span id="folge">FOLGE</span><span id="uns">UNS</span></p>
|
||||||
<!-- Footer Location-->
|
</div>
|
||||||
<div class="col-lg-4 mb-5 mb-lg-0">
|
<div class="link-items">
|
||||||
<h4 class="text-uppercase mb-4">Location</h4>
|
<ul style="list-style-type:none" class="footer-links">
|
||||||
<p class="lead mb-0">
|
<li><a href="https://github.com/Mueller-Patrick/Betterzon">GiT</a></li>
|
||||||
76133 Karlsruhe
|
<li><a href="https://blog.betterzon.xyz/">BLOG</a></li>
|
||||||
<br/>
|
<li><a href="https://github.com/Mueller-Patrick/Betterzon/wiki">Wiki</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div id="footer-line">
|
||||||
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Footer Social Icons-->
|
<div class="bottom-logo">
|
||||||
<div class="col-lg-4 mb-5 mb-lg-0">
|
<p><span id="better">BETTER</span><span id="zon">ZON</span></p>
|
||||||
<h4 class="text-uppercase mb-4">FOLLOW US</h4>
|
|
||||||
<a class="btn btn-outline-light btn-social mx-1" href="https://github.com/Mueller-Patrick/Betterzon"><i
|
|
||||||
class="fab fa-fw fa-github"></i></a>
|
|
||||||
<a class="btn btn-outline-light btn-social mx-1" href="https://blog.betterzon.xyz/"><i
|
|
||||||
class="fab fa-fw fa-dribbble"></i></a>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Footer About Text-->
|
<div class="bottom-info">
|
||||||
<div class="col-lg-4">
|
<ul style="list-style-type:none" class="footer-links">
|
||||||
<h4 class="text-uppercase mb-4">CONTACT US</h4>
|
<li><a>DATENSCHUTZERKLÄRUNG</a></li>
|
||||||
<p class="lead mb-0">
|
<li><a>IMPRESSUM</a></li>
|
||||||
betterzon-contact@mueller-patrick.tech
|
</ul>
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</footer>
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import {BottomBarComponent} from './bottom-bar.component';
|
import { BottomBarComponent } from "./bottom-bar.component";
|
||||||
|
|
||||||
describe('BottomBarComponent', () => {
|
describe("BottomBarComponent", () => {
|
||||||
let component: BottomBarComponent;
|
let component: BottomBarComponent;
|
||||||
let fixture: ComponentFixture<BottomBarComponent>;
|
let fixture: ComponentFixture<BottomBarComponent>;
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ import {Component, OnInit} from '@angular/core';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-bottom-bar',
|
selector: 'app-bottom-bar',
|
||||||
templateUrl: './bottom-bar.component.html',
|
templateUrl: "./bottom-bar.component.html",
|
||||||
styleUrls: ['./bottom-bar.component.css']
|
styleUrls: ["./bottom-bar.component.css"]
|
||||||
})
|
})
|
||||||
export class BottomBarComponent implements OnInit {
|
export class BottomBarComponent implements OnInit {
|
||||||
|
|
||||||
constructor() {
|
constructor() { }
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
#imprintSection {
|
|
||||||
right: 1em;
|
|
||||||
bottom: 1em;
|
|
||||||
width: 100%;
|
|
||||||
text-align: right;
|
|
||||||
padding-right: 1em;
|
|
||||||
grid-area: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#imprintSection a {
|
|
||||||
color: white;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#copyright {
|
|
||||||
display: grid;
|
|
||||||
grid-template-areas:
|
|
||||||
'left center right';
|
|
||||||
grid-template-columns: 30% 40% 30%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#copyright-text {
|
|
||||||
grid-area: center;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<div class="copyright py-4 text-center text-white" id="copyright">
|
|
||||||
<div class="container" id="copyright-text"><small>Copyright © Betterzon 2021</small></div>
|
|
||||||
<div id="imprintSection">
|
|
||||||
<a href="/impressum">Imprint</a><br>
|
|
||||||
<a href="/datenschutz">Privacy Policy</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {CopyrightComponent} from './copyright.component';
|
|
||||||
|
|
||||||
describe('CopyrightComponent', () => {
|
|
||||||
let component: CopyrightComponent;
|
|
||||||
let fixture: ComponentFixture<CopyrightComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [CopyrightComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(CopyrightComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-copyright',
|
|
||||||
templateUrl: './copyright.component.html',
|
|
||||||
styleUrls: ['./copyright.component.css']
|
|
||||||
})
|
|
||||||
export class CopyrightComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -11,8 +11,7 @@ export class FooterComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute
|
||||||
) {
|
) {}
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
<header class="masthead bg-primary text-white text-center">
|
|
||||||
<div class="container d-flex align-items-center flex-column">
|
|
||||||
<!-- Masthead Avatar Image-->
|
|
||||||
<img class="masthead-avatar mb-5" src="assets/images/Betterzon.svg" alt="..."/>
|
|
||||||
<!-- Masthead Heading-->
|
|
||||||
<h1 class="masthead-heading text-uppercase mb-0"></h1>
|
|
||||||
<!-- Icon Divider-->
|
|
||||||
<div class="divider-custom divider-light">
|
|
||||||
<div class="divider-custom-line"></div>
|
|
||||||
<div class="divider-custom-icon"><i class="fas fa-star"></i></div>
|
|
||||||
<div class="divider-custom-line"></div>
|
|
||||||
</div>
|
|
||||||
<!-- Masthead Subheading-->
|
|
||||||
<p class="masthead-subheading font-weight-light mb-0"></p>
|
|
||||||
</div>
|
|
||||||
</header>
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {GreetingInfoSliderComponent} from './greeting-info-slider.component';
|
|
||||||
|
|
||||||
describe('GreetingInfoSliderComponent', () => {
|
|
||||||
let component: GreetingInfoSliderComponent;
|
|
||||||
let fixture: ComponentFixture<GreetingInfoSliderComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [GreetingInfoSliderComponent]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(GreetingInfoSliderComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import {Component, OnInit} from '@angular/core';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-greeting-info-slider',
|
|
||||||
templateUrl: './greeting-info-slider.component.html',
|
|
||||||
styleUrls: ['./greeting-info-slider.component.css']
|
|
||||||
})
|
|
||||||
export class GreetingInfoSliderComponent implements OnInit {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,7 @@
|
|||||||
<img src="assets/images/Betterzon.svg" alt="Betterzon Logo" width="50px" (click)="clickedLogo()">
|
<img src="assets/images/Betterzon.svg" alt="Betterzon Logo" width="50px" (click)="clickedLogo()">
|
||||||
</div>
|
</div>
|
||||||
<div class="searchBox">
|
<div class="searchBox">
|
||||||
<input *ngIf="showSearch===true" type="text" [(ngModel)]="searchInput" placeholder="Search"
|
<input *ngIf="showSearch===true" type="text" [(ngModel)]="searchInput" placeholder="Search" (keyup.enter)="startedSearch()">
|
||||||
(keyup.enter)="startedSearch()">
|
|
||||||
</div>
|
</div>
|
||||||
<div class="slider">
|
<div class="slider">
|
||||||
<mat-slide-toggle color="primary">dark me</mat-slide-toggle>
|
<mat-slide-toggle color="primary">dark me</mat-slide-toggle>
|
||||||
|
|||||||
@@ -1,97 +1,72 @@
|
|||||||
.bbb_deals_wrapper {
|
.hot-deal-widget-wrapper{
|
||||||
overflow: hidden;
|
width: 1640px;
|
||||||
|
height: 820px;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, 1fr);
|
||||||
|
grid-column-gap: 0px;
|
||||||
|
grid-row-gap: 0px;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_wrapper:hover {
|
.product-description {
|
||||||
transform: scale(1.2);
|
/*background-color: #3480E3;*/
|
||||||
|
height: 100%;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 15% 16px 15% 16px 15% 16px 15% 16px 15% 16px 15% 8px;
|
||||||
|
grid-template-rows: repeat(5, 1fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_featured {
|
.product-image {
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals {
|
#hot-deals{
|
||||||
width: 100%;
|
/*background-color: #E53167;*/
|
||||||
margin-right: 7%;
|
justify-self: center;
|
||||||
padding-top: 80px;
|
align-self: center;
|
||||||
padding-left: 25px;
|
grid-column: 3/10;
|
||||||
padding-right: 25px;
|
grid-row: 1/2;
|
||||||
padding-bottom: 34px;
|
|
||||||
box-shadow: 1px 1px 5px 1px rgba(0, 0, 0, 0.1);
|
|
||||||
border-radius: 5px;
|
|
||||||
margin-top: 0px
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_title {
|
#product-name {
|
||||||
position: absolute;
|
justify-self: center;
|
||||||
top: 10px;
|
align-self: center;
|
||||||
left: 22px;
|
grid-column: 3/10;
|
||||||
font-size: 18px;
|
grid-row: 2/3;
|
||||||
font-weight: 500;
|
/*background-color: #E53167;*/
|
||||||
color: #000000
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_slider_container {
|
#product-name > p {
|
||||||
width: 100%
|
font-size: 65px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_item {
|
#sales {
|
||||||
width: 100% !important
|
justify-self: center;
|
||||||
|
align-self: center;
|
||||||
|
grid-column: 3/10;
|
||||||
|
grid-row: 3/4;
|
||||||
|
/*background-color: #E53167;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_image {
|
#futher-informations {
|
||||||
width: 40%;
|
justify-self: center;
|
||||||
height: 40%;
|
align-self: center;
|
||||||
|
grid-column: 3/10;
|
||||||
|
grid-row: 4/5;
|
||||||
|
/*background-color: #E53167;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_image img {
|
#points {
|
||||||
width: 100%
|
justify-self: center;
|
||||||
|
align-self: start;
|
||||||
|
grid-column: 3/10;
|
||||||
|
grid-row: 5/6;
|
||||||
|
/*background-color: #E53167;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_content {
|
.product-image {
|
||||||
margin-top: 33px
|
display: grid;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bbb_deals_item_category a {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: rgba(0, 0, 0, 0.5)
|
|
||||||
}
|
|
||||||
|
|
||||||
#bbb_deals_item_price_a {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: rgba(0, 0, 0, 0.6);
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
#bbb_deals_item_price_b {
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: rgba(0, 0, 0, 0.6);
|
|
||||||
color: green;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bbb_deals_item_name {
|
|
||||||
max-width: 300px;
|
|
||||||
word-wrap: break-word;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bbb_deals_item_price {
|
|
||||||
font-size: 24px;
|
|
||||||
font-weight: 500;
|
|
||||||
color: #228B22;
|
|
||||||
}
|
|
||||||
|
|
||||||
.available {
|
|
||||||
margin-top: 19px
|
|
||||||
}
|
|
||||||
|
|
||||||
.available_title {
|
|
||||||
font-size: 16px;
|
|
||||||
color: rgba(0, 0, 0, 0.5);
|
|
||||||
font-weight: 400
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
<section class="page-section portfolio" id="top-gesuchte">
|
<div class="hot-deal-widget-wrapper">
|
||||||
<div class="container">
|
<div class="product-description">
|
||||||
<!-- Portfolio Section Heading-->
|
<div id="hot-deals">
|
||||||
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">TOP-OFFERS</h2>
|
<h1>HOT DEALS</h1>
|
||||||
<!-- Icon Divider-->
|
|
||||||
<div class="divider-custom">
|
|
||||||
<div class="divider-custom-line"></div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Portfolio Grid Items-->
|
<div id="product-name">
|
||||||
<div class="row justify-content-center">
|
<h1>Neues Apple iPhone 12 Pro <br> (512 GB) - Graphit</h1>
|
||||||
<!-- 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_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>
|
</div>
|
||||||
<div class="bbb_deals_info_line d-flex flex-row justify-content-start">
|
<div id="sales">
|
||||||
<div class="bbb_deals_item_category">Amazon: <span
|
SPARE BIS ZU 7%!
|
||||||
id="bbb_deals_item_price_a"><strike>{{productsPricesMap[productId]?.amazonPrice?.price_in_cents / 100}}
|
|
||||||
€</strike></span></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="bbb_deals_info_line d-flex flex-row justify-content-start">
|
<div id="futher-informations">
|
||||||
<div class="bbb_deals_item_category">{{productsPricesMap[productId]?.vendor?.name}}: <span
|
Weitere Informationen
|
||||||
id="bbb_deals_item_price_b">{{productsPricesMap[productId]?.lowestPrice?.price_in_cents / 100}}
|
|
||||||
€</span></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="available_bar">
|
<div id="points">
|
||||||
<span style="width:17%"></span>
|
points
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="product-image">
|
||||||
|
<img src="assets/images/iphone-12-pro-silver-hero.png" height="771">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,47 +1,14 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { HotDealsWidgetComponent } from './hot-deals-widget.component';
|
import { HotDealsWidgetComponent } from './hot-deals-widget.component';
|
||||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
|
||||||
import {ApiService} from '../../services/api.service';
|
|
||||||
import {ActivatedRoute, convertToParamMap, Router} from '@angular/router';
|
|
||||||
import {Observable, of} from 'rxjs';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
|
||||||
getBestDeals(): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
getProductsByIds(): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActivatedRouteMock {
|
|
||||||
public paramMap = of(convertToParamMap({
|
|
||||||
testId: 'abc123',
|
|
||||||
anotherId: 'd31e8b48-7309-4c83-9884-4142efdf7271',
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('HotDealsWidgetComponent', () => {
|
describe('HotDealsWidgetComponent', () => {
|
||||||
let component: HotDealsWidgetComponent;
|
let component: HotDealsWidgetComponent;
|
||||||
let fixture: ComponentFixture<HotDealsWidgetComponent>;
|
let fixture: ComponentFixture<HotDealsWidgetComponent>;
|
||||||
let mockService;
|
|
||||||
const router = {
|
|
||||||
navigate: jasmine.createSpy('navigate'),
|
|
||||||
routerState: jasmine.createSpy('routerState')
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockService = new MockApiService();
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [HotDealsWidgetComponent],
|
declarations: [ HotDealsWidgetComponent ]
|
||||||
providers: [{provide: ApiService, useValue: mockService}, {provide: Router, useValue: router}, {
|
|
||||||
provide: ActivatedRoute,
|
|
||||||
useValue: ActivatedRouteMock
|
|
||||||
}]
|
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {ApiService} from '../../services/api.service';
|
|
||||||
import {Product} from '../../models/product';
|
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-hot-deals-widget',
|
selector: 'app-hot-deals-widget',
|
||||||
@@ -10,107 +7,9 @@ import {ActivatedRoute, Router} from '@angular/router';
|
|||||||
})
|
})
|
||||||
export class HotDealsWidgetComponent implements OnInit {
|
export class HotDealsWidgetComponent implements OnInit {
|
||||||
|
|
||||||
products: Product[] = [];
|
constructor() { }
|
||||||
bestDealsProductIds = [];
|
|
||||||
amazonPrices = [];
|
|
||||||
productsPricesMap = new Map();
|
|
||||||
@Input() numberOfProducts: number;
|
|
||||||
@Input() showProductPicture: boolean;
|
|
||||||
@Input() searchQuery: string;
|
|
||||||
@Input() type: string;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private apiService: ApiService,
|
|
||||||
private router: Router,
|
|
||||||
private route: ActivatedRoute
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
|
||||||
this.getBestDeals();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loadParams(): void {
|
|
||||||
if (!this.numberOfProducts) {
|
|
||||||
this.numberOfProducts = 9;
|
|
||||||
}
|
|
||||||
if (!this.showProductPicture) {
|
|
||||||
this.showProductPicture = false;
|
|
||||||
}
|
|
||||||
if (!this.searchQuery) {
|
|
||||||
this.searchQuery = '';
|
|
||||||
}
|
|
||||||
if (!this.type) {
|
|
||||||
this.type = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (this.type) {
|
|
||||||
case 'search': {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
this.getProductsByIds();
|
|
||||||
this.getAmazonPricesForBestDeals();
|
|
||||||
this.getVendors();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getProductsByIds(): void {
|
|
||||||
this.apiService.getProductsByIds(this.bestDealsProductIds).subscribe(
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getVendors(): void {
|
|
||||||
this.bestDealsProductIds.forEach(
|
|
||||||
productId => {
|
|
||||||
const currentDeal = this.productsPricesMap[productId].lowestPrice;
|
|
||||||
this.apiService.getVendorById(currentDeal.vendor_id).subscribe(
|
|
||||||
vendor => {
|
|
||||||
this.productsPricesMap[productId].vendor = vendor;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
getAmazonPricesForBestDeals(): void {
|
|
||||||
this.bestDealsProductIds.forEach(id => {
|
|
||||||
this.apiService.getAmazonPrice(id).subscribe(
|
|
||||||
price => {
|
|
||||||
this.amazonPrices.push(price);
|
|
||||||
this.productsPricesMap[price[0].product_id].amazonPrice = price[0];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSearchedProducts(): void {
|
|
||||||
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products);
|
|
||||||
}
|
|
||||||
|
|
||||||
clickedProduct(productId: string): void {
|
|
||||||
this.router.navigate([('/product/' + productId)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
<section class="page-section portfolio" id="unsere-kunden">
|
|
||||||
<div class="container">
|
|
||||||
<!-- Portfolio Section Heading-->
|
|
||||||
<h2 class="page-section-heading text-center text-uppercase text-secondary mb-0">THEY TRUST US</h2>
|
|
||||||
<!-- Icon Divider-->
|
|
||||||
<div class="divider-custom">
|
|
||||||
<div class="divider-custom-line"></div>
|
|
||||||
</div>
|
|
||||||
<!-- Portfolio Grid Items-->
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<!-- Portfolio Item 1-->
|
|
||||||
<div class="col-md-6 col-lg-4 mb-5">
|
|
||||||
<div class="portfolio-item mx-auto" data-bs-toggle="modal" data-bs-target="#portfolioModal1">
|
|
||||||
<div class="portfolio-item-caption d-flex align-items-center justify-content-center h-100 w-100">
|
|
||||||
<div class="portfolio-item-caption-content text-center text-white"><i
|
|
||||||
class="fas fa-plus fa-3x"></i></div>
|
|
||||||
</div>
|
|
||||||
<img width="100%" class="productImage" src="assets/images/cropped-unknown-1-1.png"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 col-lg-4 mb-5">
|
|
||||||
<div class="portfolio-item mx-auto" data-bs-toggle="modal" data-bs-target="#portfolioModal1">
|
|
||||||
<div class="portfolio-item-caption d-flex align-items-center justify-content-center h-100 w-100">
|
|
||||||
<div class="portfolio-item-caption-content text-center text-white"><i
|
|
||||||
class="fas fa-plus fa-3x"></i></div>
|
|
||||||
</div>
|
|
||||||
<img width="100%" class="productImage" src="assets/images/plantshub.jpg"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 col-lg-4 mb-5">
|
|
||||||
<div class="portfolio-item mx-auto" data-bs-toggle="modal" data-bs-target="#portfolioModal1">
|
|
||||||
<div class="portfolio-item-caption d-flex align-items-center justify-content-center h-100 w-100">
|
|
||||||
<div class="portfolio-item-caption-content text-center text-white"><i
|
|
||||||
class="fas fa-plus fa-3x"></i></div>
|
|
||||||
</div>
|
|
||||||
<img width="70%" class="productImage" src="assets/images/CeangalLogo.png"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import {ComponentFixture, TestBed} from '@angular/core/testing';
|
|
||||||
|
|
||||||
import {KundenComponent} from './kunden.component';
|
|
||||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
|
||||||
import {ApiService} from '../../services/api.service';
|
|
||||||
import {ActivatedRoute, convertToParamMap, Router} from '@angular/router';
|
|
||||||
import {of} from 'rxjs';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
|
||||||
getProducts(): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ActivatedRouteMock {
|
|
||||||
public paramMap = of(convertToParamMap({
|
|
||||||
testId: 'abc123',
|
|
||||||
anotherId: 'd31e8b48-7309-4c83-9884-4142efdf7271',
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('KundenComponent', () => {
|
|
||||||
let component: KundenComponent;
|
|
||||||
let fixture: ComponentFixture<KundenComponent>;
|
|
||||||
let mockService;
|
|
||||||
const router = {
|
|
||||||
navigate: jasmine.createSpy('navigate'),
|
|
||||||
routerState: jasmine.createSpy('routerState')
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
mockService = new MockApiService();
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
declarations: [KundenComponent],
|
|
||||||
providers: [{provide: ApiService, useValue: mockService}, {provide: Router, useValue: router}, {
|
|
||||||
provide: ActivatedRoute,
|
|
||||||
useValue: ActivatedRouteMock
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(KundenComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
|
||||||
import {ApiService} from '../../services/api.service';
|
|
||||||
import {Product} from '../../models/product';
|
|
||||||
import {ActivatedRoute, Router} from '@angular/router';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-kunden',
|
|
||||||
templateUrl: './kunden.component.html',
|
|
||||||
styleUrls: ['./kunden.component.css']
|
|
||||||
})
|
|
||||||
export class KundenComponent implements OnInit {
|
|
||||||
products: Product[] = [];
|
|
||||||
@Input() numberOfProducts: number;
|
|
||||||
@Input() showProductPicture: boolean;
|
|
||||||
@Input() searchQuery: string;
|
|
||||||
@Input() type: string;
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
private apiService: ApiService,
|
|
||||||
private router: Router,
|
|
||||||
private route: ActivatedRoute
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
|
||||||
this.loadParams();
|
|
||||||
}
|
|
||||||
|
|
||||||
loadParams(): void {
|
|
||||||
if (!this.numberOfProducts) {
|
|
||||||
this.numberOfProducts = 10;
|
|
||||||
}
|
|
||||||
if (!this.showProductPicture) {
|
|
||||||
this.showProductPicture = false;
|
|
||||||
}
|
|
||||||
if (!this.searchQuery) {
|
|
||||||
this.searchQuery = '';
|
|
||||||
}
|
|
||||||
if (!this.type) {
|
|
||||||
this.type = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (this.type) {
|
|
||||||
case 'search': {
|
|
||||||
this.getSearchedProducts();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
this.getProducts();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getProducts(): void {
|
|
||||||
this.apiService.getProducts().subscribe(products => this.products = products);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSearchedProducts(): void {
|
|
||||||
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products);
|
|
||||||
}
|
|
||||||
|
|
||||||
clickedProduct(product: Product): void {
|
|
||||||
this.router.navigate([('/product/' + product.product_id)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,3 @@
|
|||||||
<header class="masthead bg-transparent text-white text-center" id="w1">
|
|
||||||
|
|
||||||
</header>
|
|
||||||
<div class="productItem">
|
<div class="productItem">
|
||||||
<div class="productImageContainer">
|
<div class="productImageContainer">
|
||||||
<img class="productImage" src="https://www.mueller-patrick.tech/betterzon/images/{{product.image_guid}}.jpg"/>
|
<img class="productImage" src="https://www.mueller-patrick.tech/betterzon/images/{{product.image_guid}}.jpg"/>
|
||||||
@@ -23,12 +20,8 @@
|
|||||||
{{product?.short_description}}
|
{{product?.short_description}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="priceAlarm" *ngIf="!isLoggedIn" routerLink="/signin">
|
<div class="priceAlarm">
|
||||||
Login to set a price alarm
|
Set Price Alarm
|
||||||
</div>
|
|
||||||
<div class="priceAlarm" *ngIf="isLoggedIn">
|
|
||||||
<input type="search" id="s" name="price" [(ngModel)]="price">
|
|
||||||
<div (click)="setPriceAlarm()">Set Price Alarm</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="bestPriceContainer">
|
<div class="bestPriceContainer">
|
||||||
<div class="bestPrice">
|
<div class="bestPrice">
|
||||||
|
|||||||
@@ -58,11 +58,6 @@ class MockApiService extends AbstractMockObservableService {
|
|||||||
this.content = [vendor];
|
this.content = [vendor];
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
getSessionInfoFromLocalStorage(): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('ProductDetailsComponent', () => {
|
describe('ProductDetailsComponent', () => {
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ export class ProductDetailsComponent implements OnInit {
|
|||||||
vendorMap = {};
|
vendorMap = {};
|
||||||
@ViewChild('chart') chart: ChartComponent;
|
@ViewChild('chart') chart: ChartComponent;
|
||||||
public chartOptions: ChartOptions;
|
public chartOptions: ChartOptions;
|
||||||
isLoggedIn: boolean;
|
|
||||||
price: any;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService
|
private apiService: ApiService
|
||||||
@@ -46,15 +44,10 @@ export class ProductDetailsComponent implements OnInit {
|
|||||||
this.getProduct();
|
this.getProduct();
|
||||||
this.getVendors();
|
this.getVendors();
|
||||||
this.getPrices();
|
this.getPrices();
|
||||||
if (this.apiService.getSessionInfoFromLocalStorage().session_id != '') {
|
|
||||||
this.isLoggedIn = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getProduct(): void {
|
getProduct(): void {
|
||||||
this.apiService.getProduct(this.productId).subscribe(product => {
|
this.apiService.getProduct(this.productId).subscribe(product => {this.product = product});
|
||||||
this.product = product;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPrices(): void {
|
getPrices(): void {
|
||||||
@@ -122,12 +115,4 @@ export class ProductDetailsComponent implements OnInit {
|
|||||||
|
|
||||||
return Math.round(percentage);
|
return Math.round(percentage);
|
||||||
}
|
}
|
||||||
|
|
||||||
setPriceAlarm(): void {
|
|
||||||
this.apiService.createPriceAlarms(this.productId, this.price * 100).subscribe(
|
|
||||||
alarms => console.log(alarms)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +1,6 @@
|
|||||||
<div *ngIf="products.length==0">
|
<div *ngIf="products.length==0">
|
||||||
No Products found!
|
No Products found!
|
||||||
</div>
|
</div>
|
||||||
<div class="container mt-5 mb-5">
|
|
||||||
<div class="d-flex justify-content-center row">
|
|
||||||
<div class="col-md-10">
|
|
||||||
<div class="row p-2 bg-white border rounded" *ngFor="let product of products">
|
|
||||||
<div class="col-md-3 mt-1"><img width="50%" class="img-fluid img-responsive rounded product-image"
|
|
||||||
src="https://www.mueller-patrick.tech/betterzon/images/{{product.image_guid}}.jpg">
|
|
||||||
</div>
|
|
||||||
<div class="col-md-6 mt-1">
|
|
||||||
<h5>{{product.name}}</h5>
|
|
||||||
<div class="d-flex flex-row">
|
|
||||||
<p class="text-justify text-truncate para mb-0">{{product.short_description}}</p>
|
|
||||||
</div>
|
|
||||||
<div class="mt-1 mb-1 spec-1"><span></span><span class="dot"></span><span></span><span
|
|
||||||
class="dot"></span><span><br></span></div>
|
|
||||||
<div class="mt-1 mb-1 spec-1"><span></span><span class="dot"></span><span></span><span
|
|
||||||
class="dot"></span><span><br></span></div>
|
|
||||||
</div>
|
|
||||||
<div class="align-items-center align-content-center col-md-3 border-left mt-1">
|
|
||||||
<div class="d-flex flex-row align-items-center">
|
|
||||||
<h4 class="mr-1">${{pricesMap[product.product_id]?.price_in_cents / 100}}</h4>
|
|
||||||
</div>
|
|
||||||
<div class="d-flex flex-column mt-4">
|
|
||||||
<button class="btn btn-primary btn-sm" type="button" (click)="clickedProduct(product)">Details
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--
|
|
||||||
<div class="productItem" *ngFor="let product of products" (click)="clickedProduct(product)">
|
<div class="productItem" *ngFor="let product of products" (click)="clickedProduct(product)">
|
||||||
<div class="productImageContainer" *ngIf="showProductPicture===true">
|
<div class="productImageContainer" *ngIf="showProductPicture===true">
|
||||||
<img class="productImage" src="https://www.mueller-patrick.tech/betterzon/images/{{product.image_guid}}.jpg"/>
|
<img class="productImage" src="https://www.mueller-patrick.tech/betterzon/images/{{product.image_guid}}.jpg"/>
|
||||||
@@ -50,4 +20,3 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
-->
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ describe('ProductListComponent', () => {
|
|||||||
last_modified: new Date(),
|
last_modified: new Date(),
|
||||||
manufacturer_id: 1,
|
manufacturer_id: 1,
|
||||||
selling_rank: '1',
|
selling_rank: '1',
|
||||||
category_id: 1,
|
category_id: 1
|
||||||
price: 0
|
|
||||||
};
|
};
|
||||||
|
|
||||||
component.clickedProduct(product);
|
component.clickedProduct(product);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {ActivatedRoute, Router} from '@angular/router';
|
|||||||
})
|
})
|
||||||
export class ProductListComponent implements OnInit {
|
export class ProductListComponent implements OnInit {
|
||||||
products: Product[] = [];
|
products: Product[] = [];
|
||||||
pricesMap: any = {};
|
|
||||||
@Input() numberOfProducts: number;
|
@Input() numberOfProducts: number;
|
||||||
@Input() showProductPicture: boolean;
|
@Input() showProductPicture: boolean;
|
||||||
@Input() searchQuery: string;
|
@Input() searchQuery: string;
|
||||||
@@ -54,35 +53,15 @@ export class ProductListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getProducts(): void {
|
getProducts(): void {
|
||||||
this.apiService.getProducts().subscribe(products => {
|
this.apiService.getProducts().subscribe(products => this.products = products);
|
||||||
this.products = products;
|
|
||||||
this.getPrices();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getPrices(): void {
|
|
||||||
this.products.forEach(
|
|
||||||
product => {
|
|
||||||
this.apiService.getLowestPrices(product.product_id).subscribe(
|
|
||||||
prices => {
|
|
||||||
this.pricesMap[product.product_id] = prices[prices.length - 1];
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
getSearchedProducts(): void {
|
getSearchedProducts(): void {
|
||||||
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => {
|
this.apiService.getProductsByQuery(this.searchQuery).subscribe(products => this.products = products);
|
||||||
this.products = products;
|
|
||||||
this.getPrices();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clickedProduct(product: Product): void {
|
clickedProduct(product: Product): void {
|
||||||
this.router.navigate([('/product/' + product.product_id)]);
|
this.router.navigate([('/product/' + product.product_id)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import {Component, OnInit} from '@angular/core';
|
|||||||
})
|
})
|
||||||
export class SliderForProductsComponent implements OnInit {
|
export class SliderForProductsComponent implements OnInit {
|
||||||
|
|
||||||
constructor() {
|
constructor() { }
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
.top-bar-wrapper {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 200px 360px 820px 20px 250px;
|
||||||
|
grid-template-rows: 40px;
|
||||||
|
grid-column-gap: 0px;
|
||||||
|
grid-row-gap: 0px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.top-logo {
|
||||||
|
grid-area: 1/1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#better {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #3480E3;
|
||||||
|
}
|
||||||
|
|
||||||
|
#zon {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #E53167;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-button {
|
||||||
|
/*background-color: #E53167;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
.sign-up {
|
||||||
|
/*background-color: #E53167;*/
|
||||||
|
margin-left: 50px;
|
||||||
|
margin-right: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login {
|
||||||
|
margin-right: 25px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#signin {
|
||||||
|
border-radius: 25px;
|
||||||
|
background-color: #E53167;
|
||||||
|
}
|
||||||
|
|
||||||
|
._links > a {
|
||||||
|
/*background-color: #E53167;*/
|
||||||
|
margin-left: 10px;
|
||||||
|
margin-right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
._signing_links > a {
|
||||||
|
/*background-color: #E53167;*/
|
||||||
|
margin-left: 50px;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,35 +1,26 @@
|
|||||||
<nav class="navbar navbar-expand-lg bg-secondary text-uppercase fixed-top" id="mainNav">
|
<div class="top-bar-wrapper">
|
||||||
<div class="container">
|
<div class="<top-logo>">
|
||||||
<a class="navbar-brand" routerLink=""> Betterzon</a>
|
<a><span id="better">BETTER</span><span id="zon">ZON</span></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>
|
|
||||||
<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>
|
|
||||||
</button>
|
|
||||||
<div class="collapse navbar-collapse" id="navbarResponsive">
|
|
||||||
<ul class="navbar-nav ms-auto">
|
|
||||||
<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-offers</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">about</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">our
|
|
||||||
clients</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">sign in</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">sign up</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>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="links">
|
||||||
|
<nav class="_links">
|
||||||
|
<a>KONTAKTIERE UNS</a>
|
||||||
|
<a>KUNDEN</a>
|
||||||
|
<a>FAQ</a>
|
||||||
</nav>
|
</nav>
|
||||||
|
</div>
|
||||||
|
<div class="footer_space">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="search-button">
|
||||||
|
<a>
|
||||||
|
<img src="assets/images/search_black_24dp.svg" alt="Sarch button">
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="links">
|
||||||
|
<nav class="_signing_links">
|
||||||
|
<a>SIGN UP</a>
|
||||||
|
<a><span id="signin">SIGN IN</span></a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,37 +1,14 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { TopBarComponent } from './top-bar.component';
|
import { TopBarComponent } from './top-bar.component';
|
||||||
import {FormBuilder} from '@angular/forms';
|
|
||||||
import {ApiService} from '../../services/api.service';
|
|
||||||
import {Router} from '@angular/router';
|
|
||||||
import {AbstractMockObservableService} from '../../mocks/mock.service';
|
|
||||||
|
|
||||||
class MockApiService extends AbstractMockObservableService {
|
|
||||||
getUserInfo(): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
getSessionInfoFromLocalStorage(): any {
|
|
||||||
this.content = [];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('TopBarComponent', () => {
|
describe('TopBarComponent', () => {
|
||||||
let component: TopBarComponent;
|
let component: TopBarComponent;
|
||||||
let fixture: ComponentFixture<TopBarComponent>;
|
let fixture: ComponentFixture<TopBarComponent>;
|
||||||
let mockService;
|
|
||||||
const router = {
|
|
||||||
navigate: jasmine.createSpy('navigate'),
|
|
||||||
routerState: jasmine.createSpy('routerState')
|
|
||||||
};
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
mockService = new MockApiService();
|
|
||||||
await TestBed.configureTestingModule({
|
await TestBed.configureTestingModule({
|
||||||
declarations: [TopBarComponent],
|
declarations: [ TopBarComponent ]
|
||||||
providers: [{provide: ApiService, useValue: mockService}, {provide: Router, useValue: router}]
|
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
import {Component, Input, OnInit} from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
import {ApiService} from '../../services/api.service';
|
|
||||||
import {NavigationEnd, Router} from '@angular/router';
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-top-bar',
|
selector: 'app-top-bar',
|
||||||
@@ -11,42 +8,10 @@ import {NavigationEnd, Router} from '@angular/router';
|
|||||||
export class TopBarComponent implements OnInit {
|
export class TopBarComponent implements OnInit {
|
||||||
|
|
||||||
sidenav: any;
|
sidenav: any;
|
||||||
isLoggedIn: boolean;
|
|
||||||
searchQuery: string;
|
|
||||||
|
|
||||||
constructor(
|
constructor() { }
|
||||||
private api: ApiService,
|
|
||||||
private router: Router
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
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', '');
|
|
||||||
if (this.router.url === '/profile') {
|
|
||||||
this.router.navigate(['/']);
|
|
||||||
} else {
|
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
export interface Category {
|
|
||||||
category_id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
export interface ContactPerson {
|
|
||||||
contact_person_id: number;
|
|
||||||
first_name: string;
|
|
||||||
last_name: string;
|
|
||||||
gender: string;
|
|
||||||
email: string;
|
|
||||||
phone: string;
|
|
||||||
vendor_id: number;
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
export interface CrawlingStatus {
|
|
||||||
process_id: number;
|
|
||||||
started_timestamp: Date;
|
|
||||||
combinations_to_crawl: number;
|
|
||||||
successful_crawls: number;
|
|
||||||
failed_crawls: number;
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
export interface FavoriteShop {
|
|
||||||
favorite_id: number;
|
|
||||||
vendor_id: number;
|
|
||||||
user_id: number;
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
export interface Manufacturer {
|
|
||||||
manufacturer_id: number;
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
@@ -5,24 +5,3 @@ export interface Price {
|
|||||||
price_in_cents: number;
|
price_in_cents: number;
|
||||||
timestamp: Date;
|
timestamp: Date;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Deal implements Price {
|
|
||||||
price_id: number;
|
|
||||||
product_id: number;
|
|
||||||
vendor_id: number;
|
|
||||||
price_in_cents: number;
|
|
||||||
timestamp: Date;
|
|
||||||
amazonDifference: number;
|
|
||||||
amazonDifferencePercent: number;
|
|
||||||
|
|
||||||
constructor(price_id: number, product_id: number, vendor_id: number, price_in_cents: number, timestamp: Date, amazonDifference: number,
|
|
||||||
amazonDifferencePercent: number) {
|
|
||||||
this.price_id = price_id;
|
|
||||||
this.product_id = product_id;
|
|
||||||
this.vendor_id = vendor_id;
|
|
||||||
this.price_in_cents = price_in_cents;
|
|
||||||
this.timestamp = timestamp;
|
|
||||||
this.amazonDifference = amazonDifference;
|
|
||||||
this.amazonDifferencePercent = amazonDifferencePercent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,5 +11,4 @@ export interface Product {
|
|||||||
manufacturer_id: number;
|
manufacturer_id: number;
|
||||||
selling_rank: string;
|
selling_rank: string;
|
||||||
category_id: number;
|
category_id: number;
|
||||||
price: number;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<app-top-bar></app-top-bar>
|
<app-header [showSearch]="true"></app-header>
|
||||||
<div id="imprint" class="container masthead">
|
<div id="imprint">
|
||||||
<h1>Impressum</h1>
|
<h1>Impressum</h1>
|
||||||
|
|
||||||
<h2>Angaben gemäß § 5 TMG</h2>
|
<h2>Angaben gemäß § 5 TMG</h2>
|
||||||
@@ -17,16 +17,14 @@
|
|||||||
<h3>Haftung für Inhalte</h3>
|
<h3>Haftung für Inhalte</h3>
|
||||||
<p>
|
<p>
|
||||||
Als Diensteanbieter sind wir gemäß § 7 Abs.1 TMG für eigene
|
Als Diensteanbieter sind wir gemäß § 7 Abs.1 TMG für eigene
|
||||||
Inhalte auf diesen Seiten nach den allgemeinen Gesetzen verantwortlich. Nach §§ 8 bis 10 TMG sind wir
|
Inhalte auf diesen Seiten nach den allgemeinen Gesetzen verantwortlich. Nach §§ 8 bis 10 TMG sind wir als
|
||||||
als
|
|
||||||
Diensteanbieter jedoch nicht verpflichtet, übermittelte oder gespeicherte fremde Informationen zu überwachen
|
Diensteanbieter jedoch nicht verpflichtet, übermittelte oder gespeicherte fremde Informationen zu überwachen
|
||||||
oder nach Umständen zu forschen, die auf eine rechtswidrige Tätigkeit hinweisen.
|
oder nach Umständen zu forschen, die auf eine rechtswidrige Tätigkeit hinweisen.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Verpflichtungen zur Entfernung oder Sperrung der Nutzung von Informationen nach den allgemeinen Gesetzen bleiben
|
Verpflichtungen zur Entfernung oder Sperrung der Nutzung von Informationen nach den allgemeinen Gesetzen bleiben
|
||||||
hiervon unberührt.
|
hiervon unberührt.
|
||||||
Eine diesbezügliche Haftung ist jedoch erst ab dem Zeitpunkt der Kenntnis einer konkreten Rechtsverletzung
|
Eine diesbezügliche Haftung ist jedoch erst ab dem Zeitpunkt der Kenntnis einer konkreten Rechtsverletzung möglich.
|
||||||
möglich.
|
|
||||||
Bei Bekanntwerden von entsprechenden Rechtsverletzungen werden wir diese Inhalte umgehend entfernen.
|
Bei Bekanntwerden von entsprechenden Rechtsverletzungen werden wir diese Inhalte umgehend entfernen.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@@ -46,21 +44,16 @@
|
|||||||
|
|
||||||
<h3>Urheberrecht</h3>
|
<h3>Urheberrecht</h3>
|
||||||
<p>
|
<p>
|
||||||
Die durch die Seitenbetreiber erstellten Inhalte und Werke auf diesen Seiten unterliegen dem deutschen
|
Die durch die Seitenbetreiber erstellten Inhalte und Werke auf diesen Seiten unterliegen dem deutschen Urheberrecht.
|
||||||
Urheberrecht.
|
|
||||||
Die Vervielfältigung, Bearbeitung, Verbreitung und jede Art der Verwertung außerhalb der Grenzen des
|
Die Vervielfältigung, Bearbeitung, Verbreitung und jede Art der Verwertung außerhalb der Grenzen des
|
||||||
Urheberrechtes bedürfen der schriftlichen Zustimmung des jeweiligen Autors bzw. Erstellers. Downloads und
|
Urheberrechtes bedürfen der schriftlichen Zustimmung des jeweiligen Autors bzw. Erstellers. Downloads und
|
||||||
Kopien dieser Seite sind nur für den privaten, nicht kommerziellen Gebrauch gestattet.
|
Kopien dieser Seite sind nur für den privaten, nicht kommerziellen Gebrauch gestattet.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Soweit die Inhalte auf dieser Seite nicht vom Betreiber erstellt wurden, werden die Urheberrechte Dritter
|
Soweit die Inhalte auf dieser Seite nicht vom Betreiber erstellt wurden, werden die Urheberrechte Dritter beachtet.
|
||||||
beachtet.
|
Insbesondere werden Inhalte Dritter als solche gekennzeichnet. Sollten Sie trotzdem auf eine Urheberrechtsverletzung
|
||||||
Insbesondere werden Inhalte Dritter als solche gekennzeichnet. Sollten Sie trotzdem auf eine
|
aufmerksam werden, bitten wir um einen entsprechenden Hinweis. Bei Bekanntwerden von Rechtsverletzungen werden wir
|
||||||
Urheberrechtsverletzung
|
|
||||||
aufmerksam werden, bitten wir um einen entsprechenden Hinweis. Bei Bekanntwerden von Rechtsverletzungen werden
|
|
||||||
wir
|
|
||||||
derartige Inhalte umgehend entfernen.
|
derartige Inhalte umgehend entfernen.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<app-bottom-bar></app-bottom-bar>
|
<app-footer></app-footer>
|
||||||
<app-copyright></app-copyright>
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user