import {
  Component,
  OnInit,
  ChangeDetectionStrategy,
  Input,
  Output,
  EventEmitter,
  OnChanges,
  ChangeDetectorRef
} from '@angular/core';
import {BaseList} from '../../../../../../core/base/base-list';
import {AppTokenService} from '../../../../../../core/service/security/app-token.service';
import {
  TestingInformationService
} from "../../../../../../core/service/testing-information/testing-information.service";
import {catchError, concatMap, filter, tap} from "rxjs/operators";
import {throwError} from "rxjs";
import {SweetalertService} from "../../../../../../core/service/sweetalert/sweetalert";

@Component({
  selector: 'app-approve-exam-list',
  templateUrl: './approve-exam-list.component.html',
  styleUrls: ['./approve-exam-list.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class ApproveExamListComponent extends BaseList implements OnInit, OnChanges {
  @Input() subjectList: any = [];
  @Output() edit = new EventEmitter();
  @Output() open = new EventEmitter();
  @Output() view = new EventEmitter();
  @Output() expand = new EventEmitter();
  @Output() delete = new EventEmitter();
  column = [
    '1',
    'testing_information_code',
    'testing_information_name',
    'academic_semester_code',
    'academic_year_code',
    '10',
    'count_subject',
    'is_open',
    '7',
    'updated_by',
    'updated_datetime'
  ];
  private reload: boolean;
  constructor(
    private TestInformationSV: TestingInformationService,
    private swSV: SweetalertService,
    private cdr: ChangeDetectorRef,

  ) {
    super();
  }

  ngOnInit(): void {
        this.reload = false;
        setTimeout(() => {
        this.reload = true;
        }, 2000);
  }

  ngOnChanges(){
      this.subjectList = this.updateMatTable(this.subjectList ? this.subjectList : []);
  }

  onEdit(id){
      this.edit.emit(id);
  }

  onOpen(id){
      this.open.emit(id);
  }

}
