reload only on selected pages
Doesn't refresh page when a form has been edited
This commit is contained in:
@@ -51,6 +51,11 @@
|
|||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
{% block title %}Rowsandall Recent Graphs{% endblock %}
|
{% block title %}Rowsandall Recent Graphs{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Recent Graphs</h1>
|
<h1>Recent Graphs</h1>
|
||||||
|
|
||||||
|
|||||||
30
rowers/templates/monitorjobs.html
Normal file
30
rowers/templates/monitorjobs.html
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<script type='text/javascript'
|
||||||
|
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var previous = null;
|
||||||
|
var current = null;
|
||||||
|
var formNotChanged = true;
|
||||||
|
(function checkJobs() {
|
||||||
|
console.log('polling');
|
||||||
|
console.log(formNotChanged)
|
||||||
|
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/list-jobs/', function(json) {
|
||||||
|
current = JSON.stringify(json);
|
||||||
|
$('form').each(function() {
|
||||||
|
$(this).change(function() {
|
||||||
|
formNotChanged = false;
|
||||||
|
console.log("Form Changed");
|
||||||
|
console.log(formNotChanged)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (previous && current && previous !== current && formNotChanged) {
|
||||||
|
console.log('refresh');
|
||||||
|
location.reload();
|
||||||
|
};
|
||||||
|
previous = current;
|
||||||
|
});
|
||||||
|
setTimeout(checkJobs, 15000);
|
||||||
|
}());
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -2,6 +2,10 @@
|
|||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}Workouts{% endblock %}
|
{% block title %}Workouts{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -3,6 +3,9 @@
|
|||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
|
|
||||||
{% block title %}Workouts{% endblock %}
|
{% block title %}Workouts{% endblock %}
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,11 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="page" class="grid_12 alpha">
|
<div id="page" class="grid_12 alpha">
|
||||||
<div class="grid_10 prefix_2 alpha">
|
<div class="grid_10 prefix_2 alpha">
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
{% load tz %}
|
{% load tz %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}Change Workout {% endblock %}
|
{% block title %}Change Workout {% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|||||||
@@ -13,6 +13,13 @@
|
|||||||
{% block og_description %}{{ workout.name }}
|
{% block og_description %}{{ workout.name }}
|
||||||
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
<script type='text/javascript'
|
||||||
|
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="workouts" class="grid_6 alpha">
|
<div id="workouts" class="grid_6 alpha">
|
||||||
|
|
||||||
@@ -89,8 +96,9 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid_6 alpha">
|
<div id="form-div" class="grid_6 alpha">
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
<form id="importantform"
|
||||||
|
enctype="multipart/form-data" action="" method="post">
|
||||||
<table width=100%>
|
<table width=100%>
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
|
{% block scripts %}
|
||||||
|
{% include "monitorjobs.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}{{ workout.name }} {% endblock %}
|
{% block title %}{{ workout.name }} {% endblock %}
|
||||||
{% block og_title %}{{ workout.name }} {% endblock %}
|
{% block og_title %}{{ workout.name }} {% endblock %}
|
||||||
|
|||||||
@@ -9,32 +9,7 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script type='text/javascript'
|
{% block scripts %} {% endblock %}
|
||||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
window.jQuery || document.write('<script src="/static/js/jquery-3.1.0.js"><' + '/script>');
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
var previous = null;
|
|
||||||
var current = null;
|
|
||||||
(function checkJobs() {
|
|
||||||
console.log('polling');
|
|
||||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/list-jobs/', function(json) {
|
|
||||||
current = JSON.stringify(json);
|
|
||||||
if (previous && current && previous !== current) {
|
|
||||||
console.log('refresh');
|
|
||||||
location.reload();
|
|
||||||
};
|
|
||||||
previous = current;
|
|
||||||
});
|
|
||||||
setTimeout(checkJobs, 15000);
|
|
||||||
}());
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
||||||
{% analytical_head_top %}
|
{% analytical_head_top %}
|
||||||
|
|||||||
Reference in New Issue
Block a user