= form_for @check, html: {class: "small-form"} do |f|
- unless @check.respond_to?(:check_type) || @check.respond_to?(:invert)
%p.text-muted Checks are designed to identify bad data. A check fails if there are any results.
- if @check.errors.any?
.alert.alert-danger= @check.errors.full_messages.first
.form-group
= f.label :query_id, "Query"
.hide
= f.select :query_id, [], {include_blank: true}
:javascript
#{blazer_js_var "queries", Blazer::Query.named.order(:name).select("id, name").map { |q| {text: q.name, value: q.id} }}
#{blazer_js_var "items", [@check.query_id].compact}
$("#check_query_id").selectize({options: queries, items: items, highlight: false, maxOptions: 100}).parents(".hide").removeClass("hide");
- if @check.respond_to?(:check_type)
.form-group
= f.label :check_type, "Alert if"
.hide
- check_options = [["Any results (bad data)", "bad_data"], ["No results (missing data)", "missing_data"]]
- check_options << ["Anomaly (most recent data point)", "anomaly"] if Blazer.anomaly_checks
= f.select :check_type, check_options
:javascript
$("#check_check_type").selectize({}).parent().removeClass("hide");
- elsif @check.respond_to?(:invert)
.form-group
= f.label :invert, "Fails if"
.hide
= f.select :invert, [["Any results (bad data)", false], ["No results (missing data)", true]]
:javascript
$("#check_invert").selectize({}).parent().removeClass("hide");
- if @check.respond_to?(:schedule) && Blazer.check_schedules
.form-group
= f.label :schedule, "Run every"
.hide
= f.select :schedule, Blazer.check_schedules.map { |v| [v, v] }
:javascript
$("#check_schedule").selectize({}).parent().removeClass("hide");
.form-group
= f.label :emails
= f.text_field :emails, placeholder: "Optional, comma separated", class: "form-control"
- if Blazer.slack?
.form-group
= f.label :slack_channels
= f.text_field :slack_channels, placeholder: "Optional, comma separated", class: "form-control"
- if slack_mentions.present?
.form-group
= f.label :slack_members
= f.collection_select :slack_members, slack_mentions, :first, :last, {}, { placeholder: "User, Users group Slack ID", class: "form-control", multiple: true }
%p.text-muted Slack members: can select or enter new user/user_group Slack ID. It also supports special mentions: channel, everyone, here.
%p.text-muted
Emails #{Blazer.slack? ? "and Slack notifications " : nil}are sent when a check starts failing, and when it starts passing again.
%p
- if @check.persisted?
= link_to "Delete", check_path(@check), method: :delete, "data-confirm" => "Are you sure?", class: "btn btn-danger"
= f.submit "Save", class: "btn btn-success"
= link_to "Back", :back, class: "btn btn-link"
:javascript
$(document).ready(function() {
$('#check_slack_members').select2({
tags: true,
});
});