_form.html.erb 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <% if @agent.errors.any? %>
  2. <div class="row well model-errors">
  3. <h2><%= pluralize(@agent.errors.count, "error") %> prohibited this Agent from being saved:</h2>
  4. <% @agent.errors.full_messages.each do |msg| %>
  5. <p class='text-warning'><%= msg %></p>
  6. <% end %>
  7. </div>
  8. <% end %>
  9. <%= form_for(@agent,
  10. :as => :agent,
  11. :url => @agent.new_record? ? agents_path : agent_path(@agent),
  12. :method => @agent.new_record? ? "POST" : "PUT") do |f| %>
  13. <div class="row">
  14. <div class="col-md-6">
  15. <div class="row">
  16. <div class="col-md-12">
  17. <% if @agent.new_record? %>
  18. <div class="form-group type-select">
  19. <%= f.label :type %>
  20. <%= f.select :type, options_for_select([['Select an Agent Type', 'Agent']] + Agent.types.map(&:to_s).sort.map {|type| [type.gsub(/^.*::/, ''), type] }, @agent.type), {}, :class => 'select2 form-control' %>
  21. </div>
  22. <% end %>
  23. </div>
  24. <div class="agent-settings">
  25. <div class="col-md-12">
  26. <div class="form-group">
  27. <%= f.label :name %>
  28. <%= f.text_field :name, :class => 'form-control' %>
  29. </div>
  30. <div class='oauthable-form'>
  31. <%= render partial: 'oauth_dropdown', locals: { agent: @agent } %>
  32. </div>
  33. <div class="form-group">
  34. <%= f.label :schedule, :class => 'control-label' %>
  35. <div class="schedule-region" data-can-be-scheduled="<%= @agent.can_be_scheduled? %>">
  36. <div class="can-be-scheduled">
  37. <%= f.select :schedule, options_for_select(Agent::SCHEDULES.map {|s| [s.humanize.titleize, s] }, @agent.schedule), {}, :class => 'form-control' %>
  38. </div>
  39. <span class='cannot-be-scheduled text-info'>This type of Agent cannot be scheduled.</span>
  40. </div>
  41. </div>
  42. <div class="controller-region" data-has-controllers="<%= !@agent.controllers.empty? %>">
  43. <div class="form-group">
  44. <%= f.label :controllers %>
  45. <span class="glyphicon glyphicon-question-sign hover-help" data-content="Other than the system-defined schedule above, this agent may be run or controlled by these user-defined Agents."></span>
  46. <div class="controller-list">
  47. <%= agent_controllers(@agent) || 'None' %>
  48. </div>
  49. </div>
  50. </div>
  51. <div class="control-link-region" data-can-control-other-agents="<%= @agent.can_control_other_agents? %>">
  52. <div class="can-control-other-agents">
  53. <div class="form-group">
  54. <%= f.label :control_targets %>
  55. <% eventControlTargets = current_user.agents.select(&:can_be_scheduled?) %>
  56. <%= f.select(:control_target_ids,
  57. options_for_select(eventControlTargets.map {|s| [s.name, s.id] },
  58. @agent.control_target_ids),
  59. {}, { multiple: true, size: 5, class: 'select2 form-control' }) %>
  60. </div>
  61. </div>
  62. </div>
  63. <div class='event-related-region' data-can-create-events="<%= @agent.can_create_events? %>">
  64. <div class="form-group">
  65. <%= f.label :keep_events_for, "Keep events" %>
  66. <span class="glyphicon glyphicon-question-sign hover-help" data-content="In order to conserve disk space, you can choose to have events created by this Agent expire after a certain period of time. Make sure you keep them long enough to allow any subsequent Agents to make use of them."></span>
  67. <%= f.select :keep_events_for, options_for_select(Agent::EVENT_RETENTION_SCHEDULES, @agent.keep_events_for), {}, :class => 'form-control' %>
  68. </div>
  69. </div>
  70. <div class="form-group">
  71. <%= f.label :sources %>
  72. <div class="link-region" data-can-receive-events="<%= @agent.can_receive_events? %>">
  73. <% eventSources = (current_user.agents - [@agent]).find_all { |a| a.can_create_events? } %>
  74. <%= f.select(:source_ids,
  75. options_for_select(eventSources.map {|s| [s.name, s.id] },
  76. @agent.source_ids),
  77. {}, { :multiple => true, :size => 5, :class => 'select2 form-control' }) %>
  78. <span class='cannot-receive-events text-info'>This type of Agent cannot receive events.</span>
  79. <%= f.label :propagate_immediately, :class => 'propagate-immediately' do %>Propagate immediately
  80. <%= f.check_box :propagate_immediately %>
  81. <% end %>
  82. </div>
  83. </div>
  84. <% if current_user.scenario_count > 0 %>
  85. <div class="form-group">
  86. <%= f.label :scenarios %>
  87. <span class="glyphicon glyphicon-question-sign hover-help" data-content="Use Scenarios to group sets of Agents, both for organization, and to make them easy to export and share."></span>
  88. <%= f.select(:scenario_ids,
  89. options_for_select(current_user.scenarios.pluck(:name, :id), @agent.scenario_ids),
  90. {}, { :multiple => true, :size => 5, :class => 'select2 form-control' }) %>
  91. </div>
  92. <% end %>
  93. </div>
  94. <div class="col-md-12 agent-options">
  95. <%= render partial: 'options', locals: { agent: @agent } %>
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. <div class="col-md-6">
  101. <div class="row">
  102. <div class="col-md-12">
  103. <div class='well description'>
  104. <%= @agent.html_description unless @agent.new_record? %>
  105. </div>
  106. </div>
  107. </div>
  108. <div class="row">
  109. <div class="col-md-12">
  110. <div class='well event-descriptions' style='display: none'></div>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. <% end %>