Merge branch 'release_3.3.0' into prompt-cleanup-v2

This commit is contained in:
Michael Abashian
2018-03-28 13:07:10 -04:00
committed by GitHub
12 changed files with 262 additions and 174 deletions

View File

@@ -87,7 +87,11 @@ class InstanceManager(models.Manager):
return node[0] return node[0]
raise RuntimeError("No instance found with the current cluster host id") raise RuntimeError("No instance found with the current cluster host id")
def register(self, uuid=settings.SYSTEM_UUID, hostname=settings.CLUSTER_HOST_ID): def register(self, uuid=None, hostname=None):
if not uuid:
uuid = settings.SYSTEM_UUID
if not hostname:
hostname = settings.CLUSTER_HOST_ID
with advisory_lock('instance_registration_%s' % hostname): with advisory_lock('instance_registration_%s' % hostname):
instance = self.filter(hostname=hostname) instance = self.filter(hostname=hostname)
if instance.exists(): if instance.exists():

View File

@@ -55,7 +55,7 @@ from awx.main.queue import CallbackQueueDispatcher
from awx.main.expect import run, isolated_manager from awx.main.expect import run, isolated_manager
from awx.main.utils import (get_ansible_version, get_ssh_version, decrypt_field, update_scm_url, from awx.main.utils import (get_ansible_version, get_ssh_version, decrypt_field, update_scm_url,
check_proot_installed, build_proot_temp_dir, get_licenser, check_proot_installed, build_proot_temp_dir, get_licenser,
wrap_args_with_proot, OutputEventFilter, ignore_inventory_computed_fields, wrap_args_with_proot, OutputEventFilter, OutputVerboseFilter, ignore_inventory_computed_fields,
ignore_inventory_group_removal, get_type_for_model, extract_ansible_vars) ignore_inventory_group_removal, get_type_for_model, extract_ansible_vars)
from awx.main.utils.reload import restart_local_services, stop_local_services from awx.main.utils.reload import restart_local_services, stop_local_services
from awx.main.utils.pglock import advisory_lock from awx.main.utils.pglock import advisory_lock
@@ -821,19 +821,26 @@ class BaseTask(LogErrorsTask):
def get_stdout_handle(self, instance): def get_stdout_handle(self, instance):
''' '''
Return an virtual file object for capturing stdout and events. Return an virtual file object for capturing stdout and/or events.
''' '''
dispatcher = CallbackQueueDispatcher() dispatcher = CallbackQueueDispatcher()
def event_callback(event_data): if isinstance(instance, (Job, AdHocCommand, ProjectUpdate)):
event_data.setdefault(self.event_data_key, instance.id) def event_callback(event_data):
if 'uuid' in event_data: event_data.setdefault(self.event_data_key, instance.id)
cache_event = cache.get('ev-{}'.format(event_data['uuid']), None) if 'uuid' in event_data:
if cache_event is not None: cache_event = cache.get('ev-{}'.format(event_data['uuid']), None)
event_data.update(cache_event) if cache_event is not None:
dispatcher.dispatch(event_data) event_data.update(cache_event)
dispatcher.dispatch(event_data)
return OutputEventFilter(event_callback) return OutputEventFilter(event_callback)
else:
def event_callback(event_data):
event_data.setdefault(self.event_data_key, instance.id)
dispatcher.dispatch(event_data)
return OutputVerboseFilter(event_callback)
def pre_run_hook(self, instance, **kwargs): def pre_run_hook(self, instance, **kwargs):
''' '''

View File

@@ -5,7 +5,7 @@ from StringIO import StringIO
from six.moves import xrange from six.moves import xrange
from awx.main.utils import OutputEventFilter from awx.main.utils import OutputEventFilter, OutputVerboseFilter
MAX_WIDTH = 78 MAX_WIDTH = 78
EXAMPLE_UUID = '890773f5-fe6d-4091-8faf-bdc8021d65dd' EXAMPLE_UUID = '890773f5-fe6d-4091-8faf-bdc8021d65dd'
@@ -145,3 +145,55 @@ def test_large_stdout_blob():
f = OutputEventFilter(_callback) f = OutputEventFilter(_callback)
for x in range(1024 * 10): for x in range(1024 * 10):
f.write('x' * 1024) f.write('x' * 1024)
def test_verbose_line_buffering():
events = []
def _callback(event_data):
events.append(event_data)
f = OutputVerboseFilter(_callback)
f.write('one two\r\n\r\n')
assert len(events) == 2
assert events[0]['start_line'] == 0
assert events[0]['end_line'] == 1
assert events[0]['stdout'] == 'one two'
assert events[1]['start_line'] == 1
assert events[1]['end_line'] == 2
assert events[1]['stdout'] == ''
f.write('three')
assert len(events) == 2
f.write('\r\nfou')
# three is not pushed to buffer until its line completes
assert len(events) == 3
assert events[2]['start_line'] == 2
assert events[2]['end_line'] == 3
assert events[2]['stdout'] == 'three'
f.write('r\r')
f.write('\nfi')
assert events[3]['start_line'] == 3
assert events[3]['end_line'] == 4
assert events[3]['stdout'] == 'four'
f.write('ve')
f.write('\r\n')
assert len(events) == 5
assert events[4]['start_line'] == 4
assert events[4]['end_line'] == 5
assert events[4]['stdout'] == 'five'
f.close()
from pprint import pprint
pprint(events)
assert len(events) == 6
assert events[5]['event'] == 'EOF'

View File

@@ -48,7 +48,7 @@ __all__ = ['get_object_or_400', 'get_object_or_403', 'camelcase_to_underscore',
'copy_m2m_relationships', 'prefetch_page_capabilities', 'to_python_boolean', 'copy_m2m_relationships', 'prefetch_page_capabilities', 'to_python_boolean',
'ignore_inventory_computed_fields', 'ignore_inventory_group_removal', 'ignore_inventory_computed_fields', 'ignore_inventory_group_removal',
'_inventory_updates', 'get_pk_from_dict', 'getattrd', 'NoDefaultProvided', '_inventory_updates', 'get_pk_from_dict', 'getattrd', 'NoDefaultProvided',
'get_current_apps', 'set_current_apps', 'OutputEventFilter', 'get_current_apps', 'set_current_apps', 'OutputEventFilter', 'OutputVerboseFilter',
'extract_ansible_vars', 'get_search_fields', 'get_system_task_capacity', 'get_cpu_capacity', 'get_mem_capacity', 'extract_ansible_vars', 'get_search_fields', 'get_system_task_capacity', 'get_cpu_capacity', 'get_mem_capacity',
'wrap_args_with_proot', 'build_proot_temp_dir', 'check_proot_installed', 'model_to_dict', 'wrap_args_with_proot', 'build_proot_temp_dir', 'check_proot_installed', 'model_to_dict',
'model_instance_diff', 'timestamp_apiformat', 'parse_yaml_or_json', 'RequireDebugTrueOrTest', 'model_instance_diff', 'timestamp_apiformat', 'parse_yaml_or_json', 'RequireDebugTrueOrTest',
@@ -1009,6 +1009,32 @@ class OutputEventFilter(object):
self._current_event_data = None self._current_event_data = None
class OutputVerboseFilter(OutputEventFilter):
'''
File-like object that dispatches stdout data.
Does not search for encoded job event data.
Use for unified job types that do not encode job event data.
'''
def write(self, data):
self._buffer.write(data)
# if the current chunk contains a line break
if data and '\n' in data:
# emit events for all complete lines we know about
lines = self._buffer.getvalue().splitlines(True) # keep ends
remainder = None
# if last line is not a complete line, then exclude it
if '\n' not in lines[-1]:
remainder = lines.pop()
# emit all complete lines
for line in lines:
self._emit_event(line)
self._buffer = StringIO()
# put final partial line back on buffer
if remainder:
self._buffer.write(remainder)
def is_ansible_variable(key): def is_ansible_variable(key):
return key.startswith('ansible_') return key.startswith('ansible_')

View File

@@ -301,8 +301,8 @@ def _register_ldap(append=None):
register( register(
'AUTH_LDAP{}_GROUP_TYPE_PARAMS'.format(append_str), 'AUTH_LDAP{}_GROUP_TYPE_PARAMS'.format(append_str),
field_class=fields.LDAPGroupTypeParamsField, field_class=fields.LDAPGroupTypeParamsField,
label=_('LDAP Group Type'), label=_('LDAP Group Type Parameters'),
help_text=_('Parameters to send the chosen group type.'), help_text=_('Key value parameters to send the chosen group type init method.'),
category=_('LDAP'), category=_('LDAP'),
category_slug='ldap', category_slug='ldap',
default=collections.OrderedDict([ default=collections.OrderedDict([

View File

@@ -113,7 +113,7 @@ export default ['i18n', function(i18n) {
"class": 'btn-danger btn-xs', "class": 'btn-danger btn-xs',
awToolTip: i18n._('Copy inventory'), awToolTip: i18n._('Copy inventory'),
dataPlacement: 'top', dataPlacement: 'top',
ngShow: 'inventory.summary_fields.user_capabilities.edit' ngShow: '!inventory.pending_deletion && inventory.summary_fields.user_capabilities.edit'
}, },
view: { view: {
label: i18n._('View'), label: i18n._('View'),

View File

@@ -52,7 +52,8 @@ export default ['NotificationsList', 'i18n',
dataTitle: i18n._('Ansible Environment'), dataTitle: i18n._('Ansible Environment'),
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'right', dataPlacement: 'right',
ngDisabled: '!(organization_obj.summary_fields.user_capabilities.edit || canAdd)' ngDisabled: '!(organization_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_options.length > 0'
} }
}, },

View File

@@ -52,17 +52,6 @@ export default ['i18n', 'NotificationsList', 'TemplateList',
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd) || !canEditOrg', ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd) || !canEditOrg',
awLookupWhen: '(project_obj.summary_fields.user_capabilities.edit || canAdd) && canEditOrg' awLookupWhen: '(project_obj.summary_fields.user_capabilities.edit || canAdd) && canEditOrg'
}, },
custom_virtualenv: {
label: i18n._('Ansible Environment'),
type: 'select',
defaultText: i18n._('Select Ansible Environment'),
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this project to run on.") + "</p>",
dataTitle: i18n._('Ansible Environment'),
dataContainer: 'body',
dataPlacement: 'right',
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)'
},
scm_type: { scm_type: {
label: i18n._('SCM Type'), label: i18n._('SCM Type'),
type: 'select', type: 'select',
@@ -211,8 +200,21 @@ export default ['i18n', 'NotificationsList', 'TemplateList',
dataTitle: i18n._('Cache Timeout'), dataTitle: i18n._('Cache Timeout'),
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: "body", dataContainer: "body",
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)' ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
} subForm: 'sourceSubForm'
},
custom_virtualenv: {
label: i18n._('Ansible Environment'),
type: 'select',
defaultText: i18n._('Select Ansible Environment'),
ngOptions: 'venv for venv in custom_virtualenvs_options track by venv',
awPopOver: "<p>" + i18n._("Select the custom Python virtual environment for this project to run on.") + "</p>",
dataTitle: i18n._('Ansible Environment'),
dataContainer: 'body',
dataPlacement: 'right',
ngDisabled: '!(project_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_options.length > 0'
},
}, },
buttons: { buttons: {

View File

@@ -395,61 +395,66 @@ export default ['$compile', 'Attr', 'Icon',
} }
if (field_action === 'pending_deletion') { if (field_action === 'pending_deletion') {
innerTable += `<a ng-if='${list.iterator}.pending_deletion'>Pending Delete</a>`; innerTable += `<a ng-if='${list.iterator}.pending_deletion'>Pending Delete</a>`;
} } else if (field_action === 'submit') {
// Plug in Dropdown Component
if (field_action === 'submit') {
innerTable += `<at-launch-template template="${list.iterator}" ng-if="${list.iterator}.summary_fields.user_capabilities.start"></at-launch-template>`; innerTable += `<at-launch-template template="${list.iterator}" ng-if="${list.iterator}.summary_fields.user_capabilities.start"></at-launch-template>`;
} else { } else {
fAction = list.fieldActions[field_action]; // Plug in Dropdown Component
innerTable += "<button id=\""; if (field_action === 'submit' && list.fieldActions[field_action].relaunch === true) {
innerTable += (fAction.id) ? fAction.id : field_action + "-action"; innerTable += `<at-relaunch job="${list.iterator}"></at-relaunch>`;
innerTable += "\" "; } else if (field_action === 'submit' && list.fieldActions[field_action].launch === true) {
innerTable += (fAction.href) ? "href=\"" + fAction.href + "\" " : ""; innerTable += `<at-launch-template template="${list.iterator}" ng-if="${list.iterator}.summary_fields.user_capabilities.start"></at-launch-template>`;
innerTable += (fAction.ngHref) ? "ng-href=\"" + fAction.ngHref + "\" " : "";
innerTable += "class=\"List-actionButton ";
innerTable += (field_action === 'delete' || field_action === 'cancel') ? "List-actionButton--delete" : "";
innerTable += "\" ";
if(field_action === 'edit') {
// editStateParams allows us to handle cases where a list might have different types of resources in it. As a result the edit
// icon might now always point to the same state and differing states may have differing stateParams. Specifically this occurs
// on the Templates list where editing a workflow job template takes you to a state where the param is workflow_job_template_id.
// You can also edit a Job Template from this list so the stateParam there would be job_template_id.
if(list.fieldActions[field_action].editStateParams) {
let matchingConditions = handleEditStateParams(list.fieldActions[field_action].editStateParams);
innerTable += `ng-class="{'List-editButton--selected' : ${matchingConditions.join(' || ')}}"`;
}
else if (list.iterator === 'inventory') {
innerTable += `ng-class="{'List-editButton--selected': ($stateParams['${list.iterator}_id'] == ${list.iterator}.id) || ($stateParams['smartinventory_id'] == ${list.iterator}.id)}"`;
}
else if (list.iterator === 'host') {
innerTable += `ng-class="{'List-editButton--selected': $stateParams['${list.iterator}_id'] == ${list.iterator}.id && $state.is('inventories.edit.hosts.edit') }"`;
}
else {
innerTable += `ng-class="{'List-editButton--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}"`;
}
}
innerTable += (fAction.ngDisabled) ? "ng-disabled=\"" + fAction.ngDisabled + "\"" : "";
innerTable += (fAction.awPopOver) ? "aw-pop-over=\"" + fAction.awPopOver + "\" " : "";
innerTable += (fAction.dataPlacement) ? Attr(fAction, 'dataPlacement') : "";
innerTable += (fAction.dataTitle) ? Attr(fAction, 'dataTitle') : "";
for (itm in fAction) {
if (itm !== 'ngHref' && itm !== 'href' && itm !== 'label' && itm !== 'icon' && itm !== 'class' &&
itm !== 'iconClass' && itm !== "dataPlacement" && itm !== "awPopOver" &&
itm !== "dataTitle") {
innerTable += Attr(fAction, itm);
}
}
innerTable += ">";
if (fAction.iconClass) {
innerTable += "<i class=\"" + fAction.iconClass + "\"></i>";
} else { } else {
innerTable += SelectIcon({ fAction = list.fieldActions[field_action];
action: field_action innerTable += "<button id=\"";
}); innerTable += (fAction.id) ? fAction.id : field_action + "-action";
innerTable += "\" ";
innerTable += (fAction.href) ? "href=\"" + fAction.href + "\" " : "";
innerTable += (fAction.ngHref) ? "ng-href=\"" + fAction.ngHref + "\" " : "";
innerTable += "class=\"List-actionButton ";
innerTable += (field_action === 'delete' || field_action === 'cancel') ? "List-actionButton--delete" : "";
innerTable += "\" ";
if(field_action === 'edit') {
// editStateParams allows us to handle cases where a list might have different types of resources in it. As a result the edit
// icon might now always point to the same state and differing states may have differing stateParams. Specifically this occurs
// on the Templates list where editing a workflow job template takes you to a state where the param is workflow_job_template_id.
// You can also edit a Job Template from this list so the stateParam there would be job_template_id.
if(list.fieldActions[field_action].editStateParams) {
let matchingConditions = handleEditStateParams(list.fieldActions[field_action].editStateParams);
innerTable += `ng-class="{'List-editButton--selected' : ${matchingConditions.join(' || ')}}"`;
}
else if (list.iterator === 'inventory') {
innerTable += `ng-class="{'List-editButton--selected': ($stateParams['${list.iterator}_id'] == ${list.iterator}.id) || ($stateParams['smartinventory_id'] == ${list.iterator}.id)}"`;
}
else if (list.iterator === 'host') {
innerTable += `ng-class="{'List-editButton--selected': $stateParams['${list.iterator}_id'] == ${list.iterator}.id && $state.is('inventories.edit.hosts.edit') }"`;
}
else {
innerTable += `ng-class="{'List-editButton--selected' : $stateParams['${list.iterator}_id'] == ${list.iterator}.id}"`;
}
}
innerTable += (fAction.ngDisabled) ? "ng-disabled=\"" + fAction.ngDisabled + "\"" : "";
innerTable += (fAction.awPopOver) ? "aw-pop-over=\"" + fAction.awPopOver + "\" " : "";
innerTable += (fAction.dataPlacement) ? Attr(fAction, 'dataPlacement') : "";
innerTable += (fAction.dataTitle) ? Attr(fAction, 'dataTitle') : "";
for (itm in fAction) {
if (itm !== 'ngHref' && itm !== 'href' && itm !== 'label' && itm !== 'icon' && itm !== 'class' &&
itm !== 'iconClass' && itm !== "dataPlacement" && itm !== "awPopOver" &&
itm !== "dataTitle") {
innerTable += Attr(fAction, itm);
}
}
innerTable += ">";
if (fAction.iconClass) {
innerTable += "<i class=\"" + fAction.iconClass + "\"></i>";
} else {
innerTable += SelectIcon({
action: field_action
});
}
//html += (fAction.label) ? "<span class=\"list-action-label\"> " + list.fieldActions[field_action].label +
// "</span>" : "";
innerTable += "</button>";
} }
//html += (fAction.label) ? "<span class=\"list-action-label\"> " + list.fieldActions[field_action].label +
// "</span>" : "";
innerTable += "</button>";
} }
} }
} }

View File

@@ -1,15 +1,17 @@
.at-Upgrade--panel { .at-Upgrade--panel {
align-items: center; align-items: center;
background-color: @at-color-body-background-light; background-color: @at-color-body-background-light;
border-radius: 10px;
color: @at-color-body-text; color: @at-color-body-text;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: @at-font-size-jumbotron-text; font-size: @at-font-size-jumbotron-text;
height: ~"calc(100vh - 40px)";
justify-content: center; justify-content: center;
margin-top: @at-space-10x; margin: @at-space-4x;
padding: @at-space-10x; padding: @at-space-10x;
} }
.at-Upgrade--header { .at-Upgrade--header {
display: flex; display: flex;

View File

@@ -240,7 +240,8 @@ function(NotificationsList, i18n) {
dataTitle: i18n._('Ansible Environment'), dataTitle: i18n._('Ansible Environment'),
dataContainer: 'body', dataContainer: 'body',
dataPlacement: 'right', dataPlacement: 'right',
ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAdd)' ngDisabled: '!(job_template_obj.summary_fields.user_capabilities.edit || canAdd)',
ngShow: 'custom_virtualenvs_options.length > 0'
}, },
instance_groups: { instance_groups: {
label: i18n._('Instance Groups'), label: i18n._('Instance Groups'),

View File

@@ -74,12 +74,13 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
let buildSendableNodeData = function() { let buildSendableNodeData = function() {
// Create the node // Create the node
let sendableNodeData = { let sendableNodeData = {
unified_job_template: params.node.unifiedJobTemplate.id unified_job_template: params.node.unifiedJobTemplate.id,
credential: _.get(params, 'node.originalNodeObj.credential') || null
}; };
if(_.has(params, 'node.promptData.extraVars')) { if (_.has(params, 'node.promptData.extraVars')) {
if(_.get(params, 'node.promptData.launchConf.defaults.extra_vars')) { if (_.get(params, 'node.promptData.launchConf.defaults.extra_vars')) {
if(!sendableNodeData.extra_data) { if (!sendableNodeData.extra_data) {
sendableNodeData.extra_data = {}; sendableNodeData.extra_data = {};
} }
@@ -87,15 +88,15 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// Only include extra vars that differ from the template default vars // Only include extra vars that differ from the template default vars
_.forOwn(params.node.promptData.extraVars, (value, key) => { _.forOwn(params.node.promptData.extraVars, (value, key) => {
if(!defaultVars[key] || defaultVars[key] !== value) { if (!defaultVars[key] || defaultVars[key] !== value) {
sendableNodeData.extra_data[key] = value; sendableNodeData.extra_data[key] = value;
} }
}); });
if(_.isEmpty(sendableNodeData.extra_data)) { if (_.isEmpty(sendableNodeData.extra_data)) {
delete sendableNodeData.extra_data; delete sendableNodeData.extra_data;
} }
} else { } else {
if(_.has(params, 'node.promptData.extraVars') && !_.isEmpty(params.node.promptData.extraVars)) { if (_.has(params, 'node.promptData.extraVars') && !_.isEmpty(params.node.promptData.extraVars)) {
sendableNodeData.extra_data = params.node.promptData.extraVars; sendableNodeData.extra_data = params.node.promptData.extraVars;
} }
} }
@@ -104,7 +105,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// Check to see if the user has provided any prompt values that are different // Check to see if the user has provided any prompt values that are different
// from the defaults in the job template // from the defaults in the job template
if(params.node.unifiedJobTemplate.type === "job_template" && params.node.promptData) { if (params.node.unifiedJobTemplate.type === "job_template" && params.node.promptData) {
sendableNodeData = PromptService.bundlePromptDataForSaving({ sendableNodeData = PromptService.bundlePromptDataForSaving({
promptData: params.node.promptData, promptData: params.node.promptData,
dataToSave: sendableNodeData dataToSave: sendableNodeData
@@ -117,26 +118,23 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
let continueRecursing = function(parentId) { let continueRecursing = function(parentId) {
$scope.totalIteratedNodes++; $scope.totalIteratedNodes++;
if($scope.totalIteratedNodes === $scope.treeData.data.totalNodes) { if ($scope.totalIteratedNodes === $scope.treeData.data.totalNodes) {
// We're done recursing, lets move on // We're done recursing, lets move on
completionCallback(); completionCallback();
} } else {
else { if (params.node.children && params.node.children.length > 0) {
if(params.node.children && params.node.children.length > 0) {
_.forEach(params.node.children, function(child) { _.forEach(params.node.children, function(child) {
if(child.edgeType === "success") { if (child.edgeType === "success") {
recursiveNodeUpdates({ recursiveNodeUpdates({
parentId: parentId, parentId: parentId,
node: child node: child
}, completionCallback); }, completionCallback);
} } else if (child.edgeType === "failure") {
else if(child.edgeType === "failure") {
recursiveNodeUpdates({ recursiveNodeUpdates({
parentId: parentId, parentId: parentId,
node: child node: child
}, completionCallback); }, completionCallback);
} } else if (child.edgeType === "always") {
else if(child.edgeType === "always") {
recursiveNodeUpdates({ recursiveNodeUpdates({
parentId: parentId, parentId: parentId,
node: child node: child
@@ -147,7 +145,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} }
}; };
if(params.node.isNew) { if (params.node.isNew) {
TemplatesService.addWorkflowNode({ TemplatesService.addWorkflowNode({
url: $scope.treeData.workflow_job_template_obj.related.workflow_nodes, url: $scope.treeData.workflow_job_template_obj.related.workflow_nodes,
@@ -155,7 +153,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}) })
.then(function(data) { .then(function(data) {
if(!params.node.isRoot) { if (!params.node.isRoot) {
associateRequests.push({ associateRequests.push({
parentId: params.parentId, parentId: params.parentId,
nodeId: data.data.id, nodeId: data.data.id,
@@ -163,7 +161,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
} }
if(_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')){ if (_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')){
// This finds the credentials that were selected in the prompt but don't occur // This finds the credentials that were selected in the prompt but don't occur
// in the template defaults // in the template defaults
let credentialsToPost = params.node.promptData.prompts.credentials.value.filter(function(credFromPrompt) { let credentialsToPost = params.node.promptData.prompts.credentials.value.filter(function(credFromPrompt) {
@@ -193,18 +191,17 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
error.status error.status
}); });
}); });
} } else {
else { if (params.node.edited || !params.node.originalParentId || (params.node.originalParentId && params.parentId !== params.node.originalParentId)) {
if(params.node.edited || !params.node.originalParentId || (params.node.originalParentId && params.parentId !== params.node.originalParentId)) {
if(params.node.edited) { if (params.node.edited) {
editRequests.push({ editRequests.push({
id: params.node.nodeId, id: params.node.nodeId,
data: buildSendableNodeData() data: buildSendableNodeData()
}); });
if(_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')){ if (_.get(params, 'node.promptData.launchConf.ask_credential_on_launch')){
let credentialsNotInPriorCredentials = params.node.promptData.prompts.credentials.value.filter(function(credFromPrompt) { let credentialsNotInPriorCredentials = params.node.promptData.prompts.credentials.value.filter(function(credFromPrompt) {
let defaultCreds = params.node.promptData.launchConf.defaults.credentials ? params.node.promptData.launchConf.defaults.credentials : []; let defaultCreds = params.node.promptData.launchConf.defaults.credentials ? params.node.promptData.launchConf.defaults.credentials : [];
return !defaultCreds.some(function(defaultCred) { return !defaultCreds.some(function(defaultCred) {
@@ -243,20 +240,19 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
}); });
} }
} }
if((params.node.originalParentId && params.parentId !== params.node.originalParentId) || params.node.originalEdge !== params.node.edgeType) {//beep if ((params.node.originalParentId && params.parentId !== params.node.originalParentId) || params.node.originalEdge !== params.node.edgeType) {//beep
let parentIsDeleted = false; let parentIsDeleted = false;
_.forEach($scope.treeData.data.deletedNodes, function(deletedNode) { _.forEach($scope.treeData.data.deletedNodes, function(deletedNode) {
if(deletedNode === params.node.originalParentId) { if (deletedNode === params.node.originalParentId) {
parentIsDeleted = true; parentIsDeleted = true;
} }
}); });
if(!parentIsDeleted) { if (!parentIsDeleted) {
disassociateRequests.push({ disassociateRequests.push({
parentId: params.node.originalParentId, parentId: params.node.originalParentId,
nodeId: params.node.nodeId, nodeId: params.node.nodeId,
@@ -267,7 +263,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// Can only associate if we have a parent. // Can only associate if we have a parent.
// If we don't have a parent then this is a root node // If we don't have a parent then this is a root node
// and the act of disassociating will make it a root node // and the act of disassociating will make it a root node
if(params.parentId) { if (params.parentId) {
associateRequests.push({ associateRequests.push({
parentId: params.parentId, parentId: params.parentId,
nodeId: params.node.nodeId, nodeId: params.node.nodeId,
@@ -275,8 +271,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
} }
} } else if (!params.node.originalParentId && params.parentId) {
else if(!params.node.originalParentId && params.parentId) {
// This used to be a root node but is now not a root node // This used to be a root node but is now not a root node
associateRequests.push({ associateRequests.push({
parentId: params.parentId, parentId: params.parentId,
@@ -293,7 +288,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
let updateEdgeDropdownOptions = (optionsToInclude) => { let updateEdgeDropdownOptions = (optionsToInclude) => {
// Not passing optionsToInclude will include all by default // Not passing optionsToInclude will include all by default
if(!optionsToInclude) { if (!optionsToInclude) {
$scope.edgeTypeOptions = [ $scope.edgeTypeOptions = [
{ {
label: 'Always', label: 'Always',
@@ -312,17 +307,17 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.edgeTypeOptions = []; $scope.edgeTypeOptions = [];
optionsToInclude.forEach((optionToInclude) => { optionsToInclude.forEach((optionToInclude) => {
if(optionToInclude === "always") { if (optionToInclude === "always") {
$scope.edgeTypeOptions.push({ $scope.edgeTypeOptions.push({
label: 'Always', label: 'Always',
value: 'always' value: 'always'
}); });
} else if(optionToInclude === "success") { } else if (optionToInclude === "success") {
$scope.edgeTypeOptions.push({ $scope.edgeTypeOptions.push({
label: 'On Success', label: 'On Success',
value: 'success' value: 'success'
}); });
} else if(optionToInclude === "failure") { } else if (optionToInclude === "failure") {
$scope.edgeTypeOptions.push({ $scope.edgeTypeOptions.push({
label: 'On Failure', label: 'On Failure',
value: 'failure' value: 'failure'
@@ -346,9 +341,9 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
promptWatcher = $scope.$watchGroup(promptDataToWatch, function() { promptWatcher = $scope.$watchGroup(promptDataToWatch, function() {
let missingPromptValue = false; let missingPromptValue = false;
if($scope.missingSurveyValue) { if ($scope.missingSurveyValue) {
missingPromptValue = true; missingPromptValue = true;
} else if(!$scope.promptData.prompts.inventory.value || !$scope.promptData.prompts.inventory.value.id) { } else if (!$scope.promptData.prompts.inventory.value || !$scope.promptData.prompts.inventory.value.id) {
missingPromptValue = true; missingPromptValue = true;
} }
$scope.promptModalMissingReqFields = missingPromptValue; $scope.promptModalMissingReqFields = missingPromptValue;
@@ -365,7 +360,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.totalIteratedNodes = 0; $scope.totalIteratedNodes = 0;
if($scope.treeData && $scope.treeData.data && $scope.treeData.data.children && $scope.treeData.data.children.length > 0) { if ($scope.treeData && $scope.treeData.data && $scope.treeData.data.children && $scope.treeData.data.children.length > 0) {
let completionCallback = function() { let completionCallback = function() {
let disassociatePromises = disassociateRequests.map(function(request) { let disassociatePromises = disassociateRequests.map(function(request) {
@@ -376,13 +371,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
}); });
let credentialPromises = credentialRequests.map(function(request) {
return TemplatesService.postWorkflowNodeCredential({
id: request.id,
data: request.data
});
});
let editNodePromises = editRequests.map(function(request) { let editNodePromises = editRequests.map(function(request) {
return TemplatesService.editWorkflowNode({ return TemplatesService.editWorkflowNode({
id: request.id, id: request.id,
@@ -394,9 +382,16 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
return TemplatesService.deleteWorkflowJobTemplateNode(nodeId); return TemplatesService.deleteWorkflowJobTemplateNode(nodeId);
}); });
$q.all(disassociatePromises.concat(editNodePromises, deletePromises, credentialPromises)) $q.all(disassociatePromises.concat(editNodePromises, deletePromises))
.then(function() { .then(function() {
let credentialPromises = credentialRequests.map(function(request) {
return TemplatesService.postWorkflowNodeCredential({
id: request.id,
data: request.data
});
});
let associatePromises = associateRequests.map(function(request) { let associatePromises = associateRequests.map(function(request) {
return TemplatesService.associateWorkflowNode({ return TemplatesService.associateWorkflowNode({
parentId: request.parentId, parentId: request.parentId,
@@ -405,7 +400,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
}); });
$q.all(associatePromises) $q.all(associatePromises.concat(credentialPromises))
.then(function() { .then(function() {
$scope.closeDialog(); $scope.closeDialog();
}); });
@@ -417,8 +412,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
node: child node: child
}, completionCallback); }, completionCallback);
}); });
} } else {
else {
let deletePromises = $scope.treeData.data.deletedNodes.map(function(nodeId) { let deletePromises = $scope.treeData.data.deletedNodes.map(function(nodeId) {
return TemplatesService.deleteWorkflowJobTemplateNode(nodeId); return TemplatesService.deleteWorkflowJobTemplateNode(nodeId);
@@ -522,11 +516,11 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} }
} }
if(promptWatcher) { if (promptWatcher) {
promptWatcher(); promptWatcher();
} }
if(surveyQuestionWatcher) { if (surveyQuestionWatcher) {
surveyQuestionWatcher(); surveyQuestionWatcher();
} }
@@ -549,11 +543,11 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.nodeBeingEdited.isActiveEdit = false; $scope.nodeBeingEdited.isActiveEdit = false;
} }
if(promptWatcher) { if (promptWatcher) {
promptWatcher(); promptWatcher();
} }
if(surveyQuestionWatcher) { if (surveyQuestionWatcher) {
surveyQuestionWatcher(); surveyQuestionWatcher();
} }
@@ -601,12 +595,12 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
let jobTemplate = new JobTemplate(); let jobTemplate = new JobTemplate();
if(!_.isEmpty($scope.nodeBeingEdited.promptData)) { if (!_.isEmpty($scope.nodeBeingEdited.promptData)) {
$scope.promptData = _.cloneDeep($scope.nodeBeingEdited.promptData); $scope.promptData = _.cloneDeep($scope.nodeBeingEdited.promptData);
} else if($scope.nodeBeingEdited.unifiedJobTemplate){ } else if ($scope.nodeBeingEdited.unifiedJobTemplate){
let promises = [jobTemplate.optionsLaunch($scope.nodeBeingEdited.unifiedJobTemplate.id), jobTemplate.getLaunch($scope.nodeBeingEdited.unifiedJobTemplate.id)]; let promises = [jobTemplate.optionsLaunch($scope.nodeBeingEdited.unifiedJobTemplate.id), jobTemplate.getLaunch($scope.nodeBeingEdited.unifiedJobTemplate.id)];
if(_.has($scope, 'nodeBeingEdited.originalNodeObj.related.credentials')) { if (_.has($scope, 'nodeBeingEdited.originalNodeObj.related.credentials')) {
Rest.setUrl($scope.nodeBeingEdited.originalNodeObj.related.credentials); Rest.setUrl($scope.nodeBeingEdited.originalNodeObj.related.credentials);
promises.push(Rest.get()); promises.push(Rest.get());
} }
@@ -630,8 +624,8 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
const credentialHasScheduleOverride = (templateDefaultCred) => { const credentialHasScheduleOverride = (templateDefaultCred) => {
let credentialHasOverride = false; let credentialHasOverride = false;
workflowNodeCredentials.forEach((scheduleCred) => { workflowNodeCredentials.forEach((scheduleCred) => {
if(templateDefaultCred.credential_type === scheduleCred.credential_type) { if (templateDefaultCred.credential_type === scheduleCred.credential_type) {
if( if (
(!templateDefaultCred.vault_id && !scheduleCred.inputs.vault_id) || (!templateDefaultCred.vault_id && !scheduleCred.inputs.vault_id) ||
(templateDefaultCred.vault_id && scheduleCred.inputs.vault_id && templateDefaultCred.vault_id === scheduleCred.inputs.vault_id) (templateDefaultCred.vault_id && scheduleCred.inputs.vault_id && templateDefaultCred.vault_id === scheduleCred.inputs.vault_id)
) { ) {
@@ -643,9 +637,9 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
return credentialHasOverride; return credentialHasOverride;
}; };
if(_.has(launchConf, 'defaults.credentials')) { if (_.has(launchConf, 'defaults.credentials')) {
launchConf.defaults.credentials.forEach((defaultCred) => { launchConf.defaults.credentials.forEach((defaultCred) => {
if(!credentialHasScheduleOverride(defaultCred)) { if (!credentialHasScheduleOverride(defaultCred)) {
defaultCredsWithoutOverrides.push(defaultCred); defaultCredsWithoutOverrides.push(defaultCred);
} }
}); });
@@ -653,7 +647,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
prompts.credentials.value = workflowNodeCredentials.concat(defaultCredsWithoutOverrides); prompts.credentials.value = workflowNodeCredentials.concat(defaultCredsWithoutOverrides);
if(!launchConf.survey_enabled && if (!launchConf.survey_enabled &&
!launchConf.ask_inventory_on_launch && !launchConf.ask_inventory_on_launch &&
!launchConf.ask_credential_on_launch && !launchConf.ask_credential_on_launch &&
!launchConf.ask_verbosity_on_launch && !launchConf.ask_verbosity_on_launch &&
@@ -671,11 +665,11 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
if(launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has($scope, 'nodeBeingEdited.originalNodeObj.summary_fields.inventory')) { if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory') && !_.has($scope, 'nodeBeingEdited.originalNodeObj.summary_fields.inventory')) {
$scope.promptModalMissingReqFields = true; $scope.promptModalMissingReqFields = true;
} }
if(responses[1].data.survey_enabled) { if (responses[1].data.survey_enabled) {
// go out and get the survey questions // go out and get the survey questions
jobTemplate.getSurveyQuestions($scope.nodeBeingEdited.unifiedJobTemplate.id) jobTemplate.getSurveyQuestions($scope.nodeBeingEdited.unifiedJobTemplate.id)
.then((surveyQuestionRes) => { .then((surveyQuestionRes) => {
@@ -700,7 +694,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
surveyQuestionWatcher = $scope.$watch('promptData.surveyQuestions', () => { surveyQuestionWatcher = $scope.$watch('promptData.surveyQuestions', () => {
let missingSurveyValue = false; let missingSurveyValue = false;
_.each($scope.promptData.surveyQuestions, (question) => { _.each($scope.promptData.surveyQuestions, (question) => {
if(question.required && (Empty(question.model) || question.model === [])) { if (question.required && (Empty(question.model) || question.model === [])) {
missingSurveyValue = true; missingSurveyValue = true;
} }
}); });
@@ -709,8 +703,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
watchForPromptChanges(); watchForPromptChanges();
}); });
} } else {
else {
$scope.nodeBeingEdited.promptData = $scope.promptData = { $scope.nodeBeingEdited.promptData = $scope.promptData = {
launchConf: launchConf, launchConf: launchConf,
launchOptions: launchOptions, launchOptions: launchOptions,
@@ -729,7 +722,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.selectedTemplate = $scope.nodeBeingEdited.unifiedJobTemplate; $scope.selectedTemplate = $scope.nodeBeingEdited.unifiedJobTemplate;
if($scope.selectedTemplate.unified_job_type) { if ($scope.selectedTemplate.unified_job_type) {
switch ($scope.selectedTemplate.unified_job_type) { switch ($scope.selectedTemplate.unified_job_type) {
case "job": case "job":
$scope.workflowMakerFormConfig.activeTab = "jobs"; $scope.workflowMakerFormConfig.activeTab = "jobs";
@@ -741,8 +734,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.workflowMakerFormConfig.activeTab = "inventory_sync"; $scope.workflowMakerFormConfig.activeTab = "inventory_sync";
break; break;
} }
} } else if ($scope.selectedTemplate.type) {
else if($scope.selectedTemplate.type) {
switch ($scope.selectedTemplate.type) { switch ($scope.selectedTemplate.type) {
case "job_template": case "job_template":
$scope.workflowMakerFormConfig.activeTab = "jobs"; $scope.workflowMakerFormConfig.activeTab = "jobs";
@@ -767,19 +759,19 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
switch($scope.nodeBeingEdited.edgeType) { switch($scope.nodeBeingEdited.edgeType) {
case "always": case "always":
$scope.edgeType = {label: "Always", value: "always"}; $scope.edgeType = {label: "Always", value: "always"};
if(siblingConnectionTypes.length === 1 && _.includes(siblingConnectionTypes, "always")) { if (siblingConnectionTypes.length === 1 && _.includes(siblingConnectionTypes, "always")) {
edgeDropdownOptions = ["always"]; edgeDropdownOptions = ["always"];
} }
break; break;
case "success": case "success":
$scope.edgeType = {label: "On Success", value: "success"}; $scope.edgeType = {label: "On Success", value: "success"};
if(siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) { if (siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) {
edgeDropdownOptions = ["success", "failure"]; edgeDropdownOptions = ["success", "failure"];
} }
break; break;
case "failure": case "failure":
$scope.edgeType = {label: "On Failure", value: "failure"}; $scope.edgeType = {label: "On Failure", value: "failure"};
if(siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) { if (siblingConnectionTypes.length !== 0 && (!_.includes(siblingConnectionTypes, "always"))) {
edgeDropdownOptions = ["success", "failure"]; edgeDropdownOptions = ["success", "failure"];
} }
break; break;
@@ -857,13 +849,12 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.$broadcast("refreshWorkflowChart"); $scope.$broadcast("refreshWorkflowChart");
if($scope.placeholderNode) { if ($scope.placeholderNode) {
let edgeType = {label: "On Success", value: "success"}; let edgeType = {label: "On Success", value: "success"};
if($scope.placeholderNode.isRoot) { if ($scope.placeholderNode.isRoot) {
updateEdgeDropdownOptions(["always"]); updateEdgeDropdownOptions(["always"]);
edgeType = {label: "Always", value: "always"}; edgeType = {label: "Always", value: "always"};
} } else {
else {
// we need to update the possible edges based on any new siblings // we need to update the possible edges based on any new siblings
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({ let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
tree: $scope.treeData.data, tree: $scope.treeData.data,
@@ -889,8 +880,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} }
$scope.edgeType = edgeType; $scope.edgeType = edgeType;
} } else if ($scope.nodeBeingEdited) {
else if($scope.nodeBeingEdited) {
let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({ let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({
tree: $scope.treeData.data, tree: $scope.treeData.data,
parentId: $scope.nodeBeingEdited.parent.id, parentId: $scope.nodeBeingEdited.parent.id,
@@ -958,14 +948,14 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.selectedTemplate = angular.copy(selectedTemplate); $scope.selectedTemplate = angular.copy(selectedTemplate);
if(selectedTemplate.type === "job_template") { if (selectedTemplate.type === "job_template") {
let jobTemplate = new JobTemplate(); let jobTemplate = new JobTemplate();
$q.all([jobTemplate.optionsLaunch(selectedTemplate.id), jobTemplate.getLaunch(selectedTemplate.id)]) $q.all([jobTemplate.optionsLaunch(selectedTemplate.id), jobTemplate.getLaunch(selectedTemplate.id)])
.then((responses) => { .then((responses) => {
let launchConf = responses[1].data; let launchConf = responses[1].data;
if(!launchConf.survey_enabled && if (!launchConf.survey_enabled &&
!launchConf.ask_inventory_on_launch && !launchConf.ask_inventory_on_launch &&
!launchConf.ask_credential_on_launch && !launchConf.ask_credential_on_launch &&
!launchConf.ask_verbosity_on_launch && !launchConf.ask_verbosity_on_launch &&
@@ -983,11 +973,11 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
} else { } else {
$scope.showPromptButton = true; $scope.showPromptButton = true;
if(launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory')) { if (launchConf.ask_inventory_on_launch && !_.has(launchConf, 'defaults.inventory')) {
$scope.promptModalMissingReqFields = true; $scope.promptModalMissingReqFields = true;
} }
if(launchConf.survey_enabled) { if (launchConf.survey_enabled) {
// go out and get the survey questions // go out and get the survey questions
jobTemplate.getSurveyQuestions(selectedTemplate.id) jobTemplate.getSurveyQuestions(selectedTemplate.id)
.then((surveyQuestionRes) => { .then((surveyQuestionRes) => {
@@ -1012,7 +1002,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
surveyQuestionWatcher = $scope.$watch('promptData.surveyQuestions', () => { surveyQuestionWatcher = $scope.$watch('promptData.surveyQuestions', () => {
let missingSurveyValue = false; let missingSurveyValue = false;
_.each($scope.promptData.surveyQuestions, (question) => { _.each($scope.promptData.surveyQuestions, (question) => {
if(question.required && (Empty(question.model) || question.model === [])) { if (question.required && (Empty(question.model) || question.model === [])) {
missingSurveyValue = true; missingSurveyValue = true;
} }
}); });
@@ -1021,8 +1011,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
watchForPromptChanges(); watchForPromptChanges();
}); });
} } else {
else {
$scope.promptData = { $scope.promptData = {
launchConf: responses[1].data, launchConf: responses[1].data,
launchOptions: responses[0].data, launchOptions: responses[0].data,
@@ -1098,7 +1087,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// TODO: I think that the workflow chart directive (and eventually d3) is meddling with // TODO: I think that the workflow chart directive (and eventually d3) is meddling with
// this treeData object and removing the children object for some reason (?) // this treeData object and removing the children object for some reason (?)
// This happens on occasion and I think is a race condition (?) // This happens on occasion and I think is a race condition (?)
if(!$scope.treeData.data.children) { if (!$scope.treeData.data.children) {
$scope.treeData.data.children = []; $scope.treeData.data.children = [];
} }
@@ -1116,12 +1105,11 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
for(var i=0; i<data.data.results.length; i++) { for(var i=0; i<data.data.results.length; i++) {
allNodes.push(data.data.results[i]); allNodes.push(data.data.results[i]);
} }
if(data.data.next) { if (data.data.next) {
// Get the next page // Get the next page
page++; page++;
getNodes(); getNodes();
} } else {
else {
// This is the last page // This is the last page
buildTreeFromNodes(); buildTreeFromNodes();
} }