From e0a956646f77582161830395077fb39022db90bf Mon Sep 17 00:00:00 2001 From: GregTCLTK Date: Sun, 21 Jan 2024 15:37:21 +0100 Subject: [PATCH] fix: implement breaking webgen changes and fix wizard --- pages/hosting/data.ts | 2 +- pages/hosting/loading.ts | 2 +- pages/hosting/modrinth.ts | 6 +++--- pages/hosting/translation.ts | 1 + pages/hosting/types.ts | 2 +- pages/hosting/views/ServerStaticInfo.ts | 2 +- pages/hosting/views/dialogs/deleteServerDialog.ts | 2 +- pages/hosting/views/pathNavigation.ts | 5 +++-- pages/hosting/views/wizard.ts | 2 +- 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pages/hosting/data.ts b/pages/hosting/data.ts index afe13303..0e35be59 100644 --- a/pages/hosting/data.ts +++ b/pages/hosting/data.ts @@ -5,7 +5,7 @@ export const MB = 1000000; export const state = asState({ loaded: false, - servers: <(Server)[]>[], + servers: [], meta: undefined! }); diff --git a/pages/hosting/loading.ts b/pages/hosting/loading.ts index 8c047479..333d85e3 100644 --- a/pages/hosting/loading.ts +++ b/pages/hosting/loading.ts @@ -9,7 +9,7 @@ import { state } from "./data.ts"; import { canWriteInFolder, currentFiles } from "./views/state.ts"; export async function refreshState() { - state.servers = asState((await API.hosting.servers()).map(x => asState(x))); + state.servers = asState(await API.hosting.servers()); state.meta = asState(await API.hosting.meta()); } diff --git a/pages/hosting/modrinth.ts b/pages/hosting/modrinth.ts index 8272f44d..62c5fa6e 100644 --- a/pages/hosting/modrinth.ts +++ b/pages/hosting/modrinth.ts @@ -87,7 +87,7 @@ async function find(versions: string[], type: ServerTypes, offset = 0, limit = 2 path.searchParams.set("offset", offset.toString()); const json = await retry(async () => { - const response = await pipeline.fetch(SchedulerPriority.High, path.toString()); + const response = await pipeline.fetch(SchedulerPriority.High, path.toString()).promise; assert(response.ok); return response.json(); }); @@ -105,7 +105,7 @@ async function getLatestDownload(versions: string[], type: ServerTypes, projecti path.searchParams.set("game_versions", JSON.stringify(versions)); const json = await retry(async () => { - const response = await pipeline.fetch(SchedulerPriority.Low, path.toString()); + const response = await pipeline.fetch(SchedulerPriority.Low, path.toString()).promise; assert(response.ok); return response.json(); }); @@ -118,7 +118,7 @@ async function getLatestDownload(versions: string[], type: ServerTypes, projecti async function getSpecificDownload(versionId: string) { const path = new URL(`${apiUrl}/version/${versionId}`); const json = await retry(async () => { - const response = await pipeline.fetch(SchedulerPriority.High, path.toString()); + const response = await pipeline.fetch(SchedulerPriority.High, path.toString()).promise; assert(response.ok); return response.json(); }); diff --git a/pages/hosting/translation.ts b/pages/hosting/translation.ts index 09b75af5..88e0240e 100644 --- a/pages/hosting/translation.ts +++ b/pages/hosting/translation.ts @@ -4,6 +4,7 @@ export const labels = { suspended: "Suspended", "contact-support": "Contact Support", maintenance: "Maintenance", + disabled: "Disabled", } satisfies Record; export const auditLabels = { diff --git a/pages/hosting/types.ts b/pages/hosting/types.ts index c67abea3..ed2d8bfa 100644 --- a/pages/hosting/types.ts +++ b/pages/hosting/types.ts @@ -12,7 +12,7 @@ export type GridItem = Component | [ settings: { export type RemotePath = { name: string; - size?: string; + size?: number; canWrite?: boolean; lastModified?: number; fileMimeType?: string; diff --git a/pages/hosting/views/ServerStaticInfo.ts b/pages/hosting/views/ServerStaticInfo.ts index 6a5cd869..9c737fe4 100644 --- a/pages/hosting/views/ServerStaticInfo.ts +++ b/pages/hosting/views/ServerStaticInfo.ts @@ -1,7 +1,7 @@ +import { calculateUptime } from "shared/uptime.ts"; import { format } from "std/fmt/bytes.ts"; import { asRef, BasicLabel, Component, Entry, Grid, ref, refMerge, StateHandler } from "webgen/mod.ts"; import { Server } from "../../../spec/music.ts"; -import { calculateUptime } from "../../shared/uptime.ts"; import { MB } from "../data.ts"; import { GridItem } from "../types.ts"; import { ChangeStateButton } from "./changeStateButton.ts"; diff --git a/pages/hosting/views/dialogs/deleteServerDialog.ts b/pages/hosting/views/dialogs/deleteServerDialog.ts index 50dd66a2..a8127ebc 100644 --- a/pages/hosting/views/dialogs/deleteServerDialog.ts +++ b/pages/hosting/views/dialogs/deleteServerDialog.ts @@ -10,7 +10,7 @@ export const deleteServerDialog = (serverId: string) => { Button("Cancel") .setStyle(ButtonStyle.Inline) .onClick(() => sheet.close()), - Button("Delete").setColor(Color.Critical).onClick(async () => { + Button("Delete").setColor(Color.Critical).onPromiseClick(async () => { await API.hosting.serverId(serverId).delete() .then(stupidErrorAlert); location.href = "/hosting"; diff --git a/pages/hosting/views/pathNavigation.ts b/pages/hosting/views/pathNavigation.ts index 0ba21f60..57d792c0 100644 --- a/pages/hosting/views/pathNavigation.ts +++ b/pages/hosting/views/pathNavigation.ts @@ -1,8 +1,9 @@ -import { Box, Button, ButtonStyle, Component, Custom, Grid, loadingWheel } from "webgen/mod.ts"; +import { Box, Button, ButtonStyle, Custom, Grid, loadingWheel } from "webgen/mod.ts"; import { listFiles } from "../loading.ts"; +import { GridItem } from "../types.ts"; import { loading, path } from "./state.ts"; -export function pathNavigation(): Component | [ settings: { width?: number | undefined; heigth?: number | undefined; }, element: Component ] { +export function pathNavigation(): GridItem { return path.map(list => Grid( ...list.split("/").filter((_, index, list) => (list.length - 1) != index).map((item, currentIndex, list) => Button(item || 'home') .setStyle(ButtonStyle.Secondary) diff --git a/pages/hosting/views/wizard.ts b/pages/hosting/views/wizard.ts index dd5a8571..798ac80c 100644 --- a/pages/hosting/views/wizard.ts +++ b/pages/hosting/views/wizard.ts @@ -93,7 +93,7 @@ export const creationView = () => creationState.$loading.map(loading => { Spacer(), Button("Submit").onClick(async () => { const { error, validate } = Validate( - state, + data, serverCreate ); const validation = validate();