Skip to content

Commit 95c141d

Browse files
committed
Add modal to show Krona plots
1 parent 67cdd93 commit 95c141d

File tree

2 files changed

+81
-3
lines changed

2 files changed

+81
-3
lines changed

web/src/components/DataObjectTable.vue

Lines changed: 75 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<script lang="ts">
22
import {
3-
computed, defineComponent, PropType, reactive,
3+
computed, defineComponent, PropType, reactive, ref, Ref,
44
} from '@vue/composition-api';
55
import { flattenDeep } from 'lodash';
66
77
import { DataTableHeader } from 'vuetify';
88
import { humanFileSize } from '@/data/utils';
9-
import { client, BiosampleSearchResult, OmicsProcessingResult } from '@/data/api';
9+
import {
10+
client,
11+
BiosampleSearchResult,
12+
OmicsProcessingResult,
13+
api,
14+
} from '@/data/api';
1015
import { stateRefs, acceptTerms } from '@/store';
1116
import { metaproteomicCategoryEnumToDisplay } from '@/encoding';
1217
@@ -85,6 +90,25 @@ export default defineComponent({
8590
},
8691
];
8792
93+
const selectedHtmlDataObject: Ref<any | null> = ref(null);
94+
const dataModal = ref(false);
95+
const iframeDataSource = ref('');
96+
function hasHtmlData(fileType: string) {
97+
return [
98+
'Kraken2 Krona Plot',
99+
'GOTTCHA2 Krona Plot',
100+
'Centrifuge Krona Plot',
101+
].includes(fileType);
102+
}
103+
async function openHtmlDataModal(item: any) {
104+
iframeDataSource.value = await api.getDataObjectUrl(item.id);
105+
selectedHtmlDataObject.value = item;
106+
dataModal.value = true;
107+
}
108+
function handleIframeScroll(e) {
109+
console.log(e);
110+
}
111+
88112
const termsDialog = reactive({
89113
item: null as null | OmicsProcessingResult,
90114
value: false,
@@ -161,6 +185,12 @@ export default defineComponent({
161185
}
162186
163187
return {
188+
dataModal,
189+
hasHtmlData,
190+
openHtmlDataModal,
191+
selectedHtmlDataObject,
192+
iframeDataSource,
193+
handleIframeScroll,
164194
onAcceptTerms,
165195
handleDownload,
166196
descriptionMap,
@@ -186,6 +216,38 @@ export default defineComponent({
186216
@clicked="onAcceptTerms"
187217
/>
188218
</v-dialog>
219+
<v-dialog
220+
v-if="selectedHtmlDataObject !== null"
221+
v-model="dataModal"
222+
scroll-strategy="block"
223+
width="80vw"
224+
>
225+
<v-card
226+
class="d-flex flex-column"
227+
width="100%"
228+
height="80vh"
229+
>
230+
<v-card-text class="d-flex flex-grow-1">
231+
<span v-if="!iframeDataSource">Loading data</span>
232+
<iframe
233+
v-else
234+
title="iframe title"
235+
:src="iframeDataSource"
236+
:style="{border: 'none'}"
237+
width="100%"
238+
/>
239+
</v-card-text>
240+
<v-card-actions class="flex-row">
241+
<v-spacer />
242+
<v-btn
243+
text
244+
@click="dataModal = false"
245+
>
246+
Close
247+
</v-btn>
248+
</v-card-actions>
249+
</v-card>
250+
</v-dialog>
189251
<v-data-table
190252
:headers="headers"
191253
:items="items"
@@ -251,7 +313,17 @@ export default defineComponent({
251313
<span>This file is included in the currently selected bulk download</span>
252314
</v-tooltip>
253315
</td>
254-
<td>{{ item.file_type }}</td>
316+
<td>
317+
{{ item.file_type }}
318+
<v-btn
319+
v-if="hasHtmlData(item.file_type)"
320+
color="primary"
321+
icon
322+
@click="openHtmlDataModal(item)"
323+
>
324+
<v-icon>mdi-magnify</v-icon>
325+
</v-btn>
326+
</td>
255327
<td>{{ item.file_type_description }}</td>
256328
<td>{{ humanFileSize(item.file_size_bytes) }}</td>
257329
<td>{{ item.downloads }}</td>

web/src/data/api.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,11 @@ async function createBulkDownload(conditions: Condition[], dataObjectFilter: Dat
641641
};
642642
}
643643

644+
async function getDataObjectUrl(dataObjectId: string): Promise<string> {
645+
const { data } = await client.get<{ url: string }>(`data_object/${dataObjectId}/download`);
646+
return data.url;
647+
}
648+
644649
export interface KeggTermSearchResponse {
645650
term: string;
646651
text: string;
@@ -846,6 +851,7 @@ client.interceptors.response.use(undefined, async (error: AxiosError) => {
846851

847852
const api = {
848853
createBulkDownload,
854+
getDataObjectUrl,
849855
getBinnedFacet,
850856
getBulkDownloadSummary,
851857
getBulkDownloadAggregateSummary,

0 commit comments

Comments
 (0)