style(widgets): apply formatter to dashboard and addon files
This commit is contained in:
@@ -16,8 +16,8 @@ export function GrafanaAddonPage() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-col gap-3">
|
<CardContent className="flex flex-col gap-3">
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Open the full Grafana instance for dashboards, metrics, and
|
Open the full Grafana instance for dashboards, metrics, and log
|
||||||
log exploration.
|
exploration.
|
||||||
</p>
|
</p>
|
||||||
<Button asChild>
|
<Button asChild>
|
||||||
<a
|
<a
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ export function SshTasksAddonPage() {
|
|||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent className="flex flex-col gap-3">
|
<CardContent className="flex flex-col gap-3">
|
||||||
<p className="text-sm text-muted-foreground">
|
<p className="text-sm text-muted-foreground">
|
||||||
Create, edit, and run saved shell or Python tasks against local
|
Create, edit, and run saved shell or Python tasks against local or
|
||||||
or remote machines.
|
remote machines.
|
||||||
</p>
|
</p>
|
||||||
<Button onClick={() => navigate("/actions")}>
|
<Button onClick={() => navigate("/actions")}>
|
||||||
<Terminal className="mr-2 h-4 w-4" />
|
<Terminal className="mr-2 h-4 w-4" />
|
||||||
|
|||||||
@@ -18,13 +18,7 @@ import {
|
|||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Badge } from "@/components/ui/badge";
|
import { Badge } from "@/components/ui/badge";
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert";
|
import { Alert, AlertDescription } from "@/components/ui/alert";
|
||||||
import {
|
import { ChevronDown, ChevronUp, Pencil, Plus, Trash2 } from "lucide-react";
|
||||||
ChevronDown,
|
|
||||||
ChevronUp,
|
|
||||||
Pencil,
|
|
||||||
Plus,
|
|
||||||
Trash2,
|
|
||||||
} from "lucide-react";
|
|
||||||
import {
|
import {
|
||||||
useDeleteWidgetInstance,
|
useDeleteWidgetInstance,
|
||||||
useSaveWidgetInstance,
|
useSaveWidgetInstance,
|
||||||
@@ -114,9 +108,7 @@ function WidgetConfigFields({
|
|||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
value={String(value)}
|
value={String(value)}
|
||||||
onValueChange={(v) =>
|
onValueChange={(v) => onChange({ ...config, [field.key]: v })}
|
||||||
onChange({ ...config, [field.key]: v })
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<SelectTrigger id={field.key}>
|
<SelectTrigger id={field.key}>
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
@@ -124,11 +116,7 @@ function WidgetConfigFields({
|
|||||||
<SelectContent>
|
<SelectContent>
|
||||||
<SelectItem value="">Default</SelectItem>
|
<SelectItem value="">Default</SelectItem>
|
||||||
{machines
|
{machines
|
||||||
.filter(
|
.filter((m) => m.enabled && m.services.includes("jellyfin"))
|
||||||
(m) =>
|
|
||||||
m.enabled &&
|
|
||||||
m.services.includes("jellyfin"),
|
|
||||||
)
|
|
||||||
.map((m) => (
|
.map((m) => (
|
||||||
<SelectItem key={m.id} value={m.id}>
|
<SelectItem key={m.id} value={m.id}>
|
||||||
{m.name}
|
{m.name}
|
||||||
@@ -140,10 +128,7 @@ function WidgetConfigFields({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (definition.widgetType === "ssh-task" && field.key === "task_id") {
|
||||||
definition.widgetType === "ssh-task" &&
|
|
||||||
field.key === "task_id"
|
|
||||||
) {
|
|
||||||
return (
|
return (
|
||||||
<Field
|
<Field
|
||||||
key={field.key}
|
key={field.key}
|
||||||
@@ -153,9 +138,7 @@ function WidgetConfigFields({
|
|||||||
>
|
>
|
||||||
<Select
|
<Select
|
||||||
value={String(value)}
|
value={String(value)}
|
||||||
onValueChange={(v) =>
|
onValueChange={(v) => onChange({ ...config, [field.key]: v })}
|
||||||
onChange({ ...config, [field.key]: v })
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<SelectTrigger id={field.key}>
|
<SelectTrigger id={field.key}>
|
||||||
<SelectValue />
|
<SelectValue />
|
||||||
@@ -342,9 +325,7 @@ export function WidgetConfigDialog({ open, onClose }: Props) {
|
|||||||
setDraft({
|
setDraft({
|
||||||
...draft,
|
...draft,
|
||||||
sort_order:
|
sort_order:
|
||||||
e.target.value === ""
|
e.target.value === "" ? 0 : Number(e.target.value),
|
||||||
? 0
|
|
||||||
: Number(e.target.value),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
@@ -387,9 +368,7 @@ export function WidgetConfigDialog({ open, onClose }: Props) {
|
|||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
{sortedInstances.map((instance, index) => {
|
{sortedInstances.map((instance, index) => {
|
||||||
const typeDef = getWidgetDefinition(
|
const typeDef = getWidgetDefinition(instance.widget_type);
|
||||||
instance.widget_type,
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={instance.id}
|
key={instance.id}
|
||||||
@@ -397,16 +376,12 @@ export function WidgetConfigDialog({ open, onClose }: Props) {
|
|||||||
>
|
>
|
||||||
<div className="flex flex-1 flex-col gap-1">
|
<div className="flex flex-1 flex-col gap-1">
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<span className="font-medium">
|
<span className="font-medium">{instance.title}</span>
|
||||||
{instance.title}
|
|
||||||
</span>
|
|
||||||
<Badge variant="outline">
|
<Badge variant="outline">
|
||||||
{typeDef?.name ?? instance.widget_type}
|
{typeDef?.name ?? instance.widget_type}
|
||||||
</Badge>
|
</Badge>
|
||||||
{!instance.enabled ? (
|
{!instance.enabled ? (
|
||||||
<Badge variant="secondary">
|
<Badge variant="secondary">disabled</Badge>
|
||||||
disabled
|
|
||||||
</Badge>
|
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -416,9 +391,7 @@ export function WidgetConfigDialog({ open, onClose }: Props) {
|
|||||||
size="icon"
|
size="icon"
|
||||||
className="h-8 w-8"
|
className="h-8 w-8"
|
||||||
disabled={index === 0}
|
disabled={index === 0}
|
||||||
onClick={() =>
|
onClick={() => moveInstance(index, -1)}
|
||||||
moveInstance(index, -1)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<ChevronUp className="h-4 w-4" />
|
<ChevronUp className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -426,30 +399,21 @@ export function WidgetConfigDialog({ open, onClose }: Props) {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="h-8 w-8"
|
className="h-8 w-8"
|
||||||
disabled={
|
disabled={index === sortedInstances.length - 1}
|
||||||
index ===
|
onClick={() => moveInstance(index, 1)}
|
||||||
sortedInstances.length - 1
|
|
||||||
}
|
|
||||||
onClick={() =>
|
|
||||||
moveInstance(index, 1)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<ChevronDown className="h-4 w-4" />
|
<ChevronDown className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
<Switch
|
<Switch
|
||||||
checked={instance.enabled}
|
checked={instance.enabled}
|
||||||
onCheckedChange={() =>
|
onCheckedChange={() => toggleEnabled(instance)}
|
||||||
toggleEnabled(instance)
|
|
||||||
}
|
|
||||||
aria-label={`Toggle ${instance.title}`}
|
aria-label={`Toggle ${instance.title}`}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="h-8 w-8"
|
className="h-8 w-8"
|
||||||
onClick={() =>
|
onClick={() => startEdit(instance)}
|
||||||
startEdit(instance)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Pencil className="h-4 w-4" />
|
<Pencil className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -457,9 +421,7 @@ export function WidgetConfigDialog({ open, onClose }: Props) {
|
|||||||
variant="ghost"
|
variant="ghost"
|
||||||
size="icon"
|
size="icon"
|
||||||
className="h-8 w-8 text-destructive"
|
className="h-8 w-8 text-destructive"
|
||||||
onClick={() =>
|
onClick={() => removeInstance(instance)}
|
||||||
removeInstance(instance)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
<Trash2 className="h-4 w-4" />
|
<Trash2 className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -19,9 +19,7 @@ export function AddonPage() {
|
|||||||
if (!Page) {
|
if (!Page) {
|
||||||
return (
|
return (
|
||||||
<Alert>
|
<Alert>
|
||||||
<AlertDescription>
|
<AlertDescription>Addon "{addonId}" is not installed.</AlertDescription>
|
||||||
Addon "{addonId}" is not installed.
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
</Alert>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -139,9 +139,7 @@ function ShortcutDialog({
|
|||||||
<Input
|
<Input
|
||||||
id="shortcut-icon"
|
id="shortcut-icon"
|
||||||
value={draft.icon}
|
value={draft.icon}
|
||||||
onChange={(e) =>
|
onChange={(e) => onChange({ ...draft, icon: e.target.value })}
|
||||||
onChange({ ...draft, icon: e.target.value })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
</div>
|
</div>
|
||||||
@@ -183,9 +181,7 @@ function ShortcutDialog({
|
|||||||
<Input
|
<Input
|
||||||
id="shortcut-url"
|
id="shortcut-url"
|
||||||
value={draft.url}
|
value={draft.url}
|
||||||
onChange={(e) =>
|
onChange={(e) => onChange({ ...draft, url: e.target.value })}
|
||||||
onChange({ ...draft, url: e.target.value })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
) : draft.shortcut_type === "action" ? (
|
) : draft.shortcut_type === "action" ? (
|
||||||
@@ -237,9 +233,7 @@ function ShortcutDialog({
|
|||||||
<Input
|
<Input
|
||||||
id="shortcut-notes"
|
id="shortcut-notes"
|
||||||
value={draft.notes}
|
value={draft.notes}
|
||||||
onChange={(e) =>
|
onChange={(e) => onChange({ ...draft, notes: e.target.value })}
|
||||||
onChange({ ...draft, notes: e.target.value })
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
</Field>
|
</Field>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -385,10 +379,7 @@ export function Dashboard() {
|
|||||||
description="Quick links to websites today, with room for action and user shortcuts later."
|
description="Quick links to websites today, with room for action and user shortcuts later."
|
||||||
action={
|
action={
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
<Button
|
<Button variant="outline" onClick={() => setWidgetDialogOpen(true)}>
|
||||||
variant="outline"
|
|
||||||
onClick={() => setWidgetDialogOpen(true)}
|
|
||||||
>
|
|
||||||
Edit dashboard
|
Edit dashboard
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="outline" onClick={openCreateShortcut}>
|
<Button variant="outline" onClick={openCreateShortcut}>
|
||||||
|
|||||||
Reference in New Issue
Block a user