merge: with dev

This commit is contained in:
ibuler
2023-02-21 14:20:22 +08:00
14 changed files with 65 additions and 66 deletions

View File

@@ -26,7 +26,7 @@ import {
ObjectRelatedFormatter
} from '@/components/TableFormatters'
import i18n from '@/i18n/i18n'
import { newURL } from '@/utils/common'
import { newURL, replaceAllUUID } from '@/utils/common'
import ColumnSettingPopover from './components/ColumnSettingPopover'
export default {
@@ -335,7 +335,8 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name + '_' + newURL(this.iConfig.url).pathname
let tableName = this.config.name || this.$route.name + '_' + newURL(this.iConfig.url).pathname
tableName = replaceAllUUID(tableName)
const configShowColumnsNames = _.get(_tableConfig[tableName], 'showColumns', null)
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
if (showColumnsNames.length === 0) {
@@ -383,7 +384,10 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(localStorage.getItem('tableConfig'))
: {}
const tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
let tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
// 替换url中的uuid避免同一个类型接口生成多个keylocalStorage中的数据无法共用
tableName = replaceAllUUID(tableName)
_tableConfig[tableName] = {
'showColumns': columns
}

View File

@@ -68,8 +68,10 @@ export default {
}
let value = this.object[name]
const label = fieldMeta.label
if (Array.isArray(value)) {
if (typeof value[0] === 'object') {
value.forEach(item => {
const fieldName = `${name}.${item.name}`
if (excludes.includes(fieldName)) {
@@ -80,9 +82,25 @@ export default {
value: item.value
})
})
} else if (typeof value[0] === 'string') {
value.forEach((item, index) => {
let data = {}
if (index === 0) {
data = {
key: label,
value: value[index]
}
} else {
data = {
key: '',
value: value[index]
}
}
this.items.push(data)
})
}
continue
}
const label = fieldMeta.label
if (value === null || value === '') {
value = '-'
} else if (fieldMeta.type === 'datetime') {

View File

@@ -61,8 +61,10 @@ const mutations = {
ADD_ORG: (state, org) => {
state.consoleOrgs.push(org)
},
DELETE_ORG: (state, org) => {
state.consoleOrgs = state.consoleOrgs.filter(i => i.id !== org.id)
},
SET_CURRENT_ORG(state, org) {
console.log('set pre org: ', state.currentOrg)
if (state.currentOrg?.name !== 'System') {
state.preOrg = state.currentOrg
}
@@ -103,6 +105,9 @@ const actions = {
addAdminOrg({ commit, state }, org) {
commit('ADD_ORG', org)
},
deleteAdminOrg({ commit }, org) {
commit('DELETE_ORG', org)
},
modifyOrg({ commit, state }, org) {
commit('MODIFY_ORG', org)
},

View File

@@ -200,6 +200,10 @@ input[type=file] {
overflow: auto;
}
.el-table .el-table__row > td > .cell.el-tooltip {
width: auto!important;
}
.el-table .el-table__row .show-full-content > .cell {
white-space: normal!important;
}

View File

@@ -168,6 +168,13 @@ export function replaceUUID(s, n) {
return s.replace(uuidPattern, n)
}
export function replaceAllUUID(string, replacement = '*') {
if (hasUUID(string)) {
string = string.replace(/[0-9a-zA-Z\-]{36}/g, replacement)
}
return string
}
export function getDaysAgo(days, now) {
if (!now) {
now = new Date()

View File

@@ -34,6 +34,7 @@ export default {
},
data() {
const meta = assetFieldsMeta(this)
const exclude = ['device', 'cloud', 'web']
return {
tips: this.$t('assets.AssetBulkUpdateTips'),
formSetting: {
@@ -49,7 +50,7 @@ export default {
domain: {
...meta.domain,
label: this.$t('assets.Domain'),
disabled: this.category === 'cloud'
disabled: exclude.includes(this.category)
},
labels: {
...meta.labels,

View File

@@ -70,6 +70,7 @@ export default {
if (action === 'Clone') {
route.query.clone_from = row.id
route.query.platform = row.platform.id
route.query.platform_type = row.type.value
} else if (action === 'Update') {
route.params.id = row.id
route.query.platform = row.platform.id
@@ -107,7 +108,6 @@ export default {
sortable: true
},
platform: {
width: '100px',
sortable: true
},
protocols: {

View File

@@ -80,7 +80,7 @@ export default {
updateProtocols() {
const url = `/api/v1/assets/platforms/${this.object.id}/`
this.$axios.patch(url, { protocols: this.object.protocols }).then(() => {
this.$message.success(this.$tc('common.UpdateSuccess'))
this.$message.success(this.$tc('common.updateSuccessMsg'))
})
},
async getTypeConstraints() {

View File

@@ -101,15 +101,7 @@ export default {
options: [
{
label: this.$t('audits.User'),
value: 'user__name'
},
{
label: this.$t('audits.Username'),
value: 'user__username'
},
{
label: this.$t('audits.SystemUserName'),
value: 'run_as__username'
value: 'creator__name'
}
]
}

View File

@@ -45,6 +45,7 @@ export default {
default: ['name', 'address', 'platform', 'accounts', 'actions'],
min: ['name', 'address', 'actions']
},
columns: ['name', 'address', 'platform', 'accounts', 'comment', 'actions'],
columnsMeta: {
name: {
prop: 'name',

View File

@@ -9,7 +9,6 @@
import GenericListPage from '@/layout/components/GenericListPage'
import { ActionsFormatter, DateFormatter } from '@/components/TableFormatters'
import JobRunDialog from '@/views/ops/Job/JobRunDialog'
import { mapGetters } from 'vuex'
import { openTaskPage } from '@/utils/jms'
export default {
@@ -80,7 +79,7 @@ export default {
formatter: ActionsFormatter,
formatterArgs: {
hasUpdate: true,
canUpdate: this.$hasPerm('ops.change_job'),
canUpdate: this.$hasPerm('ops.change_job') && !this.$store.getters.currentOrgIsRoot,
updateRoute: 'JobUpdate',
hasDelete: true,
canDelete: this.$hasPerm('ops.delete_job'),
@@ -89,7 +88,7 @@ export default {
{
title: this.$t('ops.Run'),
name: 'run',
can: this.$hasPerm('ops.add_jobexecution'),
can: this.$hasPerm('ops.add_jobexecution') && !this.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
const params = JSON.parse(row.parameters_define)
if (Object.keys(params).length > 0) {
@@ -133,9 +132,6 @@ export default {
}
}
},
computed: {
...mapGetters(['currentOrgIsRoot'])
},
methods: {
runJob(row, parameters) {
this.$axios.post('/api/v1/ops/job-executions/', {

View File

@@ -38,26 +38,10 @@ export default {
key: this.$t('xpack.Organization.assets_amount'),
value: this.object.resource_statistics.assets_amount
},
{
key: this.$t('xpack.Organization.admin_users_amount'),
value: this.object.resource_statistics.admin_users_amount
},
{
key: this.$t('xpack.Organization.system_users_amount'),
value: this.object.resource_statistics.system_users_amount
},
{
key: this.$t('xpack.Organization.applications_amount'),
value: this.object.resource_statistics.applications_amount
},
{
key: this.$t('xpack.Organization.asset_perms_amount'),
value: this.object.resource_statistics.asset_perms_amount
},
{
key: this.$t('xpack.Organization.app_perms_amount'),
value: this.object.resource_statistics.app_perms_amount
},
'date_created', 'comment'
]
}

View File

@@ -26,11 +26,7 @@ export default {
'resource_statistics.users_amount',
'resource_statistics.groups_amount',
'resource_statistics.assets_amount',
'resource_statistics.admin_users_amount',
'resource_statistics.system_users_amount',
'resource_statistics.applications_amount',
'resource_statistics.asset_perms_amount',
'resource_statistics.app_perms_amount',
'comment', 'actions'],
columnsMeta: {
'resource_statistics.users_amount': {
@@ -42,21 +38,9 @@ export default {
'resource_statistics.assets_amount': {
label: this.$t('xpack.Organization.assets_amount')
},
'resource_statistics.admin_users_amount': {
label: this.$t('xpack.Organization.admin_users_amount')
},
'resource_statistics.system_users_amount': {
label: this.$t('xpack.Organization.system_users_amount')
},
'resource_statistics.applications_amount': {
label: this.$t('xpack.Organization.applications_amount')
},
'resource_statistics.asset_perms_amount': {
label: this.$t('xpack.Organization.asset_perms_amount')
},
'resource_statistics.app_perms_amount': {
label: this.$t('xpack.Organization.app_perms_amount')
},
actions: {
prop: 'id',
formatterArgs: {
@@ -76,6 +60,7 @@ export default {
instance.confirmButtonLoading = true
try {
await performDelete.bind(this)({ row: row, col: col })
this.$store.dispatch('users/deleteAdminOrg', { id: row.id, name: row.name })
done()
reload()
this.$message.success(this.$tc('common.deleteSuccessMsg'))

View File

@@ -108,10 +108,10 @@ export default {
'accounts.view_gatheredaccount': ['assets.view_asset', 'assets.view_node'],
'accounts.view_account': ['assets.view_node'],
'accounts.view_accountsecret': ['accounts.view_account'],
'accounts.view_historyaccount': ['accounts.view_account'],
'accounts.view_historyaccount': ['accounts.view_account', 'accounts.view_accountsecret'],
'accounts.view_accounttemplatesecret': ['accounts.view_accounttemplate'],
'accounts.change_accounttemplatesecret': ['accounts.view_accounttemplate'],
'accounts.view_historyaccountsecret': ['accounts.view_account'],
'accounts.view_historyaccountsecret': ['accounts.view_account', 'accounts.view_accountsecret'],
'accounts.add_account': ['assets.view_asset'],
'assets.gathereduser': ['assets.view_node'],
'assets.refresh_assethardwareinfo': ['assets.change_asset'],
@@ -136,6 +136,8 @@ export default {
'terminal.view_status': ['settings.change_terminal'],
'terminal.view_task': ['settings.change_terminal'],
'terminal.view_terminal': ['settings.change_terminal'],
'terminal.add_applethost': ['assets.view_platform'],
'terminal.change_applethost': ['assets.view_platform'],
'ops.view_job': ['assets.view_asset', 'assets.view_node', 'ops.view_adhoc', 'ops.view_playbook'],
'ops.change_job': ['assets.view_asset', 'assets.view_node', 'ops.view_adhoc', 'ops.view_playbook'],
'ops.add_job': ['assets.view_asset', 'assets.view_node', 'ops.view_adhoc', 'ops.view_playbook'],