Skip to content

Commit b02990f

Browse files
authored
Metadata Query Param Persistence (#324)
* add metadataQueryParam persistence * fix prev/next, increment version * increment web-client verison
1 parent 706e12c commit b02990f

File tree

6 files changed

+54
-8
lines changed

6 files changed

+54
-8
lines changed

client/dive-common/components/PrevNext.vue

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script lang="ts">
2-
import { defineComponent, ref, watch } from 'vue';
2+
import {
3+
defineComponent, ref, watch,
4+
} from 'vue';
35
import TooltipButton from 'vue-media-annotator/components/TooltipButton.vue';
4-
import { useConfiguration } from 'vue-media-annotator/provides';
6+
import { useConfiguration, useHandler } from 'vue-media-annotator/provides';
57
import { useRouter } from 'vue-router/composables';
68
79
export default defineComponent({
@@ -30,6 +32,8 @@ export default defineComponent({
3032
setup() {
3133
const configMap = useConfiguration();
3234
const router = useRouter();
35+
const { getDiveMetadataRootId } = useHandler();
36+
const diveMetadataRootId = ref(getDiveMetadataRootId());
3337
const previous = ref(configMap.prevNext.value?.previous);
3438
const next = ref(configMap.prevNext.value?.next);
3539
watch(configMap.prevNext, () => {
@@ -40,10 +44,22 @@ export default defineComponent({
4044
const gotoId = (id: string) => {
4145
router.push({ name: 'viewer', params: { id } });
4246
};
47+
48+
const queryStringParams = ref('');
49+
watch(getDiveMetadataRootId, (newval) => {
50+
diveMetadataRootId.value = newval;
51+
if (diveMetadataRootId.value) {
52+
queryStringParams.value = `?diveMetadataRootId=${diveMetadataRootId.value}`;
53+
} else {
54+
queryStringParams.value = '';
55+
}
56+
}, { immediate: true });
57+
4358
return {
4459
previous,
4560
next,
4661
gotoId,
62+
queryStringParams,
4763
};
4864
},
4965
});
@@ -63,7 +79,7 @@ export default defineComponent({
6379
:tooltip-text="`Go to Previous Dataset: ${previous.name}`"
6480
outlined
6581
tile
66-
:to="`/viewer/${previous.id}`"
82+
:to="`/viewer/${previous.id}${queryStringParams}`"
6783
/>
6884
</span>
6985
<slot name="middle" />
@@ -76,7 +92,7 @@ export default defineComponent({
7692
:tooltip-text="`Go to Next Dataset: ${next.name}`"
7793
outlined
7894
tile
79-
:to="`/viewer/${next.id}`"
95+
:to="`/viewer/${next.id}${queryStringParams}`"
8096
/>
8197
</span>
8298
</v-row>

client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dive-dsa",
3-
"version": "1.11.17",
3+
"version": "1.11.18",
44
"author": {
55
"name": "Kitware, Inc.",
66
"email": "Bryon.Lewis@kitware.com"

client/platform/web-girder/store/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Store } from 'vuex';
1212
* or a simplified id/type pair.
1313
* These types are mutually exclusive.
1414
*/
15-
export type RootlessLocationType = GirderModel | { _id: string; _modelType: GirderModelType };
15+
export type RootlessLocationType = GirderModel | { _id: string; _modelType: GirderModelType, parentId?: string | null };
1616
export type LocationType = RootlessLocationType | { type: 'collections' | 'users' | 'root' };
1717
export interface LocationState {
1818
location: LocationType | null;

client/platform/web-girder/views/AnnotationDataBrowser.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { itemsPerPageOptions } from 'dive-common/constants';
99
import { clientSettings } from 'dive-common/store/settings';
1010
import { getFolder } from 'platform/web-girder/api/girder.service';
1111
import TooltipButton from 'vue-media-annotator/components/TooltipButton.vue';
12+
import { useHandler } from 'vue-media-annotator/provides';
1213
import { useStore } from '../store/types';
1314
1415
export default defineComponent({
@@ -26,6 +27,8 @@ export default defineComponent({
2627
setup(props) {
2728
const fileManager = ref();
2829
const store = useStore();
30+
const { getDiveMetadataRootId } = useHandler();
31+
const localDiveMetadataRootId = ref(getDiveMetadataRootId());
2932
const locationStore = store.state.Location;
3033
const { getters } = store;
3134
const showDialog = ref(false);
@@ -56,6 +59,18 @@ export default defineComponent({
5659
&& !locationStore.selected.length
5760
));
5861
62+
watch(showDialog, () => {
63+
localDiveMetadataRootId.value = getDiveMetadataRootId();
64+
});
65+
66+
const queryParams = computed(() => {
67+
const params: Record<string, string> = {};
68+
if (localDiveMetadataRootId.value !== null && (location.value?._id === (locationStore.location as GirderModel)?._id)) {
69+
params.diveMetadataRootId = localDiveMetadataRootId.value;
70+
}
71+
return params;
72+
});
73+
5974
return {
6075
fileManager,
6176
locationStore,
@@ -68,6 +83,7 @@ export default defineComponent({
6883
/* methods */
6984
isAnnotationFolder,
7085
setLocation,
86+
queryParams,
7187
};
7288
},
7389
});
@@ -129,7 +145,7 @@ export default defineComponent({
129145
x-small
130146
color="primary"
131147
depressed
132-
:to="{ name: 'viewer', params: { id: item._id } }"
148+
:to="{ name: 'viewer', params: { id: item._id }, query: queryParams }"
133149
>
134150
Launch Annotator
135151
</v-btn>

client/src/use/useURLParameters.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ export default function useURLParameters(
2929
if (localDiveMetadataRootId.value !== null) {
3030
values.push(`diveMetadataRootId=${localDiveMetadataRootId.value}`);
3131
}
32+
if (window.location.href.includes('diveMetadataRootId=')) {
33+
// Make sure we add the diveMetadataRootId if it is not already there
34+
if (localDiveMetadataRootId.value === null) {
35+
const currentLocation = window.location.href;
36+
const urlParams = currentLocation.slice(currentLocation.indexOf('?') + 1);
37+
const urlSplitParams = urlParams.split('&');
38+
urlSplitParams.forEach((item) => {
39+
const splits = item.split('=');
40+
if (splits.length > 1 && splits[0] === 'diveMetadataRootId') {
41+
values.push(`diveMetadataRootId=${splits[1]}`);
42+
}
43+
});
44+
}
45+
}
3246
const currentLocation = window.location.href;
3347
if (values.length === 0) {
3448
window.history.replaceState(null, '', currentLocation.replace(/\?.*/, '')); // Override history

server/dive_server/web_client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
]
1515
},
1616
"dependencies": {
17-
"dive-dsa": "^1.11.1",
17+
"dive-dsa": "^1.11.18",
1818
"webpack": "^2.7.0",
1919
"copy-webpack-plugin": "^4.5.2"
2020
}

0 commit comments

Comments
 (0)