Skip to content
select-trigger.component.ts 2.24 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {OverAllService} from '../../overAll/overAll.service';
import {pageSize} from '../../app.constants';
wangqinghua's avatar
wangqinghua committed

@Component({
  selector: 'smart-select-trigger',
  templateUrl: './select-trigger.component.html',
  styles: []
})
export class SelectTriggerComponent implements OnInit {
wangqinghua's avatar
wangqinghua committed
    @Output() done = new EventEmitter<string>();
    isVisiable = false;
    isLoading = false;
    dataSet;
wangqinghua's avatar
wangqinghua committed

wangqinghua's avatar
wangqinghua committed
    name;
wangqinghua's avatar
wangqinghua committed

wangqinghua's avatar
wangqinghua committed
    groupList;   // 分组列表
    hostList;   //主机列表

    obj = {
        groupid:null,
        name:null,
        hostid:null,
    }

    constructor(private overAllSer: OverAllService) {
    }

    ngOnInit() {
        this.getGroup();
    }

    //获取分组
    getGroup() {
        this.overAllSer.findGroup().subscribe(
            (res) => {
                if (res.errCode == 10000) {
                    this.groupList = res.data;
                    this.obj.groupid = this.groupList[0].groupid + '';
                    this.getHost();
                }
            }
        );
    }

    //获取主机列表
    getHost() {
        const data = {
            'groupids': [this.obj.groupid],
            'hostExtend': {
                'superiorHostid': null
            }
        };
        this.overAllSer.findDetail(data).subscribe(
            (res) => {
                if (res.errCode == 10000) {
                    this.hostList = res.data;
                    this.obj.hostid = this.hostList[0].hostid + '';
wangqinghua's avatar
wangqinghua committed
                    this.getwebList();
wangqinghua's avatar
wangqinghua committed
                }
            }
        );
    }

    showModal() {
        this.isVisiable = true;
    }

    //阈值列表
    getwebList() {
        this.isLoading = true;
        const data = {
            queryName: this.obj.name,
            hostid: this.obj.hostid
        };
        this.overAllSer.findTri(data).subscribe(
            (res) => {
                if (res.errCode == 10000) {
wangqinghua's avatar
wangqinghua committed
                    this.dataSet = res.data;
wangqinghua's avatar
wangqinghua committed
                }
                this.isLoading = false;
            }
        );
    }

    set(item) {
        this.done.emit(item);
        this.isVisiable = false;
    }

    handleCancel() {
        this.isVisiable = false;
    }

    handleOk() {
        this.isVisiable = false;
    }
wangqinghua's avatar
wangqinghua committed

}