2022-06-22 11:20:57 +02:00
|
|
|
<script>
|
2023-08-23 21:15:49 +02:00
|
|
|
import {
|
|
|
|
Icon,
|
|
|
|
Button,
|
|
|
|
InputGroup,
|
|
|
|
Input,
|
|
|
|
Collapse,
|
|
|
|
Navbar,
|
|
|
|
NavbarBrand,
|
|
|
|
Nav,
|
|
|
|
NavItem,
|
|
|
|
NavbarToggler,
|
|
|
|
Dropdown,
|
|
|
|
DropdownToggle,
|
|
|
|
DropdownMenu,
|
|
|
|
InputGroupText,
|
|
|
|
} from "sveltestrap";
|
2023-08-24 09:22:12 +02:00
|
|
|
import NavbarLinks from "./NavbarLinks.svelte";
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2023-08-23 21:15:49 +02:00
|
|
|
export let username; // empty string if auth. is disabled, otherwise the username as string
|
|
|
|
export let authlevel; // Integer
|
|
|
|
export let clusters; // array of names
|
|
|
|
export let roles; // Role Enum-Like
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2023-08-23 21:15:49 +02:00
|
|
|
let isOpen = false;
|
|
|
|
let screenSize;
|
2022-06-22 11:20:57 +02:00
|
|
|
|
2023-08-23 21:15:49 +02:00
|
|
|
const jobsTitle = new Map();
|
|
|
|
jobsTitle.set(2, "Job Search");
|
|
|
|
jobsTitle.set(3, "Managed Jobs");
|
|
|
|
jobsTitle.set(4, "Jobs");
|
|
|
|
jobsTitle.set(5, "Jobs");
|
|
|
|
const usersTitle = new Map();
|
|
|
|
usersTitle.set(3, "Managed Users");
|
|
|
|
usersTitle.set(4, "Users");
|
|
|
|
usersTitle.set(5, "Users");
|
2023-01-27 18:36:58 +01:00
|
|
|
|
2023-08-23 21:15:49 +02:00
|
|
|
const views = [
|
|
|
|
{
|
|
|
|
title: "My Jobs",
|
|
|
|
requiredRole: roles.user,
|
|
|
|
href: `/monitoring/user/${username}`,
|
|
|
|
icon: "bar-chart-line-fill",
|
|
|
|
perCluster: false,
|
|
|
|
menu: "none",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: jobsTitle.get(authlevel),
|
|
|
|
requiredRole: roles.user,
|
2023-08-25 09:51:33 +02:00
|
|
|
href: `/monitoring/jobs/`,
|
2023-08-23 21:15:49 +02:00
|
|
|
icon: "card-list",
|
|
|
|
perCluster: false,
|
|
|
|
menu: "none",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: usersTitle.get(authlevel),
|
|
|
|
requiredRole: roles.manager,
|
|
|
|
href: "/monitoring/users/",
|
|
|
|
icon: "people-fill",
|
|
|
|
perCluster: false,
|
|
|
|
menu: "Groups",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Projects",
|
|
|
|
requiredRole: roles.support,
|
|
|
|
href: "/monitoring/projects/",
|
|
|
|
icon: "folder",
|
|
|
|
perCluster: false,
|
|
|
|
menu: "Groups",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Tags",
|
|
|
|
requiredRole: roles.user,
|
|
|
|
href: "/monitoring/tags/",
|
|
|
|
icon: "tags",
|
|
|
|
perCluster: false,
|
|
|
|
menu: "Groups",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Analysis",
|
|
|
|
requiredRole: roles.support,
|
|
|
|
href: "/monitoring/analysis/",
|
|
|
|
icon: "graph-up",
|
|
|
|
perCluster: true,
|
|
|
|
menu: "Stats",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Nodes",
|
|
|
|
requiredRole: roles.admin,
|
|
|
|
href: "/monitoring/systems/",
|
|
|
|
icon: "cpu",
|
|
|
|
perCluster: true,
|
|
|
|
menu: "Groups",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: "Status",
|
|
|
|
requiredRole: roles.admin,
|
|
|
|
href: "/monitoring/status/",
|
|
|
|
icon: "cpu",
|
|
|
|
perCluster: true,
|
|
|
|
menu: "Stats",
|
|
|
|
},
|
|
|
|
];
|
2022-06-22 11:20:57 +02:00
|
|
|
</script>
|
|
|
|
|
2023-08-23 21:15:49 +02:00
|
|
|
<svelte:window bind:innerWidth={screenSize} />
|
|
|
|
<Navbar color="light" light expand="sm" fixed="top">
|
2022-06-22 11:20:57 +02:00
|
|
|
<NavbarBrand href="/">
|
2023-08-23 21:15:49 +02:00
|
|
|
<img alt="ClusterCockpit Logo" src="/img/logo.png" height="25rem" />
|
2022-06-22 11:20:57 +02:00
|
|
|
</NavbarBrand>
|
|
|
|
<NavbarToggler on:click={() => (isOpen = !isOpen)} />
|
2023-08-23 21:15:49 +02:00
|
|
|
<Collapse
|
|
|
|
{isOpen}
|
|
|
|
navbar
|
|
|
|
expand="sm"
|
|
|
|
on:update={({ detail }) => (isOpen = detail.isOpen)}
|
|
|
|
>
|
|
|
|
<Nav navbar>
|
2023-08-24 09:38:12 +02:00
|
|
|
{#if screenSize > 1500 || screenSize < 576}
|
2023-08-24 09:22:12 +02:00
|
|
|
<NavbarLinks
|
|
|
|
{clusters}
|
|
|
|
links={views.filter(
|
|
|
|
(item) => item.requiredRole <= authlevel
|
|
|
|
)}
|
|
|
|
/>
|
2023-08-23 21:15:49 +02:00
|
|
|
{:else if screenSize > 1300}
|
2023-08-24 09:22:12 +02:00
|
|
|
<NavbarLinks
|
|
|
|
{clusters}
|
|
|
|
links={views.filter(
|
|
|
|
(item) =>
|
|
|
|
item.requiredRole <= authlevel &&
|
|
|
|
item.menu != "Stats"
|
|
|
|
)}
|
|
|
|
/>
|
2023-08-23 21:15:49 +02:00
|
|
|
<Dropdown nav>
|
|
|
|
<DropdownToggle nav caret>
|
|
|
|
<Icon name="graph-up" />
|
|
|
|
Stats
|
|
|
|
</DropdownToggle>
|
|
|
|
<DropdownMenu class="dropdown-menu-lg-end">
|
2023-08-24 09:22:12 +02:00
|
|
|
<NavbarLinks
|
|
|
|
{clusters}
|
|
|
|
links={views.filter(
|
|
|
|
(item) =>
|
|
|
|
item.requiredRole <= authlevel &&
|
|
|
|
item.menu == "Stats"
|
|
|
|
)}
|
|
|
|
/>
|
2023-08-23 21:15:49 +02:00
|
|
|
</DropdownMenu>
|
|
|
|
</Dropdown>
|
|
|
|
{:else}
|
2023-08-24 09:22:12 +02:00
|
|
|
<NavbarLinks
|
|
|
|
{clusters}
|
|
|
|
links={views.filter(
|
|
|
|
(item) =>
|
|
|
|
item.requiredRole <= authlevel &&
|
|
|
|
item.menu == "none"
|
|
|
|
)}
|
|
|
|
/>
|
2023-08-23 21:15:49 +02:00
|
|
|
{#each Array("Groups", "Stats") as menu}
|
|
|
|
<Dropdown nav>
|
2022-06-22 11:20:57 +02:00
|
|
|
<DropdownToggle nav caret>
|
2023-08-23 21:15:49 +02:00
|
|
|
{menu}
|
2022-06-22 11:20:57 +02:00
|
|
|
</DropdownToggle>
|
2023-08-23 21:15:49 +02:00
|
|
|
<DropdownMenu class="dropdown-menu-lg-end">
|
2023-08-24 09:22:12 +02:00
|
|
|
<NavbarLinks
|
|
|
|
{clusters}
|
|
|
|
links={views.filter(
|
|
|
|
(item) =>
|
|
|
|
item.requiredRole <= authlevel &&
|
|
|
|
item.menu == menu
|
|
|
|
)}
|
|
|
|
/>
|
2022-06-22 11:20:57 +02:00
|
|
|
</DropdownMenu>
|
|
|
|
</Dropdown>
|
2023-08-23 21:15:49 +02:00
|
|
|
{/each}
|
|
|
|
{/if}
|
2022-06-22 11:20:57 +02:00
|
|
|
</Nav>
|
|
|
|
</Collapse>
|
2023-08-23 21:15:49 +02:00
|
|
|
<Nav>
|
|
|
|
<NavItem>
|
|
|
|
<form method="GET" action="/search">
|
|
|
|
<InputGroup>
|
|
|
|
<Input
|
|
|
|
type="text"
|
|
|
|
placeholder="Search 'type:<query>' ..."
|
|
|
|
name="searchId"
|
|
|
|
/>
|
|
|
|
<Button outline type="submit"><Icon name="search" /></Button
|
|
|
|
>
|
|
|
|
<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
|
|
|
|
>
|
|
|
|
</InputGroup>
|
2022-06-22 11:20:57 +02:00
|
|
|
</form>
|
2023-08-23 21:15:49 +02:00
|
|
|
</NavItem>
|
|
|
|
{#if username}
|
|
|
|
<NavItem>
|
|
|
|
<form method="POST" action="/logout">
|
|
|
|
<Button
|
|
|
|
outline
|
|
|
|
color="success"
|
|
|
|
type="submit"
|
|
|
|
style="margin-left: 10px;"
|
|
|
|
>
|
|
|
|
{#if screenSize > 1630}
|
|
|
|
<Icon name="box-arrow-right" /> Logout {username}
|
|
|
|
{:else}
|
|
|
|
<Icon name="box-arrow-right" />
|
|
|
|
{/if}
|
|
|
|
</Button>
|
|
|
|
</form>
|
|
|
|
</NavItem>
|
2022-06-22 11:20:57 +02:00
|
|
|
{/if}
|
2023-08-23 21:15:49 +02:00
|
|
|
<NavItem>
|
|
|
|
<Button
|
|
|
|
outline
|
|
|
|
on:click={() => (window.location.href = "/config")}
|
|
|
|
style="margin-left: 10px;"
|
|
|
|
>
|
|
|
|
<Icon name="gear" />
|
|
|
|
</Button>
|
|
|
|
</NavItem>
|
|
|
|
</Nav>
|
2022-06-22 11:20:57 +02:00
|
|
|
</Navbar>
|