You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.8 KiB

9 years ago
  1. {% extends "base.html" %}
  2. {% load compress humanize staticfiles hc_extras %}
  3. {% block title %}Add Webhook - {% site_name %}{% endblock %}
  4. {% block content %}
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <h1>Webhook</h1>
  8. <p>Runs a HTTP GET or HTTP POST to your specified URL when a check
  9. goes up or down. Uses GET by default, and uses POST if you specify
  10. any POST data.</p>
  11. <p>You can use the following variables in webhook URLs:</p>
  12. <table class="table webhook-variables">
  13. <tr>
  14. <th class="variable-column">Variable</th>
  15. <td>Will be replaced with…</td>
  16. </tr>
  17. <tr>
  18. <th><code>$CODE</code></th>
  19. <td>The UUID code of the check</td>
  20. </tr>
  21. <tr>
  22. <th><code>$NAME</code></th>
  23. <td>Name of the check</td>
  24. </tr>
  25. <tr>
  26. <th><code>$NOW</code></th>
  27. <td>
  28. Current UTC time in ISO8601 format.
  29. Example: "{{ now }}"
  30. </td>
  31. </tr>
  32. <tr>
  33. <th><code>$STATUS</code></th>
  34. <td>Check's current status ("up" or "down")</td>
  35. </tr>
  36. <tr>
  37. <th><code>$TAG1, $TAG2, …</code></th>
  38. <td>Value of the first tag, the second tag, …</td>
  39. </tr>
  40. </table>
  41. <p>For example, a callback URL using variables might look like so:
  42. <pre>http://requestb.in/1hhct291?message=<strong>$NAME</strong>:<strong>$STATUS</strong></pre>
  43. <p>
  44. After encoding and replacing the variables, {% site_name %} would then call:
  45. </p>
  46. <pre>http://requestb.in/1hhct291?message=<strong>My%20Check</strong>:<strong>down</strong></pre>
  47. <h2>Integration Settings</h2>
  48. <form method="post" class="form-horizontal">
  49. {% csrf_token %}
  50. <input type="hidden" name="kind" value="webhook" />
  51. <div class="form-group {{ form.url_down.css_classes }}">
  52. <label class="col-sm-2 control-label">URL for "down" events</label>
  53. <div class="col-sm-10">
  54. <input
  55. type="text"
  56. class="form-control"
  57. name="url_down"
  58. placeholder="http://..."
  59. value="{{ form.url_down.value|default:"" }}">
  60. {% if form.url_down.errors %}
  61. <div class="help-block">
  62. {{ form.url_down.errors|join:"" }}
  63. </div>
  64. {% endif %}
  65. </div>
  66. </div>
  67. <div class="form-group {{ form.url_up.css_classes }}">
  68. <label class="col-sm-2 control-label">URL for "up" events</label>
  69. <div class="col-sm-10">
  70. <input
  71. type="text"
  72. class="form-control"
  73. name="url_up"
  74. placeholder="http://..."
  75. value="{{ form.url_up.value|default:"" }}">
  76. {% if form.url_up.errors %}
  77. <div class="help-block">
  78. {{ form.url_up.errors|join:"" }}
  79. </div>
  80. {% endif %}
  81. </div>
  82. </div>
  83. <div class="form-group {{ form.post_data.css_classes }}">
  84. <label class="col-sm-2 control-label">POST data</label>
  85. <div class="col-sm-10">
  86. <input
  87. type="text"
  88. class="form-control"
  89. name="post_data"
  90. placeholder='{"status": "$STATUS"}'
  91. value="{{ form.post_data.value|default:"" }}">
  92. {% if form.post_data.errors %}
  93. <div class="help-block">
  94. {{ form.post_data.errors|join:"" }}
  95. </div>
  96. {% endif %}
  97. </div>
  98. </div>
  99. <div class="form-group {{ form.headers.css_classes }}">
  100. <label class="col-sm-2 control-label">Request Headers</label>
  101. <div id="webhook-headers" class="col-xs-12 col-sm-10">
  102. {% for k, v in form.headers.items %}
  103. <div class="form-inline webhook-header">
  104. <input
  105. type="text"
  106. class="form-control key"
  107. name="header_key[]"
  108. placeholder="Content-Type"
  109. value="{{ k }}" />
  110. <input
  111. type="text"
  112. class="form-control value"
  113. name="header_value[]"
  114. placeholder="application/json"
  115. value="{{ v }}" />
  116. <button class="btn btn-default" type="button">
  117. <span class="icon-delete"></span>
  118. </button>
  119. </div>
  120. {% endfor %}
  121. </div>
  122. <div class="text-center">
  123. </div>
  124. </div>
  125. <div class="form-group">
  126. <div class="col-sm-offset-2 col-sm-10">
  127. <button type="submit" class="btn btn-primary">Save Integration</button>
  128. </div>
  129. </div>
  130. </form>
  131. </div>
  132. </div>
  133. <div id="header-template" class="hide">
  134. <div class="form-inline webhook-header">
  135. <input
  136. type="text"
  137. class="form-control key"
  138. name="header_key[]"
  139. placeholder="Content-Type" />
  140. <input
  141. type="text"
  142. class="form-control value"
  143. name="header_value[]"
  144. placeholder="application/json" />
  145. <button class="btn btn-default" type="button">
  146. <span class="icon-delete"></span>
  147. </button>
  148. </div>
  149. </div>
  150. {% endblock %}
  151. {% block scripts %}
  152. {% compress js %}
  153. <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
  154. <script src="{% static 'js/bootstrap.min.js' %}"></script>
  155. <script src="{% static 'js/webhook.js' %}"></script>
  156. {% endcompress %}
  157. {% endblock %}