You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2023/02/19 23:25:49 UTC
[skywalking-banyandb] branch main updated: Adding support for editing streams (#252)
This is an automated email from the ASF dual-hosted git repository.
hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
The following commit(s) were added to refs/heads/main by this push:
new 6aab0606 Adding support for editing streams (#252)
6aab0606 is described below
commit 6aab06062a59e566071d97c926c86c37c856e987
Author: Wu ChuSheng <a1...@gmail.com>
AuthorDate: Mon Feb 20 07:25:44 2023 +0800
Adding support for editing streams (#252)
* Adding support for editing streams
---
ui/src/api/index.js | 8 ++++
ui/src/components2/StreamEditor/index.vue | 53 +++++++++++++++++++++++++--
ui/src/components2/StreamEditor/tagEditor.vue | 6 ++-
3 files changed, 63 insertions(+), 4 deletions(-)
diff --git a/ui/src/api/index.js b/ui/src/api/index.js
index 896c0abd..7da9f960 100644
--- a/ui/src/api/index.js
+++ b/ui/src/api/index.js
@@ -87,4 +87,12 @@ export function createResources(type, data) {
method: 'post',
data: data
})
+}
+
+export function editResources(type, group, name, data) {
+ return request({
+ url: `/api/v1/${type}/schema/${group}/${name}`,
+ method: 'put',
+ data: data
+ })
}
\ No newline at end of file
diff --git a/ui/src/components2/StreamEditor/index.vue b/ui/src/components2/StreamEditor/index.vue
index 5b15cfd9..08dc1199 100644
--- a/ui/src/components2/StreamEditor/index.vue
+++ b/ui/src/components2/StreamEditor/index.vue
@@ -24,7 +24,7 @@ import { useRoute, useRouter } from 'vue-router'
import TagEditor from './tagEditor.vue'
import type { FormInstance } from 'element-plus'
import { ElMessage } from 'element-plus'
-import { createResources } from '@/api/index'
+import { createResources, editResources, getStreamOrMeasureList } from '@/api/index'
const $loadingCreate = getCurrentInstance().appContext.config.globalProperties.$loadingCreate
const $loadingClose = getCurrentInstance().appContext.config.globalProperties.$loadingClose
@@ -111,11 +111,29 @@ const submit = async (formEl: FormInstance | undefined) => {
tagFamilies: tagFamilies
}
$loadingCreate()
+ if (data.operator == 'edit' && data.form.group && data.form.name) {
+ return editResources('stream', data.form.group, data.form.name, { stream: form })
+ .then((res) => {
+ if (res.status == 200) {
+ ElMessage({
+ message: 'Edit successed',
+ type: "success",
+ duration: 5000
+ })
+ $bus.emit('refreshAside')
+ $bus.emit('deleteResource', data.form.name)
+ openResourses()
+ }
+ })
+ .finally(() => {
+ $loadingClose()
+ })
+ }
createResources('stream', { stream: form })
.then((res) => {
if (res.status == 200) {
ElMessage({
- message: 'Create succeeded',
+ message: 'Create successed',
type: "success",
duration: 5000
})
@@ -150,7 +168,36 @@ function openResourses() {
$bus.emit('AddTabs', add)
}
function initData() {
-
+ if (data.operator == 'edit' && data.form.group && data.form.name) {
+ $loadingCreate()
+ getStreamOrMeasureList('stream', data.form.group)
+ .then(res => {
+ if (res.status == 200) {
+ const index = res.data.stream.findIndex(item => {
+ return item.metadata.group == data.form.group && item.metadata.name == data.form.name
+ })
+ if (index >= 0) {
+ const tagFamilies = res.data.stream[index].tagFamilies
+ const arr = []
+ tagFamilies.forEach(item => {
+ item.tags.forEach(tag => {
+ let obj = {
+ tagFamily: item.name,
+ tag: tag.name,
+ type: tag.type,
+ indexedOnly: tag.indexedOnly
+ }
+ arr.push(obj)
+ })
+ })
+ tagEditorRef.value.setTagFamilies(arr)
+ }
+ }
+ })
+ .finally(() => {
+ $loadingClose()
+ })
+ }
}
</script>
diff --git a/ui/src/components2/StreamEditor/tagEditor.vue b/ui/src/components2/StreamEditor/tagEditor.vue
index 6220ef3f..e5eb9c07 100644
--- a/ui/src/components2/StreamEditor/tagEditor.vue
+++ b/ui/src/components2/StreamEditor/tagEditor.vue
@@ -206,8 +206,12 @@ function deleteTableData(index) {
function getTagFamilies() {
return data.tableData
}
+function setTagFamilies(value) {
+ data.tableData = value
+}
defineExpose({
- getTagFamilies
+ getTagFamilies,
+ setTagFamilies
})
</script>