mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 17:59:28 +08:00
updates to user roles
This commit is contained in:
@@ -53,6 +53,7 @@ export function AddServerButton() {
|
||||
const formData = new FormData(e.target as HTMLFormElement)
|
||||
const data = Object.fromEntries(formData) as Record<string, any>
|
||||
data.status = 'pending'
|
||||
data.users = pb.authStore.model!.id
|
||||
data.info = {
|
||||
cpu: 0,
|
||||
m: 0,
|
||||
|
@@ -55,6 +55,7 @@ export default function DiskChart({
|
||||
>
|
||||
<CartesianGrid vertical={false} />
|
||||
<YAxis
|
||||
className="tracking-tighter"
|
||||
width={75}
|
||||
domain={[0, diskSize]}
|
||||
// ticks={ticks}
|
||||
|
@@ -45,7 +45,8 @@ export default function DiskIoChart({
|
||||
>
|
||||
<CartesianGrid vertical={false} />
|
||||
<YAxis
|
||||
width={75}
|
||||
className="tracking-tighter"
|
||||
width={80}
|
||||
domain={[0, 'auto']}
|
||||
// ticks={ticks}
|
||||
tickCount={9}
|
||||
|
@@ -60,7 +60,7 @@ import { useMemo, useState } from 'react'
|
||||
import { $systems, pb, navigate } from '@/lib/stores'
|
||||
import { useStore } from '@nanostores/react'
|
||||
import { AddServerButton } from '../add-server'
|
||||
import { cn, copyToClipboard, isAdmin } from '@/lib/utils'
|
||||
import { cn, copyToClipboard, isReadOnlyUser } from '@/lib/utils'
|
||||
import AlertsButton from '../table-alerts'
|
||||
|
||||
function CellFormatter(info: CellContext<SystemRecord, unknown>) {
|
||||
@@ -167,15 +167,8 @@ export default function SystemsTable() {
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
{/* <DropdownMenuLabel>Actions</DropdownMenuLabel> */}
|
||||
{/* <DropdownMenuItem
|
||||
onSelect={() => {
|
||||
navigate(`/server/${name}`)
|
||||
}}
|
||||
>
|
||||
View details
|
||||
</DropdownMenuItem> */}
|
||||
<DropdownMenuItem
|
||||
className={cn(isReadOnlyUser() && 'hidden')}
|
||||
onClick={() => {
|
||||
pb.collection('systems').update(id, {
|
||||
status: status === 'paused' ? 'pending' : 'paused',
|
||||
@@ -198,9 +191,9 @@ export default function SystemsTable() {
|
||||
<CopyIcon className="mr-2.5 h-4 w-4" />
|
||||
Copy host
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuSeparator className={cn(isReadOnlyUser() && 'hidden')} />
|
||||
<AlertDialogTrigger asChild>
|
||||
<DropdownMenuItem>
|
||||
<DropdownMenuItem className={cn(isReadOnlyUser() && 'hidden')}>
|
||||
<Trash2Icon className="mr-2.5 h-4 w-4" />
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
@@ -264,11 +257,9 @@ export default function SystemsTable() {
|
||||
onChange={(event) => table.getColumn('name')?.setFilterValue(event.target.value)}
|
||||
className="max-w-sm"
|
||||
/>
|
||||
{isAdmin() && (
|
||||
<div className="ml-auto flex gap-2">
|
||||
<AddServerButton />
|
||||
</div>
|
||||
)}
|
||||
<div className={cn('ml-auto flex gap-2', isReadOnlyUser() && 'hidden')}>
|
||||
<AddServerButton />
|
||||
</div>
|
||||
</div>
|
||||
<div className="rounded-md border overflow-hidden">
|
||||
<Table>
|
||||
|
@@ -95,7 +95,7 @@ export function UserAuthForm({
|
||||
email,
|
||||
password,
|
||||
passwordConfirm: password,
|
||||
admin: true,
|
||||
role: 'admin',
|
||||
verified: true,
|
||||
})
|
||||
await pb.collection('users').authWithPassword(email, password)
|
||||
|
@@ -75,7 +75,9 @@ export const formatDay = (timestamp: string) => {
|
||||
export const updateFavicon = (newIconUrl: string) =>
|
||||
((document.querySelector("link[rel='icon']") as HTMLLinkElement).href = newIconUrl)
|
||||
|
||||
export const isAdmin = () => pb.authStore.model?.admin
|
||||
export const isAdmin = () => pb.authStore.model?.role === 'admin'
|
||||
export const isReadOnlyUser = () => pb.authStore.model?.role === 'readonly'
|
||||
// export const isDefaultUser = () => pb.authStore.model?.role === 'user'
|
||||
|
||||
/** Update systems / alerts list when records change */
|
||||
export function updateRecordList<T extends RecordModel>(
|
||||
|
Reference in New Issue
Block a user