Skip to content

Commit

Permalink
[refactor] translate chinese into english in web-app (#2343)
Browse files Browse the repository at this point in the history
Co-authored-by: tomsun28 <[email protected]>
  • Loading branch information
Calvin979 and tomsun28 authored Jul 23, 2024
1 parent 8d34de4 commit df4115a
Show file tree
Hide file tree
Showing 45 changed files with 138 additions and 148 deletions.
20 changes: 10 additions & 10 deletions web-app/src/app/core/interceptor/default.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CODE_MESSAGE: { [key: number]: string } = {
@Injectable()
export class DefaultInterceptor implements HttpInterceptor {
private notified = false;
// 是否正在刷新TOKEN过程
// Whether token is refreshing
private refreshToking = false;
private refreshToken$: BehaviorSubject<any> = new BehaviorSubject<any>(null);

Expand Down Expand Up @@ -70,7 +70,7 @@ export class DefaultInterceptor implements HttpInterceptor {
}

/**
* 刷新 Token 请求
* refresh Token request
*/
private refreshTokenRequest(): Observable<Message<any>> {
const refreshToken = this.storageSvc.getRefreshToken();
Expand All @@ -83,35 +83,35 @@ export class DefaultInterceptor implements HttpInterceptor {
// #region 刷新Token方式一:使用 401 重新刷新 Token

private tryRefreshToken(ev: HttpResponseBase, req: HttpRequest<any>, next: HttpHandler): Observable<any> {
// 1、若请求为刷新Token请求,表示来自刷新Token可以直接跳转登录页
// 1, redirect to login page if this request is used for refreshing token
if ([`/account/auth/refresh`].some(url => req.url.includes(url))) {
this.toLogin();
return throwError(ev);
}
// 2、如果 `refreshToking` 为 `true` 表示已经在请求刷新 Token 中,后续所有请求转入等待状态,直至结果返回后再重新发起请求
// 2, if `refreshToking` is true, means that the refreshing token request is in progress
// All requests will be suspended and wait for the refreshing token request to complete
if (this.refreshToking) {
return this.refreshToken$.pipe(
filter(v => !!v),
take(1),
switchMap(() => next.handle(this.reAttachToken(req)))
);
}
// 3、尝试调用刷新 Token
// 3、try refreshing Token
this.refreshToking = true;
this.refreshToken$.next(null);
return this.refreshTokenRequest().pipe(
switchMap(res => {
// 判断刷新TOKEN是否正确
// Check whether the TOKEN is correct
this.refreshToking = false;
if (res.code === 0 && res.data != undefined) {
let token = res.data.token;
let refreshToken = res.data.refreshToken;
if (token != undefined) {
this.storageSvc.storageAuthorizationToken(token);
this.storageSvc.storageRefreshToken(refreshToken);
// 通知后续请求继续执行
// notifies subsequent requests to continue
this.refreshToken$.next(token);
// 重新发起请求
return next.handle(this.reAttachToken(req));
} else {
console.warn(`flush new token failed. ${res.msg}`);
Expand All @@ -123,7 +123,7 @@ export class DefaultInterceptor implements HttpInterceptor {
}
}),
catchError(err => {
// token 刷新失败
// refreshing token is failed, redirect to login page
console.warn(`flush new token failed. ${err.msg}`);
this.refreshToking = false;
this.toLogin();
Expand Down Expand Up @@ -176,7 +176,7 @@ export class DefaultInterceptor implements HttpInterceptor {
}
}),
catchError((err: HttpErrorResponse) => {
// 处理失败响应,处理token过期自动刷新
// handle failed response and token expired
switch (err.status) {
case 401:
return this.tryRefreshToken(err, newReq, next);
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/layout/basic/widgets/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class HeaderSearchComponent implements AfterViewInit, OnDestroy {
})
)
.subscribe(value => {
// 远程加载搜索数据
// Remote loading of search data
let searchMonitors$ = this.monitorSvc.searchMonitors(undefined, undefined, value, 9, 0, 10).subscribe(
message => {
this.loading = false;
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/app/pojo/Alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class Alert {
target!: string;
monitorId!: number;
monitorName!: string;
// 告警级别 0:高-emergency-紧急告警-红色 1:-critical-严重告警-橙色 2:-warning-警告告警-黄色
// alert level -- 0:high-emergency-red 1:medium-critical-orange 2:low-warning-yellow
priority: number = 2;
// 告警状态: 0-正常告警(待处理) 1-阈值触发但未达到告警次数 2-恢复告警 3-已处理
// alert status-- 0-to be processed 1-not reached the threshold 2-recover 3-processed
status!: number;
content!: string;
// alarm times
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/pojo/AlertDefine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class AlertDefine {
field!: string;
preset: boolean = true;
expr!: string;
// 告警级别 0:高-emergency-紧急告警-红色 1:-critical-严重告警-橙色 2:-warning-警告告警-黄色
// alert level -- 0:high-emergency-red 1:medium-critical-orange 2:low-warning-yellow
priority: number = 2;
times: number = 3;
tags!: TagItem[];
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/app/pojo/NoticeReceiver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
export class NoticeReceiver {
id!: number;
name!: string;
// 通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号 4-企业微信机器人 5-钉钉机器人 6-飞书机器人
// 7-Telegram机器人 8-SlackWebHook 9-Discord机器人 10-企业微信应用消息 11-华为云SMN 12-Server酱 13-Gotify
// notification mode: 0-sms 1-email 2-webhook 3-wechat public account 4-work wechat robot 5-Dingding robot 6-Feishu robot
// 7-Telegram robot 8-SlackWebHook 9-Discord robot 10-work wechat app message 11-Huawei cloud SMN 12-ServerChan 13-Gotify
type: number = 1;
phone!: string;
email!: string;
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/app/pojo/NoticeRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export class NoticeRule {
templateId!: number | null;
templateName!: string | null;
enable: boolean = true;
// 是否转发所有
// forward all or not
filterAll: boolean = true;
// 告警级别过滤
// filter alert level
priorities!: number[];
tags!: TagItem[];
days!: number[];
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/app/pojo/NoticeTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
export class NoticeTemplate {
id!: number;
name!: string;
// 通知信息方式: 0-手机短信 1-邮箱 2-webhook 3-微信公众号 4-企业微信机器人 5-钉钉机器人 6-飞书机器人
// 7-Telegram机器人 8-SlackWebHook 9-Discord机器人 10-企业微信应用消息 11-华为云SMN
// notification mode: 0-sms 1-email 2-webhook 3-wechat public account 4-work wechat robot 5-Dingding robot 6-Feishu robot
// 7-Telegram robot 8-SlackWebHook 9-Discord robot 10-work wechat app message 11-Huawei cloud SMN 12-ServerChan 13-Gotify
type!: number;
preset!: boolean;
creator!: string;
Expand Down
4 changes: 2 additions & 2 deletions web-app/src/app/pojo/ObjectStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ export class ObjectStore<T> {

export enum ObjectStoreType {
/**
* 本地文件
* Local file
*/
FILE = 'FILE',

/**
* <a href="https://support.huaweicloud.com/obs/index.html">华为云OBS</a>
* <a href="https://support.huaweicloud.com/obs/index.html">Huawei cloud OBS</a>
*/
OBS = 'OBS'
}
Expand Down
8 changes: 3 additions & 5 deletions web-app/src/app/pojo/Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,12 @@

export class Page<T> {
content!: T[];
// 集合总页数
totalPages!: number;
// 集合总数
totalElements!: number;
// 查询的pageSize
// page size
size!: number;
// 查询的pageIndex,从0开始
// page index, start from 0
number!: number;
// 当前页的集合数量
// the number of elements in this page
numberOfElements!: number;
}
1 change: 0 additions & 1 deletion web-app/src/app/pojo/Param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ export class Param {
field!: string;
type: number | undefined;
paramValue: any;
// 是否显示
display: boolean = true;
}
5 changes: 2 additions & 3 deletions web-app/src/app/pojo/ParamDefine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ export class ParamDefine {
placeholder!: string;
range: string | undefined;
limit: number | undefined;
//'[{"label":"GET请求","value":"GET"},{"label":"PUT请求","value":"PUT"}]'
options!: any[];
// 当type为key-value时有效,表示别名描述
// key alias. This param is valid when the type is key-value
keyAlias!: string;
valueAlias!: string;
// 此参数是否隐藏 即默认不显示, 在高级设置区显示
// whether the param is hidden, default is false
hide: boolean = false;
// Map of dependent params
depend: Map<string, List<any>> | undefined;
Expand Down
2 changes: 1 addition & 1 deletion web-app/src/app/pojo/Tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Tag {
tagValue!: string;
color: string = this.getRandomColor();
description!: string;
// 标记类型 0:监控自动生成(monitorId,monitorName) 1: 用户生成 2: 系统预置
// tag type -- 0:auto-generated by system(monitorId,monitorName) 1: user generate 2: system preset
type!: number;
creator!: string;
modifier!: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class AlertCenterComponent implements OnInit {
alerts!: Alert[];
tableLoading: boolean = false;
checkedAlertIds = new Set<number>();
// 搜索过滤相关属性
filterStatus: number = 9;
filterPriority: number = 9;
filterContent: string | undefined;
Expand Down Expand Up @@ -274,7 +273,7 @@ export class AlertCenterComponent implements OnInit {
);
}

// begin: 列表多选分页逻辑
// begin: List multiple choice paging
checkedAll: boolean = false;
onAllChecked(checked: boolean) {
if (checked) {
Expand All @@ -296,7 +295,7 @@ export class AlertCenterComponent implements OnInit {
this.pageSize = pageSize;
this.loadAlertsTable();
}
// end: 列表多选分页逻辑
// end: List multiple choice paging

sliceTagName(tag: Tag): string {
if (tag.tagValue != undefined && tag.tagValue.trim() != '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@

<ng-template #rangeTemplate> {{ 'common.total' | i18n }} {{ total }} </ng-template>

<!-- 新增或修改策略弹出框 -->
<!-- new or update alert-converge pop-up box -->
<nz-modal
[(nzVisible)]="isManageModalVisible"
[nzTitle]="isManageModalAdd ? ('alert.converge.new' | i18n) : ('alert.converge.edit' | i18n)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class AlertConvergeComponent implements OnInit {
this.pageIndex = this.pageIndex > lastPage ? lastPage : this.pageIndex;
}

// begin: 列表多选分页逻辑
// begin: List multiple choice paging
checkedAll: boolean = false;
onAllChecked(checked: boolean) {
if (checked) {
Expand All @@ -191,19 +191,19 @@ export class AlertConvergeComponent implements OnInit {
}
}
/**
* 分页回调
* Paging callback
*
* @param params 页码信息
* @param params page info
*/
onTablePageChange(params: NzTableQueryParams) {
const { pageSize, pageIndex, sort, filter } = params;
this.pageIndex = pageIndex;
this.pageSize = pageSize;
this.loadAlertConvergeTable();
}
// end: 列表多选逻辑
// end: List multiple choice paging

// start 新增修改告警静默 model
// start -- new or update alert-converge model
isManageModalVisible = false;
isManageModalOkLoading = false;
isManageModalAdd = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@
</nz-tab>
</nz-tabset>

<!-- 新增或修改通知策略弹出框 -->
<!-- new or update notice strategy pop-up box -->
<nz-modal
(nzOnCancel)="onManageRuleModalCancel()"
(nzOnOk)="onManageRuleModalOk()"
Expand Down Expand Up @@ -505,7 +505,7 @@
</form>
</div>
</nz-modal>
<!-- 新增或修改通知媒介弹出框 -->
<!-- new or update notice medium pop-up box -->
<nz-modal
(nzOnCancel)="onManageReceiverModalCancel()"
(nzOnOk)="onManageReceiverModalOk()"
Expand Down Expand Up @@ -809,7 +809,7 @@
</form>
</div>
</nz-modal>
<!-- 新增或修改通知模板弹出框 -->
<!-- new or update notice template pop-up box -->
<nz-modal
(nzOnCancel)="onManageTemplateModalCancel()"
(nzOnOk)="onManageTemplateModalOk()"
Expand Down Expand Up @@ -874,7 +874,7 @@
</div>
</nz-modal>

<!-- 通知模板示例弹出框 -->
<!-- notice template example pop-up box -->
<nz-modal
(nzOnCancel)="onManageTemplateModalCancel()"
[(nzVisible)]="isShowTemplateModalVisible"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class AlertNoticeComponent implements OnInit {
loading = false;
code: string = '';
originalCode: string = '';
// start 新增或修改通知接收对象弹出框
// start -- new or update notice receiver pop-up box
isManageReceiverModalVisible: boolean = false;
isManageReceiverModalAdd: boolean = true;
isManageReceiverModalOkLoading: boolean = false;
Expand Down Expand Up @@ -232,7 +232,7 @@ export class AlertNoticeComponent implements OnInit {
});
}

// start 新增或修改通知策略弹出框
// start -- new or update notice strategy pop-up box

deleteOneNoticeTemplate(templateId: number) {
const deleteTemplate$ = this.noticeTemplateSvc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@

<ng-template #rangeTemplate> {{ 'common.total' | i18n }} {{ total }} </ng-template>

<!-- 新增或修改告警定义弹出框 -->
<!-- new or update alert definition pop-up box -->
<nz-modal
[(nzVisible)]="isManageModalVisible"
[nzTitle]="isManageModalAdd ? ('alert.setting.new' | i18n) : ('alert.setting.edit' | i18n)"
Expand Down Expand Up @@ -502,7 +502,7 @@
</div>
</nz-modal>

<!-- 关联告警定义与监控关系弹出框 -->
<!-- associate alert definition and monitoring pop-up box -->

<nz-modal
[(nzVisible)]="isConnectModalVisible"
Expand Down Expand Up @@ -549,7 +549,7 @@
</nz-transfer>
</nz-modal>

<!-- 导出告警定义弹出框 -->
<!-- export alert definitions pop-up box -->
<nz-modal
[(nzVisible)]="isSwitchExportTypeModalVisible"
[nzTitle]="'alert.export.switch-type' | i18n"
Expand Down
Loading

0 comments on commit df4115a

Please sign in to comment.