Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 14 additions & 32 deletions components/game-server-nodes/GameServerNodeRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -676,10 +676,7 @@ const isSectionExpanded = (section: string) => {
variant="outline"
size="sm"
class="shrink-0 border-yellow-500/50 text-yellow-500 hover:text-yellow-400"
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
@click="updateCs"
>
<CircleFadingArrowUp class="h-4 w-4" />
Expand All @@ -699,10 +696,7 @@ const isSectionExpanded = (section: string) => {
<Button
size="xs"
@click="updateCs"
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
v-if="gameServerNode.enabled"
>
{{ $t("game_server.install_cs") }}
Expand Down Expand Up @@ -880,10 +874,7 @@ const isSectionExpanded = (section: string) => {

<template v-if="!isGpuOnly">
<DropdownMenuItem
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
@click="updateCs"
>
<template v-if="gameServerNode.build_id">
Expand All @@ -897,10 +888,7 @@ const isSectionExpanded = (section: string) => {
</DropdownMenuItem>

<DropdownMenuItem
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
@click="updateCsgo"
>
<template v-if="gameServerNode.csgo_build_id">
Expand Down Expand Up @@ -1120,10 +1108,7 @@ const isSectionExpanded = (section: string) => {

<template v-if="!isGpuOnly">
<DropdownMenuItem
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
@click="updateCs"
>
<template v-if="gameServerNode.build_id">
Expand All @@ -1137,10 +1122,7 @@ const isSectionExpanded = (section: string) => {
</DropdownMenuItem>

<DropdownMenuItem
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
@click="updateCsgo"
>
<template v-if="gameServerNode.csgo_build_id">
Expand Down Expand Up @@ -1566,10 +1548,7 @@ const isSectionExpanded = (section: string) => {
variant="outline"
size="sm"
class="w-full mt-1 border-yellow-500/50 text-yellow-500 hover:text-yellow-400"
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
@click="updateCs"
>
<CircleFadingArrowUp class="mr-2 h-4 w-4" />
Expand All @@ -1587,10 +1566,7 @@ const isSectionExpanded = (section: string) => {
size="sm"
class="w-full"
@click="updateCs"
:disabled="
gameServerNode.status !==
e_game_server_node_statuses_enum.Online
"
:disabled="!isReachable"
v-if="gameServerNode.enabled"
>
{{ $t("game_server.install_cs") }}
Expand Down Expand Up @@ -1915,6 +1891,7 @@ interface GameServerNode {
region: string | null;
enabled: boolean;
enabled_for_match_making?: boolean;
accepting_new_matches: boolean;
demo_network_limiter?: number | null;
build_id?: string;
csgo_build_id?: number | null;
Expand Down Expand Up @@ -2576,6 +2553,11 @@ export default defineComponent({
hasRegion() {
return !!this.gameServerNode.region;
},
isReachable() {
return ["Online", "NotAcceptingNewMatches"].includes(
this.gameServerNode.status,
);
},
isGpuOnly() {
return (
!!this.gameServerNode.gpu &&
Expand Down
90 changes: 81 additions & 9 deletions components/game-server-nodes/NodeControlMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { useI18n } from "vue-i18n";
import { useToast } from "~/components/ui/toast/use-toast";
import { generateMutation } from "~/graphql/graphqlGen";
import { Switch } from "~/components/ui/switch";
import FiveStackToolTip from "~/components/FiveStackToolTip.vue";
import { e_game_server_node_statuses_enum } from "~/generated/zeus";
import {
Popover,
PopoverTrigger,
Expand All @@ -17,11 +19,26 @@ import {
Radio,
Play,
Clapperboard,
TriangleAlert,
} from "lucide-vue-next";

interface ControlledNode {
id: string;
status: string;
enabled: boolean;
enabled_for_match_making?: boolean;
accepting_new_matches: boolean;
start_port_range?: number | null;
end_port_range?: number | null;
gpu?: boolean;
gpu_streaming_enabled?: boolean;
gpu_demos_enabled?: boolean;
gpu_rendering_enabled?: boolean;
}

const props = withDefaults(
defineProps<{
node: any;
node: ControlledNode;
align?: "start" | "center" | "end";
}>(),
{
Expand All @@ -45,6 +62,29 @@ const allWorkloadsOn = computed(() =>
),
);

const acceptingNewMatches = computed(
() =>
props.node.accepting_new_matches ??
props.node.status === e_game_server_node_statuses_enum.Online,
);

const inSetup = computed(
() => props.node.status === e_game_server_node_statuses_enum.Setup,
);

const schedulingHint = computed(() => {
if (inSetup.value) {
return t("pages.gpu_nodes.scheduling_setup_hint");
}
if (
acceptingNewMatches.value &&
props.node.status === e_game_server_node_statuses_enum.Offline
) {
return t("pages.gpu_nodes.scheduling_offline_hint");
}
return null;
});

const flagged = computed(
() => props.node.gpu && props.node.enabled && !allWorkloadsOn.value,
);
Expand All @@ -70,14 +110,20 @@ async function setEnabled(enabled: boolean) {

async function setScheduling(accepting: boolean) {
try {
await client.mutate({
const { data } = await client.mutate({
mutation: generateMutation({
setGameNodeSchedulingState: [
{ game_server_node_id: props.node.id, enabled: accepting },
{ success: true },
],
}),
});
if (!data?.setGameNodeSchedulingState?.success) {
toast({
variant: "destructive",
title: t("pages.gpu_nodes.toggle_scheduling_failed"),
});
}
} catch (error: any) {
toast({
variant: "destructive",
Expand Down Expand Up @@ -145,21 +191,41 @@ async function setWorkload(
<label
v-if="hasPorts && node.enabled_for_match_making"
class="ncm-row"
:data-on="node.status === 'Online'"
:data-disabled="!node.enabled"
data-testid="scheduling-row"
:data-on="acceptingNewMatches"
:data-disabled="!node.enabled || inSetup"
>
<span class="ncm-ico"><CalendarCheck class="w-4 h-4" /></span>
<span class="ncm-text">
<span class="ncm-name">{{
t("pages.gpu_nodes.accepting_matches")
}}</span>
<span class="ncm-name">
{{ t("pages.gpu_nodes.accepting_matches") }}
<FiveStackToolTip
v-if="schedulingHint"
as-child
:delay-duration="120"
>
<template #trigger>
<span
class="ncm-hint"
tabindex="0"
role="img"
:aria-label="schedulingHint"
data-testid="scheduling-hint"
@click.prevent
>
<TriangleAlert class="w-3 h-3" />
</span>
</template>
<p class="max-w-[16rem]">{{ schedulingHint }}</p>
</FiveStackToolTip>
</span>
<span class="ncm-desc">{{
t("pages.gpu_nodes.toggle_scheduling_help")
}}</span>
</span>
<Switch
:model-value="node.status === 'Online'"
:disabled="!node.enabled"
:model-value="acceptingNewMatches"
:disabled="!node.enabled || inSetup"
@update:model-value="(v) => setScheduling(!!v)"
/>
</label>
Expand Down Expand Up @@ -323,6 +389,12 @@ async function setWorkload(
letter-spacing: 0.06em;
color: hsl(var(--foreground));
}
.ncm-hint {
display: inline-flex;
vertical-align: -0.1em;
color: hsl(var(--tac-amber));
cursor: help;
}
.ncm-row[data-on="false"] .ncm-name {
color: hsl(var(--muted-foreground));
}
Expand Down
Loading
Loading