-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add data query service --------- Co-authored-by: rick <[email protected]>
- Loading branch information
1 parent
4a38bd2
commit cc5a463
Showing
29 changed files
with
2,657 additions
and
1,906 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
* text eol=lf | ||
*.go text eol=lf | ||
*.vue text eol=lf | ||
*.js text eol=lf | ||
*.css text eol=lf | ||
*.html text eol=lf | ||
*.md text eol=lf | ||
*.yaml text eol=lf | ||
*.json text eol=lf | ||
*.yml text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<script setup lang="ts"> | ||
import { ref, watch } from 'vue' | ||
import { API } from './net' | ||
import { ElMessage } from 'element-plus' | ||
const stores = ref([]) | ||
const kind = ref('') | ||
const store = ref('') | ||
const sqlQuery = ref('') | ||
const queryResult = ref([]) | ||
const columns = ref([]) | ||
const queryTip = ref('') | ||
watch(store, (s) => { | ||
stores.value.forEach((e: Store) => { | ||
if (e.name === s) { | ||
kind.value = e.kind.name | ||
return | ||
} | ||
}) | ||
}) | ||
watch(kind, (k) => { | ||
switch (k) { | ||
case 'atest-store-orm': | ||
sqlQuery.value = 'show tables' | ||
queryTip.value = 'Enter SQL query' | ||
break; | ||
case 'atest-store-etcd': | ||
sqlQuery.value = '' | ||
queryTip.value = 'Enter key' | ||
break; | ||
} | ||
}) | ||
API.GetStores((data) => { | ||
stores.value = data.data | ||
}, (e) => { | ||
ElMessage({ | ||
showClose: true, | ||
message: e.message, | ||
type: 'error' | ||
}); | ||
}) | ||
const ormDataHandler = (data) => { | ||
const result = [] | ||
const cols = new Set() | ||
data.items.forEach(e => { | ||
const obj = {} | ||
e.data.forEach(item => { | ||
obj[item.key] = item.value | ||
cols.add(item.key) | ||
}) | ||
result.push(obj) | ||
}) | ||
queryResult.value = result | ||
columns.value = Array.from(cols).sort((a, b) => { | ||
if (a === 'id') return -1; | ||
if (b === 'id') return 1; | ||
return a.localeCompare(b); | ||
}) | ||
} | ||
const keyValueDataHandler = (data) => { | ||
queryResult.value = [] | ||
data.data.forEach(e => { | ||
const obj = {} | ||
obj['key'] = e.key | ||
obj['value'] = e.value | ||
queryResult.value.push(obj) | ||
columns.value = ['key', 'value'] | ||
}) | ||
} | ||
const executeQuery = async () => { | ||
API.DataQuery(store.value, kind.value, sqlQuery.value, (data) => { | ||
switch (kind.value) { | ||
case 'atest-store-orm': | ||
ormDataHandler(data) | ||
break; | ||
case 'atest-store-etcd': | ||
keyValueDataHandler(data) | ||
break; | ||
default: | ||
ElMessage({ | ||
showClose: true, | ||
message: 'Unsupported store kind', | ||
type: 'error' | ||
}); | ||
} | ||
}, (e) => { | ||
ElMessage({ | ||
showClose: true, | ||
message: e.message, | ||
type: 'error' | ||
}); | ||
}) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<el-form @submit.prevent="executeQuery"> | ||
<el-row :gutter="10"> | ||
<el-col :span="2"> | ||
<el-form-item> | ||
<el-select v-model="store" placeholder="Select store"> | ||
<el-option v-for="item in stores" :key="item.name" :label="item.name" | ||
:value="item.name" :disabled="!item.ready" :kind="item.kind.name"></el-option> | ||
</el-select> | ||
</el-form-item> | ||
</el-col> | ||
<el-col :span="18"> | ||
<el-form-item> | ||
<el-input v-model="sqlQuery" :placeholder="queryTip" @keyup.enter="executeQuery"></el-input> | ||
</el-form-item> | ||
</el-col> | ||
<el-col :span="2"> | ||
<el-form-item> | ||
<el-button type="primary" @click="executeQuery">Execute</el-button> | ||
</el-form-item> | ||
</el-col> | ||
</el-row> | ||
</el-form> | ||
<el-table :data="queryResult"> | ||
<el-table-column v-for="col in columns" :key="col" :prop="col" :label="col"></el-table-column> | ||
</el-table> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
Ports in extensions: | ||
|
||
| Type | Name | Port | | ||
|------|------|------| | ||
| Store | [orm](https://github.com/LinuxSuRen/atest-ext-store-orm) | 4071 | | ||
| Store | [s3](https://github.com/LinuxSuRen/atest-ext-store-s3) | 4072 | | ||
| Store | [etcd](https://github.com/LinuxSuRen/atest-ext-store-etcd) | 4073 | | ||
| Store | [git](https://github.com/LinuxSuRen/atest-ext-store-git) | 4074 | | ||
| Store | [mongodb](https://github.com/LinuxSuRen/atest-ext-store-mongodb) | 4075 | | ||
| Monitor | [docker-monitor](https://github.com/LinuxSuRen/atest-ext-monitor-docker) | | | ||
| Agent | [collector](https://github.com/LinuxSuRen/atest-ext-collector) | | | ||
| Secret | [Vault](https://github.com/LinuxSuRen/api-testing-vault-extension) | | | ||
|
||
## Contribute a new extension | ||
|
||
* First, create a repository. And please keep the same naming convertion. | ||
* Second, implement the `Loader` gRPC service which defined by [this proto](../pkg/testing/remote/loader.proto). | ||
* Finally, add the extension's name into function [SupportedExtensions](../console/atest-ui/src/views/store.ts). | ||
|
||
## Naming conventions | ||
Please follow the following conventions if you want to add a new store extension: | ||
|
||
`store-xxx` | ||
|
||
`xxx` should be a type of a backend storage. | ||
|
||
## Test | ||
|
||
First, build and copy the binary file into the system path. You can run the following | ||
command in the root directory of this project: | ||
|
||
```shell | ||
make build-ext-etcd copy-ext | ||
``` | ||
Ports in extensions: | ||
|
||
| Type | Name | Port | | ||
|------|------|------| | ||
| Store | [orm](https://github.com/LinuxSuRen/atest-ext-store-orm) | 4071 | | ||
| Store | [s3](https://github.com/LinuxSuRen/atest-ext-store-s3) | 4072 | | ||
| Store | [etcd](https://github.com/LinuxSuRen/atest-ext-store-etcd) | 4073 | | ||
| Store | [git](https://github.com/LinuxSuRen/atest-ext-store-git) | 4074 | | ||
| Store | [mongodb](https://github.com/LinuxSuRen/atest-ext-store-mongodb) | 4075 | | ||
| Monitor | [docker-monitor](https://github.com/LinuxSuRen/atest-ext-monitor-docker) | | | ||
| Agent | [collector](https://github.com/LinuxSuRen/atest-ext-collector) | | | ||
| Secret | [Vault](https://github.com/LinuxSuRen/api-testing-vault-extension) | | | ||
|
||
## Contribute a new extension | ||
|
||
* First, create a repository. And please keep the same naming convertion. | ||
* Second, implement the `Loader` gRPC service which defined by [this proto](../pkg/testing/remote/loader.proto). | ||
* Finally, add the extension's name into function [SupportedExtensions](../console/atest-ui/src/views/store.ts). | ||
|
||
## Naming conventions | ||
Please follow the following conventions if you want to add a new store extension: | ||
|
||
`store-xxx` | ||
|
||
`xxx` should be a type of a backend storage. | ||
|
||
## Test | ||
|
||
First, build and copy the binary file into the system path. You can run the following | ||
command in the root directory of this project: | ||
|
||
```shell | ||
make build-ext-etcd copy-ext | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.