From 89efd96448b327db6a255b0e5defa0d0b2bd5515 Mon Sep 17 00:00:00 2001 From: tomsun28 Date: Mon, 11 Apr 2022 22:35:36 +0800 Subject: [PATCH] [web-app]i18n for alert setting --- .../alert-setting.component.html | 144 ++++++++++-------- .../alert-setting/alert-setting.component.ts | 59 +++---- .../src/app/routes/monitor/monitor.module.ts | 2 +- web-app/src/assets/i18n/en-US.json | 37 +++++ web-app/src/assets/i18n/zh-CN.json | 37 +++++ 5 files changed, 184 insertions(+), 95 deletions(-) diff --git a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html index f14f01a..738bbd2 100644 --- a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html +++ b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.html @@ -3,14 +3,14 @@ - 仪表盘 + {{ 'menu.dashboard' | i18n }} - 告警阈值配置 + {{ 'menu.alert.setting' | i18n }} - 帮助  + {{ 'common.button.help' | i18n }}  @@ -19,17 +19,17 @@ - @@ -51,14 +51,14 @@ - 指标对象 - 阈值触发表达式 - 告警级别 - 触发次数 - 通知模版 - 全局默认 - 最新修改时间 - 操作 + {{ 'alert.setting.target' | i18n }} + {{ 'alert.setting.expr' | i18n }} + {{ 'alert.priority' | i18n }} + {{ 'alert.setting.times' | i18n }} + {{ 'alert.setting.template' | i18n }} + {{ 'alert.setting.default' | i18n }} + {{ 'common.edit-time' | i18n }} + {{ 'common.edit' | i18n }} @@ -73,36 +73,54 @@ - 紧急告警 + {{ 'alert.priority.0' | i18n }} - 严重告警 + {{ 'alert.priority.1' | i18n }} - 警告告警 + {{ 'alert.priority.2' | i18n }} {{ data.times }} {{ data.template }} - + {{ 'common.yes' | i18n }} - + {{ 'common.no' | i18n }} {{ (data.gmtUpdate ? data.gmtUpdate : data.gmtCreate) | date: 'YYYY-MM-dd HH:mm:ss' }} - - - @@ -110,12 +128,12 @@ - 总量 {{ total }} + {{ 'common.total' | i18n }} {{ total }}
- 指标对象 + {{ 'alert.setting.target' | i18n }} - + - {{ cascadeValues[2] }} : 选中的指标对象 + {{ cascadeValues[2] }} : {{ 'alert.setting.target.tip' | i18n }} - {{ item }} : 所属行其它指标对象 + {{ item }} : {{ 'alert.setting.target.other' | i18n }} - instance : 所属行实例 + instance : {{ 'alert.setting.target.instance' | i18n }} - 支持操作符函数 : equals(str1,str2), ==, <, <=, >, >=, !=, ( ), +, -, &&, || + {{ 'alert.setting.operator' | i18n }} : equals(str1,str2), ==, <, <=, >, >=, !=, ( ), +, -, &&, || @@ -160,13 +178,8 @@ - - 阈值触发表达式 + + {{ 'alert.setting.expr' | i18n }} @@ -177,32 +190,27 @@ nz-input name="expr" id="expr" - placeholder="根据此表达式计算判断是否触发阈值. 示例: responseTime>40" + [placeholder]="('alert.setting.expr.example' | i18n) + ': responseTime>40'" > - - 告警级别 + + {{ 'alert.priority' | i18n }} - - - + + + - - 触发次数 + + {{ 'alert.setting.times' | i18n }} @@ -212,25 +220,25 @@ - + - ${app} : 监控类型名称 + ${app} : {{ 'alert.setting.template.monitor-type' | i18n }} - ${metrics} : 监控指标集合名称 + ${metrics} : {{ 'alert.setting.template.metrics-name' | i18n }} - ${metric} : 监控指标名称 + ${metric} : {{ 'alert.setting.template.metric-name' | i18n }} - ${{ '{' + cascadeValues[2] + '}' }} : 监控指标对象值 + ${{ '{' + cascadeValues[2] + '}' }} : {{ 'alert.setting.template.metric-value' | i18n }} - ${{ '{' + item + '}' }} : 所属行其它指标值 + ${{ '{' + item + '}' }} : {{ 'alert.setting.template.other-value' | i18n }} - ${instance} : 所属行实例值 + ${instance} : {{ 'alert.setting.template.instance-value' | i18n }} @@ -238,8 +246,8 @@ - - 通知模版 + + {{ 'alert.setting.template' | i18n }} @@ -250,20 +258,24 @@ required name="template" id="template" - placeholder="请输入告警的通知模版. 示例: ${app}.${metrics}.${metric}'s value is too high" + [placeholder]="'alert.setting.template.example' | i18n" > - 全局默认 + + {{ 'alert.setting.default' | i18n }} + - 启用告警 + + {{ 'alert.setting.enable' | i18n }} + @@ -276,7 +288,7 @@ - 未关联监控 - 已关联监控 + {{ 'alert.setting.connect.left' | i18n }} + {{ 'alert.setting.connect.right' | i18n }} diff --git a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts index 705a7f3..5f08f83 100644 --- a/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts +++ b/web-app/src/app/routes/alert/alert-setting/alert-setting.component.ts @@ -1,4 +1,6 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, Inject, OnInit } from '@angular/core'; +import { I18NService } from '@core'; +import { ALAIN_I18N_TOKEN } from '@delon/theme'; import { NzModalService } from 'ng-zorro-antd/modal'; import { NzNotificationService } from 'ng-zorro-antd/notification'; import { NzTableQueryParams } from 'ng-zorro-antd/table'; @@ -25,7 +27,8 @@ export class AlertSettingComponent implements OnInit { private notifySvc: NzNotificationService, private appDefineSvc: AppDefineService, private monitorSvc: MonitorService, - private alertDefineSvc: AlertDefineService + private alertDefineSvc: AlertDefineService, + @Inject(ALAIN_I18N_TOKEN) private i18nSvc: I18NService ) {} pageIndex: number = 1; @@ -98,7 +101,7 @@ export class AlertSettingComponent implements OnInit { onEditOneAlertDefine(alertDefineId: number) { if (alertDefineId == null) { - this.notifySvc.warning('未选中任何待编辑项!', ''); + this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-edit'), ''); return; } this.editAlertDefine(alertDefineId); @@ -107,11 +110,11 @@ export class AlertSettingComponent implements OnInit { onEditAlertDefine() { // 编辑时只能选中一个 if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) { - this.notifySvc.warning('未选中任何待编辑项!', ''); + this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-edit'), ''); return; } if (this.checkedDefineIds.size > 1) { - this.notifySvc.warning('只能对一个选中项进行编辑!', ''); + this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.one-select-edit'), ''); return; } let alertDefineId = 0; @@ -138,24 +141,24 @@ export class AlertSettingComponent implements OnInit { this.cascadeValues = [this.define.app, this.define.metric, this.define.field]; this.cascadeOnChange(this.cascadeValues); } else { - this.notifySvc.error('查询此监控定义详情失败!', message.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.monitor-fail'), message.msg); } }, error => { - this.notifySvc.error('查询此监控定义详情失败!', error.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.monitor-fail'), error.msg); } ); } onDeleteAlertDefines() { if (this.checkedDefineIds == null || this.checkedDefineIds.size === 0) { - this.notifySvc.warning('未选中任何待删除项!', ''); + this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-delete'), ''); return; } this.modal.confirm({ - nzTitle: '请确认是否批量删除!', - nzOkText: '确定', - nzCancelText: '取消', + nzTitle: this.i18nSvc.fanyi('common.confirm.delete-batch'), + nzOkText: this.i18nSvc.fanyi('common.button.ok'), + nzCancelText: this.i18nSvc.fanyi('common.button.cancel'), nzOkDanger: true, nzOkType: 'primary', nzOnOk: () => this.deleteAlertDefines(this.checkedDefineIds) @@ -166,9 +169,9 @@ export class AlertSettingComponent implements OnInit { let defineIds = new Set(); defineIds.add(alertDefineId); this.modal.confirm({ - nzTitle: '请确认是否删除!', - nzOkText: '确定', - nzCancelText: '取消', + nzTitle: this.i18nSvc.fanyi('common.confirm.delete'), + nzOkText: this.i18nSvc.fanyi('common.button.ok'), + nzCancelText: this.i18nSvc.fanyi('common.button.cancel'), nzOkDanger: true, nzOkType: 'primary', nzOnOk: () => this.deleteAlertDefines(defineIds) @@ -177,7 +180,7 @@ export class AlertSettingComponent implements OnInit { deleteAlertDefines(defineIds: Set) { if (defineIds == null || defineIds.size == 0) { - this.notifySvc.warning('未选中任何待删除项!', ''); + this.notifySvc.warning(this.i18nSvc.fanyi('common.notify.no-select-delete'), ''); return; } this.tableLoading = true; @@ -185,17 +188,17 @@ export class AlertSettingComponent implements OnInit { message => { deleteDefines$.unsubscribe(); if (message.code === 0) { - this.notifySvc.success('删除成功!', ''); + this.notifySvc.success(this.i18nSvc.fanyi('common.notify.delete-success'), ''); this.loadAlertDefineTable(); } else { this.tableLoading = false; - this.notifySvc.error('删除失败!', message.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), message.msg); } }, error => { this.tableLoading = false; deleteDefines$.unsubscribe(); - this.notifySvc.error('删除失败!', error.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.delete-fail'), error.msg); } ); } @@ -242,7 +245,7 @@ export class AlertSettingComponent implements OnInit { } this.appHierarchies.forEach(hierarchy => { if (hierarchy.value == values[0]) { - hierarchy.children.forEach((metrics: { value: string; children: any[]}) => { + hierarchy.children.forEach((metrics: { value: string; children: any[] }) => { if (metrics.value == values[1]) { this.otherMetrics = []; metrics.children.forEach(item => { @@ -276,14 +279,14 @@ export class AlertSettingComponent implements OnInit { message => { if (message.code === 0) { this.isManageModalVisible = false; - this.notifySvc.success('新增成功!', ''); + this.notifySvc.success(this.i18nSvc.fanyi('common.notify.new-success'), ''); this.loadAlertDefineTable(); } else { - this.notifySvc.error('新增失败!', message.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), message.msg); } }, error => { - this.notifySvc.error('新增失败!', error.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.new-fail'), error.msg); } ); } else { @@ -299,14 +302,14 @@ export class AlertSettingComponent implements OnInit { message => { if (message.code === 0) { this.isManageModalVisible = false; - this.notifySvc.success('修改成功!', ''); + this.notifySvc.success(this.i18nSvc.fanyi('common.notify.edit-success'), ''); this.loadAlertDefineTable(); } else { - this.notifySvc.error('修改失败!', message.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), message.msg); } }, error => { - this.notifySvc.error('修改失败!', error.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.edit-fail'), error.msg); } ); } @@ -373,16 +376,16 @@ export class AlertSettingComponent implements OnInit { message => { this.isConnectModalOkLoading = false; if (message.code === 0) { - this.notifySvc.success('应用成功!', ''); + this.notifySvc.success(this.i18nSvc.fanyi('common.notify.apply-success'), ''); this.isConnectModalVisible = false; this.loadAlertDefineTable(); } else { - this.notifySvc.error('应用失败!', message.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.apply-fail'), message.msg); } }, error => { this.isConnectModalOkLoading = false; - this.notifySvc.error('应用失败!', error.msg); + this.notifySvc.error(this.i18nSvc.fanyi('common.notify.apply-fail'), error.msg); } ); } diff --git a/web-app/src/app/routes/monitor/monitor.module.ts b/web-app/src/app/routes/monitor/monitor.module.ts index f421e33..3ed3282 100644 --- a/web-app/src/app/routes/monitor/monitor.module.ts +++ b/web-app/src/app/routes/monitor/monitor.module.ts @@ -1,6 +1,7 @@ import { NgModule, Type } from '@angular/core'; import { SharedModule } from '@shared'; import { NzBreadCrumbModule } from 'ng-zorro-antd/breadcrumb'; +import { NzCollapseModule } from 'ng-zorro-antd/collapse'; import { NzDividerModule } from 'ng-zorro-antd/divider'; import { NzLayoutModule } from 'ng-zorro-antd/layout'; import { NzRadioModule } from 'ng-zorro-antd/radio'; @@ -16,7 +17,6 @@ import { MonitorEditComponent } from './monitor-edit/monitor-edit.component'; import { MonitorListComponent } from './monitor-list/monitor-list.component'; import { MonitorNewComponent } from './monitor-new/monitor-new.component'; import { MonitorRoutingModule } from './monitor-routing.module'; -import { NzCollapseModule } from 'ng-zorro-antd/collapse'; const COMPONENTS: Array> = [ MonitorNewComponent, diff --git a/web-app/src/assets/i18n/en-US.json b/web-app/src/assets/i18n/en-US.json index 8e811d0..773cfba 100644 --- a/web-app/src/assets/i18n/en-US.json +++ b/web-app/src/assets/i18n/en-US.json @@ -93,6 +93,38 @@ "2": "Warning" } }, + "alert.setting.new": "New Threshold", + "alert.setting.edit": "Edit Threshold", + "alert.setting.delete": "Delete Threshold", + "alert.setting.target": "Metric Target", + "alert.setting.expr": "Threshold Trigger Expr", + "alert.setting.times": "Trigger Times", + "alert.setting.times.tip": "Set how many times the threshold is triggered before sending an alert", + "alert.setting.template": "Notice Template", + "alert.setting.template.tip": "Supported notification template environment variables", + "alert.setting.template.label": "The notification information template sent after the alarm is triggered, see the template environment variable above", + "alert.setting.template.example": "Please input notice template.Eg: ${app}.${metrics}.${metric}'s value is too high", + "alert.setting.template.monitor-type": "Monitor Type Name", + "alert.setting.template.metrics-name": "Metrics Name", + "alert.setting.template.metric-name": "Metric Name", + "alert.setting.template.metric-value": "Metric Target Value", + "alert.setting.template.other-value": "Other Metric Value", + "alert.setting.template.instance-value": "Instance Value", + "alert.setting.default": "Global Default", + "alert.setting.default.tip": "Whether this alarm threshold configuration applies to all this type of monitoring globally", + "alert.setting.enable": "Enable Alert", + "alert.setting.enable.tip": "This alarm threshold configuration is enabled or disabled", + "alert.setting.connect": "Alert Associate Monitors", + "alert.setting.connect.left": "No Associate", + "alert.setting.connect.right": "Associated", + "alert.setting.expr.tip": "Supported Threshold Trigger Expression Environment Variables and Operators", + "alert.setting.expr.label": "Calculate and judge whether the threshold is triggered according to this expression. The expression environment variables and operators are shown above.", + "alert.setting.expr.example": "Calculate whether to trigger the threshold according to this expression.Eg", + "alert.setting.priority.tip": "The alarm level that triggers the threshold, from low to high:Warning,Critical,Emergency", + "alert.setting.target.tip": "The selected metric object", + "alert.setting.target.other": "Other metric objects of the row", + "alert.setting.target.instance": "Instance of the row", + "alert.setting.operator": "Supported operator functions", "alert.center.delete": "Delete Alerts", "alert.center.deal": "Mark Processed", "alert.center.no-deal": "Mark Pending", @@ -214,6 +246,9 @@ "common.notify.delete-fail": "Delete Failed!", "common.notify.new-success": "Add Success!", "common.notify.new-fail": "Add Failed!", + "common.notify.apply-success": "Apply Success!", + "common.notify.apply-fail": "Apply Failed!", + "common.notify.monitor-fail": "Query Monitor Failed!", "common.notify.edit-success": "Edit Success!", "common.notify.edit-fail": "Edit Failed!", "common.notify.no-select-cancel": "No items selected for cancel!", @@ -231,6 +266,8 @@ "common.button.ok": "OK", "common.button.cancel": "Cancel", "common.button.help": "Help", + "common.button.edit": "Edit", + "common.button.delete": "Delete", "common.button.detect": "Detect", "validation.email.invalid": "Invalid email!", "validation.phone.invalid": "Invalid phone number!", diff --git a/web-app/src/assets/i18n/zh-CN.json b/web-app/src/assets/i18n/zh-CN.json index 5da90a8..2e8240e 100644 --- a/web-app/src/assets/i18n/zh-CN.json +++ b/web-app/src/assets/i18n/zh-CN.json @@ -93,6 +93,38 @@ "2": "警告告警" } }, + "alert.setting.new": "新增阈值", + "alert.setting.edit": "编辑阈值", + "alert.setting.delete": "删除阈值", + "alert.setting.target": "指标对象", + "alert.setting.expr": "阈值触发表达式", + "alert.setting.times": "触发次数", + "alert.setting.times.tip": "设置触发阈值多少次之后才会发送告警", + "alert.setting.template": "通知模版", + "alert.setting.template.tip": "支持的通知模版环境变量", + "alert.setting.template.label": "告警触发后发送的通知信息模版,模版环境变量见上方", + "alert.setting.template.example": "请输入告警的通知模版.示例: ${app}.${metrics}.${metric}'s value is too high", + "alert.setting.template.monitor-type": "监控类型名称", + "alert.setting.template.metrics-name": "监控指标集合名称", + "alert.setting.template.metric-name": "监控指标名称", + "alert.setting.template.metric-value": "监控指标对象值", + "alert.setting.template.other-value": "所属行其它指标值", + "alert.setting.template.instance-value": "所属行实例值", + "alert.setting.default": "全局默认", + "alert.setting.default.tip": "此告警阈值配置是否应用于全局所有此类型监控", + "alert.setting.enable": "启用告警", + "alert.setting.enable.tip": "此告警阈值配置开启生效或关闭", + "alert.setting.connect": "告警定义关联监控", + "alert.setting.connect.left": "未关联监控", + "alert.setting.connect.right": "已关联监控", + "alert.setting.expr.tip": "支持的阈值触发表达式环境变量与操作符", + "alert.setting.expr.label": "根据此表达式来计算判断是否触发阈值,表达式环境变量和操作符见上方", + "alert.setting.expr.example": "根据此表达式计算判断是否触发阈值.示例", + "alert.setting.priority.tip": "触发阈值的告警级别,从低到高依次为:警告-warning,严重-critical,紧急-emergency", + "alert.setting.target.tip": "选中的指标对象", + "alert.setting.target.other": "所属行其它指标对象", + "alert.setting.target.instance": "所属行实例", + "alert.setting.operator": "支持操作符函数", "alert.center.delete": "删除告警", "alert.center.deal": "标记已处理", "alert.center.no-deal": "标记未处理", @@ -214,6 +246,9 @@ "common.notify.delete-fail": "删除失败!", "common.notify.new-success": "新增成功!", "common.notify.new-fail": "新增失败!", + "common.notify.apply-success": "应用成功!", + "common.notify.apply-fail": "应用失败!", + "common.notify.monitor-fail": "查询此监控定义详情失败!", "common.notify.edit-success": "修改成功!", "common.notify.edit-fail": "修改失败!", "common.notify.mark-success": "标记成功!", @@ -232,6 +267,8 @@ "common.button.detect": "测试", "common.button.cancel": "取消", "common.button.help": "帮助", + "common.button.edit": "编辑", + "common.button.delete": "删除", "app.role.admin": "管理员", "app.lock": "锁屏", "app.lock.placeholder": "输入任意解锁",