alert-notice.component.html 13 KB

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