From 6d5f6bdc6cfbec0db0a4fa4bbe619b7656bc80df Mon Sep 17 00:00:00 2001 From: worldworm <13227454+worldworm@users.noreply.github.com> Date: Thu, 28 Jan 2021 16:16:55 +0000 Subject: [PATCH 1/2] Add frontend translation timeout parameter #29 --- app/app.py | 8 ++++++-- app/templates/index.html | 2 +- main.py | 5 ++++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/app.py b/app/app.py index 79634f8..9b56f0d 100644 --- a/app/app.py +++ b/app/app.py @@ -13,7 +13,7 @@ def get_remote_address(): return ip -def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=False, frontend_language_source="en", frontend_language_target="en"): +def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=False, frontend_language_source="en", frontend_language_target="en", frontend_timeout=500): from app.init import boot boot() @@ -67,7 +67,7 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa @app.route("/") def index(): - return render_template('index.html', gaId=ga_id) + return render_template('index.html', gaId=ga_id, frontendTimeout=frontend_timeout) @app.route("/languages") def langs(): @@ -274,6 +274,9 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa charLimit: type: integer description: Character input limit for this language (-1 indicates no limit) + frontendTimeout: + type: integer + description: Frontend translation timeout language: type: object properties: @@ -297,6 +300,7 @@ def create_app(char_limit=-1, req_limit=-1, batch_limit=-1, ga_id=None, debug=Fa description: Human-readable language name (in English) """ return jsonify({'charLimit': char_limit, + 'frontendTimeout': frontend_timeout, 'language': { 'source': {'code': frontend_argos_language_source.code, 'name': frontend_argos_language_source.name}, 'target': {'code': frontend_argos_language_target.code, 'name': frontend_argos_language_target.name}} diff --git a/app/templates/index.html b/app/templates/index.html index 3fbe89a..42899b0 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -441,7 +441,7 @@ document.addEventListener('DOMContentLoaded', function(){ }; request.send(data); - }, 300); + }, {{ frontendTimeout }}); }, copyText: function(e){ diff --git a/main.py b/main.py index f526533..348900d 100644 --- a/main.py +++ b/main.py @@ -22,6 +22,8 @@ parser.add_argument('--frontend-language-source', type=str, default="en", metava help='Set frontend default language - source (%(default)s)') parser.add_argument('--frontend-language-target', type=str, default="es", metavar="", help='Set frontend default language - target (%(default)s)') +parser.add_argument('--frontend-timeout', type=int, default=500, metavar="", + help='Set frontend translation timeout (%(default)s)') args = parser.parse_args() @@ -33,7 +35,8 @@ if __name__ == "__main__": ga_id=args.ga_id, debug=args.debug, frontend_language_source=args.frontend_language_source, - frontend_language_target=args.frontend_language_target) + frontend_language_target=args.frontend_language_target, + frontend_timeout=args.frontend_timeout) if args.debug: app.run(host=args.host, port=args.port) else: From a36c3b53f041e9a9182e47aa2faa2758cbbe44dd Mon Sep 17 00:00:00 2001 From: worldworm <13227454+worldworm@users.noreply.github.com> Date: Thu, 28 Jan 2021 17:20:13 +0100 Subject: [PATCH 2/2] update README.md frontend arguments #29 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7c46c73..170b1c4 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ docker-compose up -d --build | --ssl | Whether to enable SSL | `False` | | --frontend-language-source | Set frontend default language - source | `en` | | --frontend-language-target | Set frontend default language - target | `es` | +| --frontend-timeout | Set frontend translation timeout | `500` | ## Roadmap