import {Component, OnInit} from '@angular/core';
import {AlarmService} from '../../alarm.service';
import {pageSize} from '../../../app.constants';

@Component({
    selector: 'smart-send-log',
    templateUrl: './send-log.component.html',
    styles: []
})
export class SendLogComponent implements OnInit {

    isShow = false;
    data;
    logList = [];
    loading = false;

    pageCount = pageSize;
    pageNum = 1;
    totalNum;

    constructor(public alarmSer: AlarmService) {
    }

    ngOnInit() {
        // this.getList();
    }

    showModal(data) {
        this.data = data;
        this.isShow = true;
        this.getList();
    }

    //获取列表
    getList() {
        const data1 = {
            hostids: [this.data.hostid],
            groupid: [this.data.groupid],
            eventPage: this.pageNum,
            pageRecords: this.pageCount
        };
        this.alarmSer.alertFind(data1).subscribe(
            (res) => {
                this.logList = res.data.data;
                this.totalNum = res.data.totalNum;
            }
        );
    }

    //关闭
    closeModal() {
        this.isShow = false;
    }

    //翻页
    change(e){
        this.pageNum = e;
        this.getList();
    }

}
