From 10b467096ef683c6a8a72e95ed20f96c3d8d809d Mon Sep 17 00:00:00 2001 From: yumiguan <41277086+yumiguan@users.noreply.github.com> Date: Mon, 4 Dec 2023 17:07:59 +0800 Subject: [PATCH] v2.23.0 - feature/inspector-temp-mock (#805) * Inspector support temprory mock; DataManager support custom tab * remove inspector save button hover --- frontend/src/api/datamanager.js | 17 +- frontend/src/components/DocumentTree.vue | 13 +- frontend/src/components/DocumentTreeNode.vue | 16 +- frontend/src/store/datamanager.js | 67 ++++- frontend/src/views/Main.vue | 5 + frontend/src/views/datamanager/DataDetail.vue | 9 +- .../views/datamanager/DataDetailFolder.vue | 139 +++++++-- .../views/datamanager/DataDetailHttpData.vue | 50 +++- .../src/views/datamanager/DataDetailInfo.vue | 18 +- .../datamanager/DataDetailPlainConfig.vue | 32 +- .../views/datamanager/DataDetailPlainJSON.vue | 32 +- frontend/src/views/datamanager/DataList.vue | 255 +--------------- .../views/datamanager/DataListButtonBar.vue | 279 +++++++++++++++++ .../src/views/datamanager/JsonPathBar.vue | 43 --- frontend/src/views/inspector/ButtonBar.vue | 54 +--- frontend/src/views/inspector/FlowDetail.vue | 177 +++++++---- .../src/views/inspector/TempMockDrawer.vue | 80 +++++ frontend/src/views/inspector/TempMockTree.vue | 129 ++++++++ lyrebird/mock/blueprints/apis/mock.py | 38 ++- lyrebird/mock/cache.py | 6 + lyrebird/mock/dm/__init__.py | 89 +++--- lyrebird/mock/dm/file_data_adapter.py | 2 +- lyrebird/mock/dm/temp_mock.py | 166 +++++++++++ lyrebird/mock/handlers/mock_handler.py | 16 +- lyrebird/utils.py | 16 + lyrebird/version.py | 2 +- tests/test_dm.py | 88 ++++++ tests/test_dm_api.py | 64 ++++ tests/test_dm_temp.py | 280 ++++++++++++++++++ 29 files changed, 1661 insertions(+), 521 deletions(-) create mode 100644 frontend/src/views/datamanager/DataListButtonBar.vue delete mode 100644 frontend/src/views/datamanager/JsonPathBar.vue create mode 100644 frontend/src/views/inspector/TempMockDrawer.vue create mode 100644 frontend/src/views/inspector/TempMockTree.vue create mode 100644 lyrebird/mock/dm/temp_mock.py create mode 100644 tests/test_dm_temp.py diff --git a/frontend/src/api/datamanager.js b/frontend/src/api/datamanager.js index 107c5b6ed..9bef9bc5a 100644 --- a/frontend/src/api/datamanager.js +++ b/frontend/src/api/datamanager.js @@ -49,6 +49,18 @@ export const updateGroup = (id, data) => { }) } +export const updateByQuery = (ids, data, tab) => { + const query = { + id: ids, + tab + } + return axios({ + url: '/api/group', + method: 'PUT', + data: { query, data } + }) +} + export const getDataDetail = (dataId) => { return axios({ url: '/api/data/' + dataId @@ -164,9 +176,10 @@ export const getSnapShotDetail = (id) => { }) } -export const deleteByQuery = (ids) => { +export const deleteByQuery = (ids, parentId) => { const query = { - id: ids + id: ids, + 'parent_id': parentId } return axios({ url: '/api/group', diff --git a/frontend/src/components/DocumentTree.vue b/frontend/src/components/DocumentTree.vue index bfdefa32d..c88100fac 100644 --- a/frontend/src/components/DocumentTree.vue +++ b/frontend/src/components/DocumentTree.vue @@ -23,7 +23,7 @@ :options="{threshold: 0.5}" transition="fade-transition" > - + @@ -37,7 +37,16 @@ export default { components: { DocumentTreeNode }, - props: ['treeData', 'searchStr'], + props: { + 'treeData': Array, + 'searchStr': String, + 'editable': { + default: true + }, + 'deletable': { + default: true + } + }, data() { return { searchRefreshDataListTimer: null, diff --git a/frontend/src/components/DocumentTreeNode.vue b/frontend/src/components/DocumentTreeNode.vue index e02cf2b9d..31181d83f 100644 --- a/frontend/src/components/DocumentTreeNode.vue +++ b/frontend/src/components/DocumentTreeNode.vue @@ -60,7 +60,7 @@ icon @click="changeMenuStatus" class="mr-1" - v-show="data.type !== 'config'" + v-show="isNodeEditable" > -1 @@ -201,6 +204,9 @@ export default { }) }, onTreeNodeClick () { + if (!this.editable) { + return + } this.$store.commit('setFocusNodeInfo', this.data) if (this.data.type === 'group') { this.$store.dispatch('loadGroupDetail', this.data) @@ -279,10 +285,6 @@ export default { } .toggle-icon-status { transform:rotate(-90deg); - /* animation-name: loading-icon-rotate; - animation-duration: 800ms; - animation-timing-function: linear; - animation-iteration-count: infinite; */ } .loading-icon { animation-name: loading-icon-rotate; diff --git a/frontend/src/store/datamanager.js b/frontend/src/store/datamanager.js index 99ea4309b..457ea40df 100644 --- a/frontend/src/store/datamanager.js +++ b/frontend/src/store/datamanager.js @@ -5,9 +5,8 @@ import { bus } from '@/eventbus' export default { state: { title: 'Mock Data', - searchStr: '', + treeSearchStr: '', groupList: [], - jsonPath: null, conflictInfo: null, isLoadConflictInfo: false, groupListOpenNode: [], @@ -41,21 +40,20 @@ export default { uneditableKey: ['id', 'rule', 'super_by'], stickyTopKey: ['id', 'rule', 'super_id', 'name', 'label', 'super_by'], displayCopyKey: ['id'], - treeUndeletableId: [] + treeUndeletableId: [], + temporaryMockDataList: [], + tempGroupId: 'tmp_group', }, mutations: { setTitle (state, title) { state.title = title }, - setSearchStr (state, searchStr) { - state.searchStr = searchStr + setTreeSearchStr (state, treeSearchStr) { + state.treeSearchStr = treeSearchStr }, setGroupList (state, groupList) { state.groupList = groupList }, - setJsonPath (state, jsonPath) { - state.jsonPath = jsonPath - }, setConflictInfo (state, conflictInfo) { state.conflictInfo = conflictInfo }, @@ -189,7 +187,10 @@ export default { }, concatTreeUndeletableId (state, treeUndeletableId) { state.treeUndeletableId = state.treeUndeletableId.concat(treeUndeletableId) - } + }, + setTemporaryMockDataList (state, val) { + state.temporaryMockDataList = val + }, }, actions: { loadDataMap ({ state, commit }) { @@ -295,7 +296,7 @@ export default { } dispatch('loadGroupDetail', payload) bus.$emit('msg.destroy') - if (response.data.message) { + if (response.data.message && response.data.message.length > 0) { bus.$emit('msg.info', response.data.message) } else { bus.$emit('msg.success', 'Group ' + payload.name + ' update!') @@ -305,6 +306,22 @@ export default { bus.$emit('msg.error', 'Group ' + payload.name + ' update error: ' + error.data.message) }) }, + sendGroupDetail ({ state }, payload) { + bus.$emit('msg.loading', `Sending ${payload.tab} ...`) + let ids = state.isSelectableStatus ? state.selectedLeaf : [state.groupDetail.id] + api.updateByQuery(ids, state.groupDetail, payload.tab) + .then(response => { + bus.$emit('msg.destroy') + if (response.data.message && response.data.message.length > 0) { + bus.$emit('msg.info', response.data.message) + } else { + bus.$emit('msg.success', `Group ${payload.tab} send success!`) + } + }) + .catch(error => { + bus.$emit('msg.error', `Group ${payload.tab} send error: ${error.data.message}`) + }) + }, deleteGroup ({ state, commit, dispatch }, payload) { bus.$emit('msg.loading', 'Deleting group ' + payload.name + ' ...') api.deleteGroup(payload.id) @@ -467,6 +484,36 @@ export default { .catch(error => { bus.$emit('msg.error', 'Delete error: ' + error.data.message) }) + }, + // Temp mock + loadTempMockData ({ state, commit }) { + api.getGroupDetail(state.tempGroupId) + .then(response => { + commit('setTemporaryMockDataList', [response.data.data]) + }) + .catch(error => { + bus.$emit('msg.error', 'Load Temporary mock data error: ' + error.data.message) + }) + }, + createTempMockData ({ state, dispatch }, payload ) { + api.createData(state.tempGroupId, payload) + .then(_ => { + dispatch('loadTempMockData') + bus.$emit('msg.success', 'Save temporary mock data success!') + }) + .catch(error => { + bus.$emit('msg.error', 'Save temporary mock error: ' + error.data.message) + }) + }, + deleteTempMockData ({ state, dispatch }, payload) { + api.deleteByQuery([payload.id], state.tempGroupId) + .then(_ => { + dispatch('loadTempMockData') + bus.$emit('msg.success', `Delete temporary mock data ${payload.name} success!`) + }) + .catch(error => { + bus.$emit('msg.error', 'Delete temporary mock data error: ' + error.data.message) + }) } } } diff --git a/frontend/src/views/Main.vue b/frontend/src/views/Main.vue index d564cde81..c869604ee 100644 --- a/frontend/src/views/Main.vue +++ b/frontend/src/views/Main.vue @@ -270,6 +270,11 @@ export default { .side-navgation { z-index: 4; } +.ivu-split-trigger-con { + /* vuetify drawer z-index is 4 */ + /* iview drawer z-index is 4 */ + z-index: 3; +} .ivu-split-pane { overflow: hidden; } diff --git a/frontend/src/views/datamanager/DataDetail.vue b/frontend/src/views/datamanager/DataDetail.vue index 6807b1a32..744dfc88c 100644 --- a/frontend/src/views/datamanager/DataDetail.vue +++ b/frontend/src/views/datamanager/DataDetail.vue @@ -1,7 +1,7 @@