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 ObjectRelatedFormatter
} from '@/components/TableFormatters' } from '@/components/TableFormatters'
import i18n from '@/i18n/i18n' import i18n from '@/i18n/i18n'
import { newURL } from '@/utils/common' import { newURL, replaceAllUUID } from '@/utils/common'
import ColumnSettingPopover from './components/ColumnSettingPopover' import ColumnSettingPopover from './components/ColumnSettingPopover'
export default { export default {
@@ -335,7 +335,8 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig') const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(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) const configShowColumnsNames = _.get(_tableConfig[tableName], 'showColumns', null)
let showColumnsNames = configShowColumnsNames || defaultColumnsNames let showColumnsNames = configShowColumnsNames || defaultColumnsNames
if (showColumnsNames.length === 0) { if (showColumnsNames.length === 0) {
@@ -383,7 +384,10 @@ export default {
const _tableConfig = localStorage.getItem('tableConfig') const _tableConfig = localStorage.getItem('tableConfig')
? JSON.parse(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] = { _tableConfig[tableName] = {
'showColumns': columns 'showColumns': columns
} }

View File

@@ -68,21 +68,39 @@ export default {
} }
let value = this.object[name] let value = this.object[name]
const label = fieldMeta.label
if (Array.isArray(value)) { if (Array.isArray(value)) {
value.forEach(item => { if (typeof value[0] === 'object') {
const fieldName = `${name}.${item.name}` value.forEach(item => {
if (excludes.includes(fieldName)) { const fieldName = `${name}.${item.name}`
return if (excludes.includes(fieldName)) {
} return
this.items.push({ }
key: item.label, this.items.push({
value: item.value key: item.label,
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 continue
} }
const label = fieldMeta.label
if (value === null || value === '') { if (value === null || value === '') {
value = '-' value = '-'
} else if (fieldMeta.type === 'datetime') { } else if (fieldMeta.type === 'datetime') {

View File

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

View File

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

View File

@@ -168,6 +168,13 @@ export function replaceUUID(s, n) {
return s.replace(uuidPattern, 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) { export function getDaysAgo(days, now) {
if (!now) { if (!now) {
now = new Date() now = new Date()

View File

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

View File

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

View File

@@ -80,7 +80,7 @@ export default {
updateProtocols() { updateProtocols() {
const url = `/api/v1/assets/platforms/${this.object.id}/` const url = `/api/v1/assets/platforms/${this.object.id}/`
this.$axios.patch(url, { protocols: this.object.protocols }).then(() => { 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() { async getTypeConstraints() {

View File

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

View File

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

View File

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

View File

@@ -38,26 +38,10 @@ export default {
key: this.$t('xpack.Organization.assets_amount'), key: this.$t('xpack.Organization.assets_amount'),
value: this.object.resource_statistics.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'), key: this.$t('xpack.Organization.asset_perms_amount'),
value: this.object.resource_statistics.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' 'date_created', 'comment'
] ]
} }

View File

@@ -26,11 +26,7 @@ export default {
'resource_statistics.users_amount', 'resource_statistics.users_amount',
'resource_statistics.groups_amount', 'resource_statistics.groups_amount',
'resource_statistics.assets_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.asset_perms_amount',
'resource_statistics.app_perms_amount',
'comment', 'actions'], 'comment', 'actions'],
columnsMeta: { columnsMeta: {
'resource_statistics.users_amount': { 'resource_statistics.users_amount': {
@@ -42,21 +38,9 @@ export default {
'resource_statistics.assets_amount': { 'resource_statistics.assets_amount': {
label: this.$t('xpack.Organization.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': { 'resource_statistics.asset_perms_amount': {
label: this.$t('xpack.Organization.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: { actions: {
prop: 'id', prop: 'id',
formatterArgs: { formatterArgs: {
@@ -76,6 +60,7 @@ export default {
instance.confirmButtonLoading = true instance.confirmButtonLoading = true
try { try {
await performDelete.bind(this)({ row: row, col: col }) await performDelete.bind(this)({ row: row, col: col })
this.$store.dispatch('users/deleteAdminOrg', { id: row.id, name: row.name })
done() done()
reload() reload()
this.$message.success(this.$tc('common.deleteSuccessMsg')) 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_gatheredaccount': ['assets.view_asset', 'assets.view_node'],
'accounts.view_account': ['assets.view_node'], 'accounts.view_account': ['assets.view_node'],
'accounts.view_accountsecret': ['accounts.view_account'], '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.view_accounttemplatesecret': ['accounts.view_accounttemplate'],
'accounts.change_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'], 'accounts.add_account': ['assets.view_asset'],
'assets.gathereduser': ['assets.view_node'], 'assets.gathereduser': ['assets.view_node'],
'assets.refresh_assethardwareinfo': ['assets.change_asset'], 'assets.refresh_assethardwareinfo': ['assets.change_asset'],
@@ -136,6 +136,8 @@ export default {
'terminal.view_status': ['settings.change_terminal'], 'terminal.view_status': ['settings.change_terminal'],
'terminal.view_task': ['settings.change_terminal'], 'terminal.view_task': ['settings.change_terminal'],
'terminal.view_terminal': ['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.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.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'], 'ops.add_job': ['assets.view_asset', 'assets.view_node', 'ops.view_adhoc', 'ops.view_playbook'],