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 TopologyService {

    constructor(private http: HttpClient) {
    }

    //查询所有拓扑图
    findAll(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysmapJson/findAll');
    }

    //根据拓扑图ID查询
    findItem(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysmapJson/find/' + params);
    }

    //创建拓扑图
    create(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysmapJson/create' , data);
    }

    //修改拓扑图
    update(data): Observable<any> {
        return this.http.put(SERVER_API_URL + '/sysmapJson/update' , data);
    }

    //删除拓扑图
    delete(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/sysmapJson/delete/' + params);
    }

    //删除图标
    iconDelete(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/icon/delete' ,data);
    }

    //查询所有图标
    iconFindAll(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/icon/findAll' , data);
    }

    //添加图标
    iconUpload(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/icon/upload' , data);
    }

    //设置默认图标
    iconDefault(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/default/' + params);
    }

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

    //查找主机组, 主机, 监控项, 网站
    findTree(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysmapJson/findTree',data);
    }

    //查找图标
    findDefaultIcon(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/icon/findDefaultIcon',data);
    }

    //添加图片
    addPic(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysmapJson/addPic',data);
    }

    //流量统计图接口
    findTrendData(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trend/findTrendData',data);
    }

    // 接受/发送流量列表
    findTrend(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/trend/findTrend',data);
    }

    //根据元素ID集合查询监测点状态
    findElementStatus(data): Observable<any> {
        return this.http.post(SERVER_API_URL + '/sysmapJson/findElementStatus',data);
    }
}
