Skip to content

Commit b553829

Browse files
committed
feat: add subscription templates and Monaco editor support
- Introduce new Templates section in sidebar with Mihomo, Stash, Singbox, and Singbox legacy routes - Add Monaco editor and YAML/JSON language support - Update backend contract to version 0.3.4 - Configure global Buffer and window.global for browser compatibility - Add new API hooks and routes for subscription templates - Enhance Monaco editor theme and configuration
1 parent 8930d05 commit b553829

File tree

28 files changed

+668
-16
lines changed

28 files changed

+668
-16
lines changed

index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@
3131
</head>
3232
<body>
3333
<div id="root"></div>
34+
<script>
35+
window.global = window
36+
</script>
37+
<script type="module">
38+
import { Buffer } from 'buffer'
39+
40+
window.Buffer = Buffer
41+
</script>
3442
<script type="module" src="/src/main.tsx"></script>
3543
</body>
3644
</html>

package-lock.json

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

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@
4545
"@mantine/nprogress": "^7.17.1",
4646
"@monaco-editor/react": "^4.7.0",
4747
"@paralleldrive/cuid2": "2.2.2",
48-
"@remnawave/backend-contract": "0.2.7",
48+
"@remnawave/backend-contract": "0.3.4",
4949
"@stablelib/base64": "^2.0.1",
5050
"@stablelib/x25519": "^2.0.1",
5151
"@tabler/icons-react": "^3.31.0",
5252
"@tanstack/react-query": "^5.66.9",
5353
"@tanstack/react-query-devtools": "^5.66.9",
5454
"axios": "^1.7.7",
55+
"buffer": "^6.0.3",
5556
"clsx": "^2.1.1",
5657
"color-hash": "^2.0.2",
5758
"consola": "^3.4.0",
@@ -64,6 +65,8 @@
6465
"i18next-http-backend": "^3.0.2",
6566
"mantine-datatable": "^7.15.1",
6667
"mantine-react-table": "^2.0.0-beta.9",
68+
"monaco-editor": "^0.52.2",
69+
"monaco-yaml": "^5.3.1",
6770
"motion": "^11.13.1",
6871
"nanoid": "^5.1.0",
6972
"react": "^18.3.1",

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
PiAirTrafficControlDuotone,
33
PiBookmarksDuotone,
4+
PiBracketsCurly,
45
PiComputerTowerDuotone,
56
PiCookie,
67
PiGearDuotone,
@@ -66,6 +67,34 @@ export const useMenuSections = (): MenuItem[] => {
6667
}
6768
]
6869
},
70+
{
71+
header: 'Templates',
72+
section: [
73+
{
74+
name: 'Subscription',
75+
href: ROUTES.DASHBOARD.NODES,
76+
icon: PiBracketsCurly,
77+
dropdownItems: [
78+
{
79+
name: 'Mihomo',
80+
href: ROUTES.DASHBOARD.TEMPLATES.MIHOMO
81+
},
82+
{
83+
name: 'Stash',
84+
href: ROUTES.DASHBOARD.TEMPLATES.STASH
85+
},
86+
{
87+
name: 'Singbox',
88+
href: ROUTES.DASHBOARD.TEMPLATES.SINGBOX
89+
},
90+
{
91+
name: 'Singbox legacy',
92+
href: ROUTES.DASHBOARD.TEMPLATES.SINGBOX_LEGACY
93+
}
94+
]
95+
}
96+
]
97+
},
6998
{
7099
header: 'Superadmin',
71100
section: [

src/app/router/router.tsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import {
55
Route,
66
RouterProvider
77
} from 'react-router-dom'
8+
import { SUBSCRIPTION_TEMPLATE_TYPE } from '@remnawave/backend-contract'
89

10+
import { TemplateBasePageConnector } from '@pages/dashboard/templates/ui/connectors/template-base-page.connector'
911
import { NodesBandwidthTablePageConnector } from '@pages/dashboard/nodes-bandwidth-table/ui/connectors'
1012
import { StatisticNodesConnector } from '@pages/dashboard/statistic-nodes/connectors'
1113
import { ApiTokensPageConnector } from '@pages/dashboard/api-tokens/ui/connectors'
@@ -53,6 +55,47 @@ const router = createBrowserRouter(
5355
element={<StatisticNodesConnector />}
5456
path={ROUTES.DASHBOARD.NODES_STATS}
5557
/>
58+
{/* Subscription templates */}
59+
<Route
60+
element={
61+
<TemplateBasePageConnector
62+
language="yaml"
63+
templateType={SUBSCRIPTION_TEMPLATE_TYPE.MIHOMO}
64+
title="Mihomo"
65+
/>
66+
}
67+
path={ROUTES.DASHBOARD.TEMPLATES.MIHOMO}
68+
/>
69+
<Route
70+
element={
71+
<TemplateBasePageConnector
72+
language="yaml"
73+
templateType={SUBSCRIPTION_TEMPLATE_TYPE.STASH}
74+
title="Stash"
75+
/>
76+
}
77+
path={ROUTES.DASHBOARD.TEMPLATES.STASH}
78+
/>
79+
<Route
80+
element={
81+
<TemplateBasePageConnector
82+
language="json"
83+
templateType={SUBSCRIPTION_TEMPLATE_TYPE.SINGBOX}
84+
title="Singbox"
85+
/>
86+
}
87+
path={ROUTES.DASHBOARD.TEMPLATES.SINGBOX}
88+
/>
89+
<Route
90+
element={
91+
<TemplateBasePageConnector
92+
language="json"
93+
templateType={SUBSCRIPTION_TEMPLATE_TYPE.SINGBOX_LEGACY}
94+
title="Singbox legacy"
95+
/>
96+
}
97+
path={ROUTES.DASHBOARD.TEMPLATES.SINGBOX_LEGACY}
98+
/>
5699
</Route>
57100

58101
<Route element={<NotFoundPageComponent />} path="*" />
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './interfaces'
2+
export * from './template-editor-actions.feature'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './props.interface'
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { TSubscriptionTemplateType } from '@remnawave/backend-contract'
2+
3+
/* eslint-disable @typescript-eslint/no-explicit-any */
4+
export interface Props {
5+
editorRef: any
6+
language: 'json' | 'yaml'
7+
monacoRef: any
8+
templateType: TSubscriptionTemplateType
9+
}

0 commit comments

Comments
 (0)