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

@Injectable()
export class MonitorService {
    constructor(private http: HttpClient,) {
    }

    //认证
    auth(data): Observable<any> {
        return this.http.post(SERVER_API_URL_MONITOR + '/monitor/auth', data);
    }

    //增加一个或多个告警
    alarms(data): Observable<any> {
        return this.http.post(SERVER_API_URL_MONITOR + '/monitor/alarms', data);
    }

    //更新某个告警属性，比如告警级别，告警描述等
    alarmsPut(params, data): Observable<any> {
        return this.http.put(SERVER_API_URL_MONITOR + '/monitor/alarms/' + params, data);
    }

    //删除告警
    alarmsDelete(params, data): Observable<any> {
        return this.http.delete(SERVER_API_URL_MONITOR + '/monitor/alarms/' + params, data);
    }

    //确认告警
    alarmsPost(params, data): Observable<any> {
        return this.http.post(SERVER_API_URL_MONITOR + '/monitor/alarm/ack', data);
    }

    //推送实时数据
    data(data): Observable<any> {
        return this.http.post(SERVER_API_URL_MONITOR + '/monitor/data', data);
    }

    //增加资产
    asset(data): Observable<any> {
        return this.http.post(SERVER_API_URL_MONITOR + '/monitor/asset', data);
    }

    //更新单个资产
    assetPut(params, data): Observable<any> {
        return this.http.put(SERVER_API_URL_MONITOR + '/monitor/asset/' + params, data);
    }

    //删除单个资产
    assetDelete(params, data): Observable<any> {
        return this.http.delete(SERVER_API_URL_MONITOR + '/monitor/asset/' + params, data);
    }

    //查询资产
    findAsset(params, data): Observable<any> {
        return this.http.post(SERVER_API_URL_MONITOR + '/monitor/asset', data);
    }

    //获取资产及扩展字段
}
