3 Commits

Author SHA1 Message Date
Fran Jurmanović
bb0a5ab66d fix form actions 2025-08-27 21:52:35 +02:00
Fran Jurmanović
76d08df3da update version 2025-08-27 21:43:29 +02:00
Fran Jurmanović
fac61ef678 resolve server actions 2025-08-27 21:43:03 +02:00
5 changed files with 31 additions and 11 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "acc-server-manager-web", "name": "acc-server-manager-web",
"version": "0.20.0", "version": "0.20.1",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "acc-server-manager-web", "name": "acc-server-manager-web",
"version": "0.20.0", "version": "0.20.1",
"dependencies": { "dependencies": {
"@date-fns/utc": "^2.1.1", "@date-fns/utc": "^2.1.1",
"@hookform/resolvers": "^5.2.1", "@hookform/resolvers": "^5.2.1",

View File

@@ -1,6 +1,6 @@
{ {
"name": "acc-server-manager-web", "name": "acc-server-manager-web",
"version": "0.20.0", "version": "0.20.1",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev --turbopack", "dev": "next dev --turbopack",

View File

@@ -1,6 +1,10 @@
import Link from 'next/link'; import Link from 'next/link';
import { Server, ServiceStatus, getStatusColor, serviceStatusToString } from '@/lib/types'; 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 { interface ServerCardProps {
server: Server; server: Server;
@@ -49,7 +53,7 @@ export function ServerCard({ server }: ServerCardProps) {
</Link> </Link>
<div className="flex justify-between gap-2 bg-gray-900 px-4 py-3"> <div className="flex justify-between gap-2 bg-gray-900 px-4 py-3">
<form action={startServerAction.bind(null, server.id)}> <form action={startServerEventAction.bind(null, server.id)}>
<button <button
type="submit" type="submit"
disabled={server.status === ServiceStatus.Running} disabled={server.status === ServiceStatus.Running}
@@ -59,7 +63,7 @@ export function ServerCard({ server }: ServerCardProps) {
</button> </button>
</form> </form>
<form action={restartServerAction.bind(null, server.id)}> <form action={restartServerEventAction.bind(null, server.id)}>
<button <button
type="submit" type="submit"
disabled={server.status === ServiceStatus.Stopped} disabled={server.status === ServiceStatus.Stopped}
@@ -69,7 +73,7 @@ export function ServerCard({ server }: ServerCardProps) {
</button> </button>
</form> </form>
<form action={stopServerAction.bind(null, server.id)}> <form action={stopServerEventAction.bind(null, server.id)}>
<button <button
type="submit" type="submit"
disabled={server.status === ServiceStatus.Stopped} disabled={server.status === ServiceStatus.Stopped}

View File

@@ -1,6 +1,10 @@
import Link from 'next/link'; import Link from 'next/link';
import { Server, getStatusColor, serviceStatusToString, ServiceStatus } from '@/lib/types/server'; 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 { interface ServerHeaderProps {
server: Server; server: Server;
@@ -49,7 +53,7 @@ export function ServerHeader({ server }: ServerHeaderProps) {
</div> </div>
<div className="flex space-x-3"> <div className="flex space-x-3">
<form action={startServerAction.bind(null, server.id)}> <form action={startServerEventAction.bind(null, server.id)}>
<button <button
type="submit" type="submit"
disabled={server.status === ServiceStatus.Running} disabled={server.status === ServiceStatus.Running}
@@ -59,7 +63,7 @@ export function ServerHeader({ server }: ServerHeaderProps) {
</button> </button>
</form> </form>
<form action={restartServerAction.bind(null, server.id)}> <form action={restartServerEventAction.bind(null, server.id)}>
<button <button
type="submit" type="submit"
disabled={server.status === ServiceStatus.Stopped} disabled={server.status === ServiceStatus.Stopped}
@@ -69,7 +73,7 @@ export function ServerHeader({ server }: ServerHeaderProps) {
</button> </button>
</form> </form>
<form action={stopServerAction.bind(null, server.id)}> <form action={stopServerEventAction.bind(null, server.id)}>
<button <button
type="submit" type="submit"
disabled={server.status === ServiceStatus.Stopped} disabled={server.status === ServiceStatus.Stopped}

View File

@@ -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) { export async function stopServerAction(serverId: string) {
try { try {
const session = await requireAuth(); 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) { export async function restartServerAction(serverId: string) {
try { try {
const session = await requireAuth(); const session = await requireAuth();
@@ -45,3 +53,7 @@ export async function restartServerAction(serverId: string) {
}; };
} }
} }
export async function restartServerEventAction(serverId: string) {
await restartServerAction(serverId);
}