mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-09-08 17:53:00 +02:00
Add 'project' to user table, add 'manager' role, conditional web render
- Addresses issues #40 #45 #82 - Reworked Navigation Header for all roles - 'Manager' role added, can be assigned a project-id in config by admins - BREAKING! -> Added 'project' column in SQLite3 table 'user' - Manager-Assigned project will be added to all graphql filters: Only show Jobs and Users of given project - 'My Jobs' Tab for all Roles - Switched from Bool "isAdmin" to integer authLevels - Removed critical data frontend logging - Reworked repo.query.SecurityCheck()
This commit is contained in:
@@ -4,23 +4,44 @@
|
||||
Dropdown, DropdownToggle, DropdownMenu, DropdownItem } from 'sveltestrap'
|
||||
|
||||
export let username // empty string if auth. is disabled, otherwise the username as string
|
||||
export let isAdmin // boolean
|
||||
export let project // empty string if user has no project in db (= not manager), otherwise the managed projectid as string
|
||||
export let authlevel // integer
|
||||
export let clusters // array of names
|
||||
|
||||
let isOpen = false
|
||||
|
||||
const views = [
|
||||
isAdmin
|
||||
? { title: 'Jobs', adminOnly: false, href: '/monitoring/jobs/', icon: 'card-list' }
|
||||
: { title: 'My Jobs', adminOnly: false, href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
||||
{ title: 'Users', adminOnly: true, href: '/monitoring/users/', icon: 'people-fill' },
|
||||
{ title: 'Projects', adminOnly: true, href: '/monitoring/projects/', icon: 'folder' },
|
||||
{ title: 'Tags', adminOnly: false, href: '/monitoring/tags/', icon: 'tags' }
|
||||
const userviews = [
|
||||
{ title: 'My Jobs', href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
||||
{ title: 'Tags', href: '/monitoring/tags/', icon: 'tags' }
|
||||
]
|
||||
|
||||
const managerviews = [
|
||||
{ title: 'My Jobs', href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
||||
{ title: `'${project}' Jobs`, href: '/monitoring/jobs/', icon: 'card-list' },
|
||||
{ title: `'${project}' Users`, href: '/monitoring/users/', icon: 'people-fill' },
|
||||
{ title: 'Tags', href: '/monitoring/tags/', icon: 'tags' }
|
||||
]
|
||||
|
||||
const supportviews = [
|
||||
{ title: 'My Jobs', href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
||||
{ title: 'Jobs', href: '/monitoring/jobs/', icon: 'card-list' },
|
||||
{ title: 'Users', href: '/monitoring/users/', icon: 'people-fill' },
|
||||
{ title: 'Projects', href: '/monitoring/projects/', icon: 'folder' },
|
||||
{ title: 'Tags', href: '/monitoring/tags/', icon: 'tags' }
|
||||
]
|
||||
|
||||
const adminviews = [
|
||||
{ title: 'My Jobs', href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
||||
{ title: 'Jobs', href: '/monitoring/jobs/', icon: 'card-list' },
|
||||
{ title: 'Users', href: '/monitoring/users/', icon: 'people-fill' },
|
||||
{ title: 'Projects', href: '/monitoring/projects/', icon: 'folder' },
|
||||
{ title: 'Tags', href: '/monitoring/tags/', icon: 'tags' }
|
||||
]
|
||||
|
||||
const viewsPerCluster = [
|
||||
{ title: 'Analysis', adminOnly: true, href: '/monitoring/analysis/', icon: 'graph-up' },
|
||||
{ title: 'Systems', adminOnly: true, href: '/monitoring/systems/', icon: 'cpu' },
|
||||
{ title: 'Status', adminOnly: true, href: '/monitoring/status/', icon: 'cpu' },
|
||||
{ title: 'Analysis', authLevel: 4, href: '/monitoring/analysis/', icon: 'graph-up' },
|
||||
{ title: 'Systems', authLevel: 5, href: '/monitoring/systems/', icon: 'cpu' },
|
||||
{ title: 'Status', authLevel: 5, href: '/monitoring/status/', icon: 'cpu' },
|
||||
]
|
||||
</script>
|
||||
|
||||
@@ -31,10 +52,26 @@
|
||||
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
||||
<Collapse {isOpen} navbar expand="lg" on:update={({ detail }) => (isOpen = detail.isOpen)}>
|
||||
<Nav pills>
|
||||
{#each views.filter(item => isAdmin || !item.adminOnly) as item}
|
||||
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
||||
{/each}
|
||||
{#each viewsPerCluster.filter(item => !item.adminOnly || isAdmin) as item}
|
||||
{#if authlevel == 5} <!-- admin -->
|
||||
{#each adminviews as item}
|
||||
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
||||
{/each}
|
||||
{:else if authlevel == 4} <!-- support -->
|
||||
{#each supportviews as item}
|
||||
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
||||
{/each}
|
||||
{:else if authlevel == 3} <!-- manager -->
|
||||
{#each managerviews as item}
|
||||
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
||||
{/each}
|
||||
{:else if authlevel == 2} <!-- user -->
|
||||
{#each userviews as item}
|
||||
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
||||
{/each}
|
||||
{:else}
|
||||
<p>API User or Unauthorized!</p>
|
||||
{/if}
|
||||
{#each viewsPerCluster.filter(item => item.authLevel <= authlevel) as item}
|
||||
<NavItem>
|
||||
<Dropdown nav inNavbar>
|
||||
<DropdownToggle nav caret>
|
||||
@@ -55,7 +92,7 @@
|
||||
<div class="d-flex">
|
||||
<form method="GET" action="/search">
|
||||
<InputGroup>
|
||||
<Input type="text" placeholder={isAdmin ? "Search jobId / username" : "Search jobId"} name="searchId"/>
|
||||
<Input type="text" placeholder={(authlevel >= 4) ? "Search jobId / username" : "Search jobId"} name="searchId"/>
|
||||
<Button outline type="submit"><Icon name="search"/></Button>
|
||||
</InputGroup>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user