Skip to content

Commit 72862ce

Browse files
committed
Refactor nested props in Tabular Chunked View
1 parent 5a9d87d commit 72862ce

2 files changed

Lines changed: 20 additions & 22 deletions

File tree

client/src/components/Dataset/DatasetDisplay.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useDatasetStore } from "@/stores/datasetStore";
66
import { withPrefix } from "@/utils/redirect";
77
import { bytesToString } from "@/utils/utils";
88
9+
import LoadingSpan from "components/LoadingSpan.vue";
910
import TabularChunkedView from "components/Visualizations/Tabular/TabularChunkedView.vue";
1011
1112
interface Props {
@@ -38,13 +39,12 @@ onMounted(async () => {
3839
</script>
3940

4041
<template>
41-
<div v-if="!isLoading && dataset">
42+
<LoadingSpan v-if="isLoading || !dataset" message="Loading dataset content" />
43+
<div v-else>
4244
<div v-if="dataset.deleted" id="deleted-data-message" class="errormessagelarge">
4345
You are viewing a deleted dataset.
4446
</div>
45-
<TabularChunkedView
46-
v-if="content && content.ck_data"
47-
:options="{ dataset_config: { ...dataset, first_data_chunk: content } }" />
47+
<TabularChunkedView v-if="content && content.ck_data" :options="{ ...dataset, first_data_chunk: content }" />
4848
<div v-else-if="content">
4949
<div v-if="isBinary">
5050
This is a binary (or unknown to Galaxy) dataset of size {{ bytesToString(dataset.file_size) }}. Preview

client/src/components/Visualizations/Tabular/TabularChunkedView.vue

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@ interface TabularChunk {
1414
1515
interface TabularChunkedViewProps {
1616
options: {
17-
dataset_config: {
18-
id: string;
19-
file_ext: string;
20-
first_data_chunk: TabularChunk;
21-
metadata_columns: number;
22-
metadata_column_types: string[];
23-
metadata_column_names: string[];
24-
};
17+
id: string;
18+
file_ext: string;
19+
first_data_chunk: TabularChunk;
20+
metadata_columns: number;
21+
metadata_column_types: string[];
22+
metadata_column_names: string[];
2523
};
2624
}
2725
@@ -37,32 +35,32 @@ const tabularData = reactive<{ rows: string[][] }>({
3735
});
3836
3937
const columns = computed(() => {
40-
const columns = Array(props.options.dataset_config.metadata_columns);
38+
const columns = Array(props.options.metadata_columns);
4139
// for each column_name, inject header
42-
if (props.options.dataset_config.metadata_column_names?.length > 0) {
43-
props.options.dataset_config.metadata_column_names.forEach((column_name, index) => {
40+
if (props.options.metadata_column_names?.length > 0) {
41+
props.options.metadata_column_names.forEach((column_name, index) => {
4442
columns[index] = column_name;
4543
});
4644
}
4745
return columns;
4846
});
4947
5048
const columnStyle = computed(() => {
51-
const columnStyle = Array(props.options.dataset_config.metadata_columns);
52-
if (props.options.dataset_config.metadata_column_types?.length > 0) {
53-
props.options.dataset_config.metadata_column_types.forEach((column_type, index) => {
49+
const columnStyle = Array(props.options.metadata_columns);
50+
if (props.options.metadata_column_types?.length > 0) {
51+
props.options.metadata_column_types.forEach((column_type, index) => {
5452
columnStyle[index] = column_type === "str" || column_type === "list" ? "string-align" : "number-align";
5553
});
5654
}
5755
return columnStyle;
5856
});
5957
6058
const delimiter = computed(() => {
61-
return props.options.dataset_config.file_ext === "csv" ? "," : "\t";
59+
return props.options.file_ext === "csv" ? "," : "\t";
6260
});
6361
6462
const chunkUrl = computed(() => {
65-
return `${getAppRoot()}dataset/display?dataset_id=${props.options.dataset_config.id}`;
63+
return `${getAppRoot()}dataset/display?dataset_id=${props.options.id}`;
6664
});
6765
6866
// Loading more data on user scroll to (near) bottom.
@@ -164,8 +162,8 @@ function nextChunk() {
164162
165163
onMounted(() => {
166164
// Render first chunk if available.
167-
if (props.options.dataset_config.first_data_chunk) {
168-
processChunk(props.options.dataset_config.first_data_chunk);
165+
if (props.options.first_data_chunk) {
166+
processChunk(props.options.first_data_chunk);
169167
loading.value = false;
170168
}
171169
});

0 commit comments

Comments
 (0)