Fix shares and keywords

This commit is contained in:
kevinpauer 2022-04-28 21:12:14 +02:00
parent 4788159865
commit 7bcfdc4081
4 changed files with 9 additions and 8 deletions

View File

@ -21,7 +21,7 @@ export class HelperService {
var data = JSON.parse(result); var data = JSON.parse(result);
for (let i = 0; i < data.data.length; i++) { for (let i = 0; i < data.data.length; i++) {
shares.push({ shares.push({
symbol: data.data[i].symbol, isin: data.data[i].isin,
}); });
} }
}); });

View File

@ -79,11 +79,12 @@ export class BotService {
* @param {string} keyword * @param {string} keyword
* @returns Observable * @returns Observable
*/ */
public createShare(symbol: string): Observable<any> { public createShare(isin: string, comment: string): Observable<any> {
return this.http.post( return this.http.post(
API_URL + 'share', API_URL + 'share',
{ {
symbol, comment,
isin,
}, },
{ {
headers: new HttpHeaders({ headers: new HttpHeaders({

View File

@ -67,7 +67,7 @@
*ngFor="let share of shares" *ngFor="let share of shares"
(removed)="removeShare(share)" (removed)="removeShare(share)"
> >
{{ share.symbol }} {{ share.isin }}
<button matChipRemove> <button matChipRemove>
<mat-icon>cancel</mat-icon> <mat-icon>cancel</mat-icon>
</button> </button>

View File

@ -14,7 +14,7 @@ export interface Fruit {
} }
export interface Share { export interface Share {
symbol: string; isin: string;
} }
export interface Keyword { export interface Keyword {
@ -80,9 +80,9 @@ export class BotSettingsComponent implements OnInit {
const value = (event.value || '').trim(); const value = (event.value || '').trim();
// Add share to database // Add share to database
if (value && !this.shares.includes({ symbol: value.toLowerCase() })) { if (value && !this.shares.includes({ isin: value.toLowerCase() })) {
console.log('Added: ' + value); console.log('Added: ' + value);
this.botService.createShare(value).subscribe((result) => { this.botService.createShare(value, 'Comment').subscribe((result) => {
console.log(result); console.log(result);
}); });
} }
@ -99,7 +99,7 @@ export class BotSettingsComponent implements OnInit {
} }
async removeShare(share: Share): Promise<void> { async removeShare(share: Share): Promise<void> {
this.botService.deleteShare(share.symbol).subscribe((result) => { this.botService.deleteShare(share.isin).subscribe((result) => {
console.log(result); console.log(result);
}); });