Skip to content

Commit e64dd62

Browse files
committed
Changed job submission warning logic
1 parent ca75965 commit e64dd62

File tree

2 files changed

+52
-31
lines changed

2 files changed

+52
-31
lines changed

src/lib/components/v2/projects/datasets/DatasetImagesTable.svelte

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
import ConfirmActionButton from '$lib/components/common/ConfirmActionButton.svelte';
44
import CreateUpdateImageModal from '$lib/components/v2/projects/datasets/CreateUpdateImageModal.svelte';
55
import BooleanIcon from 'fractal-components/common/BooleanIcon.svelte';
6-
import { encodePathForUrl, hideAllTooltips, objectChanged } from '$lib/common/component_utilities';
6+
import {
7+
encodePathForUrl,
8+
hideAllTooltips,
9+
objectChanged
10+
} from '$lib/common/component_utilities';
711
import SlimSelect from 'slim-select';
812
import { onDestroy, tick } from 'svelte';
913
import Paginator from '$lib/components/common/Paginator.svelte';
@@ -27,7 +31,10 @@
2731
export let initialFilterValues = null;
2832
/** @type {string[]} */
2933
export let disabledTypes = [];
30-
export let beforeSelectionChanged = () => {};
34+
/** @type {(key: string) => void} */
35+
export let beforeTypeSelectionChanged = () => {};
36+
/** @type {string[]} */
37+
export let highlightedTypes = [];
3138
3239
/**
3340
* Set to true if the table is displayed inside the "Images status" modal.
@@ -267,7 +274,6 @@
267274
},
268275
events: {
269276
beforeChange: () => {
270-
beforeSelectionChanged();
271277
return true;
272278
},
273279
afterChange: (selection) => {
@@ -304,7 +310,7 @@
304310
},
305311
events: {
306312
beforeChange: () => {
307-
beforeSelectionChanged();
313+
beforeTypeSelectionChanged(key);
308314
return true;
309315
},
310316
afterChange: (selection) => {
@@ -343,10 +349,6 @@
343349
isMultiple: false
344350
},
345351
events: {
346-
beforeChange: () => {
347-
beforeSelectionChanged();
348-
return true;
349-
},
350352
afterChange: (selection) => {
351353
const selectedOption = selection[0];
352354
if (!selectedOption || selectedOption.placeholder) {
@@ -685,7 +687,7 @@
685687
</th>
686688
{/each}
687689
{#each imagePage.types as typeKey}
688-
<th>
690+
<th class:bg-warning-subtle={highlightedTypes.includes(typeKey)}>
689691
<label for="type-{getIdFromValue(typeKey)}">
690692
{typeKey}
691693
</label>
@@ -718,7 +720,7 @@
718720
</th>
719721
{/each}
720722
{#each imagePage.types as typeKey}
721-
<th>
723+
<th class:bg-warning-subtle={highlightedTypes.includes(typeKey)}>
722724
<div class="type-select-wrapper mb-1">
723725
<select id="type-{getIdFromValue(typeKey)}" class="invisible" />
724726
</div>

src/lib/components/v2/workflow/RunWorkflowModal.svelte

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
let checkingConfiguration = false;
3535
/** @type {string[]} */
3636
let preSubmissionCheckResults = [];
37+
let ignorePreSubmissionCheck = false;
3738
let setSlurmAccount = true;
3839
/** @type {string[]} */
3940
let slurmAccounts = [];
@@ -82,6 +83,7 @@
8283
applyingWorkflow = false;
8384
checkingConfiguration = false;
8485
preSubmissionCheckResults = [];
86+
ignorePreSubmissionCheck = false;
8587
workerInitControl = '';
8688
if (mode === 'run' || mode === 'restart') {
8789
firstTaskIndex = 0;
@@ -214,6 +216,7 @@
214216
215217
async function firstTaskIndexChanged() {
216218
preSubmissionCheckResults = [];
219+
ignorePreSubmissionCheck = false;
217220
await loadDatasetImages();
218221
// reset last task
219222
if (
@@ -233,9 +236,14 @@
233236
async function showConfirmRun() {
234237
if (datasetImagesTable) {
235238
const params = await datasetImagesTable.applySearchFields();
236-
const valid = await preSubmissionCheck(params);
237-
if (!valid) {
238-
return;
239+
if (ignorePreSubmissionCheck) {
240+
preSubmissionCheckResults = [];
241+
ignorePreSubmissionCheck = false;
242+
} else {
243+
const valid = await preSubmissionCheck(params);
244+
if (!valid) {
245+
return;
246+
}
239247
}
240248
}
241249
const wft = workflow.task_list[firstTaskIndex || 0];
@@ -276,13 +284,15 @@
276284
const valid = preSubmissionCheckResults.length === 0;
277285
if (!valid) {
278286
await tick();
279-
// scroll to error message
287+
// scroll to warning message
280288
const modalBody = document.querySelector('.modal.show .modal-body');
281-
const errorAlert = document.getElementById('pre-submission-check-error');
282-
if (modalBody && errorAlert) {
283-
const rect = errorAlert.getBoundingClientRect();
289+
const warningAlert = document.getElementById('pre-submission-check-warning');
290+
if (modalBody && warningAlert) {
291+
const bodyRect = modalBody.getBoundingClientRect();
292+
const alertRect = warningAlert.getBoundingClientRect();
293+
const alertRelativeY = alertRect.y - bodyRect.y;
284294
modalBody.scrollTo({
285-
top: rect.y + rect.height,
295+
top: alertRelativeY + modalBody.scrollTop,
286296
behavior: 'smooth'
287297
});
288298
}
@@ -539,6 +549,22 @@
539549
data-bs-parent="#accordion-run-workflow"
540550
>
541551
<div class="accordion-body">
552+
{#if preSubmissionCheckResults.length > 0}
553+
<div class="alert alert-warning mb-0" id="pre-submission-check-warning">
554+
You are trying to run a workflow without specifying what type of images should
555+
be processed. Specify the relevant type filter to continue.
556+
<button
557+
type="button"
558+
class="btn btn-warning mt-1"
559+
on:click={() => {
560+
ignorePreSubmissionCheck = true;
561+
showConfirmRun();
562+
}}
563+
>
564+
Continue anyway
565+
</button>
566+
</div>
567+
{/if}
542568
{#if checkingConfiguration}
543569
This job will process {imagePage.total_count}
544570
{imagePage.total_count === 1 ? 'image' : 'images'}.
@@ -549,26 +575,19 @@
549575
bind:imagePage
550576
{initialFilterValues}
551577
{disabledTypes}
578+
highlightedTypes={preSubmissionCheckResults}
552579
vizarrViewerUrl={null}
553580
runWorkflowModal={true}
554-
beforeSelectionChanged={() => (preSubmissionCheckResults = [])}
581+
beforeTypeSelectionChanged={(key) => {
582+
preSubmissionCheckResults = preSubmissionCheckResults.filter(
583+
(k) => k !== key
584+
);
585+
}}
555586
/>
556587
{/if}
557588
</div>
558589
</div>
559590
</div>
560-
{#if preSubmissionCheckResults.length > 0}
561-
<div class="alert alert-danger mt-3 alert-dismissible" id="pre-submission-check-error">
562-
Image list includes multiple values for the following types:
563-
<ul>
564-
{#each preSubmissionCheckResults as item}
565-
<li><code>{item}</code></li>
566-
{/each}
567-
</ul>
568-
Please select one specific value from the dropdown menu.
569-
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close" />
570-
</div>
571-
{/if}
572591
{/if}
573592
{#if datasetImagesLoading}
574593
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" />

0 commit comments

Comments
 (0)