diff --git a/web-app/src/app/routes/setting/plugins/plugin.component.html b/web-app/src/app/routes/setting/plugins/plugin.component.html index fd749ed975a..4bf3bffd295 100644 --- a/web-app/src/app/routes/setting/plugins/plugin.component.html +++ b/web-app/src/app/routes/setting/plugins/plugin.component.html @@ -92,6 +92,9 @@
+
+ + +
+
+ + + {{ paramDefine.name }} + + + + + +
+
+
diff --git a/web-app/src/app/routes/setting/plugins/plugin.component.ts b/web-app/src/app/routes/setting/plugins/plugin.component.ts index 0ac42a2ed80..b1f9fef5718 100644 --- a/web-app/src/app/routes/setting/plugins/plugin.component.ts +++ b/web-app/src/app/routes/setting/plugins/plugin.component.ts @@ -27,6 +27,7 @@ import { NzTableQueryParams } from 'ng-zorro-antd/table'; import { NzUploadFile } from 'ng-zorro-antd/upload'; import { finalize } from 'rxjs/operators'; +import { ParamDefine } from '../../../pojo/ParamDefine'; import { Plugin } from '../../../pojo/Plugin'; import { PluginService } from '../../../service/plugin.service'; @@ -47,8 +48,10 @@ export class SettingPluginsComponent implements OnInit { jarFile: [null, [Validators.required]], enableStatus: [true, [Validators.required]] }); + this.lang = this.i18nSvc.defaultLang; } + lang: string; pageIndex: number = 1; pageSize: number = 8; total: number = 0; @@ -275,4 +278,58 @@ export class SettingPluginsComponent implements OnInit { }); this.fileList = []; } + + params: any = {}; + paramDefines!: ParamDefine[]; + isEditPluginParamDefineModalVisible = false; + + onEditPluginParamDefine(pluginId: number) { + const getPluginParamDefine$ = this.pluginService + .getPluginParamDefine(pluginId) + .pipe( + finalize(() => { + getPluginParamDefine$.unsubscribe(); + }) + ) + .subscribe((message: any) => { + if (message.code === 0) { + this.paramDefines = message.data.map((i: any) => { + this.params[i.field] = { + pluginMetadataId: pluginId, + // Parameter type 0: number 1: string 2: encrypted string 3: json string mapped by map + type: i.type === 'number' ? 0 : i.type === 'text' ? 1 : i.type === 'json' ? 3 : 2, + field: i.field, + paramValue: null + }; + i.name = i.name[this.lang]; + return i; + }); + this.isEditPluginParamDefineModalVisible = true; + } else { + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg); + } + }); + } + + onEditPluginParamDefineModalCancel() { + this.isEditPluginParamDefineModalVisible = false; + } + + onEditPluginParamDefineModalOk() { + const savePluginParamDefine$ = this.pluginService + .savePluginParamDefine(Object.values(this.params)) + .pipe( + finalize(() => { + savePluginParamDefine$.unsubscribe(); + }) + ) + .subscribe((message: any) => { + if (message.code === 0) { + this.isEditPluginParamDefineModalVisible = false; + this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), ''); + } else { + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg); + } + }); + } } diff --git a/web-app/src/app/service/plugin.service.ts b/web-app/src/app/service/plugin.service.ts index 90278805dbc..1a2bdae5114 100644 --- a/web-app/src/app/service/plugin.service.ts +++ b/web-app/src/app/service/plugin.service.ts @@ -64,20 +64,6 @@ export class PluginService { return this.http.put>(plugin_uri, body); } - public newTags(body: Tag[]): Observable> { - return this.http.post>(plugin_uri, body); - } - - public newTag(body: Tag): Observable> { - const tags = []; - tags.push(body); - return this.http.post>(plugin_uri, tags); - } - - public editTag(body: Tag): Observable> { - return this.http.put>(plugin_uri, body); - } - public deletePlugins(pluginIds: Set): Observable> { let httpParams = new HttpParams(); pluginIds.forEach(pluginId => { @@ -86,4 +72,17 @@ export class PluginService { const options = { params: httpParams }; return this.http.delete>(plugin_uri, options); } + + public getPluginParamDefine(pluginId: number): Observable> { + let httpParams = new HttpParams(); + httpParams = httpParams.appendAll({ + pluginMetadataId: pluginId + }); + const options = { params: httpParams }; + return this.http.get>(`${plugin_uri}/getParamDefine`, options); + } + + public savePluginParamDefine(body: any): Observable> { + return this.http.post>(`${plugin_uri}/saveParams`, body); + } } diff --git a/web-app/src/assets/i18n/en-US.json b/web-app/src/assets/i18n/en-US.json index 4a9cf506e35..c6edf7509a8 100644 --- a/web-app/src/assets/i18n/en-US.json +++ b/web-app/src/assets/i18n/en-US.json @@ -551,6 +551,7 @@ "plugin.delete": "Delete Plugin", "plugin.type.POST_ALERT": "POST ALERT", "plugin.search": "Search plugins", + "plugin.edit": "Edit plugin", "define.help": "The monitor templates define each monitoring type, parameter variable, metrics info, collection protocol, etc. You can select an existing monitoring template from the drop-down menu then make modifications according to your own needs. The bottom-left area is the compare area and the bottom-right area is the editing place.
You can also click \"New Monitor Type\" to custom define an new type. Currently supported protocols include HTTP, JDBC, SSH, JMX, SNMP. Monitor Templates.", "define.help.link": "https://hertzbeat.apache.org/zh-cn/docs/advanced/extend-point/", "define.save-apply": "Save And Apply", diff --git a/web-app/src/assets/i18n/zh-CN.json b/web-app/src/assets/i18n/zh-CN.json index 8218fe13370..1cc90231571 100644 --- a/web-app/src/assets/i18n/zh-CN.json +++ b/web-app/src/assets/i18n/zh-CN.json @@ -549,6 +549,7 @@ "plugin.type": "插件类型", "plugin.type.POST_ALERT": "告警后", "plugin.search": "搜索插件", + "plugin.edit": "编辑插件", "define.help": "监控模版定义每一个监控类型,类型的参数变量,指标信息,采集协议等。您可根据需求在下拉菜单中选择已有监控模板修改。左下区域为对照区,右下区域为编辑区。
您也可以点击“新增监控类型”来自定义新的的监控类型,目前支持 HTTP 协议JDBC协议SSH协议 JMX 协议 SNMP 协议点击查看监控模板。\n", "define.help.link": "https://hertzbeat.apache.org/zh-cn/docs/advanced/extend-point/", "define.save-apply": "保存并应用", diff --git a/web-app/src/assets/i18n/zh-TW.json b/web-app/src/assets/i18n/zh-TW.json index 671de56b5fb..d3c694b2f39 100644 --- a/web-app/src/assets/i18n/zh-TW.json +++ b/web-app/src/assets/i18n/zh-TW.json @@ -548,6 +548,7 @@ "plugin.delete": "刪除插件", "plugin.type.POST_ALERT": "告警後", "plugin.search": "搜尋插件", + "plugin.edit": "編輯插件", "define.help": "監控模版定義每一個監控類型,類型的參數變量,指標信息,採集協議等。您可根據需求在下拉功能表中選擇已有監控模版進行修改。右下區域為編輯區,左下區域為對照區。
您也可以點擊“新增監控類型”來自定義新的的監控類型,現支持 HTTP協議JDBC協定SSH協定 JMX協定 SNMP協定點擊查看監控範本。", "define.help.link": "https://hertzbeat.apache.org/zh-cn/docs/advanced/extend-point/", "define.save-apply": "保存並應用",