Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/components/DataBrowser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ export default defineComponent({
.length > 0
);

const panels = ref<string[]>([
SAMPLE_DATA_KEY,
...(dicomWeb.isConfigured ? [DICOM_WEB_KEY] : []),
]);
const panels = ref<string[]>([SAMPLE_DATA_KEY, DICOM_WEB_KEY]);

watch(
[hasAnonymousImages, patients] as const,
Expand Down
13 changes: 3 additions & 10 deletions src/components/dicom-web/DicomWebSettings.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
<script lang="ts">
import { defineComponent, onMounted, onUnmounted, ref } from 'vue';
import { defineComponent, onUnmounted } from 'vue';
import { useDicomWebStore } from '../../store/dicom-web/dicom-web-store';

export default defineComponent({
setup() {
const dicomWeb = useDicomWebStore();

// If host changed while mounted, fetch metadata
const hostAtStart = ref<typeof dicomWeb.host>();
onMounted(() => {
hostAtStart.value = dicomWeb.host;
});
onUnmounted(() => {
// Re-fetch if address changed or an error message exists
if (hostAtStart.value !== dicomWeb.host || dicomWeb.message)
dicomWeb.fetchInitialDicoms();
dicomWeb.fetchDicomsOnce();
});

return {
Expand All @@ -34,7 +27,7 @@ export default defineComponent({
clearable
/>
<v-text-field
v-model="dicomWeb.host"
v-model="dicomWeb.savedHost"
class="server-param"
label="Host Address"
clearable
Expand Down
2 changes: 1 addition & 1 deletion src/components/dicom-web/PatientList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineComponent({
setup() {
const dicomWebStore = useDicomWebStore();
const dicomWebMeta = useDicomMetaStore();
dicomWebStore.fetchInitialDicomsOnce();
dicomWebStore.fetchDicomsOnce();

const patients = computed(() =>
Object.values(dicomWebMeta.patientInfo)
Expand Down
2 changes: 1 addition & 1 deletion src/components/dicom-web/StudyVolumeDicomWeb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export default defineComponent({
color="white"
:indeterminate="
volume.progress.percent === 0 &&
volume.progress.state !== 'Done'
volume.progress.state === 'Pending'
"
:model-value="volume.progress.percent"
>
Expand Down
22 changes: 12 additions & 10 deletions src/store/dicom-web/dicom-web-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const useDicomWebStore = defineStore('dicom-web', () => {
const fetchError = ref<undefined | unknown>(undefined);
// DICOMWeb DataBrowser components automatically expands panels if true
const linkedToStudyOrSeries = ref(false);
const fetchInitialDicoms = async () => {
const fetchDicoms = async () => {
fetchDicomsProgress.value = 'Pending';
fetchError.value = undefined;
linkedToStudyOrSeries.value = false;
Expand Down Expand Up @@ -262,13 +262,6 @@ export const useDicomWebStore = defineStore('dicom-web', () => {
fetchDicomsProgress.value = 'Done';
};

// Safe to call in components' setup()
const fetchInitialDicomsOnce = () => {
if (fetchDicomsProgress.value === 'Idle') {
fetchInitialDicoms();
}
};

const message = computed(() => {
if (fetchError.value)
return `Error fetching DICOMWeb data: ${fetchError.value}`;
Expand All @@ -283,6 +276,15 @@ export const useDicomWebStore = defineStore('dicom-web', () => {
return '';
});

// Safe to call in components' setup()
let lastFetchedHostUrl: string | null = '';
const fetchDicomsOnce = () => {
if (lastFetchedHostUrl !== host.value || message.value) {
lastFetchedHostUrl = host.value;
fetchDicoms();
}
};

const loadedDicoms = useDICOMStore();
loadedDicoms.$onAction(({ name, args, after }) => {
if (name !== 'deleteVolume') return;
Expand All @@ -303,13 +305,13 @@ export const useDicomWebStore = defineStore('dicom-web', () => {

return {
host,
savedHost,
isConfigured,
hostName,
message,
volumes,
linkedToStudyOrSeries,
fetchInitialDicoms,
fetchInitialDicomsOnce,
fetchDicomsOnce,
fetchPatientMeta,
fetchVolumesMeta,
fetchVolumeThumbnail,
Expand Down