mirror of
https://gitee.com/dolphinscheduler/DolphinScheduler.git
synced 2024-11-29 18:58:05 +08:00
[Fix-16517][Alert Instance] Alert plugin instance i18n wrong result in rendering frontend ui (#16751)
This commit is contained in:
parent
071994933b
commit
7876d455ab
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.plugin.alert.voice;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||
import org.apache.dolphinscheduler.spi.params.input.InputParam;
|
||||
@ -42,7 +43,7 @@ public final class VoiceAlertChannelFactory implements AlertChannelFactory {
|
||||
|
||||
InputParam calledNumber =
|
||||
InputParam.newBuilder(VoiceAlertConstants.NAME_CALLED_NUMBER, VoiceAlertConstants.CALLED_NUMBER)
|
||||
.setPlaceholder(AlertInputTips.CALLED_NUMBER.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.CALLED_NUMBER)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -50,21 +51,21 @@ public final class VoiceAlertChannelFactory implements AlertChannelFactory {
|
||||
|
||||
InputParam calledShowNumber = InputParam
|
||||
.newBuilder(VoiceAlertConstants.NAME_CALLED_SHOW_NUMBER, VoiceAlertConstants.CALLED_SHOW_NUMBER)
|
||||
.setPlaceholder(AlertInputTips.CALLED_SHOW_NUMBER.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.CALLED_SHOW_NUMBER)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
InputParam ttsCode = InputParam.newBuilder(VoiceAlertConstants.NAME_TTS_CODE, VoiceAlertConstants.TTS_CODE)
|
||||
.setPlaceholder(AlertInputTips.TTS_CODE.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.TTS_CODE)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
InputParam address = InputParam.newBuilder(VoiceAlertConstants.NAME_ADDRESS, VoiceAlertConstants.ADDRESS)
|
||||
.setPlaceholder(AlertInputTips.ALIYUN_VIICE_ADDRESS.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.ALIYUN_VIICE_ADDRESS)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
@ -72,14 +73,16 @@ public final class VoiceAlertChannelFactory implements AlertChannelFactory {
|
||||
|
||||
InputParam accessKeyId =
|
||||
InputParam.newBuilder(VoiceAlertConstants.NAME_ACCESS_KEY_ID, VoiceAlertConstants.ACCESS_KEY_ID)
|
||||
.setPlaceholder(AlertInputTips.ALIYUN_VIICE_ACCESSKEYID.getMsg())
|
||||
.setPlaceholder(JSONUtils
|
||||
.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.ALIYUN_VIICE_ACCESSKEYID)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.build();
|
||||
InputParam accessKeySecret =
|
||||
InputParam.newBuilder(VoiceAlertConstants.NAME_ACCESS_KEY_SECRET, VoiceAlertConstants.ACCESS_KEY_SECRET)
|
||||
.setPlaceholder(AlertInputTips.ALIYUN_VIICE_ACCESSKEY_SECRET.getMsg())
|
||||
.setPlaceholder(JSONUtils
|
||||
.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.ALIYUN_VIICE_ACCESSKEY_SECRET)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
|
@ -17,7 +17,9 @@
|
||||
|
||||
package org.apache.dolphinscheduler.alert.api;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
|
||||
@ -73,4 +75,11 @@ public enum AlertInputTips {
|
||||
return this.enMsg;
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, String> getAllMsg(AlertInputTips alertInputTips) {
|
||||
Map<String, String> allMsgMap = new HashMap<>();
|
||||
allMsgMap.put("zhMsg", alertInputTips.zhMsg);
|
||||
allMsgMap.put("enMsg", alertInputTips.enMsg);
|
||||
return allMsgMap;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import static org.apache.dolphinscheduler.common.constants.Constants.STRING_YES;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.DataType;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
@ -137,7 +138,7 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
||||
.build();
|
||||
InputParam passwordParam = InputParam
|
||||
.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD)
|
||||
.setPlaceholder(AlertInputTips.PASSWORD.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.PASSWORD)))
|
||||
.setType("password")
|
||||
.build();
|
||||
|
||||
|
@ -27,6 +27,7 @@ import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertConstants;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.alert.api.ShowType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.DataType;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
@ -54,7 +55,7 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
|
||||
InputParam receivesParam = InputParam
|
||||
.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS,
|
||||
MailParamsConstants.PLUGIN_DEFAULT_EMAIL_RECEIVERS)
|
||||
.setPlaceholder(AlertInputTips.RECEIVERS.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.RECEIVERS)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -93,12 +94,12 @@ public final class EmailAlertChannelFactory implements AlertChannelFactory {
|
||||
.build();
|
||||
|
||||
InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, MailParamsConstants.MAIL_USER)
|
||||
.setPlaceholder(AlertInputTips.USERNAME.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.USERNAME)))
|
||||
.build();
|
||||
|
||||
InputParam mailPassword =
|
||||
InputParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, MailParamsConstants.MAIL_PASSWD)
|
||||
.setPlaceholder(AlertInputTips.PASSWORD.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.PASSWORD)))
|
||||
.setType("password")
|
||||
.build();
|
||||
|
||||
|
@ -25,6 +25,7 @@ import static org.apache.dolphinscheduler.common.constants.Constants.STRING_YES;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.DataType;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
@ -86,7 +87,7 @@ public final class FeiShuAlertChannelFactory implements AlertChannelFactory {
|
||||
.build();
|
||||
InputParam passwordParam = InputParam
|
||||
.newBuilder(FeiShuParamsConstants.NAME_FEI_SHU_PASSWORD, FeiShuParamsConstants.FEI_SHU_PASSWORD)
|
||||
.setPlaceholder(AlertInputTips.PASSWORD.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.PASSWORD)))
|
||||
.setType("password")
|
||||
.build();
|
||||
|
||||
|
@ -21,6 +21,7 @@ import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.model.OkHttpRequestHeaderContentType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.DataType;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
@ -46,7 +47,7 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
||||
public List<PluginParams> params() {
|
||||
|
||||
InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL)
|
||||
.setPlaceholder(AlertInputTips.URL.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.URL)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -54,7 +55,7 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
||||
|
||||
InputParam headerParams =
|
||||
InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
|
||||
.setPlaceholder(AlertInputTips.HEADER.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.HEADER)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
@ -75,7 +76,7 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
||||
|
||||
InputParam bodyParams =
|
||||
InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
|
||||
.setPlaceholder(AlertInputTips.JSON_BODY.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.JSON_BODY)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.plugin.alert.prometheus;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||
import org.apache.dolphinscheduler.spi.params.input.InputParam;
|
||||
@ -43,7 +44,7 @@ public final class PrometheusAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam
|
||||
.newBuilder(PrometheusAlertConstants.NAME_ALERT_MANAGER_URL,
|
||||
PrometheusAlertConstants.ALERT_MANAGER_URL)
|
||||
.setPlaceholder(AlertInputTips.URL.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.URL)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -52,14 +53,14 @@ public final class PrometheusAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam
|
||||
.newBuilder(PrometheusAlertConstants.NAME_ALERT_MANAGER_ANNOTATIONS,
|
||||
PrometheusAlertConstants.ALERT_MANAGER_ANNOTATIONS)
|
||||
.setPlaceholder(AlertInputTips.ANNOTATION.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.ANNOTATION)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
InputParam generatorUrlParam =
|
||||
InputParam
|
||||
.newBuilder(PrometheusAlertConstants.NAME_GENERATOR_URL, PrometheusAlertConstants.GENERATOR_URL)
|
||||
.setPlaceholder(AlertInputTips.GENERATOR_URL.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.GENERATOR_URL)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.plugin.alert.script;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||
@ -47,7 +48,7 @@ public final class ScriptAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.CUSTOMIZED_PARAMS.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.CUSTOMIZED_PARAMS)))
|
||||
.build();
|
||||
// need check file type and file exist
|
||||
InputParam scriptPathParam =
|
||||
@ -55,7 +56,7 @@ public final class ScriptAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.SCRIPT_PATH.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.SCRIPT_PATH)))
|
||||
.build();
|
||||
|
||||
RadioParam scriptTypeParams = RadioParam
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.plugin.alert.slack;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||
import org.apache.dolphinscheduler.spi.params.input.InputParam;
|
||||
@ -46,14 +47,14 @@ public final class SlackAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.WEBHOOK.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.WEBHOOK)))
|
||||
.build();
|
||||
|
||||
InputParam botName = InputParam.newBuilder(SlackParamsConstants.SLACK_BOT_NAME, SlackParamsConstants.SLACK_BOT)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.BOT_NAME.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.BOT_NAME)))
|
||||
.build();
|
||||
|
||||
paramsList.add(webHookParam);
|
||||
|
@ -25,6 +25,7 @@ import static org.apache.dolphinscheduler.common.constants.Constants.STRING_YES;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.DataType;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
@ -60,7 +61,7 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.WEBHOOK.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.WEBHOOK)))
|
||||
.build();
|
||||
|
||||
InputParam botTokenParam = InputParam
|
||||
@ -68,7 +69,7 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.BOT_TOKEN.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.BOT_TOKEN)))
|
||||
.build();
|
||||
|
||||
InputParam chatIdParam = InputParam
|
||||
@ -76,7 +77,7 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setPlaceholder(AlertInputTips.CHANNEL_ID.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.CHANNEL_ID)))
|
||||
.build();
|
||||
|
||||
SelectParam parseMode = SelectParam
|
||||
@ -135,7 +136,7 @@ public final class TelegramAlertChannelFactory implements AlertChannelFactory {
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.setPlaceholder("if enable use authentication, you need input password")
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.PASSWORD)))
|
||||
.setType("password")
|
||||
.build();
|
||||
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.plugin.alert.webexteams;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannel;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||
@ -45,7 +46,7 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam botAccessToken = InputParam
|
||||
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_BOT_ACCESS_TOKEN,
|
||||
WebexTeamsParamsConstants.WEBEX_TEAMS_BOT_ACCESS_TOKEN)
|
||||
.setPlaceholder(AlertInputTips.BOT_TOKEN.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.BOT_TOKEN)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -54,7 +55,7 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam roomId = InputParam
|
||||
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_ROOM_ID,
|
||||
WebexTeamsParamsConstants.WEBEX_TEAMS_ROOM_ID)
|
||||
.setPlaceholder(AlertInputTips.ROOM_ID.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.ROOM_ID)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
@ -63,7 +64,7 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam toPersonId = InputParam
|
||||
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_ID,
|
||||
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_ID)
|
||||
.setPlaceholder(AlertInputTips.RECIPIENT_USER_ID.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.RECIPIENT_USER_ID)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
@ -72,7 +73,7 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam toPersonEmail = InputParam
|
||||
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_TO_PERSON_EMAIL,
|
||||
WebexTeamsParamsConstants.WEBEX_TEAMS_TO_PERSON_EMAIL)
|
||||
.setPlaceholder(AlertInputTips.RECIPIENT_EMAIL.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.RECIPIENT_EMAIL)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
@ -81,7 +82,7 @@ public final class WebexTeamsAlertChannelFactory implements AlertChannelFactory
|
||||
InputParam atSomeoneInRoom = InputParam
|
||||
.newBuilder(WebexTeamsParamsConstants.NAME_WEBEX_TEAMS_AT_SOMEONE_IN_ROOM,
|
||||
WebexTeamsParamsConstants.WEBEX_TEAMS_AT_SOMEONE_IN_ROOM)
|
||||
.setPlaceholder(AlertInputTips.WEBEX_MENTION_USERS.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.WEBEX_MENTION_USERS)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
|
@ -22,6 +22,7 @@ import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertConstants;
|
||||
import org.apache.dolphinscheduler.alert.api.AlertInputTips;
|
||||
import org.apache.dolphinscheduler.alert.api.ShowType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
|
||||
import org.apache.dolphinscheduler.spi.params.base.Validate;
|
||||
@ -46,7 +47,7 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
||||
InputParam corpIdParam = InputParam
|
||||
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID,
|
||||
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
|
||||
.setPlaceholder(AlertInputTips.CORP_ID.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.CORP_ID)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -55,7 +56,7 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
||||
InputParam secretParam = InputParam
|
||||
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET,
|
||||
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
|
||||
.setPlaceholder(AlertInputTips.SECRET.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.SECRET)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
@ -64,7 +65,7 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
||||
InputParam usersParam = InputParam
|
||||
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS,
|
||||
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
|
||||
.setPlaceholder(AlertInputTips.WECHAT_MENTION_USERS.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.WECHAT_MENTION_USERS)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
@ -73,7 +74,7 @@ public final class WeChatAlertChannelFactory implements AlertChannelFactory {
|
||||
InputParam agentIdParam = InputParam
|
||||
.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID,
|
||||
WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
|
||||
.setPlaceholder(AlertInputTips.WECHAT_AGENT_ID.getMsg())
|
||||
.setPlaceholder(JSONUtils.toJsonString(AlertInputTips.getAllMsg(AlertInputTips.WECHAT_AGENT_ID)))
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
|
@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.api.service;
|
||||
import org.apache.dolphinscheduler.api.enums.Status;
|
||||
import org.apache.dolphinscheduler.api.service.impl.UiPluginServiceImpl;
|
||||
import org.apache.dolphinscheduler.common.enums.PluginType;
|
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils;
|
||||
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
|
||||
import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper;
|
||||
|
||||
@ -35,6 +36,8 @@ import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
|
||||
/**
|
||||
* ui plugin service test
|
||||
*/
|
||||
@ -51,7 +54,8 @@ public class UiPluginServiceTest {
|
||||
|
||||
@BeforeEach
|
||||
public void before() {
|
||||
String pluginParams = "[{\"field\":\"receivers\",\"props\":null,\"type\"}]";
|
||||
String pluginParams =
|
||||
"[{\"field\":\"receivers\",\"props\":{\"placeholder\":\"{\\\"zhMsg\\\": \\\"请输入收件人\\\",\\\"enMsg\\\": \\\"pleaseinputreceivers\\\"}\"},\"type\":\"input\"}]";
|
||||
pluginDefine = new PluginDefine("email-alert", "alert", pluginParams);
|
||||
}
|
||||
|
||||
@ -82,6 +86,14 @@ public class UiPluginServiceTest {
|
||||
Mockito.when(pluginDefineMapper.queryDetailById(1)).thenReturn(pluginDefine);
|
||||
result = uiPluginService.queryUiPluginDetailById(1);
|
||||
Assertions.assertEquals(Status.SUCCESS, result.get("status"));
|
||||
|
||||
PluginDefine data = (PluginDefine) result.get("data");
|
||||
String pluginParams = data.getPluginParams();
|
||||
ArrayNode arrayNode = JSONUtils.parseArray(pluginParams);
|
||||
String placeholder = arrayNode.path(0).path("props").path("placeholder").asText();
|
||||
Map<String, String> placeholderMap = JSONUtils.toMap(placeholder);
|
||||
Assertions.assertEquals("请输入收件人", placeholderMap.get("zhMsg"));
|
||||
Assertions.assertEquals("pleaseinputreceivers", placeholderMap.get("enMsg"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ const DetailModal = defineComponent({
|
||||
props,
|
||||
emits: ['cancel', 'update'],
|
||||
setup(props, ctx) {
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
|
||||
const rules = ref<IFormRules>({})
|
||||
const elements = ref<IFormItem[]>([]) as IElements
|
||||
@ -94,6 +94,30 @@ const DetailModal = defineComponent({
|
||||
|
||||
const trim = getCurrentInstance()?.appContext.config.globalProperties.trim
|
||||
|
||||
function isJSON(str: string): boolean {
|
||||
try {
|
||||
const parsed = JSON.parse(str)
|
||||
return typeof parsed === 'object' && parsed !== null
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function updatePlaceholder(mergedItem: any) {
|
||||
const { props } = mergedItem
|
||||
if (!props || !props.placeholder) return
|
||||
|
||||
const placeholder = props.placeholder
|
||||
if (!isJSON(placeholder)) return
|
||||
|
||||
const msgMap = JSON.parse(placeholder)
|
||||
if (locale.value === 'zh_CN') {
|
||||
props.placeholder = msgMap.zhMsg
|
||||
} else if (locale.value === 'en_US') {
|
||||
props.placeholder = msgMap.enMsg
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => props.show,
|
||||
async () => {
|
||||
@ -109,6 +133,7 @@ const DetailModal = defineComponent({
|
||||
mergedItem.name = t(
|
||||
'security.alarm_instance' + '.' + mergedItem.field
|
||||
)
|
||||
updatePlaceholder(mergedItem)
|
||||
})
|
||||
const { rules: fieldsRules, elements: fieldsElements } =
|
||||
getElementByJson(state.json, state.detailForm)
|
||||
|
Loading…
Reference in New Issue
Block a user