Skip to content

Commit 9b63e4f

Browse files
authored
bug fixes (#116)
* bug fixes * fix ws url
1 parent dfe7d57 commit 9b63e4f

File tree

8 files changed

+30
-29
lines changed

8 files changed

+30
-29
lines changed

src/components/fm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ const FMComponent: React.FC<FMProps & JSX.IntrinsicElements["div"]> = ({ wsUrl,
161161
}
162162

163163
useEffect(() => {
164-
const ws = new WebSocket(wsUrl)
164+
const url = new URL(wsUrl, window.location.origin)
165+
const ws = new WebSocket(url)
165166
wsRef.current = ws
166167
ws.binaryType = "arraybuffer"
167168
ws.onopen = () => {

src/components/server-config-batch.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,17 @@ export const ServerConfigCardBatch: React.FC<ServerConfigCardBatchProps> = ({ si
5454
setOpen(false)
5555
}
5656

57-
return (
57+
return sid.length < 1 ? (
58+
<IconButton
59+
{...props}
60+
icon="cog"
61+
onClick={() => {
62+
toast(t("Error"), {
63+
description: t("Results.NoRowsAreSelected"),
64+
})
65+
}}
66+
/>
67+
) : (
5868
<Dialog open={open} onOpenChange={setOpen}>
5969
<DialogTrigger asChild>
6070
<IconButton {...props} icon="cog" />
@@ -67,7 +77,7 @@ export const ServerConfigCardBatch: React.FC<ServerConfigCardBatchProps> = ({ si
6777
<DialogDescription />
6878
</DialogHeader>
6979
<div className="flex flex-col gap-3 mt-4">
70-
<Label>Option</Label>
80+
<Label>{t("Option")}</Label>
7181
<Input
7282
type="text"
7383
placeholder="option"
@@ -76,7 +86,7 @@ export const ServerConfigCardBatch: React.FC<ServerConfigCardBatchProps> = ({ si
7686
setCurrentKey(e.target.value)
7787
}}
7888
/>
79-
<Label>Value</Label>
89+
<Label>{t("Value")}</Label>
8090
<Textarea
8191
className="resize-y"
8292
value={currentVal}

src/components/server-config.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ for (let i = 0; i < boolFields.length; i += 2) {
101101
}
102102

103103
interface ServerConfigCardProps extends ButtonProps {
104-
sid: number[]
104+
sid: number
105105
}
106106

107107
export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
@@ -113,11 +113,7 @@ export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
113113
useEffect(() => {
114114
const fetchData = async () => {
115115
try {
116-
if (sid.length > 1) {
117-
setLoading(false)
118-
return
119-
}
120-
const result = await getServerConfig(sid[0])
116+
const result = await getServerConfig(sid)
121117
setData(JSON.parse(result))
122118
} catch (error) {
123119
console.error(error)
@@ -168,7 +164,7 @@ export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
168164
values.hard_drive_partition_allowlist = values.hard_drive_partition_allowlist_raw
169165
? JSON.parse(values.hard_drive_partition_allowlist_raw)
170166
: undefined
171-
resp = await setServerConfig({ config: JSON.stringify(values), servers: sid })
167+
resp = await setServerConfig({ config: JSON.stringify(values), servers: [sid] })
172168
} catch (e) {
173169
console.error(e)
174170
toast(t("Error"), {
@@ -187,17 +183,7 @@ export const ServerConfigCard = ({ sid, ...props }: ServerConfigCardProps) => {
187183
form.reset()
188184
}
189185

190-
return sid.length < 1 ? (
191-
<IconButton
192-
{...props}
193-
icon="cog"
194-
onClick={() => {
195-
toast(t("Error"), {
196-
description: t("Results.NoRowsAreSelected"),
197-
})
198-
}}
199-
/>
200-
) : (
186+
return (
201187
<Dialog open={open} onOpenChange={setOpen}>
202188
<DialogTrigger asChild>
203189
<IconButton {...props} icon="cog" />

src/components/terminal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const XtermComponent = forwardRef<HTMLDivElement, XtermProps & JSX.IntrinsicElem
5353
cursorBlink: true,
5454
fontSize: 16,
5555
})
56-
const ws = new WebSocket(wsUrl)
56+
const url = new URL(wsUrl, window.location.origin)
57+
const ws = new WebSocket(url)
5758
wsRef.current = ws
5859
ws.binaryType = "arraybuffer"
5960
ws.onopen = () => {

src/components/xui/pusher.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client"
22

33
import { useState } from "react"
4+
import { useTranslation } from "react-i18next"
45

56
import { Label } from "../ui/label"
67
import { Textarea } from "../ui/textarea"
@@ -13,6 +14,7 @@ interface PusherProps {
1314

1415
export const Pusher: React.FC<PusherProps> = ({ property, setData }) => {
1516
const [cData, setCData] = useState<Record<string, any>>({})
17+
const { t } = useTranslation()
1618

1719
return (
1820
<div className="flex flex-col gap-3">
@@ -43,7 +45,7 @@ export const Pusher: React.FC<PusherProps> = ({ property, setData }) => {
4345
}}
4446
/>
4547
</div>
46-
<Label>Preview</Label>
48+
<Label>{t("Preview")}</Label>
4749
<Textarea value={JSON.stringify(cData, null, 2)} readOnly />
4850
</div>
4951
)

src/locales/en/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,5 +181,8 @@
181181
"EmptyText": "Text is empty",
182182
"EmptyNote": "You didn't have any note.",
183183
"OverrideDDNSDomains": "Override DDNS Domains (per configuration)",
184-
"EditServerConfig": "Edit Server Config"
184+
"EditServerConfig": "Edit Server Config",
185+
"Option": "Option",
186+
"Value": "Value",
187+
"Preview": "Preview"
185188
}

src/routes/server.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default function ServerPage() {
145145
<>
146146
<TerminalButton id={s.id} />
147147
<ServerCard mutate={mutate} data={s} />
148-
<ServerConfigCard sid={[s.id]} variant="outline" />
148+
<ServerConfigCard sid={s.id} variant="outline" />
149149
</>
150150
</ActionButtonGroup>
151151
)

src/routes/settings.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,7 @@ export default function SettingsPage() {
6767
resolver: zodResolver(settingFormSchema),
6868
defaultValues: config
6969
? {
70-
...config,
71-
language: config?.config?.language,
72-
site_name: config.config?.site_name || "",
70+
...config.config,
7371
user_template:
7472
config.config?.user_template ||
7573
Object.keys(config.frontend_templates?.filter((t) => !t.is_admin) || {})[0] ||

0 commit comments

Comments
 (0)