alertrouter.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. {{template "main" .}}
  2. <!-- Navbar -->
  3. <nav class="main-header navbar navbar-expand navbar-white navbar-light">
  4. <!-- Left navbar links -->
  5. <ul class="navbar-nav">
  6. <li class="nav-item">
  7. <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
  8. </li>
  9. <li class="nav-item d-none d-sm-inline-block">
  10. <a href="/alertrouter" class="nav-link">告警管理</a>
  11. </li>
  12. </ul>
  13. </nav>
  14. <!-- /.navbar -->
  15. <!-- Content Wrapper. Contains page content -->
  16. <div class="content-wrapper">
  17. <!-- Content Header (Page header) -->
  18. <section class="content-header">
  19. <div class="container-fluid">
  20. <div class="row mb-2">
  21. <div class="col-sm-6">
  22. <h1>告警路由</h1>
  23. </div>
  24. <div class="col-sm-6">
  25. <ol class="breadcrumb float-sm-right">
  26. <a href="/alertrouter/add" class="btn btn-default bg-warning">
  27. <i class="fas fa-file mr-2"></i> 添加路由
  28. </a>
  29. </ol>
  30. </div>
  31. </div>
  32. </div><!-- /.container-fluid -->
  33. </section>
  34. <!-- Main content -->
  35. <section class="content">
  36. <!-- Default box -->
  37. <div class="card">
  38. <div class="card-header">
  39. <h3 class="card-title" style="color:red">** 告警路由目前仅支持 Prometheus</h3>
  40. <div class="card-tools">
  41. <button type="button" class="btn btn-tool" data-card-widget="collapse" title="Collapse">
  42. <i class="fas fa-minus"></i>
  43. </button>
  44. <button type="button" class="btn btn-tool" data-card-widget="remove" title="Remove">
  45. <i class="fas fa-times"></i>
  46. </button>
  47. </div>
  48. </div>
  49. <div class="card-body">
  50. <table id="example1" class="table table-hover">
  51. <thead>
  52. <tr>
  53. <th style="display:none;">Id</th>
  54. <th>路由名称</th>
  55. <th>生效模版</th>
  56. <th>模版类型</th>
  57. <th>模版用途</th>
  58. <th>路由规则</th>
  59. <th>创建时间</th>
  60. <th>编辑</th>
  61. <th>删除</th>
  62. </tr>
  63. </thead>
  64. <tbody id="tpllist" >
  65. {{range $k,$v:= .AlertRouter}}
  66. <tr>
  67. <th style="display:none;">{{.Id}}</th>
  68. <th>{{$v.Name}}</th>
  69. <th>{{$v.Tpl.Tplname}}</th>
  70. <th>
  71. {{if eq $v.Tpl.Tpltype "dd"}}钉钉{{end}}
  72. {{if eq $v.Tpl.Tpltype "wx"}}企业微信{{end}}
  73. {{if eq $v.Tpl.Tpltype "workwechat"}}企业微信应用{{end}}
  74. {{if eq $v.Tpl.Tpltype "fs"}}飞书{{end}}
  75. {{if eq $v.Tpl.Tpltype "webhook"}}WebHook{{end}}
  76. {{if eq $v.Tpl.Tpltype "txdx"}}腾讯云短信{{end}}
  77. {{if eq $v.Tpl.Tpltype "txdh"}}腾讯云电话{{end}}
  78. {{if eq $v.Tpl.Tpltype "alydx"}}阿里云短信{{end}}
  79. {{if eq $v.Tpl.Tpltype "alydh"}}阿里云电话{{end}}
  80. {{if eq $v.Tpl.Tpltype "hwdx"}}华为云短信{{end}}
  81. {{if eq $v.Tpl.Tpltype "bddx"}}百度云短信{{end}}
  82. {{if eq $v.Tpl.Tpltype "rlydh"}}容联云电话{{end}}
  83. {{if eq $v.Tpl.Tpltype "7moordx"}}七陌短信{{end}}
  84. {{if eq $v.Tpl.Tpltype "7moordh"}}七陌语音电话{{end}}
  85. {{if eq $v.Tpl.Tpltype "email"}}Email{{end}}
  86. {{if eq $v.Tpl.Tpltype "tg"}}Telegram{{end}}
  87. {{if eq $v.Tpl.Tpltype "rl"}}百度Hi(如流){{end}}
  88. {{if eq $v.Tpl.Tpltype "bark"}}Bark(iPhone推送){{end}}
  89. {{if eq $v.Tpl.Tpltype "voice"}}语音播报{{end}}
  90. {{if eq $v.Tpl.Tpltype "fsapp"}}飞书机器人应用{{end}}
  91. </th>
  92. <th>{{$v.Tpl.Tpluse}}</th>
  93. <th>
  94. {{$v.Rules}}
  95. </th>
  96. <th>{{$v.Created.Format "2006-01-02 15:04:05 UTC"}}</th>
  97. <th>
  98. <a href="/alertrouter/edit?id={{.Id}}" class="btn btn-default bg-success">
  99. <i class="fa fa-edit"></i> Edit
  100. </a>
  101. </th>
  102. <th>
  103. <a href="javascript:if(confirm('确实要删除吗?'))location='/alertrouter/del?id={{.Id}}'" class="btn btn-default bg-danger">
  104. <i class="fa fa-trash"></i> Delete
  105. </a>
  106. </th>
  107. </tr>
  108. {{end}}
  109. </tbody>
  110. </table>
  111. </div>
  112. <!-- /.card-body -->
  113. <div class="card-footer">
  114. </div>
  115. <!-- /.card-footer-->
  116. </div>
  117. <!-- /.card -->
  118. </section>
  119. <!-- /.content -->
  120. </div>
  121. <!-- /.content-wrapper -->
  122. {{template "endhtml"}}
  123. <script>
  124. $(function () {
  125. var tb = document.getElementById('example1');
  126. var td = tb.rows[1].cells[5];
  127. for(var i=1,rows=tb.rows.length; i<rows; i++){
  128. var td = tb.rows[i].cells[5];
  129. var str = td.innerHTML;
  130. var obj = JSON.parse(str);
  131. var table_str = ""
  132. for(var p in obj){
  133. console.log(obj[p]);
  134. if (obj[p].Regex){
  135. ischeck="正则"
  136. } else {
  137. ischeck="普通"
  138. }
  139. table_str = table_str + '<span class="badge bg-info">'+obj[p].Name+' = '+obj[p].Value+' | '+ischeck+'</span><br />'
  140. }
  141. td.innerHTML = table_str;
  142. }
  143. })
  144. </script>
  145. {{template "jshtml"}}