From 38c47143a11debfbc561b86d52d5b72877743656 Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Mon, 18 Nov 2024 09:27:47 +0100 Subject: [PATCH 1/7] Removed usage of DB_ENGINE and SQLITE_PATH variables --- examples/config_1/fractal_server.md | 3 --- examples/config_2_with_domain/fractal_server.md | 3 --- examples/config_3_with_domain_and_https/fractal_server.md | 1 - examples/config_4_with_domain_and_https/fractal_server.md | 1 - tests/.fractal_server.env | 1 - 5 files changed, 9 deletions(-) diff --git a/examples/config_1/fractal_server.md b/examples/config_1/fractal_server.md index 3585fbe5..24b2f90f 100644 --- a/examples/config_1/fractal_server.md +++ b/examples/config_1/fractal_server.md @@ -10,8 +10,6 @@ FRACTAL_TASKS_DIR=tasks FRACTAL_LOGGING_LEVEL=00 FRACTAL_RUNNER_BACKEND=local FRACTAL_RUNNER_WORKING_BASE_DIR=artifacts -DB_ENGINE=sqlite -SQLITE_PATH=fractal_server.db ``` Set-up and start-up command: @@ -24,7 +22,6 @@ Logs include ``` INFO: Started server process [32331] INFO: Waiting for application startup. -2023-05-18 07:55:41,391 - fractal_server.app.db - WARNING - SQLite is supported but discouraged in production. Given its partial support for ForeignKey constraints, consistency of the database cannot be guaranteed. 2023-05-18 07:55:41,742 - fractal_server.main - INFO - User admin@fractal.xy created INFO: Application startup complete. INFO: Uvicorn running on http://X.X.X.X:8000 (Press CTRL+C to quit) diff --git a/examples/config_2_with_domain/fractal_server.md b/examples/config_2_with_domain/fractal_server.md index c8d8b889..22904d44 100644 --- a/examples/config_2_with_domain/fractal_server.md +++ b/examples/config_2_with_domain/fractal_server.md @@ -11,8 +11,6 @@ FRACTAL_TASKS_DIR=tasks FRACTAL_LOGGING_LEVEL=00 FRACTAL_RUNNER_BACKEND=local FRACTAL_RUNNER_WORKING_BASE_DIR=artifacts -DB_ENGINE=sqlite -SQLITE_PATH=fractal_server.db ``` Set-up and start-up command: @@ -27,7 +25,6 @@ Logs include fractal_server.app.db INFO: Started server process [32375] INFO: Waiting for application startup. -2023-06-13 08:23:13,678 - fractal_server.app.db - WARNING - SQLite is supported but discouraged in production. Given its partial support for ForeignKey constraints, consistency of the database cannot be guaranteed. 2023-06-13 08:23:13,736 - fractal_server.main - WARNING - User admin@fractal.xy already exists INFO: Application startup complete. INFO: Uvicorn running on http://fractal.XXX.ch:8000 (Press CTRL+C to quit) diff --git a/examples/config_3_with_domain_and_https/fractal_server.md b/examples/config_3_with_domain_and_https/fractal_server.md index 2e04aa43..b2bf30d6 100644 --- a/examples/config_3_with_domain_and_https/fractal_server.md +++ b/examples/config_3_with_domain_and_https/fractal_server.md @@ -4,7 +4,6 @@ DEPLOYMENT_TYPE=testing JWT_SECRET_KEY=XXX JWT_EXPIRE_SECONDS=80000 -DB_ENGINE=postgres-psycopg POSTGRES_USER=XXX POSTGRES_HOST=XXX POSTGRES_DB=XXX diff --git a/examples/config_4_with_domain_and_https/fractal_server.md b/examples/config_4_with_domain_and_https/fractal_server.md index 2e04aa43..b2bf30d6 100644 --- a/examples/config_4_with_domain_and_https/fractal_server.md +++ b/examples/config_4_with_domain_and_https/fractal_server.md @@ -4,7 +4,6 @@ DEPLOYMENT_TYPE=testing JWT_SECRET_KEY=XXX JWT_EXPIRE_SECONDS=80000 -DB_ENGINE=postgres-psycopg POSTGRES_USER=XXX POSTGRES_HOST=XXX POSTGRES_DB=XXX diff --git a/tests/.fractal_server.env b/tests/.fractal_server.env index cddcadac..68ad2305 100644 --- a/tests/.fractal_server.env +++ b/tests/.fractal_server.env @@ -1,6 +1,5 @@ DEPLOYMENT_TYPE=testing JWT_SECRET_KEY=somethingverysecret -DB_ENGINE=postgres-psycopg POSTGRES_DB=fractal_test POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres From c5ac729e92e25be6558abf0a75b520484df31b6b Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Mon, 18 Nov 2024 10:29:09 +0100 Subject: [PATCH 2/7] Displayed timestamp_last_used property in task-group info modal --- src/lib/components/v2/tasks/TaskGroupInfoModal.svelte | 5 +++++ src/lib/types-v2.d.ts | 1 + src/routes/v2/admin/task-groups/+page.svelte | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/components/v2/tasks/TaskGroupInfoModal.svelte b/src/lib/components/v2/tasks/TaskGroupInfoModal.svelte index ec653b53..fe861608 100644 --- a/src/lib/components/v2/tasks/TaskGroupInfoModal.svelte +++ b/src/lib/components/v2/tasks/TaskGroupInfoModal.svelte @@ -1,5 +1,6 @@

Viewer paths

+

+ This Fractal instance includes an online viewer for OME-Zarrs, based on + vizarr. Browse to a dataset page, + and you will find links to view the available images in the browser. +

+ +

+ Note that access to image data is restricted to OME-Zarrs within certain paths (and their + subfolders). + {#if settings.project_dir || viewerPaths.length > 0} + The list of paths accessible to the current user includes: + {:else} + The list of paths accessible to the current user is empty. + {/if} +

+ + +

+ Depending on the Fractal configuration, you may also have access to additional paths.
+ Please contact an admin if you see an error message like 403 Forbidden when opening the + image viewer. +

diff --git a/tests/v2/viewer_paths.spec.js b/tests/v2/viewer_paths.spec.js index a2223043..6bf1e51d 100644 --- a/tests/v2/viewer_paths.spec.js +++ b/tests/v2/viewer_paths.spec.js @@ -43,6 +43,11 @@ test('Viewer paths', async ({ page }) => { await addUserToGroup(page, randomEmail); }); + await test.step('Add project dir to the group', async () => { + await page.getByRole('textbox', { name: 'Project dir' }).fill('/path/to/project_dir'); + await page.getByRole('button', { name: 'Save' }).nth(1).click(); + }); + await test.step('Add viewer paths', async () => { const addViewerPathBtn = page.getByRole('button', { name: 'Add viewer path' }); await addViewerPathBtn.click(); @@ -79,6 +84,7 @@ test('Viewer paths', async ({ page }) => { await page.getByRole('link', { name: 'Viewer paths' }).click(); await waitPageLoading(page); await expect(page.getByText('/path/to/1')).toBeVisible(); + await expect(page.getByText('/path/to/project_dir')).toBeVisible(); await logout(page, randomEmail); }); }); From 4950c419114855670c915421077608536dde4ee0 Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Tue, 19 Nov 2024 10:20:54 +0100 Subject: [PATCH 6/7] Added manage buttons on admin task-groups page --- CHANGELOG.md | 1 + playwright.config.js | 2 +- .../v2/tasks/TaskGroupActivities.svelte | 2 +- .../v2/tasks/TaskGroupManageModal.svelte | 10 +++- .../v2/tasks/TaskGroupsTable.svelte | 2 +- src/routes/v2/admin/task-groups/+page.svelte | 10 +++- tests/v2/admin_task_group_manage.spec.js | 59 +++++++++++++++++++ tests/v2/task_group_manage.spec.js | 7 +-- 8 files changed, 82 insertions(+), 11 deletions(-) create mode 100644 tests/v2/admin_task_group_manage.spec.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ae13e5..bfd8e50f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Removed usage of DB_ENGINE and SQLITE_PATH variables (\#643); * Displayed `timestamp_last_used` property in task-group info modal (\#643); * Viewer paths page improvements (\#643); + * Added manage buttons on admin task-groups page (\#643); # 1.10.1 diff --git a/playwright.config.js b/playwright.config.js index 20c2eda1..4c6c9ba8 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -107,7 +107,7 @@ export default defineConfig({ webServer: [ { - command: './tests/start-test-server.sh 2.9.0a2', + command: './tests/start-test-server.sh 2.9.0a4', port: 8000, waitForPort: true, stdout: 'pipe', diff --git a/src/lib/components/v2/tasks/TaskGroupActivities.svelte b/src/lib/components/v2/tasks/TaskGroupActivities.svelte index abfe3b19..f7a32b00 100644 --- a/src/lib/components/v2/tasks/TaskGroupActivities.svelte +++ b/src/lib/components/v2/tasks/TaskGroupActivities.svelte @@ -154,7 +154,7 @@ if (activityId && !isNaN(Number(activityId))) { task_group_activity_id = Number(activityId); } - if (!admin) { + if (!admin || task_group_activity_id !== null) { await searchActivities(); } updateTasksCollectionTimeout = setTimeout( diff --git a/src/lib/components/v2/tasks/TaskGroupManageModal.svelte b/src/lib/components/v2/tasks/TaskGroupManageModal.svelte index 48280b1a..7ab7a6bb 100644 --- a/src/lib/components/v2/tasks/TaskGroupManageModal.svelte +++ b/src/lib/components/v2/tasks/TaskGroupManageModal.svelte @@ -3,6 +3,9 @@ import { displayStandardErrorAlert, getAlertErrorFromResponse } from '$lib/common/errors'; import Modal from '../../common/Modal.svelte'; + /** @type {boolean} */ + export let admin; + /** @type {Modal} */ let modal; @@ -36,7 +39,9 @@ headers.append('Content-Type', 'application/json'); const response = await fetch( - `/api/v2/task-group/${taskGroup?.id}/${active ? 'reactivate' : 'deactivate'}/`, + `/api/${admin ? 'admin/' : ''}v2/task-group/${taskGroup?.id}/${ + active ? 'reactivate' : 'deactivate' + }/`, { method: 'POST', credentials: 'include', @@ -48,7 +53,8 @@ if (response.ok) { const result = await response.json(); - goto(`/v2/tasks/activities?activity_id=${result.id}`); + const page = admin ? `/v2/admin/task-groups/activities` : `/v2/tasks/activities`; + goto(`${page}?activity_id=${result.id}`); modal.hide(); } else { errorAlert = displayStandardErrorAlert( diff --git a/src/lib/components/v2/tasks/TaskGroupsTable.svelte b/src/lib/components/v2/tasks/TaskGroupsTable.svelte index 9e0e8b9d..9b3e5860 100644 --- a/src/lib/components/v2/tasks/TaskGroupsTable.svelte +++ b/src/lib/components/v2/tasks/TaskGroupsTable.svelte @@ -268,7 +268,7 @@ {updateEditedTaskGroup} groupIdsNames={user.group_ids_names || []} /> - + diff --git a/src/routes/v2/admin/task-groups/+page.svelte b/src/routes/v2/admin/task-groups/+page.svelte index cadb4bec..67ffca05 100644 --- a/src/routes/v2/admin/task-groups/+page.svelte +++ b/src/routes/v2/admin/task-groups/+page.svelte @@ -6,6 +6,7 @@ import Modal from '$lib/components/common/Modal.svelte'; import TimestampCell from '$lib/components/jobs/TimestampCell.svelte'; import TaskGroupEditModal from '$lib/components/v2/tasks/TaskGroupEditModal.svelte'; + import TaskGroupManageModal from '$lib/components/v2/tasks/TaskGroupManageModal.svelte'; /** @type {Array} */ const users = $page.data.users; @@ -36,6 +37,8 @@ /** @type {import('$lib/components/v2/tasks/TaskGroupEditModal.svelte').default} */ let taskGroupEditModal; + /** @type {import('$lib/components/v2/tasks/TaskGroupManageModal.svelte').default} */ + let taskGroupManageModal; async function searchTaskGroups() { searching = true; @@ -267,7 +270,7 @@ - + @@ -304,6 +307,10 @@ Edit + [g.id, g.name])} /> + diff --git a/tests/v2/admin_task_group_manage.spec.js b/tests/v2/admin_task_group_manage.spec.js new file mode 100644 index 00000000..8e2abf8e --- /dev/null +++ b/tests/v2/admin_task_group_manage.spec.js @@ -0,0 +1,59 @@ +import { expect, test } from '@playwright/test'; +import { waitPageLoading } from '../utils.js'; +import { createFakeTask, deleteTask } from './task_utils.js'; + +test('Admin task group manage (deactivate / reactivate)', async ({ page }) => { + let taskName; + await test.step('Create test task group', async () => { + taskName = await createFakeTask(page, { + type: 'non_parallel' + }); + }); + + await test.step('Open admin task-groups page', async () => { + await page.goto('/v2/admin/task-groups'); + await waitPageLoading(page); + await page.getByRole('textbox', { name: 'Package name' }).fill(taskName); + await page.getByRole('button', { name: 'Search task groups' }).click(); + }); + + await test.step('Deactivate the task', async () => { + await page.getByRole('row', { name: taskName }).getByRole('button', { name: 'Manage' }).click(); + const modal = page.locator('.modal.show'); + await modal.waitFor(); + await expect(modal.getByText('The task group is currently active')).toBeVisible(); + await modal.getByText('active').click(); + await modal.getByRole('button', { name: 'Deactivate task group' }).click(); + await modal.getByRole('button', { name: 'Confirm' }).click(); + }); + + await test.step('Verify that page loads the proper activity', async () => { + await page.waitForURL(/\/v2\/admin\/task-groups\/activities\?activity_id=\d+/); + await waitPageLoading(page); + await expect(page.getByRole('row')).toHaveCount(2); + await expect(page.getByRole('row', { name: taskName })).toContainText('deactivate'); + }); + + await test.step('Go back to previous page and reactivate the task', async () => { + await page.goBack(); + await waitPageLoading(page); + await page.getByRole('textbox', { name: 'Package name' }).fill(taskName); + await page.getByRole('button', { name: 'Search task groups' }).click(); + await page.getByRole('row', { name: taskName }).getByRole('button', { name: 'Manage' }).click(); + const modal = page.locator('.modal.show'); + await modal.waitFor(); + await modal.getByText('active').click(); + await modal.getByRole('button', { name: 'Reactivate task group' }).click(); + }); + + await test.step('Verify that page loads the proper activity', async () => { + await page.waitForURL(/\/v2\/admin\/task-groups\/activities\?activity_id=\d+/); + await waitPageLoading(page); + await expect(page.getByRole('row')).toHaveCount(2); + await expect(page.getByRole('row', { name: taskName })).toContainText('reactivate'); + }); + + await test.step('Cleanup', async () => { + await deleteTask(page, taskName); + }); +}); diff --git a/tests/v2/task_group_manage.spec.js b/tests/v2/task_group_manage.spec.js index a02ce4d7..89d73604 100644 --- a/tests/v2/task_group_manage.spec.js +++ b/tests/v2/task_group_manage.spec.js @@ -1,11 +1,8 @@ -import { expect, test } from './workflow_fixture.js'; +import { expect, test } from '@playwright/test'; import { waitPageLoading } from '../utils.js'; import { createFakeTask, deleteTask } from './task_utils.js'; -test('Task group manage (deactivate / reactivate)', async ({ page, workflow }) => { - await page.waitForURL(workflow.url); - await waitPageLoading(page); - +test('Task group manage (deactivate / reactivate)', async ({ page }) => { let taskName; await test.step('Create test task group', async () => { taskName = await createFakeTask(page, { From a55afd7f0311a3c36cd1a888e7acedce6d765bd9 Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Wed, 20 Nov 2024 12:20:41 +0100 Subject: [PATCH 7/7] Added last used timestamp filter to task-group admin page --- CHANGELOG.md | 1 + playwright.config.js | 2 +- src/routes/v2/admin/task-groups/+page.svelte | 63 ++++++++++++++++++++ tests/v2/admin_task_groups.spec.js | 16 +++++ 4 files changed, 81 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfd8e50f..412c3cbf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ * Displayed `timestamp_last_used` property in task-group info modal (\#643); * Viewer paths page improvements (\#643); * Added manage buttons on admin task-groups page (\#643); + * Added last used timestamp filter to task-group admin page (\#643); # 1.10.1 diff --git a/playwright.config.js b/playwright.config.js index 4c6c9ba8..e359d429 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -107,7 +107,7 @@ export default defineConfig({ webServer: [ { - command: './tests/start-test-server.sh 2.9.0a4', + command: './tests/start-test-server.sh 2.9.0a5', port: 8000, waitForPort: true, stdout: 'pipe', diff --git a/src/routes/v2/admin/task-groups/+page.svelte b/src/routes/v2/admin/task-groups/+page.svelte index 67ffca05..9aa5bc06 100644 --- a/src/routes/v2/admin/task-groups/+page.svelte +++ b/src/routes/v2/admin/task-groups/+page.svelte @@ -1,5 +1,6 @@