From f4d2f10148070a1264b959f8a135411d1ed0bee6 Mon Sep 17 00:00:00 2001 From: Stefan Midjich Date: Fri, 22 Apr 2016 16:18:33 +0200 Subject: [PATCH] fixed the error message for promise timeout and failure. --- static/css/captiveportal.css | 8 +++++--- static/js/captiveportal.js | 20 +++++++++++++++----- views/portalindex.tpl | 5 ++--- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/static/css/captiveportal.css b/static/css/captiveportal.css index 48f6b06..86bde0e 100644 --- a/static/css/captiveportal.css +++ b/static/css/captiveportal.css @@ -9,10 +9,12 @@ } .msgbox { - border-radius: 25px; - padding: 15px; + border: 1px solid; + margin: 10px 0px; + padding:15px 10px 15px 25px; } .msgbox-error { - background: #ff4000; + color: #D8000C; + background-color: #FFBABA; } diff --git a/static/js/captiveportal.js b/static/js/captiveportal.js index 3a41d94..4b0a55e 100644 --- a/static/js/captiveportal.js +++ b/static/js/captiveportal.js @@ -9,6 +9,7 @@ var debug = true; // all jobs have succeeded in the portal software. function do_success() { console.log('success: '+window.location); + // Do something like refresh the window or go to another URL. window.location = window.href; location.reload(true); @@ -16,11 +17,13 @@ function do_success() { // Show an error to the user function do_error(message) { - $('#error-row').show(); + console.log('failure: '+message); + + $('#error-box').show(); $('#form-row').hide(); - $('#error-message').val('Failed. Reload page and try again or contact support. '); + $('#error-box').append('

Failed. Reload page and try again or contact support.

'); if (message) { - $('#error-message').append('System response: '+message); + $('#error-box').append('

System response: '+message+'

'); } } @@ -61,14 +64,15 @@ function poll_jobs(data) { console.log('Resolving job: ', job_result.id); resolve(job_result); clearTimeout(timer); - return; + return(true); } if(job_result.is_failed) { console.log('Job failed: ', job_result.id); reject(job_result); clearTimeout(timer); - return; + return(false); + } }); ajaxReq.fail(function(XMLHttpRequest, textStatus, errorThrown) { @@ -113,6 +117,12 @@ function poll_jobs(data) { }); } + +$(document).ready(function() { + $('#error-box').hide(); +}); + + // Submit the form $('#approveForm').submit(function (event) { var api_url = '/approve'; diff --git a/views/portalindex.tpl b/views/portalindex.tpl index 3ae526b..c271e23 100644 --- a/views/portalindex.tpl +++ b/views/portalindex.tpl @@ -38,9 +38,8 @@
-