withdrawals.component.ts 3.42 KB
import { Component, OnInit, TemplateRef, ViewChild, Inject } from '@angular/core';
import { MatDialogConfig, MatDialogRef, MatDialog } from '@angular/material';
import { DOCUMENT } from '@angular/common';
import { DialogComponent } from '../dialog/dialog.component';

const defaultDialogConfig = new MatDialogConfig();

@Component({
  selector: 'app-withdrawals',
  templateUrl: './withdrawals.component.html',
  styleUrls: ['./withdrawals.component.scss']
})
export class WithdrawalsComponent implements OnInit {

  withdrawDataSOurce = WITHDRAW_DATA;
  dialogRef: MatDialogRef<any> | null;
  lastAfterClosedResult: string;
  lastBeforeCloseResult: string;
  actionsAlignment: string;
  btn_name: string;

  config = {
    disableClose: true,
    panelClass: 'custom-overlay-pane-class',
    hasBackdrop: true,
    backdropClass: '',
    width: '',
    height: '',
    minWidth: '',
    minHeight: '',
    maxWidth: defaultDialogConfig.maxWidth,
    maxHeight: '',
    position: {
      top: '',
      bottom: '',
      left: '',
      right: ''
    },
  };

  @ViewChild(TemplateRef) template: TemplateRef<any>;
  constructor(public dialog: MatDialog, @Inject(DOCUMENT) doc: any) {
    dialog.afterOpen.subscribe(() => {
      if (!doc.body.classList.contains('no-scroll')) {
        doc.body.classList.add('no-scroll');
      }
    });
    dialog.afterAllClosed.subscribe(() => {
      doc.body.classList.remove('no-scroll');
    });
  }

  ngOnInit() {
  }

  openDialog() {
    console.log(this.btn_name)
    this.dialogRef = this.dialog.open(DialogComponent, this.config);
    this.dialogRef.beforeClose().subscribe((result: string) => {
      this.lastBeforeCloseResult = result;
    });
    this.dialogRef.afterClosed().subscribe((result: string) => {
      this.lastAfterClosedResult = result;
      this.dialogRef = null;
    });
  }

}
export interface WithdrawDataElement {
  withdrawId: string;
  userName: string;
  amount: number;
  accountNo: string;
  bankName: string;
  remoteIp: string;
  status: string;
  createTime: string;
  executeTime: string;
  remark: string;

}
const WITHDRAW_DATA: WithdrawDataElement[] = [
  {
    withdrawId: "1",
    userName: "test",
    amount: 1500,
    accountNo: "123456789",
    bankName: "IBC",
    remoteIp: "0.0.0.0",
    status: "pending",
    createTime: "13-12-1992 00:00:0000",
    executeTime: "13-12-1992 00:00:0000",
    remark: "withdraw"
  },
  {
    withdrawId: "2",
    userName: "test",
    amount: 1500,
    accountNo: "123456789",
    bankName: "IBC",
    remoteIp: "0.0.0.0",
    status: "pending",
    createTime: "13-12-1992 00:00:0000",
    executeTime: "13-12-1992 00:00:0000",
    remark: "withdraw"
  },
  {
    withdrawId: "3",
    userName: "test",
    amount: 1500,
    accountNo: "123456789",
    bankName: "IBC",
    remoteIp: "0.0.0.0",
    status: "pending",
    createTime: "13-12-1992 00:00:0000",
    executeTime: "13-12-1992 00:00:0000",
    remark: "withdraw"
  },
  {
    withdrawId: "4",
    userName: "test",
    amount: 1500,
    accountNo: "123456789",
    bankName: "IBC",
    remoteIp: "0.0.0.0",
    status: "pending",
    createTime: "13-12-1992 00:00:0000",
    executeTime: "13-12-1992 00:00:0000",
    remark: "withdraw"
  },
  {
    withdrawId: "5",
    userName: "test",
    amount: 1500,
    accountNo: "123456789",
    bankName: "IBC",
    remoteIp: "0.0.0.0",
    status: "pending",
    createTime: "13-12-1992 00:00:0000",
    executeTime: "13-12-1992 00:00:0000",
    remark: "withdraw"
  }
];