Skip to content

Commit a6f8805

Browse files
committed
Removed dataset filters and renamed ENABLE_INTERACTIVE_ATTRIBUTE_FILTERS to ENABLE_INTERACTIVE_FILTERS
1 parent 18f5aa9 commit a6f8805

File tree

16 files changed

+126
-202
lines changed

16 files changed

+126
-202
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ LOG_LEVEL_CONSOLE=warn
2020

2121
FRACTAL_RUNNER_BACKEND=local
2222
#WARNING_BANNER_PATH=/path/to/banner.txt
23-
ENABLE_INTERACTIVE_ATTRIBUTE_FILTERS=false
23+
ENABLE_INTERACTIVE_FILTERS=false
2424

2525
BODY_SIZE_LIMIT=5000000

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ LOG_LEVEL_CONSOLE=info
1919

2020
FRACTAL_RUNNER_BACKEND=local
2121
#WARNING_BANNER_PATH=/path/to/banner.txt
22-
ENABLE_INTERACTIVE_ATTRIBUTE_FILTERS=false
22+
ENABLE_INTERACTIVE_FILTERS=false

.github/workflows/end_to_end_tests.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
OAUTH_DEXIDP_OIDC_CONFIGURATION_ENDPOINT: "http://127.0.0.1:5556/dex/.well-known/openid-configuration"
2020
PUBLIC_OAUTH_CLIENT_NAME: dexidp
2121
PUBLIC_FRACTAL_VIZARR_VIEWER_URL: http://localhost:3000/vizarr
22-
ENABLE_INTERACTIVE_ATTRIBUTE_FILTERS: true
22+
ENABLE_INTERACTIVE_FILTERS: true
2323

2424
strategy:
2525
matrix:

__tests__/v2/RunWorkflowModal.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ describe('RunWorkflowModal', () => {
6868
num_available_images: 5
6969
}
7070
},
71-
attributeFiltersEnabled: false
71+
filtersEnabled: false
7272
});
7373

7474
result.component.open('continue');

components/src/lib/types/api.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ export type DatasetV2 = {
5858
project: ProjectV2;
5959
history: Array<DatasetHistoryItemV2> | null;
6060
zarr_dir: string;
61-
attribute_filters: { [key: string]: Array<string | number | boolean> | null };
62-
type_filters: { [key: string]: boolean };
6361
timestamp_created: string;
6462
};
6563

docs/environment-variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The following environment variables can be used to configure fractal-web.
1919
* `FRACTAL_RUNNER_BACKEND`: specifies which runner backend is used; supported values are: `local`, `slurm`, `slurm_ssh`; setting this variable is mandatory;
2020
* `PUBLIC_FRACTAL_VIZARR_VIEWER_URL`: URL to [fractal-vizarr-viewer](https://github.com/fractal-analytics-platform/fractal-vizarr-viewer) service (e.g. http://localhost:3000/vizarr for testing);
2121
* `WARNING_BANNER_PATH`: specifies the path to a text file containing the warning banner message displayed on the site; the banner is used to inform users about important issues, such as external resources downtime or maintenance alerts; if the variable is empty or unset no banner is displayed;
22-
* `ENABLE_INTERACTIVE_ATTRIBUTE_FILTERS`: enable attribute filters interactive editing from the job-submission modal; supported values are `true` or `false`; default value is `false`.
22+
* `ENABLE_INTERACTIVE_FILTERS`: enable attribute and type filters interactive editing from the job-submission modal; supported values are `true` or `false`; default value is `false`.
2323

2424
When running directly using `node` command these extra variables can also be configured:
2525

docs/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export FRACTAL_RUNNER_BACKEND=local
6666
#export AUTH_COOKIE_PATH=/
6767
#export AUTH_COOKIE_SAME_SITE=lax
6868
#export PUBLIC_UPDATE_JOBS_INTERVAL=3000
69-
#export ENABLE_INTERACTIVE_ATTRIBUTE_FILTERS=false
69+
#export ENABLE_INTERACTIVE_FILTERS=false
7070

7171
node build/
7272
```

src/lib/components/common/Modal.svelte

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,18 @@
8383
}
8484
8585
export function displayErrorAlert(/** @type {any} */ error) {
86-
errorAlert = displayStandardErrorAlert(error, `errorAlert-${id}`);
86+
const errorAlertId = `errorAlert-${id}`;
87+
errorAlert = displayStandardErrorAlert(error, errorAlertId);
88+
if (scrollable) {
89+
const modalBody = document.querySelector('.modal.show .modal-body');
90+
const errorAlert = document.getElementById(errorAlertId);
91+
if (modalBody && errorAlert) {
92+
modalBody.scrollTo({
93+
top: errorAlert.getBoundingClientRect().y,
94+
behavior: 'smooth'
95+
});
96+
}
97+
}
8798
}
8899
89100
function getBootstrapModal() {

src/lib/components/v2/projects/ProjectInfoModal.svelte

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,24 +82,13 @@
8282
<div id="errorAlert-projectInfoModal" />
8383
{#if datasets}
8484
<p class="lead">Datasets</p>
85-
<table class="table">
86-
<thead class="table-light">
87-
<tr>
88-
<th>Name</th>
89-
<th># Attribute Filters</th>
90-
<th># Type Filters</th>
91-
</tr>
92-
</thead>
93-
<tbody>
94-
{#each datasets as { name, attribute_filters, type_filters }}
95-
<tr>
96-
<td>{name}</td>
97-
<td>{Object.entries(attribute_filters).length}</td>
98-
<td>{Object.entries(type_filters).length}</td>
99-
</tr>
100-
{/each}
101-
</tbody>
102-
</table>
85+
<ul>
86+
{#each datasets as { name }}
87+
<li>
88+
{name}
89+
</li>
90+
{/each}
91+
</ul>
10392
{/if}
10493
</div>
10594
</div>

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

Lines changed: 23 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,49 +2,40 @@
22
import { displayStandardErrorAlert, getAlertErrorFromResponse } from '$lib/common/errors';
33
import ConfirmActionButton from '$lib/components/common/ConfirmActionButton.svelte';
44
import CreateUpdateImageModal from '$lib/components/v2/projects/datasets/CreateUpdateImageModal.svelte';
5-
import Paginator from '$lib/components/common/Paginator.svelte';
65
import BooleanIcon from 'fractal-components/common/BooleanIcon.svelte';
7-
import { deepCopy, objectChanged } from '$lib/common/component_utilities';
6+
import { objectChanged } from '$lib/common/component_utilities';
87
import SlimSelect from 'slim-select';
98
import { onDestroy, tick } from 'svelte';
10-
import Tooltip from '$lib/components/common/Tooltip.svelte';
119
1210
/** @type {import('fractal-components/types/api').DatasetV2} */
1311
export let dataset;
1412
/** @type {import('fractal-components/types/api').ImagePage} */
1513
export let imagePage;
1614
/** @type {string|null} */
1715
export let vizarrViewerUrl;
18-
/** @type {boolean} */
19-
export let useDatasetFilters;
2016
/**
2117
* Set to true if the table is displayed inside the "Run workflow" modal.
2218
* Used to disable some buttons.
2319
* @type {boolean}
2420
*/
2521
export let runWorkflowModal;
26-
export let attributeFiltersEnabled = true;
22+
export let filtersEnabled = true;
2723
/** @type {{ attribute_filters: { [key: string]: Array<string | number | boolean> | null }, type_filters: { [key: string]: boolean | null }} | null} */
2824
export let initialFilterValues = null;
2925
30-
let datasetFiltersChanged = false;
3126
/** @type {(dataset: import('fractal-components/types/api').DatasetV2) => void} */
3227
export let onDatasetsUpdated = () => {};
3328
3429
let showTable = false;
3530
let firstLoad = true;
3631
37-
/** @type {Tooltip|undefined} */
38-
let currentSelectionTooltip;
39-
4032
/** @type {CreateUpdateImageModal|undefined} */
4133
let imageModal = undefined;
4234
4335
let searching = false;
4436
let resetting = false;
4537
let savingDatasetFilters = false;
4638
47-
let loading = false;
4839
/** @type {{ [key: string]: Array<string | number | boolean> | null}} */
4940
let attributeFilters = {};
5041
@@ -132,41 +123,29 @@
132123
133124
export async function applySearchFields() {
134125
searching = true;
135-
await searchImages();
126+
const params = await searchImages();
136127
resetBtnActive =
137128
Object.values(attributeFilters).filter((a) => a !== null).length > 0 ||
138129
Object.values(typeFilters).filter((t) => t !== null).length > 0;
139130
searching = false;
131+
return params;
140132
}
141133
142134
async function resetSearchFields() {
143135
resetBtnActive = false;
144136
resetting = true;
145-
if (useDatasetFilters) {
146-
attributeFilters = deepCopy(dataset.attribute_filters);
147-
typeFilters = deepCopy(dataset.type_filters);
148-
} else {
149-
attributeFilters = getAttributeFilterBaseValues(imagePage);
150-
typeFilters = getTypeFilterBaseValues(imagePage);
151-
}
137+
attributeFilters = getAttributeFilterBaseValues(imagePage);
138+
typeFilters = getTypeFilterBaseValues(imagePage);
152139
await tick();
153140
await searchImages();
154141
resetting = false;
155142
}
156143
157144
export async function load() {
158-
loading = true;
159-
currentSelectionTooltip?.setEnabled(!useDatasetFilters);
160-
if (useDatasetFilters) {
161-
attributeFilters = deepCopy(dataset.attribute_filters);
162-
typeFilters = deepCopy(dataset.type_filters);
163-
} else {
164-
attributeFilters = getAttributeFilterBaseValues(imagePage);
165-
typeFilters = getTypeFilterBaseValues(imagePage);
166-
}
145+
attributeFilters = getAttributeFilterBaseValues(imagePage);
146+
typeFilters = getTypeFilterBaseValues(imagePage);
167147
await tick();
168148
await searchImages();
169-
loading = false;
170149
}
171150
172151
onDestroy(() => {
@@ -233,12 +212,10 @@
233212
])
234213
);
235214
236-
if (runWorkflowModal) {
237-
if (!attributeFiltersEnabled) {
238-
// disable attribute filters selection
239-
for (const attributeSelector of Object.values(attributesSelectors)) {
240-
attributeSelector.disable();
241-
}
215+
if (runWorkflowModal && !filtersEnabled) {
216+
// disable attribute filters selection
217+
for (const attributeSelector of Object.values(attributesSelectors)) {
218+
attributeSelector.disable();
242219
}
243220
// disable type filters selection
244221
for (const typeSelector of Object.values(typesSelectors)) {
@@ -351,6 +328,7 @@
351328
/**
352329
* @param {number|null} currentPage
353330
* @param {number|null} pageSize
331+
* @returns {Promise<{ attribute_filters: any, type_filters: any }>}
354332
*/
355333
async function searchImages(currentPage = null, pageSize = null) {
356334
if (currentPage === null) {
@@ -417,6 +395,7 @@
417395
'datasetImagesError'
418396
);
419397
}
398+
return params;
420399
}
421400
422401
/**
@@ -502,13 +481,6 @@
502481
}
503482
}
504483
505-
$: if (attributeFilters && typeFilters) {
506-
datasetFiltersChanged =
507-
!applyBtnActive &&
508-
(attributesChanged(dataset.attribute_filters, removeNullValues(attributeFilters)) ||
509-
objectChanged(dataset.type_filters, removeNullValues(typeFilters)));
510-
}
511-
512484
$: if (dataset) {
513485
resetBtnActive = false;
514486
}
@@ -678,12 +650,12 @@
678650
{/if}
679651
Reset
680652
</button>
681-
{#if !runWorkflowModal && useDatasetFilters}
653+
{#if !runWorkflowModal}
682654
<ConfirmActionButton
683655
modalId="confirmSaveDatasetFilters"
684656
label="Save"
685657
message="Save dataset filters"
686-
disabled={!datasetFiltersChanged || savingDatasetFilters}
658+
disabled={savingDatasetFilters}
687659
callbackAction={async () => {
688660
await saveDatasetFilters();
689661
}}
@@ -753,73 +725,16 @@
753725
</tbody>
754726
</table>
755727
</div>
756-
<div class="pb-2" id="dataset-filters-wrapper" class:sticky-bottom={!runWorkflowModal}>
757-
<div class="row">
758-
<div class="col-lg-3 mb-3">
759-
{#if !runWorkflowModal}
760-
<input
761-
type="radio"
762-
class="btn-check"
763-
name="filters-switch"
764-
id="all-images"
765-
autocomplete="off"
766-
value={false}
767-
bind:group={useDatasetFilters}
768-
on:change={load}
769-
disabled={loading || searching || resetting}
770-
/>
771-
<label class="btn btn-white btn-outline-primary" for="all-images">All images</label>
772-
<Tooltip
773-
id="current-selection-label"
774-
title="These are default selection for images on which a workflow will be run"
775-
placement="bottom"
776-
bind:this={currentSelectionTooltip}
777-
>
778-
<input
779-
type="radio"
780-
class="btn-check"
781-
name="filters-switch"
782-
id="current-selection"
783-
autocomplete="off"
784-
value={true}
785-
bind:group={useDatasetFilters}
786-
on:change={load}
787-
disabled={loading || searching || resetting}
788-
/>
789-
<label class="btn btn-white btn-outline-primary" for="current-selection">
790-
Current selection
791-
</label>
792-
</Tooltip>
793-
{#if loading}
794-
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" />
795-
{/if}
796-
{/if}
797-
</div>
798-
<div class="col-lg-6">
799-
<Paginator
800-
currentPage={imagePage.current_page}
801-
pageSize={imagePage.page_size}
802-
totalCount={imagePage.total_count}
803-
onPageChange={searchImages}
804-
/>
805-
</div>
806-
{#if !runWorkflowModal}
807-
<div class="col-lg-3">
808-
<button
809-
class="btn btn-outline-secondary float-end"
810-
on:click={() => imageModal?.openForCreate()}
811-
>
812-
<i class="bi bi-plus-circle" />
813-
Add an image list entry
814-
</button>
815-
</div>
816-
{/if}
817-
</div>
818-
</div>
819728
</div>
820729
{/if}
821730
822-
<CreateUpdateImageModal {dataset} onImageSave={searchImages} bind:this={imageModal} />
731+
<CreateUpdateImageModal
732+
{dataset}
733+
onImageSave={async () => {
734+
await searchImages();
735+
}}
736+
bind:this={imageModal}
737+
/>
823738
824739
<style>
825740
#dataset-images-table td:last-child,
@@ -831,15 +746,6 @@
831746
word-break: break-all;
832747
}
833748
834-
#dataset-filters-wrapper {
835-
background-color: #fff;
836-
}
837-
838-
.btn-check:not(:checked) + .btn-white {
839-
color: #0d6efd;
840-
background-color: #fff;
841-
}
842-
843749
.wrap {
844750
white-space: normal;
845751
}

0 commit comments

Comments
 (0)