Commit 0e110478 authored by wenmo's avatar wenmo

报警组下拉多选报警实例

parent d2dbb824
...@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.JsonNode; ...@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -81,4 +82,12 @@ public class AlertInstanceController { ...@@ -81,4 +82,12 @@ public class AlertInstanceController {
alertInstance = alertInstanceService.getById(alertInstance.getId()); alertInstance = alertInstanceService.getById(alertInstance.getId());
return Result.succeed(alertInstance,"获取成功"); return Result.succeed(alertInstance,"获取成功");
} }
/**
* 获取可用的报警实例列表
*/
@GetMapping("/listEnabledAll")
public Result listEnabledAll() {
return Result.succeed(alertInstanceService.listEnabledAll(),"获取成功");
}
} }
...@@ -3,6 +3,8 @@ package com.dlink.service; ...@@ -3,6 +3,8 @@ package com.dlink.service;
import com.dlink.db.service.ISuperService; import com.dlink.db.service.ISuperService;
import com.dlink.model.AlertInstance; import com.dlink.model.AlertInstance;
import java.util.List;
/** /**
* AlertInstanceService * AlertInstanceService
* *
...@@ -10,4 +12,6 @@ import com.dlink.model.AlertInstance; ...@@ -10,4 +12,6 @@ import com.dlink.model.AlertInstance;
* @since 2022/2/24 19:52 * @since 2022/2/24 19:52
**/ **/
public interface AlertInstanceService extends ISuperService<AlertInstance> { public interface AlertInstanceService extends ISuperService<AlertInstance> {
List<AlertInstance> listEnabledAll();
} }
package com.dlink.service.impl; package com.dlink.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dlink.db.service.impl.SuperServiceImpl; import com.dlink.db.service.impl.SuperServiceImpl;
import com.dlink.mapper.AlertInstanceMapper; import com.dlink.mapper.AlertInstanceMapper;
import com.dlink.model.AlertInstance; import com.dlink.model.AlertInstance;
import com.dlink.service.AlertInstanceService; import com.dlink.service.AlertInstanceService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* AlertInstanceServiceImpl * AlertInstanceServiceImpl
* *
...@@ -14,4 +17,8 @@ import org.springframework.stereotype.Service; ...@@ -14,4 +17,8 @@ import org.springframework.stereotype.Service;
**/ **/
@Service @Service
public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapper, AlertInstance> implements AlertInstanceService { public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapper, AlertInstance> implements AlertInstanceService {
@Override
public List<AlertInstance> listEnabledAll() {
return list(new QueryWrapper<AlertInstance>().eq("enabled",1));
}
} }
...@@ -164,6 +164,16 @@ export function showJars(dispatch: any) { ...@@ -164,6 +164,16 @@ export function showJars(dispatch: any) {
}); });
}); });
} }
/*--- 刷新 报警实例 ---*/
export function showAlertInstance(dispatch: any) {
const res = getData('api/alertInstance/listEnabledAll');
res.then((result) => {
result.datas && dispatch && dispatch({
type: "Alert/saveInstance",
payload: result.datas,
});
});
}
/*--- 刷新 元数据表 ---*/ /*--- 刷新 元数据表 ---*/
export function showMetaDataTable(id:number) { export function showMetaDataTable(id:number) {
return getData('api/database/getSchemasAndTables',{id:id}); return getData('api/database/getSchemasAndTables',{id:id});
......
...@@ -12,7 +12,7 @@ import StudioLeftTool from "./StudioLeftTool"; ...@@ -12,7 +12,7 @@ import StudioLeftTool from "./StudioLeftTool";
import StudioRightTool from "./StudioRightTool"; import StudioRightTool from "./StudioRightTool";
import { import {
listSession, showCluster, showDataBase, getFillAllByVersion, listSession, showCluster, showDataBase, getFillAllByVersion,
showClusterConfiguration, showSessionCluster, showJars, showEnv showClusterConfiguration, showSessionCluster, showJars, showEnv,showAlertInstance
} from "@/components/Studio/StudioEvent/DDL"; } from "@/components/Studio/StudioEvent/DDL";
import {loadSettings} from "@/pages/Settings/function"; import {loadSettings} from "@/pages/Settings/function";
import DraggleLayout from "@/components/DraggleLayout"; import DraggleLayout from "@/components/DraggleLayout";
...@@ -59,6 +59,7 @@ const Studio = (props: any) => { ...@@ -59,6 +59,7 @@ const Studio = (props: any) => {
showDataBase(dispatch); showDataBase(dispatch);
listSession(dispatch); listSession(dispatch);
showJars(dispatch); showJars(dispatch);
showAlertInstance(dispatch);
showEnv(dispatch); showEnv(dispatch);
onResize(); onResize();
}, []); }, []);
......
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {Form, Button, Input, Modal, Select,Divider,Switch} from 'antd'; import {Form, Button, Input, Modal, Select,Tag,Switch} from 'antd';
import {AlertGroupTableListItem} from "@/pages/AlertGroup/data"; import {AlertGroupTableListItem} from "@/pages/AlertGroup/data";
import {JarStateType} from "@/pages/Jar/model";
import {connect} from "umi";
import {StateType} from "@/pages/FlinkSqlStudio/model";
import {AlertStateType} from "@/pages/AlertInstance/model";
import {AlertInstanceTableListItem} from "@/pages/AlertInstance/data";
import {buildFormData, getFormData} from "@/pages/AlertGroup/function";
export type AlertGroupFormProps = { export type AlertGroupFormProps = {
onCancel: (flag?: boolean) => void; onCancel: (flag?: boolean) => void;
onSubmit: (values: Partial<AlertGroupTableListItem>) => void; onSubmit: (values: Partial<AlertGroupTableListItem>) => void;
modalVisible: boolean; modalVisible: boolean;
values: Partial<AlertGroupTableListItem>; values: Partial<AlertGroupTableListItem>;
instance: AlertInstanceTableListItem[];
}; };
const Option = Select.Option; const Option = Select.Option;
...@@ -30,12 +37,24 @@ const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => { ...@@ -30,12 +37,24 @@ const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => {
onSubmit: handleSubmit, onSubmit: handleSubmit,
onCancel: handleModalVisible, onCancel: handleModalVisible,
modalVisible, modalVisible,
instance,
} = props; } = props;
const getAlertInstanceOptions = () => {
const itemList = [];
for (const item of instance) {
const tag = (<><Tag color="processing">{item.type}</Tag>{item.name}</>);
itemList.push(<Option key={item.id} value={item.id.toString()} label={tag}>
{tag}
</Option>)
}
return itemList;
};
const submitForm = async () => { const submitForm = async () => {
const fieldsValue = await form.validateFields(); const fieldsValue = await form.validateFields();
setFormVals({...formVals, ...fieldsValue}); setFormVals(buildFormData(formVals,fieldsValue));
handleSubmit({...formVals, ...fieldsValue}); handleSubmit(buildFormData(formVals,fieldsValue));
}; };
const renderContent = (formVals) => { const renderContent = (formVals) => {
...@@ -52,7 +71,14 @@ const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => { ...@@ -52,7 +71,14 @@ const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => {
label="报警实例" label="报警实例"
help="请选择报警组实例" help="请选择报警组实例"
> >
<Input placeholder="请选择报警实例"/> <Select
mode="multiple"
style={{width: '100%'}}
placeholder="请选择报警实例"
optionLabelProp="label"
>
{getAlertInstanceOptions()}
</Select>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="note" name="note"
...@@ -95,12 +121,14 @@ const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => { ...@@ -95,12 +121,14 @@ const AlertGroupForm: React.FC<AlertGroupFormProps> = (props) => {
<Form <Form
{...formLayout} {...formLayout}
form={form} form={form}
initialValues={formVals} initialValues={getFormData(formVals)}
> >
{renderContent(formVals)} {renderContent(getFormData(formVals))}
</Form> </Form>
</Modal> </Modal>
); );
}; };
export default AlertGroupForm; export default connect(({Alert}: { Alert: AlertStateType }) => ({
instance: Alert.instance,
})) (AlertGroupForm);
import {AlertGroupTableListItem} from "@/pages/AlertGroup/data";
export const getFormData = (values: AlertGroupTableListItem) => {
let alertInstanceIds:string [] = [];
if(values&&values.alertInstanceIds&&values.alertInstanceIds!=''){
alertInstanceIds = values.alertInstanceIds.split(',');
}
return {...values,alertInstanceIds:alertInstanceIds};
}
export const buildFormData = (values: AlertGroupTableListItem,params: any) => {
let newValue = values;
if(params.alertInstanceIds){
newValue.alertInstanceIds = params.alertInstanceIds.join(',');
delete params.alertInstanceIds;
}
return {...newValue,...params};
}
...@@ -83,6 +83,9 @@ const AlertGroupTableList: React.FC<{}> = (props: any) => { ...@@ -83,6 +83,9 @@ const AlertGroupTableList: React.FC<{}> = (props: any) => {
title: '报警实例', title: '报警实例',
sorter: true, sorter: true,
dataIndex: 'alertInstanceIds', dataIndex: 'alertInstanceIds',
hideInTable: true,
hideInForm: true,
hideInSearch: true,
}, },
{ {
title: '注释', title: '注释',
...@@ -286,7 +289,7 @@ const AlertGroupTableList: React.FC<{}> = (props: any) => { ...@@ -286,7 +289,7 @@ const AlertGroupTableList: React.FC<{}> = (props: any) => {
)} )}
</Drawer> </Drawer>
</PageContainer> </PageContainer>
); );
}; };
export default AlertGroupTableList; export default AlertGroupTableList;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment