|
@@ -1,4 +1,4 @@
|
|
-import {Component, Inject, OnInit} from "@angular/core";
|
|
|
|
|
|
+import {Component, Inject, OnDestroy, OnInit} from "@angular/core";
|
|
import {AccountEvent, AccountInfo, AccountService} from "../bank/account/account.service";
|
|
import {AccountEvent, AccountInfo, AccountService} from "../bank/account/account.service";
|
|
import {PersonService} from "./person.service";
|
|
import {PersonService} from "./person.service";
|
|
import {HttpClient} from "@angular/common/http";
|
|
import {HttpClient} from "@angular/common/http";
|
|
@@ -7,24 +7,38 @@ import {BankService, DemurrageInfo} from "../bank/bank.service";
|
|
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material/dialog";
|
|
import {MAT_DIALOG_DATA, MatDialog, MatDialogRef} from "@angular/material/dialog";
|
|
import {AppComponent} from "../app.component";
|
|
import {AppComponent} from "../app.component";
|
|
import {OrgInfo, OrgService} from "../org/org.service";
|
|
import {OrgInfo, OrgService} from "../org/org.service";
|
|
|
|
+import {RxStompService} from "@stomp/ng2-stompjs";
|
|
|
|
+import {Subscription} from "rxjs";
|
|
|
|
|
|
@Component({
|
|
@Component({
|
|
selector: 'person-page',
|
|
selector: 'person-page',
|
|
templateUrl: 'person.page.component.html',
|
|
templateUrl: 'person.page.component.html',
|
|
styleUrls: ['person.page.component.scss']
|
|
styleUrls: ['person.page.component.scss']
|
|
})
|
|
})
|
|
-export class PersonPageComponent implements OnInit {
|
|
|
|
|
|
+export class PersonPageComponent implements OnInit, OnDestroy {
|
|
|
|
|
|
accounts: AccountInfo[] = []
|
|
accounts: AccountInfo[] = []
|
|
events: AccountEvent[] = []
|
|
events: AccountEvent[] = []
|
|
orgs: OrgInfo[] = []
|
|
orgs: OrgInfo[] = []
|
|
demurrage: DemurrageInfo
|
|
demurrage: DemurrageInfo
|
|
|
|
+ eventBus: Subscription
|
|
|
|
|
|
- constructor(private app: AppComponent, private orgService: OrgService, private personService: PersonService, private accountService: AccountService, private bankService: BankService, private httpClient: HttpClient, private matDialog: MatDialog) {
|
|
|
|
|
|
+ constructor(private app: AppComponent, private orgService: OrgService, private personService: PersonService, private accountService: AccountService, private bankService: BankService, private httpClient: HttpClient, private matDialog: MatDialog, private rxStompService: RxStompService) {
|
|
app.setTitle("ЛИЧНЫЙ КАБИНЕТ")
|
|
app.setTitle("ЛИЧНЫЙ КАБИНЕТ")
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ngOnDestroy(): void {
|
|
|
|
+ this.eventBus.unsubscribe()
|
|
|
|
+ }
|
|
|
|
+
|
|
ngOnInit(): void {
|
|
ngOnInit(): void {
|
|
|
|
+ this.eventBus = this.rxStompService.watch("/bus/exchange").subscribe(msg => {
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ this.updateNow()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ updateNow(): void {
|
|
this.personService.getCurrentPerson().subscribe(person => {
|
|
this.personService.getCurrentPerson().subscribe(person => {
|
|
this.orgService.getOrgsInfo(person.auth.id).subscribe(orgs => this.orgs = orgs);
|
|
this.orgService.getOrgsInfo(person.auth.id).subscribe(orgs => this.orgs = orgs);
|
|
this.accountService.getAccountsInfo(person.auth.id).subscribe(accounts => {
|
|
this.accountService.getAccountsInfo(person.auth.id).subscribe(accounts => {
|
|
@@ -49,11 +63,11 @@ export class PersonPageComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
addAccount() {
|
|
addAccount() {
|
|
- this.personService.getCurrentPerson().subscribe(person => this.accountService.addAccount(person.auth.id).subscribe(res => this.ngOnInit()))
|
|
|
|
|
|
+ this.personService.getCurrentPerson().subscribe(person => this.accountService.addAccount(person.auth.id).subscribe(res => this.updateNow()))
|
|
}
|
|
}
|
|
|
|
|
|
iNeedMoney() {
|
|
iNeedMoney() {
|
|
- this.personService.getCurrentPerson().subscribe(person => this.httpClient.post(`/api/old/person/${person.auth.id}/givemoney`, {}).subscribe(res => this.ngOnInit()))
|
|
|
|
|
|
+ this.personService.getCurrentPerson().subscribe(person => this.httpClient.post(`/api/old/person/${person.auth.id}/givemoney`, {}).subscribe(res => this.updateNow()))
|
|
}
|
|
}
|
|
|
|
|
|
getTotatOverall(): number {
|
|
getTotatOverall(): number {
|
|
@@ -61,7 +75,7 @@ export class PersonPageComponent implements OnInit {
|
|
}
|
|
}
|
|
|
|
|
|
addPrivate() {
|
|
addPrivate() {
|
|
- this.personService.getCurrentPerson().subscribe(person => this.orgService.addPrivateToPerson(person.auth.id).subscribe(res => this.ngOnInit()))
|
|
|
|
|
|
+ this.personService.getCurrentPerson().subscribe(person => this.orgService.addPrivateToPerson(person.auth.id).subscribe(res => this.updateNow()))
|
|
}
|
|
}
|
|
|
|
|
|
joinPrivate() {
|
|
joinPrivate() {
|
|
@@ -98,7 +112,7 @@ export class PersonPageComponent implements OnInit {
|
|
if (res.action == 'create') {
|
|
if (res.action == 'create') {
|
|
let data = <PersonCreditData>res.data
|
|
let data = <PersonCreditData>res.data
|
|
this.httpClient.post(`/api/old/person/${person.auth.id}/account/${data.account.id}/credit/by-link/${data.code}`, {code: res.key, amount: data.amount}).subscribe((res: any) => {
|
|
this.httpClient.post(`/api/old/person/${person.auth.id}/account/${data.account.id}/credit/by-link/${data.code}`, {code: res.key, amount: data.amount}).subscribe((res: any) => {
|
|
- this.ngOnInit()
|
|
|
|
|
|
+ this.updateNow()
|
|
console.log(`transaction done ${res.id}`)
|
|
console.log(`transaction done ${res.id}`)
|
|
})
|
|
})
|
|
}
|
|
}
|