mirror of
https://github.com/jumpserver/lina.git
synced 2026-01-29 21:28:52 +00:00
merge: with origin
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
},
|
||||
"assets": {
|
||||
"Action": "动作",
|
||||
"CmdFilter": "命令过滤器",
|
||||
"UpdateAssetUserToken": "更新资产用户认证信息",
|
||||
"Password": "密码",
|
||||
"RefreshHardware": "更新硬件信息",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
},
|
||||
"assets": {
|
||||
"Action": "Action",
|
||||
"CmdFilter": "CmdFilter",
|
||||
"UpdateAssetUserToken": "Update asset user auth",
|
||||
"Password": "Password",
|
||||
"RefreshHardware": "Refresh hardware",
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
<template>
|
||||
<Dialog width="70%" class="api-key-dialog" :visible.sync="showDialog" :title="this.$t('setting.ApiKeyList')" :show-cancel="false" :show-confirm="false">
|
||||
<div>
|
||||
<el-alert type="success"> {{ helpMessage }} </el-alert>
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</div>
|
||||
</Dialog>
|
||||
<div>
|
||||
<Dialog width="45%" :visible.sync="showDialog" :title="this.$t('setting.ApiKeyList')" :show-cancel="false" :show-confirm="false">
|
||||
<div>
|
||||
<el-alert type="success"> {{ helpMessage }} </el-alert>
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -25,15 +27,24 @@ export default {
|
||||
showDialog: false,
|
||||
helpMessage: this.$t('setting.helpText.ApiKeyList'),
|
||||
tableConfig: {
|
||||
hasSelection: true,
|
||||
url: `/api/v1/authentication/access-keys/`,
|
||||
columns: [
|
||||
'id', 'secret', 'is_active', 'date_created', 'actions'
|
||||
'id_display', 'secret', 'is_active', 'date_created', 'actions'
|
||||
],
|
||||
hasSelection: false,
|
||||
columnsMeta: {
|
||||
id_display: {
|
||||
label: 'ID',
|
||||
width: '315px'
|
||||
},
|
||||
secret: {
|
||||
label: '密文',
|
||||
width: '315px',
|
||||
formatter: ShowKeyFormatter
|
||||
},
|
||||
is_active: {
|
||||
width: '80px'
|
||||
},
|
||||
date_created: {
|
||||
label: this.$t('setting.DateCreated'),
|
||||
formatter: DateFormatter
|
||||
@@ -66,12 +77,12 @@ export default {
|
||||
}
|
||||
},
|
||||
headerActions: {
|
||||
hasSearch: true,
|
||||
hasRightActions: false,
|
||||
hasExport: false,
|
||||
hasImport: false,
|
||||
hasRefresh: true,
|
||||
hasBulkDelete: false,
|
||||
hasSearch: false,
|
||||
hasCreate: false,
|
||||
extraActions: [
|
||||
{
|
||||
@@ -79,7 +90,7 @@ export default {
|
||||
title: this.$t('setting.Create'),
|
||||
type: 'primary',
|
||||
can: true,
|
||||
callback: () => {
|
||||
callback: function() {
|
||||
this.$axios.post(
|
||||
`/api/v1/authentication/access-keys/`
|
||||
).then(res => {
|
||||
@@ -87,8 +98,8 @@ export default {
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
}).catch(error => {
|
||||
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + error))
|
||||
}).bind(this)
|
||||
}
|
||||
})
|
||||
}.bind(this)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<script>
|
||||
import GenericCreateUpdatePage from '@/layout/components/GenericCreateUpdatePage'
|
||||
import select2 from '@/components/Select2'
|
||||
import UploadKey from '@/components/UploadKey'
|
||||
import { Select2 } from '@/components'
|
||||
export default {
|
||||
name: 'SystemUserCreateUpdate',
|
||||
components: { GenericCreateUpdatePage },
|
||||
@@ -71,9 +71,20 @@ export default {
|
||||
}
|
||||
},
|
||||
cmd_filters: {
|
||||
component: select2,
|
||||
component: Select2,
|
||||
el: {
|
||||
placeholder: '命令过滤器'
|
||||
multiple: true,
|
||||
value: [],
|
||||
ajax: {
|
||||
url: '/api/v1/assets/cmd-filters/',
|
||||
processResults(data) {
|
||||
const results = data.results.map((item) => {
|
||||
return { label: item.name, value: item.id }
|
||||
})
|
||||
const more = !!data.next
|
||||
return { results: results, pagination: more, total: data.count }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
priority: {
|
||||
|
||||
@@ -1,13 +1,31 @@
|
||||
<template>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="14">
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<QuickActions type="primary" :actions="quickActions" />
|
||||
<RelationCard type="info" style="margin-top: 15px" v-bind="nodeReletionConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="14">
|
||||
<ListTable ref="ListTable" :table-config="tableConfig" :header-actions="headerActions" />
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<QuickActions type="primary" :actions="quickActions" />
|
||||
<RelationCard type="info" style="margin-top: 15px" v-bind="nodeReletionConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
<Dialog width="50" :title="this.$t('assets.UpdateAssetUserToken')" :visible.sync="showDialog" @confirm="handleConfirm()" @cancel="handleCancel()">
|
||||
<el-form label-position="right" label-width="80px" :model="dialogInfo">
|
||||
<el-form-item :label="this.$t('assets.Hostname')">
|
||||
<el-input v-model="dialogInfo.hostname" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item :label="this.$t('assets.Username')">
|
||||
<el-input v-model="dialogInfo.username" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item :label="this.$t('assets.Password')">
|
||||
<el-input v-model="dialogInfo.password" type="password" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="this.$t('assets.sshkey')">
|
||||
<input type="file" @change="Onchange">
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</Dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -15,13 +33,15 @@ import ListTable from '@/components/ListTable/index'
|
||||
import { CustomActionsFormatter, DateFormatter } from '@/components/ListTable/formatters'
|
||||
import QuickActions from '@/components/QuickActions/index'
|
||||
import RelationCard from '@/components/RelationCard'
|
||||
import Dialog from '@/components/Dialog'
|
||||
|
||||
export default {
|
||||
name: 'Detail',
|
||||
components: {
|
||||
QuickActions,
|
||||
ListTable,
|
||||
RelationCard
|
||||
RelationCard,
|
||||
Dialog
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
@@ -31,6 +51,14 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showDialog: false,
|
||||
dialogInfo: {
|
||||
asset: '',
|
||||
username: '',
|
||||
hostname: '',
|
||||
password: '',
|
||||
key: ''
|
||||
},
|
||||
AutoPushConfig: {
|
||||
icon: 'fa-info',
|
||||
title: this.$t('assets.QuickUpdate'),
|
||||
@@ -87,24 +115,6 @@ export default {
|
||||
)
|
||||
}.bind(this)
|
||||
}
|
||||
},
|
||||
{
|
||||
title: this.$t('assets.PushSystemUserNow'),
|
||||
attrs: {
|
||||
type: 'primary',
|
||||
label: this.$t('assets.Push')
|
||||
},
|
||||
callbacks: {
|
||||
click: function() {
|
||||
this.$axios.post(
|
||||
`api/v1/assets/system-users/${this.object.id}/tasks/`,
|
||||
{ action: 'push' }
|
||||
).then(res => {
|
||||
window.open(`/ops/celery/task/${res.task}/log/`, '', 'width=900,height=600')
|
||||
}
|
||||
)
|
||||
}.bind(this)
|
||||
}
|
||||
}
|
||||
],
|
||||
tableConfig: {
|
||||
@@ -148,16 +158,33 @@ export default {
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'Test',
|
||||
name: this.$t('common.Test'),
|
||||
title: this.$t('common.Test'),
|
||||
callback: (val) => {
|
||||
console.log('Test')
|
||||
console.log(val.cellValue)
|
||||
this.$axios.post(
|
||||
`api/v1/assets/asset-users/tasks/?id=${val.cellValue}`,
|
||||
{ action: 'test' }
|
||||
).then(res => {
|
||||
window.open(`/ops/celery/task/${res.task}/log/`, '', 'width=900,height=600')
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: this.$t('common.Update'),
|
||||
title: this.$t('common.Update'),
|
||||
callback: function(val) {
|
||||
console.log(val)
|
||||
this.showDialog = true
|
||||
this.dialogInfo.asset = val.row.asset
|
||||
this.dialogInfo.hostname = val.row.hostname
|
||||
this.dialogInfo.username = val.row.username
|
||||
}.bind(this)
|
||||
},
|
||||
{
|
||||
name: 'Push',
|
||||
title: this.$t('common.Push'),
|
||||
callback: (val) => {
|
||||
callback: function(val) {
|
||||
console.log('Push')
|
||||
}
|
||||
}
|
||||
@@ -240,6 +267,55 @@ export default {
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
handleCancel() {
|
||||
this.dialogInfo = {
|
||||
asset: '',
|
||||
username: '',
|
||||
hostname: '',
|
||||
password: '',
|
||||
key: ''
|
||||
}
|
||||
this.showDialog = false
|
||||
},
|
||||
Onchange(e) {
|
||||
const vm = this
|
||||
// TODO 校验文件类型
|
||||
const reader = new FileReader()
|
||||
reader.onload = function() {
|
||||
vm.dialogInfo.key = this.result
|
||||
}
|
||||
reader.readAsText(
|
||||
e.target.files[0]
|
||||
)
|
||||
},
|
||||
handleConfirm() {
|
||||
const data = {
|
||||
asset: this.dialogInfo.asset,
|
||||
username: this.dialogInfo.username
|
||||
}
|
||||
if (this.dialogInfo.password !== '') {
|
||||
data.password = this.dialogInfo.password
|
||||
}
|
||||
if (this.dialogInfo.key !== '') {
|
||||
data.key = this.dialogInfo.key
|
||||
}
|
||||
this.$axios.post(
|
||||
`/api/v1/assets/asset-users/`,
|
||||
data
|
||||
).then(res => {
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
}).catch(err => {
|
||||
this.$message.error(this.$t('common.updateErrorMsg' + ' ' + err))
|
||||
})
|
||||
this.dialogInfo = {
|
||||
asset: '',
|
||||
username: '',
|
||||
hostname: '',
|
||||
password: '',
|
||||
key: ''
|
||||
}
|
||||
this.showDialog = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
<AutoPushCard v-bind="AutoPushConfig" />
|
||||
<RelationCard v-if="object.protocol === 'ssh'" ref="RelationCard" type="info" style="margin-top: 15px" v-bind="nodeRelationConfig" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>a
|
||||
@@ -12,12 +13,14 @@
|
||||
<script>
|
||||
import DetailCard from '@/components/DetailCard'
|
||||
import AutoPushCard from './AutoPushCard'
|
||||
import RelationCard from '@/components/RelationCard/index'
|
||||
|
||||
export default {
|
||||
name: 'Detail',
|
||||
components: {
|
||||
DetailCard,
|
||||
AutoPushCard
|
||||
AutoPushCard,
|
||||
RelationCard
|
||||
},
|
||||
props: {
|
||||
object: {
|
||||
@@ -37,6 +40,56 @@ export default {
|
||||
auto_push: this.object.auto_push
|
||||
}
|
||||
]
|
||||
},
|
||||
nodeRelationConfig: {
|
||||
icon: 'fa-info',
|
||||
hasObjectsId: this.object.cmd_filters,
|
||||
title: this.$t('assets.CmdFilter'),
|
||||
objectsAjax: {
|
||||
url: '/api/v1/assets/cmd-filters/',
|
||||
processResults(data) {
|
||||
let results = data.results
|
||||
results = results.map((item) => {
|
||||
return { label: item.name, value: item.id }
|
||||
})
|
||||
const more = !!data.next
|
||||
return { results: results, pagination: more, total: data.count }
|
||||
}
|
||||
},
|
||||
performAdd: (items) => {
|
||||
const objectId = this.object.id
|
||||
const relationUrl = `/api/v1/assets/system-users/${objectId}/`
|
||||
const objectOldRelationCmdFilters = this.object.cmd_filters
|
||||
items.map(v => objectOldRelationCmdFilters.push(v.value))
|
||||
const data = { cmd_filters: objectOldRelationCmdFilters }
|
||||
return this.$axios.patch(relationUrl, data)
|
||||
},
|
||||
performDelete: (item) => {
|
||||
const objectId = this.object.id
|
||||
const relationUrl = `/api/v1/assets/system-users/${objectId}/`
|
||||
const objectOldRelationCmdFilters = this.object.cmd_filters
|
||||
const objectNewRelationCmdFilters = objectOldRelationCmdFilters.filter(v => v !== item.value)
|
||||
const data = { cmd_filters: objectNewRelationCmdFilters }
|
||||
return this.$axios.patch(relationUrl, data)
|
||||
},
|
||||
onAddSuccess: (objects, that) => {
|
||||
this.$log.debug('Select value', that.select2.value)
|
||||
that.iHasObjects = [...that.iHasObjects, ...objects]
|
||||
that.$refs.select2.clearSelected()
|
||||
this.$message.success(this.$t('common.updateSuccessMsg'))
|
||||
// setTimeout(() => location.reload(), 300)
|
||||
},
|
||||
onDeleteSuccess: (obj, that) => {
|
||||
const theRemoveIndex = that.iHasObjects.findIndex((v) => v.value === obj.value)
|
||||
that.iHasObjects.splice(theRemoveIndex, 1)
|
||||
while (that.select2.disabledValues.indexOf(obj.value) !== -1) {
|
||||
const i = that.select2.disabledValues.indexOf(obj.value)
|
||||
this.$log.debug('disabled values remove index: ', i)
|
||||
that.select2.disabledValues.splice(i, 1)
|
||||
}
|
||||
this.$message.success(this.$t('common.deleteSuccessMsg'))
|
||||
// setTimeout(() => location.reload(), 300)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user