_form.html.erb 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <% unless @check.respond_to?(:invert) %>
  2. <p class="text-muted">Checks are designed to identify bad data. A check fails if there are any results.</p>
  3. <% end %>
  4. <% if @check.errors.any? %>
  5. <div class="alert alert-danger"><%= @check.errors.full_messages.first %></div>
  6. <% end %>
  7. <%= form_for @check do |f| %>
  8. <div class="form-group">
  9. <%= f.label :query_id, "Query" %>
  10. <div class="hide">
  11. <%= f.select :query_id, [], {include_blank: true} %>
  12. </div>
  13. <script>
  14. <%= blazer_js_var "queries", Blazer::Query.named.order(:name).select("id, name").map { |q| {text: q.name, value: q.id} } %>
  15. <%= blazer_js_var "items", [@check.query_id].compact %>
  16. $("#check_query_id").selectize({options: queries, items: items, highlight: false, maxOptions: 100}).parents(".hide").removeClass("hide");
  17. </script>
  18. </div>
  19. <% if @check.respond_to?(:check_type) %>
  20. <div class="form-group">
  21. <%= f.label :check_type, "Alert if" %>
  22. <div class="hide">
  23. <% check_options = [["Any results (bad data)", "bad_data"], ["No results (missing data)", "missing_data"]] %>
  24. <% check_options << ["Anomaly (most recent data point)", "anomaly"] if Blazer.anomaly_checks %>
  25. <%= f.select :check_type, check_options %>
  26. </div>
  27. <script>
  28. $("#check_check_type").selectize({}).parent().removeClass("hide");
  29. </script>
  30. </div>
  31. <% elsif @check.respond_to?(:invert) %>
  32. <div class="form-group">
  33. <%= f.label :invert, "Fails if" %>
  34. <div class="hide">
  35. <%= f.select :invert, [["Any results (bad data)", false], ["No results (missing data)", true]] %>
  36. </div>
  37. <script>
  38. $("#check_invert").selectize({}).parent().removeClass("hide");
  39. </script>
  40. </div>
  41. <% end %>
  42. <% if @check.respond_to?(:schedule) && Blazer.check_schedules %>
  43. <div class="form-group">
  44. <%= f.label :schedule, "Run every" %>
  45. <div class="hide">
  46. <%= f.select :schedule, Blazer.check_schedules.map { |v| [v, v] } %>
  47. </div>
  48. <script>
  49. $("#check_schedule").selectize({}).parent().removeClass("hide");
  50. </script>
  51. </div>
  52. <% end %>
  53. <div class="form-group">
  54. <%= f.label :emails %>
  55. <%= f.text_field :emails, placeholder: "Optional, comma separated", class: "form-control" %>
  56. </div>
  57. <p class="text-muted">Emails are sent when a check starts failing, and when it starts passing again.
  58. <p>
  59. <% if @check.persisted? %>
  60. <%= link_to "Delete", check_path(@check), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger" %>
  61. <% end %>
  62. <%= f.submit "Save", class: "btn btn-success" %>
  63. <%= link_to "Back", :back, class: "btn btn-link" %>
  64. </p>
  65. <% end %>