Compare commits
1 Commits
76d08df3da
...
v0.20.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb0a5ab66d |
@@ -1,24 +1,16 @@
|
||||
import Link from 'next/link';
|
||||
import { Server, ServiceStatus, getStatusColor, serviceStatusToString } from '@/lib/types';
|
||||
import { startServerAction, stopServerAction, restartServerAction } from '@/lib/actions/servers';
|
||||
import {
|
||||
startServerEventAction,
|
||||
restartServerEventAction,
|
||||
stopServerEventAction
|
||||
} from '@/lib/actions/servers';
|
||||
|
||||
interface ServerCardProps {
|
||||
server: Server;
|
||||
}
|
||||
|
||||
export function ServerCard({ server }: ServerCardProps) {
|
||||
const handleStartServer = () => {
|
||||
startServerAction(server.id);
|
||||
};
|
||||
|
||||
const handleStopServer = () => {
|
||||
stopServerAction(server.id);
|
||||
};
|
||||
|
||||
const handleRestartServer = () => {
|
||||
restartServerAction(server.id);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden rounded-lg border border-gray-700 bg-gray-800 shadow-lg">
|
||||
<Link href={`/dashboard/server/${server.id}`} className="block">
|
||||
@@ -61,7 +53,7 @@ export function ServerCard({ server }: ServerCardProps) {
|
||||
</Link>
|
||||
|
||||
<div className="flex justify-between gap-2 bg-gray-900 px-4 py-3">
|
||||
<form action={handleStartServer}>
|
||||
<form action={startServerEventAction.bind(null, server.id)}>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={server.status === ServiceStatus.Running}
|
||||
@@ -71,7 +63,7 @@ export function ServerCard({ server }: ServerCardProps) {
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action={handleRestartServer}>
|
||||
<form action={restartServerEventAction.bind(null, server.id)}>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={server.status === ServiceStatus.Stopped}
|
||||
@@ -81,7 +73,7 @@ export function ServerCard({ server }: ServerCardProps) {
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action={handleStopServer}>
|
||||
<form action={stopServerEventAction.bind(null, server.id)}>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={server.status === ServiceStatus.Stopped}
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
import Link from 'next/link';
|
||||
import { Server, getStatusColor, serviceStatusToString, ServiceStatus } from '@/lib/types/server';
|
||||
import { startServerAction, stopServerAction, restartServerAction } from '@/lib/actions/servers';
|
||||
import {
|
||||
startServerEventAction,
|
||||
restartServerEventAction,
|
||||
stopServerEventAction
|
||||
} from '@/lib/actions/servers';
|
||||
|
||||
interface ServerHeaderProps {
|
||||
server: Server;
|
||||
}
|
||||
|
||||
export function ServerHeader({ server }: ServerHeaderProps) {
|
||||
const handleStartServer = () => {
|
||||
startServerAction(server.id);
|
||||
};
|
||||
|
||||
const handleStopServer = () => {
|
||||
stopServerAction(server.id);
|
||||
};
|
||||
|
||||
const handleRestartServer = () => {
|
||||
restartServerAction(server.id);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="rounded-lg bg-gray-800 p-6">
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -61,7 +53,7 @@ export function ServerHeader({ server }: ServerHeaderProps) {
|
||||
</div>
|
||||
|
||||
<div className="flex space-x-3">
|
||||
<form action={handleStartServer}>
|
||||
<form action={startServerEventAction.bind(null, server.id)}>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={server.status === ServiceStatus.Running}
|
||||
@@ -71,7 +63,7 @@ export function ServerHeader({ server }: ServerHeaderProps) {
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action={handleRestartServer}>
|
||||
<form action={restartServerEventAction.bind(null, server.id)}>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={server.status === ServiceStatus.Stopped}
|
||||
@@ -81,7 +73,7 @@ export function ServerHeader({ server }: ServerHeaderProps) {
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action={handleStopServer}>
|
||||
<form action={stopServerEventAction.bind(null, server.id)}>
|
||||
<button
|
||||
type="submit"
|
||||
disabled={server.status === ServiceStatus.Stopped}
|
||||
|
||||
@@ -18,6 +18,10 @@ export async function startServerAction(serverId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function startServerEventAction(serverId: string) {
|
||||
await startServerAction(serverId);
|
||||
}
|
||||
|
||||
export async function stopServerAction(serverId: string) {
|
||||
try {
|
||||
const session = await requireAuth();
|
||||
@@ -32,6 +36,10 @@ export async function stopServerAction(serverId: string) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function stopServerEventAction(serverId: string) {
|
||||
await stopServerAction(serverId);
|
||||
}
|
||||
|
||||
export async function restartServerAction(serverId: string) {
|
||||
try {
|
||||
const session = await requireAuth();
|
||||
@@ -45,3 +53,7 @@ export async function restartServerAction(serverId: string) {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function restartServerEventAction(serverId: string) {
|
||||
await restartServerAction(serverId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user