Skip to content

Commit e37881e

Browse files
authored
Merge pull request #658 from fractal-analytics-platform/tasks-filter
Added task filters, split tasks page in "tasks" and "tasks management"
2 parents 8f377e8 + 10c5c7e commit e37881e

28 files changed

+951
-263
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
*Note: Numbers like (\#123) point to closed Pull Requests on the fractal-web repository.*
22

3+
# Unreleased
4+
5+
* Added tasks search filters (\#658);
6+
* Split standard-user tasks page into "tasks page" vs "tasks management page" (\#658);
7+
* Added alive endpoint (\#658);
8+
* Added user column and sorted users by email in `/v2/admin/task-groups/activities` (\#658);
9+
310
# 1.11.0
411

512
* Alignment with fractal-server 2.9.0 (\#640, \#643, \#652, \#655):

__tests__/v2/AddWorkflowTaskModal.test.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ describe('AddWorkflowTaskModal', () => {
4747
category: null,
4848
modality: null,
4949
authors: null,
50-
tags: []
50+
tags: [],
51+
input_types: {},
52+
docs_info: ''
5153
}
5254
],
5355
user_id: 1,
@@ -66,7 +68,9 @@ describe('AddWorkflowTaskModal', () => {
6668
category: null,
6769
modality: null,
6870
authors: null,
69-
tags: []
71+
tags: [],
72+
input_types: {},
73+
docs_info: ''
7074
}
7175
],
7276
user_id: 1,
@@ -117,7 +121,9 @@ describe('AddWorkflowTaskModal', () => {
117121
category: null,
118122
modality: null,
119123
authors: null,
120-
tags: []
124+
tags: [],
125+
input_types: {},
126+
docs_info: ''
121127
}
122128
],
123129
user_id: 1,
@@ -136,7 +142,9 @@ describe('AddWorkflowTaskModal', () => {
136142
category: null,
137143
modality: null,
138144
authors: null,
139-
tags: []
145+
tags: [],
146+
input_types: {},
147+
docs_info: ''
140148
}
141149
],
142150
user_id: 1,
@@ -165,7 +173,7 @@ describe('AddWorkflowTaskModal', () => {
165173
);
166174
await waitFor(() => screen.getAllByText(/test_task/));
167175

168-
const dropdown = screen.getByRole('combobox');
176+
const dropdown = await screen.findByRole('combobox');
169177
expect(dropdown.options.length).eq(2);
170178
expect(dropdown.options[0].text).eq('0.0.1');
171179
expect(dropdown.options[1].text).eq('INVALID');

package-lock.json

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@testing-library/jest-dom": "^6.6.2",
2525
"@testing-library/svelte": "^4.0.4",
2626
"@testing-library/user-event": "^14.5.2",
27+
"@types/color-hash": "^2.0.0",
2728
"@types/dompurify": "^3.0.2",
2829
"@types/node": "^22.7.4",
2930
"dotenv": "^16.3.1",
@@ -46,6 +47,7 @@
4647
"@vincjo/datatables": "^1.14.10",
4748
"ajv": "^8.12.0",
4849
"ajv-formats": "^3.0.1",
50+
"color-hash": "^2.0.2",
4951
"dompurify": "^3.0.5",
5052
"jose": "^4.14.4",
5153
"log4js": "^6.9.1",

src/hooks.server.js

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { env } from '$env/dynamic/private';
2+
import { getServerInfo } from '$lib/server/api/alive';
23
import { getCurrentUser } from '$lib/server/api/auth_api';
34
import { getLogger } from '$lib/server/logger.js';
45
import { error, redirect } from '@sveltejs/kit';
@@ -64,7 +65,8 @@ export async function handle({ event, resolve }) {
6465

6566
const isPublicPage =
6667
event.url.pathname == '/' ||
67-
event.url.pathname.startsWith('/auth');
68+
event.url.pathname.startsWith('/auth') ||
69+
event.url.pathname.startsWith('/alive');
6870

6971
if (isPublicPage) {
7072
logger.debug('Public page - No auth required');
@@ -109,31 +111,6 @@ export async function handleFetch({ event, request, fetch }) {
109111
return fetch(request);
110112
}
111113

112-
/**
113-
* @param {typeof fetch} fetch
114-
* @returns {Promise<{ alive: boolean, version: string | null }>}
115-
*/
116-
async function getServerInfo(fetch) {
117-
let serverInfo = { alive: false, version: null };
118-
119-
try {
120-
const serverInfoResponse = await fetch(env.FRACTAL_SERVER_HOST + '/api/alive/');
121-
if (serverInfoResponse.ok) {
122-
serverInfo = await serverInfoResponse.json();
123-
logger.debug('Server info loaded: Alive %s - %s', serverInfo.alive, serverInfo.version);
124-
} else {
125-
logger.error(
126-
'Alive endpoint replied with unsuccessful status code %d',
127-
serverInfoResponse.status
128-
);
129-
}
130-
} catch (error) {
131-
logger.fatal('Error loading server info', error);
132-
}
133-
134-
return serverInfo;
135-
}
136-
137114
/**
138115
* @param {typeof fetch} fetch
139116
* @returns {Promise<import('$lib/types').User|null>}

src/lib/common/task_utilities.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* Sort task-group activities by timestamp_started.
3+
* @param {import('$lib/types-v2').TaskGroupActivityV2} a1
4+
* @param {import('$lib/types-v2').TaskGroupActivityV2} a2
5+
*/
6+
export const sortActivitiesByTimestampStarted = function (a1, a2) {
7+
return a1.timestamp_started < a2.timestamp_started ? 1 : -1;
8+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<script>
2+
import { onMount } from 'svelte';
3+
4+
/** @type {string | null} */
5+
export let value;
6+
7+
let ColorHash;
8+
9+
/**
10+
* @param {string} stringInput
11+
*/
12+
function getBackgroundColor(stringInput) {
13+
const colorHash = new ColorHash({ lightness: 0.8, saturation: 0.95 });
14+
return colorHash.hex(stringInput);
15+
}
16+
17+
let mounted = false;
18+
19+
onMount(async () => {
20+
// Force rendering of coloured badge after SSR, to avoid issue with
21+
// color-hash dependency, that is available only client side.
22+
ColorHash = (await import('color-hash')).default;
23+
mounted = true;
24+
});
25+
</script>
26+
27+
{#if value && mounted}
28+
<span
29+
style="background-color: {getBackgroundColor(value)}"
30+
class="badge rounded-pill coloured-badge text-dark"
31+
>
32+
{value}
33+
</span>
34+
{/if}

src/lib/components/v2/admin/UserSettingsImportModal.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
},
7474
events: {
7575
afterChange: (selection) => {
76-
if (selection[0].value === 'Select...') {
76+
if (selection.length === 0 || selection[0].value === 'Select...') {
7777
selectedUserId = null;
7878
} else {
7979
selectedUserId = Number(selection[0].value);

0 commit comments

Comments
 (0)