11<script lang="ts">
22import {
3- defineComponent , computed , PropType , ref , onBeforeMount ,
3+ defineComponent ,
4+ computed ,
5+ PropType ,
6+ ref ,
7+ Ref ,
8+ onBeforeMount ,
49} from ' vue' ;
510import {
611 Pipelines ,
@@ -10,14 +15,25 @@ import {
1015 DatasetType ,
1116} from ' dive-common/apispec' ;
1217import JobLaunchDialog from ' dive-common/components/JobLaunchDialog.vue' ;
13- import { stereoPipelineMarker , multiCamPipelineMarkers , LargeImageType } from ' dive-common/constants' ;
18+ import JobConfigFilterTranscodeDialog from ' dive-common/components/JobConfigFilterTranscodeDialog.vue' ;
19+ import {
20+ stereoPipelineMarker ,
21+ multiCamPipelineMarkers ,
22+ LargeImageType ,
23+ pipelineCreatesDatasetMarkers ,
24+ } from ' dive-common/constants' ;
1425import { useRequest } from ' dive-common/use' ;
1526import { usePrompt } from ' dive-common/vue-utilities/prompt-service' ;
1627
28+ type MenuState = ' idle' | ' configuring' ;
29+
1730export default defineComponent ({
1831 name: ' RunPipelineMenu' ,
1932
20- components: { JobLaunchDialog },
33+ components: {
34+ JobLaunchDialog ,
35+ JobConfigFilterTranscodeDialog ,
36+ },
2137
2238 props: {
2339 selectedDatasetIds: {
@@ -69,6 +85,14 @@ export default defineComponent({
6985 state : jobState,
7086 } = useRequest ();
7187
88+ const menuState: Ref <MenuState > = ref (' idle' );
89+ const configuring = computed (() => menuState .value === ' configuring' );
90+ const selectedPipeline: Ref <Pipe | null > = ref (null );
91+ const selectedPipelineName = computed (() => (selectedPipeline .value ? selectedPipeline .value .name : ' ' ));
92+ function cancelConfig() {
93+ menuState .value = ' idle' ;
94+ }
95+
7296 const includesLargeImage = computed (() => props .typeList .includes (LargeImageType ));
7397
7498 const successMessage = computed (() => (
@@ -124,7 +148,10 @@ export default defineComponent({
124148 return false ;
125149 });
126150
127- async function runPipelineOnSelectedItem(pipeline : Pipe ) {
151+ async function _runPipelineOnSelectedItemInner(
152+ pipeline : Pipe ,
153+ additionalConfigById ? : Record <string , Record <string , string > | undefined >,
154+ ) {
128155 if (props .selectedDatasetIds .length === 0 ) {
129156 throw new Error (' No selected datasets to run on' );
130157 }
@@ -150,10 +177,46 @@ export default defineComponent({
150177 }
151178 selectedPipe .value = pipeline ;
152179 await _runPipelineRequest (() => Promise .all (
153- datasetIds .map ((id ) => runPipeline (id , pipeline )),
180+ datasetIds .map ((id ) => {
181+ const additionalConfig = additionalConfigById ? additionalConfigById [id ] : undefined ;
182+ return runPipeline (id , pipeline , additionalConfig );
183+ }),
154184 ));
155185 }
156186
187+ async function runPipelineOnSelectedItem(pipeline : Pipe ) {
188+ if (! pipelineCreatesDatasetMarkers .includes (pipeline .type )) {
189+ _runPipelineOnSelectedItemInner (pipeline );
190+ } else {
191+ // If a pipeline creates datasets, open the configuration dialog
192+ // to allow users to name that dataset
193+ // This is relevant for filter and transcode pipeline types
194+ selectedPipeline .value = pipeline ;
195+ menuState .value = ' configuring' ; // force the dialog open
196+ }
197+ }
198+
199+ /**
200+ * Handle a user confirming additional configuration for filter
201+ * or transcode pipelines, which create new datasets.
202+ *
203+ * @param outputNameMap Map selected dataset IDs to the name
204+ * of the resultant dataset created by the pipeline
205+ */
206+ async function exitPipelineConfig(outputNameMap : Record <string , string >) {
207+ menuState .value = ' idle' ; // close the dialog
208+ const additionalConfigById: Record <string , Record <string , string >> = {};
209+ Object .keys (outputNameMap ).forEach ((id : string ) => {
210+ additionalConfigById [id ] = {
211+ outputDatasetName: outputNameMap [id ],
212+ };
213+ });
214+ if (selectedPipeline .value ) {
215+ _runPipelineOnSelectedItemInner (selectedPipeline .value , additionalConfigById );
216+ }
217+ selectedPipeline .value = null ; // reset selected pipeline state
218+ }
219+
157220 function pipeTypeDisplay(pipeType : string ) {
158221 switch (pipeType ) {
159222 case ' trained' :
@@ -179,6 +242,12 @@ export default defineComponent({
179242 runPipelineOnSelectedItem ,
180243 pipelinesCurrentlyRunning ,
181244 singlePipelineValue ,
245+ selectedPipeline ,
246+ selectedPipelineName ,
247+ configuring ,
248+ cancelConfig ,
249+ menuState ,
250+ exitPipelineConfig ,
182251 };
183252 },
184253});
@@ -337,5 +406,13 @@ export default defineComponent({
337406 :message =" successMessage"
338407 @close =" dismissLaunchDialog"
339408 />
409+ <JobConfigFilterTranscodeDialog
410+ :value =" menuState === 'configuring'"
411+ :dataset-name =" 'foo'"
412+ :pipeline-name =" selectedPipelineName"
413+ :selected-dataset-ids =" selectedDatasetIds"
414+ @cancel =" cancelConfig"
415+ @submit =" exitPipelineConfig"
416+ />
340417 </div >
341418</template >
0 commit comments