From bfe65562c4a1ebdb81e76e81b674f34b6b3db6df Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Fri, 2 Jun 2023 11:51:29 -0300 Subject: [PATCH 1/4] feat: Quietly check submission status before reloading --- ietf/static/js/draft-submit.js | 41 ++++++++++---------- ietf/templates/submit/submission_status.html | 18 ++++----- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/ietf/static/js/draft-submit.js b/ietf/static/js/draft-submit.js index 4d813a7fbef..ac8ac5d9f82 100644 --- a/ietf/static/js/draft-submit.js +++ b/ietf/static/js/draft-submit.js @@ -67,27 +67,28 @@ $(function () { }); // Reload page periodically if the enableAutoReload checkbox is present and checked - const autoReloadSwitch = document.getElementById("enableAutoReload"); - const timeSinceDisplay = document.getElementById("time-since-uploaded"); - if (autoReloadSwitch) { - const autoReloadTime = 30000; // ms - let autoReloadTimeoutId; - autoReloadSwitch.parentElement.classList.remove("d-none"); + const submissionValidatingAlert = document.getElementById('submission-validating-alert'); + if (submissionValidatingAlert) { + let statusPollTimer; + const timeSinceDisplay = document.getElementById("time-since-uploaded"); + const statusUrl = submissionValidatingAlert.dataset['submissionStatusUrl']; + const statusPollInterval = 3000; // ms timeSinceDisplay.classList.remove("d-none"); - autoReloadTimeoutId = setTimeout(() => location.reload(), autoReloadTime); - autoReloadSwitch.addEventListener("change", (e) => { - if (e.currentTarget.checked) { - if (!autoReloadTimeoutId) { - autoReloadTimeoutId = setTimeout(() => location.reload(), autoReloadTime); - timeSinceDisplay.classList.remove("d-none"); - } - } else { - if (autoReloadTimeoutId) { - clearTimeout(autoReloadTimeoutId); - autoReloadTimeoutId = null; - timeSinceDisplay.classList.add("d-none"); + + function checkStatus() { + const xhr = new XMLHttpRequest(); + xhr.open("GET", statusUrl, true); + xhr.onload = (e) => { + if (xhr.response && xhr.response.state !== 'validating') { + location.reload(); + } else { + statusPollTimer = setTimeout(checkStatus, statusPollInterval); } - } - }); + }; + xhr.onerror = (e) => {statusPollTimer = setTimeout(checkStatus, statusPollInterval);}; + xhr.responseType = 'json'; + xhr.send(''); + } + statusPollTimer = setTimeout(checkStatus, statusPollInterval); } }); diff --git a/ietf/templates/submit/submission_status.html b/ietf/templates/submit/submission_status.html index fba1023c5da..0926c3e3ecd 100644 --- a/ietf/templates/submit/submission_status.html +++ b/ietf/templates/submit/submission_status.html @@ -137,13 +137,14 @@

Submission checks

Notice: The Internet-Draft submission process has changed as of Datatracker version 10.3.0. Your Internet-Draft is currently being processed and validated asynchronously. Results will be displayed at this URL when they are available. If JavaScript is enabled in your - browser, this page will refreshed automatically. If JavaScript is not enabled, or if you - disable the automatic refresh with the toggle below, please reload this page in a few - minutes to see the results. + browser, this page will refreshed automatically. If JavaScript is not enabled, + please reload this page in a few minutes to see the results. -
- This submission is being processed and validated. This normally takes a few minutes after - submission. +
+ This submission is being processed and validated. This usually takes a few seconds but may + take a few minutes for complex drafts or during periods of heavy load. {% with earliest_event=submission.submissionevent_set.last %} {% if earliest_event %} Your draft was uploaded at {{ earliest_event.time }} @@ -151,11 +152,6 @@

Submission checks

{% endif %} {% endwith %} Please contact the secretariat for assistance if it has been more than an hour. - -
{# hide with d-none unless javascript makes it visible #} - - -
{% else %}

Meta-data from the submission

From 6755d1b85b50d92ed18d7916c832a545cdb2d141 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Fri, 2 Jun 2023 12:08:04 -0300 Subject: [PATCH 2/4] chore: Remove misleading "time since" display --- ietf/static/js/draft-submit.js | 2 -- ietf/templates/submit/submission_status.html | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/ietf/static/js/draft-submit.js b/ietf/static/js/draft-submit.js index ac8ac5d9f82..58f174a3850 100644 --- a/ietf/static/js/draft-submit.js +++ b/ietf/static/js/draft-submit.js @@ -70,10 +70,8 @@ $(function () { const submissionValidatingAlert = document.getElementById('submission-validating-alert'); if (submissionValidatingAlert) { let statusPollTimer; - const timeSinceDisplay = document.getElementById("time-since-uploaded"); const statusUrl = submissionValidatingAlert.dataset['submissionStatusUrl']; const statusPollInterval = 3000; // ms - timeSinceDisplay.classList.remove("d-none"); function checkStatus() { const xhr = new XMLHttpRequest(); diff --git a/ietf/templates/submit/submission_status.html b/ietf/templates/submit/submission_status.html index 0926c3e3ecd..4235a4375ab 100644 --- a/ietf/templates/submit/submission_status.html +++ b/ietf/templates/submit/submission_status.html @@ -147,8 +147,7 @@

Submission checks

take a few minutes for complex drafts or during periods of heavy load. {% with earliest_event=submission.submissionevent_set.last %} {% if earliest_event %} - Your draft was uploaded at {{ earliest_event.time }} - ({{ earliest_event.time|timesince }} ago). + Your draft was uploaded at {{ earliest_event.time }}. {% endif %} {% endwith %} Please contact the secretariat for assistance if it has been more than an hour. From 2055ab0ebca637587625f5123d0a97056c12897b Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Fri, 2 Jun 2023 12:15:00 -0300 Subject: [PATCH 3/4] feat: Back off submission status poll frequency --- ietf/static/js/draft-submit.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ietf/static/js/draft-submit.js b/ietf/static/js/draft-submit.js index 58f174a3850..1ad80dd9f3a 100644 --- a/ietf/static/js/draft-submit.js +++ b/ietf/static/js/draft-submit.js @@ -71,9 +71,13 @@ $(function () { if (submissionValidatingAlert) { let statusPollTimer; const statusUrl = submissionValidatingAlert.dataset['submissionStatusUrl']; - const statusPollInterval = 3000; // ms + let statusPollInterval = 2000; // ms + const maxPollInterval = 32000; // ms function checkStatus() { + if (statusPollInterval < maxPollInterval) { + statusPollInterval *= 2; + } const xhr = new XMLHttpRequest(); xhr.open("GET", statusUrl, true); xhr.onload = (e) => { From bf997ac666b990f34c7dad160361a9bad594a1fe Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Fri, 2 Jun 2023 12:21:19 -0300 Subject: [PATCH 4/4] chore: Fix code comment --- ietf/static/js/draft-submit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ietf/static/js/draft-submit.js b/ietf/static/js/draft-submit.js index 1ad80dd9f3a..38ac7eb2633 100644 --- a/ietf/static/js/draft-submit.js +++ b/ietf/static/js/draft-submit.js @@ -66,7 +66,7 @@ $(function () { }); - // Reload page periodically if the enableAutoReload checkbox is present and checked + // If draft is validating, poll until validation is complete, then reload the page const submissionValidatingAlert = document.getElementById('submission-validating-alert'); if (submissionValidatingAlert) { let statusPollTimer;