@@ -22,14 +22,13 @@ window.setupJsonEditor = ($editors = $(".live-json-editor")) ->
|
||
| 22 | 22 |
return editors |
| 23 | 23 |
|
| 24 | 24 |
hideSchedule = -> |
| 25 |
- $(".schedule-region select").hide()
|
|
| 25 |
+ $(".schedule-region .can-be-scheduled").hide()
|
|
| 26 | 26 |
$(".schedule-region .cannot-be-scheduled").show()
|
| 27 | 27 |
|
| 28 | 28 |
showSchedule = (defaultSchedule = null) -> |
| 29 |
- $(".schedule-region select").show()
|
|
| 30 | 29 |
if defaultSchedule? |
| 31 | 30 |
$(".schedule-region select").val(defaultSchedule).change()
|
| 32 |
- $(".schedule-region select").show()
|
|
| 31 |
+ $(".schedule-region .can-be-scheduled").show()
|
|
| 33 | 32 |
$(".schedule-region .cannot-be-scheduled").hide()
|
| 34 | 33 |
|
| 35 | 34 |
hideLinks = -> |
@@ -43,6 +42,16 @@ showLinks = -> |
||
| 43 | 42 |
$(".link-region .cannot-receive-events").hide()
|
| 44 | 43 |
showEventDescriptions() |
| 45 | 44 |
|
| 45 |
+hideChains = -> |
|
| 46 |
+ $(".chain-region .select2-container").hide()
|
|
| 47 |
+ $(".chain-region .propagate-immediately").hide()
|
|
| 48 |
+ $(".chain-region .cannot-receive-events").show()
|
|
| 49 |
+ |
|
| 50 |
+showChains = -> |
|
| 51 |
+ $(".chain-region .select2-container").show()
|
|
| 52 |
+ $(".chain-region .propagate-immediately").show()
|
|
| 53 |
+ $(".chain-region .cannot-receive-events").hide()
|
|
| 54 |
+ |
|
| 46 | 55 |
hideEventCreation = -> |
| 47 | 56 |
$(".event-related-region").hide()
|
| 48 | 57 |
|
@@ -161,6 +170,11 @@ $(document).ready -> |
||
| 161 | 170 |
else |
| 162 | 171 |
hideLinks() |
| 163 | 172 |
|
| 173 |
+ if json.can_run_other_agents |
|
| 174 |
+ showChains() |
|
| 175 |
+ else |
|
| 176 |
+ hideChains() |
|
| 177 |
+ |
|
| 164 | 178 |
if json.can_create_events |
| 165 | 179 |
showEventCreation() |
| 166 | 180 |
else |
@@ -191,6 +205,12 @@ $(document).ready -> |
||
| 191 | 205 |
else |
| 192 | 206 |
hideLinks() |
| 193 | 207 |
|
| 208 |
+ if $(".chain-region")
|
|
| 209 |
+ if $(".chain-region").data("can-run-other-agents") == true
|
|
| 210 |
+ showChains() |
|
| 211 |
+ else |
|
| 212 |
+ hideChains() |
|
| 213 |
+ |
|
| 194 | 214 |
if $(".event-related-region")
|
| 195 | 215 |
if $(".event-related-region").data("can-create-events") == true
|
| 196 | 216 |
showEventCreation() |
@@ -182,6 +182,10 @@ class Agent < ActiveRecord::Base |
||
| 182 | 182 |
!cannot_create_events? |
| 183 | 183 |
end |
| 184 | 184 |
|
| 185 |
+ def can_run_other_agents? |
|
| 186 |
+ self.class.can_run_other_agents? |
|
| 187 |
+ end |
|
| 188 |
+ |
|
| 185 | 189 |
def log(message, options = {})
|
| 186 | 190 |
puts "Agent##{id}: #{message}" unless Rails.env.test?
|
| 187 | 191 |
AgentLog.log_for_agent(self, message, options) |
@@ -304,6 +308,14 @@ class Agent < ActiveRecord::Base |
||
| 304 | 308 |
!!@cannot_receive_events |
| 305 | 309 |
end |
| 306 | 310 |
|
| 311 |
+ def can_run_other_agents! |
|
| 312 |
+ @can_run_other_agents = true |
|
| 313 |
+ end |
|
| 314 |
+ |
|
| 315 |
+ def can_run_other_agents? |
|
| 316 |
+ @can_run_other_agents |
|
| 317 |
+ end |
|
| 318 |
+ |
|
| 307 | 319 |
# Find all Agents that have received Events since the last execution of this method. Update those Agents with |
| 308 | 320 |
# their new `last_checked_event_id` and queue each of the Agents to be called with #receive using `async_receive`. |
| 309 | 321 |
# This is called by bin/schedule.rb periodically. |
@@ -33,11 +33,26 @@ |
||
| 33 | 33 |
<div class="form-group"> |
| 34 | 34 |
<%= f.label :schedule, :class => 'control-label' %> |
| 35 | 35 |
<div class="schedule-region" data-can-be-scheduled="<%= @agent.can_be_scheduled? %>"> |
| 36 |
- <%= f.select :schedule, options_for_select(Agent::SCHEDULES.map {|s| [s.humanize.titleize, s] }, @agent.schedule), {}, :class => 'form-control' %>
|
|
| 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> |
|
| 37 | 39 |
<span class='cannot-be-scheduled text-info'>This type of Agent cannot be scheduled.</span> |
| 38 | 40 |
</div> |
| 39 | 41 |
</div> |
| 40 | 42 |
|
| 43 |
+ <div class="chain-region" data-can-run-other-agents="<%= @agent.can_run_other_agents? %>"> |
|
| 44 |
+ <div class="can-run-other-agents"> |
|
| 45 |
+ <div class="form-group"> |
|
| 46 |
+ <%= f.label :targets %> |
|
| 47 |
+ <% eventTargets = current_user.agents.select(&:can_be_scheduled?) %> |
|
| 48 |
+ <%= f.select(:target_ids, |
|
| 49 |
+ options_for_select(eventTargets.map {|s| [s.name, s.id] },
|
|
| 50 |
+ @agent.target_ids), |
|
| 51 |
+ {}, { multiple: true, size: 5, class: 'select2 form-control' }) %>
|
|
| 52 |
+ </div> |
|
| 53 |
+ </div> |
|
| 54 |
+ </div> |
|
| 55 |
+ |
|
| 41 | 56 |
<div class='event-related-region' data-can-create-events="<%= @agent.can_create_events? %>"> |
| 42 | 57 |
<div class="form-group"> |
| 43 | 58 |
<%= f.label :keep_events_for, "Keep events" %> |
@@ -134,6 +134,17 @@ |
||
| 134 | 134 |
</p> |
| 135 | 135 |
<% end %> |
| 136 | 136 |
|
| 137 |
+ <% if @agent.can_run_other_agents? %> |
|
| 138 |
+ <p> |
|
| 139 |
+ <b>Targets:</b> |
|
| 140 |
+ <% if (agents = @agent.targets).length > 0 %> |
|
| 141 |
+ <%= agents.map { |agent| link_to(agent.name, agent_path(agent)) }.to_sentence.html_safe %>
|
|
| 142 |
+ <% else %> |
|
| 143 |
+ None |
|
| 144 |
+ <% end %> |
|
| 145 |
+ </p> |
|
| 146 |
+ <% end %> |
|
| 147 |
+ |
|
| 137 | 148 |
<p> |
| 138 | 149 |
<b>Working:</b> |
| 139 | 150 |
<%= working @agent %> |