You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
2.2 KiB
TypeScript
65 lines
2.2 KiB
TypeScript
5 years ago
|
import { Component, OnInit, Inject } from '@angular/core';
|
||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
|
||
|
import { Store } from '@ngrx/store';
|
||
|
|
||
5 years ago
|
import { PeerCL, GetInfoCL } from '../../../../shared/models/clModels';
|
||
|
import { CLOpenChannelAlert } from '../../../../shared/models/alertData';
|
||
|
import { FEE_RATE_TYPES } from '../../../../shared/services/consts-enums-functions';
|
||
5 years ago
|
|
||
|
import * as RTLActions from '../../../../store/rtl.actions';
|
||
|
import * as fromRTLReducer from '../../../../store/rtl.reducers';
|
||
|
|
||
|
@Component({
|
||
5 years ago
|
selector: 'rtl-cl-open-channel',
|
||
5 years ago
|
templateUrl: './open-channel.component.html',
|
||
|
styleUrls: ['./open-channel.component.scss']
|
||
|
})
|
||
5 years ago
|
export class CLOpenChannelComponent implements OnInit {
|
||
5 years ago
|
public alertTitle: string;
|
||
5 years ago
|
public peer: PeerCL;
|
||
|
public information: GetInfoCL;
|
||
5 years ago
|
public fundingAmount: number;
|
||
5 years ago
|
public myChanPolicy: any = {};
|
||
5 years ago
|
public isPrivate = false;
|
||
5 years ago
|
public feeRateTypes = FEE_RATE_TYPES;
|
||
|
public totalBalance = 0;
|
||
5 years ago
|
public newlyAdded = false;
|
||
5 years ago
|
public selFeeRate = '';
|
||
|
public flgMinConf = false;
|
||
|
public minConfValue = null;
|
||
|
public moreOptions = false;
|
||
5 years ago
|
|
||
5 years ago
|
constructor(public dialogRef: MatDialogRef<CLOpenChannelComponent>, @Inject(MAT_DIALOG_DATA) public data: CLOpenChannelAlert, private store: Store<fromRTLReducer.RTLState>) {}
|
||
5 years ago
|
|
||
|
ngOnInit() {
|
||
5 years ago
|
this.peer = this.data.message.peer;
|
||
|
this.information = this.data.message.information;
|
||
|
this.totalBalance = this.data.message.balance;
|
||
5 years ago
|
this.newlyAdded = this.data.newlyAdded;
|
||
5 years ago
|
this.alertTitle = this.data.alertTitle;
|
||
5 years ago
|
}
|
||
|
|
||
|
onClose() {
|
||
|
this.dialogRef.close(false);
|
||
|
}
|
||
|
|
||
5 years ago
|
resetData() {
|
||
5 years ago
|
this.fundingAmount = 0;
|
||
|
this.moreOptions = false;
|
||
|
this.flgMinConf = false;
|
||
5 years ago
|
this.isPrivate = false;
|
||
5 years ago
|
this.selFeeRate = '';
|
||
|
this.minConfValue = null;
|
||
5 years ago
|
}
|
||
|
|
||
5 years ago
|
onOpenChannel() {
|
||
5 years ago
|
if (!this.fundingAmount || (this.totalBalance - ((this.fundingAmount) ? this.fundingAmount : 0) < 0)) { return true; }
|
||
5 years ago
|
this.store.dispatch(new RTLActions.OpenSpinner('Opening Channel...'));
|
||
5 years ago
|
this.store.dispatch(new RTLActions.SaveNewChannelCL({
|
||
|
peerId: this.peer.id, satoshis: this.fundingAmount, announce: !this.isPrivate, feeRate: this.selFeeRate, minconf: this.flgMinConf ? this.minConfValue : null
|
||
5 years ago
|
}));
|
||
|
this.dialogRef.close(false);
|
||
|
}
|
||
|
|
||
|
}
|