mirror of
https://github.com/Buriburizaem0n/admin-frontend-domain.git
synced 2026-02-04 04:30:06 +00:00
@@ -161,7 +161,8 @@ const FMComponent: React.FC<FMProps & JSX.IntrinsicElements["div"]> = ({ wsUrl,
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const ws = new WebSocket(wsUrl)
|
||||
const url = new URL(wsUrl, window.location.origin)
|
||||
const ws = new WebSocket(url)
|
||||
wsRef.current = ws
|
||||
ws.binaryType = "arraybuffer"
|
||||
ws.onopen = () => {
|
||||
|
||||
@@ -54,7 +54,17 @@ export const ServerConfigCardBatch: React.FC<ServerConfigCardBatchProps> = ({ si
|
||||
setOpen(false)
|
||||
}
|
||||
|
||||
return (
|
||||
return sid.length < 1 ? (
|
||||
<IconButton
|
||||
{...props}
|
||||
icon="cog"
|
||||
onClick={() => {
|
||||
toast(t("Error"), {
|
||||
description: t("Results.NoRowsAreSelected"),
|
||||
})
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<IconButton {...props} icon="cog" />
|
||||
@@ -67,7 +77,7 @@ export const ServerConfigCardBatch: React.FC<ServerConfigCardBatchProps> = ({ si
|
||||
<DialogDescription />
|
||||
</DialogHeader>
|
||||
<div className="flex flex-col gap-3 mt-4">
|
||||
<Label>Option</Label>
|
||||
<Label>{t("Option")}</Label>
|
||||
<Input
|
||||
type="text"
|
||||
placeholder="option"
|
||||
@@ -76,7 +86,7 @@ export const ServerConfigCardBatch: React.FC<ServerConfigCardBatchProps> = ({ si
|
||||
setCurrentKey(e.target.value)
|
||||
}}
|
||||
/>
|
||||
<Label>Value</Label>
|
||||
<Label>{t("Value")}</Label>
|
||||
<Textarea
|
||||
className="resize-y"
|
||||
value={currentVal}
|
||||
|
||||
@@ -101,7 +101,7 @@ for (let i = 0; i < boolFields.length; i += 2) {
|
||||
}
|
||||
|
||||
interface ServerConfigCardProps extends ButtonProps {
|
||||
sid: number[]
|
||||
sid: number
|
||||
}
|
||||
|
||||
export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
|
||||
@@ -113,11 +113,7 @@ export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
if (sid.length > 1) {
|
||||
setLoading(false)
|
||||
return
|
||||
}
|
||||
const result = await getServerConfig(sid[0])
|
||||
const result = await getServerConfig(sid)
|
||||
setData(JSON.parse(result))
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
@@ -168,7 +164,7 @@ export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
|
||||
values.hard_drive_partition_allowlist = values.hard_drive_partition_allowlist_raw
|
||||
? JSON.parse(values.hard_drive_partition_allowlist_raw)
|
||||
: undefined
|
||||
resp = await setServerConfig({ config: JSON.stringify(values), servers: sid })
|
||||
resp = await setServerConfig({ config: JSON.stringify(values), servers: [sid] })
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
toast(t("Error"), {
|
||||
@@ -187,17 +183,7 @@ export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
|
||||
form.reset()
|
||||
}
|
||||
|
||||
return sid.length < 1 ? (
|
||||
<IconButton
|
||||
{...props}
|
||||
icon="cog"
|
||||
onClick={() => {
|
||||
toast(t("Error"), {
|
||||
description: t("Results.NoRowsAreSelected"),
|
||||
})
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<DialogTrigger asChild>
|
||||
<IconButton {...props} icon="cog" />
|
||||
|
||||
@@ -53,7 +53,8 @@ const XtermComponent = forwardRef<HTMLDivElement, XtermProps & JSX.IntrinsicElem
|
||||
cursorBlink: true,
|
||||
fontSize: 16,
|
||||
})
|
||||
const ws = new WebSocket(wsUrl)
|
||||
const url = new URL(wsUrl, window.location.origin)
|
||||
const ws = new WebSocket(url)
|
||||
wsRef.current = ws
|
||||
ws.binaryType = "arraybuffer"
|
||||
ws.onopen = () => {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import { useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { Label } from "../ui/label"
|
||||
import { Textarea } from "../ui/textarea"
|
||||
@@ -13,6 +14,7 @@ interface PusherProps {
|
||||
|
||||
export const Pusher: React.FC<PusherProps> = ({ property, setData }) => {
|
||||
const [cData, setCData] = useState<Record<string, any>>({})
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
@@ -43,7 +45,7 @@ export const Pusher: React.FC<PusherProps> = ({ property, setData }) => {
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<Label>Preview</Label>
|
||||
<Label>{t("Preview")}</Label>
|
||||
<Textarea value={JSON.stringify(cData, null, 2)} readOnly />
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -181,5 +181,8 @@
|
||||
"EmptyText": "Text is empty",
|
||||
"EmptyNote": "You didn't have any note.",
|
||||
"OverrideDDNSDomains": "Override DDNS Domains (per configuration)",
|
||||
"EditServerConfig": "Edit Server Config"
|
||||
"EditServerConfig": "Edit Server Config",
|
||||
"Option": "Option",
|
||||
"Value": "Value",
|
||||
"Preview": "Preview"
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ export default function ServerPage() {
|
||||
<>
|
||||
<TerminalButton id={s.id} />
|
||||
<ServerCard mutate={mutate} data={s} />
|
||||
<ServerConfigCard sid={[s.id]} variant="outline" />
|
||||
<ServerConfigCard sid={s.id} variant="outline" />
|
||||
</>
|
||||
</ActionButtonGroup>
|
||||
)
|
||||
|
||||
@@ -67,9 +67,7 @@ export default function SettingsPage() {
|
||||
resolver: zodResolver(settingFormSchema),
|
||||
defaultValues: config
|
||||
? {
|
||||
...config,
|
||||
language: config?.config?.language,
|
||||
site_name: config.config?.site_name || "",
|
||||
...config.config,
|
||||
user_template:
|
||||
config.config?.user_template ||
|
||||
Object.keys(config.frontend_templates?.filter((t) => !t.is_admin) || {})[0] ||
|
||||
|
||||
Reference in New Issue
Block a user