mirror of
https://github.com/ansible/awx.git
synced 2026-01-23 07:28:02 -03:30
Code cleanup. Fixed bugs with workflow results page including details links
This commit is contained in:
parent
676c068b71
commit
5b459e3c5d
@ -62,7 +62,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
|
||||
return d.y;
|
||||
});
|
||||
|
||||
zoomObj = d3.behavior.zoom().scaleExtent([0.5, 2]);
|
||||
zoomObj = d3.behavior.zoom().scaleExtent([0.1, 2]);
|
||||
|
||||
baseSvg = d3.select(element[0]).append("svg")
|
||||
.attr("class", "WorkflowChart-svg")
|
||||
@ -1130,9 +1130,11 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
|
||||
thisNode.append("foreignObject")
|
||||
.attr("x", nodeW - 6)
|
||||
.attr("y", nodeH/2 - 9)
|
||||
.attr("height", "17px")
|
||||
.attr("width", "13px")
|
||||
.style("font-size","14px")
|
||||
.html(function () {
|
||||
return `<span class="fa fa-link" />`;
|
||||
return `<span class="fa fa-link"></span>`;
|
||||
})
|
||||
.attr("class", "WorkflowChart-nodeLinkIcon")
|
||||
.style("display", function(d) { return d.id === scope.graphState.nodeBeingAdded || scope.readOnly ? "none" : null; })
|
||||
@ -1347,46 +1349,18 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
|
||||
d3.select(this).style("text-decoration", null);
|
||||
});
|
||||
this.on("click", function(d) {
|
||||
|
||||
let goToJobResults = function(job_type) {
|
||||
if(job_type === 'job') {
|
||||
$state.go('output', {id: d.job.id, type: 'playbook'});
|
||||
}
|
||||
else if(job_type === 'inventory_update') {
|
||||
$state.go('output', {id: d.job.id, type: 'inventory'});
|
||||
}
|
||||
else if(job_type === 'project_update') {
|
||||
$state.go('output', {id: d.job.id, type: 'project'});
|
||||
}
|
||||
};
|
||||
|
||||
if(d.job.type) {
|
||||
if(d.unifiedJobTemplate) {
|
||||
goToJobResults(d.unifiedJobTemplate.unified_job_type);
|
||||
}
|
||||
else {
|
||||
// We don't have access to the job type and have to make
|
||||
// a GET request in order to find out what type job this was
|
||||
// so that we can route the user to the correct stdout view
|
||||
Rest.setUrl(GetBasePath("workflow_jobs") + `${d.originalNodeObj.workflow_job}/workflow_nodes/?order_by=id`);
|
||||
Rest.get()
|
||||
.then(function (res) {
|
||||
if (res.data.results && res.data.results.length > 0) {
|
||||
const { results } = res.data;
|
||||
const job = results.filter(result => result.summary_fields.job.id === d.job.id);
|
||||
goToJobResults(job[0].summary_fields.job.type);
|
||||
}
|
||||
})
|
||||
.catch(({
|
||||
data,
|
||||
status
|
||||
}) => {
|
||||
ProcessErrors(scope, data, status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Unable to get job: ' + status
|
||||
});
|
||||
});
|
||||
}
|
||||
if(d.job.type === 'job') {
|
||||
$state.go('output', {id: d.job.id, type: 'playbook'});
|
||||
}
|
||||
else if(d.job.type === 'inventory_update') {
|
||||
$state.go('output', {id: d.job.id, type: 'inventory'});
|
||||
}
|
||||
else if(d.job.type === 'project_update') {
|
||||
$state.go('output', {id: d.job.id, type: 'project'});
|
||||
} else if (d.job.type === 'workflow_job') {
|
||||
$state.go('workflowResults', {
|
||||
id: d.job.id,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
export default [function(){
|
||||
return {
|
||||
generateArraysOfNodesAndLinks: function(allNodes) {
|
||||
generateArraysOfNodesAndLinks: (allNodes) => {
|
||||
let nonRootNodeIds = [];
|
||||
let allNodeIds = [];
|
||||
let arrayOfLinksForChart = [];
|
||||
@ -15,10 +15,7 @@ export default [function(){
|
||||
isStartNode: true,
|
||||
unifiedJobTemplate: {
|
||||
name: "START"
|
||||
},
|
||||
fixed: true,
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
}
|
||||
];
|
||||
nodeIdCounter++;
|
||||
|
||||
@ -21,7 +21,7 @@ export default ['templateUrl',
|
||||
scope.zoom = 100;
|
||||
$( "#slider" ).slider({
|
||||
value:100,
|
||||
min: 50,
|
||||
min: 10,
|
||||
max: 200,
|
||||
step: 10,
|
||||
slide: function( event, ui ) {
|
||||
@ -54,7 +54,7 @@ export default ['templateUrl',
|
||||
};
|
||||
|
||||
scope.zoomOut = function() {
|
||||
scope.zoom = Math.floor((scope.zoom - 10) / 10) * 10 > 50 ? Math.floor((scope.zoom - 10) / 10) * 10 : 50;
|
||||
scope.zoom = Math.floor((scope.zoom - 10) / 10) * 10 > 10 ? Math.floor((scope.zoom - 10) / 10) * 10 : 10;
|
||||
$("#slider").slider('value',scope.zoom);
|
||||
scope.zoomChart({
|
||||
zoom: scope.zoom
|
||||
|
||||
@ -88,7 +88,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
'missingSurveyValue'
|
||||
];
|
||||
|
||||
promptWatcher = $scope.$watchGroup(promptDataToWatch, function() {
|
||||
promptWatcher = $scope.$watchGroup(promptDataToWatch, () => {
|
||||
let missingPromptValue = false;
|
||||
if ($scope.missingSurveyValue) {
|
||||
missingPromptValue = true;
|
||||
@ -524,7 +524,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
|
||||
listPromises.push(
|
||||
qs.search(GetBasePath('unified_job_templates'), $scope.wf_maker_template_queryset)
|
||||
.then(function(res) {
|
||||
.then((res) => {
|
||||
$scope.wf_maker_template_dataset = res.data;
|
||||
$scope.wf_maker_templates = $scope.wf_maker_template_dataset.results;
|
||||
})
|
||||
@ -540,7 +540,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
|
||||
listPromises.push(
|
||||
qs.search(GetBasePath('projects'), $scope.wf_maker_project_queryset)
|
||||
.then(function(res) {
|
||||
.then((res) => {
|
||||
$scope.wf_maker_project_dataset = res.data;
|
||||
$scope.wf_maker_projects = $scope.wf_maker_project_dataset.results;
|
||||
})
|
||||
@ -557,7 +557,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
|
||||
listPromises.push(
|
||||
qs.search(GetBasePath('inventory_sources'), $scope.wf_maker_inventory_source_dataset)
|
||||
.then(function(res) {
|
||||
.then((res) => {
|
||||
$scope.wf_maker_inventory_source_dataset = res.data;
|
||||
$scope.wf_maker_inventory_sources = $scope.wf_maker_inventory_source_dataset.results;
|
||||
})
|
||||
@ -567,14 +567,14 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
.then(() => {
|
||||
if ($scope.nodeConfig.mode === "edit") {
|
||||
// Make sure that we have the full unified job template object
|
||||
if (!$scope.nodeConfig.node.fullUnifiedJobTemplate && _.get($scope, 'nodeConfig.node.originalNodeObject.summary_fields.unified_job_template.unified_job_type') === 'job') {
|
||||
if (!$scope.nodeConfig.node.fullUnifiedJobTemplateObject && _.get($scope, 'nodeConfig.node.originalNodeObject.summary_fields.unified_job_template.unified_job_type') === 'job') {
|
||||
// This is a node that we got back from the api with an incomplete
|
||||
// unified job template so we're going to pull down the whole object
|
||||
TemplatesService.getUnifiedJobTemplate($scope.nodeConfig.node.originalNodeObject.summary_fields.unified_job_template.id)
|
||||
.then(function({data}) {
|
||||
.then(({data}) => {
|
||||
$scope.nodeConfig.node.fullUnifiedJobTemplateObject = data.results[0];
|
||||
finishConfiguringEdit();
|
||||
}, function(error) {
|
||||
}, (error) => {
|
||||
ProcessErrors($scope, error.data, error.status, null, {
|
||||
hdr: 'Error!',
|
||||
msg: 'Failed to get unified job template. GET returned ' +
|
||||
@ -590,16 +590,15 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openPromptModal = function() {
|
||||
$scope.openPromptModal = () => {
|
||||
$scope.promptData.triggerModalOpen = true;
|
||||
};
|
||||
|
||||
$scope.toggle_row = function(selectedRow) {
|
||||
$scope.toggle_row = (selectedRow) => {
|
||||
if (!$scope.readOnly) {
|
||||
// TODO: make this more concise
|
||||
switch($scope.activeTab) {
|
||||
case 'jobs':
|
||||
$scope.wf_maker_templates.forEach(function(row, i) {
|
||||
$scope.wf_maker_templates.forEach((row, i) => {
|
||||
if (row.id === selectedRow.id) {
|
||||
$scope.wf_maker_templates[i].checked = 1;
|
||||
|
||||
@ -609,7 +608,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
});
|
||||
break;
|
||||
case 'project_syncs':
|
||||
$scope.wf_maker_projects.forEach(function(row, i) {
|
||||
$scope.wf_maker_projects.forEach((row, i) => {
|
||||
if (row.id === selectedRow.id) {
|
||||
$scope.wf_maker_projects[i].checked = 1;
|
||||
} else {
|
||||
@ -618,7 +617,7 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
});
|
||||
break;
|
||||
case 'inventory_syncs':
|
||||
$scope.wf_maker_inventory_sources.forEach(function(row, i) {
|
||||
$scope.wf_maker_inventory_sources.forEach((row, i) => {
|
||||
if (row.id === selectedRow.id) {
|
||||
$scope.wf_maker_inventory_sources[i].checked = 1;
|
||||
} else {
|
||||
@ -638,11 +637,11 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
});
|
||||
|
||||
$scope.$watchGroup(['wf_maker_templates', 'wf_maker_projects', 'wf_maker_inventory_sources', 'activeTab'], () => {
|
||||
// TODO: make this more concise
|
||||
const unifiedJobTemplateId = _.get($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject.id') || _.get($scope, 'nodeConfig.node.unifiedJobTemplate.id') || null;
|
||||
switch($scope.activeTab) {
|
||||
case 'jobs':
|
||||
$scope.wf_maker_templates.forEach(function(row, i) {
|
||||
if(_.hasIn($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject.id') && row.id === $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id) {
|
||||
$scope.wf_maker_templates.forEach((row, i) => {
|
||||
if(row.id === unifiedJobTemplateId) {
|
||||
$scope.wf_maker_templates[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
@ -651,8 +650,8 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
});
|
||||
break;
|
||||
case 'project_syncs':
|
||||
$scope.wf_maker_projects.forEach(function(row, i) {
|
||||
if(_.hasIn($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject.id') && row.id === $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id) {
|
||||
$scope.wf_maker_projects.forEach((row, i) => {
|
||||
if(row.id === unifiedJobTemplateId) {
|
||||
$scope.wf_maker_projects[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
@ -661,8 +660,8 @@ export default ['$scope', 'TemplatesService', 'JobTemplateModel', 'PromptService
|
||||
});
|
||||
break;
|
||||
case 'inventory_syncs':
|
||||
$scope.wf_maker_inventory_sources.forEach(function(row, i) {
|
||||
if(_.hasIn($scope, 'nodeConfig.node.fullUnifiedJobTemplateObject.id') && row.id === $scope.nodeConfig.node.fullUnifiedJobTemplateObject.id) {
|
||||
$scope.wf_maker_inventory_sources.forEach((row, i) => {
|
||||
if(row.id === unifiedJobTemplateId) {
|
||||
$scope.wf_maker_inventory_sources[i].checked = 1;
|
||||
}
|
||||
else {
|
||||
|
||||
@ -14,86 +14,121 @@ export default ['$scope', 'TemplatesService',
|
||||
Wait
|
||||
) {
|
||||
|
||||
$scope.strings = TemplatesStrings;
|
||||
$scope.preventCredsWithPasswords = true;
|
||||
|
||||
let deletedNodeIds = [];
|
||||
let workflowMakerNodeIdCounter = 1;
|
||||
let workflowMakerNodeIdCounter;
|
||||
let nodeIdToChartNodeIdMapping = {};
|
||||
let nodeRef = {};
|
||||
let allNodes = [];
|
||||
let page = 1;
|
||||
|
||||
$scope.strings = TemplatesStrings;
|
||||
$scope.preventCredsWithPasswords = true;
|
||||
$scope.showKey = false;
|
||||
$scope.toggleKey = () => $scope.showKey = !$scope.showKey;
|
||||
$scope.keyClassList = `{ 'Key-menuIcon--active': showKey }`;
|
||||
|
||||
$scope.readOnly = !_.get($scope, 'workflowJobTemplateObj.summary_fields.user_capabilities.edit');
|
||||
|
||||
$scope.formState = {
|
||||
'showNodeForm': false,
|
||||
'showLinkForm': false
|
||||
};
|
||||
|
||||
let buildSendableNodeData = function (node) {
|
||||
// Create the node
|
||||
let sendableNodeData = {
|
||||
extra_data: {},
|
||||
inventory: null,
|
||||
job_type: null,
|
||||
job_tags: null,
|
||||
skip_tags: null,
|
||||
limit: null,
|
||||
diff_mode: null,
|
||||
verbosity: null,
|
||||
credential: null
|
||||
};
|
||||
let getNodes = () => {
|
||||
Wait('start');
|
||||
TemplatesService.getWorkflowJobTemplateNodes($scope.workflowJobTemplateObj.id, page)
|
||||
.then(({data}) => {
|
||||
for (var i = 0; i < data.results.length; i++) {
|
||||
allNodes.push(data.results[i]);
|
||||
}
|
||||
if (data.next) {
|
||||
// Get the next page
|
||||
page++;
|
||||
getNodes();
|
||||
} else {
|
||||
let arrayOfLinksForChart = [];
|
||||
let arrayOfNodesForChart = [];
|
||||
|
||||
if (_.has(node, 'fullUnifiedJobTemplateObject')) {
|
||||
sendableNodeData.unified_job_template = node.fullUnifiedJobTemplateObject.id;
|
||||
}
|
||||
({arrayOfNodesForChart, arrayOfLinksForChart, nodeIdToChartNodeIdMapping, nodeRef, workflowMakerNodeIdCounter} = WorkflowChartService.generateArraysOfNodesAndLinks(allNodes));
|
||||
|
||||
if (_.has(node, 'promptData.extraVars')) {
|
||||
if (_.get(node, 'promptData.launchConf.defaults.extra_vars')) {
|
||||
const defaultVars = jsyaml.safeLoad(node.promptData.launchConf.defaults.extra_vars);
|
||||
$scope.graphState = { arrayOfNodesForChart, arrayOfLinksForChart };
|
||||
|
||||
// Only include extra vars that differ from the template default vars
|
||||
_.forOwn(node.promptData.extraVars, (value, key) => {
|
||||
if (!defaultVars[key] || defaultVars[key] !== value) {
|
||||
sendableNodeData.extra_data[key] = value;
|
||||
}
|
||||
Wait('stop');
|
||||
}
|
||||
}, ({ data, status, config }) => {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: $scope.strings.get('error.HEADER'),
|
||||
msg: $scope.strings.get('error.CALL', {
|
||||
path: `${config.url}`,
|
||||
action: `${config.method}`,
|
||||
status
|
||||
})
|
||||
});
|
||||
if (_.isEmpty(sendableNodeData.extra_data)) {
|
||||
delete sendableNodeData.extra_data;
|
||||
}
|
||||
} else {
|
||||
if (_.has(node, 'promptData.extraVars') && !_.isEmpty(node.promptData.extraVars)) {
|
||||
sendableNodeData.extra_data = node.promptData.extraVars;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the user has provided any prompt values that are different
|
||||
// from the defaults in the job template
|
||||
|
||||
if (_.has(node, 'fullUnifiedJobTemplateObject') && node.fullUnifiedJobTemplateObject.type === "job_template" && node.promptData) {
|
||||
sendableNodeData = PromptService.bundlePromptDataForSaving({
|
||||
promptData: node.promptData,
|
||||
dataToSave: sendableNodeData
|
||||
});
|
||||
}
|
||||
|
||||
return sendableNodeData;
|
||||
};
|
||||
|
||||
$scope.closeWorkflowMaker = function() {
|
||||
getNodes();
|
||||
|
||||
$scope.closeWorkflowMaker = () => {
|
||||
// Revert the data to the master which was created when the dialog was opened
|
||||
$scope.graphState.nodeTree = angular.copy($scope.graphStateMaster);
|
||||
$scope.closeDialog();
|
||||
};
|
||||
|
||||
$scope.saveWorkflowMaker = function () {
|
||||
$scope.saveWorkflowMaker = () => {
|
||||
|
||||
Wait('start');
|
||||
|
||||
let buildSendableNodeData = (node) => {
|
||||
// Create the node
|
||||
let sendableNodeData = {
|
||||
extra_data: {},
|
||||
inventory: null,
|
||||
job_type: null,
|
||||
job_tags: null,
|
||||
skip_tags: null,
|
||||
limit: null,
|
||||
diff_mode: null,
|
||||
verbosity: null,
|
||||
credential: null
|
||||
};
|
||||
|
||||
if (_.has(node, 'fullUnifiedJobTemplateObject')) {
|
||||
sendableNodeData.unified_job_template = node.fullUnifiedJobTemplateObject.id;
|
||||
}
|
||||
|
||||
if (_.has(node, 'promptData.extraVars')) {
|
||||
if (_.get(node, 'promptData.launchConf.defaults.extra_vars')) {
|
||||
const defaultVars = jsyaml.safeLoad(node.promptData.launchConf.defaults.extra_vars);
|
||||
|
||||
// Only include extra vars that differ from the template default vars
|
||||
_.forOwn(node.promptData.extraVars, (value, key) => {
|
||||
if (!defaultVars[key] || defaultVars[key] !== value) {
|
||||
sendableNodeData.extra_data[key] = value;
|
||||
}
|
||||
});
|
||||
if (_.isEmpty(sendableNodeData.extra_data)) {
|
||||
delete sendableNodeData.extra_data;
|
||||
}
|
||||
} else {
|
||||
if (_.has(node, 'promptData.extraVars') && !_.isEmpty(node.promptData.extraVars)) {
|
||||
sendableNodeData.extra_data = node.promptData.extraVars;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the user has provided any prompt values that are different
|
||||
// from the defaults in the job template
|
||||
|
||||
if (_.has(node, 'fullUnifiedJobTemplateObject') && node.fullUnifiedJobTemplateObject.type === "job_template" && node.promptData) {
|
||||
sendableNodeData = PromptService.bundlePromptDataForSaving({
|
||||
promptData: node.promptData,
|
||||
dataToSave: sendableNodeData
|
||||
});
|
||||
}
|
||||
|
||||
return sendableNodeData;
|
||||
};
|
||||
|
||||
if ($scope.graphState.arrayOfNodesForChart.length > 1) {
|
||||
let addPromises = [];
|
||||
let editPromises = [];
|
||||
@ -110,9 +145,9 @@ export default ['$scope', 'TemplatesService',
|
||||
if (_.get(nodeRef[workflowMakerNodeId], 'promptData.launchConf.ask_credential_on_launch')) {
|
||||
// This finds the credentials that were selected in the prompt but don't occur
|
||||
// in the template defaults
|
||||
let credentialIdsToPost = nodeRef[workflowMakerNodeId].promptData.prompts.credentials.value.filter(function (credFromPrompt) {
|
||||
let credentialIdsToPost = nodeRef[workflowMakerNodeId].promptData.prompts.credentials.value.filter((credFromPrompt) => {
|
||||
let defaultCreds = _.get(nodeRef[workflowMakerNodeId], 'promptData.launchConf.defaults.credentials', []);
|
||||
return !defaultCreds.some(function (defaultCred) {
|
||||
return !defaultCreds.some((defaultCred) => {
|
||||
return credFromPrompt.id === defaultCred.id;
|
||||
});
|
||||
});
|
||||
@ -134,16 +169,16 @@ export default ['$scope', 'TemplatesService',
|
||||
}));
|
||||
|
||||
if (_.get(nodeRef[workflowMakerNodeId], 'promptData.launchConf.ask_credential_on_launch')) {
|
||||
let credentialsNotInPriorCredentials = nodeRef[workflowMakerNodeId].promptData.prompts.credentials.value.filter(function (credFromPrompt) {
|
||||
let credentialsNotInPriorCredentials = nodeRef[workflowMakerNodeId].promptData.prompts.credentials.value.filter((credFromPrompt) => {
|
||||
let defaultCreds = _.get(nodeRef[workflowMakerNodeId], 'promptData.launchConf.defaults.credentials', []);
|
||||
return !defaultCreds.some(function (defaultCred) {
|
||||
return !defaultCreds.some((defaultCred) => {
|
||||
return credFromPrompt.id === defaultCred.id;
|
||||
});
|
||||
});
|
||||
|
||||
let credentialsToAdd = credentialsNotInPriorCredentials.filter(function (credNotInPrior) {
|
||||
let credentialsToAdd = credentialsNotInPriorCredentials.filter((credNotInPrior) => {
|
||||
let previousOverrides = _.get(nodeRef[workflowMakerNodeId], 'promptData.prompts.credentials.previousOverrides', []);
|
||||
return !previousOverrides.some(function (priorCred) {
|
||||
return !previousOverrides.some((priorCred) => {
|
||||
return credNotInPrior.id === priorCred.id;
|
||||
});
|
||||
});
|
||||
@ -151,8 +186,8 @@ export default ['$scope', 'TemplatesService',
|
||||
let credentialsToRemove = [];
|
||||
|
||||
if (_.has(nodeRef[workflowMakerNodeId], 'promptData.prompts.credentials.previousOverrides')) {
|
||||
credentialsToRemove = nodeRef[workflowMakerNodeId].promptData.prompts.credentials.previousOverrides.filter(function (priorCred) {
|
||||
return !credentialsNotInPriorCredentials.some(function (credNotInPrior) {
|
||||
credentialsToRemove = nodeRef[workflowMakerNodeId].promptData.prompts.credentials.previousOverrides.filter((priorCred) => {
|
||||
return !credentialsNotInPriorCredentials.some((credNotInPrior) => {
|
||||
return priorCred.id === credNotInPrior.id;
|
||||
});
|
||||
});
|
||||
@ -181,7 +216,7 @@ export default ['$scope', 'TemplatesService',
|
||||
|
||||
});
|
||||
|
||||
let deletePromises = deletedNodeIds.map(function (nodeId) {
|
||||
let deletePromises = deletedNodeIds.map((nodeId) => {
|
||||
return TemplatesService.deleteWorkflowJobTemplateNode(nodeId);
|
||||
});
|
||||
|
||||
@ -315,8 +350,8 @@ export default ['$scope', 'TemplatesService',
|
||||
});
|
||||
|
||||
$q.all(disassociatePromises)
|
||||
.then(function () {
|
||||
let credentialPromises = credentialRequests.map(function (request) {
|
||||
.then(() => {
|
||||
let credentialPromises = credentialRequests.map((request) => {
|
||||
return TemplatesService.postWorkflowNodeCredential({
|
||||
id: request.id,
|
||||
data: request.data
|
||||
@ -324,7 +359,7 @@ export default ['$scope', 'TemplatesService',
|
||||
});
|
||||
|
||||
return $q.all(associatePromises.concat(credentialPromises))
|
||||
.then(function () {
|
||||
.then(() => {
|
||||
Wait('stop');
|
||||
$scope.closeDialog();
|
||||
});
|
||||
@ -339,12 +374,12 @@ export default ['$scope', 'TemplatesService',
|
||||
|
||||
} else {
|
||||
|
||||
let deletePromises = deletedNodeIds.map(function (nodeId) {
|
||||
let deletePromises = deletedNodeIds.map((nodeId) => {
|
||||
return TemplatesService.deleteWorkflowJobTemplateNode(nodeId);
|
||||
});
|
||||
|
||||
$q.all(deletePromises)
|
||||
.then(function () {
|
||||
.then(() => {
|
||||
Wait('stop');
|
||||
$scope.closeDialog();
|
||||
$state.transitionTo('templates');
|
||||
@ -354,7 +389,7 @@ export default ['$scope', 'TemplatesService',
|
||||
|
||||
/* ADD NODE FUNCTIONS */
|
||||
|
||||
$scope.startAddNodeWithoutChild = function (parent) {
|
||||
$scope.startAddNodeWithoutChild = (parent) => {
|
||||
if ($scope.nodeConfig) {
|
||||
$scope.cancelNodeForm();
|
||||
}
|
||||
@ -389,7 +424,7 @@ export default ['$scope', 'TemplatesService',
|
||||
$scope.formState.showNodeForm = true;
|
||||
};
|
||||
|
||||
$scope.startAddNodeWithChild = function (link) {
|
||||
$scope.startAddNodeWithChild = (link) => {
|
||||
if ($scope.nodeConfig) {
|
||||
$scope.cancelNodeForm();
|
||||
}
|
||||
@ -432,7 +467,7 @@ export default ['$scope', 'TemplatesService',
|
||||
$scope.formState.showNodeForm = true;
|
||||
};
|
||||
|
||||
$scope.confirmNodeForm = function(selectedTemplate, promptData, edgeType) {
|
||||
$scope.confirmNodeForm = (selectedTemplate, promptData, edgeType) => {
|
||||
const nodeId = $scope.nodeConfig.nodeId;
|
||||
if ($scope.nodeConfig.mode === "add") {
|
||||
if (selectedTemplate && edgeType && edgeType.value) {
|
||||
@ -471,7 +506,7 @@ export default ['$scope', 'TemplatesService',
|
||||
$scope.$broadcast("refreshWorkflowChart");
|
||||
};
|
||||
|
||||
$scope.cancelNodeForm = function() {
|
||||
$scope.cancelNodeForm = () => {
|
||||
const nodeId = $scope.nodeConfig.nodeId;
|
||||
if ($scope.nodeConfig.mode === "add") {
|
||||
// Remove the placeholder node from the array
|
||||
@ -524,7 +559,7 @@ export default ['$scope', 'TemplatesService',
|
||||
|
||||
/* EDIT NODE FUNCTIONS */
|
||||
|
||||
$scope.startEditNode = function(nodeToEdit) {
|
||||
$scope.startEditNode = (nodeToEdit) => {
|
||||
if ($scope.linkConfig) {
|
||||
$scope.cancelLinkForm();
|
||||
}
|
||||
@ -763,17 +798,17 @@ export default ['$scope', 'TemplatesService',
|
||||
|
||||
/* DELETE NODE FUNCTIONS */
|
||||
|
||||
$scope.startDeleteNode = function (nodeToDelete) {
|
||||
$scope.startDeleteNode = (nodeToDelete) => {
|
||||
$scope.nodeToBeDeleted = nodeToDelete;
|
||||
$scope.deleteOverlayVisible = true;
|
||||
};
|
||||
|
||||
$scope.cancelDeleteNode = function () {
|
||||
$scope.cancelDeleteNode = () => {
|
||||
$scope.nodeToBeDeleted = null;
|
||||
$scope.deleteOverlayVisible = false;
|
||||
};
|
||||
|
||||
$scope.confirmDeleteNode = function () {
|
||||
$scope.confirmDeleteNode = () => {
|
||||
if ($scope.nodeToBeDeleted) {
|
||||
const nodeId = $scope.nodeToBeDeleted.id;
|
||||
|
||||
@ -857,73 +892,34 @@ export default ['$scope', 'TemplatesService',
|
||||
|
||||
};
|
||||
|
||||
$scope.toggleManualControls = function() {
|
||||
$scope.toggleManualControls = () => {
|
||||
$scope.showManualControls = !$scope.showManualControls;
|
||||
};
|
||||
|
||||
$scope.panChart = function (direction) {
|
||||
$scope.panChart = (direction) => {
|
||||
$scope.$broadcast('panWorkflowChart', {
|
||||
direction: direction
|
||||
});
|
||||
};
|
||||
|
||||
$scope.zoomChart = function (zoom) {
|
||||
$scope.zoomChart = (zoom) => {
|
||||
$scope.$broadcast('zoomWorkflowChart', {
|
||||
zoom: zoom
|
||||
});
|
||||
};
|
||||
|
||||
$scope.resetChart = function () {
|
||||
$scope.resetChart = () => {
|
||||
$scope.$broadcast('resetWorkflowChart');
|
||||
};
|
||||
|
||||
$scope.workflowZoomed = function (zoom) {
|
||||
$scope.workflowZoomed = (zoom) => {
|
||||
$scope.$broadcast('workflowZoomed', {
|
||||
zoom: zoom
|
||||
});
|
||||
};
|
||||
|
||||
$scope.zoomToFitChart = function () {
|
||||
$scope.zoomToFitChart = () => {
|
||||
$scope.$broadcast('zoomToFitChart');
|
||||
};
|
||||
|
||||
let allNodes = [];
|
||||
let page = 1;
|
||||
|
||||
let getNodes = function () {
|
||||
Wait('start');
|
||||
TemplatesService.getWorkflowJobTemplateNodes($scope.workflowJobTemplateObj.id, page)
|
||||
.then(function (data) {
|
||||
for (var i = 0; i < data.data.results.length; i++) {
|
||||
allNodes.push(data.data.results[i]);
|
||||
}
|
||||
if (data.data.next) {
|
||||
// Get the next page
|
||||
page++;
|
||||
getNodes();
|
||||
} else {
|
||||
let arrayOfLinksForChart = [];
|
||||
let arrayOfNodesForChart = [];
|
||||
|
||||
({arrayOfNodesForChart, arrayOfLinksForChart, nodeIdToChartNodeIdMapping, nodeRef, workflowMakerNodeIdCounter} = WorkflowChartService.generateArraysOfNodesAndLinks(allNodes));
|
||||
|
||||
$scope.graphState = { arrayOfNodesForChart, arrayOfLinksForChart };
|
||||
|
||||
Wait('stop');
|
||||
}
|
||||
}, function ({ data, status, config }) {
|
||||
Wait('stop');
|
||||
ProcessErrors($scope, data, status, null, {
|
||||
hdr: $scope.strings.get('error.HEADER'),
|
||||
msg: $scope.strings.get('error.CALL', {
|
||||
path: `${config.url}`,
|
||||
action: `${config.method}`,
|
||||
status
|
||||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
getNodes();
|
||||
}
|
||||
];
|
||||
|
||||
@ -74,7 +74,7 @@
|
||||
</div>
|
||||
<div class="WorkflowLegend-maker--right">
|
||||
<span class="WorkflowMaker-totalJobs">{{strings.get('workflow_maker.TOTAL_TEMPLATES')}}</span>
|
||||
<span class="badge List-titleBadge" ng-bind="graphState.arrayOfNodesForChart.length-1"></span>
|
||||
<span class="badge List-titleBadge" ng-bind="graphState.arrayOfNodesForChart.length === 0 ? graphState.arrayOfNodesForChart.length : graphState.arrayOfNodesForChart.length-1"></span>
|
||||
<i ng-class="{'WorkflowMaker-manualControlsIcon--active': showManualControls}" class="fa fa-cog WorkflowMaker-manualControlsIcon" aria-hidden="true" alt="Controls" ng-click="toggleManualControls()"></i>
|
||||
<div ng-show="showManualControls" class="WorkflowMaker-manualControls noselect">
|
||||
<workflow-controls class="WorkflowControls" pan-chart="panChart(direction)" zoom-chart="zoomChart(zoom)" reset-chart="resetChart()" zoom-to-fit-chart="zoomToFitChart()"></workflow-controls>
|
||||
|
||||
@ -5,9 +5,8 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
|
||||
workflowDataOptions, jobLabels, workflowNodes, $scope, ParseTypeChange,
|
||||
ParseVariableString, count, $state, i18n, WorkflowChartService, $filter,
|
||||
moment) {
|
||||
let nodeRef;
|
||||
var runTimeElapsedTimer = null;
|
||||
let nodeIdToChartNodeIdMapping = {};
|
||||
let chartNodeIdToIndexMapping = {};
|
||||
|
||||
var getLinks = function() {
|
||||
var getLink = function(key) {
|
||||
@ -113,7 +112,6 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
|
||||
function init() {
|
||||
// put initially resolved request data on scope
|
||||
$scope.workflow = workflowData;
|
||||
$scope.workflow_nodes = workflowNodes;
|
||||
$scope.workflowOptions = workflowDataOptions.actions.GET;
|
||||
$scope.labels = jobLabels;
|
||||
$scope.showManualControls = false;
|
||||
@ -173,7 +171,7 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
|
||||
let arrayOfLinksForChart = [];
|
||||
let arrayOfNodesForChart = [];
|
||||
|
||||
({arrayOfNodesForChart, arrayOfLinksForChart, chartNodeIdToIndexMapping, nodeIdToChartNodeIdMapping} = WorkflowChartService.generateArraysOfNodesAndLinks(workflowNodes));
|
||||
({arrayOfNodesForChart, arrayOfLinksForChart, nodeRef} = WorkflowChartService.generateArraysOfNodesAndLinks(workflowNodes));
|
||||
|
||||
$scope.graphState = { arrayOfNodesForChart, arrayOfLinksForChart };
|
||||
}
|
||||
@ -275,15 +273,12 @@ export default ['workflowData', 'workflowResultsService', 'workflowDataOptions',
|
||||
runTimeElapsedTimer = workflowResultsService.createOneSecondTimer(moment(), updateWorkflowJobElapsedTimer);
|
||||
}
|
||||
|
||||
$scope.graphState.arrayOfNodesForChart[chartNodeIdToIndexMapping[nodeIdToChartNodeIdMapping[data.workflow_node_id]]].job = {
|
||||
id: data.unified_job_id,
|
||||
status: data.status
|
||||
};
|
||||
|
||||
$scope.workflow_nodes.forEach(node => {
|
||||
if(parseInt(node.id) === parseInt(data.workflow_node_id)){
|
||||
node.summary_fields.job = {
|
||||
status: data.status
|
||||
$scope.graphState.arrayOfNodesForChart.forEach((node) => {
|
||||
if (nodeRef[node.id] && nodeRef[node.id].originalNodeObject.id === data.workflow_node_id) {
|
||||
node.job = {
|
||||
id: data.unified_job_id,
|
||||
status: data.status,
|
||||
type: nodeRef[node.id].unifiedJobTemplate.unified_job_type
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user