mirror of
https://github.com/ansible/awx.git
synced 2026-05-08 09:57:35 -02:30
Added tooltips to workflow nodes with long resource names
This commit is contained in:
@@ -114,3 +114,23 @@
|
|||||||
padding: 1px 3px;
|
padding: 1px 3px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
.WorkflowChart-nameText {
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.WorkflowChart-tooltipContents {
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #707070;
|
||||||
|
color: #FFFFFF;
|
||||||
|
border-radius: 4px;
|
||||||
|
word-wrap: break-word;
|
||||||
|
max-width: 325px;
|
||||||
|
}
|
||||||
|
.WorkflowChart-tooltipArrow {
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-left: 10px solid transparent;
|
||||||
|
border-right: 10px solid transparent;
|
||||||
|
border-top: 10px solid #707070;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|||||||
@@ -23,12 +23,13 @@ export default [ '$state','moment', '$timeout', '$window',
|
|||||||
|
|
||||||
let margin = {top: 20, right: 20, bottom: 20, left: 20},
|
let margin = {top: 20, right: 20, bottom: 20, left: 20},
|
||||||
i = 0,
|
i = 0,
|
||||||
nodeW = 120,
|
nodeW = 180,
|
||||||
nodeH = 60,
|
nodeH = 60,
|
||||||
rootW = 60,
|
rootW = 60,
|
||||||
rootH = 40,
|
rootH = 40,
|
||||||
startNodeOffsetY = scope.mode === 'details' ? 17 : 10,
|
startNodeOffsetY = scope.mode === 'details' ? 17 : 10,
|
||||||
verticalSpaceBetweenNodes = 20,
|
verticalSpaceBetweenNodes = 20,
|
||||||
|
maxNodeTextLength = 27,
|
||||||
windowHeight,
|
windowHeight,
|
||||||
windowWidth,
|
windowWidth,
|
||||||
tree,
|
tree,
|
||||||
@@ -125,11 +126,8 @@ export default [ '$state','moment', '$timeout', '$window',
|
|||||||
// TODO: this function is hacky and we need to come up with a better solution
|
// TODO: this function is hacky and we need to come up with a better solution
|
||||||
// see: http://stackoverflow.com/questions/15975440/add-ellipses-to-overflowing-text-in-svg#answer-27723752
|
// see: http://stackoverflow.com/questions/15975440/add-ellipses-to-overflowing-text-in-svg#answer-27723752
|
||||||
function wrap(text) {
|
function wrap(text) {
|
||||||
|
if(text && text.length > maxNodeTextLength) {
|
||||||
let maxLength = scope.mode === 'details' ? 14 : 15;
|
return text.substring(0,maxNodeTextLength) + '...';
|
||||||
|
|
||||||
if(text && text.length > maxLength) {
|
|
||||||
return text.substring(0,maxLength) + '...';
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return text;
|
return text;
|
||||||
@@ -216,7 +214,7 @@ export default [ '$state','moment', '$timeout', '$window',
|
|||||||
links = tree.links(nodes);
|
links = tree.links(nodes);
|
||||||
let node = svgGroup.selectAll("g.node")
|
let node = svgGroup.selectAll("g.node")
|
||||||
.data(nodes, function(d) {
|
.data(nodes, function(d) {
|
||||||
d.y = d.depth * 180;
|
d.y = d.depth * 240;
|
||||||
return d.id || (d.id = ++i);
|
return d.id || (d.id = ++i);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -347,11 +345,32 @@ export default [ '$state','moment', '$timeout', '$window',
|
|||||||
.call(edit_node)
|
.call(edit_node)
|
||||||
.on("mouseover", function(d) {
|
.on("mouseover", function(d) {
|
||||||
if(!d.isStartNode) {
|
if(!d.isStartNode) {
|
||||||
|
let resourceName = (d.unifiedJobTemplate && d.unifiedJobTemplate.name) ? d.unifiedJobTemplate.name : "";
|
||||||
|
if(resourceName && resourceName.length > maxNodeTextLength) {
|
||||||
|
// Render the tooltip quickly in the dom and then remove. This lets us know how big the tooltip is so that we can place
|
||||||
|
// it properly on the workflow
|
||||||
|
let tooltipDimensionChecker = $("<div style='visibility:hidden;font-size:12px;position:absolute;' class='WorkflowChart-tooltipContents'><span>" + resourceName + "</span></div>");
|
||||||
|
$('body').append(tooltipDimensionChecker);
|
||||||
|
let tipWidth = $(tooltipDimensionChecker).outerWidth();
|
||||||
|
let tipHeight = $(tooltipDimensionChecker).outerHeight();
|
||||||
|
$(tooltipDimensionChecker).remove();
|
||||||
|
|
||||||
|
thisNode.append("foreignObject")
|
||||||
|
.attr("x", (nodeW / 2) - (tipWidth / 2))
|
||||||
|
.attr("y", (tipHeight + 15) * -1)
|
||||||
|
.attr("width", tipWidth)
|
||||||
|
.attr("height", tipHeight+20)
|
||||||
|
.attr("class", "WorkflowChart-tooltip")
|
||||||
|
.html(function(){
|
||||||
|
return "<div class='WorkflowChart-tooltipContents'><span>" + resourceName + "</span></div><div class='WorkflowChart-tooltipArrow'></div>";
|
||||||
|
});
|
||||||
|
}
|
||||||
d3.select("#node-" + d.id)
|
d3.select("#node-" + d.id)
|
||||||
.classed("hovering", true);
|
.classed("hovering", true);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on("mouseout", function(d){
|
.on("mouseout", function(d){
|
||||||
|
$('.WorkflowChart-tooltip').remove();
|
||||||
if(!d.isStartNode) {
|
if(!d.isStartNode) {
|
||||||
d3.select("#node-" + d.id)
|
d3.select("#node-" + d.id)
|
||||||
.classed("hovering", false);
|
.classed("hovering", false);
|
||||||
|
|||||||
Reference in New Issue
Block a user