[Feature] Threshold Warning + Cosmetics (#277)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#277
This commit is contained in:
2025-12-20 02:11:47 +13:00
parent a4a4179261
commit 7c60a28801
10 changed files with 304 additions and 165 deletions

View File

@ -22,13 +22,16 @@ document.addEventListener('alpine:init', () => {
status: config.status,
modified: config.modified,
statusUrl: config.statusUrl,
emptyDueToThreshold: config.emptyDueToThreshold === "True",
showUpdateNotice: false,
showEmptyDueToThresholdNotice: false,
emptyDueToThresholdMessage: 'The Pathway is empty due to the selected threshold. Please try a different threshold.',
updateMessage: '',
pollInterval: null,
get statusTooltip() {
const tooltips = {
'completed': 'Pathway prediction complete.',
'completed': 'Pathway prediction completed.',
'failed': 'Pathway prediction failed.',
'running': 'Pathway prediction running.'
};
@ -39,9 +42,17 @@ document.addEventListener('alpine:init', () => {
if (this.status === 'running') {
this.startPolling();
}
if (this.emptyDueToThreshold) {
this.showEmptyDueToThresholdNotice = true;
}
},
startPolling() {
if (this.pollInterval) {
return;
}
this.pollInterval = setInterval(() => this.checkStatus(), 5000);
},
@ -50,9 +61,16 @@ document.addEventListener('alpine:init', () => {
const response = await fetch(this.statusUrl);
const data = await response.json();
if (data.emptyDueToThreshold) {
this.emptyDueToThreshold = true;
this.showEmptyDueToThresholdNotice = true;
}
if (data.modified > this.modified) {
this.showUpdateNotice = true;
this.updateMessage = this.getUpdateMessage(data.status);
if (!this.emptyDueToThreshold) {
this.showUpdateNotice = true;
this.updateMessage = this.getUpdateMessage(data.status);
}
}
if (data.status !== 'running') {