mirror of
https://github.com/ansible/awx.git
synced 2026-05-07 17:37:37 -02:30
Merge pull request #4867 from mabashian/4856-delete-wf-node
Fixed stale workflow node data issue
This commit is contained in:
@@ -112,7 +112,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA
|
|||||||
},
|
},
|
||||||
views: {
|
views: {
|
||||||
'modal': {
|
'modal': {
|
||||||
template: ` <workflow-maker ng-if="includeWorkflowMaker" tree-data="workflowTree" can-add-workflow-job-template="canAddWorkflowJobTemplate"></workflow-maker>`
|
template: `<workflow-maker ng-if="includeWorkflowMaker" workflow-job-template-obj="workflow_job_template_obj" can-add-workflow-job-template="canAddWorkflowJobTemplate"></workflow-maker>`
|
||||||
},
|
},
|
||||||
'jobTemplateList@templates.editWorkflowJobTemplate.workflowMaker': {
|
'jobTemplateList@templates.editWorkflowJobTemplate.workflowMaker': {
|
||||||
templateProvider: function(WorkflowMakerJobTemplateList, generateList) {
|
templateProvider: function(WorkflowMakerJobTemplateList, generateList) {
|
||||||
|
|||||||
@@ -149,54 +149,7 @@
|
|||||||
$scope.url = workflowJobTemplateData.url;
|
$scope.url = workflowJobTemplateData.url;
|
||||||
$scope.survey_enabled = workflowJobTemplateData.survey_enabled;
|
$scope.survey_enabled = workflowJobTemplateData.survey_enabled;
|
||||||
|
|
||||||
let allNodes = [];
|
$scope.includeWorkflowMaker = true;
|
||||||
let page = 1;
|
|
||||||
|
|
||||||
let buildTreeFromNodes = function(){
|
|
||||||
$scope.workflowTree = WorkflowService.buildTree({
|
|
||||||
workflowNodes: allNodes
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: I think that the workflow chart directive (and eventually d3) is meddling with
|
|
||||||
// this workflowTree object and removing the children object for some reason (?)
|
|
||||||
// This happens on occasion and I think is a race condition (?)
|
|
||||||
if(!$scope.workflowTree.data.children) {
|
|
||||||
$scope.workflowTree.data.children = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.workflowTree.workflow_job_template_obj = $scope.workflow_job_template_obj;
|
|
||||||
|
|
||||||
// In the partial, the workflow maker directive has an ng-if attribute which is pointed at this scope variable.
|
|
||||||
// It won't get included until this the tree has been built - I'm open to better ways of doing this.
|
|
||||||
$scope.includeWorkflowMaker = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
let getNodes = function(){
|
|
||||||
// Get the workflow nodes
|
|
||||||
TemplatesService.getWorkflowJobTemplateNodes(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 {
|
|
||||||
// This is the last page
|
|
||||||
buildTreeFromNodes();
|
|
||||||
}
|
|
||||||
}, function(error){
|
|
||||||
ProcessErrors($scope, error.data, error.status, form, {
|
|
||||||
hdr: 'Error!',
|
|
||||||
msg: 'Failed to get workflow job template nodes. GET returned ' +
|
|
||||||
'status: ' + error.status
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
getNodes();
|
|
||||||
|
|
||||||
}, function(error){
|
}, function(error){
|
||||||
ProcessErrors($scope, error.data, error.status, form, {
|
ProcessErrors($scope, error.data, error.status, form, {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<div class="tab-pane" id="workflow_edit">
|
<div class="tab-pane" id="workflow_edit">
|
||||||
<div ui-view></div>
|
<div ui-view></div>
|
||||||
<div ng-cloak id="htmlTemplate" class="Panel"></div>
|
<div ng-cloak id="htmlTemplate" class="Panel"></div>
|
||||||
<workflow-maker ng-if="includeWorkflowMaker" tree-data="workflowTree"></workflow-maker>
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -779,11 +779,15 @@ export default [ '$state','moment',
|
|||||||
|
|
||||||
scope.$watch('canAddWorkflowJobTemplate', function() {
|
scope.$watch('canAddWorkflowJobTemplate', function() {
|
||||||
// Redraw the graph if permissions change
|
// Redraw the graph if permissions change
|
||||||
update();
|
if(scope.treeData) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$on('refreshWorkflowChart', function(){
|
scope.$on('refreshWorkflowChart', function(){console.log(scope.treeData);
|
||||||
update();
|
if(scope.treeData) {
|
||||||
|
update();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
scope.$on('panWorkflowChart', function(evt, params) {
|
scope.$on('panWorkflowChart', function(evt, params) {
|
||||||
@@ -798,6 +802,13 @@ export default [ '$state','moment',
|
|||||||
manualZoom(params.zoom);
|
manualZoom(params.zoom);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let clearWatchTreeData = scope.$watch('treeData', function(newVal) {
|
||||||
|
if(newVal) {
|
||||||
|
update();
|
||||||
|
clearWatchTreeData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}];
|
}];
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
.WorkflowLegend-maker--right {
|
.WorkflowLegend-maker--right {
|
||||||
flex: 0 0 206px;
|
flex: 0 0 215px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -226,7 +226,7 @@
|
|||||||
}
|
}
|
||||||
.WorkflowMaker-manualControls {
|
.WorkflowMaker-manualControls {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: -86px;
|
left: -77px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
width: 293px;
|
width: 293px;
|
||||||
background-color: @default-bg;
|
background-color: @default-bg;
|
||||||
|
|||||||
@@ -40,9 +40,56 @@ export default ['$scope', 'WorkflowService', 'generateList', 'TemplateList', 'Pr
|
|||||||
$scope.disassociateRequests = [];
|
$scope.disassociateRequests = [];
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
$scope.treeDataMaster = angular.copy($scope.treeData.data);
|
|
||||||
$scope.showManualControls = false;
|
let allNodes = [];
|
||||||
$scope.$broadcast("refreshWorkflowChart");
|
let page = 1;
|
||||||
|
|
||||||
|
let buildTreeFromNodes = function(){
|
||||||
|
WorkflowService.buildTree({
|
||||||
|
workflowNodes: allNodes
|
||||||
|
}).then(function(data){
|
||||||
|
$scope.treeData = data;
|
||||||
|
|
||||||
|
// 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 happens on occasion and I think is a race condition (?)
|
||||||
|
if(!$scope.treeData.data.children) {
|
||||||
|
$scope.treeData.data.children = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$scope.treeData.workflow_job_template_obj = $scope.workflowJobTemplateObj;
|
||||||
|
|
||||||
|
$scope.treeDataMaster = angular.copy($scope.treeData.data);
|
||||||
|
$scope.showManualControls = false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
let getNodes = function(){
|
||||||
|
// Get the workflow nodes
|
||||||
|
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 {
|
||||||
|
// This is the last page
|
||||||
|
buildTreeFromNodes();
|
||||||
|
}
|
||||||
|
}, function(error){
|
||||||
|
ProcessErrors($scope, error.data, error.status, form, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to get workflow job template nodes. GET returned ' +
|
||||||
|
'status: ' + error.status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetNodeForm() {
|
function resetNodeForm() {
|
||||||
@@ -155,6 +202,7 @@ export default ['$scope', 'WorkflowService', 'generateList', 'TemplateList', 'Pr
|
|||||||
data: buildSendableNodeData()
|
data: buildSendableNodeData()
|
||||||
})
|
})
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
|
params.node.isNew = false;
|
||||||
continueRecursing(data.data.id);
|
continueRecursing(data.data.id);
|
||||||
}, function(error) {
|
}, function(error) {
|
||||||
ProcessErrors($scope, error.data, error.status, form, {
|
ProcessErrors($scope, error.data, error.status, form, {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ export default ['templateUrl', 'CreateDialog', 'Wait', '$state',
|
|||||||
function(templateUrl, CreateDialog, Wait, $state) {
|
function(templateUrl, CreateDialog, Wait, $state) {
|
||||||
return {
|
return {
|
||||||
scope: {
|
scope: {
|
||||||
treeData: '=',
|
workflowJobTemplateObj: '=',
|
||||||
canAddWorkflowJobTemplate: '='
|
canAddWorkflowJobTemplate: '='
|
||||||
},
|
},
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default [function(){
|
export default ['$q', function($q){
|
||||||
return {
|
return {
|
||||||
searchTree: function(params) {
|
searchTree: function(params) {
|
||||||
// params.element
|
// params.element
|
||||||
@@ -129,6 +129,8 @@ export default [function(){
|
|||||||
buildTree: function(params) {
|
buildTree: function(params) {
|
||||||
//params.workflowNodes
|
//params.workflowNodes
|
||||||
|
|
||||||
|
let deferred = $q.defer();
|
||||||
|
|
||||||
let _this = this;
|
let _this = this;
|
||||||
|
|
||||||
let treeData = {
|
let treeData = {
|
||||||
@@ -185,7 +187,9 @@ export default [function(){
|
|||||||
treeData.data.children.push(branch);
|
treeData.data.children.push(branch);
|
||||||
});
|
});
|
||||||
|
|
||||||
return treeData;
|
deferred.resolve(treeData);
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
buildBranch: function(params) {
|
buildBranch: function(params) {
|
||||||
// params.nodeId
|
// params.nodeId
|
||||||
|
|||||||
Reference in New Issue
Block a user