Skip to content

Commit e850374

Browse files
authored
Merge pull request #60 from common-workflow-language/fullscreen-graph
Fullscreen button for graph
2 parents 514f730 + c8e432f commit e850374

File tree

3 files changed

+98
-1
lines changed

3 files changed

+98
-1
lines changed

src/main/resources/static/css/main.css

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,44 @@ body {
5555
margin-right: 5px;
5656
}
5757

58+
#fullscreen-open, #fullscreen-close {
59+
cursor: pointer;
60+
font-size: 25px;
61+
position: absolute;
62+
top: 10px;
63+
right: 25px;
64+
opacity: 0.333;
65+
}
66+
67+
#fullscreen-close {
68+
top: 25px;
69+
}
70+
71+
#fullscreen-open:hover, #fullscreen-close:hover {
72+
opacity: 1;
73+
}
74+
75+
#fullScreenGraphModal .modal-dialog {
76+
width: 98%;
77+
height: 92%;
78+
padding: 0;
79+
}
80+
81+
#fullScreenGraphModal .modal-body {
82+
width: 100%;
83+
height: 100%;
84+
}
85+
86+
#fullScreenGraphModal .modal-content {
87+
height: 99%;
88+
}
89+
90+
#graphFullscreen {
91+
background-color: #eeeeee;
92+
width: 100%;
93+
height: 90%;
94+
}
95+
5896
#graph-menu {
5997
margin-bottom: 5px;
6098
}

src/main/resources/static/js/workflow.js

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,51 @@ require(['jquery', 'bootstrap.modal', 'svg-pan-zoom', 'hammerjs'],
102102
};
103103

104104
// Enable svg-pan-zoom on the graph
105-
svgPanZoom('#graph', {
105+
var graph = svgPanZoom('#graph', {
106106
zoomEnabled: true,
107107
controlIconsEnabled: true,
108108
customEventsHandler: eventHandler
109109
});
110+
111+
// Resizing window also resizes the graph
112+
$(window).resize(function(){
113+
graph.resize();
114+
graph.fit();
115+
graph.center();
116+
});
117+
118+
// Enable svg-pan-zoom on fullscreen modal when opened
119+
$('#fullScreenGraphModal').on('shown.bs.modal', function (e) {
120+
// Timeout allows for modal to show
121+
setTimeout(function() {
122+
var fullGraph = svgPanZoom('#graphFullscreen', {
123+
zoomEnabled: true,
124+
controlIconsEnabled: true,
125+
customEventsHandler: eventHandler
126+
});
127+
128+
// Set to same zoom/pan as other graph
129+
fullGraph.zoom(graph.getZoom());
130+
fullGraph.pan(graph.getPan());
131+
132+
// Link the two graphs panning and zooming
133+
fullGraph.setOnZoom(function(level){
134+
graph.zoom(level);
135+
graph.pan(fullGraph.getPan());
136+
});
137+
138+
fullGraph.setOnPan(function(point){
139+
graph.pan(point);
140+
});
141+
142+
// Resizing window also resizes the graph
143+
$(window).resize(function(){
144+
fullGraph.resize();
145+
fullGraph.fit();
146+
fullGraph.center();
147+
});
148+
}, 100);
149+
});
110150
});
111151

112152
/**

src/main/resources/templates/workflow.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@ <h4 class="modal-title" id="dotGraphLabel">Workflow DOT Graph</h4>
9696
</div>
9797
</div>
9898

99+
<!-- Modal for viewing the graph in full screen -->
100+
<div class="modal fade" id="fullScreenGraphModal" tabindex="-1" role="dialog" aria-labelledby="fullScreenGraphLabel">
101+
<div class="modal-dialog" role="document">
102+
<div class="modal-content">
103+
<div class="modal-header">
104+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
105+
<h4 class="modal-title" id="fullScreenGraphLabel">Workflow Graph</h4>
106+
</div>
107+
<div class="modal-body">
108+
<span id="fullscreen-close" data-dismiss="modal" class="close glyphicon glyphicon-resize-full"></span>
109+
<object id="graphFullscreen" th:data="@{'/workflows/' + ${workflow.id} + '/graph/svg'}" type="image/svg+xml">
110+
<img th:src="@{'/workflows/' + ${workflow.id} + '/graph/png'}" alt="workflow graph" />
111+
</object>
112+
</div>
113+
</div>
114+
</div>
115+
</div>
116+
99117
<div class="container">
100118
<div class="row">
101119
<div class="col-md-12" role="main" id="main" th:with="workflowURL=@{'github.com/' + ${workflow.retrievedFrom.owner} + '/' + ${workflow.retrievedFrom.repoName} + '/tree/' + ${workflow.lastCommit} + '/' + ${workflow.retrievedFrom.path}}">
@@ -128,6 +146,7 @@ <h2>Workflow: <span th:text="${workflow.label}">Workflow Name</span></h2>
128146
<div class="row">
129147
<div class="col-md-12">
130148
<div id="visualisation" class="jumbotron">
149+
<span id="fullscreen-open" data-toggle="modal" data-target="#fullScreenGraphModal" class="glyphicon glyphicon-resize-full"></span>
131150
<object id="graph" th:data="@{'/workflows/' + ${workflow.id} + '/graph/svg'}" type="image/svg+xml">
132151
<img th:src="@{'/workflows/' + ${workflow.id} + '/graph/png'}" alt="workflow graph" />
133152
</object>

0 commit comments

Comments
 (0)