update.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. {% extends "portal/layout.html" %}
  2. {% block content %}
  3. <link rel="stylesheet" href="{{ url_for('static', filename='select2/select2.css') }}"/>
  4. <link rel="stylesheet" href="{{ url_for('static', filename='css/select2-bootstrap.css') }}"/>
  5. <script type="text/javascript" src="{{ url_for('static', filename='select2/select2.min.js') }}"></script>
  6. <input type="hidden" id="tpl_id" value="{{ data.tpl.id }}">
  7. <div class="panel panel-default">
  8. <div class="panel-heading">模板基本信息</div>
  9. <div class="panel-body">
  10. <div class="form-inline mt10" role="form">
  11. <div class="form-group">
  12. name: <input type="text" style="width: 400px;" value="{{ data.tpl.tpl_name }}" class="form-control"
  13. id="name">
  14. </div>
  15. <div class="form-group">
  16. parent:
  17. </div>
  18. <div class="form-group">
  19. <input type="text" style="width: 400px;" value="{{ data.tpl.parent.id }}" class="form-control"
  20. id="parent_id">
  21. </div>
  22. <div class="form-group">
  23. <button class="btn btn-default" onclick="update_template();">
  24. <span class="glyphicon glyphicon-floppy-disk"></span>
  25. Save
  26. </button>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="panel panel-default">
  32. <div class="panel-heading">该模板中的策略列表</div>
  33. <div class="panel-body">
  34. <div class="pull-right">
  35. <a class="btn btn-default" href="javascript:goto_strategy_add_div();">
  36. <span class="glyphicon glyphicon-plus"></span>
  37. </a>
  38. </div>
  39. <div style="line-height: 35px;">
  40. max: 最大报警次数 P:报警级别(&lt;3: 既发短信也发邮件 &gt;=3: 只发邮件) run:生效时间,不指定就是全天生效
  41. </div>
  42. </div>
  43. <table class="table table-hover table-bordered table-striped" style="margin-bottom: 0px;">
  44. <thead>
  45. <tr>
  46. <th>metric/<span class="text-success">tags</span><span class="gray"> [note]</span></th>
  47. <th>condition</th>
  48. <th>max</th>
  49. <th>P</th>
  50. <th>run</th>
  51. <th>operation</th>
  52. </tr>
  53. </thead>
  54. <tbody>
  55. {% for s in data.ss %}
  56. <tr>
  57. <td>
  58. {{ s.metric }}{% if s.tags %}/<span class="text-success">{{ s.tags }}</span>{% endif %}
  59. <span class="gray">{% if s.note %}[{{ s.note }}]{% endif %}</span>
  60. </td>
  61. <td>
  62. {{ s.func }}{{ s.op }}{{ s.right_value }}
  63. </td>
  64. <td>{{ s.max_step }}</td>
  65. <td>{{ s.priority }}</td>
  66. <td>{% if s.run_begin and s.run_end %}{{ s.run_begin }}-{{ s.run_end }}{% endif %}</td>
  67. <td>
  68. <a href="javascript:clone_strategy('{{ s.id }}');" style="text-decoration: none;">
  69. <span class="glyphicon glyphicon-duplicate orange"></span>
  70. </a>
  71. <span class="cut-line">¦</span>
  72. <a href="javascript:modify_strategy('{{ s.id }}');" style="text-decoration: none;">
  73. <span class="glyphicon glyphicon-edit orange"></span>
  74. </a>
  75. <span class="cut-line">¦</span>
  76. <a href="javascript:delete_strategy('{{ s.id }}');" style="text-decoration: none;">
  77. <span class="glyphicon glyphicon-trash orange"></span>
  78. </a>
  79. </td>
  80. </tr>
  81. {% else %}
  82. <tr>
  83. <td colspan="6">no records</td>
  84. </tr>
  85. {% endfor %}
  86. </tbody>
  87. </table>
  88. </div>
  89. <input type="hidden" id="current_sid">
  90. <a name="add"></a>
  91. <div class="panel panel-success" id="add_div" style="display: none;">
  92. <div class="panel-heading">策略添加/修改</div>
  93. <div class="panel-body">
  94. <div class="form-inline mt10" role="form">
  95. <div class="form-group">
  96. metric:
  97. </div>
  98. <div class="form-group">
  99. <input type="text" style="width: 300px;" class="form-control" id="metric">
  100. </div>
  101. <div class="form-group">
  102. tags: <input type="text" class="form-control" id="tags">
  103. Max: <input class="form-control" id="max_step" style="width: 100px;" value="3">
  104. P: <input class="form-control" id="priority" style="width: 60px;" value="0">
  105. note: <input class="form-control" id="note">
  106. </div>
  107. </div>
  108. <div class="form-inline mt10" role="form">
  109. <div class="form-group">
  110. if <input type="text" value="all(#3)" class="form-control" id="func" style="width: 500px;">
  111. <select class="form-control" id="op">
  112. <option value="==">==</option>
  113. <option value="!=">!=</option>
  114. <option value="<">&lt;</option>
  115. <option value="<=">&lt;=</option>
  116. <option value=">">&gt;</option>
  117. <option value=">=">&gt;=</option>
  118. </select>
  119. <input type="text" value="0" class="form-control" id="right_value" style="width: 100px;">
  120. : alarm(); callback();
  121. </div>
  122. </div>
  123. <div class="form-inline mt10" role="form">
  124. <div class="form-group">
  125. run begin(e.g. 00:00): <input type="text" class="form-control" id="run_begin">
  126. run end(e.g. 24:00): <input type="text" class="form-control" id="run_end">
  127. (生效时间,不指定就是全天生效)
  128. </div>
  129. </div>
  130. <button class="btn btn-default" onclick="save_strategy();">
  131. <span class="glyphicon glyphicon-floppy-disk"></span>
  132. Save
  133. </button>
  134. </div>
  135. </div>
  136. <div class="panel panel-warning">
  137. <div class="panel-heading">模板报警配置,对模板中的所有策略生效</div>
  138. <div class="panel-body">
  139. <div class="panel panel-default">
  140. <div class="panel-heading">def alarm(): #配置了UIC组才会发报警</div>
  141. <div class="panel-body">
  142. 报警接收组(管理报警组,<a target="_blank" href="/team/list">快捷入口</a>):
  143. <input class="form-control" id="uic" value="{{ data.tpl.action.uic }}">
  144. </div>
  145. </div>
  146. <div class="panel panel-default">
  147. <div class="panel-heading">def callback(): #高级用法,配置了callback地址才会触发回调</div>
  148. <div class="panel-body">
  149. callback地址(只支持http get方式回调):
  150. <input class="form-control" id="callback_url" value="{{ data.tpl.action.url }}">
  151. <div class="mt10">
  152. <label class="checkbox-inline">
  153. <input type="checkbox" id="before_callback_sms"
  154. {% if data.tpl.action.before_callback_sms == 1 %}checked="checked"{% endif %}> 回调之前发提醒短信
  155. </label>
  156. <label class="checkbox-inline">
  157. <input type="checkbox" id="before_callback_mail"
  158. {% if data.tpl.action.before_callback_mail == 1 %}checked="checked"{% endif %}> 回调之前发提醒邮件
  159. </label>
  160. <label class="checkbox-inline">
  161. <input type="checkbox" id="after_callback_sms"
  162. {% if data.tpl.action.after_callback_sms == 1 %}checked="checked"{% endif %}> 回调之后发结果短信
  163. </label>
  164. <label class="checkbox-inline">
  165. <input type="checkbox" id="after_callback_mail"
  166. {% if data.tpl.action.after_callback_mail == 1 %}checked="checked"{% endif %}> 回调之后发结果邮件
  167. </label>
  168. </div>
  169. </div>
  170. </div>
  171. <button class="btn btn-default" onclick="save_action_for_tpl('{{ data.tpl.id }}');">
  172. <span class="glyphicon glyphicon-floppy-disk"></span>
  173. Save
  174. </button>
  175. </div>
  176. </div>
  177. <script>
  178. $(function () {
  179. make_select2_for_template("#parent_id");
  180. make_select2_for_uic_group("#uic");
  181. make_select2_for_metric("#metric");
  182. });
  183. </script>
  184. {% endblock %}