with jquery to refresh when tasks are complete
jquery lives in basebase.html. Perhaps should live in individual pages
This commit is contained in:
@@ -65,7 +65,7 @@ def processattachment(rower, fileobj, title, uploadoptions):
|
||||
workoutcsvfilename = workout.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = workoutcsvfilename + timestr + '.png'
|
||||
result = uploads.make_plot(
|
||||
result,jobid = uploads.make_plot(
|
||||
workout.user, workout, workoutcsvfilename,
|
||||
workout.csvfilename,
|
||||
plottype, title,
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<h1>Your Tasks Status</h1>
|
||||
<p>Manage the asynchronous tasks running for you</p>
|
||||
|
||||
|
||||
@@ -175,11 +175,11 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
|
||||
|
||||
|
||||
if settings.DEBUG:
|
||||
res = handle_makeplot.delay(f1,f2,title,
|
||||
job = handle_makeplot.delay(f1,f2,title,
|
||||
hrpwrdata,plotnr,
|
||||
imagename)
|
||||
else:
|
||||
res = queue.enqueue(handle_makeplot,f1,f2,
|
||||
job = queue.enqueue(handle_makeplot,f1,f2,
|
||||
title,hrpwrdata,
|
||||
plotnr,imagename)
|
||||
|
||||
@@ -195,7 +195,7 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
|
||||
width=width,height=height)
|
||||
i.save()
|
||||
|
||||
return i.id
|
||||
return i.id,job.id
|
||||
|
||||
import c2stuff,stravastuff,sporttracksstuff,runkeeperstuff
|
||||
import underarmourstuff,tpstuff
|
||||
|
||||
@@ -208,7 +208,8 @@ def get_job_result(jobid):
|
||||
verbose_job_status = {
|
||||
'updatecp': 'Critical Power Calculation for Ergometer Workouts',
|
||||
'updatecpwater': 'Critical Power Calculation for OTW Workouts',
|
||||
'otwsetpower': 'Rowing Physics OTW Power Calculation'
|
||||
'otwsetpower': 'Rowing Physics OTW Power Calculation',
|
||||
'make_plot': 'Create static chart',
|
||||
}
|
||||
|
||||
def get_job_status(jobid):
|
||||
@@ -3539,7 +3540,7 @@ def oterankings_view(request,theuser=0,
|
||||
request.session['async_tasks'] += [(job.id,'updatecp')]
|
||||
except KeyError:
|
||||
request.session['async_tasks'] = [(job.id,'updatecp')]
|
||||
messages.info(request,'New calculation queued. Refresh page or resubmit the date form to get the result')
|
||||
messages.info(request,'New calculation queued.')
|
||||
|
||||
powerdf = pd.DataFrame({
|
||||
'Delta':delta,
|
||||
@@ -7468,9 +7469,14 @@ def workout_add_chart_view(request,id,plotnr=1):
|
||||
u = w.user.user
|
||||
r = getrower(u)
|
||||
title = w.name
|
||||
res = uploads.make_plot(r,w,f1,w.csvfilename,'timeplot',title,plotnr=plotnr,
|
||||
imagename=imagename)
|
||||
|
||||
res,jobid = uploads.make_plot(
|
||||
r,w,f1,w.csvfilename,'timeplot',title,plotnr=plotnr,
|
||||
imagename=imagename
|
||||
)
|
||||
try:
|
||||
request.session['async_tasks'] += [(jobid,'make_plot')]
|
||||
except KeyError:
|
||||
request.session['async_tasks'] = [(jobid,'make_plot')]
|
||||
|
||||
try:
|
||||
url = request.session['referer']
|
||||
|
||||
@@ -9,6 +9,31 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script>
|
||||
var previous = null;
|
||||
var current = null;
|
||||
$(document).ready(function() {
|
||||
$.getJSON('http://localhost:8000/rowers/list-jobs/', function(json) {
|
||||
current = JSON.stringify(json);
|
||||
previous = current;
|
||||
});
|
||||
console.log('initial poll');
|
||||
});
|
||||
|
||||
setInterval(function() {
|
||||
$.getJSON('http://localhost:8000/rowers/list-jobs/', function(json) {
|
||||
current = JSON.stringify(json);
|
||||
if (previous && current && previous !== current) {
|
||||
console.log('refresh');
|
||||
location.reload();
|
||||
};
|
||||
previous = current;
|
||||
});
|
||||
console.log('polling');
|
||||
}, 15000)
|
||||
</script>
|
||||
|
||||
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
||||
{% analytical_head_top %}
|
||||
{% if GOOGLE_ANALYTICS_PROPERTY_ID %}
|
||||
|
||||
Reference in New Issue
Block a user