1
0

_form.html.erb 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <% load_ace_editor! %>
  2. <% if @agent.errors.any? %>
  3. <div class="row well model-errors">
  4. <h2><%= pluralize(@agent.errors.count, "error") %> prohibited this Agent from being saved:</h2>
  5. <% @agent.errors.full_messages.each do |msg| %>
  6. <p class='text-warning'><%= msg %></p>
  7. <% end %>
  8. </div>
  9. <% end %>
  10. <%= form_for(@agent,
  11. as: :agent,
  12. url: @agent.new_record? ? agents_path : agent_path(@agent),
  13. method: @agent.new_record? ? "POST" : "PUT",
  14. html: { class: 'agent-form' }) do |f| %>
  15. <%= hidden_field_tag :return, params[:return] %>
  16. <div class="row">
  17. <div class="col-md-6">
  18. <div class="row">
  19. <div class="col-md-12">
  20. <% if @agent.new_record? %>
  21. <div class="form-group type-select">
  22. <%= f.label :type %>
  23. <%= f.select :type, options_for_select(agent_type_select_options, @agent.type), {}, class: 'form-control', autofocus: true %>
  24. </div>
  25. <% end %>
  26. </div>
  27. <div class="agent-settings">
  28. <div class="col-md-12">
  29. <div class="form-group">
  30. <%= f.label :name %>
  31. <%= f.text_field :name, :class => 'form-control' %>
  32. </div>
  33. <div class='oauthable-form'>
  34. <%= render partial: 'oauth_dropdown', locals: { agent: @agent } %>
  35. </div>
  36. <div class="form-group">
  37. <%= f.label :schedule, :class => 'control-label' %>
  38. <div class="schedule-region" data-can-be-scheduled="<%= @agent.can_be_scheduled? %>">
  39. <div class="can-be-scheduled">
  40. <%= f.select :schedule, options_for_select(Agent::SCHEDULES.map {|s| [builtin_schedule_name(s), s] }, @agent.schedule), {}, :class => 'form-control' %>
  41. </div>
  42. <span class='cannot-be-scheduled text-info'>This type of Agent cannot be scheduled.</span>
  43. </div>
  44. </div>
  45. <div class="controller-region">
  46. <div class="form-group">
  47. <%= f.label :controllers %>
  48. <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>
  49. <%= f.select(:controller_ids,
  50. options_for_select(current_user.agents.select(&:can_control_other_agents?).pluck(:name, :id),
  51. @agent.controller_ids),
  52. {}, { multiple: true, size: 5, class: 'select2-linked-tags form-control', data: {url_prefix: '/agents'}}) %>
  53. </div>
  54. </div>
  55. <div class="control-link-region" data-can-control-other-agents="<%= @agent.can_control_other_agents? %>">
  56. <div class="can-control-other-agents">
  57. <div class="form-group">
  58. <%= f.label :control_targets %>
  59. <%= f.select(:control_target_ids,
  60. options_for_select(current_user.agents.map {|s| [s.name, s.id] },
  61. @agent.control_target_ids),
  62. {}, { multiple: true, size: 5, class: 'select2-linked-tags form-control', data: {url_prefix: '/agents'}}) %>
  63. </div>
  64. </div>
  65. </div>
  66. <div class='event-related-region' data-can-create-events="<%= @agent.can_create_events? %>">
  67. <div class="form-group">
  68. <%= f.label :keep_events_for, "Keep events" %>
  69. <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>
  70. <%= f.select :keep_events_for, options_for_select(Agent::EVENT_RETENTION_SCHEDULES, @agent.keep_events_for), {}, :class => 'form-control' %>
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. <%= f.label :sources %>
  75. <span class="glyphicon glyphicon-question-sign hover-help" data-content="This Agent will receive events from the selected Agents."></span>
  76. <div class="link-region" data-can-receive-events="<%= @agent.can_receive_events? %>">
  77. <% eventSources = (current_user.agents - [@agent]).find_all { |a| a.can_create_events? } %>
  78. <%= f.select(:source_ids,
  79. options_for_select(eventSources.map {|s| [s.name, s.id] },
  80. @agent.source_ids),
  81. {}, { :multiple => true, :size => 5, :class => 'select2-linked-tags form-control', data: {url_prefix: '/agents'} }) %>
  82. <span class='cannot-receive-events text-info'>This type of Agent cannot receive events.</span>
  83. <%= f.label :propagate_immediately, :class => 'propagate-immediately' do %>Propagate immediately
  84. <%= f.check_box :propagate_immediately %>
  85. &nbsp;
  86. <span class="glyphicon glyphicon-question-sign hover-help" data-content="Normally, Huginn moves Events from source Agents to receiving Agents once per minute. Checking this option will cause Events created by this Agent's sources to be received immediately. This can use more CPU resources, but will decrease the time between Event creation and being received by this Agent."></span>
  87. <% end %>
  88. </div>
  89. </div>
  90. <div class="form-group">
  91. <%= f.label :receivers %>
  92. <span class="glyphicon glyphicon-question-sign hover-help" data-content="Events created by this Agent will be sent to the selected Agents."></span>
  93. <div class="event-related-region">
  94. <% eventTargets = (current_user.agents - [@agent]).find_all { |a| a.can_receive_events? } %>
  95. <%= f.select(:receiver_ids,
  96. options_for_select(eventTargets.pluck(:name, :id),
  97. @agent.receiver_ids),
  98. {}, { :multiple => true, :size => 5, :class => 'select2-linked-tags form-control', data: {url_prefix: '/agents'} }) %>
  99. <span class='cannot-create-events text-info'>This type of Agent cannot create events.</span>
  100. </div>
  101. </div>
  102. <% if current_user.scenario_count > 0 %>
  103. <div class="form-group">
  104. <%= f.label :scenarios %>
  105. <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>
  106. <%= f.select(:scenario_ids,
  107. options_for_select(current_user.scenarios.pluck(:name, :id), @agent.scenario_ids),
  108. {}, { :multiple => true, :size => 5, :class => 'select2-linked-tags form-control', data: {url_prefix: '/scenarios'} }) %>
  109. </div>
  110. <% end %>
  111. </div>
  112. <div class="col-md-12 agent-options">
  113. <%= render partial: 'options', locals: { agent: @agent } %>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. <div class="col-md-6">
  119. <div class="row">
  120. <div class="col-md-12">
  121. <div class='well description'>
  122. <%= @agent.html_description unless @agent.new_record? %>
  123. </div>
  124. </div>
  125. </div>
  126. <div class="row">
  127. <div class="col-md-12">
  128. <div class='well event-descriptions' style='display: none'></div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <% end %>