Commit ea9b8649 authored by Ossi Laine's avatar Ossi Laine
Browse files

Cleaning code

parent cc60ad37
from app import socketio
from flask_socketio import emit
import embody_plot
import os
import secrets
import json
from datetime import datetime, date
from datetime import date
from flask_socketio import emit
from sqlalchemy import and_
from flask_login import login_required
from werkzeug import secure_filename
from flask import (
Flask,
render_template,
request,
session,
flash,
redirect,
url_for,
Blueprint,
jsonify
Blueprint
)
from wtforms import Form
from sqlalchemy import and_, update
from flask_login import login_required
from werkzeug import secure_filename
from app import app, db
from app import app, db, socketio
from app.routes import APP_ROOT
from app.models import background_question, experiment
from app.models import background_question_answer
from app.models import page, question
from app.models import background_question_option
from app.models import answer_set, answer, forced_id
from app.models import user, trial_randomization
from app.models import trial_randomization
from app.models import embody_answer, embody_question
from app.forms import (
CreateBackgroundQuestionForm,
......@@ -41,7 +32,9 @@ from app.forms import (
EditPageForm, RemoveExperimentForm, GenerateIdForm, CreateEmbodyForm
)
from app.utils import get_mean_from_slider_answers, map_answers_to_questions, \
saved_data_as_file, timeit, generate_csv
generate_csv
import embody_plot
# Stimuli upload folder setting
#APP_ROOT = os.path.dirname(os.path.abspath(__file__))
......
import os
import random
import secrets
from datetime import datetime, date
import json
from datetime import datetime
from flask import (render_template,
request,
......@@ -16,9 +15,9 @@ from flask_login import current_user, login_user, logout_user, login_required
from app import app, db
from app.models import background_question, experiment
from app.models import background_question_answer
from app.models import page, question, embody_question, embody_answer
from app.models import page
from app.models import background_question_option
from app.models import answer_set, answer, forced_id
from app.models import answer_set, forced_id
from app.models import user, trial_randomization
from app.forms import LoginForm, RegisterForm, StartWithIdForm
......
......@@ -21,17 +21,18 @@ $(document).ready(function()  {
});
socket.on('progress', function(data) {
console.log(data)
progressBar.width(100*(data.done/data.from) + '%')
});
socket.on('timeout', function(data) {
console.log("timeout error", data.exc)
// kill connection
socket.disconnect()
exportButton.text('Export results')
exportButton.removeClass('disabled')
progressBarContainer.addClass("hidden")
// show error
exportLinkContainer.removeClass("hidden")
exportError.text('Error: ' + data.exc)
});
......@@ -41,18 +42,18 @@ $(document).ready(function()  {
exportButton.text('File is ready!')
// show link
exportLinkContainer.removeClass("hidden")
exportLink.text('Download: ' + file.filename + '.csv')
// set filename to exportlink
var href = exportLink.attr('href');
href += '&path=' + file.path
$(exportLink).attr('href', href);
// Remove progress bar
progressBarContainer.addClass("hidden")
progressBar.width('0%')
exportLink.text('Download: ' + file.filename + '.csv')
});
}
......@@ -64,11 +65,9 @@ $(document).ready(function()  {
var socket = io.connect(exportURL);
initConnection(socket)
// start generating csv file...
socket.emit('generate_csv', {exp_id: this.dataset.value})
progressBarContainer.removeClass("hidden")
})
})
......@@ -40,37 +40,13 @@ $(document).ready(function()  {
var socket = io.connect(getDrawingURI);
initConnection(socket)
//
var pageId = this.dataset.value.split('-')[0]
var embodyId = this.dataset.value.split('-')[1]
console.log(pageId)
console.log(embodyId)
socket.emit('draw', {page:pageId, embody:embodyId})
progressBarContainer.removeClass("hidden")
scrollTo('plotted-image')
/*
With AJAX -calls
var spinner = $(event.target.firstElementChild)
spinner.removeClass("hidden")
$.ajax({
url: getDrawingURI,
method: 'POST',
data: {page:pageId}
}).done(function(data) {
var source = JSON.parse(data).path;
console.log(source)
d = new Date()
imageContainer.attr("src", "/static/" + source + "?" +d.getTime())
spinner.addClass("hidden")
})
*/
})
function scrollTo(hash) {
......@@ -78,5 +54,4 @@ $(document).ready(function()  {
'scrollTop': $('#'+hash).offset().top - 250
}, 500);
}
})
......@@ -39,4 +39,4 @@ class Config(object):
TEMPLATES_AUTO_RELOAD = True
DEBUG = True
DEBUG = False
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment