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