Compare commits

..

1 Commits

Author SHA1 Message Date
feng
fc5da73384 perf: risk detail 2025-02-28 11:37:23 +08:00
569 changed files with 7372 additions and 13338 deletions

View File

@@ -14,97 +14,64 @@ module.exports = {
window: true, window: true,
_: true _: true
}, },
plugins: ['vue', 'spellcheck'],
// add your custom rules here // add your custom rules here
// it is base on https://github.com/vuejs/eslint-config-vue // it is base on https://github.com/vuejs/eslint-config-vue
rules: { rules: {
'vue/max-attributes-per-line': [ 'vue/max-attributes-per-line': [2, {
2, 'singleline': 10,
{ 'multiline': {
singleline: 10, 'max': 1,
multiline: { 'allowFirstLine': false
max: 1,
allowFirstLine: false
}
} }
], }],
'vue/singleline-html-element-content-newline': 'off', 'vue/singleline-html-element-content-newline': 'off',
'vue/multiline-html-element-content-newline': 'off', 'vue/multiline-html-element-content-newline': 'off',
'vue/name-property-casing': ['error', 'PascalCase'], 'vue/name-property-casing': ['error', 'PascalCase'],
'vue/no-v-html': 'off', 'vue/no-v-html': 'off',
'accessor-pairs': 2, 'accessor-pairs': 2,
'arrow-spacing': [ 'arrow-spacing': [2, {
2, 'before': true,
{ 'after': true
before: true, }],
after: true
}
],
'block-spacing': [2, 'always'], 'block-spacing': [2, 'always'],
'brace-style': [ 'brace-style': [2, '1tbs', {
2, 'allowSingleLine': true
'1tbs', }],
{ 'camelcase': [0, {
allowSingleLine: true 'properties': 'always'
} }],
],
camelcase: [
0,
{
properties: 'always'
}
],
'comma-dangle': [2, 'never'], 'comma-dangle': [2, 'never'],
'comma-spacing': [ 'comma-spacing': [2, {
2, 'before': false,
{ 'after': true
before: false, }],
after: true
}
],
'comma-style': [2, 'last'], 'comma-style': [2, 'last'],
'constructor-super': 2, 'constructor-super': 2,
curly: [2, 'multi-line'], 'curly': [2, 'multi-line'],
'dot-location': [2, 'property'], 'dot-location': [2, 'property'],
'eol-last': 2, 'eol-last': 2,
eqeqeq: ['error', 'always', { null: 'ignore' }], 'eqeqeq': ['error', 'always', { 'null': 'ignore' }],
'generator-star-spacing': [ 'generator-star-spacing': [2, {
2, 'before': true,
{ 'after': true
before: true, }],
after: true
}
],
'handle-callback-err': [2, '^(err|error)$'], 'handle-callback-err': [2, '^(err|error)$'],
indent: [ 'indent': [2, 2, {
2, 'SwitchCase': 1
2, }],
{
SwitchCase: 1
}
],
'jsx-quotes': [2, 'prefer-single'], 'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [ 'key-spacing': [2, {
2, 'beforeColon': false,
{ 'afterColon': true
beforeColon: false, }],
afterColon: true 'keyword-spacing': [2, {
} 'before': true,
], 'after': true
'keyword-spacing': [ }],
2, 'new-cap': [2, {
{ 'newIsCap': true,
before: true, 'capIsNew': false
after: true }],
}
],
'new-cap': [
2,
{
newIsCap: true,
capIsNew: false
}
],
'new-parens': 2, 'new-parens': 2,
'no-array-constructor': 2, 'no-array-constructor': 2,
'no-caller': 2, 'no-caller': 2,
@@ -135,23 +102,17 @@ module.exports = {
'no-irregular-whitespace': 2, 'no-irregular-whitespace': 2,
'no-iterator': 2, 'no-iterator': 2,
'no-label-var': 2, 'no-label-var': 2,
'no-labels': [ 'no-labels': [2, {
2, 'allowLoop': false,
{ 'allowSwitch': false
allowLoop: false, }],
allowSwitch: false
}
],
'no-lone-blocks': 2, 'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2, 'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2, 'no-multi-spaces': 2,
'no-multi-str': 2, 'no-multi-str': 2,
'no-multiple-empty-lines': [ 'no-multiple-empty-lines': [2, {
2, 'max': 1
{ }],
max: 1
}
],
'no-native-reassign': 2, 'no-native-reassign': 2,
'no-negated-in-lhs': 2, 'no-negated-in-lhs': 2,
'no-new-object': 2, 'no-new-object': 2,
@@ -179,125 +140,62 @@ module.exports = {
'no-undef-init': 2, 'no-undef-init': 2,
'no-unexpected-multiline': 2, 'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2, 'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [ 'no-unneeded-ternary': [2, {
2, 'defaultAssignment': false
{ }],
defaultAssignment: false
}
],
'no-unreachable': 2, 'no-unreachable': 2,
'no-unsafe-finally': 2, 'no-unsafe-finally': 2,
'no-unused-vars': [ 'no-unused-vars': [2, {
2, 'vars': 'all',
{ 'args': 'none'
vars: 'all', }],
args: 'none'
}
],
'no-useless-call': 2, 'no-useless-call': 2,
'no-useless-computed-key': 2, 'no-useless-computed-key': 2,
'no-useless-constructor': 2, 'no-useless-constructor': 2,
'no-useless-escape': 0, 'no-useless-escape': 0,
'no-whitespace-before-property': 2, 'no-whitespace-before-property': 2,
'no-with': 2, 'no-with': 2,
'one-var': [ 'one-var': [2, {
2, 'initialized': 'never'
{ }],
initialized: 'never' 'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
} }
], }],
'operator-linebreak': [
2,
'after',
{
overrides: {
'?': 'before',
':': 'before'
}
}
],
'padded-blocks': [2, 'never'], 'padded-blocks': [2, 'never'],
quotes: [ 'quotes': [2, 'single', {
2, 'avoidEscape': true,
'single', 'allowTemplateLiterals': true
{ }],
avoidEscape: true, 'semi': [2, 'never'],
allowTemplateLiterals: true 'semi-spacing': [2, {
} 'before': false,
], 'after': true
semi: [2, 'never'], }],
'semi-spacing': [
2,
{
before: false,
after: true
}
],
'space-before-blocks': [2, 'always'], 'space-before-blocks': [2, 'always'],
'space-before-function-paren': [ 'space-before-function-paren': [2, 'never'],
2,
{ anonymous: 'never', named: 'never', asyncArrow: 'always' }
],
'space-in-parens': [2, 'never'], 'space-in-parens': [2, 'never'],
'space-infix-ops': 2, 'space-infix-ops': 2,
'space-unary-ops': [ 'space-unary-ops': [2, {
2, 'words': true,
{ 'nonwords': false
words: true, }],
nonwords: false 'spaced-comment': [2, 'always', {
} 'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
], }],
'object-curly-spacing': [2, 'always'],
'spaced-comment': [
2,
'always',
{
markers: ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}
],
'template-curly-spacing': [2, 'never'], 'template-curly-spacing': [2, 'never'],
'use-isnan': 2, 'use-isnan': 2,
'valid-typeof': 2, 'valid-typeof': 2,
'wrap-iife': [2, 'any'], 'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'], 'yield-star-spacing': [2, 'both'],
yoda: [2, 'never'], 'yoda': [2, 'never'],
'prefer-const': 2, 'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'array-bracket-spacing': [2, 'never'], 'object-curly-spacing': [2, 'always', {
'spellcheck/spell-checker': [ objectsInObjects: false
'warn', }],
{ 'array-bracket-spacing': [2, 'never']
comments: true,
strings: false,
identifiers: false,
lang: 'en_US',
skipWords: [
'echarts',
'resize',
'vue',
'eslint',
'babel',
'jsx',
'scss',
'v-deep',
'calc',
'vw',
'vh',
'px',
'rgba',
'rgb',
'var',
'lang',
'scoped',
'pdf',
'rbac'
],
skipIfMatch: [
'http://[^s]*',
'^[-\\w]+/[-\\w\\.]+$' // For import paths
],
minLength: 3
}
]
} }
} }

View File

@@ -1,11 +0,0 @@
{
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"semi": false,
"trailingComma": "none",
"bracketSpacing": true,
"arrowParens": "avoid",
"endOfLine": "lf"
}

View File

@@ -1,11 +0,0 @@
module.exports = {
singleQuote: true,
semi: false,
trailingComma: 'none',
printWidth: 100,
tabWidth: 2,
useTabs: false,
bracketSpacing: true,
arrowParens: 'avoid',
endOfLine: 'auto'
}

View File

@@ -1,4 +1,4 @@
FROM jumpserver/lina-base:20250805_081024 AS stage-build FROM jumpserver/lina-base:20240723_084702 AS stage-build
ARG VERSION ARG VERSION
ENV VERSION=$VERSION ENV VERSION=$VERSION

View File

@@ -1,25 +1,13 @@
import Mock from 'mockjs' import Mock from 'mockjs'
import { param2Obj } from '../src/utils'
import user from './user' import user from './user'
import table from './table' import table from './table'
export function param2Obj(url) { const mocks = [
const search = url.split('?')[1] ...user,
if (!search) { ...table
return {} ]
}
return JSON.parse(
'{"' +
decodeURIComponent(search)
.replace(/"/g, '\\"')
.replace(/&/g, '","')
.replace(/=/g, '":"')
.replace(/\+/g, ' ') +
'"}'
)
}
const mocks = [...user, ...table]
// for front mock // for front mock
// please use it cautiously, it will redefine XMLHttpRequest, // please use it cautiously, it will redefine XMLHttpRequest,

View File

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

View File

@@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="0" http-equiv="Expires"> <meta content="0" http-equiv="Expires">
@@ -20,71 +20,52 @@
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background-color: rgba(255, 255, 255, 0.98); background-color: white;
z-index: 9999; z-index: 9999;
} }
#loading .spinner { .spinner {
width: 40px; width: 50px;
height: 40px; height: 50px;
border: 3px solid transparent; border: 5px solid rgba(0, 0, 0, 0.1);
border-top-color: var(--color-primary);
border-radius: 50%; border-radius: 50%;
animation: spin 1s linear infinite; border-top-color: #3498db;
} animation: spin 1s infinite linear;
#loading .spinner::after {
content: '';
position: absolute;
top: -3px;
left: -3px;
width: 40px;
height: 40px;
border: 3px solid transparent;
border-top-color: rgba(64, 158, 255, 0.2);
border-radius: 50%;
animation: spin 2s linear infinite;
} }
@keyframes spin { @keyframes spin {
0% { to {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg); transform: rotate(360deg);
} }
} }
</style> </style>
</head> </head>
<body> <body>
<noscript> <noscript>
<strong> <strong>We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
We're sorry but <%= webpackConfig.name %> doesn't work properly without JavaScript enabled. </noscript>
Please enable it to continue. <script>
</strong> window.onload = function () {
</noscript> if (location.pathname === '/') {
<script> location.pathname = '/ui/'
window.onload = function () { }
if (location.pathname === '/') { const pathname = window.location.pathname
location.pathname = '/ui/' if (pathname.startsWith('/core')) {
} return
const pathname = window.location.pathname }
if (pathname.startsWith('/core')) { if (pathname.indexOf('/ui') === -1) {
return window.location.href = window.location.origin + '/ui/#' + pathname
} }
if (pathname.indexOf('/ui') === -1) { if (pathname.startsWith('/ui/#/chat')) {
window.location.href = window.location.origin + '/ui/#' + pathname window.location.href = window.location.origin + pathname
} }
if (pathname.startsWith('/ui/#/chat')) { }
window.location.href = window.location.origin + pathname </script>
} <div id="app">
} </div>
</script> <div id="loading">
<div id="app"> <div class="spinner"></div>
</div> </div>
<div id="loading"> <!-- built files will be auto injected -->
<div class="spinner"></div> </body>
</div>
<!-- built files will be auto injected -->
</body>
</html> </html>

View File

@@ -5,90 +5,14 @@
</template> </template>
<script> <script>
import { mapState, mapGetters } from 'vuex' import { mapState } from 'vuex'
import { Watermark } from 'watermark-js-plus'
export default { export default {
name: 'App', name: 'App',
data() {
return {
watermark: null
}
},
computed: { computed: {
...mapState({ ...mapState({
isRouterAlive: state => state.common.isRouterAlive isRouterAlive: state => state.common.isRouterAlive
}),
...mapGetters({
currentUser: 'currentUser',
publicSettings: 'publicSettings'
}) })
},
watch: {
currentUser: {
handler(newVal) {
this.createWatermark()
}
},
'publicSettings.SECURITY_WATERMARK_ENABLED': {
handler(newVal) {
if (!newVal) {
return setTimeout(() => {
this.watermark?.destroy()
this.watermark = null
})
}
this.createWatermark()
}
}
},
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,
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
})
this.watermark.create()
}
}
} }
} }
</script> </script>

View File

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

View File

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

@@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1752631175762" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4421" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M93.866667 234.666667c-34.133333 12.8-51.2 25.6-51.2 34.133333 0 4.266667 51.2 64 115.2 136.533333 64 68.266667 115.2 128 115.2 128s-51.2 59.733333-115.2 128C93.866667 729.6 42.666667 793.6 42.666667 797.866667c4.266667 17.066667 59.733333 42.666667 98.133333 42.666666 64 0 81.066667-12.8 217.6-162.133333 68.266667-76.8 128-140.8 128-140.8 0-4.266667-55.466667-64-123.733333-140.8-85.333333-102.4-132.266667-145.066667-153.6-157.866667-29.866667-12.8-81.066667-17.066667-115.2-4.266666z m725.333333 4.266666c-21.333333 8.533333-68.266667 59.733333-153.6 153.6-68.266667 76.8-123.733333 140.8-123.733333 140.8 0 4.266667 55.466667 68.266667 128 140.8 136.533333 153.6 153.6 162.133333 217.6 162.133334 42.666667 0 98.133333-21.333333 98.133333-42.666667 0-4.266667-51.2-68.266667-115.2-136.533333-64-68.266667-115.2-128-115.2-128s51.2-59.733333 115.2-128c64-68.266667 115.2-128 115.2-136.533334-4.266667-17.066667-55.466667-38.4-98.133333-38.4-34.133333 0-46.933333 4.266667-68.266667 12.8z" fill="#E57000" p-id="4422"></path><path d="M238.933333 136.533333c-42.666667 21.333333-42.666667 25.6-4.266666 68.266667 221.866667 243.2 273.066667 302.933333 277.333333 302.933333 4.266667 0 311.466667-332.8 315.733333-341.333333 0-4.266667-8.533333-12.8-21.333333-21.333333-17.066667-12.8-34.133333-17.066667-68.266667-17.066667-64-4.266667-85.333333 8.533333-162.133333 93.866667-34.133333 38.4-64 72.533333-64 72.533333s-29.866667-29.866667-64-68.266667c-34.133333-38.4-72.533333-76.8-89.6-85.333333-25.6-17.066667-89.6-21.333333-119.466667-4.266667zM354.133333 725.333333c-85.333333 93.866667-153.6 170.666667-153.6 174.933334 0 4.266667 8.533333 12.8 21.333334 21.333333 17.066667 12.8 34.133333 17.066667 68.266666 17.066667 59.733333 4.266667 85.333333-8.533333 162.133334-98.133334 34.133333-38.4 64-68.266667 64-68.266666s29.866667 29.866667 64 68.266666c81.066667 89.6 98.133333 102.4 162.133333 98.133334 34.133333 0 51.2-4.266667 68.266667-17.066667 12.8-8.533333 21.333333-17.066667 21.333333-21.333333-4.266667-8.533333-311.466667-345.6-315.733333-341.333334-8.533333 0-76.8 76.8-162.133334 166.4z" p-id="4423"></path></svg>

Before

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -1 +0,0 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1748326203303" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2853" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M10.24 605.184l839.168-481.28L1013.76 220.672v191.488L174.592 895.488 10.24 804.352z" fill="#0096FF" p-id="2854"></path><path d="M10.24 416.768V220.672l168.96-96.768 308.736 178.688-331.776 193.536zM541.184 717.312l331.264-195.072 141.312 88.064v194.048l-165.376 95.744z" fill="#25C764" p-id="2855"></path></svg>

Before

Width:  |  Height:  |  Size: 645 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -3,7 +3,7 @@
</template> </template>
<script> <script>
import DataActions from '@/components/Common/DataActions/index.vue' import DataActions from '@/components/DataActions'
export default { export default {
name: 'ActionsGroup', name: 'ActionsGroup',

View File

@@ -1,26 +1,24 @@
import { UpdateToken, UploadSecret } from '@/components/Form/FormFields' import { UpdateToken, UploadSecret } from '@/components/Form/FormFields'
import Select2 from '@/components/Form/FormFields/Select2.vue' import Select2 from '@/components/Form/FormFields/Select2.vue'
import AssetSelect from '@/components/Apps/AssetSelect/index.vue'
import { Required, RequiredChange } from '@/components/Form/DataForm/rules' import { Required, RequiredChange } from '@/components/Form/DataForm/rules'
import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue' import AutomationParamsForm from '@/views/assets/Platform/AutomationParamsSetting.vue'
export const accountFieldsMeta = (vm) => { export const accountFieldsMeta = (vm) => {
const defaultPrivilegedAccounts = ['root', 'administrator'] const defaultPrivilegedAccounts = ['root', 'administrator']
function onPrivilegedUser(value, updateForm) {
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true, secret_reset: false, push_now: false })
}
}
return { return {
assets: { assets: {
component: AssetSelect, component: Select2,
label: vm.$t('Asset'), label: vm.$t('Assets'),
rules: [Required], rules: [Required],
el: { el: {
multiple: false multiple: true,
ajax: {
url: '/api/v1/assets/assets/',
transformOption: (item) => {
return { label: item.name + '(' + item.address + ')', value: item.id }
}
}
}, },
hidden: () => { hidden: () => {
return vm.platform || vm.asset return vm.platform || vm.asset
@@ -72,8 +70,11 @@ export const accountFieldsMeta = (vm) => {
if (!vm.account?.name) { if (!vm.account?.name) {
updateForm({ username: value }) updateForm({ username: value })
} }
const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true })
}
} }
onPrivilegedUser(value, updateForm)
} }
}, },
hidden: () => { hidden: () => {
@@ -91,7 +92,10 @@ export const accountFieldsMeta = (vm) => {
vm.usernameChanged = true vm.usernameChanged = true
}, },
change: ([value], updateForm) => { change: ([value], updateForm) => {
onPrivilegedUser(value, updateForm) const maybePrivileged = defaultPrivilegedAccounts.includes(value)
if (maybePrivileged) {
updateForm({ privileged: true })
}
} }
}, },
hidden: () => { hidden: () => {
@@ -117,6 +121,11 @@ export const accountFieldsMeta = (vm) => {
el: { el: {
multiple: false, multiple: false,
clearable: true, clearable: true,
disabled: {
get disabled() {
return vm.isDisabled
}
},
ajax: { ajax: {
url: `/api/v1/accounts/accounts/su-from-accounts/?account=${vm.account?.id || ''}&asset=${vm.asset?.id || ''}`, url: `/api/v1/accounts/accounts/su-from-accounts/?account=${vm.account?.id || ''}&asset=${vm.asset?.id || ''}`,
transformOption: (item) => { transformOption: (item) => {
@@ -230,9 +239,6 @@ export const accountFieldsMeta = (vm) => {
el: {}, el: {},
hidden: (formValue) => { hidden: (formValue) => {
const automation = vm.iPlatform.automation || {} const automation = vm.iPlatform.automation || {}
if (!vm.iPlatform.automation) {
return true
}
vm.fieldsMeta.params.el.method = vm.iPlatform.automation.push_account_method vm.fieldsMeta.params.el.method = vm.iPlatform.automation.push_account_method
vm.fieldsMeta.params.el.pushAccountParams = vm.iPlatform.automation.push_account_params vm.fieldsMeta.params.el.pushAccountParams = vm.iPlatform.automation.push_account_params
return !formValue.push_now || return !formValue.push_now ||

View File

@@ -11,7 +11,7 @@
<script> <script>
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue' import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
import { encryptPassword } from '@/utils/secure' import { encryptPassword } from '@/utils/crypto'
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const' import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
export default { export default {
@@ -63,7 +63,7 @@ export default {
encryptedFields: ['secret'], encryptedFields: ['secret'],
fields: [ fields: [
[this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username', 'template']], [this.$t('Basic'), ['name', 'username', 'privileged', 'su_from', 'su_from_username', 'template']],
[this.$t('Asset'), ['assets']], [this.$t('Assets'), ['assets']],
[this.$t('Secret'), [ [this.$t('Secret'), [
'secret_type', 'password', 'ssh_key', 'token', 'secret_type', 'password', 'ssh_key', 'token',
'access_key', 'passphrase', 'api_key', 'access_key', 'passphrase', 'api_key',

View File

@@ -11,7 +11,7 @@
<script> <script>
import { GenericUpdateFormDialog } from '@/layout/components' import { GenericUpdateFormDialog } from '@/layout/components'
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const' import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
import { encryptPassword } from '@/utils/secure' import { encryptPassword } from '@/utils/crypto'
export default { export default {
name: 'AccountBulkUpdateDialog', name: 'AccountBulkUpdateDialog',

View File

@@ -24,7 +24,7 @@
<script> <script>
import Drawer from '@/components/Drawer/index.vue' import Drawer from '@/components/Drawer/index.vue'
import AccountCreateUpdateForm from '@/components/Apps/AccountCreateUpdateForm/index.vue' import AccountCreateUpdateForm from '@/components/Apps/AccountCreateUpdateForm/index.vue'
import IBox from '@/components/Common/IBox/index.vue' import IBox from '@/components/IBox/index.vue'
import Page from '@/layout/components/Page/index.vue' import Page from '@/layout/components/Page/index.vue'
export default { export default {
@@ -184,7 +184,7 @@ export default {
}, },
handleCloseDrawer() { handleCloseDrawer() {
this.iVisible = false this.iVisible = false
// Reflect.deleteProperty(this.$route.query, 'flag') Reflect.deleteProperty(this.$route.query, 'flag')
}, },
handleAccountOperation(id, path, data) { handleAccountOperation(id, path, data) {
this.$axios.post(`/api/v1/accounts/accounts/${id}/${path}/`, data).then((res) => { this.$axios.post(`/api/v1/accounts/accounts/${id}/${path}/`, data).then((res) => {

View File

@@ -50,15 +50,9 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex' import { accountOtherActions, accountQuickFilters, connectivityMeta } from './const'
import { accountOtherActions, accountQuickFilters, connectivityMeta, isDirectoryServiceAccount } from './const' import { openTaskPage } from '@/utils/jms'
import { openTaskPage } from '@/utils/jms/index' import { ActionsFormatter, PlatformFormatter, SecretViewerFormatter, AccountConnectFormatter } from '@/components/Table/TableFormatters'
import {
AccountConnectFormatter,
ActionsFormatter,
PlatformFormatter,
SecretViewerFormatter
} from '@/components/Table/TableFormatters'
import ViewSecret from './ViewSecret.vue' import ViewSecret from './ViewSecret.vue'
import UpdateSecretInfo from './UpdateSecretInfo.vue' import UpdateSecretInfo from './UpdateSecretInfo.vue'
import ResultDialog from './BulkCreateResultDialog.vue' import ResultDialog from './BulkCreateResultDialog.vue'
@@ -143,17 +137,12 @@ export default {
showQuickFilters: { showQuickFilters: {
type: Boolean, type: Boolean,
default: true default: true
},
showActions: {
type: Boolean,
default: true
} }
}, },
data() { data() {
const vm = this const vm = this
return { return {
addTemplate: false, addTemplate: false,
isUpdateAccount: false,
currentAccountColumn: {}, currentAccountColumn: {},
showPasswordHistoryDialog: false, showPasswordHistoryDialog: false,
showViewSecretDialog: false, showViewSecretDialog: false,
@@ -182,21 +171,9 @@ export default {
}, },
columnsMeta: { columnsMeta: {
name: { name: {
minWidth: '60px', width: '120px',
formatterArgs: { formatterArgs: {
can: () => vm.$hasPerm('accounts.view_account'), can: () => vm.$hasPerm('accounts.view_account'),
getRoute: ({ row }) => ({
name: 'AccountDetail',
params: { id: row.id }
}),
getTitle: ({ row }) => {
let title = row.name
if (row.ds && this.asset && this.asset.id !== row.asset.id) {
const dsID = row.ds.id.split('-')[0]
title = `${row.name}@${dsID}`
}
return title
},
getDrawerTitle({ row }) { getDrawerTitle({ row }) {
return `${row.username}@${row.asset.name}` return `${row.username}@${row.asset.name}`
} }
@@ -216,45 +193,33 @@ export default {
width: '80px', width: '80px',
formatter: AccountConnectFormatter, formatter: AccountConnectFormatter,
formatterArgs: { formatterArgs: {
asset: this.asset, buttonIcon: 'fa fa-desktop',
can: ({ row }) => { titleText: '可选协议',
return this.currentUserIsSuperAdmin url: '/api/v1/assets/assets/{id}',
} connectUrlTemplate: (row) => `/luna/pam_connect/${row.id}/${row.username}/${row.asset.id}/${row.asset.name}/`,
} setMapItem: (id, protocol) => {
}, this.$store.commit('table/SET_PROTOCOL_MAP_ITEM', {
ds: { key: id,
width: '100px', value: protocol
formatter: (row) => { })
if (row.ds && row.ds['domain_name']) {
return row.ds['domain_name']
} else {
return ''
} }
} }
}, },
platform: { platform: {
label: this.$t('Platform'), label: this.$t('Platform'),
width: '150px', width: '120px',
formatter: PlatformFormatter, formatter: PlatformFormatter,
formatterArgs: { formatterArgs: {
platformAttr: 'asset.platform' platformAttr: 'asset.platform'
} }
}, },
asset: { asset: {
minWidth: '100px',
formatter: function(row) { formatter: function(row) {
return row.asset.name return row.asset.name
} }
}, },
username: { username: {
minWidth: '60px', width: '120px'
formatter: function(row) {
if (row.ds && row.ds['domain_name']) {
return `${row.username}@${row.ds['domain_name']}`
} else {
return row.username
}
}
}, },
secret_type: { secret_type: {
formatter: function(row) { formatter: function(row) {
@@ -282,17 +247,11 @@ export default {
connectivity: connectivityMeta, connectivity: connectivityMeta,
actions: { actions: {
formatter: ActionsFormatter, formatter: ActionsFormatter,
has: this.showActions,
formatterArgs: { 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) hasUpdate: false, // can set function(row, value)
hasDelete: true, // can set function(row, value) hasDelete: true, // can set function(row, value)
hasClone: false, hasClone: false,
canDelete: ({ row }) => vm.$hasPerm('accounts.delete_account') && !isDirectoryServiceAccount(row, this), canDelete: () => vm.$hasPerm('accounts.delete_account'),
moreActionsTitle: this.$t('More'), moreActionsTitle: this.$t('More'),
extraActions: accountOtherActions(this) extraActions: accountOtherActions(this)
} }
@@ -323,15 +282,16 @@ export default {
type: 'primary', type: 'primary',
icon: 'plus', icon: 'plus',
can: () => { can: () => {
return vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
}, },
callback: () => { callback: async() => {
await this.getAssetDetail()
setTimeout(() => { setTimeout(() => {
vm.iAsset = this.asset vm.iAsset = this.asset
vm.account = {} vm.account = {}
this.addTemplate = false vm.addTemplate = false
this.showAddDialog = true vm.showAddDialog = true
}, 200) })
} }
}, },
{ {
@@ -339,9 +299,9 @@ export default {
title: this.$t('TemplateAdd'), title: this.$t('TemplateAdd'),
has: !(this.platform || this.asset), has: !(this.platform || this.asset),
can: () => { can: () => {
return vm.$hasPerm('accounts.add_account') && !vm.$store.getters.currentOrgIsRoot return vm.$hasPerm('accounts.add_account') && !this.$store.getters.currentOrgIsRoot
}, },
callback: async () => { callback: async() => {
await this.getAssetDetail() await this.getAssetDetail()
setTimeout(() => { setTimeout(() => {
vm.iAsset = this.asset vm.iAsset = this.asset
@@ -362,7 +322,7 @@ export default {
can: ({ selectedRows }) => { can: ({ selectedRows }) => {
return selectedRows.length > 0 && return selectedRows.length > 0 &&
['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 && ['clickhouse', 'redis', 'website', 'chatgpt'].indexOf(selectedRows[0].asset.type.value) === -1 &&
!this.$store.getters.currentOrgIsRoot && vm.$hasPerm('accounts.verify_account') !this.$store.getters.currentOrgIsRoot
}, },
callback: function({ selectedRows }) { callback: function({ selectedRows }) {
const ids = selectedRows.map(v => { const ids = selectedRows.map(v => {
@@ -428,12 +388,9 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters(['currentUserIsSuperAdmin']),
accountCreateUpdateTitle() { accountCreateUpdateTitle() {
if (this.addTemplate) { if (this.addTemplate) {
return this.$t('AddAccountByTemplate') return this.$t('AddAccountByTemplate')
} else if (this.isUpdateAccount) {
return this.$t('UpdateAccount')
} else { } else {
return this.$t('AddAccount') return this.$t('AddAccount')
} }
@@ -473,12 +430,11 @@ export default {
Object.assign(this.account, account) Object.assign(this.account, account)
}, },
addAccountSuccess() { addAccountSuccess() {
// Reflect.deleteProperty(this.$route.query, 'flag') Reflect.deleteProperty(this.$route.query, 'flag')
this.isUpdateAccount = false
this.$refs.ListTable.reloadTable() this.$refs.ListTable.reloadTable()
}, },
async getAssetDetail() { async getAssetDetail() {
const { query: { asset } } = this.$route const { query: { asset }} = this.$route
if (asset) { if (asset) {
this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`) this.iAsset = await this.$axios.get(`/api/v1/assets/assets/${asset}/`)
} }

View File

@@ -12,7 +12,7 @@
<script> <script>
import Dialog from '@/components/Dialog/index.vue' import Dialog from '@/components/Dialog/index.vue'
import { openTaskPage } from '@/utils/jms/index' import { openTaskPage } from '@/utils/jms'
export default { export default {
name: 'RemoveAccount', name: 'RemoveAccount',

View File

@@ -23,7 +23,7 @@
<script> <script>
import Dialog from '@/components/Dialog/index.vue' import Dialog from '@/components/Dialog/index.vue'
import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const' import { accountFieldsMeta } from '@/components/Apps/AccountCreateUpdateForm/const'
import { encryptPassword } from '@/utils/secure' import { encryptPassword } from '@/utils/crypto'
import AutoDataForm from '@/components/Form/AutoDataForm/index.vue' import AutoDataForm from '@/components/Form/AutoDataForm/index.vue'
export default { export default {

View File

@@ -61,7 +61,7 @@
import Dialog from '@/components/Dialog/index.vue' import Dialog from '@/components/Dialog/index.vue'
import PasswordHistoryDialog from './PasswordHistoryDialog.vue' import PasswordHistoryDialog from './PasswordHistoryDialog.vue'
import { SecretViewerFormatter } from '@/components/Table/TableFormatters' import { SecretViewerFormatter } from '@/components/Table/TableFormatters'
import { encryptPassword } from '@/utils/secure' import { encryptPassword } from '@/utils/crypto'
export default { export default {
name: 'ShowSecretInfo', name: 'ShowSecretInfo',

View File

@@ -1,5 +1,5 @@
import { ChoicesFormatter } from '@/components/Table/TableFormatters' import { ChoicesFormatter } from '@/components/Table/TableFormatters'
import { openTaskPage } from '@/utils/jms/index' import { openTaskPage } from '@/utils/jms'
export const connectivityMeta = { export const connectivityMeta = {
formatter: ChoicesFormatter, formatter: ChoicesFormatter,
@@ -7,23 +7,11 @@ export const connectivityMeta = {
faChoices: { faChoices: {
'-': '', '-': '',
ok: 'fa-check-circle', ok: 'fa-check-circle',
err: 'fa-times-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'
}, },
classChoices: { classChoices: {
ok: 'text-primary', ok: 'text-primary',
err: 'text-danger', 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'
}, },
getText({ cellValue }) { getText({ cellValue }) {
if (cellValue?.value === '-' || cellValue?.value === 'unknown') { if (cellValue?.value === '-' || cellValue?.value === 'unknown') {
@@ -36,200 +24,152 @@ export const connectivityMeta = {
width: '130px' width: '130px'
} }
export function isDirectoryServiceAccount(account, vm) { export const accountOtherActions = (vm) => [
return vm.asset && vm.asset.id !== account.asset.id {
} name: 'View',
title: vm.$t('View'),
export const accountOtherActions = vm => { can: vm.$hasPerm('accounts.view_accountsecret'),
return [ type: 'primary',
{ order: 1,
name: 'View', callback: ({ row }) => {
title: vm.$t('View'), // debugger
can: vm.$hasPerm('accounts.view_accountsecret'), vm.secretUrl = `/api/v1/accounts/account-secrets/${row.id}/`
type: 'primary', vm.account = row
order: 1, vm.showViewSecretDialog = false
callback: ({ row }) => { setTimeout(() => {
// debugger vm.showViewSecretDialog = true
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.delete_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
}
} }
] },
} {
name: 'Update',
title: vm.$t('Edit'),
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.showAddDialog = false
vm.accountCreateUpdateTitle = vm.$t('UpdateAccount')
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'),
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
export const accountQuickFilters = vm => [ 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,
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',
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) => [
{ {
label: vm.$t('Recent (7 days)'), label: vm.$t('Recent (7 days)'),
options: [ options: [
@@ -271,11 +211,11 @@ export const accountQuickFilters = vm => [
{ {
label: vm.$t('NoLoginLongTime'), label: vm.$t('NoLoginLongTime'),
filter: { filter: {
long_time_no_login: 'true' risk: 'long_time_no_login'
} }
}, },
{ {
label: vm.$t('AddAccount'), label: vm.$t('UnmanagedAccount'),
filter: { filter: {
risk: 'new_found' risk: 'new_found'
} }
@@ -297,6 +237,12 @@ export const accountQuickFilters = vm => [
filter: { filter: {
long_time_no_change_secret: 'true' long_time_no_change_secret: 'true'
} }
},
{
label: vm.$t('LongTimeNoVerify'),
filter: {
long_time_no_verify: 'true'
}
} }
] ]
}, },

View File

@@ -16,7 +16,7 @@
</template> </template>
<script> <script>
import IBox from '@/components/Common/IBox/index.vue' import IBox from '@/components/IBox/index.vue'
import AssetSelect from '@/components/Apps/AssetSelect/index.vue' import AssetSelect from '@/components/Apps/AssetSelect/index.vue'
export default { export default {
@@ -48,13 +48,11 @@ export default {
}, },
performAdd: { performAdd: {
type: Function, type: Function,
default: (objects, that) => { default: (objects, that) => {}
}
}, },
onAddSuccess: { onAddSuccess: {
type: Function, type: Function,
default: (objects, that) => { default: (objects, that) => {}
}
}, },
canSelect: { canSelect: {
type: Function, type: Function,
@@ -64,7 +62,8 @@ export default {
} }
}, },
data() { data() {
return {} return {
}
}, },
methods: { methods: {
addObjects() { addObjects() {
@@ -78,18 +77,18 @@ export default {
</script> </script>
<style scoped> <style scoped>
b, strong { b, strong {
font-weight: 700; font-weight: 700;
font-size: 13px; font-size: 13px;
} }
tr td { tr td {
line-height: 1.42857; line-height: 1.42857;
padding: 8px; padding: 8px;
vertical-align: top; vertical-align: top;
} }
tr.item td { tr.item td {
border-top: 1px solid #e7eaec; border-top: 1px solid #e7eaec;
} }
</style> </style>

View File

@@ -82,7 +82,7 @@ export default {
}, },
{ {
prop: 'address', prop: 'address',
label: this.$t('Address'), label: this.$t('IpDomain'),
sortable: 'custom' sortable: 'custom'
}, },
{ {

View File

@@ -56,10 +56,6 @@ export default {
treeSetting: { treeSetting: {
type: Object, type: Object,
default: () => ({}) default: () => ({})
},
disabled: {
type: [Boolean, Function],
default: false
} }
}, },
data() { data() {
@@ -75,7 +71,6 @@ export default {
dialogVisible: false, dialogVisible: false,
initialValue: _.cloneDeep(iValue), initialValue: _.cloneDeep(iValue),
select2Config: { select2Config: {
disabled: this.disabled,
value: iValue, value: iValue,
multiple: true, multiple: true,
clearable: true, clearable: true,

View File

@@ -20,7 +20,7 @@
<script> <script>
import TreeTable from '../../Table/TreeTable/index.vue' import TreeTable from '../../Table/TreeTable/index.vue'
import { setRouterQuery, setUrlParam } from '@/utils/common/index' import { setRouterQuery, setUrlParam } from '@/utils/common'
import $ from '@/utils/jquery-vendor' import $ from '@/utils/jquery-vendor'
export default { export default {
@@ -114,11 +114,6 @@ export default {
treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`, treeUrl: `${this.typeUrl}?assets=${showAssets ? '1' : '0'}&count_resource=${this.treeSetting.countResource || 'asset'}`,
callback: { callback: {
onSelected: (event, treeNode) => this.getAssetsUrl(treeNode) onSelected: (event, treeNode) => this.getAssetsUrl(treeNode)
},
edit: {
drag: {
isMove: false
}
} }
} }
} }

View File

@@ -1,6 +1,6 @@
<template> <template>
<div class="container"> <div class="container">
<div v-if="hasPrompt" class="chat-action"> <div class="chat-action">
<Select2 <Select2
v-model="select.value" v-model="select.value"
:disabled="isLoading || isSelectDisabled" :disabled="isLoading || isSelectDisabled"
@@ -36,10 +36,6 @@ export default {
expanded: { expanded: {
type: Boolean, type: Boolean,
default: false default: false
},
hasPrompt: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@@ -50,7 +46,7 @@ export default {
url: '/api/v1/settings/chatai-prompts/', url: '/api/v1/settings/chatai-prompts/',
value: '', value: '',
multiple: false, multiple: false,
placeholder: this.$t('Role'), placeholder: this.$t('Prompt'),
ajax: { ajax: {
transformOption: (item) => { transformOption: (item) => {
return { label: item.name, value: item.content } return { label: item.name, value: item.content }

View File

@@ -33,7 +33,7 @@
<!-- eslint-disable-next-line --> <!-- eslint-disable-next-line -->
<div class="divider"></div> <div class="divider"></div>
<p> <p>
<MessageText :message="item.reasoning" @insert-code="handleInsertCode" /> <MessageText :message="item.reasoning" />
</p> </p>
</div> </div>
@@ -41,7 +41,8 @@
<span v-if="isServerError" class="error"> <span v-if="isServerError" class="error">
{{ isServerError }} {{ isServerError }}
</span> </span>
<MessageText :message="item.result" :is-terminal="isTerminal" @insert-code="handleInsertCode" /></div> <MessageText :message="item.result" />
</div>
</div> </div>
</div> </div>
<div class="action"> <div class="action">
@@ -77,9 +78,9 @@
<script> <script>
import MessageText from './MessageText.vue' import MessageText from './MessageText.vue'
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
import { copy } from '@/utils/common/index' import { copy } from '@/utils/common'
import { useChat } from '../../useChat.js' import { useChat } from '../../useChat.js'
import { reconnect } from '@/utils/request' import { reconnect } from '@/utils/socket'
const { setLoading, removeLoadingMessageInChat } = useChat() const { setLoading, removeLoadingMessageInChat } = useChat()
@@ -92,10 +93,6 @@ export default {
type: Object, type: Object,
default: () => { default: () => {
} }
},
isTerminal: {
type: Boolean,
default: false
} }
}, },
data() { data() {
@@ -145,9 +142,6 @@ export default {
if (value === 'copy') { if (value === 'copy') {
copy(this.item.result.content) copy(this.item.result.content)
} }
},
handleInsertCode(code) {
this.$emit('insert-code', code)
} }
} }
} }

View File

@@ -17,7 +17,7 @@ import mdKatex from '@traptitech/markdown-it-katex'
import mila from 'markdown-it-link-attributes' import mila from 'markdown-it-link-attributes'
import hljs from 'highlight.js' import hljs from 'highlight.js'
import 'highlight.js/styles/atom-one-dark.css' import 'highlight.js/styles/atom-one-dark.css'
import { copy } from '@/utils/common/index' import { copy } from '@/utils/common'
export default { export default {
props: { props: {
@@ -25,10 +25,6 @@ export default {
type: Object, type: Object,
default: () => { default: () => {
} }
},
isTerminal: {
type: Boolean,
default: false
} }
}, },
data() { data() {
@@ -49,10 +45,10 @@ export default {
this.init() this.init()
}, },
updated() { updated() {
this.addEvents() this.addCopyEvents()
}, },
destroyed() { destroyed() {
this.removeEvents() this.removeCopyEvents()
}, },
methods: { methods: {
init() { init() {
@@ -69,68 +65,30 @@ export default {
return vm.highlightBlock(hljs.highlightAuto(code).value, '') return vm.highlightBlock(hljs.highlightAuto(code).value, '')
} }
}) })
this.markdown.use(mila, { attrs: { target: '_blank', rel: 'noopener', class: 'link-style' } }) this.markdown.use(mila, { attrs: { target: '_blank', rel: 'noopener', class: 'link-style' }})
this.markdown.use(mdKatex, { blockClass: 'katexmath-block rounded-md', errorColor: ' #cc0000' }) this.markdown.use(mdKatex, { blockClass: 'katexmath-block rounded-md', errorColor: ' #cc0000' })
}, },
highlightBlock(str, lang) { highlightBlock(str, lang) {
let insertSpanHtml = `<span class="code-block-header__insert">${this.$t('Insert')}</span>` return `<pre class="code-block-wrapper"><div class="code-block-header"><span class="code-block-header__lang">${lang}</span><span class="code-block-header__copy">${'Copy'}</span></div><code class="hljs code-block-body ${lang}">${str}</code></pre>`
if (!this.isTerminal) {
insertSpanHtml = ''
}
return `<pre class="code-block-wrapper">
<div class="code-block-header">
<span class="code-block-header__lang">${lang}</span>
<span class="code-block-header__actions">
${insertSpanHtml}
<span class="code-block-header__copy">${this.$t('Copy')}</span>
</span>
</div>
<code class="hljs code-block-body ${lang}">${str}</code></pre>`
}, },
addEvents() { addCopyEvents() {
this.addBtnClickEvents('.code-block-header__copy', this.handlerClickCopy) const copyBtn = document.querySelectorAll('.code-block-header__copy')
this.addBtnClickEvents('.code-block-header__insert', this.handlerClickInsert) copyBtn.forEach((btn) => {
}, btn.addEventListener('click', () => {
const code = btn.parentElement?.nextElementSibling?.textContent
handlerClickCopy(event) { if (code) {
const wrapper = event.target.closest('.code-block-wrapper') copy(code)
if (wrapper) { }
// 查找里面的 code 元素
const codeElement = wrapper.querySelector('code.code-block-body')
if (codeElement) {
const codeText = codeElement.textContent
copy(codeText)
}
}
},
handlerClickInsert(event) {
const wrapper = event.target.closest('.code-block-wrapper')
if (wrapper) {
// 查找里面的 code 元素
const codeElement = wrapper.querySelector('code.code-block-body')
if (codeElement) {
const codeText = codeElement.textContent
this.$emit('insert-code', codeText)
}
}
},
addBtnClickEvents(selector, callback) {
const buttons = this.$refs.textRef.querySelectorAll(selector)
buttons.forEach((btn) => {
btn.addEventListener('click', callback)
})
},
removeBtnClickEvent(selector) {
const buttons = this.$refs.textRef.querySelectorAll(selector)
buttons.forEach((btn) => {
btn.removeEventListener('click', () => {
}) })
}) })
}, },
removeEvents() { removeCopyEvents() {
if (this.$refs.textRef) { if (this.$refs.textRef) {
this.removeBtnClickEvent('.code-block-header__copy') const copyBtn = this.$refs.textRef.querySelectorAll('.code-block-header__copy')
this.addBtnClickEvents('.code-block-header__insert') copyBtn.forEach((btn) => {
btn.removeEventListener('click', () => {
})
})
} }
} }
} }
@@ -140,7 +98,6 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.markdown-body { .markdown-body {
font-size: 13px; font-size: 13px;
max-width: 300px;;
&::v-deep p { &::v-deep p {
margin-bottom: 0 !important; margin-bottom: 0 !important;
@@ -158,46 +115,26 @@ export default {
&::v-deep .code-block-wrapper { &::v-deep .code-block-wrapper {
background: #1F2329; background: #1F2329;
padding: 0; padding: 2px 6px;
margin: 5px 0; margin: 5px 0;
display: flex;
flex-direction: column;
overflow: hidden;
.code-block-body { .code-block-body {
padding: 5px 10px; padding: 5px 10px 0;
} }
;
.code-block-header { .code-block-header {
margin-bottom: 4px; margin-bottom: 4px;
overflow: hidden; overflow: hidden;
background: #353946; background: #353946;
color: #c2d1e1; color: #c2d1e1;
display: flex;
justify-content: space-between;
align-items: center;
padding: 4px 8px;
width: 100%;
box-sizing: border-box;
.code-block-header__actions { .code-block-header__copy {
display: flex; float: right;
gap: 8px; cursor: pointer;
.code-block-header__copy { &:hover {
cursor: pointer; color: #6e747b;
&:hover {
color: #6e747b;
}
}
.code-block-header__insert {
cursor: pointer;
&:hover {
color: #6e747b;
}
} }
} }
} }
@@ -241,7 +178,6 @@ export default {
0% { 0% {
opacity: 1; opacity: 1;
} }
100% { 100% {
opacity: 0; opacity: 0;
} }

View File

@@ -17,7 +17,7 @@
</div> </div>
</div> </div>
</div> </div>
<ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" :is-terminal="isTerminal" @insert-code="insertCode" /> <ChatMessage v-for="(item, index) in activeChat.chats" :key="index" :item="item" />
</div> </div>
<div class="input-box"> <div class="input-box">
<el-button <el-button
@@ -28,7 +28,7 @@
size="small" size="small"
@click="onStopHandle" @click="onStopHandle"
>{{ $tc('Stop') }}</el-button> >{{ $tc('Stop') }}</el-button>
<ChatInput ref="chatInput" :expanded="expanded" :has-prompt="!isTerminal" @send="onSendHandle" @select-prompt="onSelectPromptHandle" /> <ChatInput ref="chatInput" :expanded="expanded" @send="onSendHandle" @select-prompt="onSelectPromptHandle" />
</div> </div>
</div> </div>
</template> </template>
@@ -37,7 +37,7 @@
import ChatInput from './ChatInput.vue' import ChatInput from './ChatInput.vue'
import ChatMessage from './ChatMessage.vue' import ChatMessage from './ChatMessage.vue'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/request' import { closeWebSocket, createWebSocket, onSend, ws } from '@/utils/socket'
import { getInputFocus, useChat } from '../../useChat.js' import { getInputFocus, useChat } from '../../useChat.js'
const { const {
@@ -68,10 +68,7 @@ export default {
prompt: '', prompt: '',
conversationId: '', conversationId: '',
showIntroduction: false, showIntroduction: false,
introduction: [], introduction: []
terminalContext: null,
isTerminal: false,
sessionChat: {}
} }
}, },
computed: { computed: {
@@ -103,9 +100,6 @@ export default {
this.showIntroduction = true this.showIntroduction = true
this.conversationId = '' this.conversationId = ''
this.$refs.chatInput.select.value = '' this.$refs.chatInput.select.value = ''
if (this.terminalContext) {
this.prompt = this.terminalContext.content || ''
}
const chat = { const chat = {
message: { message: {
content: this.$t('ChatHello'), content: this.$t('ChatHello'),
@@ -156,32 +150,6 @@ export default {
addMessageToActiveChat(data) addMessageToActiveChat(data)
setLoading(true) setLoading(true)
}, },
onTerminalContext(terminalContext) {
const originSessionId = this.terminalContext?.sessionId
const newSessionId = terminalContext.sessionId || ''
if (originSessionId) {
this.saveSessionChat(originSessionId)
}
this.terminalContext = terminalContext
this.isTerminal = true
this.prompt = terminalContext.content || ''
if (originSessionId !== newSessionId) {
if (this.sessionChat[newSessionId]) {
clearChats()
for (const chat of this.sessionChat[newSessionId]) {
addChatMessageById(chat)
}
} else {
this.onNewChat()
}
}
},
saveSessionChat(sessionId) {
if (this.terminalContext) {
this.sessionChat[sessionId] = JSON.parse(JSON.stringify(this.activeChat.chats))
}
},
onSendHandle(value) { onSendHandle(value) {
this.showIntroduction = false this.showIntroduction = false
this.socket = ws || {} this.socket = ws || {}
@@ -236,15 +204,6 @@ export default {
sendIntroduction(item) { sendIntroduction(item) {
this.showIntroduction = false this.showIntroduction = false
this.onSendHandle(item.content) this.onSendHandle(item.content)
},
insertCode(code) {
this.sendPostMessage({
name: 'INSERT_TERMINAL_CODE',
data: code.replace(/^[\s\r\n]+|[\s\r\n]+$/g, '')
})
},
sendPostMessage(data) {
window.parent.postMessage(data)
} }
} }
} }

View File

@@ -1,6 +1,5 @@
<template> <template>
<DrawerPanel <DrawerPanel
v-if="visible"
ref="drawer" ref="drawer"
:default-show-panel="!!defaultShowPanel" :default-show-panel="!!defaultShowPanel"
:expanded="expanded" :expanded="expanded"
@@ -46,12 +45,9 @@
import Sidebar from './components/Sidebar/index.vue' import Sidebar from './components/Sidebar/index.vue'
import Chat from './components/ChitChat/index.vue' import Chat from './components/ChitChat/index.vue'
import { getInputFocus } from './useChat.js' import { getInputFocus } from './useChat.js'
import { ws } from '@/utils/request' import { ws } from '@/utils/socket'
import DrawerPanel from '@/components/Apps/DrawerPanel/index.vue' import DrawerPanel from '@/components/Apps/DrawerPanel/index.vue'
import { ObjectLocalStorage } from '@/utils/common'
import { mapGetters } from 'vuex'
const aiPannelLocalStorage = new ObjectLocalStorage('ai_panel_settings')
export default { export default {
components: { components: {
DrawerPanel, DrawerPanel,
@@ -76,68 +72,23 @@ export default {
}, },
data() { data() {
return { return {
visible: false,
active: 'chat', active: 'chat',
robotUrl: require('@/assets/img/robot-assistant.png'), robotUrl: require('@/assets/img/robot-assistant.png'),
height: '400px', height: '400px',
expanded: false, expanded: false,
clientOffset: {}, clientOffset: {}
currentTerminalContent: {}
} }
}, },
computed: {
...mapGetters([
'publicSettings'
])
},
watch: { watch: {
'publicSettings.CHAT_AI_METHOD': {
handler(newVal) {
this.visible = newVal === 'api'
}
}
}, },
mounted() { mounted() {
this.handleStartChat() this.handlePostMessage()
}, },
methods: { methods: {
handleStartChat() {
if (this.publicSettings.CHAT_AI_METHOD === 'api') {
this.visible = true
const expanded = aiPannelLocalStorage.get('expanded')
this.updateExpandedState(expanded)
this.handlePostMessage()
} else if (this.publicSettings.CHAT_AI_METHOD === 'embed') {
const embedScriptId = 'chat-ai-embed-id'
if (document.getElementById(embedScriptId)) {
return
}
const script = document.createElement('script')
script.id = embedScriptId
script.src = this.publicSettings.CHAT_AI_EMBED_URL
script.async = true
script.onload = () => {
const loadEvent = new Event('load', { bubbles: false, cancelable: false })
window.dispatchEvent(loadEvent)
}
document.body.appendChild(script)
}
},
handlePostMessage() { handlePostMessage() {
window.addEventListener('message', (event) => { window.addEventListener('message', (event) => {
if (event.data === 'show-chat-panel') { if (event.data === 'show-chat-panel') {
this.$refs.drawer.show = true this.$refs.drawer.show = true
this.initWebSocket()
return
}
const msg = event.data
switch (msg.name) {
case 'current_terminal_content':
// {content: '...', terminalId: '',sessionId: '',viewId: '',viewName: ''}
this.$log.debug('current_terminal_content', msg)
this.currentTerminalContent = msg.data
this.$refs.component?.onTerminalContext(msg.data)
break
} }
}) })
}, },
@@ -145,11 +96,6 @@ export default {
this.$refs.drawer.handleHeaderMoveDown(event) this.$refs.drawer.handleHeaderMoveDown(event)
}, },
handleMouseMoveUp(event) { handleMouseMoveUp(event) {
// Prevent the new chat button from triggering the header move up
const newButton = event.target.closest('.new')
if (newButton) {
return
}
this.$refs.drawer.handleHeaderMoveUp(event) this.$refs.drawer.handleHeaderMoveUp(event)
}, },
initWebSocket() { initWebSocket() {
@@ -161,20 +107,12 @@ export default {
this.$refs.drawer.show = false this.$refs.drawer.show = false
}, },
expandFull() { expandFull() {
this.updateExpandedState(true) this.height = '100%'
this.save_pannel_settings() this.expanded = true
}, },
compress() { compress() {
this.updateExpandedState(false) this.height = '400px'
this.save_pannel_settings() this.expanded = false
},
save_pannel_settings() {
aiPannelLocalStorage.set('expanded', this.expanded)
console.log('AI panel settings saved:', this.expanded)
},
updateExpandedState(expanded) {
this.expanded = expanded
this.height = expanded ? '100%' : '400px'
}, },
onNewChat() { onNewChat() {
this.active = 'chat' this.active = 'chat'

View File

@@ -1,5 +1,5 @@
import store from '@/store' import store from '@/store'
import { pageScroll } from '@/utils/common/index' import { pageScroll } from '@/utils/common'
export const getInputFocus = () => { export const getInputFocus = () => {
const dom = document.querySelector('.chat-input .el-textarea__inner') const dom = document.querySelector('.chat-input .el-textarea__inner')
@@ -9,11 +9,11 @@ export const getInputFocus = () => {
export function useChat() { export function useChat() {
const chatStore = {} const chatStore = {}
const setLoading = loading => { const setLoading = (loading) => {
store.commit('chat/setLoading', loading) store.commit('chat/setLoading', loading)
} }
const onNewChat = name => { const onNewChat = (name) => {
const data = { const data = {
name: name || `new chat`, name: name || `new chat`,
id: 1, id: 1,
@@ -27,7 +27,7 @@ export function useChat() {
store.commit('chat/clearChats') store.commit('chat/clearChats')
} }
const addMessageToActiveChat = chat => { const addMessageToActiveChat = (chat) => {
store.commit('chat/addMessageToActiveChat', chat) store.commit('chat/addMessageToActiveChat', chat)
} }
@@ -35,7 +35,7 @@ export function useChat() {
store.commit('chat/removeLoadingMessageInChat') store.commit('chat/removeLoadingMessageInChat')
} }
const addChatMessageById = chat => { const addChatMessageById = (chat) => {
store.commit('chat/addMessageToActiveChat', chat) store.commit('chat/addMessageToActiveChat', chat)
if (chat?.conversation_id) { if (chat?.conversation_id) {
store.commit('chat/setActiveChatConversationId', chat.conversation_id) store.commit('chat/setActiveChatConversationId', chat.conversation_id)
@@ -54,7 +54,7 @@ export function useChat() {
addChatMessageById(temporaryChat) addChatMessageById(temporaryChat)
} }
const newChatAndAddMessageById = chat => { const newChatAndAddMessageById = (chat) => {
onNewChat(chat.message.content) onNewChat(chat.message.content)
addChatMessageById(chat) addChatMessageById(chat)
} }

View File

@@ -34,7 +34,7 @@
<script> <script>
import Dialog from '@/components/Dialog/index.vue' import Dialog from '@/components/Dialog/index.vue'
import { openTaskPage } from '@/utils/jms/index' import { openTaskPage } from '@/utils/jms'
export default { export default {
name: 'GatewayDialog', name: 'GatewayDialog',

View File

@@ -7,7 +7,7 @@
/> />
</template> </template>
<script> <script type="text/jsx">
import AssetTreeTable from '@/components/Apps/AssetTreeTable' import AssetTreeTable from '@/components/Apps/AssetTreeTable'
import { AccountInfoFormatter, DetailFormatter } from '@/components/Table/TableFormatters' import { AccountInfoFormatter, DetailFormatter } from '@/components/Table/TableFormatters'
import { connectivityMeta } from '@/components/Apps/AccountListTable/const' import { connectivityMeta } from '@/components/Apps/AccountListTable/const'
@@ -85,7 +85,6 @@ export default {
hasTree: true, hasTree: true,
columnsExtra: ['view_account'], columnsExtra: ['view_account'],
columnsExclude: ['spec_info'], columnsExclude: ['spec_info'],
columns: ['id', 'name', 'address', 'comment', 'labels', 'connectivity', 'platform', 'view_account', 'actions'],
columnsShow: { columnsShow: {
min: ['name', 'address', 'accounts'], min: ['name', 'address', 'accounts'],
default: ['name', 'address', 'platform', 'view_account', 'actions'] default: ['name', 'address', 'platform', 'view_account', 'actions']

View File

@@ -1,59 +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: true,
hasBulkUpdate: false,
hasLeftActions: true,
hasRightActions: true,
canCreate: this.$hasPerm('settings.change_security'),
canBulkDelete: 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

@@ -6,8 +6,7 @@
<script> <script>
import { DrawerListTable as ListTable } from '@/components' import { DrawerListTable as ListTable } from '@/components'
import { toM2MJsonParams } from '@/utils/jms/index' import { toM2MJsonParams } from '@/utils/jms'
import { DetailFormatter } from '@/components/Table/TableFormatters'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {
@@ -42,10 +41,15 @@ export default {
columnsMeta: { columnsMeta: {
name: { name: {
label: this.$t('Asset'), label: this.$t('Asset'),
formatter: DetailFormatter, formatter: (row) => {
formatterArgs: { const to = {
getRoute: ({ row }) => { name: 'AssetDetail',
return { name: 'AssetDetail', params: { id: row.id } } params: { id: row.id }
}
if (this.$hasPerm('assets.view_asset')) {
return <router-link to={to} class='text-link'>{row.name}</router-link>
} else {
return <span>{row.name}</span>
} }
} }
}, },
@@ -64,3 +68,7 @@ export default {
} }
} }
</script> </script>
<style scoped>
</style>

View File

@@ -6,9 +6,8 @@
<script> <script>
import { DrawerListTable as ListTable } from '@/components' import { DrawerListTable as ListTable } from '@/components'
import { toM2MJsonParams } from '@/utils/jms/index' import { toM2MJsonParams } from '@/utils/jms'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import TwoCol from '@/layout/components/Page/TwoColPage.vue'
import { DetailFormatter } from '@/components/Table/TableFormatters'
export default { export default {
name: 'User', name: 'User',
@@ -45,13 +44,15 @@ export default {
columnsMeta: { columnsMeta: {
name: { name: {
label: this.$t('Name'), label: this.$t('Name'),
formatter: DetailFormatter, formatter: (row) => {
formatterArgs: { const to = {
getRoute: ({ row }) => { name: 'UserDetail',
return { params: { id: row.id }
name: 'UserDetail', }
params: { id: row.id } if (this.$hasPerm('users.view_user')) {
} return <router-link to={to} class='text-link'>{row.name}</router-link>
} else {
return <span>{row.name}</span>
} }
} }
}, },
@@ -89,3 +90,7 @@ export default {
} }
} }
</script> </script>
<style scoped>
</style>

View File

@@ -28,10 +28,10 @@
</template> </template>
<script> <script>
import IBox from '@/components/Common/IBox/index.vue' import IBox from '@/components/IBox/index.vue'
import DiffDetail from '@/components/Dialog/DiffDetail.vue' import DiffDetail from '@/components/Dialog/DiffDetail.vue'
import { openTaskPage } from '@/utils/jms/index' import { openTaskPage } from '@/utils/jms'
import { toSafeLocalDateStr } from '@/utils/common/time' import { toSafeLocalDateStr } from '@/utils/time'
import TwoCol from '@/layout/components/Page/TwoColPage.vue' import TwoCol from '@/layout/components/Page/TwoColPage.vue'
export default { export default {

View File

@@ -8,7 +8,7 @@
:visible.sync="visible" :visible.sync="visible"
class="dialog-content" class="dialog-content"
v-bind="$attrs" v-bind="$attrs"
width="600px" width="740px"
@confirm="visible = false" @confirm="visible = false"
v-on="$listeners" v-on="$listeners"
> >
@@ -49,47 +49,41 @@
</el-select> </el-select>
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="!noCodeMFA.includes(subTypeSelected)" :gutter="24" style="margin: 0 auto;"> <el-row :gutter="24" style="margin: 0 auto;">
<el-col :md="24" :sm="24" style="display: flex; align-items: center; "> <el-col :md="24" :sm="24" style="display: flex; align-items: center; margin-bottom: 20px;">
<el-input <el-input
v-if="subTypeSelected !== 'face'"
v-model="secretValue" v-model="secretValue"
:placeholder="inputPlaceholder" :placeholder="inputPlaceholder"
:show-password="showPassword" :show-password="showPassword"
@keyup.enter.native="handleConfirm" @keyup.enter.native="handleConfirm"
/> />
<span v-if="subTypeSelected === 'sms' || subTypeSelected === 'email'" style="margin: -1px 0 0 20px;">
<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'" style="margin: -1px 0 0 20px;">
<el-button <el-button
:disabled="smsBtnDisabled" :disabled="smsBtnDisabled"
size="mini" size="mini"
style="line-height: 14px; float: right;" style="line-height: 14px; float: right;"
type="primary" type="primary"
@click="sendCode" @click="sendSMSCode"
> >
{{ smsBtnText }} {{ smsBtnText }}
</el-button> </el-button>
</span> </span>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row :gutter="24" style="margin: 10px auto;">
<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: 600px;border: none;"
/>
</el-col>
</el-row>
<el-row :gutter="24" style="margin: 20px auto 10px;">
<el-col :md="24" :sm="24"> <el-col :md="24" :sm="24">
<el-button <el-button
v-if="!noCodeMFA.includes(subTypeSelected)" v-if="subTypeSelected!=='face'"
class="confirm-btn" class="confirm-btn"
size="mini" size="mini"
type="primary" type="primary"
@@ -98,8 +92,7 @@
{{ this.$t('Confirm') }} {{ this.$t('Confirm') }}
</el-button> </el-button>
<el-button <el-button
v-if="subTypeSelected === 'face'" v-if="subTypeSelected==='face'&&!isFaceCaptureVisible"
v-show="!isFaceCaptureVisible"
class="confirm-btn" class="confirm-btn"
size="mini" size="mini"
type="primary" type="primary"
@@ -107,16 +100,6 @@
> >
{{ this.$tc('VerifyFace') }} {{ this.$tc('VerifyFace') }}
</el-button> </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-col>
</el-row> </el-row>
</div> </div>
@@ -124,7 +107,7 @@
</template> </template>
<script> <script>
import Dialog from '@/components/Dialog/index.vue' import Dialog from '@/components/Dialog/index.vue'
import { encryptPassword } from '@/utils/secure' import { encryptPassword } from '@/utils/crypto'
export default { export default {
name: 'UserConfirmDialog', name: 'UserConfirmDialog',
@@ -158,11 +141,7 @@ export default {
processing: false, processing: false,
isFaceCaptureVisible: false, isFaceCaptureVisible: false,
faceToken: null, faceToken: null,
faceCaptureUrl: null, faceCaptureUrl: null
noCodeMFA: ['face', 'passkey'],
sendCodeMFA: ['email', 'sms', 'otp'],
passkeyVisible: false,
passkeyUrl: '/api/v1/authentication/passkeys/login/?mfa=1'
} }
}, },
computed: { computed: {
@@ -195,7 +174,7 @@ export default {
this.$log.debug('perform confirm action') this.$log.debug('perform confirm action')
const confirmType = response.data?.code const confirmType = response.data?.code
const confirmUrl = '/api/v1/authentication/confirm/' const confirmUrl = '/api/v1/authentication/confirm/'
this.$axios.get(confirmUrl, { params: { confirm_type: confirmType } }).then((data) => { this.$axios.get(confirmUrl, { params: { confirm_type: confirmType }}).then((data) => {
this.confirmTypeRequired = data.confirm_type this.confirmTypeRequired = data.confirm_type
if (this.confirmTypeRequired === 'relogin') { if (this.confirmTypeRequired === 'relogin') {
@@ -225,8 +204,8 @@ export default {
logout() { logout() {
window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}` window.location.href = `${process.env.VUE_APP_LOGOUT_PATH}?next=${this.$route.fullPath}`
}, },
sendCode() { sendSMSCode() {
this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: this.subTypeSelected }).then(res => { this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: 'sms' }).then(res => {
this.$message.success(this.$tc('VerificationCodeSent')) this.$message.success(this.$tc('VerificationCodeSent'))
let time = 60 let time = 60
this.smsBtnDisabled = true this.smsBtnDisabled = true
@@ -245,26 +224,6 @@ export default {
this.$message.error(this.$tc('FailedToSendVerificationCode')) 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() { startFaceCapture() {
const url = '/api/v1/authentication/face/context/' const url = '/api/v1/authentication/face/context/'
this.$axios.post(url).then(data => { this.$axios.post(url).then(data => {
@@ -288,13 +247,6 @@ export default {
handleFaceCapture() { handleFaceCapture() {
this.startFaceCapture() this.startFaceCapture()
}, },
onSuccess() {
this.secretValue = ''
this.visible = false
this.$nextTick(() => {
this.callback()
})
},
handleConfirm() { handleConfirm() {
if (this.confirmTypeRequired === 'relogin') { if (this.confirmTypeRequired === 'relogin') {
return this.logout() return this.logout()
@@ -310,7 +262,11 @@ export default {
} }
this.$axios.post(`/api/v1/authentication/confirm/`, data).then(() => { this.$axios.post(`/api/v1/authentication/confirm/`, data).then(() => {
this.onSuccess() this.secretValue = ''
this.visible = false
this.$nextTick(() => {
this.callback()
})
}).catch((err) => { }).catch((err) => {
this.$message.error(err.message || this.$tc('ConfirmFailed')) this.$message.error(err.message || this.$tc('ConfirmFailed'))
this.faceCaptureUrl = null this.faceCaptureUrl = null

View File

@@ -39,9 +39,6 @@ export default {
['', ['name', 'var_name', 'type', 'text_default_value', 'select_default_value', 'extra_args', 'tips', 'required']] ['', ['name', 'var_name', 'type', 'text_default_value', 'select_default_value', 'extra_args', 'tips', 'required']]
], ],
fieldsMeta: { fieldsMeta: {
var_name: {
helpTextAsTip: false
},
text_default_value: { text_default_value: {
label: this.$t('DefaultValue'), label: this.$t('DefaultValue'),
hidden: (formValue) => { hidden: (formValue) => {

View File

@@ -1,5 +1,5 @@
<script type="text/jsx"> <script type="text/jsx">
import { toSafeLocalDateStr } from '@/utils/common/time' import { toSafeLocalDateStr } from '@/utils/time'
export default { export default {
name: 'ItemValue', name: 'ItemValue',

View File

@@ -12,9 +12,9 @@
<script> <script>
import DetailCard from './index.vue' import DetailCard from './index.vue'
import { copy } from '@/utils/common/index' import { copy } from '@/utils/common'
import { toSafeLocalDateStr } from '@/utils/common/time' import { toSafeLocalDateStr } from '@/utils/time'
import IBox from '@/components/Common/IBox/index.vue' import IBox from '@/components/IBox/index.vue'
import LabelsDetailFormatter from '../Formatters/LabelsDetailFormatter.vue' import LabelsDetailFormatter from '../Formatters/LabelsDetailFormatter.vue'
export default { export default {
@@ -129,18 +129,8 @@ export default {
parseArrayValue(value, excludes, label) { parseArrayValue(value, excludes, label) {
if (Array.isArray(value)) { if (Array.isArray(value)) {
const tp = typeof value[0] 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()) { for (const [index, item] of value.entries()) {
let object = {}
if (tp === 'object') { if (tp === 'object') {
const firstValue = value[0] const firstValue = value[0]
if (firstValue.hasOwnProperty('name')) { if (firstValue.hasOwnProperty('name')) {

View File

@@ -19,7 +19,7 @@
</template> </template>
<script> <script>
import IBox from '@/components/Common/IBox/index.vue' import IBox from '../../IBox/index.vue'
import ItemValue from './ItemValue.vue' import ItemValue from './ItemValue.vue'
export default { export default {

View File

@@ -49,7 +49,7 @@
<script> <script>
import { createSourceIdCache } from '@/api/common' import { createSourceIdCache } from '@/api/common'
import { Select2 } from '@/components/Form/FormFields' import { Select2 } from '@/components/Form/FormFields'
import IBox from '@/components/Common/IBox/index.vue' import IBox from '@/components/IBox/index.vue'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {

View File

@@ -1,19 +1,14 @@
<template> <template>
<div> <div>
<div class="summary-header"> <div class="summary-header">
<el-tooltip :content="title" :open-delay="500" placement="top"> <el-tooltip :content="title" placement="top" :open-delay="500">
<span class="title">{{ title }}</span> <span class="title">{{ title }}</span>
</el-tooltip> </el-tooltip>
</div> </div>
<slot> <slot>
<h3 class="no-margins "> <h3 class="no-margins ">
<span <span v-async="iCount" class="num" @click="handleClick">
:class="{ 'can-direct': canDirect }" -
class="num"
@click="handleClick"
>
<span v-if="count === null"> - </span>
<span v-else>{{ count }}</span>
</span> </span>
</h3> </h3>
</slot> </slot>
@@ -21,6 +16,7 @@
</template> </template>
<script> <script>
export default { export default {
name: 'SummaryCard', name: 'SummaryCard',
props: { props: {
@@ -28,18 +24,18 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
body: {
type: Object,
default: () => ({})
},
count: { count: {
type: [Number, String, Promise], type: [Number, String, Promise],
default: null default: 0
}, },
route: { route: {
type: [String, Object], type: [String, Object],
default: '' default: ''
}, },
canDirect: {
type: Boolean,
default: false
},
callback: { callback: {
type: Function, type: Function,
default: () => { default: () => {
@@ -53,13 +49,25 @@ export default {
data() { data() {
return {} return {}
}, },
computed: {
iCount() {
const count = this.body.count || this.count
return count
},
iRoute() {
return this.body.route || this.route
},
iDisabled() {
return this.body.disabled === undefined ? this.disabled : this.body.disabled
}
},
methods: { methods: {
handleClick() { handleClick() {
if (this.disabled) { if (this.iDisabled) {
return return
} }
if (this.route) { if (this.iRoute) {
this.$router.push(this.route) this.$router.push(this.iRoute)
return return
} }
this.callback.bind(this)() this.callback.bind(this)()
@@ -97,7 +105,7 @@ export default {
color: var(--color-text-primary); color: var(--color-text-primary);
cursor: pointer; cursor: pointer;
&.can-direct:hover { &:hover {
color: var(--color-primary); color: var(--color-primary);
} }
} }

View File

@@ -5,16 +5,10 @@
:options="options" :options="options"
:autoresize="true" :autoresize="true"
theme="light" theme="light"
:class="{'disabled-when-print': !!dataUrl}" class="disabled-when-print"
@finished="genSnapshot" @finished="getDataUrl"
/> />
<img <img v-if="dataUrl" :src="dataUrl" class="enabled-when-print" style="display: none;width: 100%;">
v-if="dataUrl"
:src="dataUrl"
class="enabled-when-print"
style="display: none;width: 100%;"
alt="chart snapshot"
>
</div> </div>
</template> </template>
@@ -116,6 +110,7 @@ export default {
}, },
axisLabel: { axisLabel: {
textStyle: { textStyle: {
// 坐标轴颜色
color: '#8F959E' color: '#8F959E'
} }
}, },
@@ -160,7 +155,7 @@ export default {
type: 'line', type: 'line',
smooth: true, smooth: true,
areaStyle: { areaStyle: {
// 区域填充样式 // 区域填充样式
normal: { normal: {
color: new echarts.graphic.LinearGradient( color: new echarts.graphic.LinearGradient(
0, 0,
@@ -192,7 +187,7 @@ export default {
type: 'line', type: 'line',
smooth: true, smooth: true,
areaStyle: { areaStyle: {
// 区域填充样式 // 区域填充样式
normal: { normal: {
color: new echarts.graphic.LinearGradient( color: new echarts.graphic.LinearGradient(
0, 0,
@@ -225,58 +220,23 @@ export default {
}, },
watch: { watch: {
range() { range() {
this.genSnapshot() this.getMetricData()
},
datesMetrics() {
this.genSnapshot()
},
primaryData() {
this.genSnapshot()
},
secondaryData() {
this.genSnapshot()
} }
}, },
mounted() { mounted() {
this.genSnapshot() this.getMetricData()
this._before = () => this.genSnapshot(true)
this._after = () => this.forceResize()
window.addEventListener('beforeprint', this._before)
window.addEventListener('afterprint', this._after)
// 兼容某些浏览器Safari触发 print 媒体切换
this._mql = window.matchMedia && window.matchMedia('print')
if (this._mql) {
const handler = e => (e.matches ? this._before() : this._after())
this._mql.addEventListener?.('change', handler)
this._mql.addListener?.(handler)
this._mql._handler = handler
}
},
beforeDestroy() {
window.removeEventListener('beforeprint', this._before)
window.removeEventListener('afterprint', this._after)
if (this._mql) {
this._mql.removeEventListener?.('change', this._mql._handler)
this._mql.removeListener?.(this._mql._handler)
}
}, },
methods: { methods: {
forceResize() { getDataUrl() {
const inst = this.$refs.echarts?.echartsInstance const instance = this.$refs.echarts.echartsInstance
if (inst) inst.resize() if (instance) {
}, this.dataUrl = instance.getDataURL()
async genSnapshot(force = false) {
if (force) this.forceResize()
const inst = this.$refs.echarts?.echartsInstance
if (!inst) return
try {
this.dataUrl = inst.getDataURL({ pixelRatio: 2, backgroundColor: '#ffffff' })
} catch (e) {
this.dataUrl = ''
} }
},
getMetricData() {
this.getDataUrl()
} }
} }
} }
</script> </script>
@@ -288,11 +248,13 @@ export default {
@media print { @media print {
.disabled-when-print { .disabled-when-print {
display: none !important; display: none;
} }
.enabled-when-print { .enabled-when-print {
display: block !important; display: inherit !important;
width: 100% !important; }
.print-margin {
margin-top: 10px;
} }
} }
</style> </style>

View File

@@ -9,7 +9,7 @@
class="table" class="table"
style="width: 100%" style="width: 100%"
> >
<el-table-column :label="$tc('Ranking')" width="100"> <el-table-column :label="$tc('Ranking')">
<template #header> <template #header>
<el-tooltip :content="$t('Ranking')" placement="top" :open-delay="500"> <el-tooltip :content="$t('Ranking')" placement="top" :open-delay="500">
<span style="cursor: pointer;">{{ $t('Ranking') }}</span> <span style="cursor: pointer;">{{ $t('Ranking') }}</span>

View File

@@ -6,7 +6,7 @@
<div class="content"> <div class="content">
<el-row justify="space-between" type="flex"> <el-row justify="space-between" type="flex">
<el-col v-for="item of summaryItems" :key="item.title" :md="8" :sm="12" :xs="12"> <el-col v-for="item of summaryItems" :key="item.title" :md="8" :sm="12" :xs="12">
<SummaryCard :title="item.title" v-bind="item.body" /> <SummaryCard :body="item.body" :title="item.title" />
</el-col> </el-col>
</el-row> </el-row>
</div> </div>

View File

@@ -33,7 +33,7 @@ export default {
const formatTitle = (text) => { const formatTitle = (text) => {
if (!text) return '' if (!text) return ''
const maxLength = 25 const maxLength = 23
const lines = [] const lines = []
for (let i = 0; i < text.length; i += maxLength) { for (let i = 0; i < text.length; i += maxLength) {
lines.push(text.slice(i, i + maxLength)) lines.push(text.slice(i, i + maxLength))
@@ -88,7 +88,6 @@ export default {
{ {
name: title, name: title,
type: 'pie', type: 'pie',
minAngle: 5,
radius: ['72%', '90%'], radius: ['72%', '90%'],
avoidLabelOverlap: false, avoidLabelOverlap: false,
itemStyle: { itemStyle: {

View File

@@ -7,9 +7,9 @@
<SummaryCard <SummaryCard
v-for="item of items" v-for="item of items"
:key="item.title" :key="item.title"
:body="item.body"
:title="item.title" :title="item.title"
class="summary-card" class="summary-card"
v-bind="item.body"
/> />
</div> </div>
</div> </div>

View File

@@ -16,13 +16,11 @@
<script> <script>
export default { export default {
props: { props: {
name: {
type: String,
default: 'dashboardDays'
},
days: { days: {
type: [String, Number], type: String,
default: null default: () => {
return localStorage.getItem('dashboardDays') || '7'
}
}, },
options: { options: {
type: Array, type: Array,
@@ -49,28 +47,8 @@ export default {
iOptions: this.options.length > 0 ? this.options : defaultOptions iOptions: this.options.length > 0 ? this.options : defaultOptions
} }
}, },
created() {
let days = this.days
if (!days) {
days = this.$route.query.days
}
if (!days) {
days = localStorage.getItem(this.name)
}
if (!days) {
days = '7'
}
if (days && days !== this.select) {
this.select = days
this.$emit('change', days)
}
},
mounted() {
this.$emit('change', this.select)
},
methods: { methods: {
onChange(val) { onChange(val) {
localStorage.setItem(this.name, val)
this.$emit('change', val) this.$emit('change', val)
} }
} }

View File

@@ -15,7 +15,7 @@
@click="handleClick(action)" @click="handleClick(action)"
@command="handleDropdownCallback" @command="handleDropdownCallback"
> >
<span v-if="action.split" :style="{ cursor: action.disabled ? 'not-allowed' : 'pointer' }"> <span v-if="action.split">
{{ action.title }} {{ action.title }}
</span> </span>
<el-button <el-button
@@ -89,7 +89,7 @@
</template> </template>
<script> <script>
import { toSentenceCase } from '@/utils/common/index' import { toSentenceCase } from '@/utils/common'
import Icon from '@/components/Widgets/Icon/index.vue' import Icon from '@/components/Widgets/Icon/index.vue'
export default { export default {

View File

@@ -4,7 +4,7 @@
:visible="iVisible" :visible="iVisible"
class="processing-dialog" class="processing-dialog"
height="300" height="300"
:title="$tc('Processing')" title="Processing"
width="300" width="300"
@confirm="iVisible=false" @confirm="iVisible=false"
> >

View File

@@ -28,7 +28,7 @@
<script> <script>
import i18n from '@/i18n/i18n' import i18n from '@/i18n/i18n'
import { copy } from '@/utils/common/index' import { copy } from '@/utils/common'
import Dialog from '@/components/Dialog/index' import Dialog from '@/components/Dialog/index'
export default { export default {

View File

@@ -2,7 +2,6 @@
<transition name="dialog-fade"> <transition name="dialog-fade">
<el-dialog <el-dialog
:append-to-body="true" :append-to-body="true"
:class="{ shadow: shadow }"
:modal-append-to-body="true" :modal-append-to-body="true"
:title="title" :title="title"
:top="top" :top="top"
@@ -47,7 +46,7 @@ export default {
}, },
width: { width: {
type: String, type: String,
default: '800px' default: '60%'
}, },
showConfirm: { showConfirm: {
type: Boolean, type: Boolean,
@@ -80,10 +79,6 @@ export default {
maxWidth: { maxWidth: {
type: String, type: String,
default: '1200px' default: '1200px'
},
shadow: {
type: Boolean,
default: true
} }
}, },
data() { data() {
@@ -106,14 +101,14 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.dialog.shadow ::v-deep .el-dialog {
box-shadow: 1px 2px 12px 0 rgba(0, 0, 0, 0.6);
}
.dialog ::v-deep .el-dialog { .dialog ::v-deep .el-dialog {
border-radius: 0.3em; border-radius: 0.3em;
max-width: min(100vw, 1500px); max-width: min(100vw, 1500px);
//.el-form, .form-buttons {
// margin-left: 20px;
//}
.form-group-header { .form-group-header {
margin-left: 20px; margin-left: 20px;
} }
@@ -137,7 +132,7 @@ export default {
&__body { &__body {
padding: 20px 30px; padding: 20px 30px;
font-size: 13px; font-size: 13px;
&:has(.el-table) { &:has(.el-table) {
background: #f3f3f4; background: #f3f3f4;

View File

@@ -30,8 +30,6 @@
</template> </template>
<script> <script>
import { getDrawerWidth } from '@/utils/common/index'
export default { export default {
props: { props: {
title: { title: {
@@ -40,9 +38,7 @@ export default {
}, },
size: { size: {
type: String, type: String,
default: () => { default: '768px'
return getDrawerWidth()
}
}, },
component: { component: {
type: [String, Function, Object], type: [String, Function, Object],
@@ -107,16 +103,6 @@ export default {
} }
} }
@media (max-width: 992px) {
.drawer ::v-deep {
.el-form-item {
display: flex;
flex-direction: column;
gap: 0.3rem;
}
}
}
.drawer { .drawer {
::v-deep { ::v-deep {
min-width: 565px; min-width: 565px;
@@ -147,7 +133,6 @@ export default {
&.detail-card { &.detail-card {
padding-right: 0; padding-right: 0;
margin-top: unset;
} }
// Detail 中 // Detail 中
@@ -283,7 +268,6 @@ export default {
} }
.drawer__content, .tab-page-content { .drawer__content, .tab-page-content {
height: 100%;
background: #f3f3f3; background: #f3f3f3;
} }

View File

@@ -1,27 +1,25 @@
<template> <template>
<div> <DataForm
<DataForm v-if="!loading"
v-if="!loading" ref="dataForm"
ref="dataForm" :fields="totalFields"
:fields="totalFields" :form="iForm"
:form="iForm" v-bind="$attrs"
v-bind="$attrs" v-on="$listeners"
v-on="$listeners" >
<template
v-for="(group, i) in groups"
:slot="'id:'+group.name"
> >
<template <FormGroupHeader
v-for="(group, i) in groups" v-if="!groupHidden(group, i)"
:slot="'id:'+group.name" :key="'group-' + group.name"
> :group="group"
<FormGroupHeader :index="i"
v-if="!groupHidden(group, i)" :line="i !== 0 && !groupHidden(groups[i - 1], i - 1)"
:key="'group-' + group.name" />
:group="group" </template>
:index="i" </DataForm>
:line="i !== 0 && !groupHidden(groups[i - 1], i - 1)"
/>
</template>
</DataForm>
</div>
</template> </template>
<script> <script>
@@ -89,12 +87,11 @@ export default {
} }
}, },
mounted() { mounted() {
// this.$log.debug('>>> Method: ', this.method)
this.optionUrlMetaAndGenerateColumns() this.optionUrlMetaAndGenerateColumns()
}, },
methods: { methods: {
async optionUrlMetaAndGenerateColumns() { async optionUrlMetaAndGenerateColumns() {
let data = { actions: {} } let data = { actions: {}}
if (this.url) { if (this.url) {
data = await this.$store.dispatch('common/getUrlMeta', { url: this.url }) data = await this.$store.dispatch('common/getUrlMeta', { url: this.url })
} }
@@ -140,11 +137,14 @@ export default {
this._cleanFormValue(this.iForm, this.remoteMeta) this._cleanFormValue(this.iForm, this.remoteMeta)
}, },
setFieldError(name, error) { setFieldError(name, error) {
error = error.replace(/[。.]+$/, '')
const field = this.totalFields.find((v) => v.prop === name) const field = this.totalFields.find((v) => v.prop === name)
if (!field) { if (!field) {
return return
} }
if (field.attrs.error === error) {
error += '.'
}
if (typeof error === 'string') { if (typeof error === 'string') {
field.el.errors = error field.el.errors = error
field.attrs.error = error field.attrs.error = error

View File

@@ -4,7 +4,7 @@ import NestedField from '@/components/Form/AutoDataForm/components/NestedField.v
import rules from '@/components/Form/DataForm/rules' import rules from '@/components/Form/DataForm/rules'
import BasicTree from '@/components/Form/FormFields/BasicTree.vue' import BasicTree from '@/components/Form/FormFields/BasicTree.vue'
import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue' import JsonEditor from '@/components/Form/FormFields/JsonEditor.vue'
import { assignIfNot, toSentenceCase } from '@/utils/common/index' import { assignIfNot, toSentenceCase } from '@/utils/common'
import TagInput from '@/components/Form/FormFields/TagInput.vue' import TagInput from '@/components/Form/FormFields/TagInput.vue'
import i18n from '@/i18n/i18n' import i18n from '@/i18n/i18n'
@@ -177,10 +177,7 @@ export class FormFieldGenerator {
const systemLang = document.cookie.django_language const systemLang = document.cookie.django_language
if (helpTextAsPlaceholder !== undefined) { if (helpTextAsPlaceholder !== undefined) {
helpTextAsPlaceholder = !!helpTextAsPlaceholder helpTextAsPlaceholder = !!helpTextAsPlaceholder
} else if ( } else if (placeholderType.indexOf(field.type) === -1 && placeholderComponent.indexOf(field.component) === -1) {
placeholderType.indexOf(field.type) === -1 &&
placeholderComponent.indexOf(field.component) === -1
) {
helpTextAsPlaceholder = false helpTextAsPlaceholder = false
} else if ((helpTextWordLength <= 5 || helpText.length <= 10) && systemLang === 'en') { } else if ((helpTextWordLength <= 5 || helpText.length <= 10) && systemLang === 'en') {
helpTextAsPlaceholder = true helpTextAsPlaceholder = true

View File

@@ -9,7 +9,6 @@
> >
<template v-if="data.label" #label> <template v-if="data.label" #label>
<span :title="data.label"> <span :title="data.label">
<span v-if="data.required">* </span>
{{ data.label }} {{ data.label }}
<el-tooltip <el-tooltip
v-if="data.helpTip" v-if="data.helpTip"

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-form ref="elForm" :model="value" class="el-form-renderer" v-bind="$attrs" @submit.native.prevent> <el-form ref="elForm" :model="value" class="el-form-renderer" v-bind="$attrs">
<template v-for="item in innerContent"> <template v-for="item in innerContent">
<slot v-if="!isHidden(item)" :name="`id:${item.id}`" /> <slot v-if="!isHidden(item)" :name="`id:${item.id}`" />
<component <component

View File

@@ -8,8 +8,7 @@
:form="basicForm" :form="basicForm"
:label-position="iLabelPosition" :label-position="iLabelPosition"
class="form-fields" class="form-fields"
:label-width="labelWidth" label-width="25%"
:style="{ '--label-width': labelWidth }"
v-bind="$attrs" v-bind="$attrs"
v-on="$listeners" v-on="$listeners"
> >
@@ -71,20 +70,8 @@
<script> <script>
import ElFormRender from './components/el-form-renderer' import ElFormRender from './components/el-form-renderer'
import { randomString } from '@/utils/common/index' import { randomString } from '@/utils/string'
import { scrollToError } from '@/utils'
const scrollToError = (
el,
scrollOption = {
behavior: 'smooth',
block: 'center'
}
) => {
setTimeout(() => {
const isError = el.getElementsByClassName('is-error')
isError[0].scrollIntoView(scrollOption)
}, 0)
}
export default { export default {
components: { components: {
@@ -141,10 +128,6 @@ export default {
labelPosition: { labelPosition: {
type: String, type: String,
default: '' default: ''
},
labelWidth: {
type: String,
default: '25%'
} }
}, },
data() { data() {
@@ -280,7 +263,7 @@ export default {
} }
.el-form-item__content { .el-form-item__content {
width: calc(100% - var(--label-width)); width: 75%;
line-height: 32px; line-height: 32px;
// 禁用的输入框 // 禁用的输入框
@@ -354,7 +337,7 @@ export default {
::v-deep .form-buttons { ::v-deep .form-buttons {
margin-top: 30px; margin-top: 30px;
margin-left: var(--label-width); margin-left: 25%;
} }
} }

View File

@@ -27,9 +27,7 @@ export default {
}, },
beforeSubmit: { beforeSubmit: {
type: Function, type: Function,
default: (val) => { default: (val) => { return true }
return true
}
} }
}, },
data() { data() {
@@ -52,16 +50,14 @@ export default {
::v-deep .el-select { ::v-deep .el-select {
width: 100%; width: 100%;
} }
::v-deep .el-form-item__content { ::v-deep .el-form-item__content {
width: 100% !important; width: 100% !important;
} }
::v-deep .form-buttons { ::v-deep .form-buttons {
margin: 0 !important; margin: 0 !important;
} }
.attr-input { .attr-input {
margin-top: -10px;
} }
</style> </style>

View File

@@ -47,9 +47,6 @@ export default {
}, },
computed: { computed: {
iValue() { iValue() {
if (!this.value) {
return []
}
return this.value.map(item => { return this.value.map(item => {
if (item.value) { if (item.value) {
return item.value return item.value

View File

@@ -361,10 +361,9 @@ export default {
}, },
// 填充表达式 // 填充表达式
submitFill() { submitFill() {
const minMinutes = 60
const crontabDiffMin = this.crontabDiff / 1000 / 60 const crontabDiffMin = this.crontabDiff / 1000 / 60
if (crontabDiffMin > 0 && crontabDiffMin < minMinutes) { if (crontabDiffMin > 0 && crontabDiffMin < 10) {
const msg = this.$t('CrontabDiffError', { minutes: minMinutes }) const msg = this.$tc('CrontabDiffError')
this.$message.error(msg) this.$message.error(msg)
return return
} }

View File

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

View File

@@ -9,7 +9,7 @@
<el-form-item> <el-form-item>
<el-radio v-model="radioValue" :label="3"> <el-radio v-model="radioValue" :label="3">
{{ this.$t('From') }} {{ 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') }} {{ this.$t('Min') }} {{ this.$t('ExecuteOnce') }}
</el-radio> </el-radio>
</el-form-item> </el-form-item>

View File

@@ -13,7 +13,7 @@
<script> <script>
import parser from 'cron-parser' import parser from 'cron-parser'
import { toSafeLocalDateStr } from '@/utils/common/time' import { toSafeLocalDateStr } from '@/utils/time'
export default { export default {
name: 'CrontabResult', name: 'CrontabResult',

View File

@@ -39,13 +39,6 @@ export default {
showCron: false showCron: false
} }
}, },
watch: {
value: {
handler(val) {
this.crontabFill(val)
}
}
},
methods: { methods: {
crontabFill(value) { crontabFill(value) {
// 确定后回传的值 // 确定后回传的值

View File

@@ -13,7 +13,7 @@
<script> <script>
import Dialog from '@/components/Dialog/index.vue' import Dialog from '@/components/Dialog/index.vue'
import ListTable from '@/components/Table/ListTable/index.vue' import { DrawerListTable as ListTable } from '@/components'
export default { export default {
name: 'AttrMatchResultDialog', name: 'AttrMatchResultDialog',

View File

@@ -10,7 +10,7 @@
<script> <script>
import BaseFormatter from '@/components/Table/TableFormatters/base.vue' import BaseFormatter from '@/components/Table/TableFormatters/base.vue'
import { setUrlParam } from '@/utils/common/index' import { setUrlParam } from '@/utils/common'
export default { export default {
name: 'ValueFormatter', name: 'ValueFormatter',

View File

@@ -42,9 +42,9 @@ import DataTable from '@/components/Table/DataTable/index.vue'
import ValueFormatter from './ValueFormatter.vue' import ValueFormatter from './ValueFormatter.vue'
import AttrFormDialog from './AttrFormDialog.vue' import AttrFormDialog from './AttrFormDialog.vue'
import AttrMatchResultDialog from './AttrMatchResultDialog.vue' import AttrMatchResultDialog from './AttrMatchResultDialog.vue'
import { setUrlParam } from '@/utils/common/index' import { setUrlParam } from '@/utils/common'
import { attrMatchOptions } from '@/components/const' import { attrMatchOptions } from '@/components/const'
import { toM2MJsonParams } from '@/utils/jms/index' import { toM2MJsonParams } from '@/utils/jms'
export default { export default {
name: 'JSONManyToManySelect', name: 'JSONManyToManySelect',
@@ -109,7 +109,7 @@ export default {
columns: [ columns: [
{ prop: 'name', label: this.$t('AttrName'), formatter: tableFormatter('name') }, { prop: 'name', label: this.$t('AttrName'), formatter: tableFormatter('name') },
{ prop: 'match', label: this.$t('Match'), formatter: tableFormatter('match') }, { prop: 'match', label: this.$t('Match'), formatter: tableFormatter('match') },
{ prop: 'value', label: this.$t('AttrValue'), formatter: ValueFormatter, formatterArgs: { attrs: this.attrs } }, { prop: 'value', label: this.$t('AttrValue'), formatter: ValueFormatter, formatterArgs: { attrs: this.attrs }},
{ {
prop: 'action', prop: 'action',
label: this.$t('Action'), label: this.$t('Action'),

View File

@@ -5,6 +5,7 @@
slot="prepend" slot="prepend"
:placeholder="$tc('Select')" :placeholder="$tc('Select')"
:value="rawValue.code" :value="rawValue.code"
style="width: 105px;"
@change="onChange" @change="onChange"
> >
<el-option <el-option
@@ -46,7 +47,7 @@ export default {
} }
}, },
mounted() { mounted() {
const defaults = { code: this.getDefaultCode(), phone: '' } const defaults = { code: localStorage.getItem('prePhoneCode') || '+86', phone: '' }
this.rawValue = this.value || defaults this.rawValue = this.value || defaults
this.$axios.get('/api/v1/common/countries/').then(res => { this.$axios.get('/api/v1/common/countries/').then(res => {
this.countries = res.map(item => { this.countries = res.map(item => {
@@ -56,22 +57,6 @@ export default {
this.$emit('input', this.fullPhone) this.$emit('input', this.fullPhone)
}, },
methods: { methods: {
getDefaultCode() {
const mapper = {
'zh': '+86',
'en': '+1',
'ja': '+81',
'ko': '+82',
'fr': '+33',
'de': '+49',
'es': '+34',
'it': '+39',
'ru': '+7',
'ar': '+966'
}
const locale = this.$i18n.locale.split('-')[0]
return localStorage.getItem('prePhoneCode') || mapper[locale] || '+86'
},
onChange(countryCode) { onChange(countryCode) {
this.rawValue.code = countryCode this.rawValue.code = countryCode
this.onInputChange() this.onInputChange()
@@ -84,11 +69,7 @@ export default {
} }
</script> </script>
<style lang="scss" scoped> <style scoped>
.el-select {
width: 85px;
}
.country-name { .country-name {
display: inline-block; display: inline-block;
width: 150px; width: 150px;

View File

@@ -3,7 +3,6 @@
v-if="$attrs.visible" v-if="$attrs.visible"
:close-on-click-modal="false" :close-on-click-modal="false"
:destroy-on-close="true" :destroy-on-close="true"
:modal="false"
:show-cancel="false" :show-cancel="false"
:show-confirm="false" :show-confirm="false"
:title="$tc('PlatformProtocolConfig') + '' + protocol.name" :title="$tc('PlatformProtocolConfig') + '' + protocol.name"
@@ -53,7 +52,6 @@ export default {
const vm = this const vm = this
const platform = this.$route.query.platform const platform = this.$route.query.platform
return { return {
platform: '',
loading: true, loading: true,
form: this.protocol, form: this.protocol,
platformDetail: platform ? '#/console/assets/platforms/' + platform : '', platformDetail: platform ? '#/console/assets/platforms/' + platform : '',
@@ -98,29 +96,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: { methods: {
onSubmit(form) { onSubmit(form) {
this.protocol = Object.assign(this.protocol, form) this.protocol = Object.assign(this.protocol, form)
this.$emit('update:visible', false) this.$emit('update:visible', false)
this.$emit('confirm', this.protocol) this.$emit('confirm', this.protocol)
},
openInNewTab() {
window.open(this.platformDetail, '_blank')
} }
} }
} }

View File

@@ -78,18 +78,16 @@ export default {
}, },
data() { data() {
return { return {
filterTags: this.value,
focus: false, focus: false,
filterValue: '', filterValue: '',
filterTags: this.value, isCheckShowPassword: this.replaceShowPassword,
isCheckShowPassword: this.replaceShowPassword component: this.autocomplete ? 'el-autocomplete' : 'el-input'
} }
}, },
computed: { computed: {
iPlaceholder() { iPlaceholder() {
return `${this.placeholder} (${this.$t('EnterToContinue')})` return `${this.placeholder} (${this.$t('EnterToContinue')})`
},
component() {
return this.autocomplete !== null ? 'el-autocomplete' : 'el-input'
} }
}, },
watch: { watch: {
@@ -115,9 +113,8 @@ export default {
if (!this.filterTags.includes(this.filterValue)) { if (!this.filterTags.includes(this.filterValue)) {
this.filterTags.push(this.filterValue) this.filterTags.push(this.filterValue)
this.filterValue = '' this.filterValue = ''
this.$emit('change', this.filterTags)
} }
this.$emit('change', this.filterTags)
this.$emit('input', this.filterTags)
this.$refs.SearchInput.focus() this.$refs.SearchInput.focus()
}, },
handleTagClick(v, k) { handleTagClick(v, k) {
@@ -154,7 +151,7 @@ export default {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: center; align-items: center;
//padding: 0 6px; padding: 1px 2px 1px;
border: 1px solid #dcdee2; border: 1px solid #dcdee2;
border-radius: 1px; border-radius: 1px;
background-color: #fff; background-color: #fff;
@@ -165,9 +162,8 @@ export default {
} }
& ::v-deep .el-tag { & ::v-deep .el-tag {
margin-bottom: 1px; margin-top: 1px;
font-family: sans-serif !important; font-family: sans-serif !important;
margin-left: 5px;
} }
& ::v-deep .el-autocomplete { & ::v-deep .el-autocomplete {
@@ -181,8 +177,7 @@ export default {
& ::v-deep .el-input__inner { & ::v-deep .el-input__inner {
max-width: 100%; max-width: 100%;
border: none; border: none;
padding-left: 12px; padding-left: 10px;
height: 28px;
} }
} }
@@ -192,7 +187,7 @@ export default {
} }
.filter-field ::v-deep .el-input__inner { .filter-field ::v-deep .el-input__inner {
height: 27px !important; height: 28px;
} }
.show-password { .show-password {

View File

@@ -24,7 +24,7 @@
<script> <script>
import Select2 from './Select2.vue' import Select2 from './Select2.vue'
import { hasUUID } from '@/utils/common/index' import { hasUUID } from '@/utils/common'
export default { export default {
components: { components: {

View File

@@ -20,7 +20,7 @@
</template> </template>
<script> <script>
import { randomString } from '@/utils/common/index' import { randomString } from '@/utils/string'
export default { export default {
props: { props: {

View File

@@ -10,9 +10,6 @@
<div> <div>
<img v-if="preview" :class="showBG ? 'show-bg' : ''" :src="preview" v-bind="$attrs" alt=""> <img v-if="preview" :class="showBG ? 'show-bg' : ''" :src="preview" v-bind="$attrs" alt="">
</div> </div>
<el-button v-if="fileName" size="mini" type="danger" @click.native.stop="resetUpload">
{{ this.$t('Cancel') }}
</el-button>
</div> </div>
</template> </template>
@@ -58,29 +55,21 @@ export default {
}, },
Onchange(e) { Onchange(e) {
const upLoadFile = e.target.files[0] const upLoadFile = e.target.files[0]
if (upLoadFile === undefined) { if (upLoadFile === undefined) {
this.$emit('input', this.initial)
return return
} }
this.fileName = upLoadFile?.name || '' this.fileName = upLoadFile?.name || ''
this.$emit('fileChange', upLoadFile) this.$emit('fileChange', upLoadFile)
this.$emit('input', this.getObjectURL(upLoadFile)) this.$emit('input', this.getObjectURL(upLoadFile))
}, },
resetUpload() {
this.fileName = ''
this.preview = ''
this.$refs.upLoadFile.value = ''
this.$emit('input', '')
this.$emit('fileChange', null)
},
getObjectURL(file) { getObjectURL(file) {
let url = null let url = null
if (window.createObjectURL !== undefined) { if (window.createObjectURL !== undefined) { // basic
url = window.createObjectURL(file) url = window.createObjectURL(file)
} else if (window.URL !== undefined) { } else if (window.URL !== undefined) { // mozilla(firefox)
url = window.URL.createObjectURL(file) url = window.URL.createObjectURL(file)
} else if (window.webkitURL !== undefined) { } else if (window.webkitURL !== undefined) { // webkit or chrome
url = window.webkitURL.createObjectURL(file) url = window.webkitURL.createObjectURL(file)
} }
return url return url

View File

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

View File

@@ -1,14 +1,12 @@
<template> <template>
<div ref="formGroup" class="form-group-header"> <div ref="formGroup" class="form-group-header">
<div v-if="line" class="hr-line-dashed" /> <div v-if="line" class="hr-line-dashed" />
<div v-if="group['title']"> <h3 @click="toggle">{{ group['title'] }} </h3>
<h3 @click="toggle">{{ group['title'] }} </h3> <span class="compass" @click="toggle">
<span class="compass" @click="toggle"> <i :class="iconClass" />
<i :class="iconClass" /> </span>
</span>
</div>
<div v-if="!isVisible" class="ellipsis" @click="toggle"> <div v-if="!isVisible" class="ellipsis" @click="toggle">
<i class="fa fa-angle-double-down" /> <i class="el-icon-more-outline" />
</div> </div>
</div> </div>
</template> </template>

View File

@@ -2,8 +2,7 @@
<IBox v-bind="$attrs"> <IBox v-bind="$attrs">
<div v-if="contentHeading" class="ibox-heading"> <div v-if="contentHeading" class="ibox-heading">
<slot name="content-heading"> <slot name="content-heading">
<h3 v-if="contentHeading.title"><i v-if="contentHeading.fa" :class="'fa ' + contentHeading.fa" /> {{ <h3 v-if="contentHeading.title"><i v-if="contentHeading.fa" :class="'fa ' + contentHeading.fa" /> {{ contentHeading.title }}</h3>
contentHeading.title }}</h3>
<small v-if="contentHeading.content"><i class="fa fa-tim" /> {{ contentHeading.content }}</small> <small v-if="contentHeading.content"><i class="fa fa-tim" /> {{ contentHeading.content }}</small>
</slot> </slot>
</div> </div>
@@ -12,8 +11,7 @@
</template> </template>
<script> <script>
import IBox from './index.vue' import IBox from './index'
export default { export default {
name: 'HeadingIBox', name: 'HeadingIBox',
components: { IBox }, components: { IBox },
@@ -27,22 +25,20 @@ export default {
</script> </script>
<style scoped> <style scoped>
.ibox-heading { .ibox-heading {
background-color: #f3f6fb; background-color: #f3f6fb;
border-bottom: none; border-bottom: none;
margin: -15px -20px 20px -20px; margin: -15px -20px 20px -20px;
padding: 20px padding: 20px
} }
.ibox-heading h3 {
.ibox-heading h3 { font-weight: 200;
font-weight: 200; font-size: 24px;
font-size: 24px; margin-top: 5px;
margin-top: 5px; margin-bottom: 10px;
margin-bottom: 10px; line-height: 1.1;
line-height: 1.1; }
} .ibox .el-card__body {
background-color: #f3f6fb;
.ibox .el-card__body { }
background-color: #f3f6fb;
}
</style> </style>

View File

@@ -1,32 +1,34 @@
<template> <template>
<tr> <tr>
<td>{{ getActionTitle(action) }}</td>
<td> <td>
{{ getActionTitle(action) }} <el-popover
<el-tooltip v-if="action.attrs.showTip" :content="action.attrs.tip" :open-delay="500" effect="dark"> :content="action.attrs.tip"
<i class="fa fa-question-circle-o" /> :disabled="!action.attrs.showTip"
</el-tooltip> placement="left-end"
</td> trigger="hover"
<td> >
<span slot="reference"> <span slot="reference">
<component <component
:is="iType" :is="iType"
v-model="action.attrs.model" v-model="action.attrs.model"
:title="label" :title="label"
v-bind="action.attrs" v-bind="action.attrs"
v-on="callbacks" v-on="callbacks"
> >
{{ label }} {{ label }}
</component> </component>
</span> </span>
</el-popover>
</td> </td>
</tr> </tr>
</template> </template>
<script> <script>
import Switcher from '@/components/Form/FormFields/Switcher.vue' import Switcher from '@/components/Form/FormFields/Switcher'
import Select2 from '@/components/Form/FormFields/Select2.vue' import Select2 from '@/components/Form/FormFields/Select2'
import UpdateSelect from '@/components/Form/FormFields/UpdateSelect.vue' import UpdateSelect from '@/components/Form/FormFields/UpdateSelect'
import { toSentenceCase } from '@/utils/common/index' import { toSentenceCase } from '@/utils/common'
class Action { class Action {
constructor() { constructor() {

View File

@@ -9,8 +9,8 @@
</template> </template>
<script> <script>
import IBox from '@/components/Common/IBox/index.vue' import IBox from '@/components/IBox'
import ActionItem from './action.vue' import ActionItem from './action'
// views/users/users/UserDetail/UserInfo.vue 使 // views/users/users/UserDetail/UserInfo.vue 使
export default { export default {

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