From b9ceae1564ea3bfa5648ec2e565eb0e96ea047e1 Mon Sep 17 00:00:00 2001 From: Zachary Sloan Date: Thu, 28 Aug 2014 20:37:05 +0000 Subject: Added a validation that warns the user of the number of permutations for pyLMM is more than 20 (due to speed) Changed the port in the flask settings to 5002 due to adding the new production server branch --- wqflask/cfg/default_settings.py | 2 +- wqflask/maintenance/our_settings.py | 1 - .../static/new/javascript/validation.coffee | 11 +++ .../wqflask/static/new/javascript/validation.js | 102 ++++++++++++--------- .../templates/show_trait_mapping_tools.html | 6 +- 5 files changed, 77 insertions(+), 45 deletions(-) delete mode 120000 wqflask/maintenance/our_settings.py diff --git a/wqflask/cfg/default_settings.py b/wqflask/cfg/default_settings.py index e638a9c0..c9d2a934 100755 --- a/wqflask/cfg/default_settings.py +++ b/wqflask/cfg/default_settings.py @@ -1,6 +1,6 @@ LOGFILE = """/tmp/flask_gn_log""" -SERVER_PORT = 5000 +SERVER_PORT = 5002 #This is needed because Flask turns key errors into a #400 bad request response with no exception/log diff --git a/wqflask/maintenance/our_settings.py b/wqflask/maintenance/our_settings.py deleted file mode 120000 index b14de960..00000000 --- a/wqflask/maintenance/our_settings.py +++ /dev/null @@ -1 +0,0 @@ -../../../lei_settings.py \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/validation.coffee b/wqflask/wqflask/static/new/javascript/validation.coffee index f28e9bd7..901f8c7c 100755 --- a/wqflask/wqflask/static/new/javascript/validation.coffee +++ b/wqflask/wqflask/static/new/javascript/validation.coffee @@ -27,5 +27,16 @@ $ -> console.log("input isn't valid") $('#remove_samples_invalid').show() + validate_pylmm_permutation = -> + ### + Check if number of permutations is high (and will take long to compute) + ### + input = $('input[name=num_perm_pylmm]').val() + console.log("input:", input) + if input > 20 + $('#permutations_alert').show() + else + $('#permutations_alert').hide() + $('input[name=num_perm_pylmm]').change(validate_pylmm_permutation) $('#remove_samples_field').change(validate_remove_samples) \ No newline at end of file diff --git a/wqflask/wqflask/static/new/javascript/validation.js b/wqflask/wqflask/static/new/javascript/validation.js index 9536491b..24a2a5b0 100755 --- a/wqflask/wqflask/static/new/javascript/validation.js +++ b/wqflask/wqflask/static/new/javascript/validation.js @@ -1,47 +1,65 @@ // Generated by CoffeeScript 1.7.1 -$(function() { - var remove_samples_is_valid, validate_remove_samples; - remove_samples_is_valid = function(input) { - var new_splats, pattern, splat, splats, _i, _len; - if (_.trim(input).length === 0) { +(function() { + $(function() { + var remove_samples_is_valid, validate_pylmm_permutation, validate_remove_samples; + remove_samples_is_valid = function(input) { + var new_splats, pattern, splat, splats, _i, _len; + if (_.trim(input).length === 0) { + return true; + } + splats = input.split(","); + new_splats = (function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = splats.length; _i < _len; _i++) { + input = splats[_i]; + _results.push(_.trim(input)); + } + return _results; + })(); + console.log("new_splats:", new_splats); + pattern = /^\d+\s*(?:-\s*\d+)?\s*$/; + for (_i = 0, _len = new_splats.length; _i < _len; _i++) { + splat = new_splats[_i]; + console.log("splat is:", splat); + if (!splat.match(pattern)) { + return false; + } + } return true; - } - splats = input.split(","); - new_splats = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = splats.length; _i < _len; _i++) { - input = splats[_i]; - _results.push(_.trim(input)); + }; + validate_remove_samples = function() { + + /* + Check if input for the remove samples function is valid and notify the user if not + */ + var input; + input = $('#remove_samples_field').val(); + console.log("input is:", input); + if (remove_samples_is_valid(input)) { + console.log("input is valid"); + return $('#remove_samples_invalid').hide(); + } else { + console.log("input isn't valid"); + return $('#remove_samples_invalid').show(); } - return _results; - })(); - console.log("new_splats:", new_splats); - pattern = /^\d+\s*(?:-\s*\d+)?\s*$/; - for (_i = 0, _len = new_splats.length; _i < _len; _i++) { - splat = new_splats[_i]; - console.log("splat is:", splat); - if (!splat.match(pattern)) { - return false; + }; + validate_pylmm_permutation = function() { + + /* + Check if number of permutations is high (and will take long to compute) + */ + var input; + input = $('input[name=num_perm_pylmm]').val(); + console.log("input:", input); + if (input > 20) { + return $('#permutations_alert').show(); + } else { + return $('#permutations_alert').hide(); } - } - return true; - }; - validate_remove_samples = function() { + }; + $('input[name=num_perm_pylmm]').change(validate_pylmm_permutation); + return $('#remove_samples_field').change(validate_remove_samples); + }); - /* - Check if input for the remove samples function is valid and notify the user if not - */ - var input; - input = $('#remove_samples_field').val(); - console.log("input is:", input); - if (remove_samples_is_valid(input)) { - console.log("input is valid"); - return $('#remove_samples_invalid').hide(); - } else { - console.log("input isn't valid"); - return $('#remove_samples_invalid').show(); - } - }; - return $('#remove_samples_field').change(validate_remove_samples); -}); +}).call(this); diff --git a/wqflask/wqflask/templates/show_trait_mapping_tools.html b/wqflask/wqflask/templates/show_trait_mapping_tools.html index 61fb98de..d6426f0c 100755 --- a/wqflask/wqflask/templates/show_trait_mapping_tools.html +++ b/wqflask/wqflask/templates/show_trait_mapping_tools.html @@ -151,8 +151,12 @@
- +
+ +
+
-- cgit v1.2.3