Merge pull request #1120 from mabashian/1066-workflow-node-credentials

Fixed workflow node credential bug
This commit is contained in:
Michael Abashian
2018-03-28 11:22:51 -04:00
committed by GitHub

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();
} }