add.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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="expression_id" value="{{ data.expression.id }}">
  7. <div class="panel panel-default">
  8. <div class="panel-heading">{% if data.expression.id %}modify{% else %}add{% endif %} expression <span class="gray">e.g. each(metric=qps srv=falcon) </span></div>
  9. <div class="panel-body">
  10. <textarea class="form-control" rows="2" id="expression"
  11. placeholder="e.g. each(metric=qps srv=falcon)">{{ data.expression.expression }}</textarea>
  12. <div class="form-inline mt10" role="form">
  13. <div class="form-group">
  14. if <input type="text" value="{{ data.expression.func or 'all(#3)' }}" class="form-control" id="func"
  15. style="width: 500px;">
  16. <select class="form-control" id="op">
  17. <option value="=="
  18. {% if data.expression.op == '==' or data.expression.op == '=' %}selected{% endif %}
  19. >==
  20. </option>
  21. <option value="!=" {% if data.expression.op == '!=' %}selected{% endif %}>!=</option>
  22. <option value="<" {% if data.expression.op == '<' %}selected{% endif %}>&lt;</option>
  23. <option value="<=" {% if data.expression.op == '<=' %}selected{% endif %}>&lt;=</option>
  24. <option value=">" {% if data.expression.op == '>' %}selected{% endif %}>&gt;</option>
  25. <option value=">=" {% if data.expression.op == '>=' %}selected{% endif %}>&gt;=</option>
  26. </select>
  27. <input type="text" value="{{ data.expression.right_value or '0' }}" class="form-control"
  28. id="right_value"
  29. style="width: 100px;">
  30. : alarm(); callback();
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="panel panel-default">
  36. <div class="panel-heading">def alarm(): #配置了UIC组才会发报警</div>
  37. <div class="panel-body">
  38. 报警接收组(在UIC中管理报警组,<a target="_blank" href="/team/list">快捷入口</a>):
  39. <input class="form-control" id="uic" value="{{ data.action.uic }}">
  40. <div class="form-inline mt10" role="form">
  41. <div class="form-group">
  42. 最多报警次数:<input class="form-control" id="max_step" style="width: 100px;"
  43. value="{{ data.expression.max_step or '3' }}">
  44. 报警级别(&lt;3: sms and mail; &gt;=3: mail):
  45. <input class="form-control" id="priority"
  46. style="width: 60px;"
  47. value="{{ data.expression.priority or '0' }}">
  48. 备注信息(将附在告警内容中发送):<input class="form-control" id="note" value="{{ data.expression.note }}">
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. <div class="panel panel-default">
  54. <div class="panel-heading">def callback(): #高级用法,配置了callback地址才会触发回调</div>
  55. <div class="panel-body">
  56. callback地址(只支持http get方式回调):
  57. <input class="form-control" id="callback_url" value="{{ data.action.url }}">
  58. <div class="mt10">
  59. <label class="checkbox-inline">
  60. <input type="checkbox" id="before_callback_sms"
  61. {% if data.action.before_callback_sms == 1 %}checked="checked"{% endif %}> 回调之前发提醒短信
  62. </label>
  63. <label class="checkbox-inline">
  64. <input type="checkbox" id="before_callback_mail"
  65. {% if data.action.before_callback_mail == 1 %}checked="checked"{% endif %}> 回调之前发提醒邮件
  66. </label>
  67. <label class="checkbox-inline">
  68. <input type="checkbox" id="after_callback_sms"
  69. {% if data.action.after_callback_sms == 1 %}checked="checked"{% endif %}> 回调之后发结果短信
  70. </label>
  71. <label class="checkbox-inline">
  72. <input type="checkbox" id="after_callback_mail"
  73. {% if data.action.after_callback_mail == 1 %}checked="checked"{% endif %}> 回调之后发结果邮件
  74. </label>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="mb20">
  79. <button class="btn btn-default" onclick="update_expression();">Submit</button>
  80. <button class="btn btn-default" onclick="history.go(-1);">
  81. <span class="glyphicon glyphicon-arrow-left"></span>
  82. <span>Back</span>
  83. </button>
  84. </div>
  85. <script>
  86. $(function () {
  87. make_select2_for_uic_group('#uic');
  88. });
  89. </script>
  90. {% endblock %}