Unverified Commit 37457a57 authored by Zzm0809's avatar Zzm0809 Committed by GitHub

support http alert (#2688)

* support-http-alert * Spotless Apply * fix render icon * send msg support * Spotless Apply --------- Co-authored-by: 's avatarZzm0809 <Zzm0809@users.noreply.github.com>
parent bc60bac5
......@@ -20,6 +20,7 @@
package org.dinky.data.model.ext;
import org.dinky.assertion.Asserts;
import org.dinky.data.ext.ConfigItem;
import java.io.Serializable;
import java.util.ArrayList;
......
......@@ -52,7 +52,7 @@ public class FeiShuSenderTest {
FeiShuAlert feiShuAlert = new FeiShuAlert();
AlertConfig alertConfig = new AlertConfig();
alertConfig.setType("FeiShu");
alertConfig.setType(FeiShuConstants.TYPE);
alertConfig.setParam(feiShuConfig);
feiShuAlert.setConfig(alertConfig);
......
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.dinky</groupId>
<artifactId>dinky-alert</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>dinky-alert-http</artifactId>
<packaging>jar</packaging>
<name>Dinky : Alter : Http</name>
<dependencies>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-alert-base</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.alert.http;
import org.dinky.alert.AbstractAlert;
import org.dinky.alert.AlertResult;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* DingTalkAlert
*
* @since 2022/2/23 19:28
*/
public class HttpAlert extends AbstractAlert {
private static final Logger log = LoggerFactory.getLogger(HttpAlert.class);
@Override
public String getType() {
return HttpConstants.TYPE;
}
@Override
public AlertResult send(String title, String content) {
HttpSender sender = new HttpSender(getConfig().getParam());
Map<String, Object> templateParams = sender.buildTemplateParams(title, content);
return sender.send(templateParams);
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.alert.http;
/** DingTalkConstants */
public class HttpConstants {
public static final String TYPE = "Http";
public static final String ALERT_TEMPLATE_TITLE = "title";
public static final String ALERT_TEMPLATE_CONTENT = "content";
public static final String REQUEST_TYPE_POST = "POST";
public static final String REQUEST_TYPE_GET = "GET";
public static final String DEFAULT_CHARSET = "UTF-8";
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.alert.http;
import org.dinky.alert.AlertResult;
import org.dinky.alert.http.params.HttpParams;
import org.dinky.assertion.Asserts;
import org.dinky.data.ext.ConfigItem;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
/**
* DingTalkSender
*/
public class HttpSender {
private static final Logger logger = LoggerFactory.getLogger(HttpSender.class);
private final HttpParams httpParams;
private HttpRequestBase httpRequest;
HttpSender(Map<String, Object> config) {
this.httpParams = JSONUtil.toBean(JSONUtil.toJsonStr(config), HttpParams.class);
Asserts.checkNotNull(httpParams, "httpParams is null");
}
/**
* build template params
*
* @param title
* @param content
* @return
*/
public Map<String, Object> buildTemplateParams(String title, String content) {
Map<String, Object> params = new HashMap<>();
params.put(HttpConstants.ALERT_TEMPLATE_TITLE, title);
params.put(HttpConstants.ALERT_TEMPLATE_CONTENT, content);
return params;
}
/**
* send msg of main
*
* @param content: send msg content
* @return AlertResult
*/
public AlertResult send(Map<String, Object> templateParams) {
AlertResult alertResult = new AlertResult();
try {
createHttpRequest(templateParams);
} catch (MalformedURLException | URISyntaxException e) {
throw new RuntimeException(e);
}
if (httpParams.getMethod() == null) {
alertResult.setSuccess(false);
alertResult.setMessage("Request types are not supported");
return alertResult;
}
try {
String resp = this.getResponseString(httpRequest);
alertResult.setSuccess(true);
alertResult.setMessage(resp);
} catch (Exception e) {
logger.error("send http alert msg exception : {}", e.getMessage());
alertResult.setSuccess(false);
alertResult.setMessage("send http request alert fail.");
}
return alertResult;
}
private void createHttpRequest(Map<String, Object> templateParams)
throws MalformedURLException, URISyntaxException {
if (HttpConstants.REQUEST_TYPE_POST.equals(httpParams.getMethod())) {
httpRequest = new HttpPost(httpParams.getUrl());
buildRequestHeader();
buildMsgToRequestBody(templateParams);
} else if (HttpConstants.REQUEST_TYPE_GET.equals(httpParams.getMethod())) {
buildMsgToUrl(templateParams);
URL unencodeUrl = new URL(httpParams.getUrl());
URI uri = new URI(
unencodeUrl.getProtocol(),
unencodeUrl.getHost(),
unencodeUrl.getPath(),
unencodeUrl.getQuery(),
null);
httpRequest = new HttpGet(uri);
buildRequestHeader();
}
}
public String getResponseString(HttpRequestBase httpRequest) throws IOException {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
CloseableHttpResponse response = httpClient.execute(httpRequest);
HttpEntity entity = response.getEntity();
return EntityUtils.toString(entity, HttpConstants.DEFAULT_CHARSET);
}
/**
* add msg param in url
*/
private void buildMsgToUrl(Map<String, Object> templateParams) {
String line;
// check splice char is & or ?
if (!httpParams.getUrl().contains("?")) {
line = "?";
} else {
line = "&";
}
templateParams.forEach((k, v) -> {
httpParams.setUrl(String.format("%s%s%s=%s", httpParams.getUrl(), line, k, v));
});
}
private void buildRequestHeader() {
List<ConfigItem> paramsHeaders = httpParams.getHeaders();
if (CollUtil.isNotEmpty(paramsHeaders)) {
paramsHeaders.forEach(configItem -> {
httpRequest.setHeader(configItem.getKey(), configItem.getValue());
});
}
}
/**
* set body params
*/
private void buildMsgToRequestBody(Map<String, Object> templateParams) {
try {
JSONObject jsonObject = JSONUtil.createObj();
templateParams.forEach(jsonObject::set);
if (CollUtil.isNotEmpty(httpParams.getBody())) {
httpParams.getBody().forEach(configItem -> {
jsonObject.set(configItem.getKey(), configItem.getValue());
});
}
StringEntity entity = new StringEntity(JSONUtil.toJsonStr(jsonObject), HttpConstants.DEFAULT_CHARSET);
((HttpPost) httpRequest).setEntity(entity);
} catch (Exception e) {
logger.error("send http alert msg exception : {}", e.getMessage());
}
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.alert.http.params;
import org.dinky.data.ext.ConfigItem;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor(onConstructor = @__(@JsonCreator))
public class HttpParams {
private String url = "";
private String method = "";
private List<ConfigItem> headers = new ArrayList<>();
private List<ConfigItem> body = new ArrayList<>();
}
${title}
${content}
\ No newline at end of file
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
org.dinky.alert.http.HttpAlert
\ No newline at end of file
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.dinky.alert.http;
import org.dinky.alert.AlertBaseConstant;
import org.dinky.alert.AlertConfig;
import org.dinky.alert.AlertResult;
import org.dinky.alert.http.params.HttpParams;
import org.dinky.data.ext.ConfigItem;
import org.dinky.utils.JsonUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import cn.hutool.json.JSONUtil;
public class HttpSenderTest {
private static Map<String, Object> httpConfig = new HashMap<>();
@Before
public void initConfig() {
HttpParams httpParams = new HttpParams();
httpParams.setUrl("https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx");
httpParams.setMethod(HttpConstants.REQUEST_TYPE_POST);
ConfigItem configItem = new ConfigItem("Content-Type", "application/json");
httpParams.setHeaders(Arrays.asList(configItem));
ConfigItem msgType = new ConfigItem("msgtype", "markdown");
ConfigItem title = new ConfigItem("title", AlertBaseConstant.ALERT_TEMPLATE_TITLE);
ConfigItem content = new ConfigItem("content", AlertBaseConstant.ALERT_TEMPLATE_MSG);
ConfigItem markdown = new ConfigItem("markdown", JSONUtil.toJsonStr(new HashMap<String, Object>() {
{
put("title", AlertBaseConstant.ALERT_TEMPLATE_TITLE);
put("text", AlertBaseConstant.ALERT_TEMPLATE_MSG);
}
}));
Arrays.asList(msgType, content, title, markdown).forEach(item -> {
httpParams.getBody().add(item);
});
httpConfig = JsonUtils.toMap(JSONUtil.toJsonStr(httpParams), String.class, Object.class);
}
@Test
public void sendTest() {
HttpAlert httpAlert = new HttpAlert();
AlertConfig alertConfig = new AlertConfig();
alertConfig.setType(HttpConstants.TYPE);
alertConfig.setParam(httpConfig);
httpAlert.setConfig(alertConfig);
AlertResult alertResult =
httpAlert.send(AlertBaseConstant.ALERT_TEMPLATE_TITLE, AlertBaseConstant.ALERT_TEMPLATE_MSG);
Assert.assertEquals(true, alertResult.getSuccess());
}
}
......@@ -37,6 +37,7 @@
<module>dinky-alert-feishu</module>
<module>dinky-alert-email</module>
<module>dinky-alert-sms</module>
<module>dinky-alert-http</module>
</modules>
</project>
......@@ -17,7 +17,7 @@
*
*/
package org.dinky.data.model.ext;
package org.dinky.data.ext;
import java.io.Serializable;
......
......@@ -283,6 +283,36 @@ export const SmsSvg = (props: any) => {
);
};
export const HttpSvg = (props: any) => {
const size = props.size || defaultSvgSize;
return (
<>
<Icon
style={style}
component={() => (
<svg
viewBox='0 0 1490 1024'
version='1.1'
xmlns='http://www.w3.org/2000/svg'
width={size}
height={size}
>
<path
d='M1203.118794 1023.767378a286.589732 286.589732 0 1 0 0-573.179463 302.407996 302.407996 0 0 0-46.524307 3.954566 390.80418 390.80418 0 0 0 2.093594-40.708769 413.833712 413.833712 0 0 0-827.667424 0 390.80418 390.80418 0 0 0 2.093593 40.708769 302.407996 302.407996 0 0 0-46.524307-3.954566 286.589732 286.589732 0 0 0 0 573.179463z'
fill='#4674CE'
></path>
<path
d='M301.2451 610.39891v116.310767H442.911615v-116.310767h45.3612v277.28487H442.911615v-122.824171h-141.666515v122.824171H256.814387V610.39891zM747.413206 610.39891v38.847796h-90.722399v238.437074h-46.524308V649.246706h-90.722398v-38.847796zM986.315523 610.39891v38.847796h-90.955021v238.437074h-46.524307V649.246706h-89.791913v-38.847796zM1134.262819 610.39891c66.762381 0 100.492503 28.379827 100.492504 84.90686s-33.730123 85.837347-101.42299 85.837347h-69.786461v106.540663h-46.524307V610.39891z m-69.78646 131.89641h66.064516a74.438891 74.438891 0 0 0 44.198092-10.70059 43.732849 43.732849 0 0 0 13.957292-36.28896 41.639255 41.639255 0 0 0-14.422536-35.358473 71.647433 71.647433 0 0 0-43.732848-10.700591h-65.831895z'
fill='#FFFFFF'
></path>
</svg>
)}
/>
</>
);
};
/**
* random rgb color
*/
......
......@@ -656,9 +656,13 @@ export default {
'rc.ai.wechat': 'WeChat',
'rc.ai.wechatAtUsersPleaseHolder':
'Please enter the @user ID (enterprise and micro user name spelled out)',
'rc.ai.xls.file.path': 'XLS storage directory',
'rc.ai.xls.file.pathPleaseHolder':
'Please enter the XLS storage directory! The default is /tmp/xls',
'rc.ai.http': 'HTTP',
'rc.ai.http.url': 'Request address',
'rc.ai.http.urlPleaseHolder': 'Please enter the request address',
'rc.ai.http.method': 'Request method',
'rc.ai.http.methodPleaseHolder': 'Please select the request method',
'rc.ai.http.headers': 'Request headers',
'rc.ai.http.body': 'Request body',
'rc.alert.template.create': 'Create Template',
'rc.alert.template.modify': 'Modify Template',
'rc.alert.template.new': 'Create an alert template',
......
......@@ -634,7 +634,13 @@ export default {
'rc.ai.webhookPleaseHolder': '请输入 webhook 地址',
'rc.ai.wechat': '企业微信',
'rc.ai.wechatAtUsersPleaseHolder': '请输入被@用户ID(企微用户名全拼)',
'rc.ai.http': 'HTTP',
'rc.ai.http.url': '请求地址',
'rc.ai.http.urlPleaseHolder': '请输入请求地址',
'rc.ai.http.method': '请求方法',
'rc.ai.http.methodPleaseHolder': '请选择请求方法',
'rc.ai.http.headers': '请求头',
'rc.ai.http.body': '请求体',
'rc.alert.template.create': '创建模板',
'rc.alert.template.modify': '修改模板',
'rc.alert.template.new': '新建告警模板',
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import { RequestMethod } from '@/pages/RegCenter/Alert/AlertInstance/constans';
import { Alert } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl';
import {
ProForm,
ProFormGroup,
ProFormList,
ProFormSelect,
ProFormText
} from '@ant-design/pro-components';
import { Space } from 'antd';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
import React from 'react';
type HttpProps = {
values: Partial<Alert.AlertInstance>;
form: FormInstance<Values>;
};
const Http: React.FC<HttpProps> = (props) => {
const { values, form } = props;
const params = values.params as Alert.AlertInstanceParamsHttp;
return (
<>
<ProForm.Group>
<ProFormSelect
width='sm'
name={['params', 'method']}
label={l('rc.ai.http.method')}
rules={[{ required: true, message: l('rc.ai.http.methodPleaseHolder') }]}
placeholder={l('rc.ai.http.methodPleaseHolder')}
options={RequestMethod}
/>
<ProFormText
width='xl'
name={['params', 'url']}
label={l('rc.ai.http.url')}
rules={[{ required: true, message: l('rc.ai.http.urlPleaseHolder') }]}
placeholder={l('rc.ai.http.urlPleaseHolder')}
/>
</ProForm.Group>
{/*这有 bug,待解决*/}
<ProFormList
name={['params', 'headers']}
label={l('rc.ai.http.headers')}
copyIconProps={false}
required
initialValue={[{ key: '', value: '' }]}
deleteIconProps={{
tooltipText: l('rc.cc.deleteConfig')
}}
creatorButtonProps={{
style: { width: '100%' },
creatorButtonText: l('rc.cc.addConfig')
}}
>
<ProFormGroup key='headersGroup' style={{ width: '100%' }}>
<Space key={'config'} style={{ width: '100%' }} align='baseline'>
<ProFormText width={'md'} name='key' placeholder={l('rc.cc.key')} />
<ProFormText width={'lg'} name='value' placeholder={l('rc.cc.value')} />
</Space>
</ProFormGroup>
</ProFormList>
{/*这有 bug,待解决*/}
<ProFormList
name={['params', 'body']}
label={l('rc.ai.http.body')}
copyIconProps={false}
required
initialValue={[{ key: '', value: '' }]}
deleteIconProps={{
tooltipText: l('rc.cc.deleteConfig')
}}
creatorButtonProps={{
style: { width: '100%' },
creatorButtonText: l('rc.cc.addConfig')
}}
>
<ProFormGroup key='bodyGroup' style={{ width: '100%' }}>
<Space key={'config'} style={{ width: '100%' }} align='baseline'>
<ProFormText width={'md'} name='key' placeholder={l('rc.cc.key')} />
<ProFormText width={'lg'} name='value' placeholder={l('rc.cc.value')} />
</Space>
</ProFormGroup>
</ProFormList>
</>
);
};
export default Http;
......@@ -19,6 +19,7 @@
import Email from '@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm/Email';
import FeiShu from '@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm/FeiShu';
import Http from '@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm/Http';
import Sms from '@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm/Sms';
import WeChat from '@/pages/RegCenter/Alert/AlertInstance/components/AlertTypeChoose/InstanceForm/WeChat';
import { ALERT_TYPE_LIST_OPTIONS } from '@/pages/RegCenter/Alert/AlertInstance/constans';
......@@ -77,6 +78,8 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
return <Email values={value} form={form} />;
case ALERT_TYPE.SMS:
return <Sms values={value} form={form} />;
case ALERT_TYPE.HTTP:
return <Http values={value} form={form} />;
default:
return <></>;
}
......@@ -84,10 +87,12 @@ const InstanceForm: React.FC<InstanceFormProps> = (props) => {
return (
<>
<ProForm.Group>
{renderPreForm()}
{renderFormByType(values, alertType)}
</ProForm.Group>
<ProForm form={form} submitter={false}>
<ProForm.Group>
{renderPreForm()}
{renderFormByType(values, alertType)}
</ProForm.Group>
</ProForm>
</>
);
};
......
......@@ -22,6 +22,7 @@ import {
DingTalkSvg,
EmailSvg,
FeiShuSvg,
HttpSvg,
SmsSvg,
TencentSmsSvg,
WeChatSvg
......@@ -71,9 +72,21 @@ export const ALERT_TYPE_LIST_OPTIONS: DefaultOptionType[] = [
</Space>
),
value: ALERT_TYPE.SMS
},
{
label: (
<Space align={'baseline'} size={5}>
<HttpSvg size={16} /> {l('rc.ai.http')}
</Space>
),
value: ALERT_TYPE.HTTP
}
];
export const RequestMethod = [
{ label: 'POST', value: 'POST', key: 'POST', disabled: false },
{ label: 'GET', value: 'GET', key: 'GET', disabled: true }
];
export enum SMS_TYPE {
ALIBABA = 'alibaba',
CLOOPEN = 'cloopen',
......
......@@ -23,6 +23,7 @@ import {
DingTalkSvg,
EmailSvg,
FeiShuSvg,
HttpSvg,
SmsSvg,
WeChatSvg
} from '@/components/Icons/AlertIcon';
......@@ -46,6 +47,8 @@ export const getAlertIcon = (type: string, size?: number) => {
return <SmsSvg size={size} />;
case ALERT_TYPE.EMAIL:
return <EmailSvg size={size} />;
case ALERT_TYPE.HTTP:
return <HttpSvg size={size} />;
case ALERT_TYPE.GROUP:
return <AlertGroupSvg size={size} />;
default:
......
......@@ -18,6 +18,7 @@
*/
import { BaseBeanColumns } from '@/types/Public/data';
import { ConfigItem } from '@/types/Studio/data.d';
/**
* about alert
......@@ -60,6 +61,12 @@ declare namespace Alert {
password: string;
};
export type AlertInstanceParamsHttp = {
url: string;
method: string;
headers: ConfigItem[];
};
export type AlertInstanceParamsEmail = {
serverHost: string;
serverPort: string;
......@@ -138,7 +145,8 @@ declare namespace Alert {
| AlertInstanceParamsFeiShu
| AlertInstanceParamsEmail
| AlertInstanceParamsWeChat
| AlertInstanceParamsSms;
| AlertInstanceParamsSms
| AlertInstanceParamsHttp;
};
/**
......@@ -160,6 +168,7 @@ export const ALERT_TYPE = {
FEISHU: 'FeiShu',
EMAIL: 'Email',
SMS: 'Sms',
HTTP: 'Http',
GROUP: 'Group'
};
......
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