-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add users management page with tables per IDP.
- Loading branch information
Showing
17 changed files
with
402 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script lang="ts"> | ||
export let data = { cell: '', row: { status: '' } }; | ||
</script> | ||
|
||
<button | ||
type="button" | ||
title="Information" | ||
class="bg-initial text-secondary-600 hover:text-primary-600" | ||
> | ||
<i class="fa-solid fa-circle-info fa-xl"></i> | ||
<span class="sr-only">View Information</span> | ||
</button> | ||
|
||
{#if data.row.status === 'Active'} | ||
<button type="button" title="Edit" class="bg-initial text-secondary-600 hover:text-primary-600"> | ||
<i class="fa-solid fa-pen-to-square fa-xl"></i> | ||
<span class="sr-only">Edit</span> | ||
</button> | ||
<button | ||
type="button" | ||
title="Deactivate user" | ||
class="bg-initial text-secondary-600 hover:text-primary-600" | ||
> | ||
<i class="fa-solid fa-circle-xmark fa-xl"></i> | ||
<span class="sr-only">Deactivate user</span> | ||
</button> | ||
{:else} | ||
<button | ||
type="button" | ||
title="Reactivate user" | ||
class="bg-initial text-secondary-600 hover:text-primary-600" | ||
> | ||
<i class="fa-solid fa-circle-check fa-xl"></i> | ||
<span class="sr-only">Reactivate user</span> | ||
</button> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script lang="ts"> | ||
export let data = { cell: '', row: {} }; | ||
</script> | ||
|
||
<span class={`p-1 rounded variant-filled-${data.cell === 'Active' ? 'success' : 'error'}`} | ||
>{data.cell}</span | ||
> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface Connection { | ||
uuid: string; | ||
id: string; | ||
label: string; | ||
subPrefix: string; | ||
requiredFields: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface Privilege { | ||
uuid: string; | ||
name: string; | ||
description: string; | ||
queryScope: string; | ||
application?: object; | ||
} | ||
|
||
export interface Role { | ||
uuid: string; | ||
name: string; | ||
description: string; | ||
privileges: Privilege[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import type { Role } from './Role'; | ||
import type { Connection } from './Connection'; | ||
|
||
export interface User { | ||
uuid?: string; | ||
email?: string; | ||
privileges?: string[]; | ||
roles?: string[]; | ||
token?: string; | ||
acceptedTOS?: boolean; | ||
} | ||
|
||
export interface ExtendedUser extends User { | ||
subject?: string; | ||
connection: Connection; | ||
active: boolean; | ||
roles: Role[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { writable, type Writable } from 'svelte/store'; | ||
|
||
import { roles as mockRoles, users as mockUsers, connections as mockConns } from './mock/Users'; | ||
import type { ExtendedUser } from '../models/User'; | ||
import type { Connection } from '../models/Connection'; | ||
import type { Role } from '../models/Role'; | ||
|
||
// TODO: Break connections and roles out into different store files when working on super-admin page. | ||
export const users: Writable<ExtendedUser[]> = writable([]); | ||
export const roles: Writable<Role[]> = writable([]); | ||
export const connections: Writable<Connection[]> = writable([]); | ||
|
||
// TODO: Add api integration | ||
export async function getUsers() { | ||
users.set(mockUsers); | ||
} | ||
|
||
export async function getConnections() { | ||
connections.set(mockConns); | ||
} | ||
|
||
export async function getRoles() { | ||
roles.set(mockRoles); | ||
} | ||
|
||
export default { | ||
users, | ||
roles, | ||
connections, | ||
getUsers, | ||
getRoles, | ||
getConnections, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
// Mock api data to use until login flow is added. Excluded json data we could get but don't need -- excess fields | ||
// recieved when setting response json object to data model will be ignored. | ||
// TODO: Move these to the test mock-data folder when api has been inmplemented. | ||
|
||
const _application = { | ||
picsure: { | ||
uuid: 'a1234', | ||
name: 'PICSURE', | ||
description: 'PIC-SURE multiple data access API', | ||
enable: true, | ||
}, | ||
jupyter: { | ||
uuid: 'a2345', | ||
name: 'JupyterHub', | ||
description: 'JupyterHub authentication via PSAMA', | ||
enable: true, | ||
}, | ||
}; | ||
|
||
const _privileges = { | ||
superAdmin: { | ||
uuid: 'p1234', | ||
name: 'SUPER_ADMIN', | ||
description: 'PIC-SURE Auth super admin for managing roles/privileges/application/connections', | ||
queryScope: '[]', | ||
}, | ||
admin: { | ||
uuid: 'p2345', | ||
name: 'ADMIN', | ||
description: 'PIC-SURE Auth admin for managing users.', | ||
queryScope: '[]', | ||
}, | ||
anyQuery: { | ||
uuid: 'p3456', | ||
name: 'PIC_SURE_ANY_QUERY', | ||
description: 'User who cann run any PIC-SURE Query', | ||
queryScope: '[]', | ||
application: _application.picsure, | ||
}, | ||
jupyter: { | ||
uuid: 'p4567', | ||
name: 'JUPYTER_USER', | ||
description: 'JupyterHub user for accessing notebooks', | ||
queryScope: '[]', | ||
application: _application.jupyter, | ||
}, | ||
}; | ||
|
||
const _roles = { | ||
topAdmin: { | ||
uuid: 'r1234', | ||
name: 'PIC-SURE Top Admin', | ||
description: | ||
'PIC-SURE Auth Micro App Top admin including Admin and super Admin, can manage roles and privileges directly', | ||
privileges: [_privileges.superAdmin, _privileges.admin], | ||
}, | ||
user: { | ||
uuid: 'r2345', | ||
name: 'PIC-SURE User', | ||
description: 'Normal user, can run any query including data export.', | ||
privileges: [_privileges.anyQuery], | ||
}, | ||
jupyterUser: { | ||
uuid: 'r3456', | ||
name: 'JupyterHub User', | ||
description: 'The user is able to access JupyterHub as a normal user', | ||
privileges: [_privileges.jupyter], | ||
}, | ||
admin: { | ||
uuid: 'r4567', | ||
name: 'Admin', | ||
description: | ||
'Normal admin users, can manage other users including assignment of roles and privileges', | ||
privileges: [_privileges.admin], | ||
}, | ||
}; | ||
export const roles = Object.values(_roles); | ||
|
||
const _connections = { | ||
c1234: { | ||
uuid: 'c1234', | ||
label: 'Some IDP', | ||
id: 'some-idp', | ||
subPrefix: 'some-idp|', | ||
requiredFields: '[{"label":"Email", "id":"email"}]', | ||
}, | ||
c2345: { | ||
uuid: 'c1234', | ||
label: 'Another IDP', | ||
id: 'another-idp', | ||
subPrefix: 'another-idp|', | ||
requiredFields: '[{"label":"Email", "id":"email"}]', | ||
}, | ||
}; | ||
export const connections = Object.values(_connections); | ||
|
||
export const users = [ | ||
{ | ||
uuid: 'abcd', | ||
subject: _connections.c1234.subPrefix + 'abcd', | ||
roles: [_roles.topAdmin, _roles.admin, _roles.user], | ||
email: 'abcd@test.com', | ||
connection: _connections.c1234, | ||
active: true, | ||
}, | ||
{ | ||
uuid: 'bcde', | ||
subject: _connections.c1234.subPrefix + 'bcde', | ||
roles: [_roles.topAdmin, _roles.admin, _roles.user], | ||
email: 'bcde@test.com', | ||
connection: _connections.c1234, | ||
active: true, | ||
}, | ||
{ | ||
uuid: 'cdef', | ||
roles: [_roles.admin, _roles.user], | ||
email: 'cdef@test.com', | ||
connection: _connections.c1234, | ||
generalMetadata: '{"email":"cdef@test.com"}', | ||
active: false, | ||
}, | ||
{ | ||
uuid: 'defg', | ||
roles: [_roles.user], | ||
email: 'defg@test.com', | ||
connection: _connections.c2345, | ||
generalMetadata: '{"email":"defg@test.com"}', | ||
active: true, | ||
}, | ||
{ | ||
uuid: 'efgh', | ||
roles: [_roles.user], | ||
email: 'efgh@test.com', | ||
connection: _connections.c1234, | ||
generalMetadata: '{"email":"efgh@test.com"}', | ||
active: false, | ||
}, | ||
{ | ||
uuid: 'fghi', | ||
subject: 'google-oauth2|fghi', | ||
roles: [_roles.user], | ||
email: 'fghi@test.com', | ||
connection: _connections.c1234, | ||
active: true, | ||
}, | ||
]; |
Oops, something went wrong.