mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-26 06:58:53 +00:00
[update]添加命令执行功能
This commit is contained in:
@@ -31,6 +31,10 @@
|
||||
"assets": {
|
||||
"Action": "动作",
|
||||
"AutoGenerateKey": "自动生成密钥",
|
||||
"UnselectedAssets":"未选择资产",
|
||||
"Pending": "等待",
|
||||
"NoSystemUserWasSelected":"未选择系统用户",
|
||||
"NoInputCommand": "未输入命令",
|
||||
"LoginModeHelpMessage": "如果选择手动登录模式,用户名和密码可以不填写",
|
||||
"UsernameHelpMessage": "用户名是动态的,登录资产时使用当前用户的用户名登录",
|
||||
"PriorityHelpMessage": "1-100, 1最低优先级,100最高优先级。授权多个用户时,高优先级的系统用户将会作为默认登录用户",
|
||||
@@ -49,7 +53,6 @@
|
||||
"AssetDetail": "资产详情",
|
||||
"AssetList": "资产列表",
|
||||
"AssetNumber": "资产编号",
|
||||
"AssetUserList": "资产用户列表",
|
||||
"Assets": "资产",
|
||||
"Auth": "认证",
|
||||
"AutoPush": "自动推送",
|
||||
@@ -147,8 +150,6 @@
|
||||
"DateLastWeek": "最近一周",
|
||||
"DateLastMonth": "最近一月",
|
||||
"DateLast3Months": "最近三月",
|
||||
"View": "查看",
|
||||
"Remove": "移除",
|
||||
"Yes": "是",
|
||||
"No": "否",
|
||||
"Action": "动作",
|
||||
@@ -399,9 +400,9 @@
|
||||
"DatabaseAppPermissionUpdate": "更新数据库应用授权规则",
|
||||
"DatabaseAppUpdate": "",
|
||||
"DomainCreate": "创建网关",
|
||||
"DomainDetail": "网域详情",
|
||||
"DomainList": "网域列表",
|
||||
"DomainUpdate": "更新网域",
|
||||
"DomainDetail": "域名详情",
|
||||
"DomainList": "网关列表",
|
||||
"DomainUpdate": "更新网关",
|
||||
"FileManager": "文件管理",
|
||||
"FtpLog": "FTP日志",
|
||||
"GatewayCreate": "创建网关",
|
||||
@@ -455,7 +456,7 @@
|
||||
"WebFTP": "文件管理",
|
||||
"WebTerminal": "Web终端",
|
||||
"BatchCommandLog": "批量命令",
|
||||
"TaskMonitor": "任务监控"
|
||||
"": ""
|
||||
},
|
||||
"sessions": {
|
||||
"StorageConfiguration": "存储配置",
|
||||
@@ -625,9 +626,7 @@
|
||||
"consult": "咨询",
|
||||
"ImportLicense": "导入许可证",
|
||||
"AssetCount": "资产数量",
|
||||
"ImportLicenseTip": "请导入许可证",
|
||||
"all": "全部",
|
||||
"auto": "自动"
|
||||
"ImportLicenseTip": "请导入许可证"
|
||||
},
|
||||
"settings": {
|
||||
"setting": ""
|
||||
@@ -653,10 +652,6 @@
|
||||
"DeleteNode": "删除节点",
|
||||
"RenameNode": "重命名节点"
|
||||
},
|
||||
"audits": {
|
||||
"View": "查看",
|
||||
"Hosts": "主机"
|
||||
},
|
||||
"users": {
|
||||
"SSHKey": "SSH公钥",
|
||||
"TermsAndConditions": "条款和条件",
|
||||
@@ -735,10 +730,6 @@
|
||||
"dateLastLogin": ""
|
||||
},
|
||||
"xpack": {
|
||||
"Vault": {
|
||||
"Vault": "密码匣子",
|
||||
"Create": "创建"
|
||||
},
|
||||
"Basic": "基本",
|
||||
"Other": "其他",
|
||||
"Admin": "管理员",
|
||||
@@ -778,8 +769,8 @@
|
||||
"DateJoined": "创建日期",
|
||||
"DateUpdated": "更新日期",
|
||||
"ManualExecutePlan": "手动执行计划",
|
||||
"AddAsset": "添加资产",
|
||||
"AddNode": "添加节点",
|
||||
"addAsset": "添加资产",
|
||||
"addNode": "添加节点",
|
||||
"Result": "结果",
|
||||
"TimeDelta": "运行时间",
|
||||
"DateStart": "开始日期",
|
||||
@@ -795,20 +786,11 @@
|
||||
"Corporation": "公司",
|
||||
"Edition": "版本",
|
||||
"Expired": "过期时间",
|
||||
"GatherUser": {
|
||||
"GatherUser": "收集用户",
|
||||
"GatherUserTask": "收集用户任务",
|
||||
"GatherUserList": "收集资产用户列表",
|
||||
"GatherUserTaskCreate": "创建任务",
|
||||
"GatherUserTaskList": "收集资产任务列表",
|
||||
"GatherUserTaskUpdate": "更新任务"
|
||||
},
|
||||
"Organization": {
|
||||
"OrganizationCreate": "创建组织",
|
||||
"OrganizationDetail": "组织详情",
|
||||
"OrganizationList": "组织管理",
|
||||
"OrganizationUpdate": "更新组织"
|
||||
},
|
||||
"GatherUserTask": "收集用户任务",
|
||||
"GatherUserList": "收集用户",
|
||||
"GatherUserTaskCreate": "创建任务",
|
||||
"GatherUserTaskList": "任务列表",
|
||||
"GatherUserTaskUpdate": "更新任务",
|
||||
"ImportLicense": "导入许可证",
|
||||
"ImportLicenseTip": "请导入许可证",
|
||||
"InterfaceSettings": "界面设置",
|
||||
@@ -816,6 +798,10 @@
|
||||
"LicenseDetail": "许可证详情",
|
||||
"LicenseFile": "许可证文件",
|
||||
"NoLicense": "暂无许可证",
|
||||
"OrganizationCreate": "创建组织",
|
||||
"OrganizationDetail": "组织详情",
|
||||
"OrganizationList": "组织管理",
|
||||
"OrganizationUpdate": "更新组织",
|
||||
"RestoreButton": "恢复默认",
|
||||
"SubscriptionID": "订阅授权ID",
|
||||
"Timer": "定时执行",
|
||||
@@ -835,7 +821,7 @@
|
||||
"restoreDialogTitle": "你确认吗",
|
||||
"technologyConsult": "技术咨询",
|
||||
"Cloud": {
|
||||
"CloudCenter": "云管中心",
|
||||
"Cloud": "云管中心",
|
||||
"AccountList": "账户列表",
|
||||
"AccountCreate": "创建账户",
|
||||
"AccountUpdate": "更新账户",
|
||||
|
@@ -30,6 +30,10 @@
|
||||
},
|
||||
"assets": {
|
||||
"Action": "Action",
|
||||
"NoInputCommand": "No input command",
|
||||
"UnselectedAssets":"Unselected assets",
|
||||
"Pending": "Pending",
|
||||
"NoSystemUserWasSelected":"No system user was selected",
|
||||
"LoginModeHelpMessage": "If you choose manual login mode, you do not need to fill in the username and password.",
|
||||
"UsernameHelpMessage": "Username is dynamic, When connect asset, using current user's username",
|
||||
"PriorityHelpMessage": "1-100, High level will be using login asset as default, if user was granted more than 2 system user",
|
||||
@@ -51,7 +55,6 @@
|
||||
"AssetList": "Asset list",
|
||||
"AssetNumber": "Asset number",
|
||||
"Assets": "Assets",
|
||||
"AssetUserList": "Asset user",
|
||||
"Auth": "Auth",
|
||||
"AutoPush": "Auto push",
|
||||
"BasePlatform": "Base platform",
|
||||
@@ -146,8 +149,6 @@
|
||||
"DateLastWeek": "Last week",
|
||||
"DateLastMonth": "Last month",
|
||||
"DateLast3Months": "Last 3 months",
|
||||
"Remove": "Remove",
|
||||
"View": "View",
|
||||
"Yes": "Yes",
|
||||
"No": "No",
|
||||
"Action": "Action",
|
||||
@@ -275,10 +276,6 @@
|
||||
"Weekly": "Weekly",
|
||||
"TimesWeekUnit": "times/week"
|
||||
},
|
||||
"audits": {
|
||||
"View": "View",
|
||||
"Hosts": "Hosts"
|
||||
},
|
||||
"ops": {
|
||||
"ID": "ID",
|
||||
"No": "No",
|
||||
@@ -455,8 +452,7 @@
|
||||
"Users": "Users",
|
||||
"WebFTP": "WebFTP",
|
||||
"WebTerminal": "Web terminal",
|
||||
"BatchCommandLog": "Batch command log",
|
||||
"TaskMonitor": "Task monitor"
|
||||
"BatchCommandLog": "Batch command log"
|
||||
},
|
||||
"sessions": {
|
||||
"StorageConfiguration": "Storage configuration",
|
||||
@@ -622,8 +618,8 @@
|
||||
"AssetCount": "Asset count",
|
||||
"ImportLicenseTip": "Please Import License",
|
||||
"ApiKeyList": "Api key list",
|
||||
"all": "All",
|
||||
"auto": "Auto"
|
||||
"DateCreated": "",
|
||||
"Create": ""
|
||||
},
|
||||
"settings": {
|
||||
"setting": ""
|
||||
@@ -728,10 +724,6 @@
|
||||
"ResetAndDownloadSSHKey": "Reset and download SSH Key"
|
||||
},
|
||||
"xpack": {
|
||||
"Vault": {
|
||||
"Vault": "Vault",
|
||||
"Create": "Create"
|
||||
},
|
||||
"Admin": "Admin",
|
||||
"AssetCount": "Asset count",
|
||||
"Auditor": "Auditor",
|
||||
|
@@ -5,6 +5,7 @@
|
||||
<div v-show="iShowTree" :style="iShowTree?('width:250px;'):('width:0;')" class="transition-box">
|
||||
<AutoDataZTree
|
||||
ref="AutoDataZTree"
|
||||
:key="DataZTree"
|
||||
:setting="treeSetting"
|
||||
class="auto-data-ztree"
|
||||
/>
|
||||
@@ -58,6 +59,7 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
DataZTree: 0,
|
||||
codeMirrorOptions: {
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
@@ -135,7 +137,7 @@ export default {
|
||||
},
|
||||
handleSystemUserChange(id) {
|
||||
this.treeSetting.treeUrl = `${this.basicUrl}&system_user=${id}`
|
||||
this.$refs.AutoDataZTree.$refs.dataztree.$refs.ztree.initTree()
|
||||
this.DataZTree++
|
||||
},
|
||||
getSelectedAssetsNode() {
|
||||
const nodes = this.zTree.getCheckedNodes(true)
|
||||
@@ -169,15 +171,11 @@ export default {
|
||||
const port = document.location.port ? ':' + document.location.port : ''
|
||||
const url = '/ws/ops/tasks/log/'
|
||||
const wsURL = scheme + '://' + document.location.hostname + port + url
|
||||
const failOverPort = '8070'
|
||||
const failOverWsURL = scheme + '://' + document.location.hostname + ':' + failOverPort + url
|
||||
// const failOverPort = '8070'
|
||||
// const failOverWsURL = scheme + '://' + document.location.hostname + ':' + failOverPort + url
|
||||
this.ws = new WebSocket(wsURL)
|
||||
this.ws.onerror = (e) => {
|
||||
this.ws = new WebSocket(failOverWsURL)
|
||||
this.setWsCallback()
|
||||
this.ws.onerror = (e) => {
|
||||
this.xterm.write(this.wrapperError('Connect websocket server error'))
|
||||
}
|
||||
this.xterm.write(this.wrapperError('Connect websocket server error'))
|
||||
}
|
||||
this.setWsCallback()
|
||||
},
|
||||
@@ -188,28 +186,45 @@ export default {
|
||||
}
|
||||
},
|
||||
wrapperError(msg) {
|
||||
return '\\033[31m' + msg + '\\033[0m\r\n'
|
||||
return `\r\n${msg}\r\n`
|
||||
},
|
||||
writeExecutionOutput(taskId) {
|
||||
let msg = this.$t('assets.Pending')
|
||||
this.xterm.write(msg)
|
||||
msg = JSON.stringify({ task: taskId })
|
||||
this.ws.send(msg)
|
||||
},
|
||||
execute() {
|
||||
// const size = 'rows=' + this.xterm.rows + '&cols=' + this.xterm.cols
|
||||
// const url = '{% url "api-ops:command-execution-list" %}?' + size
|
||||
const size = 'rows=' + this.xterm.rows + '&cols=' + this.xterm.cols
|
||||
const url = '/api/v1/ops/command-executions/?' + size
|
||||
const runAs = this.selectedSystemUser
|
||||
// const command = editor.getValue()
|
||||
const command = this.actions
|
||||
const hosts = this.getSelectedAssetsNode().map(function(node) {
|
||||
return node.id
|
||||
})
|
||||
if (hosts.length === 0) {
|
||||
this.xterm.write(this.wrapperError("{% trans 'Unselected assets' %}"))
|
||||
this.xterm.write(this.wrapperError(this.$t('assets.UnselectedAssets')))
|
||||
return
|
||||
}
|
||||
if (!command) {
|
||||
this.xterm.write(this.wrapperError(this.$t('assets.NoInputCommand')))
|
||||
return
|
||||
}
|
||||
// if (!command) {
|
||||
// this.xterm.write(this.wrapperError("{% trans 'No input command' %}"))
|
||||
// return
|
||||
// }
|
||||
if (!runAs) {
|
||||
this.xterm.write(this.wrapperError("{% trans 'No system user was selected' %}"))
|
||||
this.xterm.write(this.wrapperError(this.$t('assets.NoSystemUserWasSelected')))
|
||||
return
|
||||
}
|
||||
const data = {
|
||||
hosts: hosts,
|
||||
run_as: runAs,
|
||||
command: command
|
||||
}
|
||||
this.$axios.post(
|
||||
url, data
|
||||
).then(res => {
|
||||
this.writeExecutionOutput(res.id)
|
||||
console.log('success')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user