Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refactor atest ui #466

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6e78b2e
refactor: refactor atest frontend.
yuluo-yx May 4, 2024
fded85b
featL optimize
yuluo-yx May 7, 2024
6ce4a38
feat: optimize test pages
yuluo-yx May 8, 2024
f45dc74
Merge https://github.com/linuxsuren/api-testing into 0504-yuluo/front…
yuluo-yx May 10, 2024
f3b3a52
feat: optimize import order
yuluo-yx May 10, 2024
e3202f9
ui: optimize headercomponent style
yuluo-yx May 11, 2024
5fb6cda
optimize: optimize test pages
yuluo-yx May 21, 2024
1e41be2
optimize: optimize test pages
yuluo-yx May 29, 2024
80cf32e
optimize: optimize other pages
yuluo-yx May 30, 2024
2eaf313
optimize: optimize test pages
SamYSF May 30, 2024
62e1c83
Merge remote-tracking branch 'origin/master' into front-api-re
SamYSF May 31, 2024
6053be6
feat: add docs stie for api-testing
yuluo-yx Jun 1, 2024
9cd76e8
Merge remote-tracking branch 'upstream/master' into 0504-yuluo/front-…
LinuxSuRen Jun 1, 2024
bc3cbda
Merge pull request #4 from LinuxSuRen/merge-yuluo-front
yuluo-yx Jun 2, 2024
b467c86
fix: fix css style
yuluo-yx Jun 2, 2024
9bbca84
Merge branch '0601-yuluo/add-docs-site' of https://github.com/yuluo-y…
yuluo-yx Jun 2, 2024
bdf4c47
fix: fix error links
yuluo-yx Jun 2, 2024
14f574e
fix: fix error links
yuluo-yx Jun 2, 2024
3dfcfac
restore
yuluo-yx Jun 2, 2024
8891ea1
fix: fix ci
yuluo-yx Jun 2, 2024
ae9010d
fix
yuluo-yx Jun 2, 2024
6032a9d
fix: update style
yuluo-yx Jun 2, 2024
fd08a72
fix: fix side language switch
SamYSF Jun 2, 2024
54e571c
fix: fix test pages bugs
yuluo-yx Jun 2, 2024
8a79494
Merge branch '0504-yuluo/front-api-re' of https://github.com/yuluo-yx…
yuluo-yx Jun 2, 2024
de27839
fix: fix test pages request bugs
yuluo-yx Jun 2, 2024
f6b0749
fix: fix test pages bugs
yuluo-yx Jun 2, 2024
99ed4fe
fix
yuluo-yx Jun 2, 2024
f49cc9f
fix: code generator
yuluo-yx Jun 2, 2024
e69491d
fix
yuluo-yx Jun 2, 2024
f405096
fix: fix test pages bug
yuluo-yx Jun 3, 2024
601849a
fix
yuluo-yx Jun 3, 2024
e2cde85
fix
yuluo-yx Jun 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/data/index.css

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions cmd/data/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Testing</title>
<script type="module" crossorigin src="/assets/main-de922bcb.js"></script>
<link rel="stylesheet" href="/assets/index-057fa3a8.css">
</head>
<body>
<div id="app"></div>

</body>
</html>
176 changes: 176 additions & 0 deletions cmd/data/index.js

Large diffs are not rendered by default.

147 changes: 3 additions & 144 deletions console/atest-ui/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,148 +1,7 @@
<script setup lang="ts">
import {
Document,
Menu as IconMenu,
Location,
Share,
ArrowDown
} from '@element-plus/icons-vue'
import { ref, watch } from 'vue'
import { API } from './views/net'
import { Cache } from './views/cache'
import TestingPanel from './views/TestingPanel.vue'
import MockManager from './views/MockManager.vue'
import StoreManager from './views/StoreManager.vue'
import SecretManager from './views/SecretManager.vue'
import WelcomePage from './views/WelcomePage.vue'
import { useI18n } from 'vue-i18n'

const { t, locale: i18nLocale } = useI18n()

import setAsDarkTheme from './theme'

const asDarkMode = ref(Cache.GetPreference().darkTheme)
setAsDarkTheme(asDarkMode.value)
watch(asDarkMode, Cache.WatchDarkTheme)
watch(asDarkMode, () => {
setAsDarkTheme(asDarkMode.value)
})

const appVersion = ref('')
const appVersionLink = ref('https://github.com/LinuxSuRen/api-testing')
API.GetVersion((d) => {
appVersion.value = d.message
const version = d.message.match('^v\\d*.\\d*.\\d*')
const dirtyVersion = d.message.match('^v\\d*.\\d*.\\d*-\\d*-g')

if (!version && !dirtyVersion) {
return
}

if (dirtyVersion && dirtyVersion.length > 0) {
appVersionLink.value = appVersionLink.value + '/commit/' + d.message.replace(dirtyVersion[0], '')
} else if (version && version.length > 0) {
appVersionLink.value = appVersionLink.value + '/releases/tag/' + version[0]
}
})

const sideWidth = ref("width: 200px; display: flex;flex-direction: column;")
const isCollapse = ref(false)
watch(isCollapse, (e) => {
if (e) {
sideWidth.value = "width: 80px; display: flex;flex-direction: column;"
} else {
sideWidth.value = "width: 200px; display: flex;flex-direction: column;"
}
})
const lastActiveMenu = window.localStorage.getItem('activeMenu')
const activeMenu = ref(lastActiveMenu === '' ? 'welcome' : lastActiveMenu)
const panelName = ref(activeMenu)
const handleSelect = (key: string) => {
panelName.value = key
window.localStorage.setItem('activeMenu', key)
}

const locale = ref(Cache.GetPreference().language)
i18nLocale.value = locale.value

watch(locale, (value) =>{
Cache.WatchLocale(value)
i18nLocale.value = locale.value
})

const handleChangeLan = (command: string) => {
switch (command) {
case "chinese":
locale.value = "zh-CN"
break;
case "english":
locale.value = "en-US"
break;
}
};

</script>

<template>
<el-container style="height: 100%">
<el-aside :style="sideWidth">
<el-radio-group v-model="isCollapse">
<el-radio-button :label="false">+</el-radio-button>
<el-radio-button :label="true">-</el-radio-button>
</el-radio-group>
<el-menu
style="flex-grow: 1;"
:default-active="activeMenu"
:collapse="isCollapse"
@select="handleSelect"
>
<el-menu-item index="welcome">
<el-icon><share /></el-icon>
<template #title>{{ t('title.welcome') }}</template>
</el-menu-item>
<el-menu-item index="testing" test-id="testing-menu">
<el-icon><icon-menu /></el-icon>
<template #title>{{ t('title.testing' )}}</template>
</el-menu-item>
<el-menu-item index="mock" test-id="mock-menu">
<el-icon><icon-menu /></el-icon>
<template #title>{{ t('title.mock' )}}</template>
</el-menu-item>
<el-menu-item index="secret">
<el-icon><document /></el-icon>
<template #title>{{ t('title.secrets') }}</template>
</el-menu-item>
<el-menu-item index="store">
<el-icon><location /></el-icon>
<template #title>{{ t('title.stores') }}</template>
</el-menu-item>
</el-menu>
</el-aside>

<slot name="app"></slot>

<el-main style="padding-top: 5px; padding-bottom: 5px;">
<div style="position: absolute; top: 10px; right: 20px;">
<el-col style="display: flex; align-items: center;">
<el-tag style="font-size: 18px;">{{ t('language') }}</el-tag>
<el-dropdown trigger="click" @command="(command: string) => handleChangeLan(command)">
<el-icon><arrow-down /></el-icon>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="chinese">中文</el-dropdown-item>
<el-dropdown-item command="english">English</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</el-col>
</div>
<TestingPanel v-if="panelName === 'testing'" />
<MockManager v-else-if="panelName === 'mock'" />
<StoreManager v-else-if="panelName === 'store'" />
<SecretManager v-else-if="panelName === 'secret'" />
<WelcomePage v-else />
</el-main>
<router-view/>

<div style="position: absolute; bottom: 0px; right: 10px;">
<a :href=appVersionLink target="_blank" rel="noopener">{{appVersion}}</a>
</div>
</el-container>
</template>
33 changes: 33 additions & 0 deletions console/atest-ui/src/api/app/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2024 API Testing Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { post } from '../axios'
import { getToken } from '../../utils/auth/token'
import { Cache } from '../../utils/cache'

export const GetVersion = () => post('/server.Runner/GetVersion', null, null)

export const PopularHeaders = () =>
post('/server.Runner/PopularHeaders', null, {
'X-Store-Name': Cache.GetCurrentStore().name,
'X-Auth': getToken()
})

export const GetSuggestedAPIs = (params: any) =>
post('/server.Runner/GetSuggestedAPIs', params, {
'X-Store-Name': Cache.GetCurrentStore().name,
'X-Auth': getToken()
})
81 changes: 81 additions & 0 deletions console/atest-ui/src/api/axios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2024 API Testing Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import service from './manager'

export const get = (url: string, params: any, header: any) => {

return new Promise((resolve, reject) => {
service.get(url, {
params: params,
headers: header,
}).then(res => {
resolve(res.data);
}).catch(err => {
reject(err.data);
});
});
}

export const del = (url: string, params: any, header: any) => {

return new Promise((resolve, reject) => {
service.delete(
url,
{
headers: header,
}
).then(res => {
resolve(res.data);
}).catch(err => {
reject(err.data);
});
});
}

export const put = (url: string, data: any, header: any) => {

return new Promise((resolve, reject) => {
service.put(
url,
data,
{
headers: header,
}
).then(res => {
resolve(res.data);
}).catch(err => {
reject(err.data);
});
});
}

export const post = (url: string, params: any, header: any) => {

return new Promise((resolve, reject) => {
service.post(
url,
params,
{
headers: header,
}
).then(res => {
resolve(res.data);
}).catch(err => {
reject(err.data);
});
});
}
43 changes: 43 additions & 0 deletions console/atest-ui/src/api/cert/cert.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
Copyright 2024 API Testing Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { post } from '../axios'
import { getToken } from '../../utils/auth/token'

export const GetSecrets = () =>
post('/server.Runner/GetSecrets', null, {
'X-Auth': getToken()
})

export const FunctionsQuery = (params: string) =>
post('/server.Runner/FunctionsQuery', params, {
'X-Auth': getToken()
})

export const DeleteSecret = (name: any) =>
post('/server.Runner/DeleteSecret', name, {
'X-Auth': getToken()
})

export const CreateSecret = (params: any) =>
post('/server.Runner/CreateSecret', params, {
'X-Auth': getToken()
})

export const UpdateSecret = (params: any) =>
post('/server.Runner/UpdateSecret', params, {
'X-Auth': getToken()
})
33 changes: 33 additions & 0 deletions console/atest-ui/src/api/code/code.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2024 API Testing Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { post } from '../axios'
import type { GenerateRequest } from '../common'
import { getToken } from '../../utils/auth/token'
import { Cache } from '../../utils/cache'

const stroeName = Cache.GetCurrentStore().name

export const GenerateCode = (params: GenerateRequest) =>
post('/server.Runner/GenerateCode', params, {
'X-Store-Name': stroeName,
'X-Auth': getToken()
})

export const ListCodeGenerator = () =>
post('/server.Runner/ListCodeGenerator', null, {
'X-Auth': getToken()
})
Loading
Loading