Skip to content

Commit 13924ff

Browse files
authored
Merge pull request #259 from fractal-analytics-platform/243-revamp-home-page-and-remove-info-page
Revamp home page and remove Info page
2 parents 8b883ef + 470cfa4 commit 13924ff

File tree

11 files changed

+104
-39
lines changed

11 files changed

+104
-39
lines changed

.env.development

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ AUTH_COOKIE_DOMAIN=localhost
77
AUTH_COOKIE_PATH=/
88
AUTH_COOKIE_MAX_AGE=1800
99
AUTH_COOKIE_SAME_SITE=lax
10-
AUTH_COOKIE_HTTP_ONLY=true
10+
AUTH_COOKIE_HTTP_ONLY=true
11+
12+
# PUBLIC VARIABLES (accessible from client side)
13+
PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL=help@localhost

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
# Unreleased
55

6+
* Revamp home page and user-related layout (\#259).
7+
* Review logout action (\#259).
68
* Implemented editing and deletion of tasks (\#207, \#268).
79
* Bump `word-wrap` from 1.2.3 to 1.2.5 (\#251).
810
* Implemented A to B workflow execution (\#254).

docs/contribute.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,26 @@ Environment variables are set either in `.env` or `.env.development` files, see
3232
[vite documentation](https://vitejs.dev/guide/env-and-mode.html#env-files)
3333
(briefly: `.env.development` is the relevant file when using `npm run dev`).
3434

35+
Here is an example of a `.env` file:
36+
```bash
37+
FRACTAL_SERVER_HOST=http://localhost:8000
38+
39+
# AUTH COOKIE
40+
AUTH_COOKIE_NAME=fastapiusersauth
41+
AUTH_COOKIE_SECURE=false
42+
AUTH_COOKIE_DOMAIN=localhost
43+
AUTH_COOKIE_PATH=/
44+
AUTH_COOKIE_MAX_AGE=1800
45+
AUTH_COOKIE_SAME_SITE=lax
46+
AUTH_COOKIE_HTTP_ONLY=true
47+
48+
# PUBLIC VARIABLES (accessible from client side)
49+
PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL=help@localhost
50+
```
51+
52+
Some relevant environment variables are:
53+
*
54+
3555
## Web client startup
3656

3757
The project comes with a default `.env.development` development environment file.

src/lib/server/api/v1/auth_api.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { FRACTAL_SERVER_HOST } from '$env/static/private';
2+
import { responseError } from '$lib/common/errors';
23

34
/**
45
* Request to authenticate user
@@ -52,7 +53,11 @@ export async function logout(fetch) {
5253
mode: 'cors'
5354
});
5455

55-
if (!response.ok) {
56-
throw new Error('Logout failed');
56+
if (response.ok) {
57+
console.log('Logout successful');
58+
return await response.json();
5759
}
60+
61+
console.error('Logout failed');
62+
await responseError(response);
5863
}

src/routes/+layout.svelte

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
<a href="/" class="nav-link">Home</a>
1414
</li>
1515
{#if userLoggedIn}
16-
<li class="nav-item">
17-
<a href="/info" class="nav-link">Info</a>
18-
</li>
1916
<li class="nav-item">
2017
<a href="/projects" class="nav-link">Projects</a>
2118
</li>
@@ -25,6 +22,9 @@
2522
{/if}
2623
</ul>
2724
<ul class="nav">
25+
{#if userLoggedIn}
26+
<span class="navbar-text">{$page.data.userInfo.email}</span>
27+
{/if}
2828
<li class="nav-item">
2929
{#if !userLoggedIn}
3030
<a href="/auth/login" class="nav-link">Login</a>
@@ -42,25 +42,13 @@
4242
<footer
4343
class="d-flex flex-wrap justify-content-between align-items-center py-3 my-4 border-top"
4444
>
45-
<div class="col-md-4 d-flex align-items-center">
46-
<span class="mb-3 mb-md-0 text-muted">
47-
<a href="https://fractal-analytics-platform.github.io">Fractal Analytics Platform</a>
48-
</span>
49-
</div>
50-
<div class="col-md-4 d-flex justify-content-center">
45+
<div class="col d-flex justify-content-center">
5146
<div class="hstack gap-3">
5247
<span class="font-monospace">{server.version}</span>
5348
<div class="vr" />
5449
<span class="font-monospace">{server.deployment_type}</span>
5550
</div>
5651
</div>
57-
<ul class="nav col-md-4 justify-content-end d-flex">
58-
<li class="ms-2">
59-
<a class="text-muted fs-4" href="https://github.com/fractal-analytics-platform">
60-
<i class="bi bi-github" />
61-
</a>
62-
</li>
63-
</ul>
6452
</footer>
6553
</div>
6654
</main>

src/routes/+page.svelte

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,48 @@
11
<script>
2+
import { env } from '$env/dynamic/public';
23
</script>
34

4-
<h1>Welcome to Fractal's web client.</h1>
5+
<h1>Welcome to Fractal web client.</h1>
6+
7+
<div>
8+
<p>
9+
Welcome to the web client of Fractal, a framework to process high-content imaging data at scale and prepare it for interactive visualization.
10+
</p>
11+
<p>
12+
To access Fractal features, you should first log-in as a registered user.
13+
Navigate to the <i>Projects</i> page to create new projects and to create/edit/execute image-analysis workflows.
14+
The <i>Tasks</i> page lets you view/edit the available image-analysis tasks or create new ones.
15+
</p>
16+
17+
<div class="col mb-3">
18+
<a href="/auth/login" class="btn btn-primary">Login</a>
19+
<a href="/projects" class="btn btn-primary">Projects</a>
20+
<a href="/tasks" class="btn btn-primary">Tasks</a>
21+
</div>
22+
23+
{#if env.PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL}
24+
<h3>Where to get support</h3>
25+
<p>
26+
<a href="mailto:{env.PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL}">{env.PUBLIC_FRACTAL_ADMIN_SUPPORT_EMAIL}</a>
27+
</p>
28+
{/if}
29+
30+
<h3>Links</h3>
31+
32+
<ul>
33+
<li>
34+
<a href="https://fractal-analytics-platform.github.io" target="_blank">
35+
Home page of the Fractal project
36+
</a>
37+
</li>
38+
<li>
39+
<a href="https://github.com/fractal-analytics-platform" target="_blank">
40+
Fractal GitHub organization
41+
</a>
42+
(where development takes place)
43+
44+
45+
</li>
46+
</ul>
47+
48+
</div>

src/routes/auth/login/+page.server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ export const actions = {
4242
console.log(cookieOptions);
4343
cookies.set(AUTH_COOKIE_NAME, authData.access_token, cookieOptions);
4444

45-
throw redirect(302, '/');
45+
throw redirect(302, '/projects');
4646
}
4747
};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script>
2+
import { goto, invalidateAll } from '$app/navigation';
3+
import { onMount } from 'svelte';
4+
5+
async function logout() {
6+
await fetch(`/auth/token/logout`, {
7+
method: 'POST',
8+
credentials: 'include'
9+
});
10+
await invalidateAll();
11+
goto('/');
12+
};
13+
14+
onMount(() => logout());
15+
</script>
16+
17+
Logging out...
Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { error } from '@sveltejs/kit';
21
import { logout } from '$lib/server/api/v1/auth_api';
32
import {
43
AUTH_COOKIE_NAME,
@@ -9,13 +8,9 @@ import {
98
AUTH_COOKIE_HTTP_ONLY
109
} from '$env/static/private';
1110

12-
export async function GET({ fetch, cookies }) {
13-
try {
14-
await logout(fetch);
15-
} catch (e) {
16-
console.error(e);
17-
throw error(500, { message: e.message });
18-
}
11+
export async function POST({fetch, cookies}) {
12+
13+
await logout(fetch);
1914

2015
// Set the fastapiusersauth cookie to expire in the past
2116
// This will delete the cookie
@@ -28,9 +23,5 @@ export async function GET({ fetch, cookies }) {
2823
httpOnly: `${AUTH_COOKIE_HTTP_ONLY}` === 'true'
2924
});
3025

31-
const headers = new Headers();
32-
// Set a redirect header to index
33-
headers.set('Location', '/');
34-
35-
return new Response('', { headers, status: 302 });
26+
return new Response(null, { status: 204 });
3627
}

src/routes/info/+page.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)