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-01-27 18:36:58 +01:00
|
|
|
export let authlevel // integer
|
2022-06-22 11:20:57 +02:00
|
|
|
export let clusters // array of names
|
|
|
|
|
|
|
|
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-01-27 18:36:58 +01:00
|
|
|
{ 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' },
|
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-01-27 18:36:58 +01:00
|
|
|
{#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}
|
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-22 16:30:01 +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-02-22 16:30:01 +01:00
|
|
|
<InputGroupText style="cursor:help;" title={(authlevel >= 4) ? "Example: 'projectId:a100cd', Types are: jobId | jobName | projectId | username | name" : "Example: 'jobName:myjob', Types are jobId | jobName | projectId"}><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>
|