Skip to content

Commit 899528c

Browse files
committed
feat: add Xray JSON template and localization support
- Introduce Xray JSON template route and sidebar menu item - Add localization for Xray JSON template description in English, Farsi, and Russian - Update backend contract to version 0.3.6 - Modify simple metrics to use bytes utility without prefix - Add Xray JSON template description widget
1 parent b553829 commit 899528c

File tree

13 files changed

+118
-12
lines changed

13 files changed

+118
-12
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"@mantine/nprogress": "^7.17.1",
4646
"@monaco-editor/react": "^4.7.0",
4747
"@paralleldrive/cuid2": "2.2.2",
48-
"@remnawave/backend-contract": "0.3.4",
48+
"@remnawave/backend-contract": "0.3.6",
4949
"@stablelib/base64": "^2.0.1",
5050
"@stablelib/x25519": "^2.0.1",
5151
"@tabler/icons-react": "^3.31.0",

public/locales/en/remnawave.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,12 @@
396396
"password-too-short": "Minimum 24 characters",
397397
"register-description": "Create a super-admin account to get started"
398398
}
399+
},
400+
"xray-json-template-description": {
401+
"widget": {
402+
"importing-json-subscription": "Importing JSON subscription",
403+
"description-line-1": "To use this subscription, just add",
404+
"description-line-2": "at the end of your subscription link. Make sure you're using one of the supported apps listed in the table below. Otherwise, subscription will work as usual for requsted client. (e.g. Base64, Mihomo)"
405+
}
399406
}
400407
}

public/locales/fa/remnawave.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,12 @@
396396
"password-too-short": "حداقل 24 کاراکتر",
397397
"register-description": "برای شروع یک اکانت سوپرادمین ایجاد کنید"
398398
}
399+
},
400+
"xray-json-template-description": {
401+
"widget": {
402+
"description-line-1": "برای استفاده از این اشتراک ، فقط اضافه کنید",
403+
"description-line-2": "در انتهای لینک اشتراک خود. \nاطمینان حاصل کنید که از یکی از برنامه های پشتیبانی شده ذکر شده در جدول زیر استفاده می کنید.",
404+
"importing-json-subscription": "وارد کردن اشتراک JSON"
405+
}
399406
}
400-
}
407+
}

public/locales/ru/remnawave.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,12 @@
396396
"sign-up": "Зарегистрироваться",
397397
"username": "Имя пользователя"
398398
}
399+
},
400+
"xray-json-template-description": {
401+
"widget": {
402+
"description-line-1": "Чтобы использовать эту подписку, просто добавьте",
403+
"description-line-2": "в конец вашей ссылки на подписку. \nУбедитесь, что вы используете одно из поддерживаемых приложений, перечисленных в таблице ниже. \nИначе подписка будет работать как обычно для запрошенного клиента. (например, Base64, Mihomo)",
404+
"importing-json-subscription": "Импорт JSON подписки"
405+
}
399406
}
400407
}

src/app/layouts/dashboard/sidebar/menu-sections.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export const useMenuSections = (): MenuItem[] => {
7575
href: ROUTES.DASHBOARD.NODES,
7676
icon: PiBracketsCurly,
7777
dropdownItems: [
78+
{
79+
name: 'Xray JSON',
80+
href: ROUTES.DASHBOARD.TEMPLATES.XRAY_JSON
81+
},
7882
{
7983
name: 'Mihomo',
8084
href: ROUTES.DASHBOARD.TEMPLATES.MIHOMO

src/app/router/router.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ const router = createBrowserRouter(
9696
}
9797
path={ROUTES.DASHBOARD.TEMPLATES.SINGBOX_LEGACY}
9898
/>
99+
<Route
100+
element={
101+
<TemplateBasePageConnector
102+
language="json"
103+
templateType={SUBSCRIPTION_TEMPLATE_TYPE.XRAY_JSON}
104+
title="Xray JSON"
105+
/>
106+
}
107+
path={ROUTES.DASHBOARD.TEMPLATES.XRAY_JSON}
108+
/>
99109
</Route>
100110

101111
<Route element={<NotFoundPageComponent />} path="*" />

src/pages/dashboard/home/components/metrics/simple-metrics.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { GetStatsCommand } from '@remnawave/backend-contract'
33
import { TFunction } from 'i18next'
44
import dayjs from 'dayjs'
55

6-
import { prettyBytesUtil } from '@shared/utils/bytes'
6+
import { prettyBytesUtil, prettyBytesUtilWithoutPrefix } from '@shared/utils/bytes'
77

88
export const getSimpleMetrics = (
99
systemInfo: GetStatsCommand.Response['response'],
@@ -16,7 +16,7 @@ export const getSimpleMetrics = (
1616

1717
return [
1818
{
19-
value: prettyBytesUtil(Number(users.totalTrafficBytes)) ?? 0,
19+
value: prettyBytesUtilWithoutPrefix(Number(users.totalTrafficBytes)) ?? 0,
2020
icon: PiChartBarDuotone,
2121
title: t('simple-metrics.total-traffic'),
2222
color: 'green'

src/pages/dashboard/templates/ui/components/template-base-page.component.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { TSubscriptionTemplateType } from '@remnawave/backend-contract'
22
import { useTranslation } from 'react-i18next'
3-
import { Divider } from '@mantine/core'
43

54
import { SubscriptionTemplateEditorWidget } from '@widgets/dashboard/templates/subscription-template-editor'
65
import { ROUTES } from '@shared/constants'
@@ -37,7 +36,6 @@ export const TemplateBasePageComponent = (props: Props) => {
3736
templateJson={templateJson}
3837
templateType={templateType}
3938
/>
40-
<Divider mb="md" mt="md" size="md" />
4139
</Page>
4240
)
4341
}

src/shared/constants/routes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const ROUTES = {
1414
NODES_STATS: '/dashboard/stats/nodes',
1515
API_TOKENS: '/dashboard/api-tokens',
1616
TEMPLATES: {
17+
XRAY_JSON: '/dashboard/templates/xray-json',
1718
MIHOMO: '/dashboard/templates/mihomo',
1819
SINGBOX_LEGACY: '/dashboard/templates/sg-legacy',
1920
SINGBOX: '/dashboard/templates/singbox',

0 commit comments

Comments
 (0)