Skip to content

Commit 517f239

Browse files
committed
refactor: use uozi admin-kit
1 parent daee3ac commit 517f239

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1669
-1310
lines changed

app/eslint.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export default createConfig(
5151
'sonarjs/no-nested-template-literals': 'off',
5252
'sonarjs/pseudo-random': 'warn',
5353
'sonarjs/no-nested-functions': 'off',
54+
55+
'eslint-comments/no-unlimited-disable': 'off',
5456
},
5557
},
5658
)

app/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
{
22
"name": "nginx-ui-app-next",
33
"type": "module",
4-
"version": "2.0.0",
5-
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
4+
"version": "2.1.0-beta.1",
5+
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39",
66
"scripts": {
77
"dev": "vite --host",
88
"typecheck": "vue-tsc --noEmit",
99
"lint": "eslint .",
1010
"lint:fix": "eslint --fix .",
1111
"build": "vite build",
1212
"preview": "vite preview",
13-
"gettext:extract": "vue-gettext-extract"
13+
"gettext:extract": "generate-curd-translations --output src/language/curd.ts && vue-gettext-extract"
1414
},
1515
"dependencies": {
1616
"@0xjacky/vue-github-button": "^3.1.1",
1717
"@ant-design/icons-vue": "^7.0.1",
1818
"@formkit/auto-animate": "^0.8.2",
1919
"@simplewebauthn/browser": "^13.1.0",
2020
"@uozi-admin/curd": "^4.1.4",
21+
"@uozi-admin/request": "^2.6.0",
2122
"@vue/reactivity": "^3.5.14",
2223
"@vue/shared": "^3.5.14",
2324
"@vueuse/components": "^13.2.0",

app/pnpm-lock.yaml

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

app/src/api/2fa.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthenticationResponseJSON } from '@simplewebauthn/browser'
2-
import http from '@/lib/http'
2+
import { http } from '@uozi-admin/request'
33

44
export interface TwoFAStatus {
55
enabled: boolean

app/src/api/acme_user.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ModelBase } from '@/api/curd'
2-
import Curd from '@/api/curd'
3-
import http from '@/lib/http'
2+
import { http, useCurdApi } from '@uozi-admin/request'
43

54
export interface AcmeUser extends ModelBase {
65
name: string
@@ -9,16 +8,10 @@ export interface AcmeUser extends ModelBase {
98
registration: { body?: { status: string } }
109
}
1110

12-
class ACMEUserCurd extends Curd<AcmeUser> {
13-
constructor() {
14-
super('acme_users')
15-
}
11+
const baseUrl = '/acme_users'
1612

17-
public async register(id: number) {
18-
return http.post(`${this.baseUrl}/${id}/register`)
19-
}
20-
}
21-
22-
const acme_user = new ACMEUserCurd()
13+
const acme_user = useCurdApi<AcmeUser>(baseUrl, {
14+
register: (id: number) => http.post(`${baseUrl}/${id}/register`),
15+
})
2316

2417
export default acme_user

app/src/api/analytic.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22
import ws from '@/lib/websocket'
33

44
export interface CPUInfoStat {

app/src/api/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AuthenticationResponseJSON } from '@simplewebauthn/browser'
2-
import http from '@/lib/http'
2+
import { http } from '@uozi-admin/request'
33
import { useUserStore } from '@/pinia'
44

55
const { login, logout } = useUserStore()

app/src/api/auto_cert.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export const AutoCertChallengeMethod = {
44
http01: 'http01',

app/src/api/backup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
/**
44
* Interface for restore backup response

app/src/api/cert.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { AcmeUser } from '@/api/acme_user'
33
import type { ModelBase } from '@/api/curd'
44
import type { DnsCredential } from '@/api/dns_credential'
55
import type { PrivateKeyType } from '@/constants'
6-
import Curd from '@/api/curd'
6+
import { useCurdApi } from '@uozi-admin/request'
77

88
export interface Cert extends ModelBase {
99
name: string
@@ -39,6 +39,6 @@ export interface CertificateResult {
3939
key_type: PrivateKeyType
4040
}
4141

42-
const cert: Curd<Cert> = new Curd('/certs')
42+
const cert = useCurdApi<Cert>('/certs')
4343

4444
export default cert

app/src/api/config.ts

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { GetListResponse } from '@/api/curd'
22
import type { ChatComplicationMessage } from '@/api/openai'
3-
import Curd from '@/api/curd'
4-
import http from '@/lib/http'
3+
import { http, useCurdApi } from '@uozi-admin/request'
54

65
export interface ModelBase {
76
id: number
@@ -26,33 +25,16 @@ export interface ConfigBackup extends ModelBase {
2625
content: string
2726
}
2827

29-
class ConfigCurd extends Curd<Config> {
30-
constructor() {
31-
super('/configs')
32-
}
33-
34-
get_base_path() {
35-
return http.get('/config_base_path')
36-
}
37-
38-
mkdir(basePath: string, name: string) {
39-
return http.post('/config_mkdir', { base_path: basePath, folder_name: name })
40-
}
41-
42-
rename(basePath: string, origName: string, newName: string, syncNodeIds?: number[]) {
43-
return http.post('/config_rename', {
44-
base_path: basePath,
45-
orig_name: origName,
46-
new_name: newName,
47-
sync_node_ids: syncNodeIds,
48-
})
49-
}
50-
51-
get_history(filepath: string) {
52-
return http.get<GetListResponse<ConfigBackup>>('/config_histories', { params: { filepath } })
53-
}
54-
}
55-
56-
const config: ConfigCurd = new ConfigCurd()
28+
const config = useCurdApi<Config>('/configs', {
29+
get_base_path: () => http.get('/config_base_path'),
30+
mkdir: (basePath: string, name: string) => http.post('/config_mkdir', { base_path: basePath, folder_name: name }),
31+
rename: (basePath: string, origName: string, newName: string, syncNodeIds?: number[]) => http.post('/config_rename', {
32+
base_path: basePath,
33+
orig_name: origName,
34+
new_name: newName,
35+
sync_node_ids: syncNodeIds,
36+
}),
37+
get_history: (filepath: string) => http.get<GetListResponse<ConfigBackup>>('/config_histories', { params: { filepath } }),
38+
})
5739

5840
export default config

app/src/api/curd.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface ModelBase {
44
id: number
@@ -18,6 +18,12 @@ export interface GetListResponse<T> {
1818
pagination?: Pagination
1919
}
2020

21+
export interface UpdateOrderRequest {
22+
target_id: number
23+
direction: number
24+
affected_ids: number[]
25+
}
26+
2127
class Curd<T> {
2228
protected readonly baseUrl: string
2329

app/src/api/dns_credential.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DNSProvider } from '@/api/auto_cert'
22
import type { ModelBase } from '@/api/curd'
3-
import Curd from '@/api/curd'
3+
import { useCurdApi } from '@uozi-admin/request'
44

55
export interface DnsCredential extends ModelBase {
66
name: string
@@ -17,6 +17,8 @@ export interface DnsCredential extends ModelBase {
1717
}
1818
}
1919

20-
const dns_credential: Curd<DnsCredential> = new Curd('/dns_credentials')
20+
const baseUrl = '/dns_credentials'
21+
22+
const dns_credential = useCurdApi<DnsCredential>(baseUrl)
2123

2224
export default dns_credential

app/src/api/env_group.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import type { ModelBase } from '@/api/curd'
2-
import Curd from '@/api/curd'
3-
1+
import type { ModelBase, UpdateOrderRequest } from '@/api/curd'
2+
import { http, useCurdApi } from '@uozi-admin/request'
43
// Post-sync action types
54
export const PostSyncAction = {
65
None: 'none',
@@ -13,4 +12,12 @@ export interface EnvGroup extends ModelBase {
1312
post_sync_action?: string
1413
}
1514

16-
export default new Curd<EnvGroup>('/env_groups')
15+
const baseUrl = '/env_groups'
16+
17+
const env_group = useCurdApi<EnvGroup>(baseUrl, {
18+
updateOrder(data: UpdateOrderRequest) {
19+
return http.post('/env_groups/order', data)
20+
},
21+
})
22+
23+
export default env_group

app/src/api/environment.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ModelBase } from '@/api/curd'
2-
import Curd from '@/api/curd'
3-
import http from '@/lib/http'
2+
import { http, useCurdApi } from '@uozi-admin/request'
43

54
export interface Environment extends ModelBase {
65
name: string
@@ -16,16 +15,10 @@ export interface Node {
1615
response_at?: Date
1716
}
1817

19-
class EnvironmentCurd extends Curd<Environment> {
20-
constructor() {
21-
super('/environments')
22-
}
18+
const baseUrl = '/environments'
2319

24-
load_from_settings() {
25-
return http.post(`${this.baseUrl}/load_from_settings`)
26-
}
27-
}
28-
29-
const environment: EnvironmentCurd = new EnvironmentCurd()
20+
const environment = useCurdApi<Environment>(baseUrl, {
21+
load_from_settings: () => http.post(`${baseUrl}/load_from_settings`),
22+
})
3023

3124
export default environment

app/src/api/external_notify.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import type { ModelBase } from '@/api/curd'
2-
import Curd from '@/api/curd'
2+
import { useCurdApi } from '@uozi-admin/request'
33

44
export interface ExternalNotify extends ModelBase {
55
type: string
66
config: Record<string, string>
77
}
88

9-
class ExternalNotifyCurd extends Curd<ExternalNotify> {
10-
constructor() {
11-
super('/external_notifies')
12-
}
13-
}
9+
const baseUrl = '/external_notifies'
1410

15-
const externalNotify: ExternalNotifyCurd = new ExternalNotifyCurd()
11+
const externalNotify = useCurdApi<ExternalNotify>(baseUrl)
1612

1713
export default externalNotify

app/src/api/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface InstallRequest {
44
email: string

app/src/api/nginx_log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface INginxLogData {
44
type: string
@@ -10,7 +10,7 @@ const nginx_log = {
1010
return http.post(`/nginx_log?page=${page}`, data)
1111
},
1212

13-
get_list(params: {
13+
getList(params: {
1414
type?: string
1515
name?: string
1616
path?: string

app/src/api/ngx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface NgxConfig {
44
file_name?: string

app/src/api/node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
function reloadNginx(nodeIds: number[]) {
44
return http.post('/environments/reload_nginx', { node_ids: nodeIds })

app/src/api/notification.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import type { ModelBase } from '@/api/curd'
2-
import Curd from '@/api/curd'
3-
import http from '@/lib/http'
2+
import { http, useCurdApi } from '@uozi-admin/request'
43

54
export interface Notification extends ModelBase {
65
type: string
76
title: string
87
details: string
98
}
109

11-
class NotificationCurd extends Curd<Notification> {
12-
public clear() {
13-
return http.delete(this.baseUrl)
14-
}
15-
}
10+
const baseUrl = '/notifications'
1611

17-
const notification = new NotificationCurd('/notifications')
12+
const notification = useCurdApi<Notification>(baseUrl, {
13+
clear: () => http.delete(baseUrl),
14+
})
1815

1916
export default notification

app/src/api/openai.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22
import ws from '@/lib/websocket'
33

44
export interface ChatComplicationMessage {

app/src/api/otp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { RecoveryCodesResponse } from '@/api/recovery'
2-
import http from '@/lib/http'
2+
import { http } from '@uozi-admin/request'
33

44
export interface OTPGenerateSecretResponse {
55
secret: string

app/src/api/passkey.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { RegistrationResponseJSON } from '@simplewebauthn/browser'
22
import type { ModelBase } from '@/api/curd'
3-
import http from '@/lib/http'
3+
import { http } from '@uozi-admin/request'
44

55
export interface Passkey extends ModelBase {
66
name: string

app/src/api/public.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface ICP {
44
icp_number: string

app/src/api/recovery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface RecoveryCode {
44
code: string

app/src/api/self_check.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Container } from '@/language'
22
import type { CosyError } from '@/lib/http'
3-
import http from '@/lib/http'
3+
import { http } from '@uozi-admin/request'
44
import ws from '@/lib/websocket'
55

66
export const ReportStatus = {

app/src/api/settings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import http from '@/lib/http'
1+
import { http } from '@uozi-admin/request'
22

33
export interface AppSettings {
44
page_size: number

0 commit comments

Comments
 (0)