-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c9a712
commit 8ac0b44
Showing
9 changed files
with
274 additions
and
778 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { t } from '@locales/index'; | ||
|
||
/** | ||
* 机器事件统类型 | ||
*/ | ||
export const enum MachineEvents { | ||
IMPORT_RESOURCE = 'import_resource', | ||
APPLY_RESOURCE = 'apply_resource', | ||
RETURN_RESOURCE = 'return_resource', | ||
TO_DIRTY = 'to_dirty', | ||
TO_RECYCLE = 'to_recycle', | ||
TO_FAULT = 'to_fault', | ||
UNDO_IMPORT = 'undo_import', | ||
RECYCLED = 'recycled', | ||
} | ||
|
||
export const machineEventsDisplayMap = { | ||
[MachineEvents.IMPORT_RESOURCE]: t('导入资源池'), | ||
[MachineEvents.APPLY_RESOURCE]: t('申请资源'), | ||
[MachineEvents.RETURN_RESOURCE]: t('退回资源'), | ||
[MachineEvents.TO_DIRTY]: t('转入污点池'), | ||
[MachineEvents.TO_RECYCLE]: t('转入待回收池'), | ||
[MachineEvents.TO_FAULT]: t('转入故障池'), | ||
[MachineEvents.UNDO_IMPORT]: t('撤销导入'), | ||
[MachineEvents.RECYCLED]: t('回收'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
dbm-ui/frontend/src/services/model/db-resource/machineEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { MachineEvents, machineEventsDisplayMap } from '@common/const/machineEvents'; | ||
|
||
import { utcDisplayTime } from '@utils'; | ||
|
||
import { t } from '@locales/index'; | ||
|
||
export default class MachineEvent { | ||
bk_biz_id: number | undefined; | ||
bk_biz_name: string | undefined; | ||
bk_host_id: number; | ||
clusters: string[]; | ||
creator: string; | ||
create_at: string; | ||
db_app_abbr: string; | ||
event: MachineEvents; | ||
id: number; | ||
ip: string; | ||
ticket: number | null; | ||
ticket_type_display: string; | ||
to: string; | ||
updater: string; | ||
update_at: string; | ||
|
||
constructor(payload = {} as MachineEvent) { | ||
this.bk_biz_id = payload.bk_biz_id; | ||
this.bk_biz_name = payload.bk_biz_name; | ||
this.bk_host_id = payload.bk_host_id; | ||
this.clusters = payload.clusters; | ||
this.creator = payload.creator; | ||
this.create_at = payload.create_at; | ||
this.db_app_abbr = payload.db_app_abbr; | ||
this.event = payload.event; | ||
this.id = payload.id; | ||
this.ip = payload.ip; | ||
this.ticket = payload.ticket; | ||
this.ticket_type_display = payload.ticket_type_display; | ||
this.to = payload.to; | ||
this.updater = payload.updater; | ||
this.update_at = payload.update_at; | ||
} | ||
|
||
get bizDisplay() { | ||
return this.bk_biz_id ? `${this.bk_biz_name}(#${this.bk_biz_id},${this.db_app_abbr})` : '--'; | ||
} | ||
|
||
get eventDisplay() { | ||
return machineEventsDisplayMap[this.event]; | ||
} | ||
|
||
get updateAtDisplay() { | ||
return utcDisplayTime(this.update_at); | ||
} | ||
|
||
get operationDetail() { | ||
switch (this.event) { | ||
case MachineEvents.IMPORT_RESOURCE: | ||
return `${this.eventDisplay}(${t('从「n」业务 CMDB空闲机模块导入', { n: this.bk_biz_name })})`; | ||
case MachineEvents.APPLY_RESOURCE: | ||
return this.eventDisplay; | ||
case MachineEvents.RETURN_RESOURCE: | ||
return t('业务主机退回资源池'); | ||
case MachineEvents.TO_DIRTY: | ||
return this.eventDisplay; | ||
case MachineEvents.TO_RECYCLE: | ||
return t('资源池主机转入待回收池'); | ||
case MachineEvents.TO_FAULT: | ||
return this.bk_biz_id ? t('资源池主机转入故障池') : t('业务主机转入故障池'); | ||
case MachineEvents.UNDO_IMPORT: | ||
return `${this.eventDisplay}(${t('退回「n」业务 CMDB 空闲机模块', { n: this.bk_biz_name })})`; | ||
case MachineEvents.RECYCLED: | ||
return `${this.eventDisplay}(${t('退回「n」业务 CMDB 待回收模块', { n: this.bk_biz_name })})`; | ||
default: | ||
return this.event; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.