[manager,web-app] 监控参数支持单选options
This commit is contained in:
@@ -1,25 +0,0 @@
|
|||||||
package com.usthe.manager.pojo.entity;
|
|
||||||
|
|
||||||
import com.usthe.common.util.GsonUtil;
|
|
||||||
|
|
||||||
import javax.persistence.AttributeConverter;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* json 互转map对象字段为数据String字段
|
|
||||||
* @author tom
|
|
||||||
* @date 2021/12/4 07:54
|
|
||||||
*/
|
|
||||||
public class JsonMapAttributeConverter implements AttributeConverter<Map<String,String>, String> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String convertToDatabaseColumn(Map<String,String> attribute) {
|
|
||||||
return GsonUtil.toJson(attribute);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String,String> convertToEntityAttribute(String dbData) {
|
|
||||||
return GsonUtil.fromJson(dbData, Map.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.usthe.manager.pojo.entity;
|
||||||
|
|
||||||
|
import com.usthe.common.util.GsonUtil;
|
||||||
|
|
||||||
|
import javax.persistence.AttributeConverter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* json 互转map对象字段为数据String字段
|
||||||
|
* @author tom
|
||||||
|
* @date 2021/12/4 07:54
|
||||||
|
*/
|
||||||
|
public class JsonOptionListAttributeConverter implements AttributeConverter<List<ParamDefine.Option>, String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String convertToDatabaseColumn(List<ParamDefine.Option> attribute) {
|
||||||
|
return GsonUtil.toJson(attribute);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ParamDefine.Option> convertToEntityAttribute(String dbData) {
|
||||||
|
return GsonUtil.fromJson(dbData, List.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import javax.persistence.GenerationType;
|
|||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.List;
|
||||||
|
|
||||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_ONLY;
|
||||||
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
import static io.swagger.annotations.ApiModelProperty.AccessMode.READ_WRITE;
|
||||||
@@ -107,8 +107,8 @@ public class ParamDefine {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "当type为radio单选框,checkbox复选框时,option表示可选项值列表", example = "{key1,value1}", accessMode = READ_WRITE, position = 8)
|
@ApiModelProperty(value = "当type为radio单选框,checkbox复选框时,option表示可选项值列表", example = "{key1,value1}", accessMode = READ_WRITE, position = 8)
|
||||||
@Column(name = "param_options")
|
@Column(name = "param_options")
|
||||||
@Convert(converter = JsonMapAttributeConverter.class)
|
@Convert(converter = JsonOptionListAttributeConverter.class)
|
||||||
private Map<String,String> options;
|
private List<Option> options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 此条记录创建者
|
* 此条记录创建者
|
||||||
@@ -133,4 +133,18 @@ public class ParamDefine {
|
|||||||
*/
|
*/
|
||||||
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 12)
|
@ApiModelProperty(value = "记录最新修改时间(毫秒时间戳)", example = "1612198444000", accessMode = READ_ONLY, position = 12)
|
||||||
private LocalDateTime gmtUpdate;
|
private LocalDateTime gmtUpdate;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public static final class Option {
|
||||||
|
/**
|
||||||
|
* 值显示标签
|
||||||
|
*/
|
||||||
|
private String label;
|
||||||
|
/**
|
||||||
|
* 可选值
|
||||||
|
*/
|
||||||
|
private String value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,6 +187,12 @@ public class MonitorServiceImpl implements MonitorService {
|
|||||||
+ booleanValue + " is invalid boolean value.");
|
+ booleanValue + " is invalid boolean value.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "radio":
|
||||||
|
// todo radio校验
|
||||||
|
break;
|
||||||
|
case "checkbox":
|
||||||
|
// todo checkbox校验
|
||||||
|
break;
|
||||||
// todo 更多参数定义与实际值格式校验
|
// todo 更多参数定义与实际值格式校验
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("ParamDefine type " + paramDefine.getType() + " is invalid.");
|
throw new IllegalArgumentException("ParamDefine type " + paramDefine.getType() + " is invalid.");
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
|
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
|
||||||
app: TanCloud
|
app: exapmle_type
|
||||||
# 参数映射map. type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串
|
# 参数映射map. type是参数类型: 0-number数字, 1-string明文字符串, 2-secret加密字符串
|
||||||
# 强制固定必须参数 - host
|
# 强制固定必须参数 - host
|
||||||
configmap:
|
configmap:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
|
# 监控应用类型名称(与文件名保持一致) eg: linux windows tomcat mysql aws...
|
||||||
app: TanCloud
|
app: exapmle_type
|
||||||
# 强制固定必须参数 - host(ipv4,ipv6,域名)
|
# 强制固定必须参数 - host(ipv4,ipv6,域名)
|
||||||
param:
|
param:
|
||||||
# field-字段名称标识符
|
# field-字段名称标识符
|
||||||
@@ -32,8 +32,20 @@ param:
|
|||||||
required: false
|
required: false
|
||||||
- field: ssl
|
- field: ssl
|
||||||
name: 启动SSL
|
name: 启动SSL
|
||||||
|
# 当type为boolean时,前端用switch展示开关
|
||||||
type: boolean
|
type: boolean
|
||||||
required: false
|
required: false
|
||||||
# 当type为boolean时,前端用switch展示开关
|
- field: method
|
||||||
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表
|
name: 请求方式
|
||||||
# option: Yes,No
|
type: radio
|
||||||
|
required: true
|
||||||
|
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表 {name1:value1,name2:value2}
|
||||||
|
options:
|
||||||
|
- label: GET请求
|
||||||
|
value: GET
|
||||||
|
- label: POST请求
|
||||||
|
value: POST
|
||||||
|
- label: PUT请求
|
||||||
|
value: PUT
|
||||||
|
- label: DELETE请求
|
||||||
|
value: DELETE
|
||||||
@@ -23,13 +23,22 @@ param:
|
|||||||
# 当type为text时,用limit表示字符串限制大小
|
# 当type为text时,用limit表示字符串限制大小
|
||||||
limit: 100
|
limit: 100
|
||||||
required: true
|
required: true
|
||||||
placeholder: 'eg:/index.html'
|
placeholder: '请输入网站的URI,例如:/index.html'
|
||||||
- field: method
|
- field: method
|
||||||
name: 请求方式
|
name: 请求方式
|
||||||
type: text
|
type: radio
|
||||||
# 当type为text时,用limit表示字符串限制大小
|
|
||||||
limit: 20
|
|
||||||
required: true
|
required: true
|
||||||
|
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表 {name1:value1,name2:value2}
|
||||||
|
options:
|
||||||
|
- label: GET请求
|
||||||
|
value: GET
|
||||||
|
- label: POST请求
|
||||||
|
value: POST
|
||||||
|
- label: PUT请求
|
||||||
|
value: PUT
|
||||||
|
- label: DELETE请求
|
||||||
|
value: DELETE
|
||||||
|
|
||||||
- field: username
|
- field: username
|
||||||
name: 用户名
|
name: 用户名
|
||||||
type: text
|
type: text
|
||||||
@@ -42,8 +51,6 @@ param:
|
|||||||
required: false
|
required: false
|
||||||
- field: ssl
|
- field: ssl
|
||||||
name: 使用SSL
|
name: 使用SSL
|
||||||
|
# 当type为boolean时,前端用switch展示开关
|
||||||
type: boolean
|
type: boolean
|
||||||
required: true
|
required: true
|
||||||
# 当type为boolean时,前端用switch展示开关
|
|
||||||
# 当type为radio单选框,checkbox复选框时,option表示可选项值列表
|
|
||||||
# option: Yes,No
|
|
||||||
@@ -7,5 +7,6 @@ export class ParamDefine {
|
|||||||
placeholder!: string;
|
placeholder!: string;
|
||||||
range: string | undefined;
|
range: string | undefined;
|
||||||
limit: number | undefined;
|
limit: number | undefined;
|
||||||
options: string | undefined;
|
//'[{"label":"GET请求","value":"GET"},{"label":"PUT请求","value":"PUT"}]'
|
||||||
|
options!: any[];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,20 @@
|
|||||||
<nz-switch [(ngModel)]="params[i].value" [name]="paramDefine.field" [id]="paramDefine.field"></nz-switch>
|
<nz-switch [(ngModel)]="params[i].value" [name]="paramDefine.field" [id]="paramDefine.field"></nz-switch>
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
|
|
||||||
|
<nz-form-label *ngIf="paramDefine.type === 'radio'"
|
||||||
|
nzSpan="7"
|
||||||
|
[nzRequired]="paramDefine.required"
|
||||||
|
[nzFor]= "paramDefine.field">{{paramDefine.name}}
|
||||||
|
</nz-form-label>
|
||||||
|
<nz-form-control *ngIf="paramDefine.type === 'radio'" nzSpan="10">
|
||||||
|
<nz-radio-group [(ngModel)]="params[i].value" nzButtonStyle="solid"
|
||||||
|
[name]="paramDefine.field" [id]="paramDefine.field">
|
||||||
|
<label nz-radio-button [nzValue]="optionItem.value" *ngFor="let optionItem of paramDefine.options">
|
||||||
|
{{optionItem.label}}
|
||||||
|
</label>
|
||||||
|
</nz-radio-group>
|
||||||
|
</nz-form-control>
|
||||||
|
|
||||||
</nz-form-item >
|
</nz-form-item >
|
||||||
|
|
||||||
<nz-divider></nz-divider>
|
<nz-divider></nz-divider>
|
||||||
|
|||||||
@@ -96,6 +96,20 @@
|
|||||||
<nz-switch [(ngModel)]="params[i].value" [name]="paramDefine.field" [id]="paramDefine.field"></nz-switch>
|
<nz-switch [(ngModel)]="params[i].value" [name]="paramDefine.field" [id]="paramDefine.field"></nz-switch>
|
||||||
</nz-form-control>
|
</nz-form-control>
|
||||||
|
|
||||||
|
<nz-form-label *ngIf="paramDefine.type === 'radio'"
|
||||||
|
nzSpan="7"
|
||||||
|
[nzRequired]="paramDefine.required"
|
||||||
|
[nzFor]= "paramDefine.field">{{paramDefine.name}}
|
||||||
|
</nz-form-label>
|
||||||
|
<nz-form-control *ngIf="paramDefine.type === 'radio'" nzSpan="10">
|
||||||
|
<nz-radio-group [(ngModel)]="params[i].value" nzButtonStyle="solid"
|
||||||
|
[name]="paramDefine.field" [id]="paramDefine.field">
|
||||||
|
<label nz-radio-button [nzValue]="optionItem.value" *ngFor="let optionItem of paramDefine.options">
|
||||||
|
{{optionItem.label}}
|
||||||
|
</label>
|
||||||
|
</nz-radio-group>
|
||||||
|
</nz-form-control>
|
||||||
|
|
||||||
</nz-form-item >
|
</nz-form-item >
|
||||||
|
|
||||||
<nz-divider></nz-divider>
|
<nz-divider></nz-divider>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import {ChangeDetectorRef, Component, OnInit} from '@angular/core';
|
||||||
import {ParamDefine} from "../../../pojo/ParamDefine";
|
import {ParamDefine} from "../../../pojo/ParamDefine";
|
||||||
import {AppDefineService} from "../../../service/app-define.service";
|
import {AppDefineService} from "../../../service/app-define.service";
|
||||||
import {ActivatedRoute, ParamMap, Router} from "@angular/router";
|
import {ActivatedRoute, ParamMap, Router} from "@angular/router";
|
||||||
@@ -30,6 +30,7 @@ export class MonitorNewComponent implements OnInit {
|
|||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private router: Router,
|
private router: Router,
|
||||||
private notifySvc: NzNotificationService,
|
private notifySvc: NzNotificationService,
|
||||||
|
private cdr: ChangeDetectorRef,
|
||||||
private i18n: I18NService,
|
private i18n: I18NService,
|
||||||
private formBuilder: FormBuilder) {
|
private formBuilder: FormBuilder) {
|
||||||
this.monitor = new Monitor();
|
this.monitor = new Monitor();
|
||||||
@@ -134,5 +135,4 @@ export class MonitorNewComponent implements OnInit {
|
|||||||
app = app ? app : '';
|
app = app ? app : '';
|
||||||
this.router.navigateByUrl(`/monitors?app=${app}`)
|
this.router.navigateByUrl(`/monitors?app=${app}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {NzBreadCrumbModule} from "ng-zorro-antd/breadcrumb";
|
|||||||
import {NzDividerModule} from "ng-zorro-antd/divider";
|
import {NzDividerModule} from "ng-zorro-antd/divider";
|
||||||
import {NzSwitchModule} from "ng-zorro-antd/switch";
|
import {NzSwitchModule} from "ng-zorro-antd/switch";
|
||||||
import {NzTagModule} from "ng-zorro-antd/tag";
|
import {NzTagModule} from "ng-zorro-antd/tag";
|
||||||
|
import {NzRadioModule} from "ng-zorro-antd/radio";
|
||||||
|
|
||||||
const COMPONENTS: Type<void>[] = [
|
const COMPONENTS: Type<void>[] = [
|
||||||
MonitorNewComponent,
|
MonitorNewComponent,
|
||||||
@@ -24,7 +25,8 @@ const COMPONENTS: Type<void>[] = [
|
|||||||
NzBreadCrumbModule,
|
NzBreadCrumbModule,
|
||||||
NzDividerModule,
|
NzDividerModule,
|
||||||
NzSwitchModule,
|
NzSwitchModule,
|
||||||
NzTagModule
|
NzTagModule,
|
||||||
|
NzRadioModule
|
||||||
],
|
],
|
||||||
declarations: COMPONENTS,
|
declarations: COMPONENTS,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user