Skip to content

Commit 1036325

Browse files
authored
ui: reflect the network request related codes (#274)
Co-authored-by: rick <[email protected]>
1 parent 35c685c commit 1036325

19 files changed

+704
-347
lines changed

.github/workflows/release.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
env:
1111
REGISTRY: ghcr.io
1212
REGISTRY_DOCKERHUB: docker.io
13+
REGISTRY_ALIYUN: registry.aliyuncs.com
1314
IMAGE_NAME: ${{ github.repository }}
1415

1516
jobs:
@@ -179,3 +180,41 @@ jobs:
179180
unset HELM_VERSION
180181
fi
181182
make helm-package helm-push
183+
184+
image-aliyuncs:
185+
runs-on: ubuntu-20.04
186+
steps:
187+
- name: Checkout
188+
uses: actions/checkout@v4
189+
with:
190+
fetch-tags: true
191+
fetch-depth: 0
192+
- name: Set output
193+
id: vars
194+
run: echo "tag=$(git describe --tags)" >> $GITHUB_OUTPUT
195+
- name: Setup Docker buildx
196+
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
197+
- name: Log into registry ${{ env.REGISTRY_ALIYUN }}
198+
if: github.event_name != 'pull_request'
199+
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
200+
with:
201+
registry: ${{ env.REGISTRY_ALIYUN }}
202+
username: linuxsuren
203+
password: ${{ secrets.REGISTRY_ALIYUN_PUBLISH_SECRETS }}
204+
- name: Extract Docker metadata
205+
id: meta
206+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
207+
with:
208+
images: ${{ env.REGISTRY_ALIYUN }}/${{ env.IMAGE_NAME }}
209+
- name: Build and push Docker image
210+
id: build-and-push
211+
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
212+
with:
213+
context: .
214+
push: ${{ github.event_name != 'pull_request' }}
215+
tags: ${{ steps.meta.outputs.tags }}
216+
labels: ${{ steps.meta.outputs.labels }}
217+
platforms: linux/amd64,linux/arm64
218+
cache-from: type=gha
219+
cache-to: type=gha,mode=max
220+
build-args: VERSION=${{ steps.vars.outputs.tag }}

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See https://www.gitpod.io/docs/configure/workspaces
22
tasks:
3-
- init: make init-env
3+
- init: make init-env install-precheck
44
before: IMG_TOOL=docker GOPROXY= make build-ext copy-ext build-image
55
command: cd console/atest-ui/ && npm i
66

console/atest-ui/src/App.vue

+23-49
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import { ElTree, ElMessage } from 'element-plus'
1010
import type { FormInstance, FormRules } from 'element-plus'
1111
import { Edit, Share } from '@element-plus/icons-vue'
1212
import type { Suite } from './types'
13+
import { API } from './views/net'
1314
import { Cache } from './views/cache'
14-
import { DefaultResponseProcess } from './views/net'
1515
import { useI18n } from 'vue-i18n'
1616
import ClientMonitor from 'skywalking-client-js'
1717
import { name, version } from '../package'
@@ -48,18 +48,7 @@ const handleNodeClick = (data: Tree) => {
4848
testSuiteKind.value = data.kind
4949
Cache.SetCurrentStore(data.store)
5050
51-
const requestOptions = {
52-
method: 'POST',
53-
headers: {
54-
'X-Store-Name': data.store
55-
},
56-
body: JSON.stringify({
57-
name: data.label
58-
})
59-
}
60-
fetch('/server.Runner/ListTestCase', requestOptions)
61-
.then((response) => response.json())
62-
.then((d) => {
51+
API.ListTestCase(data.label, data.store, (d) => {
6352
if (d.items && d.items.length > 0) {
6453
data.children = []
6554
d.items.forEach((item: any) => {
@@ -73,7 +62,7 @@ const handleNodeClick = (data: Tree) => {
7362
} as Tree)
7463
})
7564
}
76-
})
65+
})
7766
} else {
7867
Cache.SetCurrentStore(data.store)
7968
Cache.SetLastTestCaseLocation(data.parentID, data.id)
@@ -133,13 +122,16 @@ interface Store {
133122
}
134123
135124
const stores = ref([] as Store[])
125+
const storesLoading = ref(false)
136126
function loadStores() {
127+
storesLoading.value = true
137128
const requestOptions = {
138129
method: 'POST',
139130
}
140131
fetch('/server.Runner/GetStores', requestOptions)
141132
.then((response) => response.json())
142133
.then(async (d) => {
134+
storesLoading.value = false
143135
stores.value = d.data
144136
data.value = [] as Tree[]
145137
Cache.SetStores(d.data)
@@ -227,21 +219,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
227219
if (valid) {
228220
suiteCreatingLoading.value = true
229221
230-
const requestOptions = {
231-
method: 'POST',
232-
headers: {
233-
'X-Store-Name': testSuiteForm.store
234-
},
235-
body: JSON.stringify({
236-
name: testSuiteForm.name,
237-
api: testSuiteForm.api,
238-
kind: testSuiteForm.kind
239-
})
240-
}
241-
242-
fetch('/server.Runner/CreateTestSuite', requestOptions)
243-
.then(DefaultResponseProcess())
244-
.then((e) => {
222+
API.CreateTestSuite(testSuiteForm, (e) => {
245223
suiteCreatingLoading.value = false
246224
if (e.error !== "") {
247225
ElMessage.error('Oops, ' + e.error)
@@ -272,23 +250,11 @@ const importSuiteFormSubmit = async (formEl: FormInstance | undefined) => {
272250
if (valid) {
273251
suiteCreatingLoading.value = true
274252
275-
const requestOptions = {
276-
method: 'POST',
277-
headers: {
278-
'X-Store-Name': importSuiteForm.store
279-
},
280-
body: JSON.stringify({
281-
url: importSuiteForm.url
282-
})
283-
}
284-
285-
fetch('/server.Runner/ImportTestSuite', requestOptions)
286-
.then((response) => response.json())
287-
.then(() => {
288-
loadStores()
289-
importDialogVisible.value = false
290-
formEl.resetFields()
291-
})
253+
API.ImportTestSuite(importSuiteForm, () => {
254+
loadStores()
255+
importDialogVisible.value = false
256+
formEl.resetFields()
257+
})
292258
}
293259
})
294260
}
@@ -325,6 +291,11 @@ const suiteKinds = [{
325291
}, {
326292
"name": "tRPC",
327293
}]
294+
295+
const appVersion = ref('')
296+
API.GetVersion((d) => {
297+
appVersion.value = d.message
298+
})
328299
</script>
329300

330301
<template>
@@ -340,7 +311,7 @@ const suiteKinds = [{
340311

341312
<el-main>
342313
<el-container style="height: 100%">
343-
<el-aside width="200px">
314+
<el-aside>
344315
<el-button type="primary" @click="openTestSuiteCreateDialog"
345316
data-intro="Click here to create a new test suite"
346317
test-id="open-new-suite-dialog" :icon="Edit">{{ t('button.new') }}</el-button>
@@ -350,6 +321,7 @@ const suiteKinds = [{
350321
<el-input v-model="filterText" placeholder="Filter keyword" test-id="search" />
351322

352323
<el-tree
324+
v-loading="storesLoading"
353325
:data=data
354326
highlight-current
355327
:check-on-click-node="true"
@@ -361,8 +333,6 @@ const suiteKinds = [{
361333
@node-click="handleNodeClick"
362334
data-intro="This is the test suite tree. You can click the test suite to edit it."
363335
/>
364-
365-
<TemplateFunctions/>
366336
</el-aside>
367337

368338
<el-main>
@@ -392,6 +362,10 @@ const suiteKinds = [{
392362
</el-main>
393363
</el-container>
394364
</el-main>
365+
<div style="position: absolute; bottom: 0px; right: 10px;">
366+
<a href="https://github.com/LinuxSuRen/api-testing" target="_blank" rel="noopener">{{appVersion}}</a>
367+
</div>
368+
<TemplateFunctions/>
395369
</el-container>
396370
</div>
397371

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

+26-57
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { reactive, ref } from 'vue'
44
import { Edit, Delete } from '@element-plus/icons-vue'
55
import type { FormInstance, FormRules } from 'element-plus'
66
import type { Pair } from './types'
7+
import { API } from './net'
78
import { SupportedExtensions } from './store'
89
import { useI18n } from 'vue-i18n'
910
@@ -50,39 +51,24 @@ interface Store {
5051
}
5152
5253
function loadStores() {
53-
const requestOptions = {
54-
method: 'POST',
55-
}
56-
fetch('/server.Runner/GetStores', requestOptions)
57-
.then((response) => response.json())
58-
.then((e) => {
59-
stores.value = e.data
60-
})
61-
.catch((e) => {
62-
ElMessage.error('Oops, ' + e)
63-
})
54+
API.GetStores((e) => {
55+
stores.value = e.data
56+
}, (e) => {
57+
ElMessage.error('Oops, ' + e)
58+
})
6459
}
6560
loadStores()
6661
6762
function deleteStore(name: string) {
68-
const requestOptions = {
69-
method: 'POST',
70-
body: JSON.stringify({
71-
name: name
72-
})
73-
}
74-
fetch('/server.Runner/DeleteStore', requestOptions)
75-
.then((response) => response.json())
76-
.then((e) => {
77-
ElMessage({
78-
message: 'Deleted.',
79-
type: 'success'
80-
})
81-
loadStores()
82-
})
83-
.catch((e) => {
84-
ElMessage.error('Oops, ' + e)
63+
API.DeleteStore(name, (e) => {
64+
ElMessage({
65+
message: 'Deleted.',
66+
type: 'success'
8567
})
68+
loadStores()
69+
}, (e) => {
70+
ElMessage.error('Oops, ' + e)
71+
})
8672
}
8773
8874
function editStore(name: string) {
@@ -161,36 +147,19 @@ const submitForm = async (formEl: FormInstance | undefined) => {
161147
162148
function storeVerify(formEl: FormInstance | undefined) {
163149
if (!formEl) return
164-
165-
const requestOptions = {
166-
method: 'POST',
167-
body: JSON.stringify({
168-
name: storeForm.name
169-
})
170-
}
171150
172-
let api = '/server.Runner/VerifyStore'
173-
fetch(api, requestOptions)
174-
.then((response) => {
175-
if (!response.ok) {
176-
throw new Error(response.statusText)
177-
} else {
178-
return response.json()
179-
}
180-
})
181-
.then((e) => {
182-
if (e.ready) {
183-
ElMessage({
184-
message: 'Verified!',
185-
type: 'success'
186-
})
187-
} else {
188-
ElMessage.error(e.message)
189-
}
190-
})
191-
.catch((e) => {
192-
ElMessage.error('Oops, ' + e)
193-
})
151+
API.VerifyStore(setStoreForm.name, (e) => {
152+
if (e.ready) {
153+
ElMessage({
154+
message: 'Verified!',
155+
type: 'success'
156+
})
157+
} else {
158+
ElMessage.error(e.message)
159+
}
160+
}, (e) => {
161+
ElMessage.error('Oops, ' + e)
162+
})
194163
}
195164
196165
function updateKeys() {

0 commit comments

Comments
 (0)