Skip to content

Commit 7a840ef

Browse files
author
Mark Robinson
committed
Add fullscreen button to enlarge graph
1 parent c0a0ddc commit 7a840ef

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-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: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,36 @@ 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+
setTimeout(function() {
121+
var fullGraph = svgPanZoom('#graphFullscreen', {
122+
zoomEnabled: true,
123+
controlIconsEnabled: true,
124+
customEventsHandler: eventHandler
125+
});
126+
127+
// Resizing window also resizes the graph
128+
$(window).resize(function(){
129+
fullGraph.resize();
130+
fullGraph.fit();
131+
fullGraph.center();
132+
});
133+
}, 400);
134+
});
110135
});
111136

112137
/**

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)