From 0875e0a9ab284819757e264c106167f8d8015e29 Mon Sep 17 00:00:00 2001 From: Wu ChuSheng Date: Tue, 27 Jun 2023 14:14:15 +0800 Subject: [PATCH] Add CRUD function of index-rule-binding (#287) Co-authored-by: Gao Hongtao --- ui/src/components/Aside/index.vue | 21 +- ui/src/components/IndexRule/index.vue | 30 ++- ui/src/components/IndexRuleBinding/Editor.vue | 244 +++++++++++++++++- ui/src/components/IndexRuleBinding/index.vue | 89 ++++++- ui/src/components/Read/index.vue | 6 +- ui/src/components/TopNav/index.vue | 6 +- ui/src/router/index.js | 24 +- ui/src/styles/elementPlus.scss | 12 +- 8 files changed, 383 insertions(+), 49 deletions(-) diff --git a/ui/src/components/Aside/index.vue b/ui/src/components/Aside/index.vue index bb5a4a9c5..6fd81b8c2 100644 --- a/ui/src/components/Aside/index.vue +++ b/ui/src/components/Aside/index.vue @@ -362,6 +362,13 @@ function shrinkDown(e) { // right click menu function rightClickGroup(e, index) { data.rightMenuList = groupMenu + if (props.type == 'measure') { + data.rightMenuList.push({ + icon: "el-icon-document", + name: "new resources", + id: "create resources" + }) + } data.clickIndex = index data.rightClickType = 'group' openRightMenu(e) @@ -552,7 +559,9 @@ function openDeletaDialog() { if (data.rightClickType == 'group') { return deleteGroupFunction(group) } else if (data.rightClickType == 'index-rule') { - return deleteIndexRuleFunction() + return deleteIndexRuleOrIndexRuleBindingFunction("index-rule") + } else if (data.rightClickType == 'index-rule-binding') { + return deleteIndexRuleOrIndexRuleBindingFunction("index-rule-binding") } return deleteResource(group) }) @@ -560,11 +569,15 @@ function openDeletaDialog() { // catch error }) } -function deleteIndexRuleFunction() { +function deleteIndexRuleOrIndexRuleBindingFunction(type) { $loadingCreate() + const flag = { + 'index-rule': 'indexRule', + 'index-rule-binding': 'indexRuleBinding' + } let group = data.groupLists[data.clickIndex].metadata.name - let name = data.groupLists[data.clickIndex].indexRule[data.clickChildIndex].metadata.name - deleteIndexRuleOrIndexRuleBinding("index-rule", group, name) + let name = data.groupLists[data.clickIndex][flag[type]][data.clickChildIndex].metadata.name + deleteIndexRuleOrIndexRuleBinding(type, group, name) .then((res) => { if (res.status == 200) { if (res.data.deleted) { diff --git a/ui/src/components/IndexRule/index.vue b/ui/src/components/IndexRule/index.vue index c9531e39b..ce597f323 100644 --- a/ui/src/components/IndexRule/index.vue +++ b/ui/src/components/IndexRule/index.vue @@ -49,21 +49,23 @@ watch(() => route, () => { }) function initData() { - $loadingCreate() - getIndexRuleOrIndexRuleBinding(data.type, data.group, data.name) - .then(result => { - data.indexRule = result.data.indexRule - }) - .catch(err => { - ElMessage({ - message: 'Please refresh and try again. Error: ' + err, - type: "error", - duration: 3000 + if (data.type && data.group && data.name) { + $loadingCreate() + getIndexRuleOrIndexRuleBinding(data.type, data.group, data.name) + .then(result => { + data.indexRule = result.data.indexRule }) - }) - .finally(() => { - $loadingClose() - }) + .catch(err => { + ElMessage({ + message: 'Please refresh and try again. Error: ' + err, + type: "error", + duration: 3000 + }) + }) + .finally(() => { + $loadingClose() + }) + } } diff --git a/ui/src/components/IndexRuleBinding/Editor.vue b/ui/src/components/IndexRuleBinding/Editor.vue index 68570dadf..cb6b20296 100644 --- a/ui/src/components/IndexRuleBinding/Editor.vue +++ b/ui/src/components/IndexRuleBinding/Editor.vue @@ -17,10 +17,248 @@ ~ under the License. --> - + - \ No newline at end of file + \ No newline at end of file diff --git a/ui/src/components/IndexRuleBinding/index.vue b/ui/src/components/IndexRuleBinding/index.vue index f8d4369c2..af0e1922b 100644 --- a/ui/src/components/IndexRuleBinding/index.vue +++ b/ui/src/components/IndexRuleBinding/index.vue @@ -17,10 +17,93 @@ ~ under the License. --> - + - \ No newline at end of file + \ No newline at end of file diff --git a/ui/src/components/Read/index.vue b/ui/src/components/Read/index.vue index 945ffc9d7..8c0376c4f 100644 --- a/ui/src/components/Read/index.vue +++ b/ui/src/components/Read/index.vue @@ -389,7 +389,7 @@ function changeFields() { -
+
- +
- +
diff --git a/ui/src/components/TopNav/index.vue b/ui/src/components/TopNav/index.vue index c91801b78..4ed5db9cd 100644 --- a/ui/src/components/TopNav/index.vue +++ b/ui/src/components/TopNav/index.vue @@ -68,15 +68,15 @@ function initData() { if (operator == 'read') { routeData.name = type add.label = name - add.type = type == 'index-rule' || type == 'index-rule' ? `Read-${type}` : 'Read' + add.type = type == 'index-rule' || type == 'index-rule-binding' ? `Read-${type}` : 'Read' } else if (operator == 'edit') { routeData.name = `edit-${type}` add.label = name - add.type = type == 'index-rule' || type == 'index-rule' ? `Edit-${type}` : 'Edit' + add.type = type == 'index-rule' || type == 'index-rule-binding' ? `Edit-${type}` : 'Edit' } else { routeData.name = `create-${type}` add.label = group - add.type = type == 'index-rule' || type == 'index-rule' ? `Create-${type}` : 'Create' + add.type = type == 'index-rule' || type == 'index-rule-binding' ? `Create-${type}` : 'Create' } data.tabsList.push(add) } diff --git a/ui/src/router/index.js b/ui/src/router/index.js index e19f41cdd..79e417c7c 100644 --- a/ui/src/router/index.js +++ b/ui/src/router/index.js @@ -72,34 +72,34 @@ const router = createRouter({ component: () => import('@/views/Stream/createEdit.vue') }, { - path: '/banyandb/stream/index-rule/operator/:type/:operator/:group', + path: '/banyandb/stream/index-rule/operator-read/:type/:operator/:group/:name', + name: 'index-rule', + component: () => import('@/components/IndexRule/index.vue') + }, + { + path: '/banyandb/stream/index-rule/operator-create/:type/:operator/:group', name: 'create-index-rule', component: () => import('@/components/IndexRule/Editor.vue') }, { - path: '/banyandb/stream/index-rule/operator/:type/:operator/:group/:name', + path: '/banyandb/stream/index-rule/operator-edit/:type/:operator/:group/:name', name: 'edit-index-rule', component: () => import('@/components/IndexRule/Editor.vue') }, { - path: '/banyandb/stream/index-rule/operator/:type/:operator/:group/:name', - name: 'index-rule', - component: () => import('@/components/IndexRule/index.vue') + path: '/banyandb/stream/index-rule-binding/operator-read/:type/:operator/:group/:name', + name: 'index-rule-binding', + component: () => import('@/components/IndexRuleBinding/index.vue') }, { - path: '/banyandb/stream/index-rule-binding/operator/:type/:operator/:group', + path: '/banyandb/stream/index-rule-binding/operator-create/:type/:operator/:group', name: 'create-index-rule-binding', component: () => import('@/components/IndexRuleBinding/Editor.vue') }, { - path: '/banyandb/stream/index-rule-binding/operator/:type/:operator/:group/:name', + path: '/banyandb/stream/index-rule-binding/operator-edit/:type/:operator/:group/:name', name: 'edit-index-rule-binding', component: () => import('@/components/IndexRuleBinding/Editor.vue') - }, - { - path: '/banyandb/stream/index-rule-binding/operator/:type/:operator/:group/:name', - name: 'index-rule-binding', - component: () => import('@/components/IndexRuleBinding/index.vue') } ] }, diff --git a/ui/src/styles/elementPlus.scss b/ui/src/styles/elementPlus.scss index 5f257a144..dbbc12733 100644 --- a/ui/src/styles/elementPlus.scss +++ b/ui/src/styles/elementPlus.scss @@ -131,7 +131,6 @@ el-select ==================== */ .el-select { - height: 25px !important; border-radius: 1px !important; --el-select-input-focus-border-color: var(--color-main) !important; --el-select-border-color-hover: var(--color-main) !important; @@ -156,26 +155,25 @@ el-input ====================*/ .el-input { - height: 25px !important; --el-input-border-radius: 1px !important; --el-input-focus-border-color: var(--color-main) !important; --el-input-clear-hover-color: var(--color-main) !important; - .el-input__inner { + /* .el-input__inner { height: 25px !important; - } + } */ } /* ================ el-date-editor =====================*/ .el-date-editor { - height: 25px !important; + /* height: 25px !important; */ border-radius: 1px !important; - .el-range-input { + /* .el-range-input { height: 21px !important; - } + } */ } /* ================