Skip to content

Commit

Permalink
Feature/update datamanager (#840)
Browse files Browse the repository at this point in the history
* fix,inspector request miss data

* Update datamanager to better adapt the adapter

* show jsonpath

* bugfix,update

* bugfix

* bugfix

* bugfix

* bugfix
  • Loading branch information
echoyang7 authored Apr 19, 2024
1 parent fb0d3b4 commit 8358a91
Show file tree
Hide file tree
Showing 26 changed files with 1,422 additions and 360 deletions.
319 changes: 273 additions & 46 deletions frontend/package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"dependencies": {
"axios": "^0.27.2",
"iview": "^3.4.2",
"jsonpath": "^1.1.1",
"lodash": "^4.17.21",
"monaco-editor": "^0.30.1",
"socket.io-client": "^3.1.3",
Expand Down
23 changes: 22 additions & 1 deletion frontend/src/api/datamanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export const getGroupMap = (options) => {
})
}

// V2 getGroupMap
export const getMockDataByOpenNodes = (options) => {
return axios({
url: '/api/search/group?search_str=',
method: 'POST',
data: { 'open_nodes': options.openNodes, 'reset': options.reset }
})
}

export const getGroupDetail = (groupId) => {
return axios({
url: '/api/group/' + groupId
Expand Down Expand Up @@ -176,7 +185,7 @@ export const getSnapShotDetail = (id) => {
})
}

export const deleteByQuery = (ids, parentId) => {
export const deleteTempMockDataByQuery = (ids, parentId) => {
const query = {
id: ids,
'parent_id': parentId
Expand All @@ -188,6 +197,18 @@ export const deleteByQuery = (ids, parentId) => {
})
}

export const deleteByQuery = (dataIds, groupIds) => {
const query = {
'data': dataIds,
'groups': groupIds
}
return axios({
url: '/api/group',
method: 'DELETE',
data: { query }
})
}

export const saveTreeView = (tree) => {
return axios({
url: '/api/tree',
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/api/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import axios from 'axios'

export const searchGroupByName = (name) => {
return axios({
url: '/api/search/group/name/' + name
url: '/api/search/group?search_str=' + name
})
}
7 changes: 6 additions & 1 deletion frontend/src/components/DocumentTree.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export default {
'isShowMessage': false,
val
})
this.$store.dispatch('loadDataMap')
if (this.$store.state.dataManager.isCurrentVersionV1) {
this.$store.dispatch('loadDataMap')
}
}
},
groupListOpenNode: {
Expand All @@ -92,6 +94,9 @@ export default {
set (val) {
this.$store.commit('setSelectedLeaf', val)
}
},
isCurrentVersionV1 () {
return this.$store.state.dataManager.isCurrentVersionV1
}
},
watch: {
Expand Down
21 changes: 20 additions & 1 deletion frontend/src/components/DocumentTreeDialogCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ export default {
createTypeItems: [
{ value: 'group', text: 'Group' },
{ value: 'data', text: 'Data (HTTP)' },
{ value: 'json', text: 'Data (JSON)' }
{ value: 'json', text: 'Data (JSON)' },
{ value: 'config', text: 'Data (CONFIG)' }
]
}
},
Expand All @@ -85,6 +86,11 @@ export default {
},
set (val) {
this.$store.commit('setCreateType', val)
if (val == 'config') {
this.createName = '.Settings'
} else {
this.createName = null
}
}
}
},
Expand All @@ -97,6 +103,10 @@ export default {
parentId: this.nodeInfo.id
})
} else {
if (this.createType === 'config' && !this.checkIfConfigCanBeCreated(this.nodeInfo)) {
this.$bus.$emit('msg.error', 'Only one .Settings can be created!')
return
}
this.$store.dispatch('createData', {
type: this.createType,
dataName: this.createName,
Expand All @@ -109,6 +119,15 @@ export default {
onCancel () {
this.createName = ''
this.shown = false
this.$store.commit('setCreateType', 'group')
},
checkIfConfigCanBeCreated (nodeInfo) {
for (const node of nodeInfo.children) {
if (node.type === 'config') {
return false
}
}
return true
}
}
}
Expand Down
25 changes: 19 additions & 6 deletions frontend/src/components/DocumentTreeDialogDelete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ export default {
}
]
}
]
],
dataListToDelete: [],
groupListToDelete: []
}
},
computed: {
Expand All @@ -156,12 +158,22 @@ export default {
},
methods: {
onTreeNodeDelete () {
const deleteItemId = []
for (const item of this.deleteItem) {
deleteItemId.push(item.id)
if (this.$store.state.dataManager.deleteDialogSource === 'single') {
this.$store.dispatch('deleteGroup', this.deleteNode[0])
} else {
for (const item of this.deleteItem) {
this.groupListToDelete.push(item.id)
if (!item.type === 'group') {
this.dataListToDelete.push(item.id)
}
}
let payload = {
'data': this.dataListToDelete,
'groups': this.groupListToDelete
}
this.$store.dispatch('deleteByQuery', payload)
this.$store.commit('setIsSelectableStatus', false)
}
this.$store.dispatch('deleteByQuery', deleteItemId)
this.$store.commit('setIsSelectableStatus', false)
this.isShown = false
},
getDeleteItem () {
Expand Down Expand Up @@ -189,6 +201,7 @@ export default {
},
getNodeChildren (node) {
let nodeList = []
this.$store.dispatch('getParentAbsPath', node)
nodeList.push(node)
if (!node.children || node.children.length===0) {
return nodeList
Expand Down
17 changes: 15 additions & 2 deletions frontend/src/components/DocumentTreeNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<span>
<div class="status-point" v-show="isGroupActivated"/>
<span :class="nameClass">
<span :class="[nameClass, { 'highlight': isHighlight }]">
<span v-if="data.parent_id">{{data.name}}</span>
<v-icon v-else small color="accent">mdi-home</v-icon>
</span>
Expand Down Expand Up @@ -152,6 +152,15 @@ export default {
},
isLabelDisplay () {
return this.$store.state.dataManager.isLabelDisplay
},
isHighlight () {
if (this.data.id == this.$store.state.dataManager.treeSearchStr) {
return true;
}
if (this.$store.state.dataManager.treeSearchStr != '' && this.data.name.includes(this.$store.state.dataManager.treeSearchStr)) {
return true
}
return false
}
},
watch: {
Expand Down Expand Up @@ -186,7 +195,7 @@ export default {
this.$store.dispatch('saveTreeViewOpenNodes', this.$store.state.dataManager.groupListOpenNode)
return
}
if (!this.isLoadTreeAsync) {
if (!this.isLoadTreeAsync && this.$store.state.dataManager.isCurrentVersionV1) {
this.$store.commit('addGroupListOpenNode', this.data.id)
this.$store.dispatch('saveTreeViewOpenNodes', this.$store.state.dataManager.groupListOpenNode)
return
Expand Down Expand Up @@ -216,6 +225,7 @@ export default {
this.$store.dispatch('saveTreeViewOpenNodes', this.$store.state.dataManager.groupListOpenNode)
this.$store.dispatch('saveTreeView', this.$store.state.dataManager.treeData)
this.$store.commit('setFocusNodeInfo', this.data)
this.$store.dispatch('getParentAbsPath', this.data)
if (this.data.type === 'group') {
this.$store.dispatch('loadGroupDetail', this.data)
} else if (this.data.type === 'data') {
Expand Down Expand Up @@ -335,6 +345,9 @@ export default {
box-shadow: 0 0px 10px #19be6b, 0 1px 10px #19be6b inset;
}
}
.highlight {
background-color: #FFEE58;
}
</style>

<style lang='scss' scoped>
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/DocumentTreeNodeMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ export default {
},
onTreeNodeCut () {
this.$store.dispatch('cutGroupOrData', this.data)
let targetNode = this.findNode(this.$store.state.dataManager.treeData, this.data.parent_id)
targetNode.children = targetNode.children.filter(item => item.id != this.data.id)
if (this.$store.state.dataManager.isCurrentVersionV1) {
let targetNode = this.findNode(this.$store.state.dataManager.treeData, this.data.parent_id)
targetNode.children = targetNode.children.filter(item => item.id != this.data.id)
}
},
onTreeNodeCopy () {
this.$store.dispatch('copyGroupOrData', this.data)
Expand All @@ -164,6 +166,7 @@ export default {
this.$store.dispatch('pasteGroupOrData', this.data)
},
onTreeNodeDuplicate () {
// Deprecated
if (this.duplicateNodeChildrenCount >= this.shownDuplicateDialogCount) {
this.$store.commit('setIsShownDuplicateDialog', true)
return
Expand Down
Loading

0 comments on commit 8358a91

Please sign in to comment.