File tree Expand file tree Collapse file tree
app/frontend/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7373 <n-form-item :label =" t('inspection.messageTemplate')" >
7474 <n-flex vertical >
7575 {{ t('inspection.messageTemplatePlaceholder') }}
76- <n-input v-model:value =" alertConfig.message_template" type =" textarea" rows =" 8" style =" text-align : left ;" />
76+ <n-input v-model:value =" alertConfig.message_template" type =" textarea" rows =" 8" placeholder =' {
77+ "msgtype": "text",
78+ "text": {
79+ "content": "kafka积压告警\ntopics: [topics]\ngroup:[group]\nlag:[total_lag]\ntimestamp:[timestamp]"
80+ }
81+ }' style =" text-align : left ;" />
7782 </n-flex >
7883 </n-form-item >
7984 <n-form-item >
@@ -502,13 +507,24 @@ const addOffsets = (item) => {
502507
503508// 保存告警配置
504509const saveAlertConfig = () => {
505- // 保存告警配置到localStorage
506- // alertConfig.message_template 必须为json
507- try {
508- JSON .parse (alertConfig .value .message_template );
509- } catch (e) {
510- message .error (' 告警消息模板必须为json格式' , { duration: 5000 });
511- return ;
510+
511+ if (alertConfig .value .enabled ) {
512+ if (! alertConfig .value .webhook_url ) {
513+ message .error (' 告警Webhook URL不能为空' , { duration: 5000 });
514+ return ;
515+ }
516+ if (! alertConfig .value .message_template ) {
517+ message .error (' 告警消息模板不能为空' , { duration: 5000 });
518+ return ;
519+ }
520+ // 保存告警配置到localStorage
521+ // alertConfig.message_template 必须为json
522+ try {
523+ JSON .parse (alertConfig .value .message_template );
524+ } catch (e) {
525+ message .error (' 告警消息模板必须为json格式' , { duration: 5000 });
526+ return ;
527+ }
512528 }
513529
514530 localStorage .setItem (' kafkaKingAlertConfig' , JSON .stringify (alertConfig .value ));
You can’t perform that action at this time.
0 commit comments