File tree Expand file tree Collapse file tree 6 files changed +104
-2
lines changed Expand file tree Collapse file tree 6 files changed +104
-2
lines changed Original file line number Diff line number Diff line change 11* Note: Numbers like (\# 123) point to closed Pull Requests on the fractal-web repository.*
22
3+ # Unreleased
4+
5+ * Added settings page to admin area (\# 544);
6+
37# 1.4.2
48
59* Added admin page for job submission healthcheck (\# 543);
Original file line number Diff line number Diff line change 1+ import { env } from '$env/dynamic/private' ;
2+ import { responseError } from '$lib/common/errors' ;
3+ import { getLogger } from '$lib/server/logger.js' ;
4+
5+ const logger = getLogger ( 'settings API' ) ;
6+
7+ /**
8+ * Fetches the settings from the server
9+ * @param {typeof fetch } fetch
10+ * @returns {Promise<any> }
11+ */
12+ export async function listSettings ( fetch ) {
13+ logger . debug ( 'Fetching the settings' ) ;
14+ const response = await fetch ( env . FRACTAL_SERVER_HOST + '/api/settings/' , {
15+ method : 'GET' ,
16+ credentials : 'include'
17+ } ) ;
18+
19+ if ( ! response . ok ) {
20+ logger . error ( 'Unable to fetch the settings' ) ;
21+ await responseError ( response ) ;
22+ }
23+
24+ return await response . json ( ) ;
25+ }
Original file line number Diff line number Diff line change 11<div class =" row" >
22 <div class =" col" >
3+ <h2 class =" fw-light" >Settings</h2 >
34
4- <h2 class =" fw-light" >Users</h2 >
5+ <a href =" /v2/admin/settings" class =" btn btn-primary me-2" >
6+ <i class =" bi bi-gear-fill" />
7+ Settings
8+ </a >
9+
10+ <h2 class =" fw-light mt-3" >Users</h2 >
511
612 <a href =" /v2/admin/users" class =" btn btn-primary" >
713 <i class =" bi bi-people-fill" />
1622 </a >
1723
1824 <a href =" /v2/admin/jobs/healthcheck" class =" btn btn-primary" >
19- <i class =" bi bi-heart-pulse-fill" ></ i >
25+ <i class =" bi bi-heart-pulse-fill" / >
2026 Job submission healthcheck
2127 </a >
2228
Original file line number Diff line number Diff line change 1+ import { listSettings } from '$lib/server/api/v2/settings_api' ;
2+ import { getLogger } from '$lib/server/logger.js' ;
3+
4+ const logger = getLogger ( 'admin settings page' ) ;
5+
6+ export async function load ( { fetch } ) {
7+ logger . trace ( 'Loading settings page' ) ;
8+
9+ const settings = await listSettings ( fetch ) ;
10+
11+ return {
12+ settings
13+ } ;
14+ }
Original file line number Diff line number Diff line change 1+ <script >
2+ import { page } from ' $app/stores' ;
3+
4+ const settings = $page .data .settings ;
5+
6+ let showObfuscated = false ;
7+ </script >
8+
9+ <h1 class =" fw-light mb-2" >Settings</h1 >
10+
11+ <div class =" row mb-3" >
12+ <div class =" col" >
13+ <div class =" form-check form-switch float-end" >
14+ <input
15+ class =" form-check-input"
16+ bind:checked ={showObfuscated }
17+ type =" checkbox"
18+ role =" switch"
19+ id =" showObfuscatedSwitch"
20+ />
21+ <label class =" form-check-label" for =" showObfuscatedSwitch" >Show obfuscated fields</label >
22+ </div >
23+ </div >
24+ </div >
25+
26+ <table class =" table table-striped" >
27+ <tbody >
28+ {#each Object .entries (settings ) as [key, value]}
29+ {#if showObfuscated || value !== ' ***' }
30+ <tr >
31+ <th >{key }</th >
32+ <td >{value }</td >
33+ </tr >
34+ {/if }
35+ {/each }
36+ </tbody >
37+ </table >
Original file line number Diff line number Diff line change 1+ import { expect , test } from '@playwright/test' ;
2+ import { waitPageLoading } from '../utils.js' ;
3+
4+ test ( 'Show the admin settings page' , async ( { page } ) => {
5+ await test . step ( 'Open the admin settings page' , async ( ) => {
6+ await page . goto ( '/v2/admin/settings' ) ;
7+ await waitPageLoading ( page ) ;
8+ await expect ( page . getByText ( 'FRACTAL_TASKS_DIR' ) ) . toBeVisible ( ) ;
9+ await expect ( page . getByText ( '***' ) ) . not . toBeVisible ( ) ;
10+ } ) ;
11+
12+ await test . step ( 'Display obfuscated settings' , async ( ) => {
13+ await page . getByRole ( 'switch' ) . check ( ) ;
14+ await expect ( page . getByText ( '***' ) . first ( ) ) . toBeVisible ( ) ;
15+ } ) ;
16+ } ) ;
You can’t perform that action at this time.
0 commit comments