perf: change secret

This commit is contained in:
feng 2022-11-11 19:06:27 +08:00
parent fc08f54394
commit 057bb73405
9 changed files with 61 additions and 81 deletions

View File

@ -31,7 +31,7 @@ export default {
data() {
return {
tableConfig: {
url: `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/assets/`,
url: `/api/v1/assets/automation/${this.object.id}/assets/`,
columns: [
'name', 'ip', 'delete_action'
],
@ -51,7 +51,7 @@ export default {
formatter: DeleteActionFormatter,
onDelete: function(col, row, cellValue, reload) {
this.$axios.patch(
`/api/v1/xpack/change-auth-plan/plan/${this.object.id}/asset/remove/`,
`/api/v1/assets/automation/${this.object.id}/asset/remove/`,
{ assets: [row.id] }
).then(res => {
this.$message.success(this.$t('common.deleteSuccessMsg'))
@ -84,7 +84,7 @@ export default {
return this.object.assets.indexOf(row.id) === -1
},
performAdd: (items, that) => {
const relationUrl = `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/asset/add/`
const relationUrl = `/api/v1/assets/automation/${this.object.id}/asset/add/`
const data = {
assets: items
}
@ -108,7 +108,7 @@ export default {
disabled: this.$store.getters.currentOrgIsRoot,
hasObjectsId: this.object.nodes,
performAdd: (items, that) => {
const relationUrl = `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/nodes/?action=add`
const relationUrl = `/api/v1/assets/automation/${this.object.id}/nodes/?action=add`
const nodes = items.map(v => v.value)
const iHasObjects = that.iHasObjects.map(v => v.value)
const data = {
@ -126,7 +126,7 @@ export default {
const data = {
nodes: [item.value]
}
const relationUrl = `/api/v1/xpack/change-auth-plan/plan/${this.object.id}/nodes/?action=remove`
const relationUrl = `/api/v1/assets/automation/${this.object.id}/nodes/?action=remove`
return this.$axios.patch(relationUrl, data)
},
onDeleteSuccess: (obj, that) => {

View File

@ -28,25 +28,17 @@ export default {
computed: {
detailItems() {
return [
{
key: this.$t('xpack.ChangeAuthPlan.Username'),
value: this.object.username
},
{
key: this.$t('xpack.ChangeAuthPlan.AssetAmount'),
value: this.object.assets_amount
value: this.object.snapshot.asset_amount
},
{
key: this.$t('xpack.ChangeAuthPlan.NodeAmount'),
value: this.object.nodes_amount
value: this.object.snapshot.node_amount
},
{
key: this.$t('xpack.ChangeAuthPlan.PasswordStrategy'),
value: this.object.password_strategy_display
},
{
key: this.$t('xpack.ChangeAuthPlan.TimeDelta'),
value: this.object.timedelta.toFixed(2) + 's'
value: this.object.trigger_display
},
{
key: this.$t('xpack.ChangeAuthPlan.DateStart'),

View File

@ -19,12 +19,11 @@ export default {
}
},
data() {
const vm = this
return {
tableConfig: {
url: `/api/v1/assets/change-secret-records/?execution_id=${this.object.id}`,
columns: [
'username', 'asset', 'is_success', 'timedelta', 'date_start', 'reason_display', 'actions'
'asset', 'account', 'date_started', 'date_finished', 'status', 'error'
],
columnsMeta: {
asset: {
@ -33,12 +32,28 @@ export default {
formatterArgs: {
can: this.$hasPerm('assets.view_asset'),
getTitle({ row }) {
return row.asset_info.name
return row.asset.name
},
getRoute({ row }) {
return {
name: 'AssetDetail',
params: { id: row.asset }
params: { id: row.asset.id }
}
}
}
},
account: {
label: this.$t('users.Username'),
formatter: DetailFormatter,
formatterArgs: {
can: this.$hasPerm('assets.view_account'),
getTitle({ row }) {
return row.account.name
},
getRoute({ row }) {
return {
name: 'AssetDetail',
params: { id: row.account.id }
}
}
}
@ -55,28 +70,6 @@ export default {
},
reason_display: {
label: this.$t('xpack.AccountBackupPlan.Reason')
},
actions: {
formatterArgs: {
hasDelete: false,
hasUpdate: false,
hasClone: false,
extraActions: [
{
name: 'retry',
type: 'info',
title: this.$t('xpack.ChangeAuthPlan.Retry'),
can: vm.$hasPerm('xpack.change_changeauthplantask'),
callback: function({ row, tableData }) {
this.$axios.put(
`/api/v1/assets/change-secret-records/${row.id}/`,
).then(res => {
window.open(`/#/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
})
}.bind(this)
}
]
}
}
}
},

View File

@ -21,6 +21,7 @@ export default {
return {
execution: { id: '' },
config: {
url: '/api/v1/assets/automation-executions/',
activeMenu: 'ChangeAuthPlanExecutionInfo',
actions: {
hasUpdate: false,
@ -30,12 +31,12 @@ export default {
{
title: this.$t('common.BasicInfo'),
name: 'ChangeAuthPlanExecutionInfo',
hidden: () => !this.$hasPerm('xpack.view_changeauthplanexecution')
hidden: () => !this.$hasPerm('assets.view_automationexecution')
},
{
title: this.$t('xpack.ChangeAuthPlan.TaskList'),
name: 'ChangeAuthPlanExecutionTaskList',
hidden: () => !this.$hasPerm('xpack.view_changeauthplantask')
hidden: () => !this.$hasPerm('assets.view_changesecretrecord')
}
],
getTitle: this.getExecutionTitle

View File

@ -18,41 +18,32 @@ export default {
}
},
data() {
console.log('this', this)
return {
tableConfig: {
url: `/api/v1/xpack/change-auth-plan/plan-execution/?plan_id=${this.object.id}`,
url: `/api/v1/assets/automation-executions/?automation_id=${this.object.id}`,
columns: [
'username', 'assets_amount', 'nodes_amount', 'result_summary', 'password_strategy_display',
'timedelta', 'trigger_display', 'date_start', 'actions'
'asset_amount', 'node_amount', 'status',
'trigger_display', 'date_start', 'actions'
],
columnsMeta: {
username: {
label: this.$t('xpack.ChangeAuthPlan.Username')
},
assets_amount: {
asset_amount: {
label: this.$t('xpack.ChangeAuthPlan.AssetAmount'),
width: '80px'
},
nodes_amount: {
label: this.$t('xpack.ChangeAuthPlan.NodeAmount'),
width: '80px'
},
result_summary: {
label: this.$t('xpack.ChangeAuthPlan.Result'),
width: '80px',
showOverflowTooltip: true,
formatter: function(row) {
const summary = <div>
<span class='text-primary'>{row.result_summary.succeed}</span>/
<span class='text-danger'>{row.result_summary.failed}</span>/
<span>{row.result_summary.total}</span>
</div>
return summary
return <span>{ row.snapshot.asset_amount }</span>
}
},
password_strategy_display: {
label: this.$t('xpack.ChangeAuthPlan.PasswordStrategy'),
width: '220px',
node_amount: {
label: this.$t('xpack.ChangeAuthPlan.NodeAmount'),
width: '80px',
formatter: function(row) {
return <span>{ row.snapshot.node_amount }</span>
}
},
status: {
label: this.$t('xpack.ChangeAuthPlan.Result'),
width: '80px',
showOverflowTooltip: true
},
timedelta: {

View File

@ -34,12 +34,12 @@ export default {
attrs: {
type: 'primary',
label: this.$t('xpack.ChangeAuthPlan.Execute'),
disabled: !this.$hasPerm('xpack.add_changeauthplanexecution')
disabled: !this.$hasPerm('assets.add_automationexecution')
},
callbacks: {
click: function() {
this.$axios.post(
`/api/v1/xpack/change-auth-plan/plan-execution/`,
`/api/v1/assets/automation-executions/`,
{ plan: this.object.id }
).then(res => {
window.open(`/#/ops/celery/task/${res.task}/log/`, '_blank', 'toolbar=yes, width=900, height=600')
@ -59,19 +59,19 @@ export default {
},
{
key: this.$t('xpack.ChangeAuthPlan.Username'),
value: this.object.username
value: this.object.accounts.join(', ')
},
{
key: this.$t('xpack.ChangeAuthPlan.AssetAmount'),
value: this.object.assets_amount
value: this.object.assets.length
},
{
key: this.$t('xpack.ChangeAuthPlan.NodeAmount'),
value: this.object.nodes_amount
value: this.object.nodes.length
},
{
key: this.$t('xpack.ChangeAuthPlan.PasswordStrategy'),
value: this.object.password_strategy_display
value: this.object.secret_strategy.label
},
{
key: this.$t('xpack.ChangeAuthPlan.RegularlyPerform'),

View File

@ -24,21 +24,22 @@ export default {
plan: { name: '', username: '', comment: '' },
config: {
activeMenu: 'ChangeAuthPlanInfo',
url: '/api/v1/assets/change-secret-automations/',
submenu: [
{
title: this.$t('common.BasicInfo'),
name: 'ChangeAuthPlanInfo',
hidden: () => !this.$hasPerm('xpack.view_changeauthplan')
hidden: () => !this.$hasPerm('assets.view_changesecretautomation')
},
{
title: this.$t('xpack.ChangeAuthPlan.AssetAndNode'),
name: 'ChangeAuthPlanAsset',
hidden: () => !this.$hasPerm('xpack.change_changeauthplan')
hidden: () => !this.$hasPerm('assets.change_changesecretautomation')
},
{
title: this.$t('xpack.ChangeAuthPlan.ExecutionList'),
name: 'ChangeAuthPlanExecutionList',
hidden: () => !this.$hasPerm('xpack.view_changeauthplanexecution')
hidden: () => !this.$hasPerm('assets.view_automationexecution')
}
]
}

View File

@ -92,7 +92,10 @@ export default {
callback: function({ row }) {
this.$axios.post(
`/api/v1/assets/automation-executions/`,
{ plan: row.id }
{
automation: row.id,
type: row.type
}
).then(res => {
openTaskPage(res['task'])
})

View File

@ -126,8 +126,7 @@ export const getFields = () => {
},
accounts: {
label: i18n.t('common.Username'),
component: TagInput,
helpText: i18n.t('xpack.ChangeAuthPlan.HelpText.UsernameOfCreateUpdatePage')
component: TagInput
},
secret: {
hidden: ({ secret_strategy, secret_type }) => (secret_strategy !== 'specific' || secret_type !== 'password')