There will be a short maintenance break on Wed 27.10. at 12:00. Estimated time 30 minutes.

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

Added missing requirements

parent 4958ffad
...@@ -14,8 +14,8 @@ from flask_cors import CORS, cross_origin ...@@ -14,8 +14,8 @@ from flask_cors import CORS, cross_origin
app = Flask(__name__) app = Flask(__name__)
CORS(app) #CORS(app)
# CORS(app, resources={r"/*": {"cors_allowed_origins":"*"} } ) CORS(app, resources={r"/*": {"cors_allowed_origins":"*"} } )
#app.config['BABEL_DEFAULT_LOCALE'] = 'fin' #app.config['BABEL_DEFAULT_LOCALE'] = 'fin'
#app.config['BABEL_TRANSLATION_DIRECTORIES'] ='C:/Users/Timo/git/pet-rating/app/translations' #app.config['BABEL_TRANSLATION_DIRECTORIES'] ='C:/Users/Timo/git/pet-rating/app/translations'
......
...@@ -1045,11 +1045,13 @@ def remove_rows(rows): ...@@ -1045,11 +1045,13 @@ def remove_rows(rows):
@socketio.on('connect', namespace="/create_embody") @socketio.on('connect', namespace="/create_embody")
def start_create_embody(): def start_create_embody():
print('io connected')
emit('success', {'connection': 'on'}) emit('success', {'connection': 'on'})
@socketio.on('draw', namespace="/create_embody") @socketio.on('draw', namespace="/create_embody")
def create_embody(meta): def create_embody(meta):
print("draw initialized")
page = meta["page"] page = meta["page"]
embody = meta["embody"] embody = meta["embody"]
img_path = embody_plot.get_coordinates(page, embody) img_path = embody_plot.get_coordinates(page, embody)
...@@ -1059,6 +1061,7 @@ def create_embody(meta): ...@@ -1059,6 +1061,7 @@ def create_embody(meta):
@socketio.on('connect', namespace="/download_csv") @socketio.on('connect', namespace="/download_csv")
def start_download_csv(): def start_download_csv():
print('io connected')
emit('success', {'connection': 'Start generating CSV file'}) emit('success', {'connection': 'Start generating CSV file'})
...@@ -1073,7 +1076,7 @@ def download_csv(meta): ...@@ -1073,7 +1076,7 @@ def download_csv(meta):
emit('timeout', {'exc': str(data)}) emit('timeout', {'exc': str(data)})
return return
# create temporary file # create temporary file
fd, path = mkstemp() fd, path = mkstemp()
with os.fdopen(fd, 'w') as tmp: with os.fdopen(fd, 'w') as tmp:
tmp.write(data) tmp.write(data)
...@@ -1082,14 +1085,14 @@ def download_csv(meta): ...@@ -1082,14 +1085,14 @@ def download_csv(meta):
# return path and filename to front so user can start downloading # return path and filename to front so user can start downloading
filename = "experiment_{}_{}".format( filename = "experiment_{}_{}".format(
exp_id, date.today().strftime("%Y-%m-%d")) exp_id, date.today().strftime("%Y-%m-%d"))
path = path.split('/')[-1] path = path.split('/')[-1]
emit('file_ready', {'path': path, 'filename': filename}) emit('file_ready', {'path': path, 'filename': filename})
@socketio.on('end', namespace="/download_csv") @socketio.on('end', namespace="/download_csv")
def end_download_csv(): def end_download_csv():
# TODO: not working solution... db session keeps hanging after socket session has ended # TODO: not working solution... db session keeps hanging after socket session has ended
# mysqld timeout is set to 180s, so it kills hanging connections, but this is not a good solution # mysqld timeout is set to 180s, so it kills hanging connections, but this is not a good solution
db.session.close() db.session.close()
......
$(document).ready(function () {
var drawButtons = $(".embody-get-drawing");
$(document).ready(function()  { var imageContainer = $(".embody-image-container");
var progressBarContainer = $(".progress");
var drawButtons = $(".embody-get-drawing"); var progressBar = $("#image-loading-progress");
var imageContainer = $(".embody-image-container")
var progressBarContainer = $(".progress") // With sockets
var progressBar = $("#image-loading-progress") function initConnection(socket) {
socket.on("success", function (msg) {
// With sockets console.log(msg);
function initConnection(socket) { });
socket.on('success', function(msg) { socket.on("progress", function (data) {
console.log(msg) progressBar.width(100 * (data.done / data.from) + "%");
}); });
socket.on('progress', function(data) { socket.on("end", function (img) {
progressBar.width(100*(data.done/data.from) + '%') // kill connection
}); socket.emit("end");
socket.disconnect();
socket.on('end', function(img) {
// kill connection // Draw image to statistic -page
socket.emit('end') var source = img.path;
socket.disconnect() d = new Date();
imageContainer.attr(
// Draw image to statistic -page "src",
var source = img.path "/static/embody_drawings/" + source + "?" + d.getTime()
d = new Date() );
imageContainer.attr("src", "/static/embody_drawings/" + source + "?" +d.getTime())
// Remove progress bar
// Remove progress bar progressBarContainer.addClass("hidden");
progressBarContainer.addClass("hidden") progressBar.width("0%");
progressBar.width('0%') });
}); }
}
drawButtons.click(function (event) {
event.preventDefault();
drawButtons.click(function(event) {
event.preventDefault() console.log("SADATDS");
// Init socket // Init socket
var socket = io.connect(getDrawingURI); var socket = io.connect(getDrawingURI);
initConnection(socket) initConnection(socket);
var pageId = this.dataset.value.split('-')[0] var pageId = this.dataset.value.split("-")[0];
var embodyId = this.dataset.value.split('-')[1] var embodyId = this.dataset.value.split("-")[1];
socket.emit('draw', {page:pageId, embody:embodyId}) socket.emit("draw", { page: pageId, embody: embodyId });
progressBarContainer.removeClass("hidden") progressBarContainer.removeClass("hidden");
scrollTo('plotted-image') scrollTo("plotted-image");
}) });
function scrollTo(hash) { function scrollTo(hash) {
$('html, body').animate({ $("html, body").animate(
'scrollTop': $('#'+hash).offset().top - 250 {
}, 500); scrollTop: $("#" + hash).offset().top - 250,
} },
}) 500
);
}
});
const baseURI = "localhost:8000/";
const baseURI = 'localhost/';
//const baseURI = 'http://onni.utu.fi/'; //const baseURI = 'http://onni.utu.fi/';
var exportURL = baseURI + 'download_csv'; var exportURL = baseURI + "download_csv";
var getDrawingURI = baseURI + 'create_embody'; var getDrawingURI = baseURI + "create_embody";
\ No newline at end of file
...@@ -6,7 +6,6 @@ Flask-Login==0.4.1 ...@@ -6,7 +6,6 @@ Flask-Login==0.4.1
Flask-Migrate==2.2.1 Flask-Migrate==2.2.1
Flask-Session==0.3.1 Flask-Session==0.3.1
Flask-SocketIO==4.3.0 Flask-SocketIO==4.3.0
# Flask-SocketIO==3.3.2
Flask-SQLAlchemy==2.3.2 Flask-SQLAlchemy==2.3.2
Flask-Uploads==0.2.1 Flask-Uploads==0.2.1
Flask-WTF==0.14.2 Flask-WTF==0.14.2
...@@ -17,13 +16,12 @@ matplotlib==3.0.3 ...@@ -17,13 +16,12 @@ matplotlib==3.0.3
mysql-connector==2.2.9 mysql-connector==2.2.9
networkx==2.2 networkx==2.2
numpy==1.16.2 numpy==1.16.2
Pillow
PyMySQL==0.9.3 PyMySQL==0.9.3
pyparsing==2.3.1 pyparsing==2.3.1
python-dateutil==2.7.3 python-dateutil==2.7.3
python-editor==1.0.3 python-decouple
python-engineio==3.13.0 python-engineio==3.13.0
# python-engineio==3.5.1
# python-socketio==3.1.2
python-socketio==4.6.0 python-socketio==4.6.0
pytz==2018.7 pytz==2018.7
rope==0.12.0 rope==0.12.0
...@@ -33,4 +31,3 @@ uuid==1.30 ...@@ -33,4 +31,3 @@ uuid==1.30
Werkzeug==0.14.1 Werkzeug==0.14.1
WTForms==2.2.1 WTForms==2.2.1
WTForms-SQLAlchemy==0.1 WTForms-SQLAlchemy==0.1
python-decouple
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