mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-19 09:43:32 +00:00
feat: 支持设置默认存储
This commit is contained in:
@@ -57,6 +57,26 @@ export function TestReplayStorage(id) {
|
||||
})
|
||||
}
|
||||
|
||||
function SetToDefaultStorage(url) {
|
||||
return request({
|
||||
url: url,
|
||||
method: 'patch',
|
||||
data: { 'is_default': true }
|
||||
})
|
||||
}
|
||||
|
||||
export function SetToDefaultCommandStorage(id) {
|
||||
return SetToDefaultStorage(
|
||||
`/api/v1/terminal/command-storages/${id}/`,
|
||||
)
|
||||
}
|
||||
|
||||
export function SetToDefaultReplayStorage(id) {
|
||||
return SetToDefaultStorage(
|
||||
`/api/v1/terminal/replay-storages/${id}/`,
|
||||
)
|
||||
}
|
||||
|
||||
export function getReplayStorage(id) {
|
||||
return request({
|
||||
url: `/api/v1/terminal/replay-storages/${id}/`,
|
||||
|
@@ -663,6 +663,9 @@
|
||||
"SiteMessageList": "站内信"
|
||||
},
|
||||
"sessions": {
|
||||
"SetToDefault": "设为默认",
|
||||
"SetSuccess": "设置成功",
|
||||
"SetFailed": "设置失败",
|
||||
"StorageConfiguration": "存储配置",
|
||||
"accountKey": "账户密钥",
|
||||
"accountName": "账户名称",
|
||||
|
@@ -661,6 +661,9 @@
|
||||
"SiteMessageList": "Site message"
|
||||
},
|
||||
"sessions": {
|
||||
"SetToDefault": "Set to default",
|
||||
"SetSuccess": "Set success",
|
||||
"SetFailed": "Set failed",
|
||||
"StorageConfiguration": "Storage configuration",
|
||||
"accountKey": "Account key",
|
||||
"accountName": "Account name",
|
||||
|
@@ -1,10 +1,11 @@
|
||||
<template>
|
||||
<ListTable :table-config="commandTableConfig" :header-actions="commandActions" />
|
||||
<ListTable ref="ListTable" :table-config="commandTableConfig" :header-actions="commandActions" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable'
|
||||
import { TestCommandStorage } from '@/api/sessions'
|
||||
import { SetToDefaultCommandStorage, TestCommandStorage } from '@/api/sessions'
|
||||
import { BooleanFormatter } from '@/components/TableFormatters'
|
||||
export default {
|
||||
name: 'CommandStorage',
|
||||
components: {
|
||||
@@ -17,11 +18,12 @@ export default {
|
||||
}
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
commandActions: {
|
||||
hasExport: false,
|
||||
hasImport: false,
|
||||
hasRefresh: false,
|
||||
hasRefresh: true,
|
||||
hasMoreActions: false,
|
||||
moreCreates: {
|
||||
callback: (item) => {
|
||||
@@ -38,7 +40,7 @@ export default {
|
||||
commandTableConfig: {
|
||||
title: 'command',
|
||||
url: '/api/v1/terminal/command-storages/',
|
||||
columns: ['name', 'type', 'comment', 'actions'],
|
||||
columns: ['name', 'type', 'comment', 'is_default', 'actions'],
|
||||
columnsMeta: {
|
||||
comment: {
|
||||
sortable: 'custom'
|
||||
@@ -53,6 +55,17 @@ export default {
|
||||
return row.type
|
||||
}
|
||||
},
|
||||
is_default: {
|
||||
formatter: BooleanFormatter,
|
||||
formatterArgs: {
|
||||
iconChoices: {
|
||||
true: 'fa-check text-primary',
|
||||
false: ''
|
||||
}
|
||||
},
|
||||
align: 'center',
|
||||
width: '100px'
|
||||
},
|
||||
actions: {
|
||||
prop: 'id',
|
||||
formatterArgs: {
|
||||
@@ -79,6 +92,19 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'set_to_default',
|
||||
title: this.$t('sessions.SetToDefault'),
|
||||
type: 'primary',
|
||||
callback: function({ row, col, cellValue, reload }) {
|
||||
SetToDefaultCommandStorage(row.id).then(data => {
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
this.$message.success(this.$t('sessions.SetSuccess'))
|
||||
}).catch(() => {
|
||||
this.$message.error(this.$t('sessions.SetFailed'))
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -1,20 +1,22 @@
|
||||
<template>
|
||||
<ListTable :table-config="replayTableConfig" :header-actions="replayActions" />
|
||||
<ListTable ref="ListTable" :table-config="replayTableConfig" :header-actions="replayActions" />
|
||||
</template>
|
||||
<script>
|
||||
import ListTable from '@/components/ListTable'
|
||||
import { TestReplayStorage } from '@/api/sessions'
|
||||
import { TestReplayStorage, SetToDefaultReplayStorage } from '@/api/sessions'
|
||||
import { BooleanFormatter } from '@/components/TableFormatters'
|
||||
export default {
|
||||
name: 'ReplayStorage',
|
||||
components: {
|
||||
ListTable
|
||||
},
|
||||
data() {
|
||||
const vm = this
|
||||
return {
|
||||
replayActions: {
|
||||
hasExport: false,
|
||||
hasImport: false,
|
||||
hasRefresh: false,
|
||||
hasRefresh: true,
|
||||
hasMoreActions: false,
|
||||
moreCreates: {
|
||||
callback: (item) => {
|
||||
@@ -46,7 +48,7 @@ export default {
|
||||
},
|
||||
replayTableConfig: {
|
||||
url: '/api/v1/terminal/replay-storages/',
|
||||
columns: ['name', 'type', 'comment', 'actions'],
|
||||
columns: ['name', 'type', 'comment', 'is_default', 'actions'],
|
||||
columnsMeta: {
|
||||
name: {
|
||||
formatter: function(row) {
|
||||
@@ -58,6 +60,17 @@ export default {
|
||||
return row.type
|
||||
}
|
||||
},
|
||||
is_default: {
|
||||
formatter: BooleanFormatter,
|
||||
formatterArgs: {
|
||||
iconChoices: {
|
||||
true: 'fa-check text-primary',
|
||||
false: ''
|
||||
}
|
||||
},
|
||||
align: 'center',
|
||||
width: '100px'
|
||||
},
|
||||
comment: {
|
||||
sortable: 'custom'
|
||||
},
|
||||
@@ -87,6 +100,19 @@ export default {
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'set_to_default',
|
||||
title: this.$t('sessions.SetToDefault'),
|
||||
type: 'primary',
|
||||
callback: function({ row, col, cellValue, reload }) {
|
||||
SetToDefaultReplayStorage(row.id).then(data => {
|
||||
vm.$refs.ListTable.reloadTable()
|
||||
this.$message.success(this.$t('sessions.SetSuccess'))
|
||||
}).catch(() => {
|
||||
this.$message.error(this.$t('sessions.SetFailed'))
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Reference in New Issue
Block a user