Skip to content

Commit

Permalink
Handle implicit collection mapping in Markdown's IO streams directives
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Dec 19, 2023
1 parent 136aba2 commit ae1bad6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
68 changes: 52 additions & 16 deletions client/src/components/Markdown/Elements/ToolStd.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,70 @@
<script setup lang="ts">
import { computed } from "vue";
import { computed, toRef, watch } from "vue";
interface Job {
tool_stdout?: string;
tool_stderr?: string;
}
import { useJobStore } from "@/stores/jobStore";
import { useMappingJobs } from "./handlesMappingJobs";
type JobsMap = {
[key: string]: Job;
};
import JobSelection from "./JobSelection.vue";
interface ToolStdProps {
jobId: string;
jobId?: string;
implicitCollectionJobsId?: string;
name: "tool_stderr" | "tool_stdout";
jobs: JobsMap;
}
const props = defineProps<ToolStdProps>();
const props = withDefaults(defineProps<ToolStdProps>(), {
jobId: null,
implicitCollectionJobsId: null,
});
const jobStore = useJobStore();
const jobIdRef = toRef(props, "jobId");
const implicitCollectionJobsIdRef = toRef(props, "implicitCollectionJobsId");
const { selectJobOptions, selectedJob, targetJobId } = useMappingJobs(jobIdRef, implicitCollectionJobsIdRef);
async function init() {
if (targetJobId.value) {
jobStore.fetchJob(targetJobId.value);
}
}
watch(
targetJobId,
() => {
init();
},
{ immediate: true }
);
const jobContent = computed(() => {
const job = props.jobs[props.jobId];
return job && job[props.name];
let content: string | undefined;
if (targetJobId.value) {
const job = jobStore.getJob(targetJobId.value);
content = job && job[props.name];
}
if (!content && props.name == "tool_stdout") {
content = "*No Standard Output Available*";
} else if (!content) {
content = "*No Standard Error Available*";
}
return content;
});
</script>

<template>
<b-card nobody class="content-height">
<div :class="name" :job_id="jobId">
<pre><code class="word-wrap-normal">{{ jobContent }}</code></pre>
</div>
<JobSelection
v-model="selectedJob"
:job-id="jobId"
:implicit-collection-jobs-id="implicitCollectionJobsId"
:select-job-options="selectJobOptions">
<div :class="name" :job_id="targetJobId">
<pre><code class="word-wrap-normal">{{ jobContent }}</code></pre>
</div>
</JobSelection>
</b-card>
</template>

Expand Down
3 changes: 0 additions & 3 deletions client/src/components/Markdown/Markdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
:collections="collections"
:histories="histories"
:invocations="invocations"
:jobs="jobs"
:time="time"
:version="version"
:workflows="workflows" />
Expand Down Expand Up @@ -134,7 +133,6 @@ export default {
histories: {},
collections: {},
workflows: {},
jobs: {},
invocations: {},
loading: true,
workflowID: "",
Expand Down Expand Up @@ -193,7 +191,6 @@ export default {
this.histories = config.histories || {};
this.collections = config.history_dataset_collections || {};
this.workflows = config.workflows || {};
this.jobs = config.jobs || {};
this.invocations = config.invocations || {};
this.loading = false;
this.workflowID = Object.keys(this.markdownConfig.workflows)[0];
Expand Down
8 changes: 2 additions & 6 deletions client/src/components/Markdown/MarkdownContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ const props = defineProps({
type: Object,
default: null,
},
jobs: {
type: Object,
default: null,
},
time: {
type: String,
default: null,
Expand Down Expand Up @@ -174,8 +170,8 @@ function argToBoolean(args, name, booleanDefault) {
<ToolStd
v-else-if="['tool_stdout', 'tool_stderr'].includes(name)"
:job-id="args.job_id"
:name="name"
:jobs="jobs" />
:implicit-collection-jobs-id="args.implicit_collection_jobs_id"
:name="name" />
<HistoryDatasetDisplay
v-else-if="['history_dataset_embedded', 'history_dataset_display'].includes(name)"
:args="args"
Expand Down
2 changes: 2 additions & 0 deletions client/src/stores/jobStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ interface Job {
id: string;
tool_id: string;
tool_version: string;
tool_stdout: string;
tool_stderr: string;
}
interface JobDef {
tool_id: string;
Expand Down

0 comments on commit ae1bad6

Please sign in to comment.