alert-notice.component.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <nz-divider></nz-divider>
  2. <nz-breadcrumb>
  3. <nz-breadcrumb-item>
  4. <a [routerLink]="['/']">
  5. <i nz-icon nzType="home"></i>
  6. <span>仪表盘</span>
  7. </a>
  8. </nz-breadcrumb-item>
  9. <nz-breadcrumb-item>
  10. <i nz-icon nzType="alert"></i>
  11. <span>告警通知配置</span>
  12. </nz-breadcrumb-item>
  13. </nz-breadcrumb>
  14. <nz-divider></nz-divider>
  15. <nz-tabset nzSize="large">
  16. <nz-tab nzTitle="告警接收人">
  17. <button nz-button nzType="primary" (click)="onNewNoticeReceiver()">
  18. <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
  19. 新增接收人
  20. </button>
  21. <button nz-button nzType="primary" (click)="syncReceiver()" nz-tooltip nzTooltipTitle="刷新">
  22. <i nz-icon nzType="sync" nzTheme="outline"></i>
  23. </button>
  24. <nz-table
  25. #fixedTable
  26. [nzData]="receivers"
  27. nzFrontPagination="false"
  28. [nzLoading]="receiverTableLoading"
  29. [nzScroll]="{ x: '100%', y: '100%' }"
  30. >
  31. <thead>
  32. <tr>
  33. <th nzAlign="center" nzWidth="10%">接收人</th>
  34. <th nzAlign="center" nzWidth="20%">通知方式</th>
  35. <th nzAlign="center" nzWidth="20%">配置</th>
  36. <th nzAlign="center" nzWidth="20%">最新修改时间</th>
  37. <th nzAlign="center" nzWidth="30%">操作</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. <tr *ngFor="let data of fixedTable.data">
  42. <td nzAlign="center">
  43. <span>{{ data.name }}</span>
  44. </td>
  45. <td nzAlign="center">
  46. <nz-tag *ngIf="data.type == 0" nzColor="orange">
  47. <i nz-icon nzType="notification" nzTheme="outline"></i>
  48. <span>短信</span>
  49. </nz-tag>
  50. <nz-tag *ngIf="data.type == 1" nzColor="orange">
  51. <i nz-icon nzType="notification" nzTheme="outline"></i>
  52. <span>邮件</span>
  53. </nz-tag>
  54. <nz-tag *ngIf="data.type == 2" nzColor="orange">
  55. <i nz-icon nzType="notification" nzTheme="outline"></i>
  56. <span>WebHook</span>
  57. </nz-tag>
  58. <nz-tag *ngIf="data.type == 3" nzColor="orange">
  59. <i nz-icon nzType="notification" nzTheme="outline"></i>
  60. <span>微信公众号</span>
  61. </nz-tag>
  62. <nz-tag *ngIf="data.type == 4" nzColor="orange">
  63. <i nz-icon nzType="notification" nzTheme="outline"></i>
  64. <span>企业微信机器人</span>
  65. </nz-tag>
  66. </td>
  67. <td nzAlign="center">
  68. <span *ngIf="data.type == 0">{{ data.phone }}</span>
  69. <span *ngIf="data.type == 1">{{ data.email }}</span>
  70. <span *ngIf="data.type == 2">{{ data.hookUrl }}</span>
  71. <span *ngIf="data.type == 3">{{ data.wechatId }}</span>
  72. <span *ngIf="data.type == 4">{{ data.wechatId }}</span>
  73. </td>
  74. <td nzAlign="center">{{ data.gmtUpdate ? data.gmtUpdate : data.gmtCreate }}</td>
  75. <td nzAlign="center">
  76. <button nz-button nzType="primary" (click)="onEditOneNoticeReceiver(data)" nz-tooltip nzTooltipTitle="修改接收人">
  77. <i nz-icon nzType="edit" nzTheme="outline"></i>
  78. </button>
  79. <button nz-button nzType="primary" (click)="onDeleteOneNoticeReceiver(data.id)" nz-tooltip nzTooltipTitle="删除接收人">
  80. <i nz-icon nzType="delete" nzTheme="outline"></i>
  81. </button>
  82. </td>
  83. </tr>
  84. </tbody>
  85. </nz-table>
  86. </nz-tab>
  87. <nz-tab nzTitle="告警通知策略">
  88. <button nz-button nzType="primary" (click)="onNewNoticeRule()">
  89. <i nz-icon nzType="appstore-add" nzTheme="outline"></i>
  90. 新增通知策略
  91. </button>
  92. <button nz-button nzType="primary" (click)="syncRule()" nz-tooltip nzTooltipTitle="刷新">
  93. <i nz-icon nzType="sync" nzTheme="outline"></i>
  94. </button>
  95. <nz-table
  96. #ruleFixedTable
  97. [nzData]="rules"
  98. nzFrontPagination="false"
  99. [nzLoading]="ruleTableLoading"
  100. [nzScroll]="{ x: '100%', y: '100%' }"
  101. >
  102. <thead>
  103. <tr>
  104. <th nzAlign="center" nzWidth="15%">策略名称</th>
  105. <th nzAlign="center" nzWidth="12%">接收人</th>
  106. <th nzAlign="center" nzWidth="12%">转发所有</th>
  107. <th nzAlign="center" nzWidth="15%">是否启用</th>
  108. <th nzAlign="center" nzWidth="15%">最新修改时间</th>
  109. <th nzAlign="center" nzWidth="25%">操作</th>
  110. </tr>
  111. </thead>
  112. <tbody>
  113. <tr *ngFor="let data of ruleFixedTable.data">
  114. <td nzAlign="center">
  115. <span>{{ data.name }}</span>
  116. </td>
  117. <td nzAlign="center">
  118. <span>{{ data.receiverName }}</span>
  119. </td>
  120. <td nzAlign="center">
  121. <nz-tag *ngIf="data.filterAll" nzColor="green">
  122. <span>是</span>
  123. </nz-tag>
  124. <nz-tag *ngIf="!data.filterAll" nzColor="orange">
  125. <span>否</span>
  126. </nz-tag>
  127. </td>
  128. <td nzAlign="center">
  129. <nz-tag *ngIf="data.enable" nzColor="green">
  130. <span>开启</span>
  131. </nz-tag>
  132. <nz-tag *ngIf="!data.enable" nzColor="orange">
  133. <span>关闭</span>
  134. </nz-tag>
  135. </td>
  136. <td nzAlign="center">{{ data.gmtUpdate ? data.gmtUpdate : data.gmtCreate }}</td>
  137. <td nzAlign="center">
  138. <button nz-button nzType="primary" (click)="onEditOneNoticeRule(data)" nz-tooltip nzTooltipTitle="修改告警策略">
  139. <i nz-icon nzType="edit" nzTheme="outline"></i>
  140. </button>
  141. <button nz-button nzType="primary" (click)="onDeleteOneNoticeRule(data.id)" nz-tooltip nzTooltipTitle="删除告警策略">
  142. <i nz-icon nzType="delete" nzTheme="outline"></i>
  143. </button>
  144. </td>
  145. </tr>
  146. </tbody>
  147. </nz-table>
  148. </nz-tab>
  149. </nz-tabset>
  150. <!-- 新增或修改通知接收人弹出框 -->
  151. <nz-modal
  152. [(nzVisible)]="isManageReceiverModalVisible"
  153. [nzTitle]="isManageReceiverModalAdd ? '新增接收人' : '修改接收人'"
  154. (nzOnCancel)="onManageReceiverModalCancel()"
  155. (nzOnOk)="onManageReceiverModalOk()"
  156. nzMaskClosable="false"
  157. nzWidth="40%"
  158. [nzOkLoading]="isManageReceiverModalOkLoading"
  159. >
  160. <div *nzModalContent class="-inner-content">
  161. <form nz-form #receiverForm="ngForm">
  162. <nz-form-item>
  163. <nz-form-label [nzSpan]="7" nzFor="name" nzRequired="true">接收人名称</nz-form-label>
  164. <nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
  165. <input [(ngModel)]="receiver.name" nz-input required name="name" type="text" id="name" />
  166. </nz-form-control>
  167. </nz-form-item>
  168. <nz-form-item>
  169. <nz-form-label nzSpan="7" nzRequired="true" nzFor="type">通知方式 </nz-form-label>
  170. <nz-form-control nzSpan="12" [nzErrorTip]="'validation.required' | i18n">
  171. <nz-select [(ngModel)]="receiver.type" nzPlaceHolder="Choose" required name="type" id="type">
  172. <nz-option [nzValue]="0" nzDisabled nzLabel="短信"></nz-option>
  173. <nz-option [nzValue]="1" nzLabel="邮箱"></nz-option>
  174. <nz-option [nzValue]="2" nzLabel="WebHook"></nz-option>
  175. <nz-option [nzValue]="3" nzDisabled nzLabel="微信公众号"></nz-option>
  176. <nz-option [nzValue]="4" nzLabel="企业微信机器人"></nz-option>
  177. </nz-select>
  178. </nz-form-control>
  179. </nz-form-item>
  180. <nz-form-item *ngIf="receiver.type === 0">
  181. <nz-form-label [nzSpan]="7" nzFor="phone" [nzRequired]="receiver.type === 0">手机号</nz-form-label>
  182. <nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.phone.invalid' | i18n">
  183. <input
  184. [(ngModel)]="receiver.phone"
  185. nz-input
  186. [required]="receiver.type === 0"
  187. pattern="/^1\d{10}$/"
  188. name="phone"
  189. type="tel"
  190. id="phone"
  191. />
  192. </nz-form-control>
  193. </nz-form-item>
  194. <nz-form-item *ngIf="receiver.type === 1">
  195. <nz-form-label [nzSpan]="7" nzFor="email" [nzRequired]="receiver.type === 1">邮箱</nz-form-label>
  196. <nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.email.invalid' | i18n">
  197. <input [(ngModel)]="receiver.email" nz-input [required]="receiver.type === 1" email name="email" type="email" id="email" />
  198. </nz-form-control>
  199. </nz-form-item>
  200. <nz-form-item *ngIf="receiver.type === 2">
  201. <nz-form-label [nzSpan]="7" nzFor="hookUrl" [nzRequired]="receiver.type === 2">URL地址</nz-form-label>
  202. <nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
  203. <input [(ngModel)]="receiver.hookUrl" nz-input [required]="receiver.type === 2" name="hookUrl" type="url" id="hookUrl" />
  204. </nz-form-control>
  205. </nz-form-item>
  206. <nz-form-item *ngIf="receiver.type === 3">
  207. <nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 3">微信OPENID</nz-form-label>
  208. <nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
  209. <input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 3" name="wechatId" type="text" />
  210. </nz-form-control>
  211. </nz-form-item>
  212. <nz-form-item *ngIf="receiver.type === 4">
  213. <nz-form-label [nzSpan]="7" nzFor="wechatId" [nzRequired]="receiver.type === 4">企业微信机器人KEY</nz-form-label>
  214. <nz-form-control [nzSpan]="12" [nzErrorTip]="'validation.required' | i18n">
  215. <input [(ngModel)]="receiver.wechatId" nz-input [required]="receiver.type === 4" name="wechatId" type="text" />
  216. </nz-form-control>
  217. </nz-form-item>
  218. </form>
  219. </div>
  220. </nz-modal>
  221. <!-- 新增或修改通知策略弹出框 -->
  222. <nz-modal
  223. [(nzVisible)]="isManageRuleModalVisible"
  224. [nzTitle]="isManageRuleModalAdd ? '新增策略' : '修改策略'"
  225. (nzOnCancel)="onManageRuleModalCancel()"
  226. (nzOnOk)="onManageRuleModalOk()"
  227. nzMaskClosable="false"
  228. nzWidth="40%"
  229. [nzOkLoading]="isManageRuleModalOkLoading"
  230. >
  231. <div *nzModalContent class="-inner-content">
  232. <form nz-form #ruleForm="ngForm">
  233. <nz-form-item>
  234. <nz-form-label [nzSpan]="7" nzFor="rule_name" nzRequired="true">策略名称</nz-form-label>
  235. <nz-form-control [nzSpan]="8" [nzErrorTip]="'validation.required' | i18n">
  236. <input [(ngModel)]="rule.name" nz-input required name="rule_name" type="text" id="rule_name" />
  237. </nz-form-control>
  238. </nz-form-item>
  239. <nz-form-item>
  240. <nz-form-label nzSpan="7" nzRequired="true" nzFor="filterAll">转发所有</nz-form-label>
  241. <nz-form-control nzSpan="8">
  242. <nz-switch [(ngModel)]="rule.filterAll" disabled name="filterAll" id="filterAll"></nz-switch>
  243. </nz-form-control>
  244. </nz-form-item>
  245. <nz-form-item>
  246. <nz-form-label nzSpan="7" nzRequired="true" nzFor="receiver">接收人</nz-form-label>
  247. <nz-form-control nzSpan="8" [nzErrorTip]="'validation.required' | i18n">
  248. <nz-select
  249. [(ngModel)]="rule.receiverId"
  250. (nzOpenChange)="loadReceiversOption()"
  251. [nzOptions]="receiversOption"
  252. nzShowSearch
  253. nzAllowClear
  254. nzPlaceHolder="Select a person"
  255. required
  256. name="receiver"
  257. id="receiver"
  258. >
  259. </nz-select>
  260. </nz-form-control>
  261. </nz-form-item>
  262. <nz-form-item>
  263. <nz-form-label nzSpan="7" nzRequired="true" nzFor="enable">是否启用</nz-form-label>
  264. <nz-form-control nzSpan="8">
  265. <nz-switch [(ngModel)]="rule.enable" name="enable" id="enable"></nz-switch>
  266. </nz-form-control>
  267. </nz-form-item>
  268. </form>
  269. </div>
  270. </nz-modal>