feat: start on adding server module
This commit is contained in:
parent
ab2b41a74d
commit
39a37096dd
@ -11,6 +11,7 @@ import {
|
||||
WSModule,
|
||||
FSModule,
|
||||
} from "./modules/index.ts";
|
||||
import { ScheudlingModule } from "./modules/scheduling.ts";
|
||||
|
||||
export function handleError(err: any) {
|
||||
if (err instanceof ModrinthServerError && err.v1Error) {
|
||||
@ -40,6 +41,7 @@ export class ModrinthServer {
|
||||
readonly startup: StartupModule;
|
||||
readonly ws: WSModule;
|
||||
readonly fs: FSModule;
|
||||
readonly scheduling: ScheudlingModule;
|
||||
|
||||
constructor(serverId: string) {
|
||||
this.serverId = serverId;
|
||||
@ -51,6 +53,7 @@ export class ModrinthServer {
|
||||
this.startup = new StartupModule(this);
|
||||
this.ws = new WSModule(this);
|
||||
this.fs = new FSModule(this);
|
||||
this.scheduling = new ScheudlingModule(this);
|
||||
}
|
||||
|
||||
async createMissingFolders(path: string): Promise<void> {
|
||||
@ -192,7 +195,16 @@ export class ModrinthServer {
|
||||
const modulesToRefresh =
|
||||
modules.length > 0
|
||||
? modules
|
||||
: (["general", "content", "backups", "network", "startup", "ws", "fs"] as ModuleName[]);
|
||||
: ([
|
||||
"general",
|
||||
"content",
|
||||
"backups",
|
||||
"network",
|
||||
"startup",
|
||||
"ws",
|
||||
"fs",
|
||||
"scheduling",
|
||||
] as ModuleName[]);
|
||||
|
||||
for (const module of modulesToRefresh) {
|
||||
try {
|
||||
@ -237,6 +249,8 @@ export class ModrinthServer {
|
||||
case "fs":
|
||||
await this.fs.fetch();
|
||||
break;
|
||||
case "scheduling":
|
||||
await this.scheduling.fetch();
|
||||
}
|
||||
} catch (error) {
|
||||
this.errors[module] = {
|
||||
|
||||
26
apps/frontend/src/composables/servers/modules/scheduling.ts
Normal file
26
apps/frontend/src/composables/servers/modules/scheduling.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import type { ScheduledTask } from "@modrinth/utils";
|
||||
import { useServersFetch } from "../servers-fetch.ts";
|
||||
import { ServerModule } from "./base.ts";
|
||||
|
||||
export class ScheudlingModule extends ServerModule {
|
||||
tasks: ScheduledTask[] = [];
|
||||
|
||||
async fetch(): Promise<void> {
|
||||
this.tasks = await useServersFetch<ScheduledTask[]>(
|
||||
`servers/${this.serverId}/options/schedules`,
|
||||
{ version: 1 },
|
||||
);
|
||||
}
|
||||
|
||||
async deleteTask(_task: ScheduledTask): Promise<void> {
|
||||
// ...
|
||||
}
|
||||
|
||||
async createTask(_task: ScheduledTask): Promise<number> {
|
||||
return await 1;
|
||||
}
|
||||
|
||||
async editTask(_taskID: number, _task: Partial<ScheduledTask>) {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
@ -480,7 +480,7 @@ const loadModulesPromise = Promise.resolve().then(() => {
|
||||
if (server.general?.status === "suspended") {
|
||||
return;
|
||||
}
|
||||
return server.refresh(["content", "backups", "network", "startup", "fs"]);
|
||||
return server.refresh(["content", "backups", "network", "startup", "fs", "scheduling"]);
|
||||
});
|
||||
|
||||
provide("modulesLoaded", loadModulesPromise);
|
||||
|
||||
@ -16,7 +16,7 @@ import {
|
||||
CardIcon,
|
||||
UserIcon,
|
||||
WrenchIcon,
|
||||
CalendarSyncIcon
|
||||
CalendarSyncIcon,
|
||||
} from "@modrinth/assets";
|
||||
import { ModrinthServer } from "~/composables/servers/modrinth-servers.ts";
|
||||
import type { BackupInProgressReason } from "~/pages/servers/manage/[id].vue";
|
||||
@ -36,7 +36,11 @@ useHead({
|
||||
const navLinks = [
|
||||
{ icon: SettingsIcon, label: "General", href: `/servers/manage/${serverId}/options` },
|
||||
{ icon: WrenchIcon, label: "Platform", href: `/servers/manage/${serverId}/options/loader` },
|
||||
{ icon: CalendarSyncIcon, label: "Task Scheduling", href: `/servers/manage/${serverId}/options/scheduling`},
|
||||
{
|
||||
icon: CalendarSyncIcon,
|
||||
label: "Task Scheduling",
|
||||
href: `/servers/manage/${serverId}/options/scheduling`,
|
||||
},
|
||||
{ icon: TextQuoteIcon, label: "Startup", href: `/servers/manage/${serverId}/options/startup` },
|
||||
{ icon: VersionIcon, label: "Network", href: `/servers/manage/${serverId}/options/network` },
|
||||
{ icon: ListIcon, label: "Properties", href: `/servers/manage/${serverId}/options/properties` },
|
||||
|
||||
@ -179,8 +179,7 @@ const props = defineProps<{
|
||||
server: ModrinthServer;
|
||||
}>();
|
||||
|
||||
const tasks = ref<ScheduledTask[]>([]);
|
||||
|
||||
const tasks = ref<ScheduledTask[]>(props.server.scheduling.tasks);
|
||||
const selectedTasks = ref<ScheduledTask[]>([]);
|
||||
const sortBy = ref("Name");
|
||||
const descending = ref(false);
|
||||
|
||||
@ -16,4 +16,12 @@ export interface ModuleError {
|
||||
timestamp: number
|
||||
}
|
||||
|
||||
export type ModuleName = 'general' | 'content' | 'backups' | 'network' | 'startup' | 'ws' | 'fs'
|
||||
export type ModuleName =
|
||||
| 'general'
|
||||
| 'content'
|
||||
| 'backups'
|
||||
| 'network'
|
||||
| 'startup'
|
||||
| 'ws'
|
||||
| 'fs'
|
||||
| 'scheduling'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user