Skip to content

Commit fdee4c6

Browse files
authored
Merge pull request galaxyproject#19877 from mvdbeek/lazy_load_job_tab
[24.2] Lazy-load invocation step jobs as needed
2 parents 6f607c4 + 1545945 commit fdee4c6

2 files changed

Lines changed: 12 additions & 45 deletions

File tree

client/src/components/JobInformation/JobDetails.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<b-card>
33
<JobInformation :job_id="id" :include-times="true">
4+
<!-- only needed for admin job component -->
45
<tr v-if="hasTraceback">
56
<td>Traceback</td>
67
<td>

client/src/components/WorkflowInvocationState/JobStep.vue

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
<script setup lang="ts">
22
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
33
import { BAlert, BTab, BTabs } from "bootstrap-vue";
4-
import Vue, { computed, ref, watch } from "vue";
4+
import { computed } from "vue";
55
6-
import { GalaxyApi } from "@/api";
7-
import { type JobBaseModel, type JobDetails } from "@/api/jobs";
6+
import { type JobBaseModel } from "@/api/jobs";
87
import { getHeaderClass, iconClasses } from "@/composables/useInvocationGraph";
9-
import { rethrowSimple } from "@/utils/simple-error";
108
119
import JobDetailsDisplayed from "../JobInformation/JobDetails.vue";
12-
import LoadingSpan from "../LoadingSpan.vue";
1310
1411
interface Props {
1512
jobs: JobBaseModel[];
@@ -19,42 +16,14 @@ const props = withDefaults(defineProps<Props>(), {
1916
jobs: () => [],
2017
});
2118
22-
const loading = ref(true);
23-
const initialLoading = ref(true);
24-
const jobsDetails = ref<{ [key: string]: JobDetails }>({});
19+
const firstJob = computed(() => props.jobs[0]);
20+
const jobCount = computed(() => props.jobs.length);
2521
26-
watch(
27-
() => props.jobs,
28-
async (propJobs: JobBaseModel[]) => {
29-
loading.value = true;
30-
for (const job of propJobs) {
31-
const { data, error } = await GalaxyApi().GET("/api/jobs/{job_id}", {
32-
params: {
33-
path: { job_id: job.id },
34-
query: { full: true },
35-
},
36-
});
37-
Vue.set(jobsDetails.value, job.id, data);
38-
if (error) {
39-
rethrowSimple(error);
40-
}
41-
}
42-
if (initialLoading.value) {
43-
initialLoading.value = false;
44-
}
45-
loading.value = false;
46-
},
47-
{ immediate: true }
48-
);
49-
50-
const firstJob = computed(() => Object.values(jobsDetails.value)[0]);
51-
const jobCount = computed(() => Object.keys(jobsDetails.value).length);
52-
53-
function getIcon(job: JobDetails) {
22+
function getIcon(job: JobBaseModel) {
5423
return iconClasses[job.state];
5524
}
5625
57-
function getTabClass(job: JobDetails) {
26+
function getTabClass(job: JobBaseModel) {
5827
return {
5928
...getHeaderClass(job.state),
6029
"d-flex": true,
@@ -64,16 +33,13 @@ function getTabClass(job: JobDetails) {
6433
</script>
6534

6635
<template>
67-
<BAlert v-if="initialLoading" variant="info" show>
68-
<LoadingSpan message="Loading Jobs" />
69-
</BAlert>
70-
<BAlert v-else-if="!jobsDetails || !jobCount" variant="info" show> No jobs found for this step. </BAlert>
36+
<BAlert v-if="!jobCount" variant="info" show> No jobs found for this step. </BAlert>
7137
<div v-else-if="jobCount === 1 && firstJob">
72-
<JobDetailsDisplayed :job="firstJob" />
38+
<JobDetailsDisplayed :job-id="firstJob.id" />
7339
</div>
74-
<BTabs v-else vertical pills card nav-class="p-0" active-tab-class="p-0">
40+
<BTabs v-else lazy vertical pills card nav-class="p-0" active-tab-class="p-0">
7541
<BTab
76-
v-for="job in jobsDetails"
42+
v-for="job in jobs"
7743
:key="job.id"
7844
data-description="workflow invocation job"
7945
:title-item-class="getTabClass(job)"
@@ -87,7 +53,7 @@ function getTabClass(job: JobDetails) {
8753
:spin="getIcon(job)?.spin" />
8854
</template>
8955
<div>
90-
<JobDetailsDisplayed :job="job" />
56+
<JobDetailsDisplayed :job-id="job.id" />
9157
</div>
9258
</BTab>
9359
</BTabs>

0 commit comments

Comments
 (0)