diff --git a/app/static/css/corpus-status-text.css b/app/static/css/corpus-status-text.css
index fca3d1d2..52be06d4 100644
--- a/app/static/css/corpus-status-text.css
+++ b/app/static/css/corpus-status-text.css
@@ -2,6 +2,10 @@
--corpus-status-content: "unprepared";
}
+[data-corpus-status="SUBMITTED"] {
+ --corpus-status-content: "submitted";
+}
+
[data-corpus-status="QUEUED"] {
--corpus-status-content: "queued";
}
diff --git a/app/static/js/app/extensions/toaster.js b/app/static/js/app/extensions/toaster.js
index 876fc7b3..6808ad8b 100644
--- a/app/static/js/app/extensions/toaster.js
+++ b/app/static/js/app/extensions/toaster.js
@@ -7,24 +7,43 @@ nopaque.app.extensions.Toaster = class Toaster {
this.app.userHub.addEventListener('patch', (event) => {this.#onPatch(event.detail);});
}
- #onPatch(patch) {
- // Handle job updates
- const jobRegExp = new RegExp(`^/users/([A-Za-z0-9]+)/jobs/([A-Za-z0-9]+)`);
- const jobPatch = patch.filter((operation) => {return jobRegExp.test(operation.path);});
-
- this.#onJobPatch(jobPatch);
-
+ async #onPatch(patch) {
// Handle corpus updates
const corpusRegExp = new RegExp(`^/users/([A-Za-z0-9]+)/corpora/([A-Za-z0-9]+)`);
const corpusPatch = patch.filter((operation) => {return corpusRegExp.test(operation.path);});
this.#onCorpusPatch(corpusPatch);
+
+ // Handle job updates
+ const jobRegExp = new RegExp(`^/users/([A-Za-z0-9]+)/jobs/([A-Za-z0-9]+)`);
+ const jobPatch = patch.filter((operation) => {return jobRegExp.test(operation.path);});
+
+ this.#onJobPatch(jobPatch);
+ }
+
+ async #onCorpusPatch(patch) {
+ return;
+ // Handle corpus status updates
+ const corpusStatusRegExp = new RegExp(`^/users/([A-Za-z0-9]+)/corpora/([A-Za-z0-9]+)/status$`);
+ const corpusStatusPatch = patch
+ .filter((operation) => {return corpusStatusRegExp.test(operation.path);})
+ .filter((operation) => {return operation.op === 'replace';});
+
+ for (let operation of corpusStatusPatch) {
+ const [match, userId, corpusId] = operation.path.match(corpusStatusRegExp);
+ const user = await this.app.userHub.get(userId);
+ const corpus = user.corpora[corpusId];
+
+ this.app.ui.flash(`[${corpus.title}] New status: `, 'corpus');
+ }
}
async #onJobPatch(patch) {
// Handle job status updates
const jobStatusRegExp = new RegExp(`^/users/([A-Za-z0-9]+)/jobs/([A-Za-z0-9]+)/status$`);
- const jobStatusPatch = patch.filter((operation) => {return operation.op === 'replace';});
+ const jobStatusPatch = patch
+ .filter((operation) => {return jobStatusRegExp.test(operation.path);})
+ .filter((operation) => {return operation.op === 'replace';});
for (let operation of jobStatusPatch) {
const [match, userId, jobId] = operation.path.match(jobStatusRegExp);
@@ -34,18 +53,4 @@ nopaque.app.extensions.Toaster = class Toaster {
this.app.ui.flash(`[${job.title}] New status: `, 'job');
}
}
-
- async #onCorpusPatch(patch) {
- // Handle job status updates
- const corpusStatusRegExp = new RegExp(`^/users/([A-Za-z0-9]+)/corpora/([A-Za-z0-9]+)/status$`);
- const corpusStatusPatch = patch.filter((operation) => {return operation.op === 'replace';});
-
- for (let operation of corpusStatusPatch) {
- const [match, userId, corpusId] = operation.path.match(corpusStatusRegExp);
- const user = await this.app.userHub.get(userId);
- const corpus = user.corpora[corpusId];
-
- this.app.ui.flash(`[${corpus.title}] New status: `, 'job');
- }
- }
}
diff --git a/app/static/js/resource-displays/corpus-display.js b/app/static/js/resource-displays/corpus-display.js
index 40a7d996..82cd8897 100644
--- a/app/static/js/resource-displays/corpus-display.js
+++ b/app/static/js/resource-displays/corpus-display.js
@@ -52,22 +52,23 @@ nopaque.resource_displays.CorpusDisplay = class CorpusDisplay extends nopaque.re
}
}
- setTitle(title) {
- this.setElements(this.displayElement.querySelectorAll('.corpus-title'), title);
+ async setTitle(title) {
+ const corpusTitleElements = this.displayElement.querySelectorAll('.corpus-title');
+ this.setElements(corpusTitleElements, title);
}
setNumTokens(numTokens) {
- this.setElements(
- this.displayElement.querySelectorAll('.corpus-token-ratio'),
- `${numTokens}/${app.data.users[this.userId].corpora[this.corpusId].max_num_tokens}`
- );
+ const corpusTokenRatioElements = this.displayElement.querySelectorAll('.corpus-token-ratio');
+ const maxNumTokens = 2147483647;
+
+ this.setElements(corpusTokenRatioElements, `${numTokens}/${maxNumTokens}`);
}
setDescription(description) {
this.setElements(this.displayElement.querySelectorAll('.corpus-description'), description);
}
- setStatus(status) {
+ async setStatus(status) {
let elements = this.displayElement.querySelectorAll('.action-button[data-action="analyze"]');
for (let element of elements) {
if (['BUILT', 'STARTING_ANALYSIS_SESSION', 'RUNNING_ANALYSIS_SESSION', 'CANCELING_ANALYSIS_SESSION'].includes(status)) {
@@ -77,8 +78,10 @@ nopaque.resource_displays.CorpusDisplay = class CorpusDisplay extends nopaque.re
}
}
elements = this.displayElement.querySelectorAll('.action-button[data-action="build-request"]');
+ const user = await app.userHub.get(this.userId);
+ const corpusFiles = user.corpora[this.corpusId].files;
for (let element of elements) {
- if (['UNPREPARED', 'FAILED'].includes(status) && Object.values(app.data.users[this.userId].corpora[this.corpusId].files).length > 0) {
+ if (['UNPREPARED', 'FAILED'].includes(status) && Object.values(corpusFiles.length > 0)) {
element.classList.remove('disabled');
} else {
element.classList.add('disabled');