/// import * as ko from "knockout"; import { App } from "../app"; import * as authManager from "../authmanager"; import { _ } from "../languagemanager"; import { accountService } from "../services"; import { PopupBase } from "../ui/popupbase"; declare var apiHost: string; declare var app: App; export class AccountStatusPopup extends PopupBase { public loading: KnockoutObservable; public information: KnockoutObservable; public loginName: KnockoutObservable; public tableName: KnockoutObservable; public smallBlind: KnockoutObservable; public bigBlind: KnockoutObservable; public tableInformation: KnockoutComputed; public betInformation: KnockoutComputed; public displayCurrencyName: boolean; public addMoneyAvailable = ko.observable(false); public addMoneyAllowed = ko.observable(false); constructor() { super(); this.displayCurrencyName = false; this.loading = ko.observable(true); this.information = ko.observable(); this.loginName = ko.observable(); this.tableName = ko.observable(); this.smallBlind = ko.observable(); this.bigBlind = ko.observable(); this.tableInformation = ko.computed(() => { return _("accountStatus.tableInfo", { name: this.tableName() }); }, this); this.betInformation = ko.computed(() => { return _("accountStatus.betInfo", { sb: this.smallBlind(), bb: this.bigBlind() }); }, this); } public shown() { super.shown(); this.requestData(); this.loginName(authManager.login()); const tableView = app.tablesPage.currentTable(); this.tableName(tableView.model.TableName); this.smallBlind(tableView.model.SmallBlind); this.bigBlind(tableView.model.BigBlind); this.addMoneyAvailable(tableView.tournament() == null && tableView.opened()); this.addMoneyAllowed(tableView.couldAddChips()); } public addMoney() { if (!this.addMoneyAllowed()) { return; } const currentTable = app.tablesPage.currentTable(); app.addMoneyPopup.tableView(currentTable); super.close(); app.showPopup("addMoney").then(function (results: { name: string; result: any }) { if (results.result === "cancel") { app.showPopup("accountStatus"); } }); } private async requestData() { this.loading(true); try { const result = await accountService.getAccount(); this.loading(false); this.information(result); } catch (e) { app.closePopup(); } } }