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

@Injectable()
export class LayoutService {

    constructor(private http: HttpClient) {
    }

    //当前登录人菜单
    getMenu(): Observable<any>{
        return this.http.get(SERVER_API_URL_COMS + '/resources/getMenu');
    }

    //所有菜单
    getAllMenu(): Observable<any>{
        return this.http.get(SERVER_API_URL_COMS  + "/resources/getAll");
    }

    //修改密码
    modifyPassword(data): Observable<any>{
        return this.http.post(SERVER_API_URL_COMS  + "/modifyPassword",data);
    }

    //首页
    //主机组中的主机数量统计
    findGroupCount(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/groups/findGroupCount');
    }

    //查询设备类型下主机的数量
    findHostCount(): Observable<any> {
        return this.http.get(SERVER_API_URL + '/hostType/findHostCount');
    }

    //主机状态统计（用于首页）
    findHostCountByStatusByGroup(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/host/findHostCountByStatus');
    }

    //根据组id统计监控项状态数量
    findItemStatisticsByGroupid(params): Observable<any> {
        return this.http.get(SERVER_API_URL + '/item/findItemCountByStatus');
    }

    //取消关注
    unFollow(data): Observable<any>{
        return this.http.post(SERVER_API_URL  + "/userFollow/unFollow",data);
    }

    //添加关注
    addFollow(data): Observable<any>{
        return this.http.post(SERVER_API_URL  + "/userFollow/addFollow",data);
    }

    //我的关注
    myFollow(): Observable<any>{
        return this.http.get(SERVER_API_URL  + "/userFollow/myFollowDetail");
    }

}
