From c7bac83056bd8ab1381ab47c1661d26ffbf795f7 Mon Sep 17 00:00:00 2001 From: Alain Mazy Date: Wed, 16 Oct 2024 16:28:14 +0200 Subject: [PATCH] use tools/find to display most recent studies --- WebApplication/src/components/StudyList.vue | 7 ++++++ WebApplication/src/orthancApi.js | 26 +++++++++++++++++++++ release-notes.md | 2 +- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/WebApplication/src/components/StudyList.vue b/WebApplication/src/components/StudyList.vue index 9cc12bc..61cc0ea 100644 --- a/WebApplication/src/components/StudyList.vue +++ b/WebApplication/src/components/StudyList.vue @@ -648,7 +648,14 @@ export default { await this.$store.dispatch('studies/clearStudies'); if (this.uiOptions.StudyListContentIfNoSearch == "empty") { return; + } else if (this.uiOptions.StudyListContentIfNoSearch == "most-recents" && this['configuration/hasExtendedChanges']) { + const studies = await api.getMostRecentStudies((this.filterLabels.length > 0 ? this.filterLabels[0] : null)); + for (const study of studies) { + this.$store.dispatch('studies/addStudy', { studyId: study["ID"], study: study, reloadStats: false }); + } } else if (this.uiOptions.StudyListContentIfNoSearch == "most-recents") { + // legacy code + if (this.isLoadingLatestStudies) { // if currently loading, stop it this.shouldStopLoadingLatestStudies = true; diff --git a/WebApplication/src/orthancApi.js b/WebApplication/src/orthancApi.js index 8ef2cb0..4b068e2 100644 --- a/WebApplication/src/orthancApi.js +++ b/WebApplication/src/orthancApi.js @@ -95,6 +95,32 @@ export default { signal: window.axiosFindStudiesAbortController.signal })).data; }, + async getMostRecentStudies(label) { + await this.cancelFindStudies(); + window.axiosFindStudiesAbortController = new AbortController(); + + let payload = { + "Level": "Study", + "Limit": store.state.configuration.uiOptions.MaxStudiesDisplayed, + "Query": {}, + "RequestedTags": store.state.configuration.requestedTagsForStudyList, + "OrderBy" : [{ + 'Type': 'Metadata', + 'Key': 'LastUpdate', + 'Direction': 'DESC' + }], + "Expand": true + }; + if (label) { + payload["Labels"] = [label]; + payload["LabelsConstraint"] = "All"; + } + + return (await axios.post(orthancApiUrl + "tools/find", payload, + { + signal: window.axiosFindStudiesAbortController.signal + })).data; + }, async getLastChangeId() { const response = (await axios.get(orthancApiUrl + "changes?last")); return response.data["Last"]; diff --git a/release-notes.md b/release-notes.md index bf612aa..eff127d 100644 --- a/release-notes.md +++ b/release-notes.md @@ -2,7 +2,7 @@ Pending changes in the mainline =============================== Changes: - - Optimized loading of "most-recent" studies when the Orthanc DB supports "ExtendedChanges" + - Optimized loading of "most-recent" studies when the Orthanc DB supports "ExtendedFind" - Disable UI components on ReadOnly systems. - new configuration "EnableLabelsCount" to enable/disable the display of the number of studies with each label.