Frontend #171
@ -9,12 +9,17 @@ export class HelperService {
|
|||||||
constructor(private botService: BotService) {}
|
constructor(private botService: BotService) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to delay loading of webpage for a smoother user experience
|
||||||
* @param {number} ms
|
* @param {number} ms
|
||||||
*/
|
*/
|
||||||
delay(ms: number) {
|
delay(ms: number) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to format share data
|
||||||
|
* @returns Share
|
||||||
|
*/
|
||||||
formatShareData(): Share[] {
|
formatShareData(): Share[] {
|
||||||
var shares: Share[] = [];
|
var shares: Share[] = [];
|
||||||
this.botService.getSymbols().subscribe((result) => {
|
this.botService.getSymbols().subscribe((result) => {
|
||||||
@ -27,7 +32,10 @@ export class HelperService {
|
|||||||
});
|
});
|
||||||
return shares;
|
return shares;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* @returns Keyword
|
||||||
|
* Function to format keyword data
|
||||||
|
*/
|
||||||
formatKeywordsData(): Keyword[] {
|
formatKeywordsData(): Keyword[] {
|
||||||
var keywords: Keyword[] = [];
|
var keywords: Keyword[] = [];
|
||||||
this.botService.getKeywords().subscribe((result) => {
|
this.botService.getKeywords().subscribe((result) => {
|
||||||
|
@ -14,6 +14,7 @@ export class AuthService {
|
|||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to login user
|
||||||
* @param {string} email
|
* @param {string} email
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
@ -26,6 +27,7 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to register user
|
||||||
* @param {string} email
|
* @param {string} email
|
||||||
* @param {string} username
|
* @param {string} username
|
||||||
* @param {string} password
|
* @param {string} password
|
||||||
|
@ -15,6 +15,7 @@ export class BotService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get all keywords
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
public getKeywords(): Observable<any> {
|
public getKeywords(): Observable<any> {
|
||||||
@ -28,6 +29,7 @@ export class BotService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to create a keyword
|
||||||
* @param {string} keyword
|
* @param {string} keyword
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
@ -47,6 +49,7 @@ export class BotService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to delete a keyword
|
||||||
* @param {string} keyword
|
* @param {string} keyword
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
@ -63,6 +66,7 @@ export class BotService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get all shares
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
public getSymbols(): Observable<any> {
|
public getSymbols(): Observable<any> {
|
||||||
@ -76,6 +80,7 @@ export class BotService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to create a share
|
||||||
* @param {string} keyword
|
* @param {string} keyword
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
@ -96,6 +101,7 @@ export class BotService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to delete a share
|
||||||
* @param {string} symbol
|
* @param {string} symbol
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +17,7 @@ export class DataService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get all portfolio data
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
public getStockData(): Observable<any> {
|
public getStockData(): Observable<any> {
|
||||||
@ -30,6 +31,7 @@ export class DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get all transaction data
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
public getTransactionData(): Observable<any> {
|
public getTransactionData(): Observable<any> {
|
||||||
@ -43,6 +45,7 @@ export class DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to create a transaction
|
||||||
* @param {string} symbol
|
* @param {string} symbol
|
||||||
* @param {Date} time
|
* @param {Date} time
|
||||||
* @param {number} count
|
* @param {number} count
|
||||||
@ -77,6 +80,7 @@ export class DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get all keywords
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
public getKeywords(): Observable<any> {
|
public getKeywords(): Observable<any> {
|
||||||
|
@ -15,6 +15,7 @@ export class ProfileService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get all Userdata
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
public getUserData(): Observable<any> {
|
public getUserData(): Observable<any> {
|
||||||
@ -28,6 +29,7 @@ export class ProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to update user profile
|
||||||
* @param {string} username
|
* @param {string} username
|
||||||
* @param {number} password
|
* @param {number} password
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
@ -49,6 +51,7 @@ export class ProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to add a telegram id
|
||||||
* @param {string} telegramUserID
|
* @param {string} telegramUserID
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
@ -68,6 +71,7 @@ export class ProfileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to add a cron string for automatic updates
|
||||||
* @param {string} cronString
|
* @param {string} cronString
|
||||||
* @returns Observable
|
* @returns Observable
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +8,7 @@ export class TokenStorageService {
|
|||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to sign out user
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
signOut(): void {
|
signOut(): void {
|
||||||
@ -15,6 +16,7 @@ export class TokenStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to save token
|
||||||
* @param {string} token
|
* @param {string} token
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
@ -24,6 +26,7 @@ export class TokenStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get token
|
||||||
* @returns string
|
* @returns string
|
||||||
*/
|
*/
|
||||||
public getToken(): string | null {
|
public getToken(): string | null {
|
||||||
@ -31,6 +34,7 @@ export class TokenStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to save user
|
||||||
* @param {any} user
|
* @param {any} user
|
||||||
* @returns void
|
* @returns void
|
||||||
*/
|
*/
|
||||||
@ -40,6 +44,7 @@ export class TokenStorageService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Function to get user
|
||||||
* @returns any
|
* @returns any
|
||||||
*/
|
*/
|
||||||
public getUser(): any {
|
public getUser(): any {
|
||||||
|
@ -41,6 +41,12 @@ export class DashboardComponent implements OnInit {
|
|||||||
depotCost: number = 0;
|
depotCost: number = 0;
|
||||||
profit: number = 0;
|
profit: number = 0;
|
||||||
|
|
||||||
|
comment: string = '';
|
||||||
|
isin: string = '';
|
||||||
|
time: Date = new Date();
|
||||||
|
count: number = 0.0;
|
||||||
|
price: number = 0.0;
|
||||||
|
|
||||||
getTransactions() {
|
getTransactions() {
|
||||||
var TRANSACTION_DATA: TransactionData[] = [];
|
var TRANSACTION_DATA: TransactionData[] = [];
|
||||||
this.dataService.getTransactionData().subscribe((response: any) => {
|
this.dataService.getTransactionData().subscribe((response: any) => {
|
||||||
@ -64,6 +70,9 @@ export class DashboardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
/**
|
||||||
|
* Function gets the stock data and pushes it in the temporary object array
|
||||||
|
*/
|
||||||
this.dataService.getStockData().subscribe((response: any) => {
|
this.dataService.getStockData().subscribe((response: any) => {
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
console.log(data);
|
console.log(data);
|
||||||
@ -78,11 +87,14 @@ export class DashboardComponent implements OnInit {
|
|||||||
current_price: data.data[i].current_price,
|
current_price: data.data[i].current_price,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(STOCK_DATA);
|
// assign data source
|
||||||
this.dataSourceStocks = STOCK_DATA;
|
this.dataSourceStocks = STOCK_DATA;
|
||||||
this.profit += this.depotCurrentValue;
|
this.profit += this.depotCurrentValue;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function gets the transaction data and pushes it in the temporary object array
|
||||||
|
*/
|
||||||
this.dataService.getTransactionData().subscribe((response: any) => {
|
this.dataService.getTransactionData().subscribe((response: any) => {
|
||||||
var data = JSON.parse(response);
|
var data = JSON.parse(response);
|
||||||
this.depotCost = 0;
|
this.depotCost = 0;
|
||||||
@ -96,19 +108,13 @@ export class DashboardComponent implements OnInit {
|
|||||||
price: data.data[i].price,
|
price: data.data[i].price,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// assign data source
|
||||||
this.dataSourceTransactions = TRANSACTION_DATA;
|
this.dataSourceTransactions = TRANSACTION_DATA;
|
||||||
//TODO move to helper service
|
|
||||||
|
|
||||||
this.profit += this.depotCost;
|
this.profit += this.depotCost;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
comment: string = '';
|
// function to open the user dialog to create a new transaction
|
||||||
isin: string = '';
|
|
||||||
time: Date = new Date();
|
|
||||||
count: number = 0.0;
|
|
||||||
price: number = 0.0;
|
|
||||||
|
|
||||||
openDialog(): void {
|
openDialog(): void {
|
||||||
const dialogRef = this.dialog.open(UserDialogComponent, {
|
const dialogRef = this.dialog.open(UserDialogComponent, {
|
||||||
width: '50vw',
|
width: '50vw',
|
||||||
@ -127,6 +133,7 @@ export class DashboardComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assign columns for transactions to display in html, you can change order and add/remove columns
|
||||||
displayedColumns: string[] = [
|
displayedColumns: string[] = [
|
||||||
'comment',
|
'comment',
|
||||||
'weight',
|
'weight',
|
||||||
@ -134,6 +141,8 @@ export class DashboardComponent implements OnInit {
|
|||||||
'name',
|
'name',
|
||||||
'symbol',
|
'symbol',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// assign columns to display in html, you can change order and add/remove columns
|
||||||
displayedColumnsStocks: string[] = [
|
displayedColumnsStocks: string[] = [
|
||||||
'count',
|
'count',
|
||||||
'comment',
|
'comment',
|
||||||
|
@ -13,6 +13,7 @@ export class LoginComponent implements OnInit {
|
|||||||
email: null,
|
email: null,
|
||||||
password: null,
|
password: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
isLoggedIn = false;
|
isLoggedIn = false;
|
||||||
isLoginFailed = false;
|
isLoginFailed = false;
|
||||||
errorMessage = '';
|
errorMessage = '';
|
||||||
|
@ -32,6 +32,9 @@ export class ProfileComponent implements OnInit {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
|
/**
|
||||||
|
* get user data to display
|
||||||
|
*/
|
||||||
this.profileService.getUserData().subscribe((result) => {
|
this.profileService.getUserData().subscribe((result) => {
|
||||||
console.log(result);
|
console.log(result);
|
||||||
result = JSON.parse(result);
|
result = JSON.parse(result);
|
||||||
@ -42,6 +45,9 @@ export class ProfileComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add telegram user id in database
|
||||||
|
*/
|
||||||
onSubmit() {
|
onSubmit() {
|
||||||
if (this.userId != '') {
|
if (this.userId != '') {
|
||||||
console.log(this.userId);
|
console.log(this.userId);
|
||||||
@ -51,6 +57,9 @@ export class ProfileComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to update user information
|
||||||
|
*/
|
||||||
updateUser() {
|
updateUser() {
|
||||||
const { username, email, password } = this.form;
|
const { username, email, password } = this.form;
|
||||||
this.profileService
|
this.profileService
|
||||||
@ -60,12 +69,14 @@ export class ProfileComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// opens confirmation dialog
|
||||||
openDialog(action: string) {
|
openDialog(action: string) {
|
||||||
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
||||||
width: '50vw',
|
width: '50vw',
|
||||||
height: '20vh',
|
height: '20vh',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// on close dialog, if action is "addTelegram" update telegram id, else update user information
|
||||||
dialogRef.afterClosed().subscribe((result) => {
|
dialogRef.afterClosed().subscribe((result) => {
|
||||||
if (result === true) {
|
if (result === true) {
|
||||||
if (action === 'addTelegram') {
|
if (action === 'addTelegram') {
|
||||||
@ -77,6 +88,7 @@ export class ProfileComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// helper user dialog to explain the process of getting the telegram id
|
||||||
openHelp() {
|
openHelp() {
|
||||||
const dialogRef = this.dialog.open(HelpDialogComponent, {
|
const dialogRef = this.dialog.open(HelpDialogComponent, {
|
||||||
width: '50vw',
|
width: '50vw',
|
||||||
|
@ -25,7 +25,12 @@ export class RegisterComponent {
|
|||||||
* @param {Router} privaterouter
|
* @param {Router} privaterouter
|
||||||
*/
|
*/
|
||||||
constructor(private authService: AuthService, private router: Router) {}
|
constructor(private authService: AuthService, private router: Router) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On submit, send user information to backend
|
||||||
|
*/
|
||||||
onSubmit(): void {
|
onSubmit(): void {
|
||||||
|
// validate that passwords match
|
||||||
if (this.form.password === this.form.passwordRepeat) {
|
if (this.form.password === this.form.passwordRepeat) {
|
||||||
this.checkPasswordFailed = false;
|
this.checkPasswordFailed = false;
|
||||||
const { email, username, password } = this.form;
|
const { email, username, password } = this.form;
|
||||||
|
Loading…
Reference in New Issue
Block a user