import Vue from 'vue' import uniqueId from 'lodash' import {i18n} from '../main' import AuthorityFilter from '../commands/AuthorityFilter' import CreateAndCopySubnetDialog from '@/components/DialogComponents/SubnetDialog/CreateAndCopySubnet.vue' import CreateAndCopyElementDiscoveryDialog from '@/components/DialogComponents/ElementDiscoveryTemplate/CreateAndCopyElementDiscoveryDialog.vue' import CopyElementDiscoveryDialog from '@/components/DialogComponents/ElementDiscoveryTemplate/CopyElementDiscoveryDialog.vue' import DeleteTemplateDialog from '@/components/DialogComponents/ElementDiscoveryTemplate/DeleteTemplateDialog.vue' import UpdateTemplateDialog from '@/components/DialogComponents/ElementDiscoveryTemplate/UpdateTemplateDialog.vue' import DeleteSubnetDialog from '@/components/DialogComponents/SubnetDialog/DeleteSubnetDialog.vue' import UpdateSubnetDialog from '@/components/DialogComponents/SubnetDialog/UpdateSubnet.vue' import ImportSubnetDialog from '@/components/DialogComponents/SubnetDialog/ImportSubnetDialog.vue' Vue.component('CreateAndCopySubnetDialog', CreateAndCopySubnetDialog) Vue.component('DeleteSubnetDialog', DeleteSubnetDialog) Vue.component('UpdateSubnetDialog', UpdateSubnetDialog) Vue.component('ImportSubnetDialog', ImportSubnetDialog) Vue.component('CreateAndCopyElementDiscoveryDialog', CreateAndCopyElementDiscoveryDialog) Vue.component('CopyElementDiscoveryDialog', CopyElementDiscoveryDialog) Vue.component('DeleteTemplateDialog', DeleteTemplateDialog) Vue.component('UpdateTemplateDialog', UpdateTemplateDialog) let CommandTypes = { CREATE_COPY_SUBNET_CMD: { type: 'CreateAndCopySubnet', executeComponent: 'CreateAndCopySubnetDialog', registerComponent: CreateAndCopySubnetDialog }, CREATE_COPY_ELEMENT_DISCOVERY_CMD: { type: 'CreateAndCopyElementDiscoveryDialog', executeComponent: 'CreateAndCopyElementDiscoveryDialog', registerComponent: CreateAndCopyElementDiscoveryDialog }, COPY_ELEMENT_DISCOVERY_CMD: { type: 'copyElementDiscoveryDialog', executeComponent: 'CopyElementDiscoveryDialog', registerComponent: CopyElementDiscoveryDialog }, DELETE_TEMPLATE_CMD: { type: 'DeleteTemplate', executeComponent: 'DeleteTemplateDialog', registerComponent: DeleteTemplateDialog // import对应的对话框组件 }, UPDATE_TEMPLATE_CMD: { type: 'UpdateTemplate', executeComponent: 'UpdateTemplateDialog', registerComponent: UpdateTemplateDialog // import对应的对话框组件 }, DELETE_SUBNET_CMD: { type: 'DeleteSubnet', executeComponent: 'DeleteSubnetDialog', registerComponent: DeleteSubnetDialog // import对应的对话框组件 }, UPDATE_SUBNET_CMD: { type: 'UpdateSubnet', executeComponent: 'UpdateSubnetDialog', registerComponent: UpdateSubnetDialog // import对应的对话框组件 }, IMPORT_SUBNET_CMD: { type: 'ImportSubnetToExcel', executeComponent: 'ImportSubnetDialog', registerComponent: ImportSubnetDialog // import对应的对话框组件 } } class EdTemplateCommands { static createAndCopyEdTemplateCommand (title, templatePa, commandContext) { let command = { id: uniqueId(CommandTypes.CREATE_COPY_ELEMENT_DISCOVERY_CMD.type), visible: true, disabled: false, target: templatePa, title: title, executeComponent: CommandTypes.CREATE_COPY_ELEMENT_DISCOVERY_CMD.executeComponent, execute: undefined, done: undefined, name: i18n.tc('EdTemplateCommands.createTemplate') } command.execute = function () { Vue.set(commandContext, command.id, command) } command.done = function () { Vue.delete(commandContext, command.id) } return AuthorityFilter.elementDiscoveryAuthorityFilter(command) } static copyEdTemplateCommand (title, templatePa, commandContext) { let command = { id: uniqueId(CommandTypes.COPY_ELEMENT_DISCOVERY_CMD.type), visible: true, disabled: false, target: templatePa, title: title, executeComponent: CommandTypes.COPY_ELEMENT_DISCOVERY_CMD.executeComponent, execute: undefined, done: undefined, name: i18n.tc('EdTemplateCommands.copyTemplate') } command.execute = function () { Vue.set(commandContext, command.id, command) } command.done = function () { Vue.delete(commandContext, command.id) } return AuthorityFilter.elementDiscoveryAuthorityFilter(command) } static deleteTemplateCommand (template1, commandContext) { let command = { id: uniqueId(CommandTypes.DELETE_TEMPLATE_CMD.type), visible: true, disabled: false, target: template1, executeComponent: CommandTypes.DELETE_TEMPLATE_CMD.executeComponent, execute: undefined, done: undefined, name: i18n.tc('EdTemplateCommands.deleteTemplate') } command.execute = function () { Vue.set(commandContext, command.id, command) } command.done = function () { Vue.delete(commandContext, command.id) } return AuthorityFilter.elementDiscoveryAuthorityFilter(command) } static updateTemplateCommand (tem, commandContext) { let command = { id: uniqueId(CommandTypes.UPDATE_TEMPLATE_CMD.type), visible: true, disabled: false, target: tem, executeComponent: CommandTypes.UPDATE_TEMPLATE_CMD.executeComponent, execute: undefined, done: undefined, name: i18n.tc('EdTemplateCommands.modifyTemplate') } command.execute = function () { Vue.set(commandContext, command.id, command) } command.done = function () { Vue.delete(commandContext, command.id) } return AuthorityFilter.elementDiscoveryAuthorityFilter(command) } static updateSubnetCommand (subnet, commandContext) { let command = { id: uniqueId(CommandTypes.UPDATE_SUBNET_CMD.type), visible: true, disabled: false, target: subnet, executeComponent: CommandTypes.UPDATE_SUBNET_CMD.executeComponent, execute: undefined, done: undefined, name: i18n.tc('SubnetCommands.modifySubnet') } command.execute = function () { Vue.set(commandContext, command.id, command) } command.done = function () { Vue.delete(commandContext, command.id) } return AuthorityFilter.subnetAuthorityFilter(command) } static importSubnetCommand (commandContext) { let command = { id: uniqueId(CommandTypes.IMPORT_SUBNET_CMD.type), visible: true, disabled: false, target: null, executeComponent: CommandTypes.IMPORT_SUBNET_CMD.executeComponent, execute: undefined, done: undefined } command.execute = function () { Vue.set(commandContext, command.id, command) } command.done = function () { Vue.delete(commandContext, command.id) } return AuthorityFilter.elementDiscoveryAuthorityFilter(command) } } EdTemplateCommands.CommandTypes = CommandTypes export default EdTemplateCommands