Skip to content

Commit ffc92d3

Browse files
committed
feat: select config
1 parent e822492 commit ffc92d3

File tree

4 files changed

+154
-145
lines changed

4 files changed

+154
-145
lines changed

components/ResourceConfigs.vue

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script setup lang="ts">
22
import type { ConfigFormModal } from '#components'
3+
import * as mutations from '~/mutations'
4+
import * as queries from '~/queries'
35
46
const apiStore = useAPIStore()
57
const defaults = await apiStore.getDefaults()
@@ -12,37 +14,7 @@ const updateConfigFormModalRef = ref<InstanceType<typeof ConfigFormModal>>()
1214
const { data: configs, execute: reloadConfigs } = useAsyncData(
1315
'configs',
1416
async () => {
15-
const data = await apiStore.apiClient?.query(
16-
graphql(`
17-
query Configs {
18-
configs {
19-
id
20-
name
21-
selected
22-
global {
23-
logLevel
24-
tproxyPort
25-
allowInsecure
26-
checkInterval
27-
checkTolerance
28-
lanInterface
29-
wanInterface
30-
udpCheckDns
31-
tcpCheckUrl
32-
dialMode
33-
tcpCheckHttpMethod
34-
disableWaitingNetwork
35-
autoConfigKernelParameter
36-
sniffingTimeout
37-
tlsImplementation
38-
utlsImitate
39-
tproxyPortProtect
40-
}
41-
}
42-
}
43-
`),
44-
{}
45-
)
17+
const data = await apiStore.apiClient?.query(queries.configs, {})
4618
4719
return data?.data?.configs
4820
}
@@ -54,20 +26,27 @@ const removeConfig = async (id: string | number) => {
5426
isRemovingConfig.value = true
5527
5628
try {
57-
await apiStore.apiClient?.mutation(
58-
graphql(`
59-
mutation RemoveConfig($id: ID!) {
60-
removeConfig(id: $id)
61-
}
62-
`),
63-
{ id }
64-
)
29+
await apiStore.apiClient?.mutation(mutations.removeConfig, { id })
6530
6631
await reloadConfigs()
6732
} finally {
6833
isRemovingConfig.value = false
6934
}
7035
}
36+
37+
const isSelectingConfig = ref(false)
38+
39+
const selectConfig = async (id: string | number) => {
40+
isSelectingConfig.value = true
41+
42+
try {
43+
await apiStore.apiClient?.mutation(mutations.selectConfig, { id })
44+
45+
await reloadConfigs()
46+
} finally {
47+
isSelectingConfig.value = false
48+
}
49+
}
7150
</script>
7251

7352
<template>
@@ -114,11 +93,21 @@ const removeConfig = async (id: string | number) => {
11493

11594
<UButton
11695
:loading="isRemovingConfig"
117-
:disabled="config.id === defaults?.defaultConfigID"
96+
:disabled="
97+
config.id === defaults?.defaultConfigID || config.selected
98+
"
11899
size="xs"
119100
icon="i-heroicons-minus"
120101
@click="removeConfig(config.id)"
121102
/>
103+
104+
<UButton
105+
:loading="isSelectingConfig"
106+
:disabled="config.selected"
107+
size="xs"
108+
icon="i-heroicons-map-pin"
109+
@click="selectConfig(config.id)"
110+
/>
122111
</div>
123112
</template>
124113
</UCard>

components/ResourceGroups.vue

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import type { ConfigFormModal } from '#components'
3+
import * as mutations from '~/mutations'
34
import * as queries from '~/queries'
45
56
const apiStore = useAPIStore()
@@ -25,14 +26,7 @@ const removeGroup = async (id: string | number) => {
2526
isRemovingGroup.value = true
2627
2728
try {
28-
await apiStore.apiClient?.mutation(
29-
graphql(`
30-
mutation RemoveConfig($id: ID!) {
31-
removeConfig(id: $id)
32-
}
33-
`),
34-
{ id }
35-
)
29+
await apiStore.apiClient?.mutation(mutations.removeGroup, { id })
3630
3731
await reloadGroups()
3832
} finally {

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"preview": "nuxt preview"
1313
},
1414
"dependencies": {
15-
"@0no-co/graphqlsp": "^1.6.0",
15+
"@0no-co/graphqlsp": "^1.6.1",
1616
"@commitlint/config-conventional": "^19.1.0",
1717
"@nuxt/eslint-config": "^0.2.0",
18-
"@nuxt/fonts": "^0.3.0",
18+
"@nuxt/fonts": "^0.4.0",
1919
"@nuxt/ui": "^2.14.2",
2020
"@nuxtjs/i18n": "^8.2.0",
2121
"@pinia/nuxt": "^0.5.1",
@@ -33,7 +33,7 @@
3333
"husky": "^9.0.11",
3434
"lint-staged": "^15.2.2",
3535
"lodash-es": "^4.17.21",
36-
"monaco-editor": "^0.44.0",
36+
"monaco-editor": "^0.45.0",
3737
"nuxt": "^3.11.1",
3838
"nuxt-monaco-editor": "^1.2.7",
3939
"nuxt-zod-i18n": "^1.4.0",
@@ -43,7 +43,7 @@
4343
"sort-package-json": "^2.8.0",
4444
"splitpanes": "^3.1.5",
4545
"tailwindcss": "^3.4.1",
46-
"typescript": "^5.4.2",
46+
"typescript": "^5.4.3",
4747
"vue": "^3.4.21",
4848
"vue-router": "^4.3.0",
4949
"zod": "^3.22.4"

0 commit comments

Comments
 (0)