[manager,web-app] 监控列表,新增修改监控等编码
This commit is contained in:
@@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import {Message} from "../pojo/Message";
|
||||
import {Observable} from "rxjs";
|
||||
import {ParamDefine} from "../pojo/ParamDefine";
|
||||
|
||||
|
||||
@Injectable({
|
||||
@@ -11,12 +12,12 @@ export class AppDefineService {
|
||||
|
||||
constructor(private http : HttpClient) { }
|
||||
|
||||
public getAppParamsDefine(app: string | undefined | null) : Observable<Message> {
|
||||
public getAppParamsDefine(app: string | undefined | null) : Observable<Message<ParamDefine[]>> {
|
||||
if (app === null || app === undefined) {
|
||||
console.log("getAppParamsDefine app can not null");
|
||||
}
|
||||
const paramDefineUri = `/apps/${app}/params`;
|
||||
return this.http.get<Message>(paramDefineUri);
|
||||
return this.http.get<Message<ParamDefine[]>>(paramDefineUri);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {HttpClient, HttpParams} from "@angular/common/http";
|
||||
import {Observable} from "rxjs";
|
||||
import {Message} from "../pojo/Message";
|
||||
import {Page} from "../pojo/Page";
|
||||
import {Monitor} from "../pojo/Monitor";
|
||||
|
||||
const monitor_uri = "/monitor";
|
||||
const monitors_uri = "/monitors";
|
||||
const detect_monitor_uri = "/monitor/detect"
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -12,8 +16,49 @@ export class MonitorService {
|
||||
|
||||
constructor(private http : HttpClient) { }
|
||||
|
||||
public newMonitor(body: any) : Observable<Message> {
|
||||
return this.http.post<Message>(monitor_uri, body);
|
||||
public newMonitor(body: any) : Observable<Message<any>> {
|
||||
return this.http.post<Message<any>>(monitor_uri, body);
|
||||
}
|
||||
|
||||
public editMonitor(body: any) : Observable<Message<any>> {
|
||||
return this.http.put<Message<any>>(monitor_uri, body);
|
||||
}
|
||||
|
||||
public deleteMonitor(monitorId: number) : Observable<Message<any>> {
|
||||
return this.http.delete<Message<any>>(`${monitor_uri}/${monitorId}`);
|
||||
}
|
||||
|
||||
public deleteMonitors(monitorIds: Set<number>) : Observable<Message<any>> {
|
||||
let httpParams = new HttpParams();
|
||||
monitorIds.forEach(monitorId => {
|
||||
// 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象
|
||||
httpParams = httpParams.set('ids', monitorId);
|
||||
})
|
||||
const options = { params: httpParams };
|
||||
return this.http.delete<Message<any>>(monitors_uri, options);
|
||||
}
|
||||
|
||||
public detectMonitor(body: any) : Observable<Message<any>> {
|
||||
return this.http.post<Message<any>>(detect_monitor_uri, body);
|
||||
}
|
||||
|
||||
public getMonitor(monitorId: number) : Observable<Message<any>> {
|
||||
return this.http.get<Message<any>>(`${monitor_uri}/${monitorId}`);
|
||||
}
|
||||
|
||||
public getMonitors(app: string, pageIndex: number, pageSize: number) : Observable<Message<Page<Monitor>>> {
|
||||
app = app.trim();
|
||||
pageIndex = pageIndex ? 1 : pageIndex;
|
||||
pageSize = pageSize ? 10 : pageSize;
|
||||
// 注意HttpParams是不可变对象 需要保存set后返回的对象为最新对象
|
||||
let httpParams = new HttpParams();
|
||||
httpParams = httpParams.appendAll({
|
||||
'app': app,
|
||||
'pageIndex': pageIndex,
|
||||
'pageSize': pageSize
|
||||
});
|
||||
const options = { params: httpParams };
|
||||
return this.http.get<Message<Page<Monitor>>>(monitors_uri, options);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user