Skip to content

Commit 32f506d

Browse files
committed
using api calling to replace extension define in vue
1 parent 1f11996 commit 32f506d

File tree

5 files changed

+39
-138
lines changed

5 files changed

+39
-138
lines changed

console/atest-ui/src/views/StoreManager.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ const submitForm = async (formEl: FormInstance | undefined) => {
130130
})
131131
}
132132
133-
watch(() => storeForm.kind.name, (name) => {
134-
const ext = SupportedExtension(name)
133+
watch(() => storeForm.kind.name, async (name) => {
134+
const ext = await SupportedExtension(name)
135135
if (ext) {
136136
storeExtLink.value = ext.link
137137
let pro = storeForm.properties.slice()
@@ -211,6 +211,10 @@ function updateKeys() {
211211
}
212212
213213
const storeExtLink = ref('')
214+
const extensions = ref([])
215+
SupportedExtensions().then(e => {
216+
extensions.value = e
217+
})
214218
</script>
215219

216220
<template>
@@ -301,7 +305,7 @@ const storeExtLink = ref('')
301305
class="m-2"
302306
>
303307
<el-option
304-
v-for="item in SupportedExtensions()"
308+
v-for="item in extensions"
305309
:key="item.name"
306310
:label="item.name"
307311
:value="item.name"

console/atest-ui/src/views/net.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,10 +583,31 @@ function PopularHeaders(callback: (d: any) => void, errHandle?: (e: any) => void
583583
.then(callback).catch(emptyOrDefault(errHandle))
584584
}
585585

586-
const GetStoreKinds = (callback: (d: any) => void | null, errHandle?: (e: any) => void | null) => {
586+
interface StoreKindParam {
587+
key: string
588+
defaultValue: string
589+
description: string
590+
}
591+
592+
interface StoreKind {
593+
name: string
594+
link: string
595+
params: StoreKindParam[]
596+
}
597+
598+
interface StoreKindsResponse {
599+
data: StoreKind[]
600+
}
601+
602+
const GetStoreKinds = (callback?: (d: StoreKindsResponse) => void | null, errHandle?: (e: any) => void | null) => {
603+
if (callback) {
604+
return fetch(`/api/v1/stores/kinds`, {})
605+
.then(DefaultResponseProcess)
606+
.then(callback).catch(emptyOrDefault(errHandle))
607+
}
587608
return fetch(`/api/v1/stores/kinds`, {})
588609
.then(DefaultResponseProcess)
589-
.then(callback).catch(emptyOrDefault(errHandle))
610+
.catch(emptyOrDefault(errHandle))
590611
}
591612

592613
function CreateOrUpdateStore(payload: any, create: boolean,

console/atest-ui/src/views/store.ts

Lines changed: 4 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -48,137 +48,12 @@ export const Driver = {
4848
MySQL, Postgres, SQLite, TDengine, Cassandra
4949
}
5050

51-
const ExtensionKindGit = "atest-store-git"
52-
const ExtensionKindS3 = "atest-store-s3"
53-
const ExtensionKindORM = "atest-store-orm"
54-
const ExtensionKindIotDB = "atest-store-iotdb"
55-
const ExtensionKindCassandra = "atest-store-cassandra"
56-
const ExtensionKindEtcd = "atest-store-etcd"
57-
const ExtensionKindRedis = "atest-store-redis"
58-
const ExtensionKindMongoDB = "atest-store-mongodb"
59-
const ExtensionKindElasticsearch = "atest-store-elasticsearch"
60-
const ExtensionKindOpengeMini = "atest-store-opengemini"
61-
62-
export const ExtensionKind = {
63-
ExtensionKindGit,
64-
ExtensionKindS3,
65-
ExtensionKindORM,
66-
ExtensionKindIotDB,
67-
ExtensionKindCassandra,
68-
ExtensionKindEtcd,
69-
ExtensionKindRedis,
70-
ExtensionKindMongoDB,
71-
ExtensionKindElasticsearch,
72-
ExtensionKindOpengeMini
73-
}
74-
75-
const storeExtensions = [
76-
{
77-
name: ExtensionKindGit,
78-
params: [{
79-
key: 'insecure'
80-
}, {
81-
key: 'timeout'
82-
}, {
83-
key: 'targetpath'
84-
}, {
85-
key: 'branch'
86-
}, {
87-
key: 'email',
88-
description: 'See also: git config --local user.email [email protected]'
89-
}, {
90-
key: 'name',
91-
description: 'See also: git config --local user.name xxx'
92-
}],
93-
link: 'https://github.com/LinuxSuRen/atest-ext-store-git'
94-
},
95-
{
96-
name: ExtensionKindS3,
97-
params: [{
98-
key: 'accesskeyid'
99-
}, {
100-
key: 'secretaccesskey'
101-
}, {
102-
key: 'sessiontoken'
103-
}, {
104-
key: 'region'
105-
}, {
106-
key: 'disablessl'
107-
}, {
108-
key: 'forcepathstyle'
109-
}, {
110-
key: 'bucket'
111-
}],
112-
link: 'https://github.com/LinuxSuRen/atest-ext-store-s3'
113-
},
114-
{
115-
name: ExtensionKindORM,
116-
params: [{
117-
key: 'driver',
118-
defaultValue: 'mysql',
119-
enum: [MySQL, Postgres, SQLite, TDengine],
120-
description: 'Supported: mysql, postgres, sqlite, tdengine'
121-
}, {
122-
key: 'database',
123-
defaultValue: 'atest'
124-
}, {
125-
key: 'historyLimit',
126-
defaultValue: '',
127-
// type: 'number',
128-
description: 'Set the limit of the history record count'
129-
}],
130-
link: 'https://github.com/LinuxSuRen/atest-ext-store-orm'
131-
},
132-
{
133-
name: ExtensionKindIotDB,
134-
params: [],
135-
link: 'https://github.com/LinuxSuRen/atest-ext-store-iotdb'
136-
},
137-
{
138-
name: ExtensionKindCassandra,
139-
params: [{
140-
key: 'keyspace',
141-
defaultValue: ''
142-
}],
143-
link: 'https://github.com/LinuxSuRen/atest-ext-store-cassandra'
144-
},
145-
{
146-
name: ExtensionKindEtcd,
147-
params: [],
148-
link: 'https://github.com/LinuxSuRen/atest-ext-store-etcd'
149-
},
150-
{
151-
name: ExtensionKindRedis,
152-
params: [],
153-
link: 'https://github.com/LinuxSuRen/atest-ext-store-redis'
154-
},
155-
{
156-
name: ExtensionKindMongoDB,
157-
params: [{
158-
key: 'collection'
159-
}, {
160-
key: 'database',
161-
defaultValue: 'atest'
162-
}],
163-
link: 'https://github.com/LinuxSuRen/atest-ext-store-mongodb'
164-
},
165-
{
166-
name: ExtensionKindElasticsearch,
167-
params: [],
168-
link: 'https://github.com/LinuxSuRen/atest-ext-store-elasticsearch'
169-
},
170-
{
171-
name: ExtensionKindOpengeMini,
172-
params: [],
173-
link: 'https://github.com/LinuxSuRen/atest-ext-store-opengemini'
174-
}
175-
] as Store[]
176-
17751
export async function SupportedExtensions() {
178-
API.GetStoreKinds()
179-
return storeExtensions
52+
const kinds = await API.GetStoreKinds()
53+
return kinds.data
18054
}
18155

182-
export function SupportedExtension(name: string) {
56+
export async function SupportedExtension(name: string) {
57+
const storeExtensions = await SupportedExtensions()
18358
return storeExtensions.find(e => e.name === name)
18459
}

pkg/apispec/remote_swagger.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import (
2121
"compress/gzip"
2222
"encoding/json"
2323
"fmt"
24-
"github.com/linuxsuren/api-testing/pkg/downloader"
25-
"github.com/linuxsuren/api-testing/pkg/util/home"
2624
"io"
2725
"net/http"
2826
"os"
2927
"path/filepath"
3028
"strings"
29+
30+
"github.com/linuxsuren/api-testing/pkg/downloader"
31+
"github.com/linuxsuren/api-testing/pkg/util/home"
3132
)
3233

3334
func DownloadSwaggerData(output string, dw downloader.PlatformAwareOCIDownloader) (err error) {
@@ -105,7 +106,7 @@ func decompressData(dataFile string) (err error) {
105106
break // 退出循环
106107
}
107108
if err != nil {
108-
panic(err)
109+
return
109110
}
110111

111112
// Ensure the file path does not contain directory traversal sequences

pkg/server/remote_server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ func (s *server) GetStoreKinds(context.Context, *Empty) (kinds *StoreKinds, err
11691169
for _, store := range stores {
11701170
kinds.Data = append(kinds.Data, &StoreKind{
11711171
Name: store.Name,
1172-
Enabled: store.Enabled,
1172+
Enabled: true,
11731173
Url: store.URL,
11741174
Link: store.Link,
11751175
Params: convertStoreKindParams(store.Params),

0 commit comments

Comments
 (0)