Skip to content

Commit

Permalink
Aggregate the actions input/output in the task JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
iNecas committed Jan 15, 2014
1 parent ab13717 commit d83690f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 36 deletions.
25 changes: 5 additions & 20 deletions app/models/dynflow_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,11 @@ def execution_plan
@execution_plan ||= Orchestrate.world.persistence.load_execution_plan(self.uuid)
end

# Searches for actions with +task_input+ method and collects the values.
# It's used for getting data input params in the action into Rest API
def inputs
actions_with_task_input = run_actions.select do |action|
action.respond_to?(:task_input)
end
actions_with_task_input.map do |action|
action.task_input.merge(action: action.action_class.name)
end
end


# Searches for actions with +task_output+ method and collects the values.
# It's used for getting data collected in the action into Rest API
def outputs
actions_with_task_output = run_actions.select do |action|
action.respond_to?(:task_output) && !action.output.empty?
end
actions_with_task_output.map do |action|
action.task_output.merge(action: action.action_class.name)
def actions
run_actions.map do |action|
{ action: action.action_class.name,
input: action.task_input,
output: action.task_output }
end
end

Expand Down
3 changes: 1 addition & 2 deletions app/views/api/v2/tasks/dynflow_task_show.json.rabl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
object @task if @task

attributes :uuid, :action, :user_id, :organization_id, :pending
attributes :inputs, :outputs
attributes :uuid, :action, :user_id, :organization_id, :pending, :actions

glue (@task || @object).execution_plan do
attributes :started_at, :ended_at, :state, :result, :progress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,19 @@ angular.module('Bastion.products').controller('DiscoveryController',

setDiscoveryDetails = function (task) {
var discoveryAction = "Orchestrate::Katello::RepositoryDiscover";
var input = Task.input(task, discoveryAction);
var action = Task.action(task, discoveryAction);

$scope.discovery.pending = task.pending;

if (!task.pending) {
$scope.discovery.working = false;
}

if(!input) {
if(!action) {
return
}
$scope.discovery.url = input.url;
$scope.discoveryTable.rows = transformRows(Task.output(task, discoveryAction));

$scope.discovery.url = action.input.url;
$scope.discoveryTable.rows = transformRows(action.output);
};

$scope.setupSelected = function () {
Expand Down
14 changes: 5 additions & 9 deletions engines/bastion/app/assets/bastion/tasks/task.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,11 @@ angular.module('Bastion.tasks').factory('Task',
}
);

resource.input = function(task, actionName) {
if(task.inputs) {
return _.find(task.inputs, function(input) { return input.action == actionName });
}
}

resource.output = function(task, actionName) {
if(task.outputs) {
return _.find(task.outputs, function(output) { return output.action == actionName });
resource.action = function(task, actionName) {
if(task.actions) {
return _.find(task.actions, function(action) {
return action.action == actionName
});
}
}

Expand Down

0 comments on commit d83690f

Please sign in to comment.