2022-06-22 11:20:57 +02:00
|
|
|
<script>
|
|
|
|
import { Icon, Button, InputGroup, Input, Collapse,
|
|
|
|
Navbar, NavbarBrand, Nav, NavItem, NavLink, NavbarToggler,
|
2023-01-12 11:26:01 +01:00
|
|
|
Dropdown, DropdownToggle, DropdownMenu, DropdownItem, InputGroupText } from 'sveltestrap'
|
2022-06-22 11:20:57 +02:00
|
|
|
|
|
|
|
export let username // empty string if auth. is disabled, otherwise the username as string
|
2023-03-06 11:44:38 +01:00
|
|
|
export let authlevel // Integer
|
2022-06-22 11:20:57 +02:00
|
|
|
export let clusters // array of names
|
2023-03-06 11:44:38 +01:00
|
|
|
export let roles // Role Enum-Like
|
2022-06-22 11:20:57 +02:00
|
|
|
|
|
|
|
let isOpen = false
|
|
|
|
|
2023-01-27 18:36:58 +01:00
|
|
|
const userviews = [
|
2023-02-22 16:30:01 +01:00
|
|
|
{ title: 'My Jobs', href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
|
|
|
{ title: `Job Search`, href: '/monitoring/jobs/', icon: 'card-list' },
|
|
|
|
{ title: 'Tags', href: '/monitoring/tags/', icon: 'tags' }
|
2022-06-22 11:20:57 +02:00
|
|
|
]
|
2023-01-27 18:36:58 +01:00
|
|
|
|
|
|
|
const managerviews = [
|
|
|
|
{ title: 'My Jobs', href: `/monitoring/user/${username}`, icon: 'bar-chart-line-fill' },
|
2023-02-17 15:45:31 +01:00
|
|
|
{ title: `Managed Jobs`, href: '/monitoring/jobs/', icon: 'card-list' },
|
|
|
|
{ title: `Managed Users`, href: '/monitoring/users/', icon: 'people-fill' },
|
2023-01-27 18:36:58 +01:00
|
|
|
{ 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' }
|
|
|
|
]
|
|
|
|
|
2022-06-22 11:20:57 +02:00
|
|
|
const viewsPerCluster = [
|
2023-03-06 11:44:38 +01:00
|
|
|
{ title: 'Analysis', requiredRole: roles.support, href: '/monitoring/analysis/', icon: 'graph-up' },
|
|
|
|
{ title: 'Systems', requiredRole: roles.admin, href: '/monitoring/systems/', icon: 'cpu' },
|
|
|
|
{ title: 'Status', requiredRole: roles.admin, href: '/monitoring/status/', icon: 'cpu' },
|
2022-06-22 11:20:57 +02:00
|
|
|
]
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<Navbar color="light" light expand="lg" fixed="top">
|
|
|
|
<NavbarBrand href="/">
|
|
|
|
<img alt="ClusterCockpit Logo" src="/img/logo.png" height="25rem">
|
|
|
|
</NavbarBrand>
|
|
|
|
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
|
|
|
<Collapse {isOpen} navbar expand="lg" on:update={({ detail }) => (isOpen = detail.isOpen)}>
|
|
|
|
<Nav pills>
|
2023-03-06 11:44:38 +01:00
|
|
|
{#if authlevel == roles.admin}
|
2023-01-27 18:36:58 +01:00
|
|
|
{#each adminviews as item}
|
|
|
|
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
|
|
|
{/each}
|
2023-03-06 11:44:38 +01:00
|
|
|
{:else if authlevel == roles.support}
|
2023-01-27 18:36:58 +01:00
|
|
|
{#each supportviews as item}
|
|
|
|
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
|
|
|
{/each}
|
2023-03-06 11:44:38 +01:00
|
|
|
{:else if authlevel == roles.manager}
|
2023-01-27 18:36:58 +01:00
|
|
|
{#each managerviews as item}
|
|
|
|
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
|
|
|
{/each}
|
2023-06-12 11:35:16 +02:00
|
|
|
{:else} <!-- Compatibility: Handle "user role" or "no role" as identical-->
|
2023-01-27 18:36:58 +01:00
|
|
|
{#each userviews as item}
|
|
|
|
<NavLink href={item.href} active={window.location.pathname == item.href}><Icon name={item.icon}/> {item.title}</NavLink>
|
|
|
|
{/each}
|
|
|
|
{/if}
|
2023-03-06 11:44:38 +01:00
|
|
|
{#each viewsPerCluster.filter(item => item.requiredRole <= authlevel) as item}
|
2022-06-22 11:20:57 +02:00
|
|
|
<NavItem>
|
|
|
|
<Dropdown nav inNavbar>
|
|
|
|
<DropdownToggle nav caret>
|
|
|
|
<Icon name={item.icon}/> {item.title}
|
|
|
|
</DropdownToggle>
|
|
|
|
<DropdownMenu>
|
|
|
|
{#each clusters as cluster}
|
2022-09-12 13:35:42 +02:00
|
|
|
<DropdownItem href={item.href + cluster.name} active={window.location.pathname == item.href + cluster.name}>
|
|
|
|
{cluster.name}
|
2022-06-22 11:20:57 +02:00
|
|
|
</DropdownItem>
|
|
|
|
{/each}
|
|
|
|
</DropdownMenu>
|
|
|
|
</Dropdown>
|
|
|
|
</NavItem>
|
|
|
|
{/each}
|
|
|
|
</Nav>
|
|
|
|
</Collapse>
|
|
|
|
<div class="d-flex">
|
|
|
|
<form method="GET" action="/search">
|
|
|
|
<InputGroup>
|
2023-02-23 12:33:14 +01:00
|
|
|
<Input type="text" placeholder="Search 'type:<query>' ..." name="searchId"/>
|
2022-06-22 11:20:57 +02:00
|
|
|
<Button outline type="submit"><Icon name="search"/></Button>
|
2023-07-14 16:42:49 +02:00
|
|
|
<InputGroupText style="cursor:help;" title={(authlevel >= roles.support) ? "Example: 'projectId:a100cd', Types are: jobId | jobName | projectId | arrayJobId | username | name" : "Example: 'jobName:myjob', Types are jobId | jobName | projectId | arrayJobId "}><Icon name="info-circle"/></InputGroupText>
|
2022-06-22 11:20:57 +02:00
|
|
|
</InputGroup>
|
|
|
|
</form>
|
|
|
|
{#if username}
|
|
|
|
<form method="POST" action="/logout">
|
|
|
|
<Button outline color="success" type="submit" style="margin-left: 10px;">
|
|
|
|
<Icon name="box-arrow-right"/> Logout {username}
|
|
|
|
</Button>
|
|
|
|
</form>
|
|
|
|
{/if}
|
|
|
|
<Button outline on:click={() => window.location.href = '/config'} style="margin-left: 10px;">
|
|
|
|
<Icon name="gear"/>
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Navbar>
|