Remove spinners if there is no data, push footer down to the bottom (#396)

* Remove spinners if there is no data
* Push footer down to the bottom properly in the admin panel
This commit is contained in:
Kevin Chung
2017-09-29 17:31:46 -04:00
committed by GitHub
parent 897916b1b5
commit 0aae79d176
8 changed files with 54 additions and 18 deletions

View File

@@ -106,12 +106,17 @@ table{
line-height: 66px; line-height: 66px;
} }
.spinner { .fa.spinner {
margin-top: 225px; margin-top: 225px;
text-align: center; text-align: center;
opacity: 0.5; opacity: 0.5;
} }
.spinner-error {
text-align: center;
opacity: 0.5;
}
#score-graph{ #score-graph{
height: 450px; height: 450px;
display: block; display: block;
@@ -495,7 +500,7 @@ table{
.footer { .footer {
position: absolute; position: absolute;
left: 0; left: 0;
padding: 0; bottom: 0;
padding: 0; padding: 0;
margin: 0; margin: 0;
width: 100%; width: 100%;

View File

@@ -66,9 +66,12 @@
<div class="container"> <div class="container">
{% block content %} {% block content %}
{% endblock %} {% endblock %}
<div class="navbar navbar-bottom footer"> </div>
<p class="text-muted text-center"><a style="text-decoration:none;" href="https://ctfd.io"><sub>Powered by CTFd</sub></p>
</div> <div class="navbar navbar-bottom footer">
<p class="text-muted text-center">
<a style="text-decoration:none;" href="https://ctfd.io"><sub>Powered by CTFd</sub></a>
</p>
</div> </div>
</div> </div>
<script src="{{ request.script_root }}/themes/admin/static/js/vendor/jquery.min.js"></script> <script src="{{ request.script_root }}/themes/admin/static/js/vendor/jquery.min.js"></script>

View File

@@ -89,6 +89,7 @@
</h2> </h2>
{% if solves %}
<div id="keys-pie-graph"> <div id="keys-pie-graph">
<div class="text-center"> <div class="text-center">
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw spinner"></i> <i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw spinner"></i>
@@ -104,6 +105,11 @@
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw spinner"></i> <i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw spinner"></i>
</div> </div>
</div> </div>
{% else %}
<div class="row">
<div class="text-center"><h3 class="spinner-error">No solves yet</h3></div>
</div>
{% endif %}
<table class="table table-striped"> <table class="table table-striped">
<h3>IP Addresses</h3> <h3>IP Addresses</h3>

View File

@@ -116,12 +116,18 @@ table{
clear: both; clear: both;
} }
.spinner { .fa.spinner {
margin-top: 225px; margin-top: 225px;
text-align: center; text-align: center;
opacity: 0.5; opacity: 0.5;
} }
.spinner-error {
padding-top: 210px;
text-align: center;
opacity: 0.5;
}
#keys-pie-graph{ #keys-pie-graph{
width: 50%; width: 50%;
float: left; float: left;

View File

@@ -1,11 +1,16 @@
function updatescores () { function updatescores () {
$.get(script_root + '/scores', function( data ) { $.get(script_root + '/scores', function( data ) {
teams = $.parseJSON(JSON.stringify(data)); var teams = $.parseJSON(JSON.stringify(data));
$('#scoreboard > tbody').empty() $('#scoreboard > tbody').empty()
for (var i = 0; i < teams['standings'].length; i++) { for (var i = 0; i < teams['standings'].length; i++) {
row = "<tr><td>{0}</td><td><a href='/team/{1}'>{2}</a></td><td>{3}</td></tr>".format(i+1, teams['standings'][i].id, htmlentities(teams['standings'][i].team), teams['standings'][i].score) var row = "<tr><td>{0}</td><td><a href='/team/{1}'>{2}</a></td><td>{3}</td></tr>".format(
i+1,
teams['standings'][i].id,
htmlentities(teams['standings'][i].team),
teams['standings'][i].score
);
$('#scoreboard > tbody').append(row) $('#scoreboard > tbody').append(row)
}; }
}); });
} }
@@ -18,15 +23,17 @@ function cumulativesum (arr) {
} }
function UTCtoDate(utc){ function UTCtoDate(utc){
var d = new Date(0) var d = new Date(0);
d.setUTCSeconds(utc) d.setUTCSeconds(utc);
return d; return d;
} }
function scoregraph () { function scoregraph () {
$.get(script_root + '/top/10', function( data ) { $.get(script_root + '/top/10', function( data ) {
var places = $.parseJSON(JSON.stringify(data)); var places = $.parseJSON(JSON.stringify(data));
places = places['places']; places = places['places'];
if (Object.keys(places).length == 0 ){ if (Object.keys(places).length === 0 ){
$('#score-graph').html('<div class="text-center"><h3 class="spinner-error">No solves yet</h3></div>'); // Replace spinner
return; return;
} }
@@ -46,7 +53,7 @@ function scoregraph () {
y: team_score, y: team_score,
mode: 'lines+markers', mode: 'lines+markers',
name: places[teams[i]]['name'] name: places[teams[i]]['name']
} };
traces.push(trace); traces.push(trace);
} }
@@ -65,7 +72,7 @@ function scoregraph () {
}; };
console.log(traces); console.log(traces);
$('#score-graph').empty() // Remove spinners $('#score-graph').empty(); // Remove spinners
Plotly.newPlot('score-graph', traces, layout); Plotly.newPlot('score-graph', traces, layout);
}); });
} }

View File

@@ -22,15 +22,16 @@ function cumulativesum (arr) {
} }
function scoregraph() { function scoregraph() {
var times = [] var times = [];
var scores = [] var scores = [];
var teamname = $('#team-id').text() var teamname = $('#team-id').text();
$.get(script_root + '/solves/' + teamid(), function (data) { $.get(script_root + '/solves/' + teamid(), function (data) {
var solves = $.parseJSON(JSON.stringify(data)); var solves = $.parseJSON(JSON.stringify(data));
solves = solves['solves']; solves = solves['solves'];
if (solves.length == 0) if (solves.length == 0) {
return; return;
}
for (var i = 0; i < solves.length; i++) { for (var i = 0; i < solves.length; i++) {
var date = moment(solves[i].time * 1000); var date = moment(solves[i].time * 1000);

View File

@@ -32,6 +32,7 @@
</div> </div>
<br> <br>
{% if teams %}
<table id="scoreboard" class="table table-striped"> <table id="scoreboard" class="table table-striped">
<thead> <thead>
<tr> <tr>
@@ -50,6 +51,7 @@
</tbody> </tbody>
</table> </table>
{% endif %} {% endif %}
{% endif %}
</div> </div>
{% endblock %} {% endblock %}

View File

@@ -41,6 +41,7 @@
<br> <br>
{% if solves %}
<div id="keys-pie-graph"> <div id="keys-pie-graph">
<div class="text-center"> <div class="text-center">
<i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw spinner"></i> <i class="fa fa-circle-o-notch fa-spin fa-3x fa-fw spinner"></i>
@@ -104,6 +105,9 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{% else %}
<div class="text-center"><h3 class="spinner-error">No solves yet</h3></div>
{% endif %}
{% endif %} {% endif %}
</div> </div>
{% endblock %} {% endblock %}
@@ -111,5 +115,7 @@
{% block scripts %} {% block scripts %}
<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/vendor/plotly.min.js"></script> <script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/vendor/plotly.min.js"></script>
<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/utils.js"></script> <script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/utils.js"></script>
{% if solves %}
<script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/team.js"></script> <script src="{{ request.script_root }}/themes/{{ ctf_theme() }}/static/js/team.js"></script>
{% endif %}
{% endblock %} {% endblock %}