import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs/Rx';
import {Injectable} from '@angular/core';
import {SERVER_API_URL} from '../app.constants';

@Injectable()
export class OverAllService {

    constructor(private http: HttpClient) {
    }

    //资源列表--所有类型
    find(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/find', data);
    }

    //停止-开启监控
    stopOrOpen(params1, params2): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/stopOrOpen/' + params1 + '/' + params2);
    }

    //批量停止开启监控接口
    batchStopOrOpen(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/batchStopOrOpen', data);
    }

    //资源列表--资源分组
    findGroup(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/groups/getAll');
    }

    //资源列表--设备类型
    findType(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostType/selectAllEquipmentType');
    }

    //根据设备类型查询主机资源
    findHostByType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/selectAllHostByType/', data);
    }

    //资源列表--查询主机
    findDetail(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/find', data);
    }

    //资源详情
    findDetailed(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findDetailed/' + data);
    }

    //平均响应时间
    responseTime(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/responseTime/' + data);
    }

    //丢包率
    losed(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/losed/' + data);
    }

    //CPU使用率
    cupUsed(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/cpuUsed/' + data.hostId + '/' + data.hostType);
    }

    //内存使用率
    used(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/used/' + data.hostId + '/' + data.hostType);
    }

    //磁盘使用率
    disks(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/disks/' + data.hostId + '/' + data.hostType);
    }

    //进出口流量    --SNMP
    inOutInfoSnmp(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/inOutInfo', data);
    }

    //进出口流量    --
    inOutInfoAgent(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/inOutInfoAgent/' + data);
    }

    //主机接口
    getinterface(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostInterface/getinterface/' + data);
    }

    //查询键值
    zabbixKey(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/zabbixKey/find/' + data);
    }

    //创建监控点
    create(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/create', data);
    }

    //删除资源--get
    deleteHostGet(data): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/deleteHost/' + data);
    }

    //批量删除资源--post
    deleteHostPost(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/deleteHost', data);
    }

    //添加资源
    createHost(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/create', data);
    }

    //获取分组信息
    getgroups(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/groups/getgroups', data);
    }

    //模版信息
    templates(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/templates');
    }

    //添加分组
    createGroup(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/groups/create', data);
    }

    //修改分组
    updataGroup(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/groups/updata', data);
    }

    //删除分组
    deleteGroup(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/groups/delete', data);
    }

    //删除监控项
    deleteItem(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/deleteItem', data);
    }

    //监控设备数
    findSize(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findSize');
    }

    //监测点列表--type
    findCheckByType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/find/', data);
    }

    //查询监控项
    findItemDetail(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/item/details/' + params);
    }

    //监控项分类
    findItemType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/application/find', data);
    }

    //新增监控项分类
    createItemType(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/application/create', data);
    }

    //监测点状态统计
    findItemCount(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/item/findItemStatistics/' + params);
    }

    //监测点图形数据
    findGraphData(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/graph/findGraphData/', data);
    }

    //监控项修改状态
    itemUpdate(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/item/updata/', data);
    }

    itemUpdata(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/item/updata/', data);
    }

    //临时暂停
    tempStop(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/host/tempStop', data);
    }

    //查询报警主机 和报警数量 以及最高报警级别
    findHostWarningCount(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/statistics/findHostWarningCount');
    }

    //查询所有告警组
    findWarnAll(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/alertGroup/findAll');
    }

    //修改资源
    updateHost(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/host/updataHost', data);
    }

    //根据host的启用状态查询count 记录数
    findHostCountByStatus(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findHostCountByStatus/' + params);
    }

    //查询所有主机的警告数和高危报警数
    findWarningByAll(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/statistics/findWarningByAll/' + params);
    }

    //网站监测
    //查询网站监测列表
    findWebscenario(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/find', data);
    }

    //修改网站监测
    updateWebscenario(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/webscenario/update', data);
    }

    //创建网站监测
    createWebscenario(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/create', data);
    }

    //临时暂停
    tempStopWebscenario(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/tempStop', data);
    }

    //取消临时暂停
    tempStopCancelWebscenario(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/temp-stop-cancel/' + params);
    }

    //启用禁用网站监测
    statusBatch(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/statusBatch', data);
    }

    //批量删除网站监测
    deleteBatch(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/delete', data);
    }

    //查找单个网站监测(数据回显接口)
    findWeb(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find/' + params);
    }

    //添加告警-查询告警目标接口
    findAlertAim(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find-alert-aim/' + params);
    }

    //添加告警接口
    addWebAction(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/add-web-action', data);
    }

    //查找最近一条监测状态
    findCurrentState(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find-current-state/' + params);
    }

    //查找监测图表数据
    findChart(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/findChart', data);
    }

    //查找阈值设定
    findTrigger(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/find-trigger/' + params);
    }

    //网站监测历史告警
    findAlert(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/webscenario/findAlert', data);
    }

    //统计网站监测告警种类
    countStatus(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/webscenario/countStatus');
    }

    //查找所有设备类型tree
    findTree(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostType/findTree');
    }

    //创建触发器
    createTrigger(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/createItemTrigger', data);
    }

    //修改触发器
    updateTrigger(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/item/updateItemTrigger', data);
    }

    //查看映射值
    findValuemap(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/valuemap/find');
    }

}
