diff --git a/src/i18n/langs/zh.json b/src/i18n/langs/zh.json index f3afaf14b..f9df25be9 100644 --- a/src/i18n/langs/zh.json +++ b/src/i18n/langs/zh.json @@ -724,6 +724,8 @@ "CreateReplayStorage": "创建录像存储", "Dashboard": "仪表盘", "DatabaseApp": "数据库", + "RemoteApps": "远程应用", + "Clouds": "云设施", "DatabaseAppCreate": "创建数据库应用", "DatabaseAppDetail": "数据库详情", "DatabaseAppPermission": "数据库授权", diff --git a/src/router/console/assets.js b/src/router/console/assets.js index d5e8f3120..410c97450 100644 --- a/src/router/console/assets.js +++ b/src/router/console/assets.js @@ -45,111 +45,6 @@ export default [ } ] }, - { - path: 'hosts', - component: empty, - redirect: '', - meta: { title: i18n.t('route.AssetList'), permissions: ['assets.view_asset'] }, - children: [ - { - path: '', - name: 'HostList', - component: () => import('@/views/assets/Host/HostList.vue'), - meta: { title: i18n.t('route.HostList') } - }, - { - path: 'create', - name: 'HostCreate', - component: () => import('@/views/assets/Asset/AssetCreateUpdate.vue'), - hidden: true, - meta: { title: i18n.t('route.HostCreate') } - }, - { - path: ':id', - name: 'HostDetail', - component: () => import('@/views/assets/Asset/AssetDetail'), - hidden: true, - meta: { title: i18n.t('route.HostDetail') } - }, - { - path: ':id/update', - name: 'HostUpdate', - component: () => import('@/views/assets/Asset/AssetCreateUpdate.vue'), - hidden: true, - meta: { title: i18n.t('route.HostUpdate') } - } - ] - }, - { - path: 'devices', - component: empty, - redirect: '', - meta: { title: i18n.t('route.NetworkDevices'), permissions: ['assets.view_asset'] }, - children: [ - { - path: '', - name: 'DeviceList', - component: () => import('@/views/assets/Asset/AssetList.vue'), - meta: { title: i18n.t('route.NetworkDevices'), permissions: [] } - }, - { - path: 'create', - name: 'DeviceCreate', - component: () => import('@/views/assets/Asset/AssetCreateUpdate.vue'), - hidden: true, - meta: { title: i18n.t('route.DeviceCreate') } - }, - { - path: ':id', - name: 'DeviceDetail', - component: () => import('@/views/assets/Asset/AssetDetail'), - hidden: true, - meta: { title: i18n.t('route.DeviceDetail') } - }, - { - path: ':id/update', - name: 'DeviceUpdate', - component: () => import('@/views/assets/Asset/AssetCreateUpdate.vue'), - hidden: true, - meta: { title: i18n.t('route.DeviceUpdate') } - } - ] - }, - { - path: 'databases', - component: empty, - redirect: '', - meta: { title: i18n.t('route.Databases'), permissions: [] }, - children: [ - { - path: '', - name: 'DatabaseList', - component: () => import('@/views/assets/Asset/AssetList.vue'), - meta: { title: i18n.t('route.Databases'), permissions: [] } - }, - { - path: 'create', - name: 'DatabaseCreate', - component: () => import('@/views/assets/Asset/AssetCreateUpdate.vue'), - hidden: true, - meta: { title: i18n.t('route.DatabaseCreate') } - }, - { - path: ':id', - name: 'AssetDetail', - component: () => import('@/views/assets/Asset/AssetDetail'), - hidden: true, - meta: { title: i18n.t('route.AssetDetail') } - }, - { - path: ':id/update', - name: 'AssetUpdate', - component: () => import('@/views/assets/Asset/AssetCreateUpdate.vue'), - hidden: true, - meta: { title: i18n.t('route.AssetUpdate') } - } - ] - }, { path: 'domains', component: empty, diff --git a/src/views/assets/Asset/AssetList.vue b/src/views/assets/Asset/AssetList.vue index 7b0a3e731..200a23a8f 100644 --- a/src/views/assets/Asset/AssetList.vue +++ b/src/views/assets/Asset/AssetList.vue @@ -1,51 +1,23 @@ @@ -53,23 +25,21 @@ import GenericTreeListPage from '@/layout/components/GenericTreeListPage/index' import { DetailFormatter, ActionsFormatter, TagsFormatter } from '@/components/TableFormatters' import $ from '@/utils/jquery-vendor' -import Dialog from '@/components/Dialog' import { mapGetters } from 'vuex' import { connectivityMeta } from '@/components/AccountListTable/const' -import { openTaskPage } from '@/utils/jms' import AssetBulkUpdateDialog from './AssetBulkUpdateDialog' -import NodeAssetsUpdateDialog from './NodeAssetsUpdateDialog' +import TreeMenu from './TreeMenu' export default { components: { GenericTreeListPage, - Dialog, AssetBulkUpdateDialog, - NodeAssetsUpdateDialog + TreeMenu }, data() { const vm = this return { + treeRef: null, treeSetting: { showMenu: true, showRefresh: true, @@ -151,7 +121,10 @@ export default { type: 'primary', can: vm.$hasPerm('assets.refresh_assethardwareinfo'), callback: function({ cellValue, tableData, row }) { - return this.$router.push({ name: 'AssetMoreInformationEdit', params: { id: row.id }}) + return this.$router.push({ + name: 'AssetMoreInformationEdit', + params: { id: row.id } + }) } } ] @@ -222,8 +195,8 @@ export default { title: this.$t('common.updateSelected'), can: ({ selectedRows }) => { return selectedRows.length > 0 && - !vm.currentOrgIsRoot && - vm.$hasPerm('assets.change_asset') + !vm.currentOrgIsRoot && + vm.$hasPerm('assets.change_asset') }, callback: ({ selectedRows }) => { vm.updateSelectedDialogSetting.selectedRows = selectedRows @@ -238,8 +211,8 @@ export default { return false } return selectedRows.length > 0 && - !vm.currentOrgIsRoot && - vm.$hasPerm('assets.change_node') + !vm.currentOrgIsRoot && + vm.$hasPerm('assets.change_node') }, callback: function({ selectedRows, reloadTable }) { const assetsId = [] @@ -262,18 +235,9 @@ export default { ] }, helpMessage: this.$t('assets.AssetListHelpMessage'), - nodeInfoDialogSetting: { - dialogVisible: false, - items: [] - }, updateSelectedDialogSetting: { visible: false, selectedRows: [] - }, - nodeAssetsUpdateDialog: { - visible: false, - action: 'add', - selectNode: null } } }, @@ -286,6 +250,7 @@ export default { this.treeSetting.showCreate = this.$hasPerm('assets.add_node') this.treeSetting.showUpdate = this.$hasPerm('assets.change_node') this.treeSetting.showDelete = this.$hasPerm('assets.delete_node') + this.treeRef = this.$refs.TreeList }, methods: { decorateRMenu() { @@ -298,145 +263,18 @@ export default { $('#m_show_asset_only_current_node').css('color', '#606266') } }, - hideRMenu() { - this.$refs.TreeList.hideRMenu() - }, - getSelectedNodes() { - return this.$refs.TreeList.getSelectedNodes() - }, - rMenuAddAssetToNode() { - this.nodeAssetsUpdateDialog.visible = true - this.nodeAssetsUpdateDialog.action = 'add' - this.nodeAssetsUpdateDialog.selectNode = this.getSelectedNodes()[0] - }, - rMenuMoveAssetToNode() { - this.nodeAssetsUpdateDialog.visible = true - this.nodeAssetsUpdateDialog.action = 'move' - this.nodeAssetsUpdateDialog.selectNode = this.getSelectedNodes()[0] - }, - rMenuUpdateNodeAssetHardwareInfo: function() { - this.hideRMenu() - const currentNode = this.getSelectedNodes()[0] - if (!currentNode) { - return - } - this.$axios.post( - `/api/v1/assets/nodes/${currentNode.meta.data.id}/tasks/`, - { 'action': 'refresh' } - ).then((res) => { - openTaskPage(res['task']) - }).catch(error => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + error)) - }) - }, - rMenuTestNodeAssetConnectivity: function() { - this.hideRMenu() - const currentNode = this.getSelectedNodes()[0] - if (!currentNode) { - return - } - this.$axios.post( - `/api/v1/assets/nodes/${currentNode.meta.data.id}/tasks/`, - { 'action': 'test' } - ).then((res) => { - openTaskPage(res['task']) - }).catch(error => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + error)) - }) - }, - rMenuShowAssetOnlyCurrentNode: function() { - this.hideRMenu() - const currentNode = this.getSelectedNodes()[0] - if (!currentNode) { - return - } - this.$cookie.set('show_current_asset', '1', 1) + showAll({ node, showCurrentAsset }) { + this.$cookie.set('show_current_asset', showCurrentAsset, 1) this.decorateRMenu() - const url = `${this.treeSetting.url}?node_id=${currentNode.meta.data.id}&show_current_asset=1` + const url = `${this.treeSetting.url}?node_id=${node.meta.data.id}&show_current_asset=${showCurrentAsset}` this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url) - }, - rMenuShowAssetAllChildrenNode: function() { - this.hideRMenu() - const currentNode = this.getSelectedNodes()[0] - if (!currentNode) { - return - } - this.$cookie.set('show_current_asset', '0', 1) - this.decorateRMenu() - const url = `${this.treeSetting.url}?node_id=${currentNode.meta.data.id}&show_current_asset=0` - this.$refs.TreeList.$refs.TreeTable.handleUrlChange(url) - }, - rMenuShowNodeInfo: function() { - this.hideRMenu() - const currentNode = this.getSelectedNodes()[0] - if (!currentNode) { - return - } - this.$axios.get( - `/api/v1/assets/nodes/${currentNode.meta.data.id}/` - ).then(res => { - this.nodeInfoDialogSetting.dialogVisible = true - this.nodeInfoDialogSetting.items = [ - { key: 'id', label: 'ID', value: res.id }, - { key: 'name', label: this.$t('assets.Name'), value: res.name }, - { key: 'fullName', label: this.$t('assets.FullName'), value: res.full_value } - ] - }).catch(error => { - this.$message.error(this.$t('common.ErrorMsg' + ' ' + error)) - }) - }, - rCheckAssetsAmount: function() { - this.$axios.post( - `/api/v1/assets/nodes/check_assets_amount_task/` - ).then(res => { - openTaskPage(res['task']) - }).catch(error => { - this.$message.error(this.$t('common.updateErrorMsg' + ' ' + error)) - }) } } } diff --git a/src/views/assets/Asset/TreeMenu.vue b/src/views/assets/Asset/TreeMenu.vue new file mode 100644 index 000000000..fdc847b42 --- /dev/null +++ b/src/views/assets/Asset/TreeMenu.vue @@ -0,0 +1,229 @@ + + + + +