Skip to content

Commit d18db5b

Browse files
feat: Improve submission status UX during validation (ietf-tools#5742)
* feat: Quietly check submission status before reloading * chore: Remove misleading "time since" display * feat: Back off submission status poll frequency * chore: Fix code comment
1 parent 818f0a9 commit d18db5b

2 files changed

Lines changed: 33 additions & 35 deletions

File tree

ietf/static/js/draft-submit.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,31 @@ $(function () {
6666

6767
});
6868

69-
// Reload page periodically if the enableAutoReload checkbox is present and checked
70-
const autoReloadSwitch = document.getElementById("enableAutoReload");
71-
const timeSinceDisplay = document.getElementById("time-since-uploaded");
72-
if (autoReloadSwitch) {
73-
const autoReloadTime = 30000; // ms
74-
let autoReloadTimeoutId;
75-
autoReloadSwitch.parentElement.classList.remove("d-none");
76-
timeSinceDisplay.classList.remove("d-none");
77-
autoReloadTimeoutId = setTimeout(() => location.reload(), autoReloadTime);
78-
autoReloadSwitch.addEventListener("change", (e) => {
79-
if (e.currentTarget.checked) {
80-
if (!autoReloadTimeoutId) {
81-
autoReloadTimeoutId = setTimeout(() => location.reload(), autoReloadTime);
82-
timeSinceDisplay.classList.remove("d-none");
83-
}
84-
} else {
85-
if (autoReloadTimeoutId) {
86-
clearTimeout(autoReloadTimeoutId);
87-
autoReloadTimeoutId = null;
88-
timeSinceDisplay.classList.add("d-none");
89-
}
69+
// If draft is validating, poll until validation is complete, then reload the page
70+
const submissionValidatingAlert = document.getElementById('submission-validating-alert');
71+
if (submissionValidatingAlert) {
72+
let statusPollTimer;
73+
const statusUrl = submissionValidatingAlert.dataset['submissionStatusUrl'];
74+
let statusPollInterval = 2000; // ms
75+
const maxPollInterval = 32000; // ms
76+
77+
function checkStatus() {
78+
if (statusPollInterval < maxPollInterval) {
79+
statusPollInterval *= 2;
9080
}
91-
});
81+
const xhr = new XMLHttpRequest();
82+
xhr.open("GET", statusUrl, true);
83+
xhr.onload = (e) => {
84+
if (xhr.response && xhr.response.state !== 'validating') {
85+
location.reload();
86+
} else {
87+
statusPollTimer = setTimeout(checkStatus, statusPollInterval);
88+
}
89+
};
90+
xhr.onerror = (e) => {statusPollTimer = setTimeout(checkStatus, statusPollInterval);};
91+
xhr.responseType = 'json';
92+
xhr.send('');
93+
}
94+
statusPollTimer = setTimeout(checkStatus, statusPollInterval);
9295
}
9396
});

ietf/templates/submit/submission_status.html

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,20 @@ <h2 class="mt-5">Submission checks</h2>
137137
Notice: The Internet-Draft submission process has changed as of Datatracker version 10.3.0.
138138
Your Internet-Draft is currently being processed and validated asynchronously. Results will be
139139
displayed at this URL when they are available. If JavaScript is enabled in your
140-
browser, this page will refreshed automatically. If JavaScript is not enabled, or if you
141-
disable the automatic refresh with the toggle below, please reload this page in a few
142-
minutes to see the results.
140+
browser, this page will refreshed automatically. If JavaScript is not enabled,
141+
please reload this page in a few minutes to see the results.
143142
</div>
144-
<div class="alert alert-warning my-3">
145-
This submission is being processed and validated. This normally takes a few minutes after
146-
submission.
143+
<div id="submission-validating-alert"
144+
class="alert alert-warning my-3"
145+
data-submission-status-url="{% url 'ietf.submit.views.api_submission_status' submission_id=submission.pk %}">
146+
This submission is being processed and validated. This usually takes a few seconds but may
147+
take a few minutes for complex drafts or during periods of heavy load.
147148
{% with earliest_event=submission.submissionevent_set.last %}
148149
{% if earliest_event %}
149-
Your draft was uploaded at {{ earliest_event.time }}<span id="time-since-uploaded" class="d-none">
150-
({{ earliest_event.time|timesince }} ago)</span>.
150+
Your draft was uploaded at {{ earliest_event.time }}.
151151
{% endif %}
152152
{% endwith %}
153153
Please contact the secretariat for assistance if it has been more than an hour.
154-
155-
<div class="form-check form-switch mt-3 d-none">{# hide with d-none unless javascript makes it visible #}
156-
<input class="form-check-input" type="checkbox" id="enableAutoReload" checked>
157-
<label class="form-check-label" for="enableAutoReload"> Refresh automatically </label>
158-
</div>
159154
</div>
160155
{% else %}
161156
<h2 class="mt-5">Meta-data from the submission</h2>

0 commit comments

Comments
 (0)