Compare commits

..

1 Commits

Author SHA1 Message Date
github-actions[bot]
2f8be1c398 perf: Update Dockerfile with new base image tag 2025-04-08 11:33:43 +00:00
127 changed files with 1224 additions and 2687 deletions

View File

@@ -1,4 +1,4 @@
FROM jumpserver/lina-base:20250508_085854 AS stage-build
FROM jumpserver/lina-base:20250408_112930 AS stage-build
ARG VERSION
ENV VERSION=$VERSION

View File

@@ -1,149 +1,148 @@
{
"name": "lina",
"version": "v4.0.0",
"description": "JumpServer Web UI",
"author": "JumpServer Team <support@lxware.hk>",
"license": "GPL-3.0-or-later",
"scripts": {
"dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
"serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
"build": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build",
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src",
"fix": "eslint --ext .js,.vue --fix src",
"test:unit": "jest --clearCache && vue-cli-service test:unit",
"test:ci": "npm run lint && npm run test:unit",
"svgo": "svgo -f src/icons/svg --config=src/icas/svgo.yml",
"vue-i18n-extract": "vue-i18n-extract",
"vue-i18n-report": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json'",
"vue-i18n-report-json": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json' -o /tmp/abc.json",
"vue-i18n-report-add-miss": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json' -a",
"diff-i18n": "python ./src/i18n/langs/i18n-util.py diff en ja zh_Hant",
"apply-i18n": "python ./src/i18n/langs/i18n-util.py apply en ja zh_Hant"
},
"dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@fontsource/open-sans": "^5.0.24",
"@traptitech/markdown-it-katex": "^3.6.0",
"@ztree/ztree_v3": "3.5.44",
"axios": "0.28.0",
"axios-retry": "^3.1.9",
"caniuse-lite": "^1.0.30001642",
"cron-parser": "^4.0.0",
"crypto-js": "^4.1.1",
"css-color-function": "^1.3.3",
"decimal.js": "^10.4.3",
"deepmerge": "^4.2.2",
"dompurify": "^3.1.6",
"echarts": "4.7.0",
"element-ui": "2.15.14",
"eslint-plugin-html": "^6.0.0",
"highlight.js": "^11.9.0",
"install": "^0.13.0",
"jquery": "^3.6.1",
"js-cookie": "2.2.0",
"jsencrypt": "^3.2.1",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"lodash": "^4.17.21",
"lodash.clonedeep": "^4.5.0",
"lodash.frompairs": "^4.0.1",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.includes": "^4.3.0",
"lodash.isempty": "^4.4.0",
"lodash.isequal": "^4.5.0",
"lodash.isplainobject": "^4.0.6",
"lodash.set": "^4.3.2",
"lodash.topairs": "^4.3.0",
"lodash.values": "^4.3.0",
"markdown-it": "^13.0.2",
"markdown-it-link-attributes": "^4.0.1",
"moment": "^2.29.4",
"moment-parseformat": "^4.0.0",
"normalize.css": "7.0.0",
"npm": "^7.8.0",
"nprogress": "0.2.0",
"path-to-regexp": "3.3.0",
"sortablejs": "^1.15.6",
"v-sanitize": "^0.0.13",
"vue": "2.6.10",
"vue-codemirror": "4.0.6",
"vue-cookie": "^1.1.4",
"vue-echarts": "^5.0.0-beta.0",
"vue-i18n": "^8.15.5",
"vue-json-editor": "^1.4.3",
"vue-markdown": "^2.2.4",
"vue-moment": "^4.1.0",
"vue-password-strength-meter": "^1.7.2",
"vue-router": "3.0.6",
"vue-select": "^3.9.5",
"vuejs-logger": "^1.5.4",
"vuex": "3.1.0",
"watermark-js-plus": "^1.5.8",
"xss": "^1.0.14",
"xterm": "^4.5.0",
"xterm-addon-fit": "^0.3.0",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@babel/core": "7.18.6",
"@babel/register": "7.0.0",
"@vue/cli-plugin-babel": "3.6.0",
"@vue/cli-plugin-eslint": "^3.9.1",
"@vue/cli-plugin-unit-jest": "3.6.3",
"@vue/cli-service": "3.6.0",
"@vue/test-utils": "1.0.0-beta.29",
"autoprefixer": "^9.5.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"chalk": "2.4.2",
"compression-webpack-plugin": "^6.1.1",
"connect": "3.6.6",
"deasync": "^0.1.29",
"element-theme-chalk": "^2.13.1",
"eslint": "^5.15.3",
"eslint-plugin-vue": "5.2.2",
"eslint-plugin-vue-i18n": "^0.3.0",
"github-markdown-css": "^5.1.0",
"html-webpack-plugin": "3.2.0",
"husky": "^4.2.3",
"less-loader": "^5.0.0",
"lint-staged": "^10.1.2",
"mockjs": "1.0.1-beta3",
"runjs": "^4.3.2",
"sass": "~1.32.6",
"sass-loader": "^7.1.0",
"script-ext-html-webpack-plugin": "2.1.3",
"script-loader": "0.7.2",
"serve-static": "^1.16.0",
"strip-ansi": "^7.1.0",
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.2",
"vue-i18n-extract": "^1.1.1",
"vue-template-compiler": "2.6.10"
},
"engines": {
"node": ">=8.9",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 4 versions",
"ie 11"
],
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,vue}": [
"eslint --fix"
]
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
"name": "lina",
"version": "v4.0.0",
"description": "JumpServer Web UI",
"author": "JumpServer Team <support@lxware.hk>",
"license": "GPL-3.0-or-later",
"scripts": {
"dev": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
"serve": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service serve",
"build": "NODE_OPTIONS=--openssl-legacy-provider vue-cli-service build",
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"preview": "node build/index.js --preview",
"lint": "eslint --ext .js,.vue src",
"fix": "eslint --ext .js,.vue --fix src",
"test:unit": "jest --clearCache && vue-cli-service test:unit",
"test:ci": "npm run lint && npm run test:unit",
"svgo": "svgo -f src/icons/svg --config=src/icas/svgo.yml",
"vue-i18n-extract": "vue-i18n-extract",
"vue-i18n-report": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json'",
"vue-i18n-report-json": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json' -o /tmp/abc.json",
"vue-i18n-report-add-miss": "vue-i18n-extract report -v './src/**/*.?(js|vue)' -l './src/i18n/langs/**/*.json' -a",
"diff-i18n": "python ./src/i18n/langs/i18n-util.py diff en ja zh_Hant",
"apply-i18n": "python ./src/i18n/langs/i18n-util.py apply en ja zh_Hant"
},
"dependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.13.12",
"@fontsource/open-sans": "^5.0.24",
"@traptitech/markdown-it-katex": "^3.6.0",
"@ztree/ztree_v3": "3.5.44",
"axios": "0.28.0",
"axios-retry": "^3.1.9",
"caniuse-lite": "^1.0.30001642",
"cron-parser": "^4.0.0",
"crypto-js": "^4.1.1",
"css-color-function": "^1.3.3",
"decimal.js": "^10.4.3",
"deepmerge": "^4.2.2",
"dompurify": "^3.1.6",
"echarts": "4.7.0",
"element-ui": "2.15.14",
"eslint-plugin-html": "^6.0.0",
"highlight.js": "^11.9.0",
"install": "^0.13.0",
"jquery": "^3.6.1",
"js-cookie": "2.2.0",
"jsencrypt": "^3.2.1",
"less": "^3.10.3",
"less-loader": "^5.0.0",
"lodash": "^4.17.21",
"lodash.clonedeep": "^4.5.0",
"lodash.frompairs": "^4.0.1",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.includes": "^4.3.0",
"lodash.isempty": "^4.4.0",
"lodash.isequal": "^4.5.0",
"lodash.isplainobject": "^4.0.6",
"lodash.set": "^4.3.2",
"lodash.topairs": "^4.3.0",
"lodash.values": "^4.3.0",
"markdown-it": "^13.0.2",
"markdown-it-link-attributes": "^4.0.1",
"moment": "^2.29.4",
"moment-parseformat": "^4.0.0",
"normalize.css": "7.0.0",
"npm": "^7.8.0",
"nprogress": "0.2.0",
"path-to-regexp": "3.3.0",
"v-sanitize": "^0.0.13",
"vue": "2.6.10",
"vue-codemirror": "4.0.6",
"vue-cookie": "^1.1.4",
"vue-echarts": "^5.0.0-beta.0",
"vue-i18n": "^8.15.5",
"vue-json-editor": "^1.4.3",
"vue-markdown": "^2.2.4",
"vue-moment": "^4.1.0",
"vue-password-strength-meter": "^1.7.2",
"vue-router": "3.0.6",
"vue-select": "^3.9.5",
"vuejs-logger": "^1.5.4",
"vuex": "3.1.0",
"watermark-js-plus": "^1.5.8",
"xss": "^1.0.14",
"xterm": "^4.5.0",
"xterm-addon-fit": "^0.3.0",
"zxcvbn": "^4.4.2"
},
"devDependencies": {
"@babel/core": "7.18.6",
"@babel/register": "7.0.0",
"@vue/cli-plugin-babel": "3.6.0",
"@vue/cli-plugin-eslint": "^3.9.1",
"@vue/cli-plugin-unit-jest": "3.6.3",
"@vue/cli-service": "3.6.0",
"@vue/test-utils": "1.0.0-beta.29",
"autoprefixer": "^9.5.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"chalk": "2.4.2",
"compression-webpack-plugin": "^6.1.1",
"connect": "3.6.6",
"deasync": "^0.1.29",
"element-theme-chalk": "^2.13.1",
"eslint": "^5.15.3",
"eslint-plugin-vue": "5.2.2",
"eslint-plugin-vue-i18n": "^0.3.0",
"github-markdown-css": "^5.1.0",
"html-webpack-plugin": "3.2.0",
"husky": "^4.2.3",
"less-loader": "^5.0.0",
"lint-staged": "^10.1.2",
"mockjs": "1.0.1-beta3",
"runjs": "^4.3.2",
"sass": "~1.32.6",
"sass-loader": "^7.1.0",
"script-ext-html-webpack-plugin": "2.1.3",
"script-loader": "0.7.2",
"serve-static": "^1.16.0",
"strip-ansi": "^7.1.0",
"svg-sprite-loader": "4.1.3",
"svgo": "1.2.2",
"vue-i18n-extract": "^1.1.1",
"vue-template-compiler": "2.6.10"
},
"engines": {
"node": ">=8.9",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 4 versions",
"ie 11"
],
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"src/**/*.{js,vue}": [
"eslint --fix"
]
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}

View File

@@ -44,48 +44,17 @@ export default {
}
},
methods: {
getWaterMarkFields() {
const user = this.currentUser
const userId = user?.id || ''
const name = user?.name || ''
const userName = user?.username || ''
const currentTime = this.$moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
return { userId, name, userName, currentTime }
},
getWaterMarkContent() {
const fields = this.getWaterMarkFields()
const template = this.publicSettings.SECURITY_WATERMARK_CONSOLE_CONTENT || ''
// 找出模板中所有的变量占位符 ${xxx}
const placeholders = template.match(/\${([^}]+)}/g) || []
const allVariables = {}
// 为模板中的每个变量准备值
placeholders.forEach(placeholder => {
const varName = placeholder.slice(2, -1) // 提取变量名,去掉 ${ 和 }
allVariables[varName] = fields[varName] !== undefined ? fields[varName] : 'N/A'
})
// 合并用户现有的字段和模板中可能缺失的字段
const safeFields = { ...fields, ...allVariables }
// 安全解析模板
return new Function(...Object.keys(safeFields), `return \`${template}\`;`)(...Object.values(safeFields))
},
createWatermark() {
if (this.currentUser?.username && this.publicSettings?.SECURITY_WATERMARK_ENABLED) {
this.watermark = new Watermark({
content: this.getWaterMarkContent(),
width: this.publicSettings?.SECURITY_WATERMARK_WIDTH,
height: this.publicSettings?.SECURITY_WATERMARK_HEIGHT,
rotate: this.publicSettings?.SECURITY_WATERMARK_ROTATE,
content: `${this.currentUser.username}(${this.currentUser.name})`,
width: 200,
height: 200,
rotate: 45,
fontWeight: 'normal',
fontSize: this.publicSettings?.SECURITY_WATERMARK_FONT_SIZE + 'px',
fontColor: this.publicSettings?.SECURITY_WATERMARK_COLOR,
contentType: 'multi-line-text',
lineHeight: this.publicSettings?.SECURITY_WATERMARK_FONT_SIZE
fontColor: 'rgba(128, 128, 128, 0.2)'
})
this.watermark.create()
}
}

View File

@@ -16,9 +16,9 @@ export function getSystemUserList(data) {
})
}
export function getZoneList(data) {
export function getDomainList(data) {
return request({
url: '/api/v1/assets/zones/',
url: '/api/v1/assets/domains/',
method: 'get',
params: data
})

View File

@@ -8,20 +8,11 @@ export function login(data) {
})
}
export async function getProfile(token) {
let profile = await request({
export function getProfile(token) {
return request({
url: '/api/v1/users/profile/',
method: 'get'
})
const perms = await request({
url: '/api/v1/users/profile/permissions/',
method: 'get'
})
profile = {
...profile,
...perms
}
return profile
}
export function getUserList(data) {
@@ -31,7 +22,6 @@ export function getUserList(data) {
params: data
})
}
export function getUserGroupList(params) {
return request({
url: '/api/v1/users/groups/',
@@ -39,7 +29,6 @@ export function getUserGroupList(params) {
params: params
})
}
export function getUserGroupDetail(id) {
return request({
url: `/api/v1/users/groups/${id}/`,
@@ -61,7 +50,6 @@ export function editUserGroup(data) {
data: data
})
}
export function updateUserGroup(id, data) {
return request({
url: '/api/v1/users/groups/' + id + '/',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 584 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -16,7 +16,7 @@ export const accountFieldsMeta = (vm) => {
return {
assets: {
component: Select2,
label: vm.$t('Asset'),
label: vm.$t('Assets'),
rules: [Required],
el: {
multiple: true,

View File

@@ -63,7 +63,7 @@ export default {
encryptedFields: ['secret'],
fields: [
[this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username', 'template']],
[this.$t('Asset'), ['assets']],
[this.$t('Assets'), ['assets']],
[this.$t('Secret'), [
'secret_type', 'password', 'ssh_key', 'token',
'access_key', 'passphrase', 'api_key',

View File

@@ -51,7 +51,7 @@
<script>
import { mapGetters } from 'vuex'
import { accountOtherActions, accountQuickFilters, connectivityMeta, isDirectoryServiceAccount } from './const'
import { accountOtherActions, accountQuickFilters, connectivityMeta } from './const'
import { openTaskPage } from '@/utils/jms'
import {
AccountConnectFormatter,
@@ -216,7 +216,6 @@ export default {
width: '80px',
formatter: AccountConnectFormatter,
formatterArgs: {
asset: this.asset,
can: ({ row }) => {
return this.currentUserIsSuperAdmin
}
@@ -284,15 +283,10 @@ export default {
formatter: ActionsFormatter,
has: this.showActions,
formatterArgs: {
performDelete: ({ row }) => {
const id = row.id
const url = `/api/v1/accounts/accounts/${id}/`
return this.$axios.delete(url)
},
hasUpdate: false, // can set function(row, value)
hasDelete: true, // can set function(row, value)
hasClone: false,
canDelete: ({ row }) => vm.$hasPerm('accounts.delete_account') && !isDirectoryServiceAccount(row, this),
canDelete: () => vm.$hasPerm('accounts.delete_account'),
moreActionsTitle: this.$t('More'),
extraActions: accountOtherActions(this)
}

View File

@@ -7,23 +7,11 @@ export const connectivityMeta = {
faChoices: {
'-': '',
ok: 'fa-check-circle',
err: 'fa-times-circle',
auth_err: 'fa-times-circle',
rdp_err: 'fa-times-circle',
password_err: 'fa-times-circle',
openssh_key_err: 'fa-times-circle',
ntlm_err: 'fa-times-circle',
create_temp_err: 'fa-times-circle'
err: 'fa-times-circle'
},
classChoices: {
ok: 'text-primary',
err: 'text-danger',
auth_err: 'text-danger',
rdp_err: 'text-danger',
password_err: 'text-danger',
openssh_key_err: 'text-danger',
ntlm_err: 'text-danger',
create_temp_err: 'text-danger'
err: 'text-danger'
},
getText({ cellValue }) {
if (cellValue?.value === '-' || cellValue?.value === 'unknown') {
@@ -36,191 +24,162 @@ export const connectivityMeta = {
width: '130px'
}
export function isDirectoryServiceAccount(account, vm) {
return vm.asset && vm.asset.id !== account.asset.id
}
export const accountOtherActions = (vm) => {
return [
{
name: 'View',
title: vm.$t('View'),
can: vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
order: 1,
callback: ({ row }) => {
// debugger
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
vm.account = row
vm.showViewSecretDialog = false
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'Update',
title: vm.$t('Edit'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
callback: ({ row }) => {
vm.isUpdateAccount = true
const data = {
...vm.asset,
...row.asset
}
vm.iAsset = data
vm.account = row
vm.addTemplate = false
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'UpdateSecret',
title: vm.$t('EditSecret'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
callback: ({ row }) => {
const data = {
...vm.asset,
...row.asset
}
vm.account = row
vm.iAsset = data
vm.showUpdateSecretDialog = false
vm.accountCreateUpdateTitle = vm.$t('UpdateAccount')
setTimeout(() => {
vm.showUpdateSecretDialog = true
})
}
},
{
name: 'Clone',
title: vm.$t('Duplicate'),
has: () => {
return !vm.asset
},
can: ({ row }) => {
return vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
callback: ({ row }) => {
vm.account = {
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
username: `${row.username} - ${vm.$t('Duplicate').toLowerCase()}`,
payload: 'pam_account_clone'
}
vm.iAsset = vm.asset
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'Test',
title: vm.$t('VerifySecret'),
divided: true,
can: ({ row }) =>
!vm.$store.getters.currentOrgIsRoot &&
vm.$hasPerm('accounts.verify_account') &&
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
vm.$axios.post(
`/api/v1/accounts/accounts/tasks/`,
{ action: 'verify', accounts: [row.id] }
).then(res => {
openTaskPage(res['task'])
})
}
},
{
name: 'ClearSecret',
title: vm.$t('ClearSecret'),
can: ({ row }) => {
return vm.$hasPerm('accounts.change_account') &&
!isDirectoryServiceAccount(row, vm)
},
type: 'primary',
callback: ({ row }) => {
vm.$axios.patch(
`/api/v1/accounts/accounts/clear-secret/`,
{ account_ids: [row.id] }
).then(() => {
vm.$message.success(vm.$tc('ClearSuccessMsg'))
})
}
},
{
name: 'SecretHistory',
title: vm.$t('HistoryPassword'),
can: () => vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
vm.account = row
vm.currentAccountColumn = row
vm.showViewSecretDialog = false
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'CopyToOther',
title: vm.$t('CopyToAsset'),
type: 'primary',
divided: true,
can: ({ row }) => {
return vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('CopyToOther')
vm.$route.query.flag = 'copy'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
},
{
name: 'MoveToOther',
title: vm.$t('MoveToAsset'),
type: 'primary',
can: ({ row }) => {
return vm.$hasPerm('accounts.add_account') &&
!vm.$store.getters.currentOrgIsRoot &&
!isDirectoryServiceAccount(row, vm)
},
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('MoveToOther')
vm.$route.query.flag = 'move'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
export const accountOtherActions = (vm) => [
{
name: 'View',
title: vm.$t('View'),
can: vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
order: 1,
callback: ({ row }) => {
// debugger
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
vm.account = row
vm.showViewSecretDialog = false
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
]
}
},
{
name: 'Update',
title: vm.$t('Edit'),
can: vm.$hasPerm('accounts.change_account') && !vm.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
vm.isUpdateAccount = true
const data = {
...vm.asset,
...row.asset
}
vm.iAsset = data
vm.account = row
vm.addTemplate = false
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'UpdateSecret',
title: vm.$t('EditSecret'),
can: vm.$hasPerm('accounts.change_account') && !vm.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
const data = {
...vm.asset,
...row.asset
}
vm.account = row
vm.iAsset = data
vm.showUpdateSecretDialog = false
vm.accountCreateUpdateTitle = vm.$t('UpdateAccount')
setTimeout(() => {
vm.showUpdateSecretDialog = true
})
}
},
{
name: 'Clone',
title: vm.$t('Duplicate'),
has: () => {
return !vm.asset
},
can: vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
callback: ({ row }) => {
vm.account = {
name: `${row.name} - ${vm.$t('Duplicate').toLowerCase()}`,
username: `${row.username} - ${vm.$t('Duplicate').toLowerCase()}`,
payload: 'pam_account_clone'
}
vm.iAsset = vm.asset
vm.showAddDialog = false
setTimeout(() => {
vm.showAddDialog = true
})
}
},
{
name: 'Test',
title: vm.$t('VerifySecret'),
divided: true,
can: ({ row }) =>
!vm.$store.getters.currentOrgIsRoot &&
vm.$hasPerm('accounts.verify_account') &&
row.asset['auto_config'].ansible_enabled &&
row.asset['auto_config'].ping_enabled,
callback: ({ row }) => {
vm.$axios.post(
`/api/v1/accounts/accounts/tasks/`,
{ action: 'verify', accounts: [row.id] }
).then(res => {
openTaskPage(res['task'])
})
}
},
{
name: 'ClearSecret',
title: vm.$t('ClearSecret'),
can: vm.$hasPerm('accounts.change_account'),
type: 'primary',
callback: ({ row }) => {
vm.$axios.patch(
`/api/v1/accounts/accounts/clear-secret/`,
{ account_ids: [row.id] }
).then(() => {
vm.$message.success(vm.$tc('ClearSuccessMsg'))
})
}
},
{
name: 'SecretHistory',
title: vm.$t('HistoryPassword'),
can: () => vm.$hasPerm('accounts.view_accountsecret'),
type: 'primary',
callback: ({ row }) => {
vm.account = row
vm.currentAccountColumn = row
vm.showViewSecretDialog = false
vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
setTimeout(() => {
vm.showViewSecretDialog = true
})
}
},
{
name: 'CopyToOther',
title: vm.$t('CopyToAsset'),
type: 'primary',
divided: true,
can: () => vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('CopyToOther')
vm.$route.query.flag = 'copy'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
},
{
name: 'MoveToOther',
title: vm.$t('MoveToAsset'),
type: 'primary',
can: () => vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot,
has: () => {
return !vm.asset
},
callback: ({ row }) => {
vm.accountCreateUpdateTitle = vm.$t('MoveToOther')
vm.$route.query.flag = 'move'
vm.iAsset = vm.asset
vm.account = row
vm.showAddDialog = true
}
}
]
export const accountQuickFilters = (vm) => [
{

View File

@@ -114,11 +114,6 @@ export default {
treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
callback: {
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
},
edit: {
drag: {
isMove: false
}
}
}
}

View File

@@ -1,58 +0,0 @@
<template>
<ListTable ref="ListTable" :header-actions="headerActions" :table-config="tableConfig" :create-drawer="createDrawer" />
</template>
<script>
import { DrawerListTable as ListTable } from '@/components'
export default {
name: 'LeakPasswordList',
components: {
ListTable
},
props: {
object: {
type: Object,
required: false,
default: () => ({})
}
},
data() {
return {
createDrawer: () => import('@/components/Apps/LeakPasswords/LeakPasswordsCreateUpdate.vue'),
tableConfig: {
url: '/api/v1/settings/leak-passwords/',
columns: [
'password'
],
columnsMeta: {
actions: {
formatterArgs: {
hasClone: false,
canDelete: this.$hasPerm('settings.change_security'),
canUpdate: this.$hasPerm('settings.change_security')
}
}
}
},
headerActions: {
hasExport: false,
hasImport: false,
hasCreate: true,
hasSearch: true,
hasRefresh: true,
hasBulkDelete: false,
hasBulkUpdate: false,
hasLeftActions: true,
hasRightActions: true,
canCreate: this.$hasPerm('settings.change_security')
}
}
}
}
</script>
<style lang='less' scoped>
</style>

View File

@@ -1,41 +0,0 @@
<template>
<div v-loading="loading">
<GenericCreateUpdatePage
v-if="!loading"
class="user-create-update"
v-bind="$data"
:title="null"
v-on="$listeners"
/>
</div>
</template>
<script>
import { GenericCreateUpdatePage } from '@/layout/components'
export default {
name: 'LeakPasswordsCreateUpdate',
components: {
GenericCreateUpdatePage
},
data() {
return {
loading: true,
fields: [
[this.$t('Basic'), ['password']]
],
encryptedFields: [],
url: '/api/v1/settings/leak-passwords/'
}
},
async mounted() {
this.loading = false
},
methods: {}
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -1,76 +0,0 @@
<template>
<div>
<div>
<el-button
size="mini"
type="primary"
@click="onOpenDialog"
>
{{ $tc('View') }}
</el-button>
</div>
<Dialog
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
:title="title"
:visible.sync="visible"
v-bind="$attrs"
width="40%"
v-on="$listeners"
>
<LeakPasswordList />
</Dialog>
</div>
</template>
<script>
import { Dialog } from '@/components'
import LeakPasswordList from '@/components/Apps/LeakPasswords/LeakPasswordList.vue'
export default {
componentName: 'LeakPasswords',
components: {
LeakPasswordList,
Dialog
},
props: {
value: {
type: Object,
default: () => ({})
},
title: {
type: String,
default: function() {
return this.$t('LeakPasswordList')
}
},
url: {
type: String,
default: `/api/v1/settings/leak-passwords/`
}
},
data() {
return {
visible: false,
form: this.value,
config: {
url: this.url,
hasSaveContinue: false,
hasButtons: true,
fields: [],
fieldsMeta: {}
}
}
},
methods: {
onOpenDialog() {
this.visible = true
}
}
}
</script>
<style scoped>
</style>

View File

@@ -49,14 +49,24 @@
</el-select>
</el-col>
</el-row>
<el-row v-if="!noCodeMFA.includes(subTypeSelected)" :gutter="24" style="margin: 0 auto;">
<el-col :md="24" :sm="24" style="display: flex; align-items: center; ">
<el-row :gutter="24" style="margin: 0 auto;">
<el-col :md="24" :sm="24" style="display: flex; align-items: center; margin-bottom: 20px;">
<el-input
v-if="subTypeSelected !== 'face'"
v-model="secretValue"
:placeholder="inputPlaceholder"
:show-password="showPassword"
@keyup.enter.native="handleConfirm"
/>
<iframe
v-if="isFaceCaptureVisible && subTypeSelected ==='face' && faceCaptureUrl"
:src="faceCaptureUrl"
allow="camera"
sandbox="allow-scripts allow-same-origin"
style="width: 100%; height: 800px;border: none;"
/>
<span v-if="subTypeSelected === 'sms' || subTypeSelected === 'email'" style="margin: -1px 0 0 20px;">
<el-button
:disabled="smsBtnDisabled"
@@ -70,26 +80,10 @@
</span>
</el-col>
</el-row>
<el-row>
<el-col>
<iframe
v-if="passkeyVisible"
:src="passkeyUrl"
style="display: none"
/>
<iframe
v-if="isFaceCaptureVisible && subTypeSelected ==='face' && faceCaptureUrl"
:src="faceCaptureUrl"
allow="camera"
sandbox="allow-scripts allow-same-origin"
style="width: 100%; height: 800px;border: none;"
/>
</el-col>
</el-row>
<el-row :gutter="24" style="margin: 20px auto 10px;">
<el-row :gutter="24" style="margin: 10px auto;">
<el-col :md="24" :sm="24">
<el-button
v-if="!noCodeMFA.includes(subTypeSelected)"
v-if="subTypeSelected!=='face'"
class="confirm-btn"
size="mini"
type="primary"
@@ -98,8 +92,7 @@
{{ this.$t('Confirm') }}
</el-button>
<el-button
v-if="subTypeSelected === 'face'"
:disabled="isFaceCaptureVisible"
v-if="subTypeSelected==='face'&&!isFaceCaptureVisible"
class="confirm-btn"
size="mini"
type="primary"
@@ -107,16 +100,6 @@
>
{{ this.$tc('VerifyFace') }}
</el-button>
<el-button
v-if="subTypeSelected === 'passkey'"
v-loading="passkeyVisible"
class="confirm-btn"
size="mini"
type="primary"
@click="handlePasskeyVerify"
>
{{ this.$tc('Next') }}
</el-button>
</el-col>
</el-row>
</div>
@@ -158,11 +141,7 @@ export default {
processing: false,
isFaceCaptureVisible: false,
faceToken: null,
faceCaptureUrl: null,
noCodeMFA: ['face', 'passkey'],
sendCodeMFA: ['email', 'sms', 'otp'],
passkeyVisible: false,
passkeyUrl: '/api/v1/authentication/passkeys/login/?mfa=1'
faceCaptureUrl: null
}
},
computed: {
@@ -245,26 +224,6 @@ export default {
this.$message.error(this.$tc('FailedToSendVerificationCode'))
})
},
handlePasskeyVerify() {
this.passkeyVisible = true
this.checkPasskeyStatus()
},
checkPasskeyStatus() {
const url = '/api/v1/authentication/confirm/check/?confirm_type=mfa'
const t = setInterval(() => {
this.$axios.get(url).then(data => {
this.passkeyVisible = false
this.onSuccess()
})
}, 2000)
setTimeout(() => {
clearInterval(t)
if (this.passkeyVisible) {
this.passkeyVisible = false
this.$message.error(this.$tc('PasskeyTimeout'))
}
}, 20000)
},
startFaceCapture() {
const url = '/api/v1/authentication/face/context/'
this.$axios.post(url).then(data => {
@@ -288,13 +247,6 @@ export default {
handleFaceCapture() {
this.startFaceCapture()
},
onSuccess() {
this.secretValue = ''
this.visible = false
this.$nextTick(() => {
this.callback()
})
},
handleConfirm() {
if (this.confirmTypeRequired === 'relogin') {
return this.logout()
@@ -310,7 +262,11 @@ export default {
}
this.$axios.post(`/api/v1/authentication/confirm/`, data).then(() => {
this.onSuccess()
this.secretValue = ''
this.visible = false
this.$nextTick(() => {
this.callback()
})
}).catch((err) => {
this.$message.error(err.message || this.$tc('ConfirmFailed'))
this.faceCaptureUrl = null

View File

@@ -129,18 +129,8 @@ export default {
parseArrayValue(value, excludes, label) {
if (Array.isArray(value)) {
const tp = typeof value[0]
let object = {}
if (value.length === 0) {
object = {
key: label,
value: '-'
}
return this.items.push(object)
}
// 如果是空数组,那么循环体将不会执行
for (const [index, item] of value.entries()) {
let object = {}
if (tp === 'object') {
const firstValue = value[0]
if (firstValue.hasOwnProperty('name')) {

View File

@@ -15,7 +15,7 @@
@click="handleClick(action)"
@command="handleDropdownCallback"
>
<span v-if="action.split" :style="{ cursor: action.disabled ? 'not-allowed' : 'pointer' }">
<span v-if="action.split">
{{ action.title }}
</span>
<el-button

View File

@@ -10,18 +10,15 @@
<el-form-item>
<el-radio v-model="radioValue" :label="2">
{{ this.$t('From') }}
<el-input-number v-model="cycle01" :max="23" :min="0" size="mini" />
-
<el-input-number v-model="cycle02" :max="23" :min="0" size="mini" />
{{ this.$t('Hour') }}
<el-input-number v-model="cycle01" :max="60" :min="0" size="mini" /> -
<el-input-number v-model="cycle02" :max="60" :min="0" size="mini" /> {{ this.$t('Hour') }}
</el-radio>
</el-form-item>
<el-form-item>
<el-radio v-model="radioValue" :label="3">
{{ this.$t('Every') }}
<el-input-number v-model="average02" :max="23" :min="1" size="mini" />
{{ this.$t('Hour') }} {{ this.$t('ExecuteOnce') }}
<el-input-number v-model="average02" :max="60" :min="1" size="mini" /> {{ this.$t('Hour') }} {{ this.$t('ExecuteOnce') }}
</el-radio>
</el-form-item>
@@ -35,7 +32,7 @@
multiple
style="width:100%"
>
<el-option v-for="item in 24" :key="item" :value="item-1">{{ item - 1 }}</el-option>
<el-option v-for="item in 24" :key="item" :value="item-1">{{ item-1 }}</el-option>
</el-select>
</el-radio>
</el-form-item>

View File

@@ -9,7 +9,7 @@
<el-form-item>
<el-radio v-model="radioValue" :label="3">
{{ this.$t('From') }}
<el-input-number v-model="average02" :max="59" :min="1" size="mini" />
<el-input-number v-model="average02" :max="60" :min="1" size="mini" />
{{ this.$t('Min') }} {{ this.$t('ExecuteOnce') }}
</el-radio>
</el-form-item>

View File

@@ -5,6 +5,7 @@
slot="prepend"
:placeholder="$tc('Select')"
:value="rawValue.code"
style="width: 105px;"
@change="onChange"
>
<el-option
@@ -68,11 +69,7 @@ export default {
}
</script>
<style lang="scss" scoped>
.el-select {
width: 85px;
}
<style scoped>
.country-name {
display: inline-block;
width: 150px;

View File

@@ -53,7 +53,6 @@ export default {
const vm = this
const platform = this.$route.query.platform
return {
platform: '',
loading: true,
form: this.protocol,
platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
@@ -98,29 +97,11 @@ export default {
}
}
},
async mounted() {
try {
const drawActionMeta = await this.$store.dispatch('common/getDrawerActionMeta')
const platform = drawActionMeta.row.platform.id
const name = drawActionMeta.row.platform.name
if (platform) {
this.platformDetail = `/ui/#/settings/platforms?id=${platform}&name=${name}`
} else {
this.platformDetail = ''
}
} catch (e) {
throw new Error(e)
}
},
methods: {
onSubmit(form) {
this.protocol = Object.assign(this.protocol, form)
this.$emit('update:visible', false)
this.$emit('confirm', this.protocol)
},
openInNewTab() {
window.open(this.platformDetail, '_blank')
}
}
}

View File

@@ -78,18 +78,16 @@ export default {
},
data() {
return {
filterTags: this.value,
focus: false,
filterValue: '',
filterTags: this.value,
isCheckShowPassword: this.replaceShowPassword
isCheckShowPassword: this.replaceShowPassword,
component: this.autocomplete ? 'el-autocomplete' : 'el-input'
}
},
computed: {
iPlaceholder() {
return `${this.placeholder} (${this.$t('EnterToContinue')})`
},
component() {
return this.autocomplete !== null ? 'el-autocomplete' : 'el-input'
}
},
watch: {
@@ -100,7 +98,7 @@ export default {
methods: {
handleTagClose(tag) {
this.filterTags.splice(this.filterTags.indexOf(tag), 1)
this.handleConfirm()
this.$emit('change', this.filterTags)
},
handleSelect(item) {
this.filterValue = item.value
@@ -115,9 +113,8 @@ export default {
if (!this.filterTags.includes(this.filterValue)) {
this.filterTags.push(this.filterValue)
this.filterValue = ''
this.$emit('change', this.filterTags)
}
this.$emit('change', this.filterTags)
this.$emit('input', this.filterTags)
this.$refs.SearchInput.focus()
},
handleTagClick(v, k) {
@@ -192,7 +189,7 @@ export default {
}
.filter-field ::v-deep .el-input__inner {
height: 27px !important;
height: 28px !important;
}
.show-password {

View File

@@ -170,7 +170,7 @@ export default {
const [start, end] = val.split('~')
const startVal = this.countIndex(start)
const endVal = this.countIndex(end)
for (let i = startVal; i < (endVal === 0 ? 24 : endVal); i++) {
for (let i = startVal; i < (endVal === 0 ? 48 : endVal); i++) {
const curWeek = this.weekTimeData[idNum]
const curChild = curWeek.child[i]
if (curChild) {
@@ -181,8 +181,11 @@ export default {
// 计算索引
countIndex(val) {
const one = val.substr(0, 2)
const index = one.startsWith('0') ? one.substr(1, 2) : one
return Number(index)
const a1 = one.startsWith('0') ? one.substr(1, 2) : one
var reg = RegExp(/30/)
const a2 = val.match(reg) ? 1 : 0
const curIndex = (a1 * 2) + a2
return curIndex
},
formatDate(date, fmt) {
const o = {

View File

@@ -21,11 +21,21 @@
</template>
<script type="text/jsx">
import Sortable from 'sortablejs'
import DataTable from '@/components/Table/DataTable/index.vue'
import { newURL, ObjectLocalStorage, replaceAllUUID } from '@/utils/common'
import {
ActionsFormatter,
ArrayFormatter,
ChoicesFormatter,
CopyableFormatter,
DateFormatter,
DetailFormatter,
DisplayFormatter,
ObjectRelatedFormatter
} from '@/components/Table/TableFormatters'
import i18n from '@/i18n/i18n'
import { newURL, ObjectLocalStorage, replaceAllUUID, toSentenceCase } from '@/utils/common'
import ColumnSettingPopover from './components/ColumnSettingPopover.vue'
import { TableColumnsGenerator } from './utils'
import LabelsFormatter from '@/components/Table/TableFormatters/LabelsFormatter.vue'
export default {
name: 'AutoDataTable',
@@ -47,9 +57,9 @@ export default {
return {
loading: true,
method: 'get',
meta: {},
iConfig: {},
autoConfig: {},
iConfig: {},
meta: {},
cleanedColumnsShow: {},
totalColumns: [],
popoverColumns: {
@@ -59,8 +69,18 @@ export default {
defaultCols: []
},
isDeactivated: false,
tableColumnsStorage: this.getTableColumnsStorage(),
sortable: null
objTableColumns: new ObjectLocalStorage('tableColumns')
}
},
computed: {
dynamicActionWidth() {
if (this.$i18n.locale === 'en') {
return '120px'
}
if (this.$i18n.locale === 'pt-br') {
return '160px'
}
return '100px'
}
},
watch: {
@@ -82,9 +102,8 @@ export default {
}, 200)
}
},
async created() {
await this.optionUrlMetaAndGenCols()
this.loading = false
created() {
this.optionUrlMetaAndGenCols()
},
deactivated() {
this.isDeactivated = true
@@ -93,101 +112,323 @@ export default {
this.isDeactivated = false
},
methods: {
setColumnDraggable() {
const el = this.$el.querySelector('.el-table__header-wrapper thead tr')
if (!el) {
setTimeout(() => this.setColumnDraggable(), 500)
return
}
if (this.sortable) {
this.sortable.destroy()
}
this.sortable = Sortable.create(el, {
animation: 150,
onEnd: (evt) => {
let { oldIndex, newIndex } = evt
if (oldIndex === newIndex) {
return
}
// 检测表格是否有选择列
const hasSelectionColumn = this.$el.querySelector('.el-table-column--selection') !== null
if (hasSelectionColumn) {
// 如果有选择列,调整索引
if (oldIndex > 0) oldIndex -= 1
if (newIndex > 0) newIndex -= 1
}
let columnNames = [...this.cleanedColumnsShow.show]
if (columnNames.includes('actions')) {
columnNames = columnNames.filter(item => item !== 'actions')
columnNames.push('actions')
}
// 边界
if (oldIndex >= 0 && oldIndex < columnNames.length &&
newIndex >= 0 && newIndex < columnNames.length) {
const movedItem = columnNames.splice(oldIndex, 1)[0]
columnNames.splice(newIndex, 0, movedItem)
this.$log.debug('Column moved: ', movedItem, oldIndex, ' => ', newIndex)
// 保存更新的列顺序
this.tableColumnsStorage.set(columnNames)
// 更新内部状态
this.cleanedColumnsShow.show = columnNames
this.popoverColumns.currentCols = columnNames
// 重新应用列顺序
this.filterShowColumns()
this.loading = true
setTimeout(() => {
this.loading = false
// 在DOM完全更新后重新初始化拖拽
this.$nextTick(() => {
setTimeout(() => this.setColumnDraggable(), 200)
})
}, 300)
}
}
})
},
generateTotalColumns() {
const generator = new TableColumnsGenerator(this.config, this.meta, this)
this.totalColumns = generator.generateColumns()
this.config.columns = this.totalColumns
this.iConfig = _.cloneDeep(this.config)
},
async optionUrlMetaAndGenCols() {
if (this.config.url === '') {
return
}
const url = (this.config.url.indexOf('?') === -1)
? `${this.config.url}?display=1`
: `${this.config.url}&display=1`
/**
* 原有代码无法正确的同步 storage 的原因是 currentOrder 总是在 totalColumns 之前进行的
* 这导致在首次加载时currentOrder总是为空数组因为此时cleanedColumnsShow.show还未初始化
*/
try {
const data = await this.$store.dispatch('common/getUrlMeta', { url: url })
? `${this.config.url}?draw=1&display=1`
: `${this.config.url}&draw=1&display=1`
this.$store.dispatch('common/getUrlMeta', { url: url }).then(data => {
const method = this.method.toUpperCase()
this.meta = data.actions && data.actions[method] ? data.actions[method] : {}
this.generateTotalColumns()
this.cleanColumnsShow()
}).then(() => {
// 根据当前列重新生成最终渲染表格
this.filterShowColumns()
}).then(() => {
// 生成给子组件使用的TotalColList
this.generatePopoverColumns()
this.setColumnDraggable()
} catch (error) {
}).catch((error) => {
this.$log.error('Error occur: ', error)
}
}).finally(() => {
this.loading = false
})
},
getTableColumnsStorage() {
let tableName = this.config.name || this.$route.name + '_' + newURL(this.config.url).pathname
tableName = replaceAllUUID(tableName)
return new ObjectLocalStorage('tableColumns', tableName)
generateColumnByName(name, col) {
switch (name) {
case 'id':
if (!col.width) {
col.width = '299px'
}
if (!col.formatter) {
col.formatter = CopyableFormatter
col.iconPosition = 'left'
}
break
case 'name':
col.formatter = DetailFormatter
col.sortable = 'custom'
col.showOverflowTooltip = true
col.minWidth = '150px'
break
case 'actions':
col = {
prop: 'actions',
label: i18n.t('Actions'),
align: 'center',
width: this.dynamicActionWidth,
formatter: ActionsFormatter,
fixed: 'right',
formatterArgs: {}
}
break
case 'is_valid':
col.label = i18n.t('Valid')
col.formatter = ChoicesFormatter
col.formatterArgs = {
textChoices: {
true: i18n.t('Yes'),
false: i18n.t('No')
}
}
col.width = '80px'
break
case 'is_active':
col.formatter = ChoicesFormatter
col.formatterArgs = {
textChoices: {
true: i18n.t('Active'),
false: i18n.t('Inactive')
}
}
col.width = '100px'
break
case 'datetime':
case 'date_start':
col.formatter = DateFormatter
break
case 'labels':
col.formatter = LabelsFormatter
col.width = '200px'
break
case 'comment':
col.showOverflowTooltip = true
}
return col
},
generateColumnByType(type, col, meta) {
switch (type) {
case 'choice':
col.sortable = 'custom'
col.formatter = DisplayFormatter
break
case 'labeled_choice':
col.sortable = 'custom'
col.formatter = ChoicesFormatter
break
case 'boolean':
col.formatter = ChoicesFormatter
// col.width = '80px'
break
case 'datetime':
col.formatter = DateFormatter
col.width = '155px'
break
case 'object_related_field':
col.formatter = ObjectRelatedFormatter
break
case 'm2m_related_field':
col.formatter = ObjectRelatedFormatter
break
case 'list':
col.formatter = ArrayFormatter
break
case 'json':
case 'field':
if (meta.child && meta.child.type === 'nested object') {
col.formatter = ObjectRelatedFormatter
}
break
}
// this.$log.debug('Field: ', type, col.prop, col)
return col
},
addHelpTipIfNeed(col) {
const helpTip = col.helpTip
if (!helpTip) {
return col
}
col.renderHeader = (h, { column, $index }) => {
const binds = {
props: {
placement: 'bottom',
effect: 'dark',
openDelay: 500,
popperClass: 'help-tips'
}
}
return (
<span>{column.label}
<el-tooltip {...binds}>
<div slot='content' v-sanitize={helpTip}/>
<i class='fa fa-question-circle-o help-tip-icon' style='padding-left: 2px'/>
</el-tooltip>
</span>
)
}
return col
},
addFilterIfNeed(col) {
if (col.prop) {
const column = this.meta[col.prop] || {}
if (!column.filter) {
return col
}
if (column.type === 'boolean') {
col.filters = [
{ text: i18n.t('Yes'), value: true },
{ text: i18n.t('No'), value: false }
]
col.sortable = false
col['column-key'] = col.prop
}
if (column.type === 'choice' && column.choices) {
col.filters = column.choices.map(item => {
if (typeof (item.value) === 'boolean') {
if (item.value) {
return { text: item['label'], value: 'True' }
} else {
return { text: item['label'], value: 'False' }
}
}
return { text: item['label'], value: item.value }
})
col.sortable = false
col['column-key'] = col.prop
}
}
return col
},
addOrderingIfNeed(col) {
if (col.prop) {
const column = this.meta[col.prop] || {}
if (column.order) {
col.sortable = 'custom'
col['column-key'] = col.prop
}
}
return col
},
setDefaultFormatterIfNeed(col) {
if (!col.formatter) {
col.formatter = (row, column, cellValue) => {
let value = cellValue
let padding = '0'
const excludes = [undefined, null, '']
if (excludes.indexOf(value) !== -1) {
padding = '6px'
value = '-'
}
return <span style={{ marginLeft: padding }}>{value}</span>
}
}
return col
},
setDefaultWidthIfNeed(col) {
const lang = this.$i18n.locale
let factor = 10
if (lang === 'zh') {
factor = 20
}
let [sortable, filters] = [0, 0]
if (col && col?.sortable === 'custom') {
sortable = 10
}
if (col && col?.filters?.length > 0) {
filters = 12
}
if (col && !col.width && col.label && !col.minWidth) {
col.minWidth = `${col.label.length * factor + sortable + filters + 30}px`
}
return col
},
generateColumn(name) {
const colMeta = this.meta[name] || {}
const customMeta = this.config.columnsMeta ? this.config.columnsMeta[name] : {}
let col = { prop: name, label: colMeta.label, showOverflowTooltip: true }
col = this.generateColumnByType(colMeta.type, col, colMeta)
col = this.generateColumnByName(name, col)
col = this.setDefaultFormatterIfNeed(col)
col = Object.assign(col, customMeta)
col = this.addHelpTipIfNeed(col)
col = this.addFilterIfNeed(col)
col = this.addOrderingIfNeed(col)
col = this.updateLabelIfNeed(col)
col = this.setDefaultWidthIfNeed(col)
return col
},
updateLabelIfNeed(col) {
if (!col.label) {
return col
}
col.label = col.label
.replace(' Amount', '')
.replace(' amount', '')
.replace('数量', '')
if (col.label.startsWith('Is ')) {
col.label = col.label.replace('Is ', '')
}
col.label = toSentenceCase(col.label)
return col
},
generateTotalColumns() {
const config = _.cloneDeep(this.config)
let columns = []
const allColumnNames = Object.entries(this.meta)
.filter(([name, meta]) => !meta['write_only'])
.map(([name, meta]) => name)
.concat(config.columnsExtra || [])
let configColumns = config.columns || allColumnNames
const columnsExclude = config.columnsExclude || []
const columnsAdd = config.columnsAdd || []
configColumns = configColumns.concat(columnsAdd)
configColumns = configColumns.filter(item => !columnsExclude.includes(item))
// 解决后端 API 返回字段中包含 actions 的问题;
const hasColumnActions = configColumns.findIndex(item => item?.prop === 'actions') !== -1
if (!hasColumnActions) {
configColumns = [...configColumns.filter(i => i !== 'actions'), 'actions']
}
for (let col of configColumns) {
if (typeof col === 'object') {
columns.push(col)
} else if (typeof col === 'string') {
col = this.generateColumn(col)
columns.push(col)
}
}
columns = columns.filter(item => {
if (item?.showFullContent) {
item.className = 'show-full-content'
}
let has = item.has
if (has === undefined) {
has = true
} else if (typeof has === 'function') {
has = has()
}
return has
})
columns = this.orderingColumns(columns)
// 第一次初始化时记录 totalColumns
this.totalColumns = columns
config.columns = columns
this.iConfig = config
},
orderingColumns(columns) {
const cols = _.cloneDeep(this.config.columns)
const defaults = _.get(this.config, 'columnsShow.default')
const ordering = (cols || defaults || []).map(item => {
let prop = item
if (typeof item === 'object') {
prop = item.prop
}
return prop
})
return _.sortBy(columns, (item) => {
if (item.prop === 'actions') {
return 1000
}
const i = ordering.indexOf(item.prop)
return i === -1 ? 999 : i
})
},
// 生成给子组件使用的TotalColList
cleanColumnsShow() {
@@ -197,12 +438,16 @@ export default {
if (defaultColumnsNames.length === 0) {
defaultColumnsNames = totalColumnsNames
}
// Clean it
defaultColumnsNames = totalColumnsNames.filter(n => defaultColumnsNames.indexOf(n) > -1)
// 最小列
const minColumnsNames = _.get(this.iConfig, 'columnsShow.min', ['actions', 'id'])
.filter(n => totalColumnsNames.includes(n))
const configShowColumnsNames = this.tableColumnsStorage.get()
let tableName = this.config.name || this.$route.name + '_' + newURL(this.config.url).pathname
tableName = replaceAllUUID(tableName)
const configShowColumnsNames = this.objTableColumns.get(tableName)
let showColumnsNames = configShowColumnsNames || defaultColumnsNames
if (showColumnsNames.length === 0) {
showColumnsNames = totalColumnsNames
@@ -213,6 +458,8 @@ export default {
showColumnsNames.push(v)
}
})
// Clean it
showColumnsNames = totalColumnsNames.filter(n => showColumnsNames.indexOf(n) > -1)
this.cleanedColumnsShow = {
default: defaultColumnsNames,
@@ -224,38 +471,9 @@ export default {
},
filterShowColumns() {
this.cleanColumnsShow()
const showFieldNames = this.cleanedColumnsShow.show
let showFields = this.totalColumns.filter(obj => {
return showFieldNames.indexOf(obj.prop) > -1
this.iConfig.columns = this.totalColumns.filter(obj => {
return this.cleanedColumnsShow.show.indexOf(obj.prop) > -1
})
showFields = this.orderingColumns(showFields)
this.iConfig.columns = showFields
// 确保最新的列配置也应用到config对象上保持同步
this.config.columns = this.iConfig.columns
this.$nextTick(() => {
if (this.$refs.dataTable) {
this.$refs.dataTable.getList()
}
})
},
orderingColumns(columns) {
const cols = _.cloneDeep(this.config.columns)
const show = this.cleanedColumnsShow.show
const ordering = (show || cols || []).map(item => {
let prop = item
if (typeof item === 'object') {
prop = item.prop
}
return prop
})
const sorted = _.sortBy(columns, (item) => {
const i = ordering.indexOf(item.prop)
item.order = i
return i === -1 ? 999 : i
})
return sorted
},
generatePopoverColumns() {
this.popoverColumns.totalColumnsList = this.totalColumns.filter(obj => {
@@ -275,7 +493,13 @@ export default {
columns = this.cleanedColumnsShow.default
}
this.popoverColumns.currentCols = columns
this.tableColumnsStorage.set(columns)
let tableName = this.config.name || this.$route.name + '_' + newURL(url).pathname
// 替换url中的uuid避免同一个类型接口生成多个keylocalStorage中的数据无法共用.
tableName = replaceAllUUID(tableName)
this.objTableColumns.set(tableName, columns)
this.filterShowColumns()
},
filterChange(filters) {

View File

@@ -1,323 +0,0 @@
import { toSentenceCase } from '@/utils/common'
import i18n from '@/i18n/i18n'
import {
ActionsFormatter,
ArrayFormatter,
ChoicesFormatter,
CopyableFormatter,
DateFormatter,
DetailFormatter,
DisplayFormatter,
ObjectRelatedFormatter
} from '@/components/Table/TableFormatters'
import LabelsFormatter from '@/components/Table/TableFormatters/LabelsFormatter.vue'
export class TableColumnsGenerator {
constructor(config, meta, vm) {
this.config = config
this.meta = meta
this.vm = vm
}
dynamicActionWidth() {
if (i18n.locale === 'en') {
return '120px'
}
if (i18n.locale === 'pt-br') {
return '160px'
}
return '100px'
}
generateColumns() {
const config = _.cloneDeep(this.config)
let columns = []
const allColumnNames = Object.entries(this.meta)
.filter(([name, meta]) => !meta['write_only'])
.map(([name, meta]) => name)
.concat(config.columnsExtra || [])
let configColumns = config.columns || allColumnNames
const columnsExclude = config.columnsExclude || []
const columnsAdd = config.columnsAdd || []
configColumns = configColumns.concat(columnsAdd)
configColumns = configColumns.filter(item => !columnsExclude.includes(item))
// 解决后端 API 返回字段中包含 actions 的问题;
const hasColumnActions = configColumns.findIndex(item => item?.prop === 'actions') !== -1
if (!hasColumnActions) {
configColumns = [...configColumns.filter(i => i !== 'actions'), 'actions']
}
for (let col of configColumns) {
if (typeof col === 'object') {
columns.push(col)
} else if (typeof col === 'string') {
col = this.generateColumn(col)
columns.push(col)
}
}
columns = columns.filter(item => {
if (item?.showFullContent) {
item.className = 'show-full-content'
}
let has = item.has
if (has === undefined) {
has = true
} else if (typeof has === 'function') {
has = has()
}
return has
})
// columns = this.orderingColumns(columns)
// 第一次初始化时记录 totalColumns
config.columns = columns
return columns
}
updateLabelIfNeed(col) {
if (!col.label) {
return col
}
col.label = col.label
.replace(' Amount', '')
.replace(' amount', '')
.replace('数量', '')
if (col.label.startsWith('Is ')) {
col.label = col.label.replace('Is ', '')
}
col.label = toSentenceCase(col.label)
return col
}
generateColumn(name) {
const colMeta = this.meta[name] || {}
const customMeta = this.config.columnsMeta ? this.config.columnsMeta[name] : {}
let col = { prop: name, label: colMeta.label, showOverflowTooltip: true }
col = this.generateColumnByType(colMeta.type, col, colMeta)
col = this.generateColumnByName(name, col)
col = this.setDefaultFormatterIfNeed(col)
col = Object.assign(col, customMeta)
col = this.addHelpTipIfNeed(col)
col = this.addFilterIfNeed(col)
col = this.addOrderingIfNeed(col)
col = this.updateLabelIfNeed(col)
col = this.setDefaultWidthIfNeed(col)
return col
}
generateColumnByName(name, col) {
switch (name) {
case 'id':
if (!col.width) {
col.width = '299px'
}
if (!col.formatter) {
col.formatter = CopyableFormatter
col.iconPosition = 'left'
}
break
case 'name':
col.formatter = DetailFormatter
col.sortable = 'custom'
col.showOverflowTooltip = true
col.minWidth = '150px'
break
case 'actions':
col = {
prop: 'actions',
label: i18n.t('Actions'),
align: 'center',
width: this.dynamicActionWidth(),
formatter: ActionsFormatter,
fixed: 'right',
formatterArgs: {}
}
break
case 'is_valid':
col.label = i18n.t('Valid')
col.formatter = ChoicesFormatter
col.formatterArgs = {
textChoices: {
true: i18n.t('Yes'),
false: i18n.t('No')
}
}
col.width = '80px'
break
case 'is_active':
col.formatter = ChoicesFormatter
col.formatterArgs = {
textChoices: {
true: i18n.t('Active'),
false: i18n.t('Inactive')
}
}
col.width = '100px'
break
case 'datetime':
case 'date_start':
col.formatter = DateFormatter
break
case 'labels':
col.formatter = LabelsFormatter
col.width = '200px'
break
case 'comment':
col.showOverflowTooltip = true
}
return col
}
generateColumnByType(type, col, meta) {
switch (type) {
case 'choice':
col.sortable = 'custom'
col.formatter = DisplayFormatter
break
case 'labeled_choice':
col.sortable = 'custom'
col.formatter = ChoicesFormatter
break
case 'boolean':
col.formatter = ChoicesFormatter
// col.width = '80px'
break
case 'datetime':
col.formatter = DateFormatter
col.width = '155px'
break
case 'object_related_field':
col.formatter = ObjectRelatedFormatter
break
case 'm2m_related_field':
col.formatter = ObjectRelatedFormatter
break
case 'list':
col.formatter = ArrayFormatter
break
case 'json':
case 'field':
if (meta.child && meta.child.type === 'nested object') {
col.formatter = ObjectRelatedFormatter
}
break
}
// this.$log.debug('Field: ', type, col.prop, col)
return col
}
setDefaultFormatterIfNeed(col) {
const h = this.vm.$createElement
if (!col.formatter) {
col.formatter = (row, column, cellValue) => {
let value = cellValue
let padding = '0'
const excludes = [undefined, null, '']
if (excludes.indexOf(value) !== -1) {
padding = '6px'
value = '-'
}
return h('span', {
'style': {
marginLeft: padding
}
}, [value])
}
}
return col
}
setDefaultWidthIfNeed(col) {
const lang = i18n.locale
let factor = 10
if (lang === 'zh') {
factor = 20
}
let [sortable, filters] = [0, 0]
if (col && col?.sortable === 'custom') {
sortable = 10
}
if (col && col?.filters?.length > 0) {
filters = 12
}
if (col && !col.width && col.label && !col.minWidth) {
col.minWidth = `${col.label.length * factor + sortable + filters + 30}px`
}
return col
}
addOrderingIfNeed(col) {
if (col.prop) {
const column = this.meta[col.prop] || {}
if (column.order) {
col.sortable = 'custom'
col['column-key'] = col.prop
}
}
return col
}
addHelpTipIfNeed(col) {
const helpTip = col.helpTip
if (!helpTip) {
return col
}
col.renderHeader = (h, { column, $index }) => {
const binds = {
props: {
placement: 'bottom',
effect: 'dark',
openDelay: 500,
popperClass: 'help-tips'
}
}
return (
<span>{column.label}
<el-tooltip {...binds}>
<div slot='content' v-sanitize={helpTip}/>
<i class='fa fa-question-circle-o help-tip-icon' style='padding-left: 2px'/>
</el-tooltip>
</span>
)
}
return col
}
addFilterIfNeed(col) {
if (col.prop) {
const column = this.meta[col.prop] || {}
if (!column.filter) {
return col
}
if (column.type === 'boolean') {
col.filters = [
{ text: i18n.t('Yes'), value: true },
{ text: i18n.t('No'), value: false }
]
col.sortable = false
col['column-key'] = col.prop
}
if (column.type === 'choice' && column.choices) {
col.filters = column.choices.map(item => {
if (typeof (item.value) === 'boolean') {
if (item.value) {
return { text: item['label'], value: 'True' }
} else {
return { text: item['label'], value: 'False' }
}
}
return { text: item['label'], value: item.value }
})
col.sortable = false
col['column-key'] = col.prop
}
}
return col
}
}

View File

@@ -34,12 +34,6 @@
@currentSizeChange="handleCurrentChange"
@sizeChange="handleSizeChange"
/>
<Drawer
v-if="detailDrawer"
:component="detailDrawer"
:title="detailTitle"
:visible.sync="detailDrawerVisible"
/>
</div>
</template>
@@ -49,14 +43,12 @@ import { Pagination } from '@/components'
import TableAction from '@/components/Table/ListTable/TableAction'
import IBox from '@/components/Common/IBox/index.vue'
import Panel from './Panel'
import Drawer from '@/components/Drawer/index.vue'
const defaultFirstPage = 1
export default {
name: 'CardTable',
components: {
Drawer,
IBox,
Panel,
TableAction,
@@ -87,10 +79,6 @@ export default {
subComponentProps: {
type: Object,
default: () => ({})
},
detailDrawer: {
type: [String, Function],
default: ''
}
},
data() {
@@ -109,9 +97,7 @@ export default {
display: 1,
draw: 1
}
},
detailDrawerVisible: false,
detailTitle: ''
}
}
},
computed: {
@@ -151,10 +137,9 @@ export default {
return
}
const pageQuery = this.getPageQuery(this.page, this.paginationSize)
const query = Object.assign(this.extraQuery, pageQuery, this.tableConfig.extraQuery)
const query = Object.assign(this.extraQuery, pageQuery)
const queryString = Object.keys(query).map(key => key + '=' + query[key]).join('&')
const connector = this.tableUrl.indexOf('?') === -1 ? '?' : '&'
const url = `${this.tableUrl}${connector}${queryString}`
const url = `${this.tableUrl}?${queryString}`
const resp = await this.$axios.get(url, this.axiosConfig)
const data = resp.data
@@ -192,20 +177,12 @@ export default {
defaultPerformDelete(obj) {
this.$axios.delete(`${this.tableConfig.url}${obj.id}/`)
},
async onView(obj) {
onView(obj) {
if (this.isDisabled(obj)) {
return
}
if (this.detailDrawer) {
await this.$store.dispatch('common/setDrawerActionMeta', {
action: 'detail', row: obj, col: {}, id: obj.id
})
this.detailTitle = `${this.$t('Detail')}: ${obj.name}`
this.detailDrawerVisible = true
} else {
const viewFunc = this.tableConfig.onView || this.defaultPerformView
await viewFunc(obj)
}
const viewFunc = this.tableConfig.onView || this.defaultPerformView
viewFunc(obj)
},
onDelete(obj) {
const msg = `${this.$t('DeleteWarningMsg')} "${obj.name}" ?`

View File

@@ -1,7 +1,7 @@
<template>
<div class="item-info">
<el-row>
<el-col v-for="(item, i) of infos" :key="i" :span="12" class="panel-item">
<el-col v-for="item of infos" :key="item.content" :span="12" class="panel-item">
<small class="item-label">{{ item.title }}</small>
<h4 class="item-value">{{ item.content }}</h4>
</el-col>

View File

@@ -1,5 +1,5 @@
<template>
<div class="info-panel" @click="gotoDetail">
<div class="info-panel">
<div class="panel-header">
<div class="panel-title">
<el-avatar :src="imageUrl" shape="square" />
@@ -30,7 +30,7 @@
</el-dropdown>
</div>
</div>
<div class="panel-content">
<div class="panel-content" @click="gotoDetail">
<InfoPanel :infos="getInfos(object)" />
</div>
<el-row class="panel-footer" />
@@ -158,7 +158,6 @@ div.info-panel {
flex-direction: column;
padding: 10px;
gap: 10px;
cursor: pointer;
.panel-header {
padding: 10px 20px;
@@ -166,6 +165,7 @@ div.info-panel {
display: flex;
justify-content: space-between;
gap: 10px;
cursor: default;
.panel-title {
display: flex;
@@ -216,6 +216,7 @@ div.info-panel {
.panel-content {
display: block;
padding: 1px 25px 10px;
cursor: pointer;
.panel-image {
margin: auto 5px;

View File

@@ -14,10 +14,9 @@
plain
size="mini"
type="primary"
:disabled="!hasPerm"
@click="handleBtnConnect"
>
<i :class="iButtonIcon" :style="{ color: hasPerm ? '' : '#fff' }" />
<i :class="iButtonIcon" />
</el-button>
<el-dropdown-menu v-if="!isClick" slot="dropdown">
@@ -54,15 +53,13 @@ export default {
default() {
return {
can: () => true,
getConnectUrl: (row, protocol, asset) => {
const assetId = asset ? asset.id : row.asset.id
getConnectUrl: (row, protocol) => {
return `/luna/admin-connect/?
asset=${assetId}
asset=${row.asset.id}
&account=${row.id}
&protocol=${protocol}
`.replace(/\s+/g, '')
},
asset: null,
assetUrl: '/api/v1/assets/assets/{id}/',
buttonIcon: 'fa fa-desktop'
}
@@ -88,7 +85,7 @@ export default {
},
methods: {
handleProtocolConnect(protocol) {
const url = this.formatterArgs.getConnectUrl(this.row, protocol, this.formatterArgs.asset)
const url = this.formatterArgs.getConnectUrl(this.row, protocol)
window.open(url, '_blank')
},
visibleChange(visible) {
@@ -114,8 +111,7 @@ export default {
try {
const url = this.formatterArgs.assetUrl.replace('{id}', assetId)
const res = await this.$axios.get(url)
this.protocols = res.protocols.filter(protocol => (protocol.name !== 'winrm')) || []
this.protocols = res.protocols || []
} catch (e) {
throw new Error(`Error getting protocols: ${e}`)
}

View File

@@ -6,7 +6,7 @@
<i class="fa fa-check" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="item of iActions" :key="item.name" :command="item.name" :disabled="item.disabled">
<el-dropdown-item v-for="item of iActions" :key="item.name" :command="item.name">
{{ item.label }}
</el-dropdown-item>
</el-dropdown-menu>
@@ -123,20 +123,17 @@ export default {
{
name: 'delete_remote',
label: this.$t('DeleteRemoteAccount'),
has: this.row.remote_present,
disabled: this.$store.getters.currentOrgIsRoot
has: this.row.remote_present
},
{
name: 'add_account',
label: this.$t('AddAccount'),
has: !this.row.present,
disabled: this.$store.getters.currentOrgIsRoot
has: !this.row.present
},
{
name: 'change_password_add',
label: this.$t('AddAccountAfterChangingPassword'),
has: !this.row.present,
disabled: this.$store.getters.currentOrgIsRoot
has: !this.row.present
}
]
return actions.filter(action => {

View File

@@ -50,75 +50,23 @@ export default {
return cellValue
},
viewText() {
const cpuCount = Number(this.items['cpu_count'] || 0)
const cpuCores = Number(this.items['cpu_cores'] || 0)
const cpuVcpus = Number(this.items['cpu_vcpus'] || 0)
const memory = Number(this.items['memory'] || 0)
const diskTotal = Number(this.items['disk_total'] || 0)
const rawCpuModel = this.items['cpu_model']
const rawGpuModel = this.items['gpu_model']
let summary = ''
const cpuCount = this.items['cpu_count']
const cpuCores = this.items['cpu_cores']
const cpuVcpus = this.items['cpu_vcpus']
const memory = this.items['memory']
const diskTotal = this.items['disk_total']
if (cpuCount) {
const coreCount = cpuVcpus || (cpuCores * cpuCount)
summary = `${coreCount} Core`
let text = `${cpuVcpus || cpuCores * cpuCount} Core`
if (memory) {
summary += ` ${Math.round(memory)}G`
text += ` ${memory}G`
}
if (diskTotal) {
summary += ` ${Math.round(diskTotal)}G`
text += ` ${diskTotal}G`
}
const cpuModel = this.formatCpuModel(rawCpuModel)
if (cpuModel) {
summary += ` (${cpuModel})`
}
if (rawGpuModel) {
const gpu = this.formatGpuModel(rawGpuModel)
summary += ` ${gpu}`
}
return summary
return text
}
return this.items?.distribution || '-'
}
},
methods: {
formatCpuModel(raw) {
if (!raw) return ''
const match = raw.match(/^([^\s]+)\s*(x\d+)?$/)
let base = match?.[1] || raw
const suffix = match?.[2] || ''
base = base
.replace(/GenuineIntel/i, '')
.replace(/\b\d+(st|nd|rd|th)? Gen\b/i, '')
.replace(/\(R\)/g, '')
.replace(/\(TM\)/g, '')
.replace(/\s+/g, ' ')
.trim()
return `${base}${suffix}`
},
formatGpuModel(raw) {
if (!raw) return ''
const match = raw.match(/(.+?),\s*(\d+),\s*([\d.]+)(?:\s*x(\d+))?/)
if (match) {
const [, model, vramMb, driverVersion, countStr] = match
const count = countStr ? parseInt(countStr) : 1
const vramGb = Math.round(parseInt(vramMb) / 1024)
const label = `${model} (${vramGb}GB, Driver ${driverVersion})`
return count > 1 ? `${label} x${count}` : label
}
return raw // fallback
}
}
}
</script>

View File

@@ -244,12 +244,10 @@ export default {
delete routeFilter.search
}
const asFilterTags = _.cloneDeep(this.filterTags)
setTimeout(() => {
this.filterTags = {
...asFilterTags,
...routeFilter
}
}, 100)
this.filterTags = {
...asFilterTags,
...routeFilter
}
},
getValueLabel(key, value) {
for (const field of this.options) {

View File

@@ -42,7 +42,7 @@ export const crontab = {
on: {
change: (val, updateForm) => {
updateForm({
interval: null
interval: ''
})
}
}
@@ -72,6 +72,7 @@ export const interval = {
],
on: {
input: (val, updateForm) => {
console.log('interval input', val)
updateForm({
crontab: ''
})

View File

@@ -19,7 +19,6 @@ export { default as UploadKey } from './Form/FormFields/UploadKey.vue'
export { default as AssetSelect } from './Apps/AssetSelect'
export { default as AutomationParams } from './Apps/AutomationParams'
export { default as BlockedIPs } from './Apps/BlockedIPs'
export { default as LeakPasswords } from './Apps/LeakPasswords'
export { default as SvgIcon } from './Widgets/SvgIcon'
export { default as TreeTable } from './Table/TreeTable'
export { default as AssetTreeTable } from './Apps/AssetTreeTable'

View File

@@ -2,10 +2,6 @@ import zhLocale from 'element-ui/lib/locale/lang/zh-CN'
import zhTWLocale from 'element-ui/lib/locale/lang/zh-TW'
import enLocale from 'element-ui/lib/locale/lang/en'
import jaLocale from 'element-ui/lib/locale/lang/ja'
import ptBrLocale from 'element-ui/lib/locale/lang/pt-br'
import esLocale from 'element-ui/lib/locale/lang/es'
import ruLocale from 'element-ui/lib/locale/lang/ru-RU'
import koLocale from 'element-ui/lib/locale/lang/ko'
import zh from './zh.json'
import zhHant from './zh_hant.json'
import en from './en.json'
@@ -27,18 +23,6 @@ const messages = {
ja: {
...jaLocale,
...ja
},
pt_br: {
...ptBrLocale
},
es: {
...esLocale
},
ru: {
...ruLocale
},
ko: {
...koLocale
}
}

View File

@@ -244,7 +244,6 @@ export default {
this.$refs.form.setFieldError(key, err)
}
}
this.$emit('performError', data)
}
},
hasSaveContinue: {

View File

@@ -228,35 +228,35 @@ export default [
component: empty,
redirect: '',
meta: {
resource: 'zone',
resource: 'domain',
icon: 'zone',
permissions: ['assets.view_zone']
permissions: ['assets.view_domain']
},
children: [
{
path: '',
name: 'ZoneList',
component: () => import('@/views/assets/Zone/ZoneList.vue'),
component: () => import('@/views/assets/Domain/DomainList.vue'),
meta: { title: i18n.t('ZoneList') }
},
{
path: 'create',
name: 'ZoneCreate',
component: () => import('@/views/assets/Zone/ZoneCreateUpdate.vue'),
component: () => import('@/views/assets/Domain/DomainCreateUpdate.vue'),
hidden: true,
meta: { title: i18n.t('ZoneCreate') }
},
{
path: ':id/update',
name: 'ZoneUpdate',
component: () => import('@/views/assets/Zone/ZoneCreateUpdate.vue'),
component: () => import('@/views/assets/Domain/DomainCreateUpdate.vue'),
hidden: true,
meta: { title: i18n.t('ZoneUpdate') }
},
{
path: ':id',
name: 'ZoneDetail',
component: () => import('@/views/assets/Zone/ZoneDetail'),
component: () => import('@/views/assets/Domain/DomainDetail'),
hidden: true,
meta: { title: i18n.t('Zone') }
}
@@ -274,7 +274,7 @@ export default [
{
path: 'create',
name: 'GatewayCreate',
component: () => import('@/views/assets/Zone/ZoneDetail/GatewayCreateUpdate.vue'),
component: () => import('@/views/assets/Domain/DomainDetail/GatewayCreateUpdate.vue'),
meta: {
title: i18n.t('GatewayCreate'),
permissions: ['assets.view_gateway']
@@ -283,7 +283,7 @@ export default [
{
path: ':id/update',
name: 'GatewayUpdate',
component: () => import('@/views/assets/Zone/ZoneDetail/GatewayCreateUpdate.vue'),
component: () => import('@/views/assets/Domain/DomainDetail/GatewayCreateUpdate.vue'),
meta: {
title: i18n.t('GatewayUpdate'),
permissions: ['assets.change_gateway']

View File

@@ -2,7 +2,6 @@ import defaultSettings from '@/settings'
import { getPublicSettings } from '@/api/settings'
import { changeElementColor, changeThemeColors } from '@/utils/theme/index'
import { changeMenuColor } from '@/utils/theme/color'
import request from '@/utils/request'
const { showSettings, fixedHeader, sidebarLogo, tagsView } = defaultSettings
@@ -13,7 +12,6 @@ const state = {
tagsView: tagsView,
publicSettings: {},
hasValidLicense: false,
authMethods: {},
themeColors: JSON.parse(localStorage.getItem('themeColors')) || {}
}
@@ -80,34 +78,6 @@ const actions = {
changeMenuColor(themeColors)
changeElementColor(themeColors)
commit('setTheme', themeColors)
},
updateAuthItemStatus({ commit }, payload) {
const [key, value] = payload
return new Promise((resolve, reject) => {
const url = '/api/v1/settings/setting/?category=auth'
const data = { [key]: value }
request.patch(url, data).then(res => {
state.authMethods[key] = value
resolve(res)
}).catch(error => {
reject(error)
})
})
},
getAuthMethods({ commit, state }) {
return new Promise((resolve, reject) => {
if (state.authMethods && Object.keys(state.authMethods).length > 0) {
resolve(state.authMethods)
} else {
const url = '/api/v1/settings/setting/?category=auth'
request.get(url).then(res => {
state.authMethods = res
resolve(res)
}).catch(error => {
reject(error)
})
}
})
}
}

View File

@@ -144,9 +144,6 @@ $single-menu-height: 38px;
line-height: $single-menu-height;
display: inline-block;
.el-tooltip {
width: 55px !important;
}
}
.group-title {

View File

@@ -397,9 +397,8 @@ export function getDrawerWidth() {
}
export class ObjectLocalStorage {
constructor(key, attr) {
constructor(key) {
this.key = key
this.attr = attr
}
b64(val) {
@@ -422,9 +421,6 @@ export class ObjectLocalStorage {
get(attr, defaults) {
const obj = this.getObject(this.key)
if (!attr && this.attr) {
attr = this.attr
}
const attrSafe = this.b64(attr)
const val = obj[attrSafe]
if (val === undefined) {
@@ -435,10 +431,6 @@ export class ObjectLocalStorage {
set(attr, value) {
const obj = this.getObject(this.key)
if (value === undefined && this.attr) {
value = attr
attr = this.attr
}
const attrSafe = this.b64(attr)
obj[attrSafe] = value
window.localStorage.setItem(this.key, JSON.stringify(obj))

View File

@@ -167,18 +167,13 @@ export async function changeCurrentViewIfNeed({ to, from, next }) {
Vue.$log.debug('Change has current view, has perm: ', viewName, '=>', has)
if (has) {
await store.dispatch('users/changeToView', viewName)
return { status: 'continue' }
return
}
viewName = getPropView()
// Next 之前要重置 init 状态,否则这些路由守卫就不走了
await store.dispatch('app/reset')
next(`/${viewName}/`)
// new Promise((resolve, reject) => reject('')) 这种方式通过输出发现在页面除此渲染的时候执行两次,
// 返回一个 Promise 我理解是为了中断第一次导航,确保只有第二次导航到到有权限的视图。由于第一个 has 为 false
// 导致被 startup catch 捕获,而 error 的 trace 之所以锁定为到 runtime 等中也是因为由于 Babel 和 Polyfill 的缘故
return { status: 'redirected', to: viewName }
return new Promise((resolve, reject) => reject(''))
}
function onI18nLoaded() {
@@ -214,8 +209,7 @@ export async function startup({ to, from, next }) {
await checkLogin({ to, from, next })
await onI18nLoaded()
await getPublicSetting({ to, from, next }, false)
const viewResult = await changeCurrentViewIfNeed({ to, from, next })
if (viewResult && viewResult.status === 'redirected') return true
await changeCurrentViewIfNeed({ to, from, next })
await changeCurrentOrgIfNeed({ to, from, next })
await generatePageRoutes({ to, from, next })
await checkUserFirstLogin({ to, from, next })

View File

@@ -47,12 +47,7 @@ export default {
showMenu: false,
showAssets: true,
url: '/api/v1/accounts/accounts/',
countResource: 'account',
edit: {
drag: {
isMove: false
}
}
countResource: 'account'
}
}
}

View File

@@ -140,14 +140,7 @@ export default {
hasImport: false,
hasCreate: false,
searchConfig: {
getUrlQuery: true,
exclude: ['asset'],
options: [
{
label: this.$t('AssetName'),
value: 'asset_name'
}
]
getUrlQuery: false
},
hasMoreActions: false
}

View File

@@ -87,8 +87,8 @@ export default {
formatter: DetailFormatter,
minWidth: '180px',
formatterArgs: {
getTitle: ({ row }) => row.automation?.name || row.snapshot.name,
getDrawerTitle: ({ row }) => row.automation?.name || row.snapshot.name,
getTitle: ({ row }) => row.snapshot.name,
getDrawerTitle: ({ row }) => row.snapshot.name,
getRoute: ({ row }) => ({
name: this.automationRoute,
params: { id: row.automation.id }

View File

@@ -61,7 +61,14 @@ export default {
fileChange: ([value], updateForm) => {
this.logo_file = value
}
}
},
rules: [
{
required: true,
message: this.$t('FieldRequiredError'),
trigger: 'blur'
}
]
}
},
hasSaveContinue: false,
@@ -93,6 +100,7 @@ export default {
}
}
},
methods: {}
methods: {
}
}
</script>

View File

@@ -55,7 +55,7 @@ export default {
formatter: DetailFormatter
},
secret: {
label: 'Secret',
label: this.$t('Secret'),
formatter: CopyableFormatter,
formatterArgs: {
shadow: true,

View File

@@ -20,7 +20,7 @@ export default {
category: 'all'
},
tableConfig: {
columnsExclude: ['date_verified', 'spec_info']
columnsExclude: ['date_verified']
},
headerActions: {
handleImportClick: ({ selectedRows }) => {

View File

@@ -1,6 +1,5 @@
import { toSafeLocalDateStr } from '@/utils/time'
import { ActionsFormatter, DetailFormatter, DiscoverConfirmFormatter } from '@/components/Table/TableFormatters'
export const statusMap = {
pending: '0',
confirmed: '1',
@@ -136,7 +135,7 @@ export const gatherAccountHeaderActions = (vm) => {
type: 'primary',
icon: 'fa fa-check',
can: ({ selectedRows }) => {
return selectedRows.length > 0 && vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot
return selectedRows.length > 0 && vm.$hasPerm('accounts.add_account')
},
callback: function({ selectedRows }) {
const ids = selectedRows.map(v => {
@@ -158,7 +157,7 @@ export const gatherAccountHeaderActions = (vm) => {
type: 'primary',
icon: 'fa fa-exchange',
can: ({ selectedRows }) => {
return selectedRows.length > 0 && vm.$hasPerm('accounts.remove_account') && !vm.$store.getters.currentOrgIsRoot
return selectedRows.length > 0 && vm.$hasPerm('accounts.remove_account')
},
callback: function({ selectedRows }) {
vm.gatherAccounts = selectedRows

View File

@@ -55,7 +55,7 @@ export default {
component: AccountFormatter,
el: {
showAddTemplate: false,
enableVirtualAccount: false,
showVirtualAccount: false,
value: ['@ALL'],
assets: []
},

View File

@@ -44,7 +44,7 @@ export default {
component: AccountFormatter,
el: {
showAddTemplate: false,
enableVirtualAccount: false
showVirtualAccount: false
}
},
action: {},

View File

@@ -81,13 +81,6 @@ export default {
return url
},
cleanFormValue(value) {
if (
Array.isArray(value.rules.time_period) &&
value.rules.time_period.every(item => item.value === '')
) {
value.rules.time_period = []
}
if (!Array.isArray(value.rules.ip_group)) {
value.rules.ip_group = value.rules.ip_group ? value.rules.ip_group.split(',') : []
}

View File

@@ -64,7 +64,7 @@ export default {
[this.$t('Basic'), ['name', 'address', 'platform', 'nodes']],
[this.$t('Protocol'), ['protocols']],
[this.$t('Account'), ['accounts']],
[this.$t('Other'), ['directory_services', 'zone', 'labels', 'is_active', 'comment']]
[this.$t('Other'), ['domain', 'labels', 'is_active', 'comment']]
],
fieldsMeta: {},
performSubmit(validValues) {

View File

@@ -37,7 +37,6 @@
{{ $t('Add') }}
</el-button>
<el-button
v-if="$hasLicense() || $route.name !== 'Applets'"
:disabled="!$hasPerm('accounts.view_accounttemplate')"
size="mini"
type="success"
@@ -99,7 +98,6 @@ export default {
},
data() {
const accounts = this.value || []
return {
accounts: accounts,
drawerRefName: null,

View File

@@ -64,7 +64,6 @@ export default {
{
name: this.$t('AccountTemplate'),
title: this.$t('AccountTemplate'),
has: this.$hasLicense() || this.$route.name !== 'Applets',
can: () => this.$hasPerm('accounts.view_accounttemplate') && !this.$store.getters.currentOrgIsRoot,
callback: () => {
this.templateDialogVisible = true
@@ -97,7 +96,7 @@ export default {
},
computed: {
iUrl() {
return this.url || `/api/v1/accounts/accounts/?asset=${this.object.id}`
return this.url || `/api/v1/assets/assets/${this.object.id}/accounts/`
}
},
methods: {

View File

@@ -183,8 +183,8 @@ export default {
url: `/api/v1/assets/assets/${this.object.id}/`,
object: this.object,
fields: [
'id', 'name', 'category', 'type', 'address',
'platform', 'protocols', 'zone', 'directory_services',
'id', 'name', 'category', 'type',
'address', 'platform', 'protocols', 'domain',
'is_active', 'date_created', 'date_updated',
'created_by', 'comment'
],

View File

@@ -1,5 +1,5 @@
<template>
<BaseList v-bind="config" />
<BaseList v-bind="tableConfig" />
</template>
<script>
@@ -11,10 +11,9 @@ export default {
},
data() {
return {
config: {
url: '/api/v1/assets/directories/',
tableConfig: {
category: 'ds',
helpMessage: this.$t('DirectoryServiceHelpMessage')
url: '/api/v1/assets/directories/'
}
}
}

View File

@@ -13,20 +13,7 @@ export default {
return {
config: {
category: 'database',
url: '/api/v1/assets/databases/',
headerActions: {
extraActions: [
{
name: this.$t('CloudSync'),
title: this.$t('CloudSync'),
icon: 'cloud-provider',
has: () => this.$hasPerm('xpack.view_account') && this.$hasLicense(),
callback: () => this.$router.push(
{ name: 'CloudAccountList', query: { category: 'database' }}
)
}
]
}
url: '/api/v1/assets/databases/'
}
}
}

View File

@@ -37,9 +37,7 @@ export default {
title: this.$t('CloudSync'),
icon: 'cloud-provider',
has: () => vm.$hasPerm('xpack.view_account') && vm.$hasLicense(),
callback: () => this.$router.push(
{ name: 'CloudAccountList', query: { category: 'host' }}
)
callback: () => this.$router.push({ name: 'CloudAccountList' })
}
]
},

View File

@@ -41,7 +41,7 @@ export default {
formSetting: {
url: '/api/v1/assets/assets/',
hasSaveContinue: false,
fields: ['platform', 'nodes', 'zone', 'labels', 'is_active', 'comment'],
fields: ['platform', 'nodes', 'domain', 'labels', 'is_active', 'comment'],
fieldsMeta: {
platform: {
el: {
@@ -63,8 +63,8 @@ export default {
...meta.nodes,
label: this.$t('Node')
},
zone: {
...meta.zone,
domain: {
...meta.domain,
label: this.$tc('Zone'),
disabled: exclude.includes(this.category)
},

View File

@@ -126,7 +126,6 @@ export default {
icon: '',
split: true,
has: this.headerActions.hasCreate,
can: !this.$store.getters.currentOrgIsRoot,
callback: () => {
this.showPlatform = false
setTimeout(() => {
@@ -186,10 +185,6 @@ export default {
}
const create = this.createAction
create.dropdown = this.recentPlatforms
create.dropdown.map((item) => {
item.can = !this.$store.getters.currentOrgIsRoot
return item
})
const extraActions = actions.extraActions || []
actions.extraActions = [create, ...extraActions]
// actions.extraActions[0].dropdown = platforms

View File

@@ -22,7 +22,7 @@ export default {
fields: [
'vendor', 'model', 'sn', 'cpu_model', 'cpu_count',
'cpu_cores', 'cpu_vcpus', 'memory', 'disk_total',
'distribution', 'distribution_version', 'arch', 'gpu_model'
'distribution', 'distribution_version', 'arch'
]
}
},

View File

@@ -138,7 +138,7 @@ export default {
strategyRelationConfig: {
title: this.$t('Strategy'),
objectsAjax: {
url: `/api/v1/xpack/cloud/strategies/?category=${this.object.category}`,
url: '/api/v1/xpack/cloud/strategies/',
transformOption: (item) => {
return { label: item.name, value: item.id }
}
@@ -224,12 +224,3 @@ export default {
}
</script>
<style scoped lang="scss">
::v-deep .el-card__body {
padding: 10px 20px 20px 20px;
.el-form {
margin-top: unset;
}
}
</style>

View File

@@ -82,9 +82,8 @@ export default {
},
computed: {
dynamicUrl() {
const category = this.$route.query.category
const baseUrl = `/api/v1/xpack/cloud/sync-instance-tasks/instances/?category=${category}`
return this.object ? `${baseUrl}&task_id=${this.object.task.id}` : baseUrl
const baseUrl = '/api/v1/xpack/cloud/sync-instance-tasks/instances/'
return this.object ? `${baseUrl}?task_id=${this.object.task.id}` : baseUrl
}
},
mounted() {

View File

@@ -21,6 +21,7 @@ export default {
TabPage
},
data() {
const vm = this
return {
Account: {
name: '', provider: '', provider_display: '', validity_display: '', comment: '', date_created: '', created_by: '', task: {}
@@ -43,7 +44,20 @@ export default {
name: 'TaskSyncAssetList',
hidden: () => { return !this.Account.task?.id }
}
]
],
actions: {
hasUpdate: false,
deleteSuccessRoute: 'CloudAccountList',
updateCallback: () => {
const id = this.$route.params.id
const routeName = 'AccountUpdate'
this.$router.push({
name: routeName,
params: { id: id },
query: { provider: vm.Account.provider.value }
})
}
}
}
}
}

View File

@@ -21,7 +21,7 @@
</template>
<script type="text/jsx">
import { lan, privateCloudProviders, publicHostProviders, publicDBProviders } from '../const'
import { lan, privateCloudProviders, publicCloudProviders } from '../const'
import CreateDialog from './components/CreateDialog.vue'
import UpdateDialog from './components/UpdateDialog.vue'
import SyncDialog from './components/SyncDialog.vue'
@@ -43,12 +43,11 @@ export default {
object: null,
table: {
tableConfig: {
url: '',
url: '/api/v1/xpack/cloud/accounts/',
permissions: {
app: 'xpack',
resource: 'account'
},
extraQuery: {}
}
},
subComponentProps: {
handleUpdate: (obj) => {
@@ -103,8 +102,7 @@ export default {
title: this.$t('PublicCloud'),
icon: 'public-cloud',
callback: () => {
const providers = this.iCategory === 'host' ? publicHostProviders : publicDBProviders
this.providerConfig.providers = providers.map(
this.providerConfig.providers = publicCloudProviders.map(
(item) => ACCOUNT_PROVIDER_ATTRS_MAP[item]
)
this.visible = true
@@ -112,9 +110,8 @@ export default {
},
{
name: 'privateCloud',
title: this.$t('PrivateCloud'),
icon: 'private-cloud',
has: () => this.iCategory === 'host',
title: this.$t('PrivateCloud'),
callback: () => {
this.providerConfig.providers = privateCloudProviders.map(
(item) => ACCOUNT_PROVIDER_ATTRS_MAP[item]
@@ -126,7 +123,6 @@ export default {
name: 'LAN',
title: this.$t('LAN'),
icon: 'computer',
has: () => this.iCategory === 'host',
callback: () => {
const providers = [lan]
this.providerConfig.providers = providers.map(
@@ -137,8 +133,7 @@ export default {
}
]
}
},
detailDrawer: () => import('@/views/assets/Cloud/Account/AccountDetail/index.vue')
}
},
providerConfig: {
providers: []
@@ -148,11 +143,6 @@ export default {
onlineSyncVisible: false
}
},
computed: {
iCategory() {
return this.$route.query.category || 'host'
}
},
watch: {
visible: {
handler(val) {
@@ -176,10 +166,6 @@ export default {
}
}
},
mounted() {
this.table.tableConfig.url = '/api/v1/xpack/cloud/accounts/'
this.table.tableConfig.extraQuery = { category: this.iCategory }
},
methods: {
valid(status) {
if (status !== 200) {

View File

@@ -3,7 +3,6 @@
ref="form"
class="form"
v-bind="settings"
@performError="handlePerformError"
@performFinished="handlePerformFinished"
@submitSuccess="handleSubmitSuccess"
/>
@@ -55,7 +54,6 @@ export default {
}
return {
priSubmitForm: null,
submitType: 'auto',
settings: {
url: `/api/v1/xpack/cloud/accounts/`,
@@ -108,9 +106,6 @@ export default {
},
project: {
label: this.$t('Project')
},
hostname_prefix: {
required: false
}
}
},
@@ -169,7 +164,6 @@ export default {
const newValues = JSON.parse(JSON.stringify(values))
newValues['attrs'] = encryptAttrsField(newValues.attrs)
newValues['provider'] = vm.provider
newValues['category'] = this.$route.query.category || 'host'
return newValues
},
addContinue: true
@@ -178,53 +172,32 @@ export default {
},
methods: {
submitForm(form, btn, submitType) {
this.priSubmitForm = form
form.validate((valid) => {
if (valid) {
btn.loading = true
this.$refs.form.$refs.form.dataForm.submitForm('form', false)
this.submitType = submitType
}
})
},
handleSubmitSuccess(res) {
if (this.submitType === 'manual') {
this.$emit('update:object', res)
this.$emit('update:active', 2)
} else if (this.submitType === 'update') {
this.$refs.form.$refs.form.dataForm.submitForm('form', false)
if (this.origin === 'update') {
setTimeout(() => {
this.$emit('submitSuccess')
this.$emit('update:visible', false)
}, 500)
}
this.submitType = submitType
},
handleSubmitSuccess(res) {
if (this.submitType === 'manual') {
this.$emit('update:object', res)
this.$emit('update:active', 2)
}
},
handlePerformFinished() {
for (const btn of this.settings.moreButtons) {
btn.loading = false
}
},
handlePerformError(errorData) {
if (errorData.hasOwnProperty('attrs')) {
for (const f in errorData['attrs']) {
this.setAttrsFieldError(f, errorData['attrs'][f])
}
}
},
setAttrsFieldError(name, errors) {
for (const item of this.priSubmitForm.content) {
if (item.id === 'attrs') {
errors = Array.isArray(errors) ? errors.join(',') : errors
const totalFields = item.el.fields
const field = totalFields.find((v) => v.prop === name)
if (!field) {
return
}
if (typeof errors === 'string') {
field.el.errors = errors
field.attrs.error = errors
}
}
}
}
}
}

View File

@@ -105,10 +105,9 @@ export default {
let url = `/api/v1/xpack/cloud/regions/?account_id=${authInfo}`
if (typeof authInfo === 'object') {
const attrs = JSON.parse(JSON.stringify(authInfo))
const category = this.$route.query.category || 'host'
method = 'post'
url = `/api/v1/xpack/cloud/regions/?provider=${this.provider}&category=${category}`
url = `/api/v1/xpack/cloud/regions/?provider=${this.provider}`
data = { 'attrs': encryptAttrsField(attrs) }
}

View File

@@ -38,10 +38,6 @@ export default {
},
updateSuccessNextRoute: { name: 'CloudAccountList', params: { activeMenu: 'StrategyList' }},
createSuccessNextRoute: { name: 'CloudAccountList', params: { activeMenu: 'StrategyList' }},
cleanFormValue: (value) => {
value['category'] = this.$route.query.category || 'host'
return value
},
getUrl() {
const id = this.$route.params?.id
return id ? `${this.url}${id}/` : this.url

View File

@@ -21,7 +21,7 @@ export default {
createDrawer: () => import('@/views/assets/Cloud/Strategy/StrategyCreateUpdate.vue'),
detailDrawer: () => import('@/views/assets/Cloud/Strategy/StrategyDetail/index.vue'),
tableConfig: {
url: '',
url: '/api/v1/xpack/cloud/strategies/',
permissions: {
app: 'xpack',
resource: 'strategy'
@@ -52,11 +52,10 @@ export default {
updateRoute: 'CloudStrategyUpdate',
hasClone: false,
canDelete: ({ row }) => {
return this.$hasPerm('xpack.delete_strategy') && row.name !== 'default'
return row.name !== 'default'
},
canUpdate: ({ row }) => {
return this.$hasPerm('xpack.change_strategy') && row.name !== 'default' &&
!this.$store.getters.currentOrgIsRoot
return row.name !== 'default'
}
}
}
@@ -70,15 +69,8 @@ export default {
}
}
},
computed: {
iCategory() {
return this.$route.query.category || 'host'
}
},
mounted() {
this.tableConfig.url = `/api/v1/xpack/cloud/strategies/?category=${this.iCategory}`
},
methods: {}
}
</script>

View File

@@ -67,16 +67,14 @@ export default {
let url = ''
let options = []
switch (val) {
case 'platform': {
const category = this.$route.query.category || 'host'
url = `/api/v1/assets/platforms/?category=${category}`
case 'platform':
url = '/api/v1/assets/platforms/?category=host'
break
}
case 'node':
url = '/api/v1/assets/nodes/'
break
case 'zone':
url = '/api/v1/assets/zones/'
case 'domain':
url = '/api/v1/assets/domains/'
break
case 'account_template':
url = '/api/v1/accounts/account-templates/'
@@ -211,7 +209,7 @@ export default {
beforeSubmit(data) {
let status = true
const labelMap = {
platform: this.$tc('Platform'), zone: this.$tc('Zone'),
platform: this.$tc('Platform'), domain: this.$tc('Zone'),
name_strategy: this.$tc('Strategy')
}
this.tableConfig.totalData.map(item => {

View File

@@ -4,7 +4,7 @@ import { attrMatchOptions } from '@/components/const'
export const resourceTypeOptions = [
{ label: i18n.t('Platform'), value: 'platform' },
{ label: i18n.t('Node'), value: 'node' },
{ label: i18n.t('Zone'), value: 'zone' },
{ label: i18n.t('Zone'), value: 'domain' },
{ label: i18n.t('AccountTemplate'), value: 'account_template' },
{ label: i18n.t('Tags'), value: 'label' },
{ label: i18n.t('Strategy'), value: 'name_strategy' }
@@ -20,9 +20,7 @@ export const tableFormatter = (colName, getResourceLabel) => {
return (row, col, cellValue) => {
const globalResource = {}
const value = cellValue
if (value?.label) {
return value.label
}
if (value?.label) { return value.label }
switch (colName) {
case 'attr':
return instanceAttrOptions.find(attr => attr.value === value)?.label || value
@@ -38,9 +36,7 @@ export const tableFormatter = (colName, getResourceLabel) => {
}
return globalResource[value] || value
case 'protocols':
return Array.isArray(value) ? value.map(p => {
return `${p.name}/${p.port}`
}).join(', ') : ''
return Array.isArray(value) ? value.map(p => { return `${p.name}/${p.port}` }).join(', ') : ''
case 'count':
return value?.length || 0
default:

View File

@@ -29,15 +29,13 @@ export const scp = 'scp'
export const apsara_stack = 'apsara_stack'
export const lan = 'lan'
export const publicHostProviders = [
export const publicCloudProviders = [
aliyun, qcloud, qcloud_lighthouse, huaweicloud,
baiducloud, jdcloud, kingsoftcloud, aws_china,
aws_international, azure, azure_international,
gcp, ucloud, volcengine
]
export const publicDBProviders = [aliyun]
export const privateCloudProviders = [
vmware, qingcloud_private, huaweicloud_private, ctyun_private,
openstack, zstack, nutanix, fc, scp, apsara_stack

View File

@@ -13,7 +13,6 @@ export default {
data() {
return {
config: {
title: '',
activeMenu: 'CloudAccountList',
submenu: [
{
@@ -40,11 +39,6 @@ export default {
}
}
}
},
mounted() {
const category = this.$route.query.category || 'host'
const display = category === 'host' ? this.$t('Host') : this.$t('Database')
this.config.title = `${display} - ${this.$t('CloudSync')}`
}
}
</script>

View File

@@ -25,9 +25,9 @@ export default {
component: AssetSelect,
el: {
value: [],
baseUrl: '/api/v1/assets/assets/?gateway_enabled=true',
baseUrl: '/api/v1/assets/assets/?domain_enabled=true',
treeUrlQuery: {
gateway_enabled: true
domain_enabled: true
},
canSelect: (row) => {
return !row.platform?.name.startsWith('Gateway')
@@ -42,7 +42,7 @@ export default {
}
}
},
url: '/api/v1/assets/zones/'
url: '/api/v1/assets/domains/'
}
}
}

View File

@@ -14,7 +14,7 @@
<script>
import BaseList from '@/views/assets/Asset/AssetList/components/BaseList'
import AddAssetDialog from '@/views/assets/Zone/components/AddAssetDialog.vue'
import AddAssetDialog from '@/views/assets/Domain/components/AddAssetDialog.vue'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default {
@@ -34,7 +34,7 @@ export default {
return {
config: {
category: 'all',
url: `/api/v1/assets/assets/?zone=${this.object.id}&is_gateway=0`,
url: `/api/v1/assets/assets/?domain=${this.object.id}&is_gateway=0`,
tableConfig: {
columns: ['name', 'address', 'platform', 'actions'],
columnsMeta: {
@@ -114,14 +114,14 @@ export default {
patch_data = rows.selectedRows.map(row => {
return {
id: row.id,
zone: null
domain: null
}
})
msg = patch_data.length + ' ' + this.$t('Rows')
} else {
patch_data = [{
id: rows.row.id,
zone: null
domain: null
}]
msg = rows.row.name
}

View File

@@ -23,7 +23,7 @@ export default {
},
data() {
return {
url: `/api/v1/assets/zones/${this.object.id}/`,
url: `/api/v1/assets/domains/${this.object.id}/`,
detailFields: [
'name', 'assets_amount',
{

View File

@@ -17,11 +17,11 @@ export default {
const url = `/api/v1/assets/platforms/?name__startswith=Gateway`
const platform = await this.$axios.get(url)
initial.platform = parseInt(platform[0].id)
initial.zone = this.$route.query.zone
initial.domain = this.$route.query.domain
return initial
},
addFieldsMeta: {
zone: {
domain: {
disabled: true
},
platform: {
@@ -40,7 +40,7 @@ export default {
createSuccessNextRoute: {
name: 'ZoneDetail',
params: {
id: this.$route.query.zone
id: this.$route.query.domain
},
query: {
tab: 'GatewayList'
@@ -49,7 +49,7 @@ export default {
updateSuccessNextRoute: {
name: 'ZoneDetail',
params: {
id: this.$route.query.zone
id: this.$route.query.domain
},
query: {
tab: 'GatewayList'

View File

@@ -27,7 +27,7 @@ import { GenericListTable } from '@/layout/components'
import GatewayTestDialog from '@/components/Apps/GatewayTestDialog'
import { connectivityMeta } from '@/components/Apps/AccountListTable/const'
import { ArrayFormatter, ChoicesFormatter, DetailFormatter, TagsFormatter } from '@/components/Table/TableFormatters'
import AddGatewayDialog from '@/views/assets/Zone/components/AddGatewayDialog'
import AddGatewayDialog from '@/views/assets/Domain/components/AddGatewayDialog'
import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default {
@@ -48,7 +48,7 @@ export default {
const vm = this
return {
createDrawer: () => import('@/views/assets/Zone/ZoneDetail/GatewayCreateUpdate.vue'),
createDrawer: () => import('@/views/assets/Domain/DomainDetail/GatewayCreateUpdate.vue'),
detailDrawer: () => import('@/views/assets/Asset/AssetDetail'),
transObject: {},
testConfig: {
@@ -57,7 +57,7 @@ export default {
cell: ''
},
tableConfig: {
url: `/api/v1/assets/gateways/?zone=${this.object.id}`,
url: `/api/v1/assets/gateways/?domain=${this.object.id}`,
columnsExclude: [
'info', 'spec_info', 'auto_config'
],
@@ -113,7 +113,7 @@ export default {
formatterArgs: {
updateRoute: {
name: 'GatewayUpdate',
query: { zone: this.object.id, platform_type: 'linux', 'category': 'host' }
query: { domain: this.object.id, platform_type: 'linux', 'category': 'host' }
},
onClone: ({ row }) => {
this.$refs.ListTable.onClone({ row: { ...row, payload: 'pam_asset_clone' }})
@@ -203,7 +203,7 @@ export default {
}
],
onCreate: () => {
vm.$refs.ListTable.onCreate({ query: { zone: vm.object.id, platform_type: 'linux', category: 'host' }})
vm.$refs.ListTable.onCreate({ query: { domain: vm.object.id, platform_type: 'linux', category: 'host' }})
}
},
addGatewaySetting: {
@@ -222,14 +222,14 @@ export default {
patch_data = rows.selectedRows.map(row => {
return {
id: row.id,
zone: null
domain: null
}
})
msg = patch_data.length + ' ' + this.$t('Rows')
} else {
patch_data = [{
id: rows.row.id,
zone: null
domain: null
}]
msg = rows.row.name
}

View File

@@ -25,7 +25,7 @@ export default {
TaskDetail: {},
config: {
activeMenu: 'Detail',
url: '/api/v1/assets/zones/',
url: '/api/v1/assets/domains/',
submenu: [
{
title: this.$t('Basic'),

View File

@@ -18,10 +18,10 @@ export default {
},
data() {
return {
createDrawer: () => import('./ZoneCreateUpdate.vue'),
detailDrawer: () => import('@/views/assets/Zone/ZoneDetail/index.vue'),
createDrawer: () => import('./DomainCreateUpdate.vue'),
detailDrawer: () => import('./DomainDetail/index.vue'),
tableConfig: {
url: '/api/v1/assets/zones/',
url: '/api/v1/assets/domains/',
columnsExclude: ['gateway'],
columnsExtra: ['gateways'],
columns: ['name', 'assets_amount', 'gateways', 'labels', 'comment', 'actions'],

View File

@@ -5,7 +5,7 @@
:modal="false"
:show-cancel="false"
:show-confirm="false"
:title="$tc('AddAssetInZone')"
:title="$tc('AddAssetInDomain')"
:visible.sync="setting.addAssetDialogVisible"
after
custom-class="asset-select-dialog"
@@ -62,9 +62,9 @@ export default {
type: 'select2',
el: {
value: [],
url: '/api/v1/assets/assets/?gateway_enabled=true',
url: '/api/v1/assets/assets/?domain_enabled=true',
treeUrlQuery: {
gateway_enabled: true
domain_enabled: true
},
canSelect: (row) => {
return !row.platform?.name.startsWith('Gateway') && this.object.assets.map(item => item.id).indexOf(row.id) === -1
@@ -75,7 +75,7 @@ export default {
cleanFormValue(values) {
const data = []
values.assets.forEach(item => {
const d = { id: item, zone: vm.object.id }
const d = { id: item, domain: vm.object.id }
data.push(d)
})
return data

View File

@@ -4,7 +4,7 @@
:destroy-on-close="true"
:show-cancel="false"
:show-confirm="false"
:title="$tc('AddGatewayInZone')"
:title="$tc('AddGatewayInDomain')"
:visible.sync="setting.addGatewayDialogVisible"
after
custom-class="asset-select-dialog"
@@ -65,7 +65,7 @@ export default {
multiple: true,
clearable: true,
ajax: {
url: '/api/v1/assets/assets/?gateway_enabled=true&is_gateway=1'
url: '/api/v1/assets/assets/?domain_enabled=true&is_gateway=1'
},
disabledValues: this.object.gateways.map(item => item.id)
}
@@ -74,7 +74,7 @@ export default {
cleanFormValue(values) {
const data = []
values.gateways.forEach(item => {
const d = { id: item.pk, zone: vm.object.id }
const d = { id: item.pk, domain: vm.object.id }
data.push(d)
})
return data

View File

@@ -50,7 +50,7 @@ export default {
]],
[this.$t('Config'), [
'protocols', 'su_enabled', 'su_method',
'gateway_enabled', 'ds_enabled',
'domain_enabled', 'ds_enabled', 'ds',
'charset'
]],
[this.$t('Automations'), ['automation']],
@@ -60,20 +60,23 @@ export default {
url: `/api/v1/assets/platforms/`,
cleanFormValue: (values) => {
const protocols = values['protocols'] || []
const query = this.$route.query || {}
const automation = values['automation'] || {}
const category_type = values['category_type']
const ansibleConfig = automation?.['ansible_config'] || {}
automation.ansible_config = ansibleConfig instanceof Object ? ansibleConfig : JSON.parse(ansibleConfig)
if (automation.hasOwnProperty('id')) {
delete automation['id']
}
values['protocols'] = protocols.map(i => {
if (i.hasOwnProperty('id')) {
delete i['id']
if (query.hasOwnProperty('_clone_from')) {
if (automation.hasOwnProperty('id')) {
delete automation['id']
}
return i
})
values['protocols'] = protocols.map(i => {
if (i.hasOwnProperty('id')) {
delete i['id']
}
return i
})
}
values['category'] = category_type[0]
values['type'] = category_type[1]
return values
@@ -152,14 +155,14 @@ export default {
})
this.fieldsMeta.protocols.el.choices = protocols
const fieldsCheck = ['gateway_enabled', 'su_enabled']
const fieldsCheck = ['domain_enabled', 'su_enabled']
for (const field of fieldsCheck) {
const disabled = constraints[field] === false
this.initial[field] = !disabled
_.set(this.fieldsMeta, `${field}.el.disabled`, disabled)
}
const fieldsHidden = ['charset', 'ds_enabled']
const fieldsHidden = ['charset_enabled', 'ds_enabled']
for (const field of fieldsHidden) {
if (constraints[field] === false) {
this.fieldsMeta[field].hidden = () => true

View File

@@ -59,7 +59,7 @@ export default {
data() {
return {
visible: false,
fields: ['gateway_enabled'],
fields: ['domain_enabled'],
quickActions: [],
url: `/api/v1/assets/platforms/${this.object.id}/`,
detailFields: [
@@ -101,16 +101,16 @@ export default {
const { object } = this
const quickActions = [
{
title: this.$t('EnableGateway'),
title: this.$t('EnableDomain'),
type: 'switch',
attrs: {
label: this.$t('Update'),
model: object['gateway_enabled'],
disabled: !this.canEdit || this.constraints['gateway_enabled'] === false
model: object['domain_enabled'],
disabled: !this.canEdit || this.constraints['domain_enabled'] === false
},
callbacks: Object.freeze({
change: (val) => {
const data = { gateway_enabled: val }
const data = { domain_enabled: val }
this.$axios.patch(
`/api/v1/assets/platforms/${object.id}/`, data).then(res => {
this.$message.success(this.$tc('UpdateSuccessMsg'))

View File

@@ -73,7 +73,7 @@ export default {
category: {
formatter: ChoicesFormatter
},
gateway_enabled: {
domain_enabled: {
formatterArgs: {
showFalse: false
}
@@ -161,15 +161,6 @@ export default {
} finally {
this.loading = false
}
const name = this.$route.query?.name
const platform = this.$route.query?.id
if (platform) {
this.$nextTick(() => {
this.$refs.genericListTable.onDetail({ row: { id: platform, name }})
})
}
},
updated() {
this.changeMoreCreates()

View File

@@ -76,7 +76,7 @@ export const platformFieldsMeta = (vm) => {
}
},
charset: {},
gateway_enabled: {
domain_enabled: {
el: {
disabled: false
}
@@ -86,7 +86,14 @@ export const platformFieldsMeta = (vm) => {
disabled: false
}
},
ds: {
el: {
multiple: false,
url: '/api/v1/assets/directories/',
disabled: false
},
hidden: (formValue) => !formValue['ds_enabled']
},
protocols: {
label: i18n.t('SupportedProtocol'),
...assetMeta.protocols,

View File

@@ -112,15 +112,18 @@ export const assetFieldsMeta = (vm, category, type) => {
}, 200)
}
},
zone: {
domain: {
component: Select2,
disabled: false,
el: {
multiple: false,
clearable: true,
ajax: {
url: '/api/v1/assets/zones/'
url: '/api/v1/assets/domains/'
}
},
hidden: () => {
return vm.platform.domain_enabled === false
}
},
accounts: {
@@ -130,15 +133,6 @@ export const assetFieldsMeta = (vm, category, type) => {
default: []
}
},
directory_services: {
el: {
url: '/api/v1/assets/directories/',
disabled: false
},
hidden: () => {
return vm.platform.ds_enabled === false
}
},
nodes: {
rules: [rules.RequiredChange],
el: {

View File

@@ -14,12 +14,6 @@
:visible.sync="showSetVariableDialog"
@submit="onSubmitVariable"
/>
<ConfirmRunAssetsDialog
:visible.sync="showConfirmRunAssetsDialog"
:is-running="isRunning"
:assets="classifiedAssets"
@submit="onConfirmRunAsset"
/>
<AssetTreeTable ref="TreeTable" :tree-setting="treeSetting">
<template slot="table">
<div class="transition-box" style="width: calc(100% - 17px);">
@@ -35,10 +29,8 @@
<QuickJobTerm
ref="xterm"
:show-tool-bar="true"
:select-assets="selectAssets"
:xterm-config="xtermConfig"
:execution-info="executionInfo"
@view-assets="viewConfirmRunAssets"
/>
</div>
<div style="display: flex;margin-top:10px;justify-content: space-between" />
@@ -50,7 +42,6 @@
<script>
import $ from '@/utils/jquery-vendor.js'
import _isequal from 'lodash.isequal'
import AssetTreeTable from '@/components/Apps/AssetTreeTable'
import QuickJobTerm from '@/views/ops/Adhoc/components/QuickJobTerm.vue'
import CodeEditor from '@/components/Form/FormFields/CodeEditor'
@@ -58,7 +49,6 @@ import Page from '@/layout/components/Page'
import AdhocOpenDialog from './AdhocOpenDialog.vue'
import AdhocSaveDialog from './AdhocSaveDialog.vue'
import VariableHelpDialog from './VariableHelpDialog.vue'
import ConfirmRunAssetsDialog from './components/ConfirmRunAssetsDialog.vue'
import SetVariableDialog from '@/views/ops/Template/components/SetVariableDialog.vue'
import { createJob, getJob, getTaskDetail, stopJob } from '@/api/ops'
@@ -72,8 +62,7 @@ export default {
AssetTreeTable,
Page,
QuickJobTerm,
CodeEditor,
ConfirmRunAssetsDialog
CodeEditor
},
data() {
return {
@@ -90,7 +79,6 @@ export default {
showOpenAdhocDialog: false,
showOpenAdhocSaveDialog: false,
showSetVariableDialog: false,
showConfirmRunAssetsDialog: false,
DataZTree: 0,
runas: '',
runasPolicy: 'skip',
@@ -147,7 +135,7 @@ export default {
query: (query, cb) => {
const { hosts, nodes } = this.getSelectedNodesAndHosts()
if (hosts.length === 0 && nodes.length === 0) {
if (hosts.length === 0) {
this.$message.warning(`${this.$t('RequiredAssetOrNode')}`)
return cb([])
}
@@ -324,15 +312,7 @@ export default {
},
iShowTree: true,
variableFormData: [],
variableQueryParam: '',
classifiedAssets: {
error: [],
runnable: [],
skipped: []
},
selectAssets: [],
selectNodes: [],
lastRequestPayload: null
variableQueryParam: ''
}
},
computed: {
@@ -341,9 +321,6 @@ export default {
},
ztree() {
return this.$refs.TreeTable.$refs.TreeList.$refs.AutoDataZTree.$refs.AutoDataZTree.$refs.dataztree.$refs.ztree
},
isRunning() {
return this.executionInfo.status.value === 'running'
}
},
watch: {
@@ -465,12 +442,6 @@ export default {
})
return { hosts, nodes }
},
shouldReRequest(payload) {
if (!this.lastRequestPayload) return true
const current = _.omit(payload, ['args'])
const last = _.omit(this.lastRequestPayload, ['args'])
return !_isequal(current, last)
},
execute() {
// const size = 'rows=' + this.xterm.rows + '&cols=' + this.xterm.cols
const { hosts, nodes } = this.getSelectedNodesAndHosts()
@@ -487,34 +458,8 @@ export default {
this.$message.error(this.$tc('RequiredRunas'))
return
}
const payload = {
assets: hosts,
nodes: nodes,
module: this.module,
args: this.command,
runas: this.runas,
runas_policy: this.runasPolicy
}
if (!this.shouldReRequest(payload)) {
this.onConfirmRunAsset(this.selectAssets, this.selectNodes)
return
}
this.lastRequestPayload = { ...payload }
this.$axios.post('/api/v1/ops/classified-hosts/', {
...payload
}).then(data => {
this.classifiedAssets = data
if (this.classifiedAssets.error.length === 0) {
this.onConfirmRunAsset(hosts, nodes)
} else {
this.showConfirmRunAssetsDialog = true
}
})
},
onConfirmRunAsset(assets, nodes) {
const data = {
assets: assets,
assets: hosts,
nodes: nodes,
module: this.module,
args: this.command,
@@ -538,13 +483,8 @@ export default {
this.setCostTimeInterval()
this.writeExecutionOutput()
this.setBtn()
this.selectAssets = assets
this.selectNodes = nodes
})
},
viewConfirmRunAssets() {
this.showConfirmRunAssetsDialog = true
},
stop() {
stopJob({ task_id: this.currentTaskId }).then(() => {
this.xterm.write('\x1b[31m' +
@@ -558,12 +498,12 @@ export default {
})
},
setBtn() {
if (!this.isRunning) {
if (this.executionInfo.status.value !== 'running') {
clearInterval(this.executionInfo.cancel)
this.toolbar.left.run.icon = 'fa fa-play'
}
this.toolbar.left.run.isVisible = this.isRunning
this.toolbar.left.stop.isVisible = !this.isRunning
this.toolbar.left.run.isVisible = this.executionInfo.status.value === 'running'
this.toolbar.left.stop.isVisible = this.executionInfo.status.value !== 'running'
},
onSubmitVariable(parameters) {
this.parameters = parameters

View File

@@ -1,211 +0,0 @@
<template>
<Dialog
:title="$t('ConfirmRunningAssets')"
:visible.sync="iVisible"
:show-buttons="!isRunning"
:show-confirm="true"
:show-cancel="true"
width="1200px"
@confirm="onConfirm"
@cancel="onCancel"
>
<div class="confirm-run-assets-dialog">
<div class="runnable-assets">
<div class="asset-group">
<div class="group-title">
{{ $t('RunnableAssets') }}
</div>
<el-checkbox
v-model="checkAll"
:indeterminate="isIndeterminate"
style="padding-bottom: 5px"
@change="handleCheckAllChange"
>
{{ $t('All') }}
</el-checkbox>
<el-checkbox-group v-model="selectedAssets" class="group-assets" @change="handleCheckedAssetChange">
<el-checkbox
v-for="asset in runnableAssets"
:key="asset.id"
:label="asset.id"
class="asset-item"
>
<div class="asset-item">
<span>{{ asset.name }}<span v-if="asset.ip">({{ asset.ip }})</span></span>
</div>
</el-checkbox>
</el-checkbox-group>
</div>
</div>
<div class="error-assets">
<div class="group-title">{{ $t('NonRunnableAssets') }}</div>
<div class="group-assets">
<div v-for="asset in failedAssets" :key="asset.id" class="asset-item">
<span><i class="fa fa-times-circle icon" />{{ asset.name }}</span>
<span class="asset-status">{{ asset.error }}</span>
</div>
</div>
</div>
</div>
<div>
<div class="selected-count">{{ selectedAssets.length }}{{ $t('AssetsSelected') }}</div>
</div>
</Dialog>
</template>
<script>
import Dialog from '@/components/Dialog'
export default {
name: 'ConfirmRunAssetsDialog',
components: {
Dialog
},
props: {
visible: {
type: Boolean,
default: false
},
assets: {
type: Object,
default: () => {
}
},
isRunning: {
type: Boolean,
default: false
}
},
data() {
return {
checkAll: true,
selectedAssets: [],
isIndeterminate: true
}
},
computed: {
iVisible: {
set(val) {
this.$emit('update:visible', val)
},
get() {
return this.visible
}
},
runnableAssets() {
return this.assets.runnable
},
failedAssets() {
return this.assets.error
}
},
watch: {
visible(val) {
if (val === true && this.selectedAssets.length === 0) {
// 首次打开时,默认选中所有可运行的资产
this.selectedAssets = this.runnableAssets.map((item) => item.id)
}
},
runnableAssets(val) {
// 去掉 selectedAssets 中不存在的 id
this.selectedAssets = this.selectedAssets.filter((item) => {
return val.some((asset) => asset.id === item)
})
}
},
methods: {
onCancel() {
this.$emit('update:visible', false)
},
onConfirm() {
this.$emit('submit', this.selectedAssets, [])
this.$emit('update:visible', false)
},
handleCheckAllChange(value) {
this.selectedAssets = value ? this.runnableAssets.map((item) => item.id) : []
this.isIndeterminate = false
},
handleCheckedAssetChange(value) {
const checkedCount = value.length
this.checkAll = checkedCount === this.runnableAssets.length
this.isIndeterminate = checkedCount > 0 && checkedCount < this.runnableAssets.length
}
}
}
</script>
<style scoped lang="scss">
.confirm-run-assets-dialog {
.runnable-assets {
padding-right: 10px
}
display: grid;
grid-template-columns: 1fr 1fr;
grid-column-gap: 10px;
.group-title {
font-weight: bold;
margin-bottom: 8px;
font-size: 15px;
background: #fbfbfd;
padding: 10px;
}
.group-assets {
::v-deep .el-checkbox__label {
display: inline-block;
padding-left: 10px;
line-height: 19px;
font-size: 13px;
width: 100%;
}
max-height: 300px;
overflow-y: auto;
scrollbar-width: none;
display: grid;
grid-template-columns: 1fr;
grid-row-gap: 5px;
justify-items: start;
.asset-item {
display: flex;
grid-template-columns: 1fr 1fr;
justify-content: space-between;
width: 100%;
border-bottom: 1px solid #eee;
.icon {
color: #ed5565;
padding-right: 3px
}
.asset-ip {
padding-right: 10px;
}
.asset-status {
padding-right: 10px;
color: #ed5565
}
}
}
.group-assets::-webkit-scrollbar {
display: none;
}
.footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 16px;
}
.selected-count {
color: #1ab394;
}
}
</style>

Some files were not shown because too many files have changed in this diff Show More